Browse Source
- Split DBus code into a client and service part. - Stop using signals for DBus but add separate methodes. - Fix id / display_name switch in panel plugin creation. - Add tasklist plugin from trunk.upstream/xfce4-panel-4.10.1

51 changed files with 2665 additions and 562 deletions
@ -0,0 +1,4 @@ |
|||
Maintainers |
|||
=========== |
|||
Jasper Huijsmans <jasper@xfce.org> |
|||
Nick Schermer <nick@xfce.org> |
@ -0,0 +1,194 @@ |
|||
/* $Id$ */ |
|||
/*
|
|||
* 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 |
|||
|
|||
#include <dbus/dbus.h> |
|||
#include <dbus/dbus-glib.h> |
|||
#include <dbus/dbus-glib-lowlevel.h> |
|||
#include <libxfce4util/libxfce4util.h> |
|||
#include <libxfce4panel/libxfce4panel.h> |
|||
|
|||
#include <panel/panel-private.h> |
|||
#include <panel/panel-dbus-client.h> |
|||
#include <panel/panel-dbus-service.h> |
|||
|
|||
|
|||
|
|||
static gboolean |
|||
panel_dbus_client_send_message (DBusMessage *message, |
|||
GError **error) |
|||
{ |
|||
DBusConnection *connection; |
|||
DBusMessage *result; |
|||
DBusError derror; |
|||
|
|||
dbus_error_init (&derror); |
|||
|
|||
/* try to connect to the session bus */ |
|||
connection = dbus_bus_get (DBUS_BUS_SESSION, &derror); |
|||
if (G_UNLIKELY (connection == NULL)) |
|||
{ |
|||
dbus_set_g_error (error, &derror); |
|||
dbus_error_free (&derror); |
|||
return FALSE; |
|||
} |
|||
|
|||
/* send the message */ |
|||
result = dbus_connection_send_with_reply_and_block (connection, message, -1, &derror); |
|||
|
|||
/* check if no reply was received */ |
|||
if (result == NULL) |
|||
{ |
|||
/* handle error */ |
|||
if (dbus_error_has_name (&derror, DBUS_ERROR_NAME_HAS_NO_OWNER)) |
|||
g_message (_("No running panel instance found.")); |
|||
else |
|||
dbus_set_g_error (error, &derror); |
|||
|
|||
dbus_error_free (&derror); |
|||
return FALSE; |
|||
} |
|||
|
|||
/* but maybe we received an error */ |
|||
if (G_UNLIKELY (dbus_message_get_type (result) == DBUS_MESSAGE_TYPE_ERROR)) |
|||
{ |
|||
dbus_set_error_from_message (&derror, result); |
|||
dbus_set_g_error (error, &derror); |
|||
dbus_message_unref (result); |
|||
dbus_error_free (&derror); |
|||
|
|||
return FALSE; |
|||
} |
|||
|
|||
/* it seems everything worked */ |
|||
dbus_message_unref (result); |
|||
|
|||
return TRUE; |
|||
} |
|||
|
|||
|
|||
|
|||
static gboolean |
|||
panel_dbus_client_display_dialog (GdkScreen *screen, |
|||
const gchar *methode_name, |
|||
GError **error) |
|||
{ |
|||
gchar *display_name; |
|||
DBusMessage *message; |
|||
gboolean result; |
|||
|
|||
/* fallback to default screen if no other is specified */ |
|||
if (G_LIKELY (screen == NULL)) |
|||
screen = gdk_screen_get_default (); |
|||
|
|||
/* determine the display name for the screen */ |
|||
display_name = gdk_screen_make_display_name (screen); |
|||
|
|||
/* generate the message */ |
|||
message = dbus_message_new_method_call (PANEL_DBUS_SERVICE_INTERFACE, PANEL_DBUS_SERVICE_PATH, |
|||
PANEL_DBUS_SERVICE_INTERFACE, methode_name); |
|||
dbus_message_set_auto_start (message, FALSE); |
|||
dbus_message_append_args (message, DBUS_TYPE_STRING, &display_name, DBUS_TYPE_INVALID); |
|||
|
|||
/* send the message */ |
|||
result = panel_dbus_client_send_message (message, error); |
|||
|
|||
/* release the message */ |
|||
dbus_message_unref (message); |
|||
|
|||
/* cleanup */ |
|||
g_free (display_name); |
|||
|
|||
return result; |
|||
} |
|||
|
|||
|
|||
|
|||
gboolean |
|||
panel_dbus_client_display_preferences_dialog (GdkScreen *screen, |
|||
GError **error) |
|||
{ |
|||
panel_return_val_if_fail (screen == NULL || GDK_IS_SCREEN (screen), FALSE); |
|||
panel_return_val_if_fail (error == NULL || *error == NULL, FALSE); |
|||
|
|||
return panel_dbus_client_display_dialog (screen, "DisplayPreferencesDialog", error); |
|||
} |
|||
|
|||
|
|||
|
|||
gboolean |
|||
panel_dbus_client_display_items_dialog (GdkScreen *screen, |
|||
GError **error) |
|||
{ |
|||
panel_return_val_if_fail (screen == NULL || GDK_IS_SCREEN (screen), FALSE); |
|||
panel_return_val_if_fail (error == NULL || *error == NULL, FALSE); |
|||
|
|||
return panel_dbus_client_display_dialog (screen, "DisplayItemsDialog", error); |
|||
} |
|||
|
|||
|
|||
|
|||
gboolean |
|||
panel_dbus_client_save (GError **error) |
|||
{ |
|||
DBusMessage *message; |
|||
gboolean result; |
|||
|
|||
panel_return_val_if_fail (error == NULL || *error == NULL, FALSE); |
|||
|
|||
/* generate the message */ |
|||
message = dbus_message_new_method_call (PANEL_DBUS_SERVICE_INTERFACE, PANEL_DBUS_SERVICE_PATH, |
|||
PANEL_DBUS_SERVICE_INTERFACE, "Save"); |
|||
dbus_message_set_auto_start (message, FALSE); |
|||
|
|||
/* send the message */ |
|||
result = panel_dbus_client_send_message (message, error); |
|||
|
|||
/* release the message */ |
|||
dbus_message_unref (message); |
|||
|
|||
return result; |
|||
} |
|||
|
|||
|
|||
|
|||
gboolean |
|||
panel_dbus_client_terminate (gboolean restart, |
|||
GError **error) |
|||
{ |
|||
DBusMessage *message; |
|||
gboolean result; |
|||
|
|||
panel_return_val_if_fail (error == NULL || *error == NULL, FALSE); |
|||
|
|||
/* generate the message */ |
|||
message = dbus_message_new_method_call (PANEL_DBUS_SERVICE_INTERFACE, PANEL_DBUS_SERVICE_PATH, |
|||
PANEL_DBUS_SERVICE_INTERFACE, "Terminate"); |
|||
dbus_message_set_auto_start (message, FALSE); |
|||
dbus_message_append_args (message, DBUS_TYPE_BOOLEAN, &restart, DBUS_TYPE_INVALID); |
|||
|
|||
/* send the message */ |
|||
result = panel_dbus_client_send_message (message, error); |
|||
|
|||
/* release the message */ |
|||
dbus_message_unref (message); |
|||
|
|||
return result; |
|||
} |
@ -0,0 +1,38 @@ |
|||
/* $Id$ */ |
|||
/*
|
|||
* 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 __PANEL_DBUS_CLIENT_H__ |
|||
#define __PANEL_DBUS_CLIENT_H__ |
|||
|
|||
#include <glib.h> |
|||
#include <gdk/gdk.h> |
|||
|
|||
gboolean panel_dbus_client_display_preferences_dialog (GdkScreen *screen, |
|||
GError **error); |
|||
|
|||
gboolean panel_dbus_client_display_items_dialog (GdkScreen *screen, |
|||
GError **error); |
|||
|
|||
gboolean panel_dbus_client_save (GError **error); |
|||
|
|||
gboolean panel_dbus_client_terminate (gboolean restart, |
|||
GError **error); |
|||
|
|||
G_END_DECLS |
|||
|
|||
#endif /* !__PANEL_DBUS_CLIENT_H__ */ |
|||
|
@ -1,103 +0,0 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
|
|||
<!-- |
|||
$Id$ |
|||
|
|||
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 |
|||
--> |
|||
|
|||
<node name="/org/xfce/Panel"> |
|||
|
|||
<interface name="org.xfce.Panel"> |
|||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="panel_dbus_service" /> |
|||
|
|||
<!-- |
|||
CustomizePanel (display : STRING) : VOID |
|||
|
|||
display : The display on which to show the dialog or "" |
|||
to use the default screen of the panel. |
|||
--> |
|||
<method name="CustomizePanel"> |
|||
<arg direction="in" name="display" type="s" /> |
|||
</method> |
|||
|
|||
<!-- |
|||
AddItems (display : STRING) : VOID |
|||
|
|||
display : The display on which to show the dialog or "" |
|||
to use the default screen of the panel. |
|||
--> |
|||
<method name="AddItems" /> |
|||
<arg direction="in" name="display" type="s" /> |
|||
</method> |
|||
|
|||
<!-- |
|||
Save () : VOID |
|||
|
|||
Tells the panel to save its configuration, including all the plugins. |
|||
--> |
|||
<method name="Save" /> |
|||
|
|||
<!-- |
|||
Terminate (restart : BOOLEAN) : VOID |
|||
|
|||
restart : Whether the panel should restart after termination. |
|||
--> |
|||
<method name="Terminate"> |
|||
<arg direction="in" name="restart" type="b" /> |
|||
</method> |
|||
</interface> |
|||
|
|||
<interface name="org.xfce.Panel.Plugin"> |
|||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="panel_dbus_service" /> |
|||
|
|||
<!-- |
|||
RegisterPlugin (id : INT) : VOID |
|||
|
|||
id : The window id of the GtkPlug. This is used to |
|||
embed the window in a GtkSocket. |
|||
--> |
|||
<method name="RegisterPlugin"> |
|||
<arg direction="in" name="id" type="i" /> |
|||
</method> |
|||
|
|||
<!-- |
|||
PropertyChanged (size : INT, screen-position : UINT, orientation : UINT, sensitive : BOOLEAN, expand : BOOLEAN) : VOID |
|||
|
|||
size : The size of the plugin. |
|||
screen-position : The screen-position of the panel on which the |
|||
plugin is embedded. |
|||
orientation : The orientation of the panel on which the |
|||
plugin is embedded. |
|||
sensitive : Whether the plugin should be sensitive. A plugin |
|||
is insensitive during panel editing. |
|||
expand : Whether the plugin expands on the panel. |
|||
--> |
|||
<signal name="PropertyChanged"> |
|||
<arg direction="in" name="size" type="i" /> |
|||
<arg direction="in" name="screen-position" type="u" /> |
|||
<arg direction="in" name="orientation" type="u" /> |
|||
<arg direction="in" name="sensitive" type="b" /> |
|||
<arg direction="in" name="expand" type="b" /> |
|||
</signal> |
|||
|
|||
<!-- |
|||
Save () : VOID |
|||
|
|||
Tells the plugin to save its configuration. |
|||
--> |
|||
<method name="Save" /> |
|||
</interface> |
|||
</node> |
@ -0,0 +1,65 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
|
|||
<!-- |
|||
$Id$ |
|||
|
|||
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 |
|||
--> |
|||
|
|||
<node name="/org/xfce/Panel"> |
|||
|
|||
<interface name="org.xfce.Panel"> |
|||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="panel_dbus_service" /> |
|||
|
|||
<!-- |
|||
DisplayPreferencesDialog (display : STRING) : VOID |
|||
|
|||
display : The display on which to show the dialog or "" |
|||
to use the default screen of the panel. |
|||
--> |
|||
<method name="DisplayPreferencesDialog"> |
|||
<arg name="display" direction="in" type="s" /> |
|||
</method> |
|||
|
|||
<!-- |
|||
DisplayItemsDialog (display : STRING) : VOID |
|||
|
|||
display : The display on which to show the dialog or "" |
|||
to use the default screen of the panel. |
|||
--> |
|||
<method name="DisplayItemsDialog"> |
|||
<arg name="display" direction="in" type="s" /> |
|||
</method> |
|||
|
|||
<!-- |
|||
Save () : VOID |
|||
|
|||
Tells the panel to save its configuration, including all the plugins. |
|||
--> |
|||
<method name="Save"> |
|||
</method> |
|||
|
|||
<!-- |
|||
Terminate (restart : BOOLEAN) : VOID |
|||
|
|||
restart : Whether the panel should restart after termination. |
|||
--> |
|||
<method name="Terminate"> |
|||
<arg name="restart" direction="in" type="b" /> |
|||
</method> |
|||
|
|||
</interface> |
|||
|
|||
</node> |