[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-cvs: pcb.git: branch: master updated (08805bad16c623f5e1a1878f19ec085d306faec7)



The branch, master has been updated
       via  08805bad16c623f5e1a1878f19ec085d306faec7 (commit)
      from  8611315f3670050fd350fb8987502aecc3acb3f2 (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
=========

 src/hid/gtk/gui-library-window.c |   49 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 49 insertions(+), 0 deletions(-)


=================
 Commit Messages
=================

commit 08805bad16c623f5e1a1878f19ec085d306faec7
Author: Krzysztof Kosciuszkiewicz <k.kosciuszkiewicz@xxxxxxxxx>
Commit: Krzysztof KoÅ?ciuszkiewicz <k.kosciuszkiewicz@xxxxxxxxx>

    hid/gtk: handle CTRL-C in library window
    
    Handle CTRL-C keypress in library window and copy name of the selected
    component into the default GTK clipboard.
    
    The change facilitates workflow where one browses footprints in pcb and
    copies component names into gattrib or gschem.

:100644 100644 eb366ba... b101576... M	src/hid/gtk/gui-library-window.c

=========
 Changes
=========

commit 08805bad16c623f5e1a1878f19ec085d306faec7
Author: Krzysztof Kosciuszkiewicz <k.kosciuszkiewicz@xxxxxxxxx>
Commit: Krzysztof KoÅ?ciuszkiewicz <k.kosciuszkiewicz@xxxxxxxxx>

    hid/gtk: handle CTRL-C in library window
    
    Handle CTRL-C keypress in library window and copy name of the selected
    component into the default GTK clipboard.
    
    The change facilitates workflow where one browses footprints in pcb and
    copies component names into gattrib or gschem.

diff --git a/src/hid/gtk/gui-library-window.c b/src/hid/gtk/gui-library-window.c
index eb366ba..b101576 100644
--- a/src/hid/gtk/gui-library-window.c
+++ b/src/hid/gtk/gui-library-window.c
@@ -63,6 +63,8 @@
 #include "data.h"
 #include "set.h"
 
+#include <gdk/gdkkeysyms.h>
+
 #ifdef HAVE_LIBDMALLOC
 #include <dmalloc.h>
 #endif
@@ -304,6 +306,48 @@ tree_row_activated (GtkTreeView       *tree_view,
     gtk_tree_view_expand_row (tree_view, path, FALSE);
 }
 
+/*! \brief Handles CTRL-C keypress in the TreeView
+ *  \par Function Description
+ *  Keypress activation handler:
+ *  If CTRL-C is pressed, copy footprint name into the clipboard.
+ *
+ *  \param [in] tree_view The component treeview.
+ *  \param [in] event     The GdkEventKey with keypress info.
+ *  \param [in] user_data Not used.
+ *  \return TRUE if CTRL-C event was handled, FALSE otherwise.
+ */
+static gboolean
+tree_row_key_pressed (GtkTreeView *tree_view,
+                      GdkEventKey *event,
+                      gpointer     user_data)
+{
+  GtkTreeSelection *selection;
+  GtkTreeModel *model;
+  GtkTreeIter iter;
+  GtkClipboard *clipboard;
+  const gchar *compname;
+  guint default_mod_mask = gtk_accelerator_get_default_mod_mask();
+
+  /* Handle both lower- and uppercase `c' */
+  if (((event->state & default_mod_mask) != GDK_CONTROL_MASK)
+      || ((event->keyval != GDK_c) && (event->keyval != GDK_C)))
+    return FALSE;
+
+  selection = gtk_tree_view_get_selection (tree_view);
+  g_return_val_if_fail (selection != NULL, TRUE);
+
+  if (!gtk_tree_selection_get_selected (selection, &model, &iter))
+    return TRUE;
+
+  gtk_tree_model_get (model, &iter, MENU_NAME_COLUMN, &compname, -1);
+
+  clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
+  g_return_val_if_fail (clipboard != NULL, TRUE);
+
+  gtk_clipboard_set_text (clipboard, compname, -1);
+
+  return TRUE;
+}
 
 /*! \brief Handles changes in the treeview selection.
  *  \par Function Description
@@ -606,6 +650,11 @@ create_lib_treeview (GhidLibraryWindow * library_window)
                     G_CALLBACK (tree_row_activated),
                     NULL);
 
+  g_signal_connect (libtreeview,
+                    "key-press-event",
+                    G_CALLBACK (tree_row_key_pressed),
+                    NULL);
+
   /* connect callback to selection */
   selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (libtreeview));
   gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);



_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs