[Xfce4-commits] [panel-plugins/xfce4-clipman-plugin] 13/37: Try to wire up paste on activate

noreply at xfce.org noreply at xfce.org
Mon Mar 23 23:30:08 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 e88a1d195329da0bb6de6b72a89090701f4a7971
Author: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
Date:   Tue Mar 17 22:16:34 2020 +0100

    Try to wire up paste on activate
---
 panel-plugin/menu.c                  | 110 +++++++++++++++++++----------------
 panel-plugin/menu.h                  |   3 +-
 panel-plugin/xfce4-clipman-history.c |  17 +++++-
 3 files changed, 76 insertions(+), 54 deletions(-)

diff --git a/panel-plugin/menu.c b/panel-plugin/menu.c
index 0f24fa7..9891a53 100644
--- a/panel-plugin/menu.c
+++ b/panel-plugin/menu.c
@@ -164,60 +164,68 @@ cb_set_clipboard (GtkMenuItem *mi, const ClipmanHistoryItem *item)
       return;
     }
 
-  {
-    int dummyi;
-    KeySym key_sym;
-    KeyCode key_code;
+  cb_paste_on_activate (GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (mi), "paste-on-activate")));
+}
 
-    Display *display = XOpenDisplay (NULL);
-    if (display == NULL)
-      {
-        return;
-      }
-    else if (!XQueryExtension (display, "XTEST", &dummyi, &dummyi, &dummyi))
-      {
-        XCloseDisplay (display);
-        return;
-      }
+void
+cb_paste_on_activate (guint paste_on_activate)
+{
+  int dummyi;
+  KeySym key_sym;
+  KeyCode key_code;
 
-    switch (GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (mi), "paste-on-activate")))
-      {
-      case PASTE_INACTIVE:
-        break;
-
-      case PASTE_CTRL_V:
-        key_sym = XK_Control_L;
-        key_code = XKeysymToKeycode (display, key_sym);
-        XTestFakeKeyEvent (display, key_code, True, CurrentTime);
-        key_sym = XK_v;
-        key_code = XKeysymToKeycode (display, key_sym);
-        XTestFakeKeyEvent (display, key_code, True, CurrentTime);
-        key_sym = XK_v;
-        key_code = XKeysymToKeycode (display, key_sym);
-        XTestFakeKeyEvent (display, key_code, False, CurrentTime);
-        key_sym = XK_Control_L;
-        key_code = XKeysymToKeycode (display, key_sym);
-        XTestFakeKeyEvent (display, key_code, False, CurrentTime);
-        break;
-
-      case PASTE_SHIFT_INS:
-        key_sym = XK_Shift_L;
-        key_code = XKeysymToKeycode (display, key_sym);
-        XTestFakeKeyEvent (display, key_code, True, CurrentTime);
-        key_sym = XK_Insert;
-        key_code = XKeysymToKeycode (display, key_sym);
-        XTestFakeKeyEvent (display, key_code, True, CurrentTime);
-        key_sym = XK_Insert;
-        key_code = XKeysymToKeycode (display, key_sym);
-        XTestFakeKeyEvent (display, key_code, False, CurrentTime);
-        key_sym = XK_Shift_L;
-        key_code = XKeysymToKeycode (display, key_sym);
-        XTestFakeKeyEvent (display, key_code, False, CurrentTime);
-        break;
-      }
+  g_warning ("paste on activate...");
+
+  Display *display = XOpenDisplay (NULL);
+  if (display == NULL)
+    {
+      return;
+    }
+  else if (!XQueryExtension (display, "XTEST", &dummyi, &dummyi, &dummyi))
+    {
+      XCloseDisplay (display);
+      return;
+    }
+  g_warning ("moving on... %d", paste_on_activate);
+
+  switch (paste_on_activate)
+    {
+    case PASTE_INACTIVE:
+      break;
+
+    case PASTE_CTRL_V:
+      g_warning ("ctrl + v");
+      key_sym = XK_Control_L;
+      key_code = XKeysymToKeycode (display, key_sym);
+      XTestFakeKeyEvent (display, key_code, True, CurrentTime);
+      key_sym = XK_v;
+      key_code = XKeysymToKeycode (display, key_sym);
+      XTestFakeKeyEvent (display, key_code, True, CurrentTime);
+      key_sym = XK_v;
+      key_code = XKeysymToKeycode (display, key_sym);
+      XTestFakeKeyEvent (display, key_code, False, CurrentTime);
+      key_sym = XK_Control_L;
+      key_code = XKeysymToKeycode (display, key_sym);
+      XTestFakeKeyEvent (display, key_code, False, CurrentTime);
+      break;
+
+    case PASTE_SHIFT_INS:
+      key_sym = XK_Shift_L;
+      key_code = XKeysymToKeycode (display, key_sym);
+      XTestFakeKeyEvent (display, key_code, True, CurrentTime);
+      key_sym = XK_Insert;
+      key_code = XKeysymToKeycode (display, key_sym);
+      XTestFakeKeyEvent (display, key_code, True, CurrentTime);
+      key_sym = XK_Insert;
+      key_code = XKeysymToKeycode (display, key_sym);
+      XTestFakeKeyEvent (display, key_code, False, CurrentTime);
+      key_sym = XK_Shift_L;
+      key_code = XKeysymToKeycode (display, key_sym);
+      XTestFakeKeyEvent (display, key_code, False, CurrentTime);
+      break;
+    }
 
-    XCloseDisplay (display);
-  }
+  XCloseDisplay (display);
 }
 
 static void
diff --git a/panel-plugin/menu.h b/panel-plugin/menu.h
index 0444f79..af06c0d 100644
--- a/panel-plugin/menu.h
+++ b/panel-plugin/menu.h
@@ -53,5 +53,6 @@ GType                   clipman_menu_get_type           ();
 
 GtkWidget *             clipman_menu_new                ();
 
-#endif /* !__CLIPMAN_MENU_H__ */
+void                    cb_paste_on_activate            (guint paste_on_activate);
 
+#endif /* !__CLIPMAN_MENU_H__ */
diff --git a/panel-plugin/xfce4-clipman-history.c b/panel-plugin/xfce4-clipman-history.c
index b5d2558..ba46656 100644
--- a/panel-plugin/xfce4-clipman-history.c
+++ b/panel-plugin/xfce4-clipman-history.c
@@ -29,6 +29,7 @@
 #include <libxfce4util/libxfce4util.h>
 #include <x11-clipboard-manager/daemon.h>
 
+#include <menu.h>
 #include <plugin.h>
 #include <history.h>
 
@@ -45,7 +46,7 @@ static void
 clipman_history_row_activated (GtkTreeView       *treeview,
                                GtkTreePath       *path,
                                GtkTreeViewColumn *column,
-                               gpointer           user_data)
+                               MyPlugin          *plugin)
 {
   GtkWidget *window;
   GtkClipboard *clipboard;
@@ -54,6 +55,7 @@ clipman_history_row_activated (GtkTreeView       *treeview,
   GtkTreeIter iter;
   gboolean ret;
   gchar *text;
+  guint paste_on_activate;
 
   ret = gtk_tree_model_get_iter (gtk_tree_view_get_model (treeview), &iter, path);
   if (!ret)
@@ -74,6 +76,17 @@ clipman_history_row_activated (GtkTreeView       *treeview,
   gtk_clipboard_set_text (clipboard, text, -1);
 
   window = gtk_widget_get_toplevel (GTK_WIDGET (treeview));
+
+  g_object_get (G_OBJECT (plugin->menu), "paste-on-activate", &paste_on_activate, NULL);
+  if (paste_on_activate > 0)
+    {
+      g_warning ("close the window and paste.,..");
+      gtk_window_iconify (GTK_WINDOW (window));
+      g_usleep (100000);
+      cb_paste_on_activate (paste_on_activate);
+      //gtk_window_deiconify (GTK_WINDOW (window));
+    }
+
   if (GTK_IS_WINDOW (window))
     gtk_dialog_response (GTK_DIALOG (window), GTK_RESPONSE_CLOSE);
 }
@@ -166,7 +179,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);
+  g_signal_connect (G_OBJECT (treeview), "row-activated", G_CALLBACK (clipman_history_row_activated), plugin);
   gtk_container_add (GTK_CONTAINER (scroll), treeview);
   gtk_widget_show (treeview);
 

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


More information about the Xfce4-commits mailing list