[Goodies-commits] r1969 - in xfce4-notes-plugin/trunk: . panel-plugin

Mike Massonnet mmassonnet at xfce.org
Wed Sep 6 00:30:53 CEST 2006


Author: mmassonnet
Date: 2006-09-05 22:30:50 +0000 (Tue, 05 Sep 2006)
New Revision: 1969

Added:
   xfce4-notes-plugin/trunk/panel-plugin/xfce4-popup-notes.c
   xfce4-notes-plugin/trunk/panel-plugin/xfce4-popup-notes.h
Modified:
   xfce4-notes-plugin/trunk/ChangeLog
   xfce4-notes-plugin/trunk/configure.in.in
   xfce4-notes-plugin/trunk/panel-plugin/Makefile.am
   xfce4-notes-plugin/trunk/panel-plugin/notes.c
Log:
	* === Released 1.3.99.1 ===
	* configure.in.in: Tag version 1.3.99.1.
	* panel-plugin/Makefile.am: Add compilation for xfce4-popup-notes.
	* panel-plugin/xfce4-popup-notes.{c,h}: New files, derivated from
	  xfce4-popup-windowlist.
	* panel-plugin/notes.c: Add message receiver for the xfce4-popup-notes
	  source.  Shows/hides the notes when called.
	* panel-plugin/notes-window.c: Use default activation in the rename
	  dialog.

Modified: xfce4-notes-plugin/trunk/ChangeLog
===================================================================
--- xfce4-notes-plugin/trunk/ChangeLog	2006-09-05 20:51:06 UTC (rev 1968)
+++ xfce4-notes-plugin/trunk/ChangeLog	2006-09-05 22:30:50 UTC (rev 1969)
@@ -1,3 +1,13 @@
+2006-09-06  Mike Massonnet <mmassonnet at gmail.com>
+
+	* === Released 1.3.99.1 ===
+	* configure.in.in: Tag version 1.3.99.1.
+	* panel-plugin/Makefile.am: Add compilation for xfce4-popup-notes.
+	* panel-plugin/xfce4-popup-notes.{c,h}: New files, derivated from
+	  xfce4-popup-windowlist.
+	* panel-plugin/notes.c: Add message receiver for the xfce4-popup-notes
+	  source.  Shows/hides the notes when called.
+
 2006-08-30  Mike Massonnet <mmassonnet at gmail.com>
 
 	* panel-plugin/notes.c: Use rc groups.
@@ -12,6 +22,8 @@
 	  panel toggled button against a classic panel button.
 	  Use a simple signal clicked instead of button-press-event for the panel
 	  button.
+	* panel-plugin/notes-window.c: Use default activation in the rename
+	  dialog.
 
 2006-08-14  Mike Massonnet <mmassonnet at gmail.com>
 

Modified: xfce4-notes-plugin/trunk/configure.in.in
===================================================================
--- xfce4-notes-plugin/trunk/configure.in.in	2006-09-05 20:51:06 UTC (rev 1968)
+++ xfce4-notes-plugin/trunk/configure.in.in	2006-09-05 22:30:50 UTC (rev 1969)
@@ -7,7 +7,7 @@
 dnl 2006 Mike Massonnet <mmassonnet at gmail.com>
 dnl
 
-m4_define([xfce4_notes_plugin_version], [1.3.90.2])
+m4_define([xfce4_notes_plugin_version], [1.3.99.1])
 
 AC_INIT([xfce4-notes-plugin], [xfce4_notes_plugin_version()], 
         [mmassonnet at gmail.com])

Modified: xfce4-notes-plugin/trunk/panel-plugin/Makefile.am
===================================================================
--- xfce4-notes-plugin/trunk/panel-plugin/Makefile.am	2006-09-05 20:51:06 UTC (rev 1968)
+++ xfce4-notes-plugin/trunk/panel-plugin/Makefile.am	2006-09-05 22:30:50 UTC (rev 1969)
@@ -1,24 +1,39 @@
+bin_PROGRAMS = xfce4-popup-notes
+
+xfce4_popup_notes_SOURCES =										\
+	xfce4-popup-notes.c											\
+	xfce4-popup-notes.h
+
+xfce4_popup_notes_CFLAGS =										\
+	$(LIBX11_CFLAGS)											\
+	$(GTK_CFLAGS)
+
+xfce4_popup_notes_LDADD =										\
+	$(LIBX11_LDFLAGS)											\
+	$(LIBX11_LIBS)												\
+	$(GTK_LIBS)
+
 plugindir = $(libexecdir)/xfce4/panel-plugins
 plugin_PROGRAMS = xfce4-notes-plugin
 
-xfce4_notes_plugin_SOURCES =						\
-	notes.c								\
-	notes-window.c							\
-	notes-options.c							\
-	notes.h								\
-	notes-window.h							\
+xfce4_notes_plugin_SOURCES =									\
+	notes.c														\
+	notes-window.c												\
+	notes-options.c												\
+	notes.h														\
+	notes-window.h												\
 	notes-options.h
 
-xfce4_notes_plugin_CFLAGS =						\
-	-I$(top_srcdir)							\
-	@LIBXFCE4PANEL_CFLAGS@						\
-	@LIBXFCEGUI4_CFLAGS@						\
-	@LIBXFCE4UTIL_CFLAGS@						\
+xfce4_notes_plugin_CFLAGS =										\
+	-I$(top_srcdir)												\
+	@LIBXFCE4PANEL_CFLAGS@										\
+	@LIBXFCEGUI4_CFLAGS@										\
+	@LIBXFCE4UTIL_CFLAGS@										\
 	-DPACKAGE_LOCALE_DIR=\"$(localedir)\"
 
-xfce4_notes_plugin_LDFLAGS =						\
-	@LIBXFCE4PANEL_LIBS@						\
-	@LIBXFCEGUI4_LIBS@						\
+xfce4_notes_plugin_LDFLAGS =									\
+	@LIBXFCE4PANEL_LIBS@										\
+	@LIBXFCEGUI4_LIBS@											\
 	@LIBXFCE4UTIL_LIBS@					
 
 desktop_in_in_files = xfce4-notes-plugin.desktop.in.in
@@ -28,10 +43,10 @@
 desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
 @INTLTOOL_DESKTOP_RULE@
 
-EXTRA_DIST = 								\
+EXTRA_DIST =													\
 	$(desktop_in_in_files)
 
-DISTCLEANFILES =							\
+DISTCLEANFILES =												\
 	$(desktop_DATA) $(desktop_in_files)
 
 # get full path into .desktop file

Modified: xfce4-notes-plugin/trunk/panel-plugin/notes.c
===================================================================
--- xfce4-notes-plugin/trunk/panel-plugin/notes.c	2006-09-05 20:51:06 UTC (rev 1968)
+++ xfce4-notes-plugin/trunk/panel-plugin/notes.c	2006-09-05 22:30:50 UTC (rev 1969)
@@ -32,21 +32,45 @@
 
 #include "notes.h"
 #include "notes-options.h"
+#include "xfce4-popup-notes.h"
 
 #define PLUGIN_NAME "xfce4-notes-plugin"
 
 
-static void     notes_construct (XfcePanelPlugin *);
-static void     notes_free_data (XfcePanelPlugin *, NotesPlugin *);
-static void     notes_save (XfcePanelPlugin *, NotesPlugin *);
-static gboolean save_on_timeout_execute (NotesPlugin *);
-static void     notes_configure (XfcePanelPlugin *, NotesPlugin *);
-static gboolean notes_set_size (XfcePanelPlugin *, int size, NotesPlugin *);
-static void     notes_load_data (XfcePanelPlugin *, NotesPlugin *);
-static gboolean notes_button_clicked (XfcePanelPlugin *, NotesPlugin *);
-static void     on_options_response (GtkWidget *, int response, NotesPlugin *);
+static void         notes_construct         (XfcePanelPlugin *);
 
+static void         notes_free_data         (XfcePanelPlugin *,
+                                             NotesPlugin *);
 
+static void         notes_save              (XfcePanelPlugin *,
+                                             NotesPlugin *);
+
+static gboolean     save_on_timeout_execute (NotesPlugin *);
+
+static void         notes_configure         (XfcePanelPlugin *, 
+                                             NotesPlugin *);
+
+static gboolean     notes_set_size          (XfcePanelPlugin *, 
+                                             int size, 
+                                             NotesPlugin *);
+
+static void         notes_load_data         (XfcePanelPlugin *, 
+                                             NotesPlugin *);
+
+static gboolean     notes_button_clicked    (XfcePanelPlugin *, 
+                                             NotesPlugin *);
+
+static void         on_options_response     (GtkWidget *,
+                                             int response, 
+                                             NotesPlugin *);
+
+static gboolean     notes_message_received  (GtkWidget *, 
+                                             GdkEventClient *,
+                                             gpointer data);
+
+static gboolean     notes_set_selection     (NotesPlugin *notes);
+
+
 /* Panel Plugin Interface */
 
 XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL (notes_construct);
@@ -222,6 +246,8 @@
 
     notes = notes_new (plugin);
 
+    notes_set_selection (notes);
+
     gtk_container_add (GTK_CONTAINER (plugin), notes->button);
 
     xfce_panel_plugin_add_action_widget (plugin, notes->button);
@@ -371,3 +397,56 @@
 
     notes_save (notes->plugin, notes);
 }
+
+
+/* handle user messages */
+
+static gboolean
+notes_message_received (GtkWidget *widget, GdkEventClient *ev, gpointer data)
+{
+    NotesPlugin *notes;
+
+    notes = data;
+
+    if (ev->data_format == 8 && *(ev->data.b) != '\0')
+      {
+        if (!strcmp (XFCE_NOTES_MESSAGE, ev->data.b))
+            return notes_button_clicked (notes->plugin, notes);
+      }
+
+    return FALSE;
+}
+
+static gboolean
+notes_set_selection (NotesPlugin *notes)
+{
+    GdkScreen *gscreen;
+    gchar selection_name[32];
+    Atom selection_atom;
+    GtkWidget *win;
+    Window xwin;
+
+    win = gtk_invisible_new ();
+    gtk_widget_realize (win);
+    xwin = GDK_WINDOW_XID (GTK_WIDGET (win)->window);
+
+    gscreen = gtk_widget_get_screen (win);
+    g_snprintf (selection_name, sizeof (selection_name),
+                XFCE_NOTES_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);
+        return FALSE;
+      }
+
+    XSelectInput (GDK_DISPLAY (), xwin, PropertyChangeMask);
+    XSetSelectionOwner (GDK_DISPLAY (), selection_atom, xwin, GDK_CURRENT_TIME);
+
+    g_signal_connect (win, "client-event",
+                      G_CALLBACK (notes_message_received), notes);
+
+    return TRUE;
+}
+

Added: xfce4-notes-plugin/trunk/panel-plugin/xfce4-popup-notes.c
===================================================================
--- xfce4-notes-plugin/trunk/panel-plugin/xfce4-popup-notes.c	                        (rev 0)
+++ xfce4-notes-plugin/trunk/panel-plugin/xfce4-popup-notes.c	2006-09-05 22:30:50 UTC (rev 1969)
@@ -0,0 +1,93 @@
+/* $Id$
+ *
+ *  Notes - panel plugin for Xfce Desktop Environment
+ *          popup command to show the notes
+ *  Copyright (C) 2002-2006  Olivier Fourdan
+ *                2006  Mike Massonnet <mmassonnet 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
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <gtk/gtk.h>
+#include <glib.h>
+#include <gdk/gdkx.h>
+#include <X11/Xlib.h>
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#include "xfce4-popup-notes.h"
+
+
+
+static gboolean
+xfce4_check_is_running (GtkWidget *widget, Window *xid)
+{
+    GdkScreen *gscreen;
+    gchar selection_name[32];
+    Atom selection_atom;
+
+    gscreen = gtk_widget_get_screen (widget);
+    g_snprintf (selection_name, 
+                sizeof (selection_name),
+                XFCE_NOTES_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;
+}
+
+int
+main (int argc, char *argv[])
+{
+    GdkEventClient gev;
+    GtkWidget *win;
+    Window id;
+
+    gtk_init (&argc, &argv);
+
+    win = gtk_invisible_new ();
+    gtk_widget_realize (win);
+
+    gev.type = GDK_CLIENT_EVENT;
+    gev.window = win->window;
+    gev.send_event = TRUE;
+    gev.message_type = gdk_atom_intern ("STRING", FALSE);
+    gev.data_format = 8;
+    strcpy (gev.data.b, XFCE_NOTES_MESSAGE);
+
+    if (xfce4_check_is_running (win, &id))
+      {
+        gdk_event_send_client_message ((GdkEvent *)&gev, (GdkNativeWindow)id);
+      }
+    else
+      {
+        g_warning ("Can't find the xfce4-panel notes to popup.\n");
+      }
+    gdk_flush ();
+
+    gtk_widget_destroy (win);
+
+    return FALSE;
+}
+

Added: xfce4-notes-plugin/trunk/panel-plugin/xfce4-popup-notes.h
===================================================================
--- xfce4-notes-plugin/trunk/panel-plugin/xfce4-popup-notes.h	                        (rev 0)
+++ xfce4-notes-plugin/trunk/panel-plugin/xfce4-popup-notes.h	2006-09-05 22:30:50 UTC (rev 1969)
@@ -0,0 +1,40 @@
+/* $Id$
+ *
+ *  Notes - panel plugin for Xfce Desktop Environment
+ *          popup command to show the notes
+ *  Copyright (C) 2002-2006  Olivier Fourdan
+ *                2006  Mike Massonnet <mmassonnet 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
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#ifndef __XFCE4_POPUP_NOTES_H__
+#define __XFCE4_POPUP_NOTES_H__
+
+#ifndef XFCE_NOTES_MESSAGE
+#define XFCE_NOTES_MESSAGE    "xfce4-notes-popup"
+#endif /* XFCE_NOTES_MESSAGE */
+
+#ifndef XFCE_NOTES_SELECTION
+#define XFCE_NOTES_SELECTION  "XFCE_NOTES_SEL"
+#endif /* XFCE_NOTES_SELECTION */
+
+#endif /* __XFCE4_POPUP_NOTES_H__ */
+




More information about the Goodies-commits mailing list