[Goodies-commits] r7508 - in xfce4-notes-plugin/trunk: . panel-plugin
Mike Massonnet
mmassonnet at xfce.org
Tue Jun 9 12:54:21 CEST 2009
Author: mmassonnet
Date: 2009-06-09 10:54:21 +0000 (Tue, 09 Jun 2009)
New Revision: 7508
Added:
xfce4-notes-plugin/trunk/panel-plugin/popup.c
xfce4-notes-plugin/trunk/panel-plugin/popup.h
xfce4-notes-plugin/trunk/panel-plugin/popup.vapi
Removed:
xfce4-notes-plugin/trunk/panel-plugin/notes.c
xfce4-notes-plugin/trunk/panel-plugin/notes.h
xfce4-notes-plugin/trunk/panel-plugin/panel-plugin.c
xfce4-notes-plugin/trunk/panel-plugin/xfce-arrow-button.c
xfce4-notes-plugin/trunk/panel-plugin/xfce-arrow-button.h
xfce4-notes-plugin/trunk/panel-plugin/xfce4-popup-notes.h
Modified:
xfce4-notes-plugin/trunk/ChangeLog
xfce4-notes-plugin/trunk/panel-plugin/Makefile.am
xfce4-notes-plugin/trunk/panel-plugin/main.vala
xfce4-notes-plugin/trunk/panel-plugin/xfce4-popup-notes.c
Log:
Restore popup command
Modified: xfce4-notes-plugin/trunk/ChangeLog
===================================================================
--- xfce4-notes-plugin/trunk/ChangeLog 2009-06-09 06:49:44 UTC (rev 7507)
+++ xfce4-notes-plugin/trunk/ChangeLog 2009-06-09 10:54:21 UTC (rev 7508)
@@ -1,3 +1,7 @@
+2009-06-09 Mike Massonnet <mmassonnet at xfce.org>
+
+Restore popup command
+
2009-06-07 Mike Massonnet <mmassonnet at xfce.org>
Window show/hide behavior and initial background
Modified: xfce4-notes-plugin/trunk/panel-plugin/Makefile.am
===================================================================
--- xfce4-notes-plugin/trunk/panel-plugin/Makefile.am 2009-06-09 06:49:44 UTC (rev 7507)
+++ xfce4-notes-plugin/trunk/panel-plugin/Makefile.am 2009-06-09 10:54:21 UTC (rev 7508)
@@ -4,8 +4,8 @@
bin_PROGRAMS = xfce4-popup-notes
xfce4_popup_notes_SOURCES = \
- xfce4-popup-notes.c \
- xfce4-popup-notes.h
+ popup.h \
+ xfce4-popup-notes.c
xfce4_popup_notes_CFLAGS = \
@LIBX11_CFLAGS@ \
@@ -51,7 +51,7 @@
BUILT_SOURCES = vala.stamp
vala.stamp: $(xfce4_notes_plugin_VALASOURCES)
- $(VALAC) --vapidir=. --pkg=config --pkg=color --pkg=libxfconf-0 --pkg=libxfce4panel-1.0 $^ -C
+ $(VALAC) --vapidir=. --pkg=config --pkg=color --pkg=popup --pkg=libxfconf-0 --pkg=libxfce4panel-1.0 $^ -C
touch $@
endif
@@ -64,6 +64,8 @@
xfce4_notes_plugin_SOURCES = \
color.c \
color.h \
+ popup.c \
+ popup.h \
xfce4_notes_plugin_SOURCES += $(vala_built_SOURCES)
xfce4_notes_plugin_CFLAGS = \
Modified: xfce4-notes-plugin/trunk/panel-plugin/main.vala
===================================================================
--- xfce4-notes-plugin/trunk/panel-plugin/main.vala 2009-06-09 06:49:44 UTC (rev 7507)
+++ xfce4-notes-plugin/trunk/panel-plugin/main.vala 2009-06-09 10:54:21 UTC (rev 7508)
@@ -24,6 +24,7 @@
public class NotesPlugin : GLib.Object {
+ private Gtk.Invisible invisible;
private Gtk.Button button;
private Gtk.Image image;
private Xfce.PanelPlugin panel_plugin;
@@ -71,8 +72,18 @@
* Set an X selection to listen to for the popup command.
*/
private bool set_x_selection () {
- // TODO
- return false;
+ invisible = new Gtk.Invisible ();
+ if (!Xnp.Popup.set_x_selection (invisible)) {
+ return false;
+ }
+ invisible.client_event += (w, event) => {
+ if (Xnp.Popup.get_message_from_event (event) == "SHOW_HIDE") {
+ application.show_hide_notes ();
+ return true;
+ }
+ return false;
+ };
+ return true;
}
Added: xfce4-notes-plugin/trunk/panel-plugin/popup.c
===================================================================
--- xfce4-notes-plugin/trunk/panel-plugin/popup.c (rev 0)
+++ xfce4-notes-plugin/trunk/panel-plugin/popup.c 2009-06-09 10:54:21 UTC (rev 7508)
@@ -0,0 +1,58 @@
+/*
+ * Notes - panel plugin for Xfce Desktop Environment
+ * Copyright (C) 2002-2006 Olivier Fourdan
+ * Copyright (C) 2009 Mike Massonnet <mmassonnet at xfce.org>
+ *
+ * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include <X11/Xlib.h>
+#include <gdk/gdkx.h>
+#include <gtk/gtk.h>
+
+#include "popup.h"
+
+gboolean popup_set_x_selection (GtkWidget *widget) {
+ GdkScreen *screen;
+ gchar *selection_name;
+ Atom selection_atom;
+ Window id;
+ Display *display;
+
+ gtk_widget_realize (widget);
+ id = GDK_WINDOW_XID (widget->window);
+
+ display = GDK_DISPLAY ();
+ screen = gtk_widget_get_screen (widget);
+ selection_name = g_strdup_printf (XFCE_NOTES_SELECTION"%d", gdk_screen_get_number (screen));
+ selection_atom = XInternAtom (display, selection_name, FALSE);
+
+ if (XGetSelectionOwner (display, selection_atom)) {
+ return FALSE;
+ }
+
+ XSelectInput (display, id, PropertyChangeMask);
+ XSetSelectionOwner (display, selection_atom, id, GDK_CURRENT_TIME);
+
+ return TRUE;
+}
+
+const gchar* popup_get_message_from_event (GdkEventClient *event) {
+ if (G_LIKELY (event->data_format == 8 && *(event->data.b) != '\0')) {
+ return event->data.b;
+ }
+ return NULL;
+}
+
Added: xfce4-notes-plugin/trunk/panel-plugin/popup.h
===================================================================
--- xfce4-notes-plugin/trunk/panel-plugin/popup.h (rev 0)
+++ xfce4-notes-plugin/trunk/panel-plugin/popup.h 2009-06-09 10:54:21 UTC (rev 7508)
@@ -0,0 +1,32 @@
+/*
+ * Notes - panel plugin for Xfce Desktop Environment
+ * Copyright (C) 2002-2006 Olivier Fourdan
+ * Copyright (C) 2009 Mike Massonnet <mmassonnet at xfce.org>
+ *
+ * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#ifndef __POPUP_H__
+#define __POPUP_H__
+
+#include <gtk/gtk.h>
+
+#define XFCE_NOTES_SELECTION "XFCE_NOTES_SELECTION"
+#define NOTES_MSG_SHOW_HIDE "SHOW_HIDE"
+
+gboolean popup_set_x_selection (GtkWidget *widget);
+const gchar* popup_get_message_from_event (GdkEventClient *event);
+
+#endif
Added: xfce4-notes-plugin/trunk/panel-plugin/popup.vapi
===================================================================
--- xfce4-notes-plugin/trunk/panel-plugin/popup.vapi (rev 0)
+++ xfce4-notes-plugin/trunk/panel-plugin/popup.vapi 2009-06-09 10:54:21 UTC (rev 7508)
@@ -0,0 +1,7 @@
+[CCode (cheader_filename = "popup.h")]
+namespace Xnp.Popup {
+ [CCode (cname = "popup_set_x_selection")]
+ public static bool set_x_selection (Gtk.Widget widget);
+ [CCode (cname = "popup_get_message_from_event")]
+ public static weak string? get_message_from_event (Gdk.EventClient event);
+}
Modified: xfce4-notes-plugin/trunk/panel-plugin/xfce4-popup-notes.c
===================================================================
--- xfce4-notes-plugin/trunk/panel-plugin/xfce4-popup-notes.c 2009-06-09 06:49:44 UTC (rev 7507)
+++ xfce4-notes-plugin/trunk/panel-plugin/xfce4-popup-notes.c 2009-06-09 10:54:21 UTC (rev 7508)
@@ -28,7 +28,7 @@
#include <gdk/gdkx.h>
#include <X11/Xlib.h>
-#include "xfce4-popup-notes.h"
+#include "popup.h"
@@ -60,7 +60,6 @@
gchar *message = NULL;
gboolean opt_show_hide = FALSE;
- gboolean opt_menu = FALSE;
GError *opt_error = NULL;
GOptionContext *context =
@@ -69,14 +68,10 @@
{
{ "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 }
};
-#if GLIB_CHECK_VERSION (2, 12, 0)
g_option_context_set_summary (context, "The default action is to show/hide all windows");
-#endif
g_option_context_add_main_entries (context, entries, NULL);
if (G_LIKELY (! g_option_context_parse (context, &argc, &argv, &opt_error)))
{
@@ -85,10 +80,7 @@
return -1;
}
- if (opt_menu)
- message = g_strdup_printf (NOTES_MSG_MENU);
- else
- message = g_strdup_printf (NOTES_MSG_SHOW_HIDE);
+ message = g_strdup_printf (NOTES_MSG_SHOW_HIDE);
gtk_init (&argc, &argv);
More information about the Goodies-commits
mailing list