Browse Source

Rework DBus code and import tasklist plugin from master.

- 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.
tags/xfce4-panel-4.10.0
Nick Schermer 11 years ago
parent
commit
0f486a34d2
51 changed files with 2665 additions and 562 deletions
  1. +4
    -0
      AUTHORS
  2. +9
    -5
      configure.in.in
  3. +4
    -4
      libxfce4panel/xfce-arrow-button.c
  4. +1
    -2
      libxfce4panel/xfce-arrow-button.h
  5. +1
    -1
      libxfce4panel/xfce-hvbox.h
  6. +1
    -1
      libxfce4panel/xfce-panel-convenience.h
  7. +3
    -3
      libxfce4panel/xfce-panel-macros.h
  8. +8
    -6
      panel/Makefile.am
  9. +47
    -36
      panel/main.c
  10. +194
    -0
      panel/panel-dbus-client.c
  11. +38
    -0
      panel/panel-dbus-client.h
  12. +0
    -103
      panel/panel-dbus-infos.xml
  13. +65
    -0
      panel/panel-dbus-service-infos.xml
  14. +53
    -100
      panel/panel-dbus-service.c
  15. +6
    -15
      panel/panel-dbus-service.h
  16. +57
    -57
      panel/panel-glue.c
  17. +18
    -18
      panel/panel-module.c
  18. +127
    -127
      panel/panel-window.c
  19. +2
    -1
      plugins/Makefile.am
  20. +24
    -21
      plugins/clock/clock-dialog.c
  21. +32
    -31
      plugins/clock/clock.c
  22. +7
    -5
      plugins/clock/clock.h
  23. +3
    -4
      plugins/launcher/launcher-dialog.c
  24. +72
    -0
      plugins/tasklist.new/Makefile.am
  25. +0
    -0
      plugins/tasklist.new/tasklist-box.c
  26. +0
    -0
      plugins/tasklist.new/tasklist-box.h
  27. +0
    -0
      plugins/tasklist.new/tasklist-plugin.c
  28. +0
    -0
      plugins/tasklist.new/tasklist-plugin.h
  29. +9
    -0
      plugins/tasklist.new/tasklist.desktop.in.in
  30. +41
    -0
      plugins/tasklist/.svn/all-wcprops
  31. +10
    -0
      plugins/tasklist/.svn/dir-prop-base
  32. +105
    -0
      plugins/tasklist/.svn/entries
  33. +1
    -0
      plugins/tasklist/.svn/format
  34. +5
    -0
      plugins/tasklist/.svn/prop-base/Makefile.am.svn-base
  35. +5
    -0
      plugins/tasklist/.svn/prop-base/tasklist-dialogs.c.svn-base
  36. +5
    -0
      plugins/tasklist/.svn/prop-base/tasklist-dialogs.h.svn-base
  37. +5
    -0
      plugins/tasklist/.svn/prop-base/tasklist.c.svn-base
  38. +5
    -0
      plugins/tasklist/.svn/prop-base/tasklist.h.svn-base
  39. +74
    -0
      plugins/tasklist/.svn/text-base/Makefile.am.svn-base
  40. +232
    -0
      plugins/tasklist/.svn/text-base/tasklist-dialogs.c.svn-base
  41. +25
    -0
      plugins/tasklist/.svn/text-base/tasklist-dialogs.h.svn-base
  42. +477
    -0
      plugins/tasklist/.svn/text-base/tasklist.c.svn-base
  43. +9
    -0
      plugins/tasklist/.svn/text-base/tasklist.desktop.in.in.svn-base
  44. +63
    -0
      plugins/tasklist/.svn/text-base/tasklist.h.svn-base
  45. +9
    -7
      plugins/tasklist/Makefile.am
  46. +232
    -0
      plugins/tasklist/tasklist-dialogs.c
  47. +25
    -0
      plugins/tasklist/tasklist-dialogs.h
  48. +473
    -0
      plugins/tasklist/tasklist.c
  49. +3
    -3
      plugins/tasklist/tasklist.desktop.in.in
  50. +64
    -0
      plugins/tasklist/tasklist.h
  51. +12
    -12
      wrapper/main.c

+ 4
- 0
AUTHORS View File

@@ -0,0 +1,4 @@
Maintainers
===========
Jasper Huijsmans <jasper@xfce.org>
Nick Schermer <nick@xfce.org>

+ 9
- 5
configure.in.in View File

@@ -108,6 +108,7 @@ XDT_CHECK_PACKAGE([LIBXFCE4UI], [libxfce4ui-1], [4.5.0])
XDT_CHECK_PACKAGE([EXO], [exo-0.3], [0.3.1.11])
XDT_CHECK_PACKAGE([DBUS], [dbus-glib-1], [0.34])
XDT_CHECK_PACKAGE([CAIRO], [cairo], [1.0.0])
XDT_CHECK_PACKAGE([LIBWNCK], [libwnck-1.0], [2.12])

dnl ***********************************
dnl *** Check for optional packages ***
@@ -122,11 +123,13 @@ dnl *** Check for gtk-doc ***
dnl *************************
GTK_DOC_CHECK([1.0])

dnl *************************************
dnl *** Disable deprecated components ***
dnl *************************************
AC_DEFINE([XFCE_DISABLE_DEPRECATED], [1], [Define to 1 to disable deprecated Xfce components])
AC_DEFINE([G_DISABLE_DEPRECATED], [1], [Define to 1 to disable deprecated Glib components])
dnl *********************************************************
dnl *** Disable deprecated components and single includes ***
dnl *********************************************************
PLATFORM_CPPFLAGS="$PLATFORM_CPPFLAGS -DXFCE_DISABLE_DEPRECATED -DPANGO_DISABLE_SINGLE_INCLUDES"
PLATFORM_CPPFLAGS="$PLATFORM_CPPFLAGS -DG_DISABLE_DEPRECATED -DG_DISABLE_SINGLE_INCLUDES"
PLATFORM_CPPFLAGS="$PLATFORM_CPPFLAGS -DGTK_DISABLE_DEPRECATED -DGTK_DISABLE_SINGLE_INCLUDES"
PLATFORM_CPPFLAGS="$PLATFORM_CPPFLAGS -DGDK_DISABLE_DEPRECATED -DGDK_PIXBUF_DISABLE_SINGLE_INCLUDES"

dnl ***********************************
dnl *** Check for debugging support ***
@@ -236,5 +239,6 @@ plugins/Makefile
plugins/clock/Makefile
plugins/launcher/Makefile
plugins/systray/Makefile
plugins/tasklist/Makefile
po/Makefile.in
])

+ 4
- 4
libxfce4panel/xfce-arrow-button.c View File

@@ -151,7 +151,7 @@ xfce_arrow_button_set_property (GObject *object,
case PROP_ARROW_TYPE:
xfce_arrow_button_set_arrow_type (button, g_value_get_enum (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -173,7 +173,7 @@ xfce_arrow_button_get_property (GObject *object,
case PROP_ARROW_TYPE:
g_value_set_enum (value, xfce_arrow_button_get_arrow_type (button));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -216,7 +216,7 @@ xfce_arrow_button_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
gint size;
/* calculate the requested arrow size */
size = ARROW_WIDTH + ARROW_PADDING + 2 * MAX (widget->style->xthickness, widget->style->ythickness);

@@ -237,7 +237,7 @@ xfce_arrow_button_add (GtkContainer *container,
static GType
xfce_arrow_button_child_type (GtkContainer *container)
{
return GTK_TYPE_NONE;
return GTK_TYPE_WIDGET;
}




+ 1
- 2
libxfce4panel/xfce-arrow-button.h View File

@@ -23,8 +23,7 @@
#ifndef __XFCE_ARROW_BUTTON_H__
#define __XFCE_ARROW_BUTTON_H__

#include <gtk/gtkenums.h>
#include <gtk/gtktogglebutton.h>
#include <gtk/gtk.h>

G_BEGIN_DECLS



+ 1
- 1
libxfce4panel/xfce-hvbox.h View File

@@ -27,7 +27,7 @@
#ifndef __XFCE_HVBOX_H__
#define __XFCE_HVBOX_H__

#include <gtk/gtkbox.h>
#include <gtk/gtk.h>

G_BEGIN_DECLS



+ 1
- 1
libxfce4panel/xfce-panel-convenience.h View File

@@ -25,7 +25,7 @@
#ifndef __XFCE_PANEL_CONVENIENCE_H__
#define __XFCE_PANEL_CONVENIENCE_H__

#include <gtk/gtkwidget.h>
#include <gtk/gtk.h>

G_BEGIN_DECLS



+ 3
- 3
libxfce4panel/xfce-panel-macros.h View File

@@ -65,12 +65,12 @@ G_BEGIN_DECLS
#define XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL XFCE_PANEL_PLUGIN_REGISTER
#define XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL_WITH_CHECK XFCE_PANEL_PLUGIN_REGISTER_WITH_CHECK

/* parameter flags */
/* parameter flags */
#define PANEL_PARAM_READABLE G_PARAM_READABLE | PANEL_PARAM_STATIC_STRINGS
#define PANEL_PARAM_READWRITE G_PARAM_READWRITE | PANEL_PARAM_STATIC_STRINGS
#define PANEL_PARAM_WRITABLE G_PARAM_WRITABLE | PANEL_PARAM_STATIC_STRINGS

/* slice allocator */
/* slice allocator (deprecated) */
#define panel_slice_alloc(block_size) (g_slice_alloc ((block_size)))
#define panel_slice_alloc0(block_size) (g_slice_alloc0 ((block_size)))
#define panel_slice_free1(block_size, mem_block) G_STMT_START{ g_slice_free1 ((block_size), (mem_block)); }G_STMT_END
@@ -78,7 +78,7 @@ G_BEGIN_DECLS
#define panel_slice_new0(type) (g_slice_new0 (type))
#define panel_slice_free(type, ptr) G_STMT_START{ g_slice_free (type, (ptr)); }G_STMT_END

/* debug macros */
/* debug macros (deprecated) */
#define _panel_assert(expr) panel_assert (expr)
#define _panel_assert_not_reached() panel_assert_not_reached ()
#define _panel_return_if_fail(expr) panel_return_if_fail (expr)


+ 8
- 6
panel/Makefile.am View File

@@ -16,15 +16,17 @@ bin_PROGRAMS = \
xfce4-panel
xfce4_panel_built_sources = \
panel-dbus-infos.h
panel-dbus-service-infos.h

xfce4_panel_SOURCES = \
$(xfce4_panel_built_sources) \
main.c \
panel-application.c \
panel-application.h \
panel-dbus.c \
panel-dbus.h \
panel-dbus-client.c \
panel-dbus-client.h \
panel-dbus-service.c \
panel-dbus-service.h \
panel-dialogs.c \
panel-dialogs.h \
panel-glue.c \
@@ -80,11 +82,11 @@ DISTCLEANFILES = \
BUILT_SOURCES = \
$(xfce4_panel_built_sources)
panel-dbus-infos.h: $(srcdir)/panel-dbus-infos.xml Makefile
dbus-binding-tool --prefix=panel_dbus_service --mode=glib-server $(srcdir)/panel-dbus-infos.xml > panel-dbus-infos.h
panel-dbus-service-infos.h: $(srcdir)/panel-dbus-service-infos.xml Makefile
dbus-binding-tool --prefix=panel_dbus_service --mode=glib-server $(srcdir)/panel-dbus-service-infos.xml > panel-dbus-service-infos.h
endif

EXTRA_DIST = \
panel-dbus-infos.h
panel-dbus-service-infos.xml

# vi:set ts=8 sw=8 noet ai nocindent syntax=automake:

+ 47
- 36
panel/main.c View File

@@ -31,7 +31,9 @@

#include <panel/panel-private.h>
#include <panel/panel-application.h>
#include <panel/panel-dbus.h>
#include <panel/panel-dbus-service.h>
#include <panel/panel-dbus-client.h>



static gboolean opt_customize = FALSE;
@@ -59,32 +61,6 @@ static const GOptionEntry option_entries[] =



static gint
send_signal (guint signal_id)
{
GError *error = NULL;

if (panel_dbus_client_send_signal (signal_id, &error))
{
/* stop any running startup notification */
gdk_notify_startup_complete ();

return EXIT_SUCCESS;
}
else
{
/* print warning */
g_critical ("Failed to send D-BUS message: %s", error ? error->message : "");

/* cleanup */
g_error_free (error);

return EXIT_FAILURE;
}
}



gint
main (gint argc, gchar **argv)
{
@@ -92,6 +68,7 @@ main (gint argc, gchar **argv)
GError *error = NULL;
GObject *dbus_service;
extern gboolean dbus_quit_with_restart;
gboolean result;

/* set translation domain */
xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
@@ -138,15 +115,33 @@ main (gint argc, gchar **argv)
return EXIT_SUCCESS;
}
else if (opt_customize)
return send_signal (SIGNAL_CUSTOMIZE);
{
/* send a signal to the running instance to show the preferences dialog */
result = panel_dbus_client_display_preferences_dialog (NULL, &error);

goto dbus_return;
}
else if (opt_add)
return send_signal (SIGNAL_ADD);
{
/* send a signal to the running instance to show the add items dialog */
result = panel_dbus_client_display_items_dialog (NULL, &error);

goto dbus_return;
}
else if (opt_save)
return send_signal (SIGNAL_SAVE);
else if (G_UNLIKELY (opt_restart))
return send_signal (SIGNAL_RESTART);
else if (G_UNLIKELY (opt_quit))
return send_signal (SIGNAL_QUIT);
{
/* send a save signal to the running instance */
result = panel_dbus_client_save (&error);

goto dbus_return;
}
else if (opt_restart || opt_quit)
{
/* send a terminate signal to the running instance */
result = panel_dbus_client_terminate (opt_restart, &error);

goto dbus_return;
}

/* create a new application */
application = panel_application_get ();
@@ -162,7 +157,7 @@ main (gint argc, gchar **argv)

/* destroy all the opened dialogs */
panel_application_destroy_dialogs (application);
/* save the configuration */
panel_application_save (application);

@@ -174,10 +169,26 @@ main (gint argc, gchar **argv)
{
/* message */
g_message (_("Restarting..."));
/* spawn ourselfs again */
g_spawn_command_line_async (argv[0], NULL);
}

return EXIT_SUCCESS;

dbus_return:

/* stop any running startup notification */
gdk_notify_startup_complete ();

if (G_UNLIKELY (error != NULL))
{
/* print warning */
g_critical ("Failed to send D-BUS message: %s", error ? error->message : "No error message");

/* cleanup */
g_error_free (error);
}

return result ? EXIT_SUCCESS : EXIT_FAILURE;
}

+ 194
- 0
panel/panel-dbus-client.c View File

@@ -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;
}

+ 38
- 0
panel/panel-dbus-client.h View File

@@ -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__ */


+ 0
- 103
panel/panel-dbus-infos.xml View File

@@ -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>

+ 65
- 0
panel/panel-dbus-service-infos.xml View File

@@ -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>

panel/panel-dbus.c → panel/panel-dbus-service.c View File

@@ -26,24 +26,18 @@
#include <libxfce4panel/libxfce4panel.h>

#include <panel/panel-private.h>
#include <panel/panel-dbus.h>
#include <panel/panel-dbus-service.h>
#include <panel/panel-application.h>
#include <panel/panel-preferences-dialog.h>
#include <panel/panel-item-dialog.h>



#define PANEL_DBUS_PATH "/org/xfce/Panel"
#define PANEL_DBUS_INTERFACE "org.xfce.Panel"



static void panel_dbus_service_class_init (PanelDBusServiceClass *klass);
static void panel_dbus_service_init (PanelDBusService *service);
static void panel_dbus_service_finalize (GObject *object);
static gboolean panel_dbus_service_signal (PanelDBusService *service,
guint32 signal_id,
GError **error);



struct _PanelDBusServiceClass
{
@@ -95,11 +89,11 @@ panel_dbus_service_init (PanelDBusService *service)
if (G_LIKELY (service->connection != NULL))
{
/* register the /org/xfce/Panel object */
dbus_g_connection_register_g_object (service->connection, PANEL_DBUS_PATH, G_OBJECT (service));
dbus_g_connection_register_g_object (service->connection, PANEL_DBUS_SERVICE_PATH, G_OBJECT (service));

/* request the org.xfce.Mousepad name for Mousepad */
dbus_bus_request_name (dbus_g_connection_get_connection (service->connection),
PANEL_DBUS_INTERFACE, DBUS_NAME_FLAG_REPLACE_EXISTING, NULL);
PANEL_DBUS_SERVICE_INTERFACE, DBUS_NAME_FLAG_REPLACE_EXISTING, NULL);
}
else
{
@@ -128,132 +122,91 @@ panel_dbus_service_finalize (GObject *object)


static gboolean
panel_dbus_service_signal (PanelDBusService *service,
guint32 signal_id,
GError **error)
panel_dbus_service_display_preferences_dialog (PanelDBusService *service,
const gchar *display,
GError **error)
{
PanelApplication *application;

panel_return_val_if_fail (PANEL_IS_DBUS_SERVICE (service), FALSE);
panel_return_val_if_fail (error == NULL || *error == NULL, FALSE);

if (signal_id == SIGNAL_CUSTOMIZE)
{
/* show the prefernces dialog */
panel_preferences_dialog_show (NULL);
}
else if (signal_id == SIGNAL_ADD)
{
/* show the items dialog */
panel_item_dialog_show ();
}
else if (signal_id == SIGNAL_SAVE)
{
/* save the configuration */
application = panel_application_get ();
panel_application_save (application);
g_object_unref (G_OBJECT (application));
}
else if (signal_id == SIGNAL_RESTART || signal_id == SIGNAL_QUIT)
{
/* set restart boolean */
dbus_quit_with_restart = !!(signal_id == SIGNAL_RESTART);
g_message ("Show preferences dialog on display %s", display);

/* quit */
gtk_main_quit ();
}
/* show the prefernces dialog */
panel_preferences_dialog_show (NULL);

return TRUE;
}



GObject *
panel_dbus_service_new (void)
static gboolean
panel_dbus_service_display_items_dialog (PanelDBusService *service,
const gchar *display,
GError **error)
{
return g_object_new (PANEL_TYPE_DBUS_SERVICE, NULL);
panel_return_val_if_fail (PANEL_IS_DBUS_SERVICE (service), FALSE);
panel_return_val_if_fail (error == NULL || *error == NULL, FALSE);

g_message ("Show items dialog on display %s", display);

/* show the items dialog */
panel_item_dialog_show ();

return TRUE;
}



static gboolean
panel_dbus_client_send (DBusMessage *message,
GError **error)
panel_dbus_service_save (PanelDBusService *service,
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;
}
PanelApplication *application;

/* send the message */
result = dbus_connection_send_with_reply_and_block (connection, message, -1, &derror);
panel_return_val_if_fail (PANEL_IS_DBUS_SERVICE (service), FALSE);
panel_return_val_if_fail (error == NULL || *error == NULL, FALSE);

/* 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;
}
/* get the current application */
application = panel_application_get ();

/* 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;
}
/* save the configuration */
panel_application_save (application);

/* it seems everything worked */
dbus_message_unref (result);
/* release the application */
g_object_unref (G_OBJECT (application));

return TRUE;
}



gboolean
panel_dbus_client_send_signal (guint32 signal_id,
GError **error)
static gboolean
panel_dbus_service_terminate (PanelDBusService *service,
gboolean restart,
GError **error)
{
DBusMessage *message;

panel_return_val_if_fail (PANEL_IS_DBUS_SERVICE (service), FALSE);
panel_return_val_if_fail (error == NULL || *error == NULL, FALSE);

/* generate the message */
message = dbus_message_new_method_call (PANEL_DBUS_INTERFACE, PANEL_DBUS_PATH, PANEL_DBUS_INTERFACE, "Signal");
dbus_message_set_auto_start (message, FALSE);
dbus_message_append_args (message, DBUS_TYPE_UINT32, &signal_id, DBUS_TYPE_INVALID);
/* set restart boolean */
dbus_quit_with_restart = restart;

/* quit */
gtk_main_quit ();

return TRUE;
}

/* send the message */
panel_dbus_client_send (message, error);

/* unref the message */
dbus_message_unref (message);

/* we return false if an error was set */
return (error != NULL);
GObject *
panel_dbus_service_new (void)
{
return g_object_new (PANEL_TYPE_DBUS_SERVICE, NULL);
}



/* include the dbus glue generated by dbus-binding-tool */
#include <panel/panel-dbus-infos.h>
#include <panel/panel-dbus-service-infos.h>


panel/panel-dbus.h → panel/panel-dbus-service.h View File

@@ -15,22 +15,16 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/

#ifndef __PANEL_DBUS_H__
#define __PANEL_DBUS_H__
#ifndef __PANEL_DBUS_SERVICE_H__
#define __PANEL_DBUS_SERVICE_H__

#include <gtk/gtk.h>
#include <glib.h>

typedef struct _PanelDBusServiceClass PanelDBusServiceClass;
typedef struct _PanelDBusService PanelDBusService;

enum
{
SIGNAL_CUSTOMIZE,
SIGNAL_ADD,
SIGNAL_SAVE,
SIGNAL_RESTART,
SIGNAL_QUIT
};
#define PANEL_DBUS_SERVICE_PATH "/org/xfce/Panel"
#define PANEL_DBUS_SERVICE_INTERFACE "org.xfce.Panel"

#define PANEL_TYPE_DBUS_SERVICE (panel_dbus_service_get_type ())
#define PANEL_DBUS_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PANEL_TYPE_DBUS_SERVICE, PanelDBusService))
@@ -43,10 +37,7 @@ GType panel_dbus_service_get_type (void) G_GNUC_CONST;

GObject *panel_dbus_service_new (void);

gboolean panel_dbus_client_send_signal (guint32 signal_id,
GError **error);

G_END_DECLS

#endif /* !__PANEL_DBUS_H__ */
#endif /* !__PANEL_DBUS_SERVICE_H__ */


+ 57
- 57
panel/panel-glue.c View File

@@ -33,7 +33,7 @@
#include <panel/panel-item-dialog.h>
#include <panel/panel-preferences-dialog.h>
#include <panel/panel-dialogs.h>
#include <panel/panel-dbus.h>
#include <panel/panel-dbus-service.h>



@@ -41,10 +41,10 @@ static void
panel_glue_popup_menu_quit (gpointer boolean)
{
extern gboolean dbus_quit_with_restart;
/* restart or quit */
dbus_quit_with_restart = !!(GPOINTER_TO_UINT (boolean));
/* quit main loop */
gtk_main_quit ();
}
@@ -57,10 +57,10 @@ panel_glue_popup_menu_deactivate (GtkMenu *menu,
{
panel_return_if_fail (GTK_IS_MENU (menu));
panel_return_if_fail (PANEL_IS_WINDOW (window));
/* thaw autohide block */
panel_window_thaw_autohide (window);
/* destroy the menu */
g_object_unref (G_OBJECT (menu));
}
@@ -73,84 +73,84 @@ panel_glue_popup_menu (PanelWindow *window)
GtkWidget *menu;
GtkWidget *item;
GtkWidget *image;
panel_return_if_fail (PANEL_IS_WINDOW (window));
/* freeze autohide */
panel_window_freeze_autohide (window);
/* create menu */
menu = gtk_menu_new ();
/* sink the menu and add unref on deactivate */
g_object_ref_sink (G_OBJECT (menu));
g_signal_connect (G_OBJECT (menu), "deactivate", G_CALLBACK (panel_glue_popup_menu_deactivate), window);
/* label */
item = gtk_image_menu_item_new_with_label (_("Xfce Panel"));
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_set_sensitive (item, FALSE);
gtk_widget_show (item);
/* separator */
item = gtk_separator_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show (item);
/* add new items */
item = gtk_image_menu_item_new_with_mnemonic (_("Add _New Items"));
g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (panel_item_dialog_show), NULL);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show (item);
image = gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
gtk_widget_show (image);
/* customize panel */
item = gtk_image_menu_item_new_with_mnemonic (_("_Customize Panels"));
g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (panel_preferences_dialog_show), window);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show (item);
image = gtk_image_new_from_stock (GTK_STOCK_PREFERENCES, GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
gtk_widget_show (image);
/* separator */
item = gtk_separator_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show (item);
/* quit item */
item = gtk_image_menu_item_new_from_stock (GTK_STOCK_QUIT, NULL);
g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (panel_glue_popup_menu_quit), GUINT_TO_POINTER (0));
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show (item);
/* restart item */
item = gtk_image_menu_item_new_with_mnemonic (_("_Restart"));
g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (panel_glue_popup_menu_quit), GUINT_TO_POINTER (1));
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show (item);
image = gtk_image_new_from_stock (GTK_STOCK_REFRESH, GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
gtk_widget_show (image);
/* separator */
item = gtk_separator_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show (item);
/* about item */
item = gtk_image_menu_item_new_from_stock (GTK_STOCK_ABOUT, NULL);
g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (panel_dialogs_show_about), NULL);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show (item);
/* popup the menu */
gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
0, gtk_get_current_event_time ());
}

@@ -160,56 +160,56 @@ XfceScreenPosition
panel_glue_get_screen_position (PanelWindow *window)
{
gboolean horizontal;
panel_return_val_if_fail (PANEL_IS_WINDOW (window), XFCE_SCREEN_POSITION_NONE);
/* whether the panel is horizontal */
horizontal = !!(panel_window_get_orientation (window) == GTK_ORIENTATION_HORIZONTAL);
/* return the screen position */
switch (panel_window_get_snap_edge (window))
{
case PANEL_SNAP_EGDE_NONE:
return horizontal ? XFCE_SCREEN_POSITION_FLOATING_H :
return horizontal ? XFCE_SCREEN_POSITION_FLOATING_H :
XFCE_SCREEN_POSITION_FLOATING_V;
case PANEL_SNAP_EGDE_NW:
return horizontal ? XFCE_SCREEN_POSITION_NW_H :
return horizontal ? XFCE_SCREEN_POSITION_NW_H :
XFCE_SCREEN_POSITION_NW_V;
case PANEL_SNAP_EGDE_NE:
return horizontal ? XFCE_SCREEN_POSITION_NE_H :
return horizontal ? XFCE_SCREEN_POSITION_NE_H :
XFCE_SCREEN_POSITION_NE_V;
case PANEL_SNAP_EGDE_SW:
return horizontal ? XFCE_SCREEN_POSITION_SW_H :
return horizontal ? XFCE_SCREEN_POSITION_SW_H :
XFCE_SCREEN_POSITION_SW_V;

case PANEL_SNAP_EGDE_SE:
return horizontal ? XFCE_SCREEN_POSITION_SE_H :
return horizontal ? XFCE_SCREEN_POSITION_SE_H :
XFCE_SCREEN_POSITION_SE_V;
case PANEL_SNAP_EGDE_W:
case PANEL_SNAP_EGDE_WC:
return horizontal ? XFCE_SCREEN_POSITION_FLOATING_H :
XFCE_SCREEN_POSITION_W;
case PANEL_SNAP_EGDE_E:
case PANEL_SNAP_EGDE_EC:
return horizontal ? XFCE_SCREEN_POSITION_FLOATING_H :
return horizontal ? XFCE_SCREEN_POSITION_FLOATING_H :
XFCE_SCREEN_POSITION_E;
case PANEL_SNAP_EGDE_S:
case PANEL_SNAP_EGDE_SC:
return horizontal ? XFCE_SCREEN_POSITION_S :
return horizontal ? XFCE_SCREEN_POSITION_S :
XFCE_SCREEN_POSITION_FLOATING_V;
case PANEL_SNAP_EGDE_N:
case PANEL_SNAP_EGDE_NC:
return horizontal ? XFCE_SCREEN_POSITION_N :
return horizontal ? XFCE_SCREEN_POSITION_N :
XFCE_SCREEN_POSITION_FLOATING_V;
}
return XFCE_SCREEN_POSITION_NONE;
}

@@ -220,7 +220,7 @@ panel_glue_set_orientation_foreach (GtkWidget *widget,
gpointer user_data)
{
panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (widget));
/* set the new plugin orientation */
xfce_panel_plugin_provider_set_orientation (XFCE_PANEL_PLUGIN_PROVIDER (widget),
GPOINTER_TO_INT (user_data));
@@ -233,7 +233,7 @@ panel_glue_set_size_foreach (GtkWidget *widget,
gpointer user_data)
{
panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (widget));
/* set the new plugin size */
xfce_panel_plugin_provider_set_size (XFCE_PANEL_PLUGIN_PROVIDER (widget),
GPOINTER_TO_INT (user_data));
@@ -246,7 +246,7 @@ panel_glue_set_screen_position_foreach (GtkWidget *widget,
gpointer user_data)
{
panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (widget));
/* set the new plugin screen position */
xfce_panel_plugin_provider_set_screen_position (XFCE_PANEL_PLUGIN_PROVIDER (widget),
GPOINTER_TO_INT (user_data));
@@ -259,18 +259,18 @@ panel_glue_set_orientation (PanelWindow *window,
GtkOrientation orienation)
{
GtkWidget *itembar;
panel_return_if_fail (PANEL_IS_WINDOW (window));
/* set the size of the window */
panel_window_set_orientation (window, orienation);
/* get the itembar */
itembar = gtk_bin_get_child (GTK_BIN (window));
/* send the new orientation to all plugins */
gtk_container_foreach (GTK_CONTAINER (itembar), panel_glue_set_orientation_foreach, GINT_TO_POINTER (orienation));
/* screen position also changed */
panel_glue_set_screen_position (window);
}
@@ -282,34 +282,34 @@ panel_glue_set_size (PanelWindow *window,
gint size)
{
GtkWidget *itembar;
panel_return_if_fail (PANEL_IS_WINDOW (window));

/* set the size of the window */
panel_window_set_size (window, size);
/* get the itembar */
itembar = gtk_bin_get_child (GTK_BIN (window));
/* send the new size to all plugins */
gtk_container_foreach (GTK_CONTAINER (itembar), panel_glue_set_size_foreach, GINT_TO_POINTER (size));
}


void
void
panel_glue_set_screen_position (PanelWindow *window)
{
XfceScreenPosition screen_position;
GtkWidget *itembar;
panel_return_if_fail (PANEL_IS_WINDOW (window));
/* get the screen position */
screen_position = panel_glue_get_screen_position (window);

/* get the itembar */
itembar = gtk_bin_get_child (GTK_BIN (window));
/* send the new size to all plugins */
gtk_container_foreach (GTK_CONTAINER (itembar), panel_glue_set_screen_position_foreach, GINT_TO_POINTER (screen_position));
}

+ 18
- 18
panel/panel-module.c View File

@@ -39,7 +39,7 @@ static void panel_module_dispose (GObject *object);
static void panel_module_finalize (GObject *object);
static gboolean panel_module_load (GTypeModule *type_module);
static void panel_module_unload (GTypeModule *type_module);
static void panel_module_item_finalized (gpointer user_data,
static void panel_module_item_finalized (gpointer user_data,
GObject *item);


@@ -119,12 +119,12 @@ panel_module_init (PanelModule *module)



static void
static void
panel_module_dispose (GObject *object)
{
/* Do nothing to avoid problems with dispose in GTypeModule when
/* Do nothing to avoid problems with dispose in GTypeModule when
* types are registered.
*
*
* For us this is not a problem since the modules are released when
* everything is destroyed. So we really want that last unref before
* closing the application. */
@@ -176,11 +176,11 @@ panel_module_load (GTypeModule *type_module)

return FALSE;
}
/* run the register function if available */
if (g_module_symbol (module->library, "xfce_panel_plugin_register_types", (gpointer) &register_func))
(*register_func) (type_module);
return TRUE;
}

@@ -252,12 +252,12 @@ panel_module_new_from_desktop_file (const gchar *filename,
/* read library location from the desktop file */
module_name = xfce_rc_read_entry (rc, "X-XFCE-Module", NULL);
directory = xfce_rc_read_entry (rc, "X-XFCE-Module-Path", NULL);
if (G_LIKELY (module_name != NULL && directory != NULL))
{
/* build the module path */
path = g_module_build_path (directory, module_name);
/* test if the module exists */
if (G_LIKELY (g_file_test (path, G_FILE_TEST_EXISTS)))
{
@@ -294,7 +294,7 @@ panel_module_new_from_desktop_file (const gchar *filename,

/* whether the plugin is unique */
module->is_unique = xfce_rc_read_bool_entry (rc, "X-XFCE-Unique", FALSE);
/* whether to run the plugin external */
module->run_in_wrapper = xfce_rc_read_bool_entry (rc, "X-XFCE-External", TRUE);
}
@@ -334,11 +334,11 @@ panel_module_create_plugin (PanelModule *module,
panel_return_val_if_fail (name != NULL, NULL);
panel_return_val_if_fail (id != NULL, NULL);
panel_return_val_if_fail (exo_str_is_equal (name, G_TYPE_MODULE (module)->name), NULL);
/* return null if the module is not usable (unique and already used) */
if (G_UNLIKELY (panel_module_is_usable (module) == FALSE))
return NULL;
/* whether we're going to start the module external */
external = !!(use_wrapper == FORCE_EXTERNAL || (use_wrapper == FROM_DESKTOP_FILE && module->run_in_wrapper));

@@ -356,9 +356,9 @@ panel_module_create_plugin (PanelModule *module,
{
/* debug check */
panel_return_val_if_fail (module->construct_func != NULL, NULL);
/* create a new panel plugin */
plugin = (*module->construct_func) (name, module->name, id, screen);
plugin = (*module->construct_func) (name, id, module->name, screen);
}
else
{
@@ -371,10 +371,10 @@ panel_module_create_plugin (PanelModule *module,
{
/* increase count */
module->use_count++;
/* handle module use count and unloading */
g_object_weak_ref (G_OBJECT (plugin), panel_module_item_finalized, module);
/* emit unique-changed if the plugin is unique */
if (module->is_unique)
panel_module_factory_emit_unique_changed (module);
@@ -395,7 +395,7 @@ panel_module_get_internal_name (PanelModule *module)
{
panel_return_val_if_fail (PANEL_IS_MODULE (module), NULL);
panel_return_val_if_fail (G_IS_TYPE_MODULE (module), NULL);
return G_TYPE_MODULE (module)->name;
}

@@ -406,7 +406,7 @@ panel_module_get_library_filename (PanelModule *module)
{
panel_return_val_if_fail (PANEL_IS_MODULE (module), NULL);
panel_return_val_if_fail (G_IS_TYPE_MODULE (module), NULL);
return module->filename;
}

@@ -451,7 +451,7 @@ gboolean
panel_module_is_valid (PanelModule *module)
{
panel_return_val_if_fail (PANEL_IS_MODULE (module), FALSE);
return g_file_test (module->filename, G_FILE_TEST_EXISTS);
}



+ 127
- 127
panel/panel-window.c View File

@@ -119,19 +119,19 @@ struct _PanelWindowClass
struct _PanelWindow
{
GtkWindow __parent__;
/* last allocated size, for recentering */
GtkAllocation prev_allocation;

/* snapping edge of the window */
PanelWindowSnapEdge snap_edge;
/* whether we should apply struts for this screen position */
gint struts_possible;
/* the last used struts for this window */
gulong struts[N_STRUTS];
/* the last calculated panel working area */
GdkRectangle working_area;

@@ -155,7 +155,7 @@ struct _PanelWindow
AutohideStatus autohide_status;
guint autohide_timer;
gint autohide_block;
/* the window we use to show during autohide */
GtkWidget *autohide_window;

@@ -220,7 +220,7 @@ panel_window_class_init (PanelWindowClass *klass)
GTK_TYPE_ORIENTATION,
GTK_ORIENTATION_HORIZONTAL,
EXO_PARAM_READABLE));
/* initialize the atoms */
cardinal_atom = panel_atom_intern ("CARDINAL");
net_wm_strut_atom = panel_atom_intern ("_NET_WM_STRUT");
@@ -238,7 +238,7 @@ panel_window_init (PanelWindow *window)
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
gtk_window_set_decorated (GTK_WINDOW (window), FALSE);
gtk_window_set_type_hint (GTK_WINDOW (window), GDK_WINDOW_TYPE_HINT_DOCK);
/* init vars */
window->is_composited = FALSE;
window->drag_motion = FALSE;
@@ -261,13 +261,13 @@ panel_window_init (PanelWindow *window)

/* connect signal to monitor the compositor changes */
g_signal_connect (G_OBJECT (window), "composited-changed", G_CALLBACK (panel_window_set_colormap), NULL);
/* set the colormap */
panel_window_set_colormap (window);

/* get the window screen */
screen = gtk_window_get_screen (GTK_WINDOW (window));
/* connect screen update signals */
g_signal_connect_swapped (G_OBJECT (screen), "size-changed", G_CALLBACK (panel_window_screen_changed), window);
#if GTK_CHECK_VERSION (2,14,0)
@@ -303,11 +303,11 @@ static void
panel_window_finalize (GObject *object)
{
PanelWindow *window = PANEL_WINDOW (object);
/* stop the autohide timeout */
if (window->autohide_timer != 0)
g_source_remove (window->autohide_timer);
/* destroy autohide window */
if (window->autohide_window != NULL)
gtk_widget_destroy (window->autohide_window);
@@ -322,7 +322,7 @@ panel_window_realize (GtkWidget *widget)
{
/* realize the window */
(*GTK_WIDGET_CLASS (panel_window_parent_class)->realize) (widget);
/* initialize the working area */
panel_window_working_area (PANEL_WINDOW (widget), -1, -1, &PANEL_WINDOW (widget)->working_area);
}
@@ -416,7 +416,7 @@ panel_window_motion_notify_snap (gint value,
*return_value = tmp;
return SNAP_END;
}
/* set value as return value */
*return_value = value;

@@ -443,7 +443,7 @@ panel_window_motion_notify (GtkWidget *widget,
{
/* get the pointer position and current screen */
gdk_display_get_pointer (gtk_widget_get_display (widget), &screen, &window_x, &window_y, NULL);
/* make sure the window is on the correct screen */
gtk_window_set_screen (GTK_WINDOW (widget), screen);

@@ -469,7 +469,7 @@ panel_window_motion_notify (GtkWidget *widget,
/* try to find snapping edges */
snap_horizontal = panel_window_motion_notify_snap (clamp_x, window_width, area.x, area.x + area.width, &snap_x);
snap_vertical = panel_window_motion_notify_snap (clamp_y, window_height, area.y, area.y + area.height, &snap_y);
/* detect the snap mode */
if (snap_horizontal == SNAP_START)
window->snap_edge = PANEL_SNAP_EGDE_W + snap_vertical;
@@ -514,7 +514,7 @@ panel_window_button_press_event (GtkWidget *widget,

/* get the modifiers */
modifiers = event->state & gtk_accelerator_get_default_mod_mask ();
if (event->button == 1
&& event->window == widget->window
&& window->locked == FALSE
@@ -541,7 +541,7 @@ panel_window_button_press_event (GtkWidget *widget,
{
/* popup the panel menu */
panel_glue_popup_menu (window);
return TRUE;
}

@@ -563,10 +563,10 @@ panel_window_button_release_event (GtkWidget *widget,

/* release the pointer */
gdk_pointer_ungrab (event->time);
/* update working area, struts and reallocate */
panel_window_screen_changed (widget, gtk_window_get_screen (GTK_WINDOW (widget)));
/* update the plugins */
panel_glue_set_screen_position (window);

@@ -582,8 +582,8 @@ static gboolean
panel_window_autohide_timeout (gpointer user_data)
{
PanelWindow *window = PANEL_WINDOW (user_data);
panel_return_val_if_fail (window->autohide_status != DISABLED
panel_return_val_if_fail (window->autohide_status != DISABLED
&& window->autohide_status != BLOCKED, FALSE);

/* change status */
@@ -591,7 +591,7 @@ panel_window_autohide_timeout (gpointer user_data)
window->autohide_status = HIDDEN;
else if (window->autohide_status == POPUP_QUEUED)
window->autohide_status = VISIBLE;
gtk_widget_queue_resize (GTK_WIDGET (window));

return FALSE;
@@ -612,16 +612,16 @@ panel_window_autohide_queue (PanelWindow *window,
AutohideStatus status)
{
guint delay;
panel_return_if_fail (PANEL_IS_WINDOW (window));
/* stop a running autohide timeout */
if (window->autohide_timer != 0)
g_source_remove (window->autohide_timer);
/* set new autohide status */
window->autohide_status = status;
/* leave when the autohide is disabled */
if (status == DISABLED || status == BLOCKED)
{
@@ -637,7 +637,7 @@ panel_window_autohide_queue (PanelWindow *window,
delay = POPDOWN_DELAY * 3;
else
delay = POPUP_DELAY;
/* schedule a new timeout */
window->autohide_timer = g_timeout_add_full (G_PRIORITY_LOW, delay,
panel_window_autohide_timeout, window,
@@ -653,10 +653,10 @@ panel_window_autohide_enter_notify_event (GtkWidget *widget,
PanelWindow *window)
{
panel_return_val_if_fail (PANEL_IS_WINDOW (window), FALSE);
/* queue a hide timeout */
panel_window_autohide_queue (window, POPUP_QUEUED);
return TRUE;
}

@@ -668,16 +668,16 @@ panel_window_autohide_leave_notify_event (GtkWidget *widget,
PanelWindow *window)
{
panel_return_val_if_fail (PANEL_IS_WINDOW (window), FALSE);
/* stop a running autohide timeout */
if (window->autohide_timer != 0)
g_source_remove (window->autohide_timer);
/* update the status */
if (window->autohide_status == POPUP_QUEUED)
window->autohide_status = HIDDEN;
return TRUE;
return TRUE;
}


@@ -686,23 +686,23 @@ static GtkWidget *
panel_window_autohide_window (PanelWindow *window)
{
GtkWidget *popup;
/* create window */
popup = gtk_window_new (GTK_WINDOW_POPUP);
/* connect signals to monitor enter/leave events */
g_signal_connect (G_OBJECT (popup), "enter-notify-event", G_CALLBACK (panel_window_autohide_enter_notify_event), window);
g_signal_connect (G_OBJECT (popup), "leave-notify-event", G_CALLBACK (panel_window_autohide_leave_notify_event), window);
/* put the window offscreen */
gtk_window_move (GTK_WINDOW (popup), OFFSCREEN, OFFSCREEN);
/* set window opacity */
_window_set_opacity (GTK_WINDOW (popup), window->leave_opacity);
/* show the window */
gtk_widget_show (popup);
return popup;
}

@@ -713,7 +713,7 @@ panel_window_enter_notify_event (GtkWidget *widget,
GdkEventCrossing *event)
{
PanelWindow *window = PANEL_WINDOW (widget);
/* ignore event when entered from an inferior */
if (event->detail == GDK_NOTIFY_INFERIOR)
return FALSE;
@@ -740,7 +740,7 @@ panel_window_leave_notify_event (GtkWidget *widget,
GdkEventCrossing *event)
{
PanelWindow *window = PANEL_WINDOW (widget);
/* ignore event when left towards an inferior */
if (event->detail == GDK_NOTIFY_INFERIOR)
return FALSE;
@@ -802,8 +802,8 @@ panel_window_size_request (GtkWidget *widget,
if (window->horizontal)
{
/* calculate the panel width (fits content, fits on the screen, and extands to user size) */
requisition->width = CLAMP (child_requisition.width,
window->working_area.width * window->length,
requisition->width = CLAMP (child_requisition.width,
window->working_area.width * window->length,
window->working_area.width);

/* set height based on user setting */
@@ -812,8 +812,8 @@ panel_window_size_request (GtkWidget *widget,
else
{
/* calculate the panel width (fits content, fits on the screen, and extands to user size) */
requisition->height = CLAMP (child_requisition.height,
window->working_area.height * window->length,
requisition->height = CLAMP (child_requisition.height,
window->working_area.height * window->length,
window->working_area.height);

/* set width based on user setting */
@@ -850,7 +850,7 @@ panel_window_size_allocate (GtkWidget *widget,
gint root_x, root_y;
gint width = HIDDEN_PANEL_SIZE, height = HIDDEN_PANEL_SIZE;
gint hidden_root_x, hidden_root_y;
if (GTK_WIDGET_REALIZED (widget))
{
/* set the widget allocation */
@@ -864,7 +864,7 @@ panel_window_size_allocate (GtkWidget *widget,
&& window->autohide_window != NULL
&& window->snap_edge != PANEL_SNAP_EGDE_NONE)
{
if (window->autohide_status == VISIBLE
if (window->autohide_status == VISIBLE
|| window->autohide_status == POPDOWN_QUEUED
|| window->autohide_status == POPDOWN_QUEUED_SLOW
|| window->autohide_status == BLOCKED)
@@ -886,14 +886,14 @@ panel_window_size_allocate (GtkWidget *widget,
case PANEL_SNAP_EGDE_WC:
height = allocation->height;
break;
case PANEL_SNAP_EGDE_NC:
case PANEL_SNAP_EGDE_SC:
case PANEL_SNAP_EGDE_N:
case PANEL_SNAP_EGDE_S:
width = allocation->width;
break;
default:
if (window->horizontal)
width = allocation->width;
@@ -901,14 +901,14 @@ panel_window_size_allocate (GtkWidget *widget,
height = allocation->height;
break;
}
/* get coordinates for the hidden window */
panel_window_calculate_position (window, width, height, &hidden_root_x, &hidden_root_y);
/* position the hidden window */
gtk_window_move (GTK_WINDOW (window->autohide_window), hidden_root_x, hidden_root_y);
gtk_window_resize (GTK_WINDOW (window->autohide_window), width, height);
/* put the panel window offscreen */
root_x = root_y = OFFSCREEN;
}
@@ -921,7 +921,7 @@ panel_window_size_allocate (GtkWidget *widget,
{
/* set the child allocation */
child_allocation = *allocation;
/* change to allocation to keep the handles free */
if (window->locked == FALSE)
{
@@ -944,12 +944,12 @@ panel_window_size_allocate (GtkWidget *widget,
/* allocate the child */
gtk_widget_size_allocate (GTK_BIN (widget)->child, &child_allocation);
}
/* update struts if possible */
if (window->struts_possible != 0)
panel_window_struts_update (window, root_x, root_y, allocation->width, allocation->height);
}
/* update previous allocation */
window->prev_allocation = *allocation;
}
@@ -962,13 +962,13 @@ panel_window_screen_changed (GtkWidget *widget,
{
GdkScreen *screen;
PanelWindow *window = PANEL_WINDOW (widget);
panel_return_if_fail (PANEL_IS_WINDOW (widget));
panel_return_if_fail (GDK_IS_SCREEN (previous_screen));
/* get the new screen */
screen = gtk_window_get_screen (GTK_WINDOW (widget));
if (screen != previous_screen)
{
/* disconnect old screen changed handles */
@@ -983,10 +983,10 @@ panel_window_screen_changed (GtkWidget *widget,

/* update the panel working area */
panel_window_working_area (window, -1, -1, &window->working_area);
/* check if struts are needed on the next resize */
window->struts_possible = -1;
/* queue a resize */
gtk_widget_queue_resize (widget);
}
@@ -1194,42 +1194,42 @@ panel_window_working_area (PanelWindow *window,
gint n_monitors;
GdkRectangle geometry;
gint i;
panel_return_if_fail (PANEL_IS_WINDOW (window));
panel_return_if_fail (GDK_IS_WINDOW (GTK_WIDGET (window)->window));
/* get valid coordinates if not set */
if (root_x == -1 && root_y == -1)
gtk_window_get_position (GTK_WINDOW (window), &root_x, &root_y);
/* get panel screen */
screen = gtk_window_get_screen (GTK_WINDOW (window));
/* get the monitor number */
monitor_num = gdk_screen_get_monitor_at_point (screen, root_x, root_y);
/* get the root monitor geometry */
gdk_screen_get_monitor_geometry (screen, monitor_num, dest);
if (window->span_monitors)
{
/* get the number of monitors */
n_monitors = gdk_screen_get_n_monitors (screen);
/* only try to extend when there are more then 2 monitors */
if (G_LIKELY (n_monitors > 1))
{
/* TODO: loop for > 2 monitors */
for (i = 0; i < n_monitors; i++)
{
/* skip the origional monitor */
if (i == monitor_num)
continue;
/* get the monitor geometry */
gdk_screen_get_monitor_geometry (screen, i, &geometry);
/* try to extend the dest geometry from the root coordinate's point of view */
if (window->horizontal
&& root_y >= geometry.y
@@ -1269,23 +1269,23 @@ panel_window_struts_are_possible (PanelWindow *window,
gint n_monitors;
gint i;
GdkRectangle geometry;
panel_return_val_if_fail (PANEL_IS_WINDOW (window), FALSE);
/* never set struts when we don't snap or when autohide is enabled */
if (window->snap_edge == PANEL_SNAP_EGDE_NONE || window->autohide_status != DISABLED)
return FALSE;
/* always set struts on the following condition */
if ((window->horizontal && y == 0) || (!window->horizontal && x == 0))
return TRUE;
/* get panel screen */
screen = gtk_window_get_screen (GTK_WINDOW (window));
/* get the number of monitors */
n_monitors = gdk_screen_get_n_monitors (screen);
if (G_LIKELY (n_monitors == 1))
{
/* don't set the struts when we're not at a screen edge */
@@ -1299,13 +1299,13 @@ panel_window_struts_are_possible (PanelWindow *window,
{
/* get the monitor geometry */
gdk_screen_get_monitor_geometry (screen, i, &geometry);
if (window->horizontal
&& x >= geometry.x
&& x >= geometry.x
&& x + width <= geometry.x + geometry.width
&& y + height < geometry.y + geometry.height)
return FALSE;
if (window->horizontal == FALSE
&& y >= geometry.y
&& y + height <= geometry.y + geometry.height
@@ -1335,20 +1335,20 @@ panel_window_struts_update (PanelWindow *window,
panel_return_if_fail (GDK_IS_WINDOW (GTK_WIDGET (window)->window));
panel_return_if_fail (N_STRUTS == 12);
panel_return_if_fail (cardinal_atom != GDK_NONE);
if (G_UNLIKELY (window->struts_possible == -1))
{
/* check whether struts are possible, skip to apply if not */
window->struts_possible = panel_window_struts_are_possible (window, x, y, width, height);
/* struts are not possible, reset them only this time */
if (window->struts_possible == 0)
goto reset_only;
}