Browse Source

Initial support for Xfconf and GtkBuilder in the panel.

Add support for Xfconf to the panel and launcher plugins. Also
switch to GtkBuilder for the various dialogs. Furthermore some
fixes and cleanups.
tags/xfce4-panel-4.10.0
Nick Schermer 11 years ago
parent
commit
dbd081d31b
32 changed files with 1552 additions and 2450 deletions
  1. +0
    -1
      TODO
  2. +1
    -0
      configure.in.in
  3. +1
    -1
      libxfce4panel/xfce-arrow-button.h
  4. +1
    -1
      libxfce4panel/xfce-hvbox.h
  5. +8
    -0
      libxfce4panel/xfce-panel-macros.h
  6. +4
    -4
      libxfce4panel/xfce-panel-plugin-provider.c
  7. +4
    -1
      libxfce4panel/xfce-panel-plugin-provider.h
  8. +64
    -52
      libxfce4panel/xfce-panel-plugin.c
  9. +2
    -0
      libxfce4panel/xfce-panel-plugin.h
  10. +9
    -9
      libxfce4panel/xfce-scaled-image.c
  11. +77
    -69
      panel/Makefile.am
  12. +9
    -6
      panel/main.c
  13. +203
    -457
      panel/panel-application.c
  14. +3
    -2
      panel/panel-application.h
  15. +1
    -1
      panel/panel-dbus-service.c
  16. +2
    -1
      panel/panel-dialogs.c
  17. +19
    -227
      panel/panel-glue.c
  18. +2
    -15
      panel/panel-glue.h
  19. +25
    -75
      panel/panel-itembar.c
  20. +0
    -2
      panel/panel-itembar.h
  21. +11
    -26
      panel/panel-plugin-external.c
  22. +153
    -614
      panel/panel-preferences-dialog.c
  23. +214
    -219
      panel/panel-preferences-dialog.glade
  24. +451
    -419
      panel/panel-window.c
  25. +1
    -50
      panel/panel-window.h
  26. +2
    -0
      plugins/launcher/Makefile.am
  27. +26
    -14
      plugins/launcher/launcher-dialog.c
  28. +36
    -23
      plugins/launcher/launcher-dialog.glade
  29. +213
    -153
      plugins/launcher/launcher.c
  30. +5
    -4
      plugins/launcher/launcher.h
  31. +3
    -3
      plugins/test/xfce-test-plugin.c
  32. +2
    -1
      wrapper/main.c

+ 0
- 1
TODO View File

@@ -12,7 +12,6 @@ General

Libxfce4panel
-------------
- Add support for visibility.
- Plugin visibility support (duno if this is possible tho).

Panel


+ 1
- 0
configure.in.in View File

@@ -108,6 +108,7 @@ XDT_CHECK_PACKAGE([EXO], [exo-0.3], [0.3.90])
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])
XDT_CHECK_PACKAGE([XFCONF], [libxfconf-0], [4.5.91])

dnl ***********************************
dnl *** Check for optional packages ***


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

@@ -57,7 +57,7 @@ struct _XfceArrowButton
GtkArrowType arrow_type;
};

PANEL_SYMBOL_EXPORT
PANEL_SYMBOL_EXPORT
GType xfce_arrow_button_get_type (void) G_GNUC_CONST;

GtkWidget *xfce_arrow_button_new (GtkArrowType arrow_type) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;


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

@@ -57,7 +57,7 @@ struct _XfceHVBox
GtkOrientation orientation;
};

PANEL_SYMBOL_EXPORT
PANEL_SYMBOL_EXPORT
GType xfce_hvbox_get_type (void) G_GNUC_CONST;

GtkWidget *xfce_hvbox_new (GtkOrientation orientation,


+ 8
- 0
libxfce4panel/xfce-panel-macros.h View File

@@ -48,8 +48,16 @@ G_BEGIN_DECLS
#define panel_return_val_if_fail(expr,val) G_STMT_START{ (void)0; }G_STMT_END
#endif

/* xfconf channel for plugins */
#define XFCE_PANEL_PLUGIN_CHANNEL_NAME ("xfce4-panel")
#define xfce_panel_plugin_xfconf_channel_new(plugin) \
xfconf_channel_new_with_property_base (XFCE_PANEL_PLUGIN_CHANNEL_NAME, \
xfce_panel_plugin_get_property_base (XFCE_PANEL_PLUGIN (plugin)));

/* canonical representation for static strings */
#ifndef I_
#define I_(string) (g_intern_static_string ((string)))
#endif

/* this is defined in glib 2.13.0 */
#ifndef G_PARAM_STATIC_STRINGS


+ 4
- 4
libxfce4panel/xfce-panel-plugin-provider.c View File

@@ -52,9 +52,9 @@ xfce_panel_plugin_provider_get_type (void)
if (G_UNLIKELY (type == 0))
{
type = g_type_register_static_simple (G_TYPE_INTERFACE, I_("XfcePanelPluginProvider"),
sizeof (XfcePanelPluginProviderIface),
(GClassInitFunc) xfce_panel_plugin_provider_class_init,
0, NULL, 0);
sizeof (XfcePanelPluginProviderIface),
(GClassInitFunc) xfce_panel_plugin_provider_class_init,
0, NULL, 0);
}

return type;
@@ -145,7 +145,7 @@ xfce_panel_plugin_provider_send_signal (XfcePanelPluginProvider *provider,
XfcePanelPluginProviderSignal signal)
{
panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (provider));
/* emit the signal */
g_signal_emit (G_OBJECT (provider), provider_signals[PROVIDER_SIGNAL], 0, signal);
}

+ 4
- 1
libxfce4panel/xfce-panel-plugin-provider.h View File

@@ -42,6 +42,9 @@ typedef enum _XfcePanelPluginProviderSignal XfcePanelPluginProviderSignal;
/* relative plugin filename */
#define PANEL_PLUGIN_RELATIVE_PATH "xfce4" G_DIR_SEPARATOR_S "panel" G_DIR_SEPARATOR_S "%s-%s.rc"

/* xfconf property base */
#define PANEL_PLUGIN_PROPERTY_BASE "/plugins/plugin-%s"

/* provider contruct function */
typedef XfcePanelPluginProvider *(*PluginConstructFunc) (const gchar *name,
const gchar *id,
@@ -53,7 +56,7 @@ struct _XfcePanelPluginProviderIface
{
/*< private >*/
GTypeInterface __parent__;
/*< signals >*/
void (*provider_signal) (XfcePanelPluginProvider *provider,
XfcePanelPluginProviderSignal signal);


+ 64
- 52
libxfce4panel/xfce-panel-plugin.c View File

@@ -23,7 +23,6 @@

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

#include <libxfce4panel/libxfce4panel.h>
@@ -36,41 +35,41 @@
typedef const gchar *(*ProviderToPlugin) (XfcePanelPluginProvider *provider);


static void xfce_panel_plugin_class_init (XfcePanelPluginClass *klass);
static void xfce_panel_plugin_init (XfcePanelPlugin *plugin);
static void xfce_panel_plugin_provider_init (XfcePanelPluginProviderIface *iface);
static void xfce_panel_plugin_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
static void xfce_panel_plugin_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec);
static void xfce_panel_plugin_dispose (GObject *object);
static void xfce_panel_plugin_finalize (GObject *object);
static void xfce_panel_plugin_realize (GtkWidget *widget);
static gboolean xfce_panel_plugin_button_press_event (GtkWidget *widget,
GdkEventButton *event);
static void xfce_panel_plugin_menu_properties (XfcePanelPlugin *plugin);
static void xfce_panel_plugin_menu_about (XfcePanelPlugin *plugin);
static void xfce_panel_plugin_menu_move (XfcePanelPlugin *plugin);
static void xfce_panel_plugin_menu_remove (XfcePanelPlugin *plugin);
static void xfce_panel_plugin_menu_add_items (XfcePanelPlugin *plugin);
static void xfce_panel_plugin_menu_panel_preferences (XfcePanelPlugin *plugin);
static GtkMenu *xfce_panel_plugin_menu_get (XfcePanelPlugin *plugin);
static gchar *xfce_panel_plugin_relative_filename (XfcePanelPlugin *plugin);
static void xfce_panel_plugin_unregister_menu (GtkMenu *menu,
XfcePanelPlugin *plugin);
static void xfce_panel_plugin_set_size (XfcePanelPluginProvider *provider,
gint size);
static void xfce_panel_plugin_set_orientation (XfcePanelPluginProvider *provider,
GtkOrientation orientation);
static void xfce_panel_plugin_set_screen_position (XfcePanelPluginProvider *provider,
XfceScreenPosition screen_position);
static void xfce_panel_plugin_save (XfcePanelPluginProvider *provider);
static void xfce_panel_plugin_take_window_notify (gpointer data,
GObject *where_the_object_was);
static void xfce_panel_plugin_class_init (XfcePanelPluginClass *klass);
static void xfce_panel_plugin_init (XfcePanelPlugin *plugin);
static void xfce_panel_plugin_provider_init (XfcePanelPluginProviderIface *iface);
static void xfce_panel_plugin_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
static void xfce_panel_plugin_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec);
static void xfce_panel_plugin_dispose (GObject *object);
static void xfce_panel_plugin_finalize (GObject *object);
static void xfce_panel_plugin_realize (GtkWidget *widget);
static gboolean xfce_panel_plugin_button_press_event (GtkWidget *widget,
GdkEventButton *event);
static void xfce_panel_plugin_menu_properties (XfcePanelPlugin *plugin);
static void xfce_panel_plugin_menu_about (XfcePanelPlugin *plugin);
static void xfce_panel_plugin_menu_move (XfcePanelPlugin *plugin);
static void xfce_panel_plugin_menu_remove (XfcePanelPlugin *plugin);
static void xfce_panel_plugin_menu_add_items (XfcePanelPlugin *plugin);
static void xfce_panel_plugin_menu_panel_preferences (XfcePanelPlugin *plugin);
static GtkMenu *xfce_panel_plugin_menu_get (XfcePanelPlugin *plugin);
static inline gchar *xfce_panel_plugin_relative_filename (XfcePanelPlugin *plugin);
static void xfce_panel_plugin_unregister_menu (GtkMenu *menu,
XfcePanelPlugin *plugin);
static void xfce_panel_plugin_set_size (XfcePanelPluginProvider *provider,
gint size);
static void xfce_panel_plugin_set_orientation (XfcePanelPluginProvider *provider,
GtkOrientation orientation);
static void xfce_panel_plugin_set_screen_position (XfcePanelPluginProvider *provider,
XfceScreenPosition screen_position);
static void xfce_panel_plugin_save (XfcePanelPluginProvider *provider);
static void xfce_panel_plugin_take_window_notify (gpointer data,
GObject *where_the_object_was);



@@ -101,6 +100,7 @@ struct _XfcePanelPluginPrivate
gchar *name;
gchar *display_name;
gchar *id;
gchar *property_base;
gchar **arguments;
gint size;
guint expand : 1;
@@ -374,6 +374,7 @@ xfce_panel_plugin_init (XfcePanelPlugin *plugin)
plugin->priv->name = NULL;
plugin->priv->display_name = NULL;
plugin->priv->id = NULL;
plugin->priv->property_base = NULL;
plugin->priv->arguments = NULL;
plugin->priv->size = 0;
plugin->priv->expand = FALSE;
@@ -504,6 +505,7 @@ xfce_panel_plugin_finalize (GObject *object)
g_free (plugin->priv->name);
g_free (plugin->priv->display_name);
g_free (plugin->priv->id);
g_free (plugin->priv->property_base);
g_strfreev (plugin->priv->arguments);

(*G_OBJECT_CLASS (xfce_panel_plugin_parent_class)->finalize) (object);
@@ -516,7 +518,7 @@ xfce_panel_plugin_realize (GtkWidget *widget)
{
XfcePanelPluginClass *klass = XFCE_PANEL_PLUGIN_GET_CLASS (widget);
XfcePanelPlugin *plugin = XFCE_PANEL_PLUGIN (widget);
/* allow gtk to realize the plugin */
(*GTK_WIDGET_CLASS (xfce_panel_plugin_parent_class)->realize) (widget);

@@ -525,7 +527,7 @@ xfce_panel_plugin_realize (GtkWidget *widget)
{
/* run the construct function */
(*klass->construct) (XFCE_PANEL_PLUGIN (widget));
/* don't run the construct function again on another realize */
plugin->priv->constructed = TRUE;
}
@@ -604,7 +606,6 @@ static void
xfce_panel_plugin_menu_remove (XfcePanelPlugin *plugin)
{
GtkWidget *dialog;
gchar *filename;

panel_return_if_fail (XFCE_IS_PANEL_PLUGIN (plugin));

@@ -630,17 +631,6 @@ xfce_panel_plugin_menu_remove (XfcePanelPlugin *plugin)
/* hide the dialog */
gtk_widget_hide (dialog);

/* get the plugin config file */
filename = xfce_panel_plugin_save_location (plugin, FALSE);
if (G_LIKELY (filename))
{
/* remove the file */
g_unlink (filename);

/* cleanup */
g_free (filename);
}

/* ask the panel or wrapper to remove the plugin */
xfce_panel_plugin_provider_send_signal (XFCE_PANEL_PLUGIN_PROVIDER (plugin), REMOVE_PLUGIN);
}
@@ -770,7 +760,7 @@ xfce_panel_plugin_menu_get (XfcePanelPlugin *plugin)



static gchar *
static inline gchar *
xfce_panel_plugin_relative_filename (XfcePanelPlugin *plugin)
{
panel_return_val_if_fail (XFCE_IS_PANEL_PLUGIN (plugin), NULL);
@@ -958,11 +948,33 @@ xfce_panel_plugin_get_id (XfcePanelPlugin *plugin)



/**
* xfce_panel_plugin_get_property_base:
* @plugin :
*
* Return value: the property base for the xfconf channel userd by a plugin.
*
* See also: xfconf_channel_new_with_property_base() and XFCE_PANEL_PLUGIN_CHANNEL_NAME.
**/
PANEL_SYMBOL_EXPORT const gchar *
xfce_panel_plugin_get_property_base (XfcePanelPlugin *plugin)
{
g_return_val_if_fail (XFCE_IS_PANEL_PLUGIN (plugin), NULL);

/* create the propert if needed */
if (plugin->priv->property_base == NULL)
plugin->priv->property_base = g_strdup_printf (PANEL_PLUGIN_PROPERTY_BASE, plugin->priv->id);

return plugin->priv->property_base;
}



/**
* xfce_panel_plugin_get_arguments:
* @plugin : an #XfcePanelPlugin.
*
* Return value: the argument vector. The vector is owned by the plugin and
* Return value: the argument vector. The vector is owned by the plugin and
* should not be freed.
*
* Since: 4.8.0


+ 2
- 0
libxfce4panel/xfce-panel-plugin.h View File

@@ -89,6 +89,8 @@ const gchar *xfce_panel_plugin_get_display_name (XfcePanelPlugin *p

const gchar *xfce_panel_plugin_get_id (XfcePanelPlugin *plugin);

const gchar *xfce_panel_plugin_get_property_base (XfcePanelPlugin *plugin);

const gchar * const *xfce_panel_plugin_get_arguments (XfcePanelPlugin *plugin);

gint xfce_panel_plugin_get_size (XfcePanelPlugin *plugin);


+ 9
- 9
libxfce4panel/xfce-scaled-image.c View File

@@ -265,12 +265,12 @@ xfce_scaled_image_update_cache (XfceScaledImage *image)
MIN (image->width, image->height),
0, NULL);
}
if (G_LIKELY (pixbuf))
{
/* create a cache icon that fits in the available size */
image->cache = xfce_scaled_image_scale_pixbuf (pixbuf, image->width, image->height);
/* release the pixbuf */
g_object_unref (G_OBJECT (pixbuf));
}
@@ -284,14 +284,14 @@ xfce_scaled_image_cleanup (XfceScaledImage *image)
/* release the pixbuf reference */
if (G_LIKELY (image->pixbuf))
g_object_unref (G_OBJECT (image->pixbuf));
/* release the cached pixbuf */
if (G_LIKELY (image->cache))
g_object_unref (G_OBJECT (image->cache));

/* free the icon name */
g_free (image->icon_name);
/* reset varaibles */
image->pixbuf = NULL;
image->cache = NULL;
@@ -366,17 +366,17 @@ xfce_scaled_image_set_from_pixbuf (XfceScaledImage *image,
{
gint source_width;
gint source_height;
g_return_if_fail (XFCE_IS_SCALED_IMAGE (image));
g_return_if_fail (pixbuf == NULL || GDK_IS_PIXBUF (pixbuf));

/* cleanup */
xfce_scaled_image_cleanup (image);
/* get the new pixbuf sizes */
source_width = gdk_pixbuf_get_width (pixbuf);
source_height = gdk_pixbuf_get_height (pixbuf);
/* set the new pixbuf, scale it to the maximum size if needed */
if (G_LIKELY (source_width <= MAX_PIXBUF_SIZE && source_height <= MAX_PIXBUF_SIZE))
image->pixbuf = g_object_ref (G_OBJECT (pixbuf));
@@ -418,7 +418,7 @@ xfce_scaled_image_set_from_file (XfceScaledImage *image,

g_return_if_fail (XFCE_IS_SCALED_IMAGE (image));
panel_return_if_fail (filename == NULL || g_path_is_absolute (filename));
/* cleanup */
xfce_scaled_image_cleanup (image);

@@ -431,7 +431,7 @@ xfce_scaled_image_set_from_file (XfceScaledImage *image,
{
/* set the new pixbuf */
xfce_scaled_image_set_from_pixbuf (image, pixbuf);
/* release the pixbuf */
g_object_unref (G_OBJECT (pixbuf));
}


+ 77
- 69
panel/Makefile.am View File

@@ -1,81 +1,84 @@
# $Id$

INCLUDES = \
-I$(top_srcdir) \
-I$(top_builddir) \
-DG_LOG_DOMAIN=\"xfce4-panel\" \
-DDATADIR=\"$(datadir)\" \
-DLIBDIR=\"$(libdir)/xfce4\" \
-DLIBEXECDIR=\"$(libexecdir)\" \
-DSYSCONFDIR=\"$(sysconfdir)\" \
-DPACKAGE_LOCALE_DIR=\"$(localedir)\" \
-DDBUS_API_SUBJECT_TO_CHANGE \
INCLUDES = \
-I$(top_srcdir) \
-I$(top_builddir) \
-DG_LOG_DOMAIN=\"xfce4-panel\" \
-DDATADIR=\"$(datadir)\" \
-DLIBDIR=\"$(libdir)/xfce4\" \
-DLIBEXECDIR=\"$(libexecdir)\" \
-DSYSCONFDIR=\"$(sysconfdir)\" \
-DPACKAGE_LOCALE_DIR=\"$(localedir)\" \
-DDBUS_API_SUBJECT_TO_CHANGE \
$(PLATFORM_CPPFLAGS)

bin_PROGRAMS = \
bin_PROGRAMS = \
xfce4-panel
xfce4_panel_built_sources = \
panel-dbus-service-infos.h \
xfce4_panel_built_sources = \
panel-dbus-service-infos.h \
panel-dbus-client-infos.h \
panel-marshal.h \
panel-marshal.c

xfce4_panel_SOURCES = \
$(xfce4_panel_built_sources) \
main.c \
panel-application.c \
panel-application.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 \
panel-glue.h \
panel-item-dialog.c \
panel-item-dialog.h \
panel-itembar.c \
panel-itembar.h \
panel-module.c \
panel-module.h \
panel-module-factory.c \
panel-module-factory.h \
panel-plugin-external.c \
panel-plugin-external.h \
panel-preferences-dialog.c \
panel-preferences-dialog.h \
panel-private.c \
panel-private.h \
panel-window.c \
panel-marshal.h \
panel-marshal.c \
panel-preferences-dialog-glade.h

xfce4_panel_SOURCES = \
$(xfce4_panel_built_sources) \
main.c \
panel-application.c \
panel-application.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 \
panel-glue.h \
panel-item-dialog.c \
panel-item-dialog.h \
panel-itembar.c \
panel-itembar.h \
panel-module.c \
panel-module.h \
panel-module-factory.c \
panel-module-factory.h \
panel-plugin-external.c \
panel-plugin-external.h \
panel-preferences-dialog.c \
panel-preferences-dialog.h \
panel-private.c \
panel-private.h \
panel-window.c \
panel-window.h

xfce4_panel_CFLAGS = \
$(GTK_CFLAGS) \
$(GMODULE_CFLAGS) \
$(GTHREAD_CFLAGS) \
$(EXO_CFLAGS) \
$(LIBXFCE4UTIL_CFLAGS) \
$(LIBXFCE4UI_CFLAGS) \
$(DBUS_CFLAGS) \
xfce4_panel_CFLAGS = \
$(GTK_CFLAGS) \
$(GMODULE_CFLAGS) \
$(GTHREAD_CFLAGS) \
$(EXO_CFLAGS) \
$(LIBXFCE4UTIL_CFLAGS) \
$(LIBXFCE4UI_CFLAGS) \
$(DBUS_CFLAGS) \
$(XFCONF_CFLAGS) \
$(PLATFORM_CFLAGS)

xfce4_panel_LDFLAGS = \
-no-undefined \
xfce4_panel_LDFLAGS = \
-no-undefined \
$(PLATFORM_LDFLAGS)

xfce4_panel_LDADD = \
$(top_builddir)/libxfce4panel/libxfce4panel.la \
$(GTK_LIBS) \
$(EXO_LIBS) \
$(GMODULE_LIBS) \
$(GTHREAD_LIBS) \
$(LIBXFCE4UTIL_LIBS) \
$(LIBXFCE4UI_LIBS) \
xfce4_panel_LDADD = \
$(top_builddir)/libxfce4panel/libxfce4panel.la \
$(GTK_LIBS) \
$(EXO_LIBS) \
$(GMODULE_LIBS) \
$(GTHREAD_LIBS) \
$(LIBXFCE4UTIL_LIBS) \
$(LIBXFCE4UI_LIBS) \
$(XFCONF_LIBS) \
$(DBUS_LIBS)

xfce4_panel_DEPENDENCIES = \
xfce4_panel_DEPENDENCIES = \
$(top_builddir)/libxfce4panel/libxfce4panel.la

if MAINTAINER_MODE
@@ -86,21 +89,26 @@ panel-dbus-service-infos.h: $(srcdir)/panel-dbus-service-infos.xml Makefile
panel-dbus-client-infos.h: $(srcdir)/panel-dbus-service-infos.xml Makefile
dbus-binding-tool --mode=glib-client $< > $@

panel-preferences-dialog-glade.h: $(srcdir)/panel-preferences-dialog.glade Makefile
exo-csource --static --strip-comments --strip-content --name=panel_preferences_dialog_glade $< >$@

panel-marshal.h: $(srcdir)/panel-marshal.list Makefile
glib-genmarshal --header --prefix=panel_marshal $< > $@

panel-marshal.c: $(srcdir)/panel-marshal.list Makefile
glib-genmarshal --body --prefix=panel_marshal $< > $@

DISTCLEANFILES = \
DISTCLEANFILES = \
$(xfce4_panel_built_sources)

BUILT_SOURCES = \
BUILT_SOURCES = \
$(xfce4_panel_built_sources)

endif

EXTRA_DIST = \
panel-dbus-service-infos.xml \
panel-marshal.list
EXTRA_DIST = \
panel-dbus-service-infos.xml \
panel-marshal.list \
panel-preferences-dialog.glade

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

+ 9
- 6
panel/main.c View File

@@ -35,6 +35,7 @@
#endif

#include <glib.h>
#include <xfconf/xfconf.h>
#include <libxfce4util/libxfce4util.h>

#include <panel/panel-private.h>
@@ -142,11 +143,6 @@ main (gint argc, gchar **argv)
/* set translation domain */
xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");

//#ifndef NDEBUG
// /* terminate the program on warnings and critical messages */
// g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING);
//#endif

/* initialize the gthread system */
if (g_thread_supported () == FALSE)
g_thread_init (NULL);
@@ -237,6 +233,10 @@ main (gint argc, gchar **argv)
goto dbus_return;
}

/* initialize xfconf */
/* TODO */
xfconf_init (NULL);

/* create dbus service */
dbus_service = panel_dbus_service_get ();

@@ -257,11 +257,14 @@ main (gint argc, gchar **argv)
panel_application_destroy_dialogs (application);

/* save the configuration */
panel_application_save (application);
panel_application_save (application, TRUE);

/* release application reference */
g_object_unref (G_OBJECT (application));

/* shutdown xfconf */
xfconf_shutdown ();

/* whether we need to restart */
if (dbus_quit_with_restart)
{


+ 203
- 457
panel/panel-application.c View File

@@ -26,6 +26,8 @@
#endif

#include <exo/exo.h>
#include <glib/gstdio.h>
#include <xfconf/xfconf.h>
#include <libxfce4util/libxfce4util.h>
#include <libxfce4panel/libxfce4panel.h>
#include <libxfce4panel/xfce-panel-plugin-provider.h>
@@ -41,7 +43,6 @@
#include <panel/panel-glue.h>
#include <panel/panel-plugin-external.h>

#define PANEL_CONFIG_PATH "xfce4" G_DIR_SEPARATOR_S "panel" G_DIR_SEPARATOR_S "panels.new.xml"
#define AUTOSAVE_INTERVAL (10 * 60)


@@ -50,19 +51,6 @@ static void panel_application_class_init (PanelApplicationClass *k
static void panel_application_init (PanelApplication *application);
static void panel_application_finalize (GObject *object);
static void panel_application_load (PanelApplication *application);
static void panel_application_load_set_property (PanelWindow *window,
const gchar *name,
const gchar *value);
static void panel_application_load_start_element (GMarkupParseContext *context,
const gchar *element_name,
const gchar **attribute_names,
const gchar **attribute_values,
gpointer user_data,
GError **error);
static void panel_application_load_end_element (GMarkupParseContext *context,
const gchar *element_name,
gpointer user_data,
GError **error);
static void panel_application_plugin_move (GtkWidget *item,
PanelApplication *application);
static gboolean panel_application_plugin_insert (PanelApplication *application,
@@ -73,7 +61,7 @@ static gboolean panel_application_plugin_insert (PanelApplication *a
gchar **arguments,
gint position);
static gboolean panel_application_save_timeout (gpointer user_data);
static gchar *panel_application_save_xml_contents (PanelApplication *application);
static void panel_application_save_reschedule (PanelApplication *application);
static void panel_application_window_destroyed (GtkWidget *window,
PanelApplication *application);
static void panel_application_dialog_destroyed (GtkWindow *dialog,
@@ -107,6 +95,9 @@ struct _PanelApplication
/* the plugin factory */
PanelModuleFactory *factory;

/* xfconf channel */
XfconfChannel *xfconf;

/* internal list of all the panel windows */
GSList *windows;

@@ -117,33 +108,6 @@ struct _PanelApplication
guint autosave_timeout_id;
};

typedef enum
{
PARSER_START,
PARSER_PANELS,
PARSER_PANEL,
PARSER_PROPERTIES,
PARSER_ITEMS
}
ParserState;

typedef struct
{
ParserState state;
PanelApplication *application;
PanelWindow *window;
}
Parser;

static GMarkupParser markup_parser =
{
panel_application_load_start_element,
panel_application_load_end_element,
NULL,
NULL,
NULL
};

static const GtkTargetEntry drag_targets[] =
{
{ "application/x-xfce-panel-plugin-widget", 0, 0 }
@@ -172,19 +136,19 @@ panel_application_init (PanelApplication *application)
/* initialize */
application->windows = NULL;
application->dialogs = NULL;
application->autosave_timeout_id = 0;

/* get a factory reference so it never unloads */
application->factory = panel_module_factory_get ();

/* get the xfconf channel */
application->xfconf = xfconf_channel_new ("xfce4-panel");

/* load setup */
panel_application_load (application);

/* start the autosave timeout */
#if GLIB_CHECK_VERSION (2, 14, 0)
application->autosave_timeout_id = g_timeout_add_seconds (AUTOSAVE_INTERVAL, panel_application_save_timeout, application);
#else
application->autosave_timeout_id = g_timeout_add (AUTOSAVE_INTERVAL * 1000, panel_application_save_timeout, application);
#endif
panel_application_save_reschedule (application);
}


@@ -210,6 +174,9 @@ panel_application_finalize (GObject *object)
/* cleanup the list of windows */
g_slist_free (application->windows);

/* release the xfconf channel */
g_object_unref (G_OBJECT (application->xfconf));

/* release the factory */
g_object_unref (G_OBJECT (application->factory));

@@ -219,299 +186,109 @@ panel_application_finalize (GObject *object)


static void
panel_application_load (PanelApplication *application)
{
gchar *filename;
gchar *contents;
gboolean succeed = FALSE;
gsize length;
GError *error = NULL;
GMarkupParseContext *context;
Parser parser;
PanelWindow *window;

panel_return_if_fail (PANEL_IS_APPLICATION (application));

if (G_LIKELY (TRUE))
{
/* get filename from user config */
filename = xfce_resource_lookup (XFCE_RESOURCE_CONFIG, PANEL_CONFIG_PATH);
}
else
panel_application_xfconf_window_bindings (PanelApplication *application,
PanelWindow *window,
gboolean store_settings)
{
XfconfChannel *channel = application->xfconf;
gchar buf[100];
guint i;
guint index = g_slist_index (application->windows, window);
GValue value = { 0, };
const gchar *bool_properties[] = { "locked", "autohide", "span-monitors", "horizontal" };
const gchar *uint_properties[] = { "size", "length", "x-offset", "y-offset",
"enter-opacity", "leave-opacity", "snap-edge",
"background-alpha" };

/* connect the boolean properties */
for (i = 0; i < G_N_ELEMENTS (bool_properties); i++)
{
/* get config from xdg directory (kiosk mode) */
filename = g_build_filename (SYSCONFDIR, PANEL_CONFIG_PATH, NULL);
}
/* create xfconf property name */
g_snprintf (buf, sizeof (buf), "/panels/panel-%u/%s", index, bool_properties[i]);

/* test config file */
if (G_LIKELY (filename && g_file_test (filename, G_FILE_TEST_IS_REGULAR)))
{
/* load the file contents */
succeed = g_file_get_contents (filename, &contents, &length, &error);
if (G_LIKELY (succeed))
/* store the window settings in the channel before we create the binding,
* so we don't loose the panel settings */
if (store_settings)
{
/* initialize the parser */
parser.state = PARSER_START;
parser.application = application;
parser.window = NULL;

/* create parse context */
context = g_markup_parse_context_new (&markup_parser, 0, &parser, NULL);

/* parse the content */
succeed = g_markup_parse_context_parse (context, contents, length, &error);
if (G_UNLIKELY (succeed == FALSE))
goto done;

/* finish parsing */
succeed = g_markup_parse_context_end_parse (context, &error);

/* goto label */
done:

/* cleanup */
g_markup_parse_context_free (context);
g_free (contents);

/* show error */
if (G_UNLIKELY (succeed == FALSE))
{
/* print warning */
g_critical ("Failed to parse configuration from \"%s\": %s", filename, error->message);

/* cleanup */
g_error_free (error);
}
g_value_init(&value, G_TYPE_BOOLEAN);
g_object_get_property (G_OBJECT (window), bool_properties[i], &value);
xfconf_channel_set_property (channel, buf, &value);
g_value_unset (&value);
}
else
{
/* print warning */
g_critical ("Failed to load configuration from \"%s\": %s", filename, error->message);

/* cleanup */
g_error_free (error);
}
/* create binding */
xfconf_g_property_bind (channel, buf, G_TYPE_BOOLEAN, window, bool_properties[i]);
}

/* cleanup */
g_free (filename);

/* loading failed, create fallback panel */
if (G_UNLIKELY (succeed == FALSE || application->windows == NULL))
/* connect the unsigned intergets */
for (i = 0; i < G_N_ELEMENTS (uint_properties); i++)
{
/* create empty panel window */
window = panel_application_new_window (application, NULL);
/* create xfconf property name */
g_snprintf (buf, sizeof (buf), "/panels/panel-%u/%s", index, uint_properties[i]);

/* TODO: create fallback panel layout instead of an empty window
* not entritely sure if an empty window is that bad... */
/* store the window settings in the channel before we create the binding,
* so we don't loose the panel settings */
if (store_settings)
{
g_value_init(&value, G_TYPE_UINT);
g_object_get_property (G_OBJECT (window), uint_properties[i], &value);
xfconf_channel_set_property (channel, buf, &value);
g_value_unset (&value);
}

/* show window */
gtk_widget_show (GTK_WIDGET (window));
/* create binding */
xfconf_g_property_bind (channel, buf, G_TYPE_UINT, window, uint_properties[i]);
}
}



static void
panel_application_load_set_property (PanelWindow *window,
const gchar *name,
const gchar *value)
panel_application_load (PanelApplication *application)
{
gint integer;
XfconfChannel *channel = application->xfconf;
PanelWindow *window;
guint i, n_panels;
guint j, n_plugins;
gchar buf[100];
gchar *name, *id;

panel_return_if_fail (name != NULL && value != NULL);
panel_return_if_fail (PANEL_IS_WINDOW (window));

/* get the integer */
integer = atoi (value);

/* set the property */
if (exo_str_is_equal (name, "locked"))
panel_window_set_locked (window, !!integer);
else if (exo_str_is_equal (name, "orientation"))
panel_window_set_orientation (window, integer == 1 ? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL);
else if (exo_str_is_equal (name, "size"))
panel_window_set_size (window, integer);
else if (exo_str_is_equal (name, "snap-edge"))
panel_window_set_snap_edge (window, CLAMP (integer, PANEL_SNAP_EGDE_NONE, PANEL_SNAP_EGDE_S));
else if (exo_str_is_equal (name, "length"))
panel_window_set_length (window, integer);
else if (exo_str_is_equal (name, "autohide"))
panel_window_set_autohide (window, !!integer);
else if (exo_str_is_equal (name, "xoffset"))
panel_window_set_xoffset (window, integer);
else if (exo_str_is_equal (name, "yoffset"))
panel_window_set_yoffset (window, integer);
else if (exo_str_is_equal (name, "background-alpha"))
panel_window_set_background_alpha (window, integer);
else if (exo_str_is_equal (name, "enter-opacity"))
panel_window_set_enter_opacity (window, integer);
else if (exo_str_is_equal (name, "leave-opacity"))
panel_window_set_leave_opacity (window, integer);
else if (exo_str_is_equal (name, "span-monitors"))
panel_window_set_span_monitors (window, !!integer);

/* xfce 4.4 panel compatibility */
else if (exo_str_is_equal (name, "transparency"))
panel_window_set_leave_opacity (window, integer);
else if (exo_str_is_equal (name, "activetrans"))
panel_window_set_enter_opacity (window, integer == 1 ? 100 : panel_window_get_leave_opacity (window));
else if (exo_str_is_equal (name, "fullwidth"))
{
/* 0: normal width, 1: full width and 2: span monitors */
if (integer > 1)
panel_window_set_length (window, 100);

if (integer == 2)
panel_window_set_span_monitors (window, TRUE);
}
else if (exo_str_is_equal (name, "screen-position"))
{
/* TODO: convert to the old screen position enum */
}
}



static void
panel_application_load_start_element (GMarkupParseContext *context,
const gchar *element_name,
const gchar **attribute_names,
const gchar **attribute_values,
gpointer user_data,
GError **error)
{
Parser *parser = user_data;
gint n;
const gchar *name = NULL;
const gchar *value = NULL;
const gchar *id = NULL;
panel_return_if_fail (PANEL_IS_APPLICATION (application));
panel_return_if_fail (XFCONF_IS_CHANNEL (application->xfconf));

switch (parser->state)
/* walk all the panel in the configuration */
n_panels = xfconf_channel_get_uint (channel, "/panels", 0);
for (i = 0; i < n_panels; i++)
{
case PARSER_START:
/* update parser state */
if (exo_str_is_equal (element_name, "panels"))
parser->state = PARSER_PANELS;
break;

case PARSER_PANELS:
if (exo_str_is_equal (element_name, "panel"))
{
/* update parser state */
parser->state = PARSER_PANEL;

/* create new window */
parser->window = panel_application_new_window (parser->application, NULL);
}
break;

case PARSER_PANEL:
/* update parser state */
if (exo_str_is_equal (element_name, "properties"))
parser->state = PARSER_PROPERTIES;
else if (exo_str_is_equal (element_name, "items"))
parser->state = PARSER_ITEMS;
break;
/* create a new window */
window = panel_application_new_window (application, NULL);

case PARSER_PROPERTIES:
if (exo_str_is_equal (element_name, "property"))
{
/* walk attributes */
for (n = 0; attribute_names[n] != NULL; n++)
{
if (exo_str_is_equal (attribute_names[n], "name"))
name = attribute_values[n];
else if (exo_str_is_equal (attribute_names[n], "value"))
value = attribute_values[n];
}

/* set panel property */
if (G_LIKELY (name != NULL && value != NULL))
panel_application_load_set_property (parser->window, name, value);
}
break;
/* walk all the plugins on the panel */
g_snprintf (buf, sizeof (buf), "/panels/panel-%u/plugins", i);
n_plugins = xfconf_channel_get_uint (channel, buf, 0);
for (j = 0; j < n_plugins; j++)
{
/* get the plugin module name */
g_snprintf (buf, sizeof (buf), "/panels/panel-%u/plugins/plugin-%u/module", i, j);
name = xfconf_channel_get_string (channel, buf, NULL);
if (G_LIKELY (name))
{
/* read the plugin id */
g_snprintf (buf, sizeof (buf), "/panels/panel-%u/plugins/plugin-%u/id", i, j);
id = xfconf_channel_get_string (channel, buf, NULL);

case PARSER_ITEMS:
if (exo_str_is_equal (element_name, "item"))
{
panel_return_if_fail (PANEL_IS_WINDOW (parser->window));

/* walk attributes */
for (n = 0; attribute_names[n] != NULL; n++)
{
/* get plugin name and id */
if (exo_str_is_equal (attribute_names[n], "name"))
name = attribute_values[n];
else if (exo_str_is_equal (attribute_names[n], "id"))
id = attribute_values[n];
}

/* append the new plugin */
if (G_LIKELY (name != NULL))
panel_application_plugin_insert (parser->application, parser->window,
gtk_window_get_screen (GTK_WINDOW (parser->window)),
panel_application_plugin_insert (application, window,
gtk_window_get_screen (GTK_WINDOW (window)),
name, id, NULL, -1);
}
break;

default:
/* set an error */
g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_UNKNOWN_ELEMENT,
"Unknown element <%s>", element_name);
break;
}
}


/* cleanup */
g_free (name);
g_free (id);
}
}

static void
panel_application_load_end_element (GMarkupParseContext *context,
const gchar *element_name,
gpointer user_data,
GError **error)
{
Parser *parser = user_data;

switch (parser->state)
{
case PARSER_PANELS:
/* update state */
if (exo_str_is_equal (element_name, "panels"))
parser->state = PARSER_START;
break;

case PARSER_PANEL:
if (exo_str_is_equal (element_name, "panel"))
{
panel_return_if_fail (PANEL_IS_WINDOW (parser->window));

/* show panel */
gtk_widget_show (GTK_WIDGET (parser->window));

/* update parser state */
parser->state = PARSER_PANELS;
parser->window = NULL;
}
break;

case PARSER_PROPERTIES:
/* update state */
if (exo_str_is_equal (element_name, "properties"))
parser->state = PARSER_PANEL;
break;

case PARSER_ITEMS:
/* update state */
if (exo_str_is_equal (element_name, "items"))
parser->state = PARSER_PANEL;
break;

default:
/* set an error */
g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_UNKNOWN_ELEMENT,
"Unknown element <%s>", element_name);
break;
/* show the window */
gtk_widget_show (GTK_WIDGET (window));
}
}

@@ -574,6 +351,8 @@ panel_application_plugin_provider_signal (XfcePanelPluginProvider *provide
{
GtkWidget *itembar;
PanelWindow *window;
gchar *property;
gchar *path, *filename;

panel_return_if_fail (PANEL_IS_APPLICATION (application));
panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (provider));
@@ -608,9 +387,31 @@ panel_application_plugin_provider_signal (XfcePanelPluginProvider *provide
break;

case REMOVE_PLUGIN:
/* create the xfconf property base */
property = g_strdup_printf (PANEL_PLUGIN_PROPERTY_BASE,
xfce_panel_plugin_provider_get_id (provider));

/* build the plugin rc filename */
filename = g_strdup_printf (PANEL_PLUGIN_RELATIVE_PATH,
xfce_panel_plugin_provider_get_name (provider),
xfce_panel_plugin_provider_get_id (provider));

/* destroy the plugin if it's a panel plugin (ie. not external) */
if (XFCE_IS_PANEL_PLUGIN (provider))
gtk_widget_destroy (GTK_WIDGET (provider));

/* remove the xfconf properties */
xfconf_channel_reset_property (application->xfconf, property, TRUE);
g_free (property);

/* get the path of the config file */
path = xfce_resource_lookup (XFCE_RESOURCE_CONFIG, filename);
g_free (filename);

/* remove the config file */
if (G_LIKELY (path))
g_unlink (path);
g_free (path);
break;

case ADD_NEW_ITEMS:
@@ -686,7 +487,7 @@ panel_application_save_timeout (gpointer user_data)
GDK_THREADS_ENTER ();

/* save */
panel_application_save (PANEL_APPLICATION (user_data));
panel_application_save (PANEL_APPLICATION (user_data), TRUE);

GDK_THREADS_LEAVE ();

@@ -695,109 +496,19 @@ panel_application_save_timeout (gpointer user_data)



static gchar *
panel_application_save_xml_contents (PanelApplication *application)
static void
panel_application_save_reschedule (PanelApplication *application)
{
GString *contents;
GSList *li;
PanelWindow *window;
GtkWidget *itembar;
GList *children, *lp;
XfcePanelPluginProvider *provider;
gchar *date_string;
GTimeVal stamp;

panel_return_val_if_fail (PANEL_IS_APPLICATION (application), NULL);

/* create string with some size to avoid reallocations */
contents = g_string_sized_new (3072);

/* create time string */
g_get_current_time (&stamp);
date_string = g_time_val_to_iso8601 (&stamp);

/* start xml file */
g_string_append_printf (contents, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
"<!DOCTYPE config SYSTEM \"config.dtd\">\n"
"<!-- Generated on %s -->\n"
"<panels>\n", date_string);

/* cleanup */
g_free (date_string);

/* store each panel */
for (li = application->windows; li != NULL; li = li->next)
{
/* get window */
window = PANEL_WINDOW (li->data);

/* panel grouping */
contents = g_string_append (contents, "\t<panel>\n"
"\t\t<properties>\n");

/* store panel properties */
g_string_append_printf (contents, "\t\t\t<property name=\"locked\" value=\"%d\" />\n"
"\t\t\t<property name=\"orientation\" value=\"%d\" />\n"
"\t\t\t<property name=\"size\" value=\"%d\" />\n"
"\t\t\t<property name=\"snap-edge\" value=\"%d\" />\n"
"\t\t\t<property name=\"length\" value=\"%d\" />\n"
"\t\t\t<property name=\"autohide\" value=\"%d\" />\n"
"\t\t\t<property name=\"xoffset\" value=\"%d\" />\n"
"\t\t\t<property name=\"yoffset\" value=\"%d\" />\n"
"\t\t\t<property name=\"background-alpha\" value=\"%d\" />\n"
"\t\t\t<property name=\"enter-opacity\" value=\"%d\" />\n"
"\t\t\t<property name=\"leave-opacity\" value=\"%d\" />\n"
"\t\t\t<property name=\"span-monitors\" value=\"%d\" />\n",
panel_window_get_locked (window),
panel_window_get_orientation (window),
panel_window_get_size (window),
panel_window_get_snap_edge (window),
panel_window_get_length (window),
panel_window_get_autohide (window),
panel_window_get_xoffset (window),
panel_window_get_yoffset (window),
panel_window_get_background_alpha (window),
panel_window_get_enter_opacity (window),
panel_window_get_leave_opacity (window),
panel_window_get_span_monitors (window));

/* item grouping */
contents = g_string_append (contents, "\t\t</properties>\n"
"\t\t<items>\n");

/* get the itembar */
itembar = gtk_bin_get_child (GTK_BIN (window));

/* debug check */
panel_assert (PANEL_IS_ITEMBAR (itembar));

/* get the itembar children */
children = gtk_container_get_children (GTK_CONTAINER (itembar));

/* store the plugin properties */
for (lp = children; lp != NULL; lp = lp->next)
{
/* cast to a plugin provider */
provider = XFCE_PANEL_PLUGIN_PROVIDER (lp->data);

/* store plugin name and id */
g_string_append_printf (contents, "\t\t\t<item name=\"%s\" id=\"%s\" />\n",
xfce_panel_plugin_provider_get_name (provider),
xfce_panel_plugin_provider_get_id (provider));
}

/* cleanup */
g_list_free (children);

/* close grouping */
contents = g_string_append (contents, "\t\t</items>\n"
"\t</panel>\n");
}
panel_return_if_fail (PANEL_IS_APPLICATION (application));

/* close xml file */
contents = g_string_append (contents, "</panels>\n");
/* stop a running timeout */
if (G_UNLIKELY (application->autosave_timeout_id != 0))
g_source_remove (application->autosave_timeout_id);

return g_string_free (contents, FALSE);
/* start a new timeout */
application->autosave_timeout_id = g_timeout_add_seconds (AUTOSAVE_INTERVAL,
panel_application_save_timeout,
application);
}


@@ -806,12 +517,43 @@ static void
panel_application_window_destroyed (GtkWidget *window,
PanelApplication *application)
{
guint n;
gchar buf[100];
GSList *li, *lnext;
gboolean passed_destroyed_window = FALSE;

panel_return_if_fail (PANEL_IS_WINDOW (window));
panel_return_if_fail (PANEL_IS_APPLICATION (application));
panel_return_if_fail (g_slist_find (application->windows, window) != NULL);

/* remove the window from the list */
application->windows = g_slist_remove (application->windows, window);
/* we need to update the bindings of all the panels... */
for (li = application->windows, n = 0; li != NULL; li = lnext, n++)
{
lnext = li->next;

/* skip window if we're not passed the active window */
if (!passed_destroyed_window && li->data != window)
continue;

/* keep updating from now on */
passed_destroyed_window = TRUE;

/* disconnect bindings from this panel */
xfconf_g_property_unbind_all (G_OBJECT (li->data));

/* remove the properties of this panel */
g_snprintf (buf, sizeof (buf), "/panels/panel-%u", n);
xfconf_channel_reset_property (application->xfconf, buf, TRUE);

/* either remove the window or add the bindings */
if (li->data == window)
application->windows = g_slist_delete_link (application->windows, li);
else
panel_application_xfconf_window_bindings (application, PANEL_WINDOW (li->data), TRUE);
}

/* force a panel save to store plugins and panel count */
panel_application_save (application, FALSE);

/* quit if there are no windows opened */
if (application->windows == NULL)
@@ -923,7 +665,7 @@ panel_application_drag_data_received (GtkWidget *itembar,

/* save the panel configuration if we succeeded */
if (G_LIKELY (succeed))
panel_application_save (application);
panel_application_save (application, FALSE);

/* release the application */
g_object_unref (G_OBJECT (application));
@@ -984,54 +726,55 @@ panel_application_get (void)


void
panel_application_save (PanelApplication *application)
panel_application_save (PanelApplication *application,
gboolean save_plugin_providers)
{
gchar *filename;
gchar *contents;
gboolean succeed;
GError *error = NULL;
GSList *li;
GtkWidget *itembar;
GSList *li;
GList *children, *lp;
GtkWidget *itembar;
XfcePanelPluginProvider *provider;
guint i, j;
gchar buf[100];
XfconfChannel *channel = application->xfconf;

panel_return_if_fail (PANEL_IS_APPLICATION (application));
panel_return_if_fail (XFCONF_IS_CHANNEL (channel));

/* get save location */
filename = xfce_resource_save_location (XFCE_RESOURCE_CONFIG, PANEL_CONFIG_PATH, TRUE);
if (G_LIKELY (filename))
/* save the settings of all plugins */
for (li = application->windows, i = 0; li != NULL; li = li->next, i++)
{
/* get the file xml data */
contents = panel_application_save_xml_contents (application);
/* get the itembar children */
itembar = gtk_bin_get_child (GTK_BIN (li->data));
children = gtk_container_get_children (GTK_CONTAINER (itembar));

/* write the data to the file */
succeed = g_file_set_contents (filename, contents, -1, &error);
if (G_UNLIKELY (succeed == FALSE))
/* walk all the plugin children */
for (lp = children, j = 0; lp != NULL; lp = lp->next, j++)
{
/* writing failed, print warning */
g_critical ("Failed to write panel configuration to \"%s\": %s", filename, error->message);
provider = XFCE_PANEL_PLUGIN_PROVIDER (lp->data);

/* cleanup */
g_error_free (error);
/* save the plugin name */
g_snprintf (buf, sizeof (buf), "/panels/panel-%u/plugins/plugin-%u/module", i, j);
xfconf_channel_set_string (channel, buf, xfce_panel_plugin_provider_get_name (provider));

/* save the plugin id */
g_snprintf (buf, sizeof (buf), "/panels/panel-%u/plugins/plugin-%u/id", i, j);
xfconf_channel_set_string (channel, buf, xfce_panel_plugin_provider_get_id (provider));

/* ask the plugin to save */
if (save_plugin_providers)
xfce_panel_plugin_provider_save (provider);
}

/* cleanup */
g_free (contents);
g_free (filename);
}
else
{
/* print warning */
g_critical ("Failed to create panel configuration file");
}

/* save the settings of all plugins */
for (li = application->windows; li != NULL; li = li->next)
{
/* get the itembar */
itembar = gtk_bin_get_child (GTK_BIN (li->data));
g_list_free (children);

/* save all the plugins on the itembar */
gtk_container_foreach (GTK_CONTAINER (itembar), (GtkCallback) xfce_panel_plugin_provider_save, NULL);
/* store the number of plugins in this panel */
g_snprintf (buf, sizeof (buf), "/panels/panel-%u/plugins", i);
xfconf_channel_set_uint (channel, buf, j);
}

/* store the number of panels */
xfconf_channel_set_uint (channel, "/panels", i);
}


@@ -1121,7 +864,7 @@ panel_application_new_window (PanelApplication *application,
panel_return_val_if_fail (screen == NULL || GDK_IS_SCREEN (screen), NULL);

/* create panel window */
window = panel_window_new ();
window = g_object_new (PANEL_TYPE_WINDOW, NULL);

/* realize */
gtk_widget_realize (window);
@@ -1137,7 +880,7 @@ panel_application_new_window (PanelApplication *application,

/* add the itembar */
itembar = panel_itembar_new ();
exo_binding_new (G_OBJECT (window), "orientation", G_OBJECT (itembar), "orientation");
exo_binding_new (G_OBJECT (window), "horizontal", G_OBJECT (itembar), "horizontal");
gtk_container_add (GTK_CONTAINER (window), itembar);
gtk_widget_show (itembar);

@@ -1145,6 +888,9 @@ panel_application_new_window (PanelApplication *application,
g_signal_connect (G_OBJECT (itembar), "drag-data-received", G_CALLBACK (panel_application_drag_data_received), window);
g_signal_connect (G_OBJECT (itembar), "drag-drop", G_CALLBACK (panel_application_drag_drop), window);

/* add the xfconf bindings */
panel_application_xfconf_window_bindings (application, PANEL_WINDOW (window), FALSE);

return PANEL_WINDOW (window);
}

@@ -1160,7 +906,7 @@ panel_application_get_windows (PanelApplication *application)



gint
guint
panel_application_get_n_windows (PanelApplication *application)
{
panel_return_val_if_fail (PANEL_IS_APPLICATION (application), 0);


+ 3
- 2
panel/panel-application.h View File

@@ -43,7 +43,8 @@ void panel_application_multihead_area (GtkWidget *widget,

PanelApplication *panel_application_get (void);

void panel_application_save (PanelApplication *application);
void panel_application_save (PanelApplication *application,
gboolean save_plugin_providers);

void panel_application_take_dialog (PanelApplication *application,
GtkWindow *dialog);
@@ -57,7 +58,7 @@ void panel_application_add_new_item (PanelApplication *applic
PanelWindow *panel_application_new_window (PanelApplication *application,
GdkScreen *screen);

gint panel_application_get_n_windows (PanelApplication *application);
guint panel_application_get_n_windows (PanelApplication *application);

gint panel_application_get_window_index (PanelApplication *application,
PanelWindow *window);


+ 1
- 1
panel/panel-dbus-service.c View File

@@ -203,7 +203,7 @@ panel_dbus_service_save (PanelDBusService *service,

/* save the configuration */
application = panel_application_get ();
panel_application_save (application);
panel_application_save (application, TRUE);
g_object_unref (G_OBJECT (application));

return TRUE;


+ 2
- 1
panel/panel-dialogs.c View File

@@ -101,7 +101,8 @@ panel_dialogs_choose_panel (PanelApplication *application)
GtkWidget *vbox;
GtkWidget *label;
GtkWidget *combo;
gint i, response = -1;
guint i;
gint response = -1;
gchar *name;

panel_return_val_if_fail (PANEL_IS_APPLICATION (application), -1);


+ 19
- 227
panel/panel-glue.c View File

@@ -41,137 +41,20 @@



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 ();
}



static void
panel_glue_popup_menu_deactivate (GtkMenu *menu,
PanelWindow *window)
{
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));
}



void
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_swapped (G_OBJECT (item), "activate", G_CALLBACK (panel_item_dialog_show), window);
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 (_("Panel Pr_eferences..."));
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,
0, gtk_get_current_event_time ());
}



XfceScreenPosition
panel_glue_get_screen_position (PanelWindow *window)
{
gboolean horizontal;
gboolean horizontal;
PanelWindowSnapEdge snap_edge;

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);
g_object_get (G_OBJECT (window), "horizontal", &horizontal,
"snap-edge", &snap_edge, NULL);

/* return the screen position */
switch (panel_window_get_snap_edge (window))
switch (snap_edge)
{
case PANEL_SNAP_EGDE_NONE:
return horizontal ? XFCE_SCREEN_POSITION_FLOATING_H :
@@ -218,121 +101,30 @@ panel_glue_get_screen_position (PanelWindow *window)
}



static void
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));
}



static void
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));
}



static void
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));
}



void
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);
}



void
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
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));
}



/* TODO move to window */
void
panel_glue_set_provider_info (XfcePanelPluginProvider *provider,
PanelWindow *window)
{
guint size;
gboolean horizontal;
guint background_alpha;

panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (provider));
panel_return_if_fail (PANEL_IS_WINDOW (window));

/* read settings from the window */
g_object_get (G_OBJECT (window), "size", &size,
"horizontal", &horizontal, "background-alpha",
&background_alpha, NULL);

/* set the background alpha if the plugin is external */
if (PANEL_IS_PLUGIN_EXTERNAL (provider))
panel_plugin_external_set_background_alpha (PANEL_PLUGIN_EXTERNAL (provider), panel_window_get_background_alpha (window));
panel_plugin_external_set_background_alpha (PANEL_PLUGIN_EXTERNAL (provider), background_alpha);

/* send plugin information */
xfce_panel_plugin_provider_set_orientation (provider, panel_window_get_orientation (window));
xfce_panel_plugin_provider_set_screen_position (provider, panel_glue_get_screen_position (window));
xfce_panel_plugin_provider_set_size (provider, panel_window_get_size (window));
xfce_panel_plugin_provider_set_size (provider, size);
xfce_panel_plugin_provider_set_orientation (provider, horizontal ? GTK_ORIENTATION_HORIZONTAL
: GTK_ORIENTATION_VERTICAL);
}

+ 2
- 15
panel/panel-glue.h View File

@@ -26,21 +26,8 @@
#include <libxfce4panel/xfce-panel-plugin-provider.h>

G_BEGIN_DECLS

void panel_glue_popup_menu (PanelWindow *window);

XfceScreenPosition panel_glue_get_screen_position (PanelWindow *window);

void panel_glue_set_size (PanelWindow *window,
gint size);

void panel_glue_set_orientation (PanelWindow *window,
GtkOrientation orientation);

void panel_glue_set_screen_position (PanelWindow *window);

void panel_glue_set_provider_info (XfcePanelPluginProvider *provider,
PanelWindow *window);
void panel_glue_set_provider_info (XfcePanelPluginProvider *provider,
PanelWindow *window);

G_END_DECLS



+ 25
- 75
panel/panel-itembar.c View File

@@ -69,8 +69,6 @@ static void panel_itembar_forall (GtkContainer *container,
GtkCallback callback,
gpointer callback_data);
static GType panel_itembar_child_type (GtkContainer *container);
static void panel_itembar_set_orientation (PanelItembar *itembar,
GtkOrientation orientation);



@@ -89,8 +87,8 @@ struct _PanelItembar
/* dnd highlight line */
GdkWindow *highlight_window;

/* orientation of the itembar */
GtkOrientation orientation;
/* whether the itembar is horizontal */
guint horizontal : 1;

/* internal list of children */
GSList *children;
@@ -108,7 +106,7 @@ struct _PanelItembarChild
enum
{
PROP_0,
PROP_ORIENTATION
PROP_HORIZONTAL
};


@@ -156,20 +154,11 @@ panel_itembar_class_init (PanelItembarClass *klass)
gtkcontainer_class->get_child_property = NULL;
gtkcontainer_class->set_child_property = NULL;

/**
* PanelItembar::orientation:
*
* The orientation of the itembar. This property is synced with the
* orientation property of the PanelWindow. That's also the reason
* the itembar has no public panel_itembar_[sg]et_orientation
* functions: it should be read from the panel window.
**/
g_object_class_install_property (gobject_class,
PROP_ORIENTATION,
g_param_spec_enum ("orientation", "orientation", "orientation",
GTK_TYPE_ORIENTATION,
GTK_ORIENTATION_HORIZONTAL,
EXO_PARAM_WRITABLE));
PROP_HORIZONTAL,
g_param_spec_boolean ("horizontal", NULL, NULL,
TRUE,
EXO_PARAM_WRITABLE));
}


@@ -182,7 +171,7 @@ panel_itembar_init (PanelItembar *itembar)
itembar->event_window = NULL;
itembar->highlight_window = NULL;
itembar->sensitive = TRUE;
itembar->orientation = GTK_ORIENTATION_HORIZONTAL;
itembar->horizontal = TRUE;

/* setup */
GTK_WIDGET_SET_FLAGS (GTK_WIDGET (itembar), GTK_NO_WINDOW);
@@ -208,8 +197,9 @@ panel_itembar_set_property (GObject *object,

switch (prop_id)
{
case PROP_ORIENTATION:
panel_itembar_set_orientation (itembar, g_value_get_enum (value));
case PROP_HORIZONTAL:
itembar->horizontal = g_value_get_boolean (value);
gtk_widget_queue_resize (GTK_WIDGET (itembar));
break;

default:
@@ -348,7 +338,7 @@ panel_itembar_size_request (GtkWidget *widget,
gtk_widget_size_request (child->widget, &child_requisition);

/* update the itembar requisition */
if (itembar->orientation == GTK_ORIENTATION_HORIZONTAL)
if (itembar->horizontal)
{
requisition->width += child_requisition.width;
requisition->height = MAX (requisition->height, child_requisition.height);
@@ -378,7 +368,6 @@ panel_itembar_size_allocate (GtkWidget *widget,
gint req_expandable_size = 0;
gint x, y;
gint border_width;
gboolean horizontal;
gint alloc_size, req_size;
gboolean expandable_children_fit;

@@ -393,11 +382,8 @@ panel_itembar_size_allocate (GtkWidget *widget,
/* get the border width */
border_width = GTK_CONTAINER (widget)->border_width;

/* boolean for orientation */
horizontal = (itembar->orientation == GTK_ORIENTATION_HORIZONTAL);

/* get the itembar size */
if (horizontal)
if (itembar->horizontal)
alloc_expandable_size = allocation->width - 2 * border_width;
else
alloc_expandable_size = allocation->height - 2 * border_width;
@@ -420,7 +406,7 @@ panel_itembar_size_allocate (GtkWidget *widget,
n_expand_children++;

/* update the size requested by the expanding children */
if (horizontal)
if (itembar->horizontal)
req_expandable_size += child_requisition.width;
else
req_expandable_size += child_requisition.height;
@@ -428,7 +414,7 @@ panel_itembar_size_allocate (GtkWidget *widget,
else
{
/* update the size avaible for allocation */
if (horizontal)
if (itembar->horizontal)
alloc_expandable_size -= child_requisition.width;
else
alloc_expandable_size -= child_requisition.height;
@@ -465,13 +451,13 @@ panel_itembar_size_allocate (GtkWidget *widget,
if (G_UNLIKELY (child->expand && expandable_children_fit == FALSE))
{
/* get requested size */
req_size = horizontal ? child_requisition.width : child_requisition.height;
req_size = itembar->horizontal ? child_requisition.width : child_requisition.height;

/* calculate allocated size */
alloc_size = alloc_expandable_size * req_size / req_expandable_size;

/* set the calculated expanding size */
if (horizontal)
if (itembar->horizontal)
child_allocation.width = alloc_size;
else