[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
gEDA-cvs: gaf.git: branch: master updated (1.5.1-20081221-204-gb1f93c9)
The branch, master has been updated
via b1f93c9c02c3adf719b8b63e1d09669cfd0a201f (commit)
from 6a07d737a32a816f43e1f061409a10e616d7aa2a (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
=========
Summary
=========
gschem/include/prototype.h | 2 +
gschem/lib/system-gschemrc.in | 6 ++--
gschem/src/i_basic.c | 14 +++++++---
gschem/src/rcstrings.c | 6 ++--
gschem/src/x_clipboard.c | 53 +++++++++++++++++++++++++++++++++++++++++
gschem/src/x_window.c | 3 ++
6 files changed, 74 insertions(+), 10 deletions(-)
=================
Commit Messages
=================
commit b1f93c9c02c3adf719b8b63e1d09669cfd0a201f
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Date: Sat Jan 24 17:30:58 2009 +0000
gschem: Update menus for clipboard support.
Make 'Edit' menu items' enabled status reflect the state of the
clipboard & selection.
:100644 100644 ce0c0c0... a1e75b6... M gschem/include/prototype.h
:100644 100644 09fd26a... d98f7b6... M gschem/lib/system-gschemrc.in
:100644 100644 f592c45... cd44e61... M gschem/src/i_basic.c
:100644 100644 2adaf26... 7f4fe00... M gschem/src/rcstrings.c
:100644 100644 27fd436... 1ea8b08... M gschem/src/x_clipboard.c
:100644 100644 861ae93... 0ff901b... M gschem/src/x_window.c
=========
Changes
=========
commit b1f93c9c02c3adf719b8b63e1d09669cfd0a201f
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Date: Sat Jan 24 17:30:58 2009 +0000
gschem: Update menus for clipboard support.
Make 'Edit' menu items' enabled status reflect the state of the
clipboard & selection.
diff --git a/gschem/include/prototype.h b/gschem/include/prototype.h
index ce0c0c0..a1e75b6 100644
--- a/gschem/include/prototype.h
+++ b/gschem/include/prototype.h
@@ -742,6 +742,8 @@ void x_vscrollbar_update(GSCHEM_TOPLEVEL *w_current);
void x_scrollbars_update(GSCHEM_TOPLEVEL *w_current);
void x_basic_warp_cursor(GtkWidget *widget, gint x, gint y);
/* x_clipboard.c */
+void x_clipboard_init (GSCHEM_TOPLEVEL *w_current);
+gboolean x_clipboard_usable (GSCHEM_TOPLEVEL *w_current);
gboolean x_clipboard_set (GSCHEM_TOPLEVEL *w_current, const GList *object_list);
GList *x_clipboard_get (GSCHEM_TOPLEVEL *w_current);
/* x_color.c */
diff --git a/gschem/lib/system-gschemrc.in b/gschem/lib/system-gschemrc.in
index 09fd26a..d98f7b6 100644
--- a/gschem/lib/system-gschemrc.in
+++ b/gschem/lib/system-gschemrc.in
@@ -1424,9 +1424,9 @@
("Redo" edit-redo edit-redo)
("SEPARATOR" no-action no-action)
("Select Mode" edit-select edit-select)
- ("Cut Buffer" buffer-cut1 buffer-cut1)
- ("Copy Buffer" buffer-copy1 buffer-copy1)
- ("Paste Buffer" buffer-paste1-hotkey buffer-paste1-hotkey)
+ ("Cut" clipboard-cut clipboard-cut)
+ ("Copy" clipboard-copy clipboard-copy)
+ ("Paste" clipboard-paste-hotkey clipboard-paste-hotkey)
("SEPARATOR" no-action no-action)
("Edit..." edit-edit edit-edit)
("Edit Text..." edit-text edit-text)
diff --git a/gschem/src/i_basic.c b/gschem/src/i_basic.c
index f592c45..cd44e61 100644
--- a/gschem/src/i_basic.c
+++ b/gschem/src/i_basic.c
@@ -374,11 +374,17 @@ void i_update_menus(GSCHEM_TOPLEVEL *w_current)
g_assert(w_current != NULL);
g_assert(toplevel->page_current != NULL);
+ if (x_clipboard_usable (w_current)) {
+ x_menus_sensitivity(w_current, "Edit/Paste", TRUE);
+ } else {
+ x_menus_sensitivity(w_current, "Edit/Paste", FALSE);
+ }
+
if (o_select_selected (w_current)) {
/* since one or more things are selected, we set these TRUE */
/* These strings should NOT be internationalized */
- x_menus_sensitivity(w_current, "Edit/Cut Buffer", TRUE);
- x_menus_sensitivity(w_current, "Edit/Copy Buffer", TRUE);
+ x_menus_sensitivity(w_current, "Edit/Cut", TRUE);
+ x_menus_sensitivity(w_current, "Edit/Copy", TRUE);
x_menus_sensitivity(w_current, "Edit/Edit...", TRUE);
x_menus_sensitivity(w_current, "Edit/Edit Text...", TRUE);
x_menus_sensitivity(w_current, "Edit/Copy Mode", TRUE);
@@ -424,8 +430,8 @@ void i_update_menus(GSCHEM_TOPLEVEL *w_current)
} else {
/* Nothing is selected, grey these out */
/* These strings should NOT be internationalized */
- x_menus_sensitivity(w_current, "Edit/Cut Buffer", FALSE);
- x_menus_sensitivity(w_current, "Edit/Copy Buffer", FALSE);
+ x_menus_sensitivity(w_current, "Edit/Cut", FALSE);
+ x_menus_sensitivity(w_current, "Edit/Copy", FALSE);
x_menus_sensitivity(w_current, "Edit/Edit...", FALSE);
x_menus_sensitivity(w_current, "Edit/Edit Text...", FALSE);
x_menus_sensitivity(w_current, "Edit/Copy Mode", FALSE);
diff --git a/gschem/src/rcstrings.c b/gschem/src/rcstrings.c
index 2adaf26..7f4fe00 100644
--- a/gschem/src/rcstrings.c
+++ b/gschem/src/rcstrings.c
@@ -19,9 +19,9 @@ _("Edit")
_("Undo")
_("Redo")
_("Select Mode")
-_("Cut Buffer")
-_("Copy Buffer")
-_("Paste Buffer")
+_("Cut")
+_("Copy")
+_("Paste")
_("Edit...")
_("Edit Text...")
_("Copy Mode")
diff --git a/gschem/src/x_clipboard.c b/gschem/src/x_clipboard.c
index 27fd436..1ea8b08 100644
--- a/gschem/src/x_clipboard.c
+++ b/gschem/src/x_clipboard.c
@@ -35,6 +35,19 @@
#define MIME_TYPE_SCHEMATIC "application/x-geda-schematic"
#define CLIP_TYPE_SCHEMATIC 1
+/* \brief Callback for handling system clipboard owner change.
+ * \par Function Description
+ *
+ */
+static void
+clip_handle_owner_change (GtkClipboard *cb, GdkEvent *event,
+ gpointer user_data)
+{
+ GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL *) user_data;
+
+ i_update_menus (w_current);
+}
+
static void
clip_get (GtkClipboard *cb, GtkSelectionData *selection_data,
guint info, gpointer user_data_or_owner)
@@ -61,6 +74,46 @@ clip_clear (GtkClipboard *cb, gpointer user_data_or_owner)
/* Do nothing for now */
}
+/* \brief Initialises system clipboard support
+ * \par Function Description
+ * Registers a signal handler to detect if the clipboard has changed
+ * and update the menu item sensitivity if necessary.
+ */
+void
+x_clipboard_init (GSCHEM_TOPLEVEL *w_current)
+{
+ GtkClipboard *cb = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
+ g_signal_connect (G_OBJECT (cb),
+ "owner-change",
+ G_CALLBACK (clip_handle_owner_change),
+ w_current);
+}
+
+/* \brief Checks if the system clipboard contains schematic data.
+ * \par Function Description
+ * Checks whether the current owner of the system clipboard is
+ * advertising gEDA schematic data.
+ *
+ * \param [in,out] w_current The current GSCHEM_TOPLEVEL.
+ *
+ * \return TRUE if the clipboard has schematic data.
+ */
+gboolean
+x_clipboard_usable (GSCHEM_TOPLEVEL *w_current)
+{
+ GtkClipboard *cb = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
+ GdkAtom *targets;
+ gint ntargets;
+ int i;
+
+ gtk_clipboard_wait_for_targets (cb, &targets, &ntargets);
+ for (i = 0; i < ntargets; i++) {
+ if (strcmp (gdk_atom_name (targets[i]), MIME_TYPE_SCHEMATIC) == 0)
+ return TRUE;
+ }
+ return FALSE;
+}
+
/* \brief Set the contents of the system clipboard.
* \par Function Description
* Set the system clipboard to contain the gschem objects listed in \a
diff --git a/gschem/src/x_window.c b/gschem/src/x_window.c
index 861ae93..0ff901b 100644
--- a/gschem/src/x_window.c
+++ b/gschem/src/x_window.c
@@ -44,6 +44,9 @@ void x_window_setup (GSCHEM_TOPLEVEL *w_current)
/* Initialize the autosave callback */
s_page_autosave_init(toplevel);
+ /* Initialize the clipboard callback */
+ x_clipboard_init (w_current);
+
/* x_window_setup_world() - BEGIN */
toplevel->init_left = -45;
toplevel->init_top = -45;
_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs