Index: panel-plugin/view.c =================================================================== --- panel-plugin/view.c (révision 3588) +++ panel-plugin/view.c (copie de travail) @@ -55,6 +55,7 @@ #include "model_system.h" #include "model_volumes.h" #include "model_user.h" +#include "xfce4-popup-places.h" struct _PlacesView { @@ -924,6 +925,61 @@ return dlg; } +/********** Handle user message **********/ +static gboolean +places_view_plugin_message_received (GtkWidget *widget, + GdkEventClient *ev, + gpointer user_data) +{ + 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; + pview_open_menu (view); + return TRUE; + } + + return FALSE; +} + +static gboolean +places_view_plugin_set_selection (PlacesView *view) +{ + GdkScreen *gscreen; + gchar *selection_name; + Atom selection_atom; + GtkWidget *win; + Window id; + + win = gtk_invisible_new (); + gtk_widget_realize (win); + id = GDK_WINDOW_XID (GTK_WIDGET (win)->window); + + gscreen = gtk_widget_get_screen (win); + selection_name = g_strdup_printf (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); + return FALSE; + } + + XSelectInput (GDK_DISPLAY (), id, PropertyChangeMask); + XSetSelectionOwner (GDK_DISPLAY (), selection_atom, id, GDK_CURRENT_TIME); + + g_signal_connect (win, + "client-event", + G_CALLBACK (places_view_plugin_message_received), + view); + + return TRUE; +} + /********** Initialization & Finalization **********/ PlacesView* places_view_init(XfcePanelPlugin *plugin) @@ -999,6 +1055,8 @@ DBG("done"); + places_view_plugin_set_selection (view); + return view; } Index: panel-plugin/xfce4-popup-places.c =================================================================== --- panel-plugin/xfce4-popup-places.c (révision 0) +++ panel-plugin/xfce4-popup-places.c (révision 0) @@ -0,0 +1,85 @@ +/* $Id$ + * + * Places - panel plugin for Xfce Desktop Environment + * popup command + * Copyright (C) 2002-2006 Olivier Fourdan + * 2007 Mike Massonnet + * + * 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 +#endif + +#include +#include +#include + +#include "xfce4-popup-places.h" + + + +static gboolean +plugin_check_is_running (GtkWidget *widget, + Window *xid) +{ + GdkScreen *gscreen; + gchar *selection_name; + Atom selection_atom; + + gscreen = gtk_widget_get_screen (widget); + selection_name = g_strdup_printf (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; +} + +gint +main (gint argc, gchar *argv[]) +{ + GdkEventClient gev; + GtkWidget *win; + Window id; + gchar *message = NULL; + + gtk_init (&argc, &argv); + + message = g_strdup_printf (PLACES_MSG_MENU); + 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; + g_snprintf (gev.data.b, sizeof (gev.data.b), message); + + if (plugin_check_is_running (win, &id)) + gdk_event_send_client_message ((GdkEvent *)&gev, (GdkNativeWindow)id); + else + g_warning ("Can't find the xfce4-places-plugin.\n"); + gdk_flush (); + + gtk_widget_destroy (win); + + return FALSE; +} + Index: panel-plugin/xfce4-popup-places.h =================================================================== --- panel-plugin/xfce4-popup-places.h (révision 0) +++ panel-plugin/xfce4-popup-places.h (révision 0) @@ -0,0 +1,35 @@ +/* $Id$ + * + * Places - panel plugin for Xfce Desktop Environment + * popup command + * Copyright (C) 2002-2006 Olivier Fourdan + * 2007 Mike Massonnet + * + * 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. + */ + +#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 + Index: panel-plugin/Makefile.am =================================================================== --- panel-plugin/Makefile.am (révision 3588) +++ panel-plugin/Makefile.am (copie de travail) @@ -1,3 +1,20 @@ +bin_PROGRAMS = xfce4-popup-places + +xfce4_popup_places_SOURCES = \ + xfce4-popup-places.c \ + xfce4-popup-places.h + +xfce4_popup_places_CFLAGS = \ + $(LIBX11_CFLAGS) \ + $(GTK_CFLAGS) + +xfce4_popup_places_LDADD = \ + $(LIBX11_LDFLAGS) \ + $(LIBX11_LIBS) \ + $(GTK_LIBS) + + + plugindir = $(libexecdir)/xfce4/panel-plugins plugin_PROGRAMS = \