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.
upstream/xfce4-panel-4.10.1
Nick Schermer 14 years ago
parent
commit
dbd081d31b
  1. 1
      TODO
  2. 1
      configure.in.in
  3. 2
      libxfce4panel/xfce-arrow-button.h
  4. 2
      libxfce4panel/xfce-hvbox.h
  5. 8
      libxfce4panel/xfce-panel-macros.h
  6. 8
      libxfce4panel/xfce-panel-plugin-provider.c
  7. 5
      libxfce4panel/xfce-panel-plugin-provider.h
  8. 116
      libxfce4panel/xfce-panel-plugin.c
  9. 2
      libxfce4panel/xfce-panel-plugin.h
  10. 18
      libxfce4panel/xfce-scaled-image.c
  11. 146
      panel/Makefile.am
  12. 15
      panel/main.c
  13. 660
      panel/panel-application.c
  14. 5
      panel/panel-application.h
  15. 2
      panel/panel-dbus-service.c
  16. 3
      panel/panel-dialogs.c
  17. 246
      panel/panel-glue.c
  18. 17
      panel/panel-glue.h
  19. 100
      panel/panel-itembar.c
  20. 2
      panel/panel-itembar.h
  21. 37
      panel/panel-plugin-external.c
  22. 767
      panel/panel-preferences-dialog.c
  23. 433
      panel/panel-preferences-dialog.glade
  24. 870
      panel/panel-window.c
  25. 51
      panel/panel-window.h
  26. 2
      plugins/launcher/Makefile.am
  27. 40
      plugins/launcher/launcher-dialog.c
  28. 59
      plugins/launcher/launcher-dialog.glade
  29. 366
      plugins/launcher/launcher.c
  30. 9
      plugins/launcher/launcher.h
  31. 6
      plugins/test/xfce-test-plugin.c
  32. 3
      wrapper/main.c

1
TODO

@ -12,7 +12,6 @@ General
Libxfce4panel
-------------
- Add support for visibility.
- Plugin visibility support (duno if this is possible tho).
Panel

1
configure.in.in

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

2
libxfce4panel/xfce-arrow-button.h

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

2
libxfce4panel/xfce-hvbox.h

@ -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
libxfce4panel/xfce-panel-macros.h

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

8
libxfce4panel/xfce-panel-plugin-provider.c

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

5
libxfce4panel/xfce-panel-plugin-provider.h

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

116
libxfce4panel/xfce-panel-plugin.c

@ -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
libxfce4panel/xfce-panel-plugin.h

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

18
libxfce4panel/xfce-scaled-image.c

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

146
panel/Makefile.am

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

15
panel/main.c

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

660
panel/panel-application.c

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