[Goodies-commits] r3356 - xfce4-notes-plugin/trunk/panel-plugin

Mike Massonnet mmassonnet at xfce.org
Thu Oct 11 00:03:01 CEST 2007


Author: mmassonnet
Date: 2007-10-10 22:03:01 +0000 (Wed, 10 Oct 2007)
New Revision: 3356

Modified:
   xfce4-notes-plugin/trunk/panel-plugin/panel-plugin.c
   xfce4-notes-plugin/trunk/panel-plugin/xfce4-popup-notes.c
   xfce4-notes-plugin/trunk/panel-plugin/xfce4-popup-notes.h
Log:
	* panel-plugin/panel-plugin.c(notes_plugin_message_received),
	  panel-plugin/xfce4-popup-notes.c(main),
	  panel-plugin/xfce4-popup-notes.h: New GOption interface for the
	  xfce4-popup-notes command.  Possibility to show the menu, or to
	  show/hide all windows.


Modified: xfce4-notes-plugin/trunk/panel-plugin/panel-plugin.c
===================================================================
--- xfce4-notes-plugin/trunk/panel-plugin/panel-plugin.c	2007-10-10 22:02:53 UTC (rev 3355)
+++ xfce4-notes-plugin/trunk/panel-plugin/panel-plugin.c	2007-10-10 22:03:01 UTC (rev 3356)
@@ -415,12 +415,16 @@
   if (G_LIKELY (ev->data_format == 8 && *(ev->data.b) != '\0'))
     {
       DBG ("`%s'", ev->data.b);
-      if (!g_ascii_strcasecmp (XFCE_NOTES_MESSAGE, ev->data.b))
+      if (!g_ascii_strcasecmp (NOTES_MSG_SHOW_HIDE, ev->data.b))
         {
           notes_plugin_show_hide_windows (notes_plugin);
-          /*GdkEventButton ev_btn;
+          return TRUE;
+        }
+      else if (!g_ascii_strcasecmp (NOTES_MSG_MENU, ev->data.b))
+        {
+          GdkEventButton ev_btn;
           ev_btn.button = 1;
-          notes_plugin_button_pressed (notes_plugin, &ev_btn);*/
+          notes_plugin_button_pressed (notes_plugin, &ev_btn);
           return TRUE;
         }
     }

Modified: xfce4-notes-plugin/trunk/panel-plugin/xfce4-popup-notes.c
===================================================================
--- xfce4-notes-plugin/trunk/panel-plugin/xfce4-popup-notes.c	2007-10-10 22:02:53 UTC (rev 3355)
+++ xfce4-notes-plugin/trunk/panel-plugin/xfce4-popup-notes.c	2007-10-10 22:03:01 UTC (rev 3356)
@@ -57,7 +57,37 @@
   GdkEventClient        gev;
   GtkWidget            *win;
   Window                id;
+  gchar                *message = NULL;
 
+  gboolean              opt_show_hide = FALSE;
+  gboolean              opt_menu = FALSE;
+  GError               *opt_error = NULL;
+
+  GOptionContext *context =
+    g_option_context_new ("- command the Xfce 4 notes plugin");
+  GOptionEntry entries[] = 
+    {
+      { "show-hide", 0, 0, G_OPTION_ARG_NONE, &opt_show_hide,
+        "Default action that show/hide all the windows", NULL },
+      { "menu", 'm', 0, G_OPTION_ARG_NONE, &opt_menu,
+        "Popup the menu from the panel button", NULL },
+      { NULL }
+    };
+
+  g_option_context_set_summary (context, "The default action is to show/hide all windows");
+  g_option_context_add_main_entries (context, entries, NULL);
+  if (G_LIKELY (! g_option_context_parse (context, &argc, &argv, &opt_error)))
+    {
+      g_printerr ("%s\n", opt_error->message);
+      g_error_free (opt_error);
+      return -1;
+    }
+
+  if (opt_menu)
+    message = g_strdup_printf (NOTES_MSG_MENU);
+  else
+    message = g_strdup_printf (NOTES_MSG_SHOW_HIDE);
+
   gtk_init (&argc, &argv);
 
   win = gtk_invisible_new ();
@@ -68,7 +98,7 @@
   gev.send_event        = TRUE;
   gev.message_type      = gdk_atom_intern ("STRING", FALSE);
   gev.data_format       = 8;
-  g_snprintf (gev.data.b, sizeof (gev.data.b), XFCE_NOTES_MESSAGE);
+  g_snprintf (gev.data.b, sizeof (gev.data.b), message);
 
   if (notes_plugin_check_is_running (win, &id))
     gdk_event_send_client_message ((GdkEvent *)&gev, (GdkNativeWindow)id);

Modified: xfce4-notes-plugin/trunk/panel-plugin/xfce4-popup-notes.h
===================================================================
--- xfce4-notes-plugin/trunk/panel-plugin/xfce4-popup-notes.h	2007-10-10 22:02:53 UTC (rev 3355)
+++ xfce4-notes-plugin/trunk/panel-plugin/xfce4-popup-notes.h	2007-10-10 22:03:01 UTC (rev 3356)
@@ -23,13 +23,21 @@
 #ifndef __XFCE4_POPUP_NOTES_H__
 #define __XFCE4_POPUP_NOTES_H__
 
-#ifndef XFCE_NOTES_MESSAGE
-#define XFCE_NOTES_MESSAGE    "xfce4-popup-notes"
+#ifndef XFCE_NOTES_SELECTION
+#define XFCE_NOTES_SELECTION    "XFCE_NOTES_SELECTION"
 #endif
 
-#ifndef XFCE_NOTES_SELECTION
-#define XFCE_NOTES_SELECTION  "XFCE_NOTES_SELECTION"
+#ifndef NOTES_MSG_SHOW_HIDE
+#define NOTES_MSG_SHOW_HIDE     "SHOW_HIDE"
 #endif
 
+#ifndef NOTES_MSG_MENU
+#define NOTES_MSG_MENU          "MENU"
 #endif
 
+#ifndef NOTES_MSG_WINDOW
+#define NOTES_MSG_WINDOW        "WIN"
+#endif
+
+#endif
+




More information about the Goodies-commits mailing list