gucharmap r1688 - trunk/gucharmap



Author: chpe
Date: Fri Mar 21 10:56:37 2008
New Revision: 1688
URL: http://svn.gnome.org/viewvc/gucharmap?rev=1688&view=rev

Log:
Make Ctrl-C copy the active character. Bug #477921.


Modified:
   trunk/gucharmap/gucharmap-chartable.c
   trunk/gucharmap/gucharmap-private.h

Modified: trunk/gucharmap/gucharmap-chartable.c
==============================================================================
--- trunk/gucharmap/gucharmap-chartable.c	(original)
+++ trunk/gucharmap/gucharmap-chartable.c	Fri Mar 21 10:56:37 2008
@@ -42,6 +42,8 @@
   ACTIVATE,
   STATUS_MESSAGE,
   MOVE_CURSOR,
+  COPY_CLIPBOARD,
+  PASTE_CLIPBOARD,
   NUM_SIGNALS
 };
 
@@ -1793,6 +1795,31 @@
   return TRUE;
 }
 
+static void
+gucharmap_chartable_copy_clipboard (GucharmapChartable *chartable)
+{
+  GtkClipboard *clipboard;
+  gunichar wc;
+  gchar utf8[7];
+  gsize len;
+
+  wc = gucharmap_chartable_get_active_character (chartable);
+  if (!gucharmap_unichar_validate (wc))
+    return;
+
+  len = g_unichar_to_utf8 (wc, utf8);
+
+  clipboard = gtk_widget_get_clipboard (GTK_WIDGET (chartable),
+                                        GDK_SELECTION_CLIPBOARD);
+  gtk_clipboard_set_text (clipboard, utf8, len);
+}
+
+static void
+gucharmap_chartable_paste_clipboard (GucharmapChartable *chartable)
+{
+  /* FIXMEchpe */
+}
+
 /* does all the initial construction */
 static void
 gucharmap_chartable_init (GucharmapChartable *chartable)
@@ -1944,6 +1971,8 @@
   klass->set_scroll_adjustments = gucharmap_chartable_set_adjustments;
   klass->move_cursor = gucharmap_chartable_move_cursor;
   klass->activate = NULL;
+  klass->copy_clipboard = gucharmap_chartable_copy_clipboard;
+  klass->paste_clipboard = gucharmap_chartable_paste_clipboard;
   klass->set_active_char = NULL;
 
   widget_class->activate_signal = signals[ACTIVATE] =
@@ -1982,6 +2011,24 @@
                   GTK_TYPE_MOVEMENT_STEP,
                   G_TYPE_INT);
 
+  signals[COPY_CLIPBOARD] =
+    g_signal_new (I_("copy-clipboard"),
+                  G_OBJECT_CLASS_TYPE (object_class),
+                  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+                  G_STRUCT_OFFSET (GucharmapChartableClass, copy_clipboard),
+                  NULL, NULL,
+                  g_cclosure_marshal_VOID__VOID,
+                  G_TYPE_NONE, 0);
+
+  signals[PASTE_CLIPBOARD] =
+    g_signal_new (I_("paste-clipboard"),
+                  G_OBJECT_CLASS_TYPE (object_class),
+                  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+                  G_STRUCT_OFFSET (GucharmapChartableClass, paste_clipboard),
+                  NULL, NULL,
+                  g_cclosure_marshal_VOID__VOID,
+                  G_TYPE_NONE, 0);
+
   /* Not using g_param_spec_unichar on purpose, since it disallows certain values
    * we want (it's performing a g_unichar_validate).
    */
@@ -2097,6 +2144,16 @@
   gtk_binding_entry_add_signal (binding_set, GDK_space, 0,
                                 "activate", 0);
 
+  /* Clipboard actions */
+  gtk_binding_entry_add_signal (binding_set, GDK_c, GDK_CONTROL_MASK,
+                                "copy-clipboard", 0);
+  gtk_binding_entry_add_signal (binding_set, GDK_Insert, GDK_CONTROL_MASK,
+                                "copy-clipboard", 0);
+  gtk_binding_entry_add_signal (binding_set, GDK_v, GDK_CONTROL_MASK,
+                                "paste-clipboard", 0);
+  gtk_binding_entry_add_signal (binding_set, GDK_Insert, GDK_SHIFT_MASK,
+                                "paste-clipboard", 0);
+
 #if 0
   /* VI keybindings */
   gucharmap_chartable_add_move_binding (binding_set, GDK_k, 0,

Modified: trunk/gucharmap/gucharmap-private.h
==============================================================================
--- trunk/gucharmap/gucharmap-private.h	(original)
+++ trunk/gucharmap/gucharmap-private.h	Fri Mar 21 10:56:37 2008
@@ -187,6 +187,8 @@
                                       GtkMovementStep     step,
                                       gint                count);
   void (* activate) (GucharmapChartable *chartable);
+  void (* copy_clipboard) (GucharmapChartable *chartable);
+  void (* paste_clipboard) (GucharmapChartable *chartable);
 
   void (* set_active_char) (GucharmapChartable *chartable, guint ch);
   void (* status_message) (GucharmapChartable *chartable, const gchar *message);



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