[Xfce4-commits] [panel-plugins/xfce4-clipman-plugin] 03/37: Wire up the row-activated signal

noreply at xfce.org noreply at xfce.org
Mon Mar 23 23:29:58 CET 2020


This is an automated email from the git hooks/post-receive script.

o   c   h   o   s   i       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository panel-plugins/xfce4-clipman-plugin.

commit 1e5e1e6502922f817403ad219fa652665a9426a5
Author: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
Date:   Mon Mar 16 01:29:10 2020 +0100

    Wire up the row-activated signal
---
 panel-plugin/xfce4-clipman-history.c | 37 +++++++++++++++++++++++++++++++++---
 1 file changed, 34 insertions(+), 3 deletions(-)

diff --git a/panel-plugin/xfce4-clipman-history.c b/panel-plugin/xfce4-clipman-history.c
index 970cd3e..e6ea4aa 100644
--- a/panel-plugin/xfce4-clipman-history.c
+++ b/panel-plugin/xfce4-clipman-history.c
@@ -40,6 +40,38 @@ enum
 };
 
 
+static void
+clipman_history_row_activated (GtkTreeView       *treeview,
+                               GtkTreePath       *path,
+                               GtkTreeViewColumn *column,
+                               gpointer           user_data)
+{
+  GtkClipboard *clipboard;
+  GtkTreeSelection *selection;
+  GtkTreeModel *model;
+  GtkTreeIter iter;
+  gboolean ret;
+  gchar *text;
+
+  ret = gtk_tree_model_get_iter (gtk_tree_view_get_model (treeview), &iter, path);
+  if (!ret)
+    return;
+
+  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
+  if (!gtk_tree_selection_get_selected (selection, &model, &iter))
+    return;
+
+  gtk_tree_model_get (model, &iter,
+                      COLUMN_TEXT, &text,
+                      -1);
+
+  clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
+  gtk_clipboard_set_text (clipboard, text, -1);
+
+  clipboard = gtk_clipboard_get (GDK_SELECTION_PRIMARY);
+  gtk_clipboard_set_text (clipboard, text, -1);
+}
+
 static gboolean
 clipman_history_visible_func (GtkTreeModel *model,
                               GtkTreeIter  *iter,
@@ -128,6 +160,7 @@ clipman_history_treeview_init (MyPlugin *plugin)
   gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE);
   gtk_tree_view_set_enable_search (GTK_TREE_VIEW (treeview), FALSE);
   g_signal_connect_swapped (G_OBJECT (treeview), "start-interactive-search", G_CALLBACK (gtk_widget_grab_focus), entry);
+  g_signal_connect (G_OBJECT (treeview), "row-activated", G_CALLBACK (clipman_history_row_activated), NULL);
   gtk_container_add (GTK_CONTAINER (scroll), treeview);
   gtk_widget_show (treeview);
 
@@ -148,8 +181,6 @@ clipman_history_treeview_init (MyPlugin *plugin)
   list = clipman_history_get_list (plugin->history);
   //list = g_slist_reverse (list);
 
-  if (list != NULL)
-    g_warning ("startin the loop");
   for (l = list, i = 0; l != NULL; l = l->next, i++)
     {
       item = l->data;
@@ -157,7 +188,7 @@ clipman_history_treeview_init (MyPlugin *plugin)
       switch (item->type)
         {
         case CLIPMAN_HISTORY_TYPE_TEXT:
-          gtk_list_store_insert_with_values (liststore, &iter, i, COLUMN_TEXT, item->preview.text, -1);
+          gtk_list_store_insert_with_values (liststore, &iter, i, COLUMN_TEXT, item->content.text, -1);
           break;
 
         case CLIPMAN_HISTORY_TYPE_IMAGE:

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list