[Goodies-commits] r3690 - in xfce4-places-plugin/trunk: panel-plugin po

Diego Ongaro ongardie at xfce.org
Mon Dec 10 07:56:47 CET 2007


Author: ongardie
Date: 2007-12-10 06:56:47 +0000 (Mon, 10 Dec 2007)
New Revision: 3690

Modified:
   xfce4-places-plugin/trunk/panel-plugin/view.c
   xfce4-places-plugin/trunk/panel-plugin/xfce4-popup-places.c
   xfce4-places-plugin/trunk/panel-plugin/xfce4-popup-places.h
   xfce4-places-plugin/trunk/po/POTFILES.in
Log:
Iterated on popup command code


Modified: xfce4-places-plugin/trunk/panel-plugin/view.c
===================================================================
--- xfce4-places-plugin/trunk/panel-plugin/view.c	2007-12-10 05:49:29 UTC (rev 3689)
+++ xfce4-places-plugin/trunk/panel-plugin/view.c	2007-12-10 06:56:47 UTC (rev 3690)
@@ -18,6 +18,12 @@
  *     launcher.c - (xfce4-panel plugin that opens programs)
  *     Copyright (c) 2005-2007 Jasper Huijsmans <jasper at xfce.org>
  *     Copyright (c) 2006-2007 Nick Schermer <nick at xfce.org>
+ * 
+ *  Popup command code adapted from:
+ *   - windowlist plugin
+ *     windowlist.c - (xfce4-panel plugin that lists open windows)
+ *     Copyright (c) 2002-2006  Olivier Fourdan
+ *     Copyright (c) 2007       Mike Massonnet <mmassonnet at xfce.com>
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -931,54 +937,48 @@
 
 /********** Handle user message **********/
 static gboolean
-places_view_plugin_message_received (GtkWidget *widget,
+pview_popup_command_message_received(GtkWidget *widget,
                                      GdkEventClient *ev,
-                                     gpointer user_data)
+                                     PlacesView *view)
 {
-    PlacesView *view = user_data;
-
-    DBG ("Message received");
     if (G_LIKELY (ev->data_format == 8 && *(ev->data.b) != '\0'
                   && !g_ascii_strcasecmp (PLACES_MSG_MENU, ev->data.b))){
-        DBG ("`%s'", ev->data.b);
-        GdkEventButton ev_btn;
-        ev_btn.button = 1;
+        DBG ("Message received: '%s'", ev->data.b);
+
         pview_open_menu (view);
         return TRUE;
     }
 
-  return FALSE;
+    DBG("Bad message received");
+    return FALSE;
 }
 
 static gboolean
-places_view_plugin_set_selection (PlacesView *view)
+pview_popup_command_set_selection(PlacesView *view)
 {
     GdkScreen          *gscreen;
-    gchar              *selection_name;
+    gchar               selection_name[256];
     Atom                selection_atom;
-    GtkWidget          *win;
     Window              id;
 
-    win = gtk_invisible_new ();
-    gtk_widget_realize (win);
-    id = GDK_WINDOW_XID (GTK_WIDGET (win)->window);
+    id = GDK_WINDOW_XID (GTK_WIDGET (view->plugin)->window);
 
-    gscreen = gtk_widget_get_screen (win);
-    selection_name = g_strdup_printf (XFCE_PLACES_SELECTION"%d",
-                                      gdk_screen_get_number (gscreen));
+    gscreen = gtk_widget_get_screen (GTK_WIDGET(view->plugin));
+
+    g_snprintf (selection_name, 256,
+                XFCE_PLACES_SELECTION"%d",
+                gdk_screen_get_number (gscreen));
+    
     selection_atom = XInternAtom (GDK_DISPLAY (), selection_name, FALSE);
 
-    if (XGetSelectionOwner (GDK_DISPLAY (), selection_atom)){
-        gtk_widget_destroy (win);
+    if (XGetSelectionOwner (GDK_DISPLAY (), selection_atom))
         return FALSE;
-    }
 
-    XSelectInput (GDK_DISPLAY (), id, PropertyChangeMask);
     XSetSelectionOwner (GDK_DISPLAY (), selection_atom, id, GDK_CURRENT_TIME);
 
-    g_signal_connect (win,
+    g_signal_connect (GTK_WIDGET(view->plugin),
                       "client-event",
-                      G_CALLBACK (places_view_plugin_message_received),
+                      G_CALLBACK (pview_popup_command_message_received),
                       view);
 
     return TRUE;
@@ -1057,10 +1057,11 @@
                              G_CALLBACK(places_cfg_view_iface_save), view->cfg_iface);
     xfce_panel_plugin_menu_show_configure(view->plugin);
 
+    /* set selection for xfce4-popup-places */
+    pview_popup_command_set_selection(view);
+
     DBG("done");
 
-    places_view_plugin_set_selection (view);
-
     return view;
 }
 

Modified: xfce4-places-plugin/trunk/panel-plugin/xfce4-popup-places.c
===================================================================
--- xfce4-places-plugin/trunk/panel-plugin/xfce4-popup-places.c	2007-12-10 05:49:29 UTC (rev 3689)
+++ xfce4-places-plugin/trunk/panel-plugin/xfce4-popup-places.c	2007-12-10 06:56:47 UTC (rev 3690)
@@ -2,8 +2,11 @@
  *
  *  Places - panel plugin for Xfce Desktop Environment
  *           popup command
+ *  Adapted from xfce4-panel's windowlist plugin
+ *
  *  Copyright (C) 2002-2006  Olivier Fourdan
  *                2007       Mike Massonnet <mmassonnet at xfce.com>
+ *                2007       Diego Ongaro <ongardie at gmail.com>
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -37,18 +40,20 @@
                          Window *xid)
 {
     GdkScreen          *gscreen;
-    gchar              *selection_name;
+    gchar               selection_name[256];
     Atom                selection_atom;
 
     gscreen = gtk_widget_get_screen (widget);
-    selection_name = g_strdup_printf (XFCE_PLACES_SELECTION"%d",
-                                      gdk_screen_get_number (gscreen));
+    
+    g_snprintf (selection_name, 256,
+                XFCE_PLACES_SELECTION"%d",
+                gdk_screen_get_number (gscreen));
     selection_atom = XInternAtom (GDK_DISPLAY (), selection_name, FALSE);
 
     if ((*xid = XGetSelectionOwner (GDK_DISPLAY (), selection_atom)))
         return TRUE;
-
-    return FALSE;
+    else
+        return FALSE;
 }
 
 gint
@@ -83,3 +88,4 @@
     return FALSE;
 }
 
+/* vim: set ai et tabstop=4: */

Modified: xfce4-places-plugin/trunk/panel-plugin/xfce4-popup-places.h
===================================================================
--- xfce4-places-plugin/trunk/panel-plugin/xfce4-popup-places.h	2007-12-10 05:49:29 UTC (rev 3689)
+++ xfce4-places-plugin/trunk/panel-plugin/xfce4-popup-places.h	2007-12-10 06:56:47 UTC (rev 3690)
@@ -2,8 +2,11 @@
  *
  *  Places - panel plugin for Xfce Desktop Environment
  *           popup command
+ *  Adapted from xfce4-panel's windowlist plugin
+ *
  *  Copyright (C) 2002-2006  Olivier Fourdan
  *                2007       Mike Massonnet <mmassonnet at gmail.com>
+ *                2007       Diego Ongaro <ongardie at gmail.com>
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -23,13 +26,10 @@
 #ifndef __XFCE4_POPUP_PLACES_H__
 #define __XFCE4_POPUP_PLACES_H__
 
-#ifndef XFCE_PLACES_SELECTION
 #define XFCE_PLACES_SELECTION   "XFCE_PLACES_SELECTION"
-#endif
 
-#ifndef PLACES_MSG_MENU
 #define PLACES_MSG_MENU         "MENU"
-#endif
 
 #endif
 
+/* vim: set ai et tabstop=4: */

Modified: xfce4-places-plugin/trunk/po/POTFILES.in
===================================================================
--- xfce4-places-plugin/trunk/po/POTFILES.in	2007-12-10 05:49:29 UTC (rev 3689)
+++ xfce4-places-plugin/trunk/po/POTFILES.in	2007-12-10 06:56:47 UTC (rev 3690)
@@ -15,3 +15,5 @@
 panel-plugin/cfg.h
 panel-plugin/support.c
 panel-plugin/support.h
+panel-plugin/xfce4-popup-places.c
+panel-plugin/xfce4-popup-places.h




More information about the Goodies-commits mailing list