diff options
author | Nick Schermer <nick@xfce.org> | 2010-02-26 14:08:07 +0100 |
---|---|---|
committer | Nick Schermer <nick@xfce.org> | 2010-02-26 14:11:30 +0100 |
commit | dbd081d31bfcbd2acf718eda322530af6b1b7700 (patch) | |
tree | 19495d263ad2f42ead530fd837af5284c0211595 | |
parent | be5658063388ae68530a855a315cfe93fa083604 (diff) |
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.
32 files changed, 1552 insertions, 2450 deletions
@@ -12,7 +12,6 @@ General Libxfce4panel ------------- - - Add support for visibility. - Plugin visibility support (duno if this is possible tho). Panel diff --git a/configure.in.in b/configure.in.in index ffacf5ff..9cada8a9 100644 --- a/configure.in.in +++ b/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 *** diff --git a/libxfce4panel/xfce-arrow-button.h b/libxfce4panel/xfce-arrow-button.h index fd6dae31..43d7822b 100644 --- a/libxfce4panel/xfce-arrow-button.h +++ b/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; diff --git a/libxfce4panel/xfce-hvbox.h b/libxfce4panel/xfce-hvbox.h index f6b79c53..757ca4af 100644 --- a/libxfce4panel/xfce-hvbox.h +++ b/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, diff --git a/libxfce4panel/xfce-panel-macros.h b/libxfce4panel/xfce-panel-macros.h index 7fabc156..d386b7fc 100644 --- a/libxfce4panel/xfce-panel-macros.h +++ b/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 diff --git a/libxfce4panel/xfce-panel-plugin-provider.c b/libxfce4panel/xfce-panel-plugin-provider.c index e001095d..573b2630 100644 --- a/libxfce4panel/xfce-panel-plugin-provider.c +++ b/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); } diff --git a/libxfce4panel/xfce-panel-plugin-provider.h b/libxfce4panel/xfce-panel-plugin-provider.h index 84dd7052..35bf5c31 100644 --- a/libxfce4panel/xfce-panel-plugin-provider.h +++ b/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); diff --git a/libxfce4panel/xfce-panel-plugin.c b/libxfce4panel/xfce-panel-plugin.c index 97272512..2f2b76aa 100644 --- a/libxfce4panel/xfce-panel-plugin.c +++ b/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); @@ -959,10 +949,32 @@ 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 diff --git a/libxfce4panel/xfce-panel-plugin.h b/libxfce4panel/xfce-panel-plugin.h index 1716a0e1..6201c1e3 100644 --- a/libxfce4panel/xfce-panel-plugin.h +++ b/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); diff --git a/libxfce4panel/xfce-scaled-image.c b/libxfce4panel/xfce-scaled-image.c index c1dc7e2b..717412e2 100644 --- a/libxfce4panel/xfce-scaled-image.c +++ b/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)); } diff --git a/panel/Makefile.am b/panel/Makefile.am index a49110d0..4274d826 100644 --- a/panel/Makefile.am +++ b/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: diff --git a/panel/main.c b/panel/main.c index 0dc07e1b..b4e432aa 100644 --- a/panel/main.c +++ b/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) { diff --git a/panel/panel-application.c b/panel/panel-application.c index 0eaa45d1..6a46f362 100644 --- a/panel/panel-application.c +++ b/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); @@ -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); diff --git a/panel/panel-application.h b/panel/panel-application.h index 104fb62a..38404b76 100644 --- a/panel/panel-application.h +++ b/panel/panel-application.h @@ -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); diff --git a/panel/panel-dbus-service.c b/panel/panel-dbus-service.c index 098ddf10..93a99e00 100644 --- a/panel/panel-dbus-service.c +++ b/panel/panel-dbus-service.c @@ -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; diff --git a/panel/panel-dialogs.c b/panel/panel-dialogs.c index 53b2ef53..af246b6d 100644 --- a/panel/panel-dialogs.c +++ b/panel/panel-dialogs.c @@ -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); diff --git a/panel/panel-glue.c b/panel/panel-glue.c index 556e2dc5..76d50e6f 100644 --- a/panel/panel-glue.c +++ b/panel/panel-glue.c @@ -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); } diff --git a/panel/panel-glue.h b/panel/panel-glue.h index f80a2a89..b5d645a4 100644 --- a/panel/panel-glue.h +++ b/panel/panel-glue.h @@ -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 diff --git a/panel/panel-itembar.c b/panel/panel-itembar.c index 291cc1df..a5189b26 100644 --- a/panel/panel-itembar.c +++ b/panel/panel-itembar.c @@ -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 child_allocation.height = alloc_size; @@ -483,14 +469,14 @@ panel_itembar_size_allocate (GtkWidget *widget, else { /* set the requested size in the allocation */ - if (horizontal) + if (itembar->horizontal) child_allocation.width = child_requisition.width; else child_allocation.height = child_requisition.height; } /* update the coordinates and set the allocated (user defined) panel size */ - if (horizontal) + if (itembar->horizontal) { x += child_allocation.width; child_allocation.height = allocation->height; @@ -541,7 +527,6 @@ panel_itembar_drag_motion (GtkWidget *widget, GtkWidget *child = NULL; gint x = 0, y = 0; gint width, height; - gboolean is_horizontal; if (G_UNLIKELY (itembar->highlight_window == NULL)) { @@ -565,9 +550,6 @@ panel_itembar_drag_motion (GtkWidget *widget, gdk_window_set_background (itembar->highlight_window, &widget->style->fg[widget->state]); } - /* get orientaion */ - is_horizontal = !!(itembar->orientation == GTK_ORIENTATION_HORIZONTAL); - /* get the drop index */ drop_index = panel_itembar_get_drop_index (itembar, drag_x, drag_y); @@ -576,7 +558,7 @@ panel_itembar_drag_motion (GtkWidget *widget, if (G_LIKELY (child)) { /* get child start coordinate */ - if (is_horizontal) + if (itembar->horizontal) x = child->allocation.x; else y = child->allocation.y; @@ -587,15 +569,15 @@ panel_itembar_drag_motion (GtkWidget *widget, child = panel_itembar_get_nth_child (itembar, g_slist_length (itembar->children) - 1); /* get coordinate at end of the child */ - if (is_horizontal) + if (itembar->horizontal) x = child->allocation.x + child->allocation.width; else y = child->allocation.y + child->allocation.height; } /* get size of the hightlight */ - width = is_horizontal ? HIGHLIGHT_THINKNESS : widget->allocation.width; - height = is_horizontal ? widget->allocation.height : HIGHLIGHT_THINKNESS; + width = itembar->horizontal ? HIGHLIGHT_THINKNESS : widget->allocation.width; + height = itembar->horizontal ? widget->allocation.height : HIGHLIGHT_THINKNESS; /* show line between the two children */ x += HIGHLIGHT_THINKNESS / 2; @@ -720,24 +702,6 @@ panel_itembar_child_type (GtkContainer *container) -static void -panel_itembar_set_orientation (PanelItembar *itembar, - GtkOrientation orientation) -{ - panel_return_if_fail (PANEL_IS_ITEMBAR (itembar)); - - if (itembar->orientation != orientation) - { - /* set new orientation */ - itembar->orientation = orientation; - - /* queue a resize */ - gtk_widget_queue_resize (GTK_WIDGET (itembar)); - } -} - - - GtkWidget * panel_itembar_new (void) { @@ -913,16 +877,6 @@ panel_itembar_set_child_expand (PanelItembar *itembar, -guint -panel_itembar_get_n_children (PanelItembar *itembar) -{ - panel_return_val_if_fail (PANEL_IS_ITEMBAR (itembar), 0); - - return g_slist_length (itembar->children); -} - - - gint panel_itembar_get_child_index (PanelItembar *itembar, GtkWidget *widget) @@ -976,7 +930,6 @@ panel_itembar_get_drop_index (PanelItembar *itembar, PanelItembarChild *child; GSList *li; GtkAllocation *allocation; - gboolean is_horizontal; guint idx; panel_return_val_if_fail (PANEL_IS_ITEMBAR (itembar), 0); @@ -985,9 +938,6 @@ panel_itembar_get_drop_index (PanelItembar *itembar, x += GTK_WIDGET (itembar)->allocation.x; y += GTK_WIDGET (itembar)->allocation.y; - /* whether the itembar is horizontal */ - is_horizontal = !!(itembar->orientation == GTK_ORIENTATION_HORIZONTAL); - for (li = itembar->children, idx = 0; li != NULL; li = li->next, idx++) { child = li->data; @@ -996,8 +946,8 @@ panel_itembar_get_drop_index (PanelItembar *itembar, allocation = &(child->widget->allocation); /* check if the drop index is before the half of the allocation */ - if ((is_horizontal && x < (allocation->x + allocation->width / 2)) - || (!is_horizontal && y < (allocation->y + allocation->height / 2))) + if ((itembar->horizontal && x < (allocation->x + allocation->width / 2)) + || (!itembar->horizontal && y < (allocation->y + allocation->height / 2))) break; } diff --git a/panel/panel-itembar.h b/panel/panel-itembar.h index 12c34d4a..09c8a7d7 100644 --- a/panel/panel-itembar.h +++ b/panel/panel-itembar.h @@ -66,8 +66,6 @@ void panel_itembar_set_child_expand (PanelItembar *itembar, GtkWidget *widget, gboolean expand); -GSList *panel_itembar_get_children (PanelItembar *itembar); - gint panel_itembar_get_child_index (PanelItembar *itembar, GtkWidget *widget); diff --git a/panel/panel-plugin-external.c b/panel/panel-plugin-external.c index 6c80d012..68b34b2f 100644 --- a/panel/panel-plugin-external.c +++ b/panel/panel-plugin-external.c @@ -24,7 +24,6 @@ #include <exo/exo.h> #include <gdk/gdk.h> #include <gdk/gdkx.h> -#include <glib/gstdio.h> #include <libxfce4util/libxfce4util.h> #include <libxfce4panel/libxfce4panel.h> #include <libxfce4panel/xfce-panel-plugin-provider.h> @@ -42,7 +41,7 @@ #ifndef NDEBUG #define N_RESTART_TRIES (0) #else -#define N_RESTART_TRIES (3) +#define N_RESTART_TRIES (2) #endif @@ -96,7 +95,7 @@ struct _PanelPluginExternal /* dbus message queue */ GSList *dbus_queue; - + /* counter to count the number of restart */ guint n_restarts; }; @@ -290,7 +289,6 @@ panel_plugin_external_plug_removed (GtkSocket *socket) PanelPluginExternal *external = PANEL_PLUGIN_EXTERNAL (socket); GtkWidget *dialog; gint response; - gchar *filename, *path; PanelWindow *window; /* leave when the plugin was already removed */ @@ -299,14 +297,14 @@ panel_plugin_external_plug_removed (GtkSocket *socket) /* plug has been removed */ external->plug_embedded = FALSE; - + /* unrealize and hide the socket */ gtk_widget_unrealize (GTK_WIDGET (socket)); gtk_widget_hide (GTK_WIDGET (socket)); /* increase the restart counter */ external->n_restarts++; - + /* check if we ask the user what to do */ if (external->n_restarts > N_RESTART_TRIES) { @@ -323,11 +321,11 @@ panel_plugin_external_plug_removed (GtkSocket *socket) GTK_STOCK_REMOVE, GTK_RESPONSE_CLOSE, NULL); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER); - + /* wait for the user's choise */ response = gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); - + /* reset the restart counter */ external->n_restarts = 0; } @@ -335,13 +333,13 @@ panel_plugin_external_plug_removed (GtkSocket *socket) { /* pretend the user clicked the yes button */ response = GTK_RESPONSE_OK; - + /* print a message we did an autorestart */ g_message ("Automatically restarting plugin %s-%s, try %d", panel_module_get_internal_name (external->module), external->id, external->n_restarts); } - + /* handle the response */ if (response == GTK_RESPONSE_OK) { @@ -359,21 +357,8 @@ panel_plugin_external_plug_removed (GtkSocket *socket) } else { - /* build the plugin rc filename */ - filename = g_strdup_printf (PANEL_PLUGIN_RELATIVE_PATH, - panel_module_get_internal_name (external->module), - external->id); - - /* get the path */ - path = xfce_resource_lookup (XFCE_RESOURCE_CONFIG, filename); - - /* remove the plugin's config file */ - if (G_LIKELY (path)) - g_unlink (path); - - /* cleanup */ - g_free (filename); - g_free (path); + /* emit a remove signal, so we can cleanup the plugin configuration (in panel-application) */ + xfce_panel_plugin_provider_send_signal (XFCE_PANEL_PLUGIN_PROVIDER (external), REMOVE_PLUGIN); /* destroy the socket */ gtk_widget_destroy (GTK_WIDGET (socket)); @@ -418,7 +403,7 @@ panel_plugin_external_provider_signal (XfcePanelPluginProvider *provider, XfcePanelPluginProviderSignal signal) { PanelPluginExternal *external = PANEL_PLUGIN_EXTERNAL (provider); - + panel_return_if_fail (PANEL_IS_PLUGIN_EXTERNAL (provider)); panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (provider)); diff --git a/panel/panel-preferences-dialog.c b/panel/panel-preferences-dialog.c index 5de964db..96150b24 100644 --- a/panel/panel-preferences-dialog.c +++ b/panel/panel-preferences-dialog.c @@ -31,6 +31,7 @@ #include <panel/panel-glue.h> #include <panel/panel-application.h> #include <panel/panel-preferences-dialog.h> +#include <panel/panel-preferences-dialog-glade.h> #define BORDER (6) #define PREFERENCES_HELP_URL "http://www.xfce.org" @@ -39,27 +40,26 @@ static void panel_preferences_dialog_class_init (PanelPreferencesDialogClass *klass); static void panel_preferences_dialog_init (PanelPreferencesDialog *dialog); -static void panel_preferences_dialog_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); -static void panel_preferences_dialog_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); static void panel_preferences_dialog_finalize (GObject *object); -static void panel_preferences_dialog_response (GtkDialog *dialog, gint response_id); -static gboolean panel_preferences_dialog_save_timeout (gpointer user_data); -static void panel_preferences_dialog_save_timeout_destroyed (gpointer user_data); +static void panel_preferences_dialog_help (GtkWidget *button); + static void panel_preferences_dialog_rebuild_selector (PanelPreferencesDialog *dialog); -static void panel_preferences_dialog_set_window (PanelPreferencesDialog *dialog); -static void panel_preferences_dialog_add_window (GtkWidget *widget, PanelPreferencesDialog *dialog); -static void panel_preferences_dialog_remove_window (GtkWidget *widget, PanelPreferencesDialog *dialog); +static void panel_preferences_dialog_bindings_unbind (PanelPreferencesDialog *dialog); +static void panel_preferences_dialog_bindings_add (PanelPreferencesDialog *dialog, const gchar *property1, const gchar *property2); +static void panel_preferences_dialog_bindings_update (GtkComboBox *combobox, PanelPreferencesDialog *dialog); +static void panel_preferences_dialog_window_add (GtkWidget *widget, PanelPreferencesDialog *dialog); +static void panel_preferences_dialog_window_remove (GtkWidget *widget, PanelPreferencesDialog *dialog); struct _PanelPreferencesDialogClass { - XfceTitledDialogClass __parent__; + GtkBuilderClass __parent__; }; struct _PanelPreferencesDialog { - XfceTitledDialog __parent__; + GtkBuilder __parent__; /* application we're handling */ PanelApplication *application; @@ -67,35 +67,13 @@ struct _PanelPreferencesDialog /* currently selected window in the selector */ PanelWindow *active; - /* panel selector widget */ - GtkWidget *selector; - - /* remove button */ - GtkWidget *remove_button; - - /* save timeout id */ - guint save_timeout_id; -}; - -enum -{ - PROP_0, - PROP_COMPOSITE, - PROP_COMPOSITE_RGBA, - PROP_LOCKED, - PROP_ORIENTATION, - PROP_AUTOHIDE, - PROP_SIZE, - PROP_LENGTH, - PROP_BACKGROUND_ALPHA, - PROP_ENTER_OPACITY, - PROP_LEAVE_OPACITY, - PROP_SPAN_MONITORS + /* list of exo bindings */ + GSList *bindings; }; -G_DEFINE_TYPE (PanelPreferencesDialog, panel_preferences_dialog, XFCE_TYPE_TITLED_DIALOG); +G_DEFINE_TYPE (PanelPreferencesDialog, panel_preferences_dialog, GTK_TYPE_BUILDER); @@ -103,82 +81,9 @@ static void panel_preferences_dialog_class_init (PanelPreferencesDialogClass *klass) { GObjectClass *gobject_class; - GtkDialogClass *gtkdialog_class; gobject_class = G_OBJECT_CLASS (klass); gobject_class->finalize = panel_preferences_dialog_finalize; - gobject_class->get_property = panel_preferences_dialog_get_property; - gobject_class->set_property = panel_preferences_dialog_set_property; - - gtkdialog_class = GTK_DIALOG_CLASS (klass); - gtkdialog_class->response = panel_preferences_dialog_response; - - g_object_class_install_property (gobject_class, - PROP_COMPOSITE, - g_param_spec_boolean ("composite", "composite", "composite", - FALSE, - EXO_PARAM_READABLE)); - - g_object_class_install_property (gobject_class, - PROP_COMPOSITE_RGBA, - g_param_spec_boolean ("composite-rgba", "composite-rgba", "composite-rgba", - FALSE, - EXO_PARAM_READABLE)); - - g_object_class_install_property (gobject_class, - PROP_LOCKED, - g_param_spec_boolean ("locked", "locked", "locked", - FALSE, - EXO_PARAM_READWRITE)); - - g_object_class_install_property (gobject_class, - PROP_ORIENTATION, - g_param_spec_enum ("orientation", "orientation", "orientation", - GTK_TYPE_ORIENTATION, - GTK_ORIENTATION_HORIZONTAL, - EXO_PARAM_READWRITE)); - - g_object_class_install_property (gobject_class, - PROP_AUTOHIDE, - g_param_spec_boolean ("autohide", "autohide", "autohide", - FALSE, - EXO_PARAM_READWRITE)); - - g_object_class_install_property (gobject_class, - PROP_SIZE, - g_param_spec_int ("size", "size", "size", - 16, 128, 16, - EXO_PARAM_READWRITE)); - - g_object_class_install_property (gobject_class, - PROP_LENGTH, - g_param_spec_int ("length", "length", "length", - 0, 100, 0, - EXO_PARAM_READWRITE)); - - g_object_class_install_property (gobject_class, - PROP_BACKGROUND_ALPHA, - g_param_spec_int ("background-alpha", "background-alpha", "background-alpha", - 0, 100, 0, - EXO_PARAM_READWRITE)); - - g_object_class_install_property (gobject_class, - PROP_ENTER_OPACITY, - g_param_spec_int ("enter-opacity", "enter-opacity", "enter-opacity", - 0, 100, 0, - EXO_PARAM_READWRITE)); - - g_object_class_install_property (gobject_class, - PROP_LEAVE_OPACITY, - g_param_spec_int ("leave-opacity", "leave-opacity", "leave-opacity", - 0, 100, 0, - EXO_PARAM_READWRITE)); - - g_object_class_install_property (gobject_class, - PROP_SPAN_MONITORS, - g_param_spec_boolean ("span-monitors", "span-monitors", "span-monitors", - FALSE, - EXO_PARAM_READWRITE)); } @@ -186,431 +91,58 @@ panel_preferences_dialog_class_init (PanelPreferencesDialogClass *klass) static void panel_preferences_dialog_init (PanelPreferencesDialog *dialog) { - GtkWidget *main_vbox; - GtkWidget *hbox; - GtkWidget *combo; - GtkWidget *button; - GtkWidget *image; - GtkWidget *notebook; - GtkWidget *label; - GtkWidget *notebook_vbox; - GtkWidget *vbox; - GtkWidget *frame; - GtkWidget *scale; - GtkSizeGroup *sg; - GtkObject *adjustment; - - /* initialize */ - dialog->save_timeout_id = 0; - - /* get application */ + GObject *window, *object; + + /* init */ + dialog->bindings = NULL; dialog->application = panel_application_get (); /* block all autohides */ panel_application_windows_autohide (dialog->application, TRUE); - /* register the dialog in the application */ - panel_application_take_dialog (dialog->application, GTK_WINDOW (dialog)); - - /* set the first window */ - dialog->active = panel_application_get_window (dialog->application, 0); - - /* signal to monitor compositor changes */ - g_signal_connect_swapped (G_OBJECT (dialog), "composited-changed", G_CALLBACK (panel_preferences_dialog_set_window), dialog); - - /* setup dialog */ - gtk_window_set_title (GTK_WINDOW (dialog), _("Xfce Panel Preferences")); - gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_PREFERENCES); - gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE); - - /* add buttons */ - gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_HELP, GTK_RESPONSE_HELP); - gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE); - gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE); - - /* create main box */ - main_vbox = gtk_vbox_new (FALSE, BORDER * 2); - gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), main_vbox); - gtk_container_set_border_width (GTK_CONTAINER (main_vbox), BORDER); - gtk_widget_show (main_vbox); - - /* box for panel selector */ - hbox = gtk_hbox_new (FALSE, BORDER); - gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0); - gtk_widget_show (hbox); - - combo = dialog->selector = gtk_combo_box_new_text (); - gtk_box_pack_start (GTK_BOX (hbox), combo, TRUE, TRUE, 0); - g_signal_connect_swapped (G_OBJECT (combo), "changed", G_CALLBACK (panel_preferences_dialog_set_window), dialog); - gtk_widget_show (combo); - - button = gtk_button_new (); - gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); - image = gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_BUTTON); - gtk_button_set_image (GTK_BUTTON (button), image); - g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (panel_preferences_dialog_add_window), dialog); - gtk_widget_show (button); - - button = dialog->remove_button = gtk_button_new (); - gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); - image = gtk_image_new_from_stock (GTK_STOCK_REMOVE, GTK_ICON_SIZE_BUTTON); - gtk_button_set_image (GTK_BUTTON (button), image); - g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (panel_preferences_dialog_remove_window), dialog); - gtk_widget_set_sensitive (button, panel_application_get_n_windows (dialog->application) > 1); - gtk_widget_show (button); - - notebook = gtk_notebook_new (); - gtk_box_pack_start (GTK_BOX (main_vbox), notebook, TRUE, TRUE, 0); - gtk_widget_show (notebook); - - /* display tab */ - notebook_vbox = gtk_vbox_new (FALSE, BORDER); - gtk_container_set_border_width (GTK_CONTAINER (notebook_vbox), BORDER); - gtk_widget_show (notebook_vbox); - - label = gtk_label_new (_("Display")); - gtk_notebook_append_page (GTK_NOTEBOOK (notebook), notebook_vbox, label); - - /* general frame */ - vbox = gtk_vbox_new (FALSE, BORDER); - gtk_widget_show (vbox); - - frame = xfce_gtk_frame_box_new_with_content (_("General"), vbox); - gtk_box_pack_start (GTK_BOX (notebook_vbox), frame, FALSE, FALSE, 0); - gtk_widget_show (frame); - - hbox = gtk_hbox_new (FALSE, BORDER * 2); - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); - gtk_widget_show (hbox); - - label = gtk_label_new_with_mnemonic (_("_Orientation:")); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - gtk_widget_show (label); - - combo = gtk_combo_box_new_text (); - gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo), "Horizontal"); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo), "Vertical"); - gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo); - exo_mutual_binding_new (G_OBJECT (dialog), "orientation", G_OBJECT (combo), "active"); - gtk_widget_show (combo); - - button = gtk_check_button_new_with_mnemonic (_("_Lock Panel")); - gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); - _widget_set_tooltip_text (button, _("When the panel is locked, it cannot be moved and the handles will be hidden.")); - exo_mutual_binding_new (G_OBJECT (dialog), "locked", G_OBJECT (button), "active"); - gtk_widget_show (button); - - button = gtk_check_button_new_with_mnemonic (_("Automatically show and hi_de the panel")); - _widget_set_tooltip_text (button, _("Hide the panel when you move your mouse out of it. " - "When the poiner enter the panel border on the screen egde, " - "the panel will reappear.")); - gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); - exo_mutual_binding_new (G_OBJECT (dialog), "autohide", G_OBJECT (button), "active"); - gtk_widget_show (button); - - /* measurements frame */ - vbox = gtk_vbox_new (FALSE, BORDER); - gtk_widget_show (vbox); - - frame = xfce_gtk_frame_box_new_with_content (_("Measurements"), vbox); - gtk_box_pack_start (GTK_BOX (notebook_vbox), frame, FALSE, FALSE, 0); - gtk_widget_show (frame); - - sg = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); - - hbox = gtk_hbox_new (FALSE, BORDER * 2); - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); - gtk_widget_show (hbox); - - label = gtk_label_new_with_mnemonic (_("_Size (pixels):")); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - gtk_misc_set_alignment (GTK_MISC (label), 0.00, 0.50); - gtk_size_group_add_widget (sg, label); - gtk_widget_show (label); - - adjustment = gtk_adjustment_new (16, 16, 128, 1, 10, 0); - exo_mutual_binding_new (G_OBJECT (dialog), "size", G_OBJECT (adjustment), "value"); - - scale = gtk_hscale_new (GTK_ADJUSTMENT (adjustment)); - gtk_box_pack_start (GTK_BOX (hbox), scale, TRUE, TRUE, 0); - gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_RIGHT); - gtk_scale_set_digits (GTK_SCALE (scale), 0); - gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED); - gtk_label_set_mnemonic_widget (GTK_LABEL (label), scale); - gtk_widget_show (scale); - - hbox = gtk_hbox_new (FALSE, BORDER * 2); - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); - gtk_widget_show (hbox); - - label = gtk_label_new_with_mnemonic (_("L_ength (%):")); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - gtk_misc_set_alignment (GTK_MISC (label), 0.00, 0.50); - gtk_size_group_add_widget (sg, label); - gtk_widget_show (label); - - adjustment = gtk_adjustment_new (1, 1, 100, 1, 10, 0); - exo_mutual_binding_new (G_OBJECT (dialog), "length", G_OBJECT (adjustment), "value"); - - scale = gtk_hscale_new (GTK_ADJUSTMENT (adjustment)); - gtk_box_pack_start (GTK_BOX (hbox), scale, TRUE, TRUE, 0); - gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_RIGHT); - gtk_scale_set_digits (GTK_SCALE (scale), 0); - gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED); - gtk_label_set_mnemonic_widget (GTK_LABEL (label), scale); - gtk_widget_show (scale); - - g_object_unref (G_OBJECT (sg)); - - /* compositing tab */ - notebook_vbox = gtk_vbox_new (FALSE, BORDER); - gtk_container_set_border_width (GTK_CONTAINER (notebook_vbox), BORDER); - - label = gtk_label_new (_("Compositing")); - gtk_notebook_append_page (GTK_NOTEBOOK (notebook), notebook_vbox, label); - exo_binding_new (G_OBJECT (dialog), "composite", G_OBJECT (notebook_vbox), "visible"); - - sg = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); - - /* background alpha frame */ - vbox = gtk_vbox_new (FALSE, BORDER); - gtk_widget_show (vbox); - - frame = xfce_gtk_frame_box_new_with_content (_("Background"), vbox); - gtk_box_pack_start (GTK_BOX (notebook_vbox), frame, FALSE, FALSE, 0); - gtk_widget_show (frame); - - hbox = gtk_hbox_new (FALSE, BORDER * 2); - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); - gtk_widget_show (hbox); - - label = gtk_label_new_with_mnemonic (_("_Alpha:")); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - gtk_misc_set_alignment (GTK_MISC (label), 0.00, 0.50); - exo_binding_new (G_OBJECT (dialog), "composite-rgba", G_OBJECT (label), "visible"); - gtk_size_group_add_widget (sg, label); - - adjustment = gtk_adjustment_new (100, 0, 100, 1, 10, 0); - exo_mutual_binding_new (G_OBJECT (dialog), "background-alpha", G_OBJECT (adjustment), "value"); - - scale = gtk_hscale_new (GTK_ADJUSTMENT (adjustment)); - gtk_box_pack_start (GTK_BOX (hbox), scale, TRUE, TRUE, 0); - gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_RIGHT); - exo_binding_new (G_OBJECT (dialog), "composite-rgba", G_OBJECT (scale), "visible"); - gtk_scale_set_digits (GTK_SCALE (scale), 0); - gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED); - gtk_label_set_mnemonic_widget (GTK_LABEL (label), scale); - - label = gtk_label_new (_("You need to restart the panel to set the alpha channel of the panel background.")); - exo_binding_new_with_negation (G_OBJECT (dialog), "composite-rgba", G_OBJECT (label), "visible"); - gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); - gtk_misc_set_alignment (GTK_MISC (label), 0.00, 0.50); - gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0); - - /* transparency frame */ - vbox = gtk_vbox_new (FALSE, BORDER); - gtk_widget_show (vbox); - - frame = xfce_gtk_frame_box_new_with_content (_("Transparency"), vbox); - gtk_box_pack_start (GTK_BOX (notebook_vbox), frame, FALSE, FALSE, 0); - gtk_widget_show (frame); - - hbox = gtk_hbox_new (FALSE, BORDER * 2); - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); - gtk_widget_show (hbox); - - label = gtk_label_new_with_mnemonic (_("_Enter:")); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - gtk_misc_set_alignment (GTK_MISC (label), 0.00, 0.50); - gtk_size_group_add_widget (sg, label); - gtk_widget_show (label); - - adjustment = gtk_adjustment_new (100, 0, 100, 1, 10, 0); - exo_mutual_binding_new (G_OBJECT (dialog), "enter-opacity", G_OBJECT (adjustment), "value"); - - scale = gtk_hscale_new (GTK_ADJUSTMENT (adjustment)); - gtk_box_pack_start (GTK_BOX (hbox), scale, TRUE, TRUE, 0); - gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_RIGHT); - gtk_scale_set_digits (GTK_SCALE (scale), 0); - gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED); - gtk_label_set_mnemonic_widget (GTK_LABEL (label), scale); - gtk_widget_show (scale); - - hbox = gtk_hbox_new (FALSE, BORDER * 2); - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); - gtk_widget_show (hbox); - - label = gtk_label_new_with_mnemonic (_("_Leave:")); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - gtk_misc_set_alignment (GTK_MISC (label), 0.00, 0.50); - gtk_size_group_add_widget (sg, label); - gtk_widget_show (label); - - adjustment = gtk_adjustment_new (100, 0, 100, 1, 10, 0); - exo_mutual_binding_new (G_OBJECT (dialog), "leave-opacity", G_OBJECT (adjustment), "value"); - - scale = gtk_hscale_new (GTK_ADJUSTMENT (adjustment)); - gtk_box_pack_start (GTK_BOX (hbox), scale, TRUE, TRUE, 0); - gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_RIGHT); - gtk_scale_set_digits (GTK_SCALE (scale), 0); - gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED); - gtk_label_set_mnemonic_widget (GTK_LABEL (label), scale); - gtk_widget_show (scale); - - g_object_unref (G_OBJECT (sg)); - - /* multi screen tab */ - notebook_vbox = gtk_vbox_new (FALSE, BORDER); - gtk_container_set_border_width (GTK_CONTAINER (notebook_vbox), BORDER); - gtk_widget_show (notebook_vbox); - - label = gtk_label_new (_("Multi Screen")); - gtk_notebook_append_page (GTK_NOTEBOOK (notebook), notebook_vbox, label); - - button = gtk_check_button_new_with_mnemonic (_("Span Monitors")); - gtk_box_pack_start (GTK_BOX (notebook_vbox), button, FALSE, FALSE, 0); - exo_mutual_binding_new (G_OBJECT (dialog), "span-monitors", G_OBJECT (button), "active"); - gtk_widget_show (button); - - /* rebuild the selector */ - panel_preferences_dialog_rebuild_selector (dialog); -} - - - -static void -panel_preferences_dialog_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - PanelPreferencesDialog *dialog = PANEL_PREFERENCES_DIALOG (object); - PanelWindow *window = dialog->active; - - panel_return_if_fail (PANEL_IS_WINDOW (window)); - panel_return_if_fail (PANEL_IS_PREFERENCES_DIALOG (dialog)); - - switch (prop_id) - { - case PROP_COMPOSITE: - g_value_set_boolean (value, gtk_widget_is_composited (GTK_WIDGET (window))); - break; - - case PROP_COMPOSITE_RGBA: - g_value_set_boolean (value, panel_window_is_composited (window)); - break; - - case PROP_LOCKED: - g_value_set_boolean (value, panel_window_get_locked (window)); - break; - - case PROP_ORIENTATION: - g_value_set_enum (value, panel_window_get_orientation (window)); - break; - - case PROP_AUTOHIDE: - g_value_set_boolean (value, panel_window_get_autohide (window)); - break; - - case PROP_SIZE: - g_value_set_int (value, panel_window_get_size (window)); - break; - - case PROP_LENGTH: - g_value_set_int (value, panel_window_get_length (window)); - break; + /* load the builder data into the object */ + gtk_builder_add_from_string (GTK_BUILDER (dialog), panel_preferences_dialog_glade, panel_preferences_dialog_glade_length, NULL); - case PROP_BACKGROUND_ALPHA: - g_value_set_int (value, panel_window_get_background_alpha (window)); - break; + /* get the dialog */ + window = gtk_builder_get_object (GTK_BUILDER (dialog), "dialog"); + panel_application_take_dialog (dialog->application, GTK_WINDOW (window)); + g_object_weak_ref (G_OBJECT (window), (GWeakNotify) g_object_unref, dialog); - case PROP_ENTER_OPACITY: - g_value_set_int (value, panel_window_get_enter_opacity (window)); - break; + /* connect the close button */ + object = gtk_builder_get_object (GTK_BUILDER (dialog), "close-button"); + g_signal_connect_swapped (G_OBJECT (object), "clicked", G_CALLBACK (gtk_widget_destroy), window); - case PROP_LEAVE_OPACITY: - g_value_set_int (value, panel_window_get_leave_opacity (window)); - break; + /* connect the help button */ + object = gtk_builder_get_object (GTK_BUILDER (dialog), "help-button"); + g_signal_connect (G_OBJECT (object), "clicked", G_CALLBACK (panel_preferences_dialog_help), NULL); - case PROP_SPAN_MONITORS: - g_value_set_boolean (value, panel_window_get_span_monitors (window)); - break; + /* connect the add button */ + object = gtk_builder_get_object (GTK_BUILDER (dialog), "add-panel"); + g_signal_connect (G_OBJECT (object), "clicked", G_CALLBACK (panel_preferences_dialog_window_add), dialog); - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - - - -static void -panel_preferences_dialog_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - PanelPreferencesDialog *dialog = PANEL_PREFERENCES_DIALOG (object); - PanelWindow *window = dialog->active; - - panel_return_if_fail (PANEL_IS_WINDOW (window)); - panel_return_if_fail (PANEL_IS_PREFERENCES_DIALOG (dialog)); - - /* stop pending timeout id */ - if (dialog->save_timeout_id != 0) - g_source_remove (dialog->save_timeout_id); - - switch (prop_id) - { - case PROP_LOCKED: - panel_window_set_locked (window, g_value_get_boolean (value)); - break; - - case PROP_ORIENTATION: - panel_glue_set_orientation (window, g_value_get_enum (value)); - break; + /* connect the remove button */ + object = gtk_builder_get_object (GTK_BUILDER (dialog), "remove-panel"); + g_signal_connect (G_OBJECT (object), "clicked", G_CALLBACK (panel_preferences_dialog_window_remove), dialog); - case PROP_AUTOHIDE: - panel_window_set_autohide (window, g_value_get_boolean (value)); - break; + /* connect the panel selector */ + object = gtk_builder_get_object (GTK_BUILDER (dialog), "panels"); + g_signal_connect (G_OBJECT (object), "changed", G_CALLBACK (panel_preferences_dialog_bindings_update), dialog); - case PROP_SIZE: - panel_glue_set_size (window, g_value_get_int (value)); - break; + /* TODO remove when implemented by glade */ + GtkCellRenderer *cell1 = gtk_cell_renderer_text_new (); + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (object), cell1, TRUE); + gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (object), cell1, "text", 0, NULL); - case PROP_LENGTH: - panel_window_set_length (window, g_value_get_int (value)); - break; + GtkCellRenderer *cell2 = gtk_cell_renderer_text_new (); + object = gtk_builder_get_object (GTK_BUILDER (dialog), "horizontal"); + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (object), cell2, TRUE); + gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (object), cell2, "text", 0, NULL); - case PROP_BACKGROUND_ALPHA: - panel_window_set_background_alpha (window, g_value_get_int (value)); - break; - - case PROP_ENTER_OPACITY: - panel_window_set_enter_opacity (window, g_value_get_int (value)); - break; - - case PROP_LEAVE_OPACITY: - panel_window_set_leave_opacity (window, g_value_get_int (value)); - break; - - case PROP_SPAN_MONITORS: - panel_window_set_span_monitors (window, g_value_get_boolean (value)); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } - - /* schedule a new save timeout */ - dialog->save_timeout_id = g_timeout_add_full (G_PRIORITY_DEFAULT_IDLE, 1000, - panel_preferences_dialog_save_timeout, dialog, - panel_preferences_dialog_save_timeout_destroyed); + /* rebuild the selector */ + panel_preferences_dialog_rebuild_selector (dialog); - /* don't leave the window */ - gtk_window_present (GTK_WINDOW (dialog)); + /* show the dialog */ + gtk_widget_show (GTK_WIDGET (window)); } @@ -620,19 +152,12 @@ panel_preferences_dialog_finalize (GObject *object) { PanelPreferencesDialog *dialog = PANEL_PREFERENCES_DIALOG (object); - /* save the settings */ - if (dialog->save_timeout_id != 0) - { - /* stop pending timeout */ - g_source_remove (dialog->save_timeout_id); - - /* save */ - panel_application_save (dialog->application); - } - /* thaw all autohide blocks */ panel_application_windows_autohide (dialog->application, FALSE); + /* deselect all windows */ + panel_application_window_select (dialog->application, NULL); + /* release the application */ g_object_unref (G_OBJECT (dialog->application)); @@ -641,59 +166,21 @@ panel_preferences_dialog_finalize (GObject *object) -static gboolean -panel_preferences_dialog_save_timeout (gpointer user_data) -{ - PanelPreferencesDialog *dialog = PANEL_PREFERENCES_DIALOG (user_data); - - panel_return_val_if_fail (PANEL_IS_PREFERENCES_DIALOG (user_data), FALSE); - panel_return_val_if_fail (PANEL_IS_APPLICATION (dialog->application), FALSE); - - /* save settings */ - panel_application_save (dialog->application); - - return FALSE; -} - - - static void -panel_preferences_dialog_save_timeout_destroyed (gpointer user_data) -{ - PANEL_PREFERENCES_DIALOG (user_data)->save_timeout_id = 0; -} - - - -static void -panel_preferences_dialog_response (GtkDialog *dialog, - gint response_id) +panel_preferences_dialog_help (GtkWidget *button) { GError *error = NULL; GdkScreen *screen; - if (response_id == GTK_RESPONSE_HELP) - { - /* get the dialog screen */ - screen = gtk_widget_get_screen (GTK_WIDGET (dialog)); - - /* open the help url */ - if (exo_url_show_on_screen (PREFERENCES_HELP_URL, NULL, screen, &error) == FALSE) - { - /* show error */ - g_warning ("Failed to open help: %s", error->message); - - /* cleanup */ - g_error_free (error); - } - } - else - { - /* deselect all windows */ - panel_application_window_select (PANEL_PREFERENCES_DIALOG (dialog)->application, NULL); + /* get the dialog screen */ + screen = gtk_widget_get_screen (button); - /* destroy the dialog */ - gtk_widget_destroy (GTK_WIDGET (dialog)); + /* open the help url */ + if (exo_url_show_on_screen (PREFERENCES_HELP_URL, NULL, screen, &error) == FALSE) + { + /* show error and cleanup */ + g_warning ("Failed to open help: %s", error->message); + g_error_free (error); } } @@ -702,16 +189,18 @@ panel_preferences_dialog_response (GtkDialog *dialog, static void panel_preferences_dialog_rebuild_selector (PanelPreferencesDialog *dialog) { - GtkComboBox *combo = GTK_COMBO_BOX (dialog->selector); + GObject *model, *combo; gint n, n_items; gchar *name; - GtkTreeModel *model; + + /* get the combo box and model */ + model = gtk_builder_get_object (GTK_BUILDER (dialog), "panels-store"); + combo = gtk_builder_get_object (GTK_BUILDER (dialog), "panels"); /* block signal */ - g_signal_handlers_block_by_func (G_OBJECT (combo), panel_preferences_dialog_set_window, dialog); + g_signal_handlers_block_by_func (combo, panel_preferences_dialog_bindings_update, dialog); /* empty the combo box */ - model = gtk_combo_box_get_model (combo); if (GTK_IS_LIST_STORE (model)) gtk_list_store_clear (GTK_LIST_STORE (model)); @@ -720,34 +209,78 @@ panel_preferences_dialog_rebuild_selector (PanelPreferencesDialog *dialog) for (n = 0; n < n_items; n++) { name = g_strdup_printf ("Panel %d", n + 1); - gtk_combo_box_append_text (combo, name); + gtk_list_store_insert_with_values (GTK_LIST_STORE (model), NULL, n, 0, name, -1); g_free (name); } /* unblock signal */ - g_signal_handlers_unblock_by_func (G_OBJECT (combo), panel_preferences_dialog_set_window, dialog); + g_signal_handlers_unblock_by_func (combo, panel_preferences_dialog_bindings_update, dialog); } static void -panel_preferences_dialog_set_window (PanelPreferencesDialog *dialog) +panel_preferences_dialog_bindings_unbind (PanelPreferencesDialog *dialog) { - gint active; - GParamSpec **specs; - guint n, nspecs; + GSList *li; + + if (dialog->bindings) + { + /* remove all bindings */ + for (li = dialog->bindings; li != NULL; li = li->next) + exo_mutual_binding_unbind (li->data); - /* get selected number */ - active = gtk_combo_box_get_active (GTK_COMBO_BOX (dialog->selector)); + /* cleanup */ + g_slist_free (dialog->bindings); + dialog->bindings = NULL; + } +} - /* set window */ - dialog->active = panel_application_get_window (dialog->application, active); - /* notify all properties */ - specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (dialog), &nspecs); - for (n = 0; n < nspecs; n++) - g_object_notify (G_OBJECT (dialog), specs[n]->name); - g_free (specs); + +static void +panel_preferences_dialog_bindings_add (PanelPreferencesDialog *dialog, + const gchar *property1, + const gchar *property2) +{ + ExoMutualBinding *binding; + GObject *object; + + /* get the object from the builder */ + object = gtk_builder_get_object (GTK_BUILDER (dialog), property1); + + /* create the binding and prepend to the list */ + binding = exo_mutual_binding_new (G_OBJECT (dialog->active), property1, object, property2); + dialog->bindings = g_slist_prepend (dialog->bindings, binding); +} + + + +static void +panel_preferences_dialog_bindings_update (GtkComboBox *combobox, + PanelPreferencesDialog *dialog) +{ + gint nth; + + panel_return_if_fail (GTK_IS_COMBO_BOX (combobox)); + panel_return_if_fail (PANEL_IS_PREFERENCES_DIALOG (dialog)); + + /* remove all the active bindings */ + panel_preferences_dialog_bindings_unbind (dialog); + + /* set the selected window */ + nth = gtk_combo_box_get_active (combobox); + dialog->active = panel_application_get_window (dialog->application, nth); + + /* hook up the bindings */ + panel_preferences_dialog_bindings_add (dialog, "horizontal", "active"); + panel_preferences_dialog_bindings_add (dialog, "locked", "active"); + panel_preferences_dialog_bindings_add (dialog, "autohide", "active"); + panel_preferences_dialog_bindings_add (dialog, "size", "value"); + panel_preferences_dialog_bindings_add (dialog, "length", "value"); + panel_preferences_dialog_bindings_add (dialog, "background-alpha", "value"); + panel_preferences_dialog_bindings_add (dialog, "enter-opacity", "value"); + panel_preferences_dialog_bindings_add (dialog, "leave-opacity", "value"); /* update selection state */ panel_application_window_select (dialog->application, dialog->active); @@ -756,11 +289,12 @@ panel_preferences_dialog_set_window (PanelPreferencesDialog *dialog) static void -panel_preferences_dialog_add_window (GtkWidget *widget, +panel_preferences_dialog_window_add (GtkWidget *widget, PanelPreferencesDialog *dialog) { gint active; PanelWindow *window; + GObject *object; /* create new window */ window = panel_application_new_window (dialog->application, gtk_widget_get_screen (widget)); @@ -772,11 +306,13 @@ panel_preferences_dialog_add_window (GtkWidget *widget, panel_preferences_dialog_rebuild_selector (dialog); /* set the sensitivity of the remove button */ - gtk_widget_set_sensitive (dialog->remove_button, panel_application_get_n_windows (dialog->application) > 1); + object = gtk_builder_get_object (GTK_BUILDER (dialog), "remove-panel"); + gtk_widget_set_sensitive (GTK_WIDGET (object), panel_application_get_n_windows (dialog->application) > 1); - /* select new panel */ + /* select new panel (new window is appended) */ + object = gtk_builder_get_object (GTK_BUILDER (dialog), "panels"); active = panel_application_get_n_windows (dialog->application) - 1; - gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->selector), active); + gtk_combo_box_set_active (GTK_COMBO_BOX (object), active); /* show window */ gtk_widget_show (GTK_WIDGET (window)); @@ -785,29 +321,34 @@ panel_preferences_dialog_add_window (GtkWidget *widget, static void -panel_preferences_dialog_remove_window (GtkWidget *widget, +panel_preferences_dialog_window_remove (GtkWidget *widget, PanelPreferencesDialog *dialog) { - gint active; + gint nth; + GObject *combo; /* get active panel */ - active = gtk_combo_box_get_active (GTK_COMBO_BOX (dialog->selector)); + nth = panel_application_get_window_index (dialog->application, dialog->active); /* destroy the window */ if (xfce_dialog_confirm (dialog, GTK_STOCK_REMOVE, NULL, - "Are you sure you want to remove panel %d?", active + 1)) + "Are you sure you want to remove panel %d?", nth + 1)) { + /* release the bindings */ + panel_preferences_dialog_bindings_unbind (dialog); + /* destroy the panel */ gtk_widget_destroy (GTK_WIDGET (dialog->active)); - /* rebuild the selector */ - panel_preferences_dialog_rebuild_selector (dialog); - /* set the sensitivity of the remove button */ gtk_widget_set_sensitive (widget, panel_application_get_n_windows (dialog->application) > 1); + /* rebuild the selector */ + panel_preferences_dialog_rebuild_selector (dialog); + /* select new active window */ - gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->selector), MAX (0, active - 1)); + combo = gtk_builder_get_object (GTK_BUILDER (dialog), "panels"); + gtk_combo_box_set_active (GTK_COMBO_BOX (combo), MAX (0, nth - 1)); } } @@ -818,6 +359,7 @@ panel_preferences_dialog_show (PanelWindow *active) { static PanelPreferencesDialog *dialog = NULL; gint idx = 0; + GObject *window, *combo; panel_return_if_fail (active == NULL || PANEL_IS_WINDOW (active)); @@ -835,14 +377,11 @@ panel_preferences_dialog_show (PanelWindow *active) active = panel_application_get_window (dialog->application, idx); /* show the dialog on the same screen as the panel */ - gtk_window_set_screen (GTK_WINDOW (dialog), gtk_widget_get_screen (GTK_WIDGET (active))); - - /* show the dialog */ - gtk_widget_show (GTK_WIDGET (dialog)); + window = gtk_builder_get_object (GTK_BUILDER (dialog), "dialog"); + gtk_window_set_screen (GTK_WINDOW (window), gtk_widget_get_screen (GTK_WIDGET (active))); + gtk_window_present (GTK_WINDOW (window)); /* select the active window in the dialog */ - gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->selector), idx); - - /* focus the window */ - gtk_window_present (GTK_WINDOW (dialog)); + combo = gtk_builder_get_object (GTK_BUILDER (dialog), "panels"); + gtk_combo_box_set_active (GTK_COMBO_BOX (combo), idx); } diff --git a/panel/panel-dialogs.glade b/panel/panel-preferences-dialog.glade index 75fa0a39..18b09417 100644 --- a/panel/panel-dialogs.glade +++ b/panel/panel-preferences-dialog.glade @@ -1,173 +1,184 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd"> -<!--Generated with glade3 3.4.5 on Sun Oct 5 17:27:12 2008 --> -<glade-interface> - <requires lib="xfce4"/> - <widget class="XfceTitledDialog" id="xfce-panel-preferences"> +<?xml version="1.0"?> +<interface> + <!-- interface-requires gtk+ 2.12 --> + <!-- interface-requires xfce4 0.0 --> + <!-- interface-naming-policy toplevel-contextual --> + <object class="XfceTitledDialog" id="dialog"> <property name="title" translatable="yes">Xfce Panel Preferences</property> <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property> <property name="icon_name">gtk-preferences</property> <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> <property name="has_separator">False</property> <child internal-child="vbox"> - <widget class="GtkVBox" id="dialog-vbox1"> + <object class="GtkVBox" id="dialog-vbox1"> <property name="visible">True</property> <property name="spacing">2</property> <child> - <widget class="GtkVBox" id="vbox1"> + <object class="GtkVBox" id="vbox1"> <property name="visible">True</property> <property name="border_width">6</property> <property name="spacing">12</property> <child> - <widget class="GtkHBox" id="hbox3"> + <object class="GtkHBox" id="hbox3"> <property name="visible">True</property> <property name="spacing">6</property> <child> - <widget class="GtkComboBox" id="combobox2"> + <object class="GtkComboBox" id="panels"> <property name="visible">True</property> - </widget> + <property name="model">panels-store</property> + </object> + <packing> + <property name="position">0</property> + </packing> </child> <child> - <widget class="GtkButton" id="button2"> + <object class="GtkButton" id="add-panel"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> - <property name="response_id">0</property> <child> - <widget class="GtkImage" id="image1"> + <object class="GtkImage" id="image1"> <property name="visible">True</property> <property name="stock">gtk-add</property> - </widget> + </object> </child> - </widget> + </object> <packing> <property name="expand">False</property> <property name="position">1</property> </packing> </child> <child> - <widget class="GtkButton" id="button3"> + <object class="GtkButton" id="remove-panel"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> - <property name="response_id">0</property> <child> - <widget class="GtkImage" id="image2"> + <object class="GtkImage" id="image2"> <property name="visible">True</property> <property name="stock">gtk-remove</property> - </widget> + </object> </child> - </widget> + </object> <packing> <property name="expand">False</property> <property name="position">2</property> </packing> </child> - </widget> + </object> + <packing> + <property name="expand">False</property> + <property name="position">0</property> + </packing> </child> <child> - <widget class="GtkNotebook" id="notebook1"> + <object class="GtkNotebook" id="notebook3"> <property name="visible">True</property> <property name="can_focus">True</property> <child> - <widget class="GtkVBox" id="vbox2"> + <object class="GtkVBox" id="vbox5"> <property name="visible">True</property> <property name="border_width">6</property> <property name="spacing">6</property> <child> - <widget class="GtkFrame" id="frame1"> + <object class="GtkFrame" id="frame5"> <property name="visible">True</property> <property name="label_xalign">0</property> <property name="shadow_type">GTK_SHADOW_NONE</property> <child> - <widget class="GtkAlignment" id="alignment1"> + <object class="GtkAlignment" id="alignment5"> <property name="visible">True</property> <property name="bottom_padding">6</property> <property name="left_padding">12</property> <child> - <widget class="GtkVBox" id="vbox2"> + <object class="GtkVBox" id="vbox6"> <property name="visible">True</property> <property name="border_width">6</property> <property name="spacing">6</property> <child> - <widget class="GtkHBox" id="hbox1"> + <object class="GtkHBox" id="hbox4"> <property name="visible">True</property> <property name="spacing">12</property> <child> - <widget class="GtkLabel" id="label8"> + <object class="GtkLabel" id="label17"> <property name="visible">True</property> <property name="label" translatable="yes">_Orientation:</property> <property name="use_underline">True</property> - </widget> + <property name="wrap_mode">PANGO_WRAP_WORD_CHAR</property> + <property name="mnemonic_widget">horizontal</property> + </object> <packing> <property name="expand">False</property> + <property name="position">0</property> </packing> </child> <child> - <widget class="GtkComboBox" id="combobox1"> + <object class="GtkComboBox" id="horizontal"> <property name="visible">True</property> - <property name="items" translatable="yes">Horizontal -Vertical</property> - </widget> + <property name="model">orientation-store</property> + </object> <packing> <property name="expand">False</property> <property name="position">1</property> </packing> </child> - </widget> + </object> + <packing> + <property name="position">0</property> + </packing> </child> <child> - <widget class="GtkCheckButton" id="checkbutton1"> + <object class="GtkCheckButton" id="locked"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="label" translatable="yes">_Lock panel</property> <property name="use_underline">True</property> - <property name="response_id">0</property> <property name="draw_indicator">True</property> - </widget> + </object> <packing> <property name="position">1</property> </packing> </child> <child> - <widget class="GtkCheckButton" id="checkbutton2"> + <object class="GtkCheckButton" id="autohide"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="label" translatable="yes">Automatically show and hi_de the panel</property> - <property name="response_id">0</property> + <property name="use_underline">True</property> <property name="draw_indicator">True</property> - </widget> + </object> <packing> <property name="position">2</property> </packing> </child> - </widget> + </object> </child> - </widget> + </object> </child> - <child> - <widget class="GtkLabel" id="label4"> + <child type="label"> + <object class="GtkLabel" id="label18"> <property name="visible">True</property> <property name="label" translatable="yes"><b>General</b></property> <property name="use_markup">True</property> - </widget> - <packing> - <property name="type">label_item</property> - </packing> + </object> </child> - </widget> + </object> + <packing> + <property name="expand">False</property> + <property name="position">0</property> + </packing> </child> <child> - <widget class="GtkFrame" id="frame2"> + <object class="GtkFrame" id="frame6"> <property name="visible">True</property> <property name="label_xalign">0</property> <property name="shadow_type">GTK_SHADOW_NONE</property> <child> - <widget class="GtkAlignment" id="alignment2"> + <object class="GtkAlignment" id="alignment6"> <property name="visible">True</property> <property name="left_padding">12</property> <child> - <widget class="GtkTable" id="table1"> + <object class="GtkTable" id="table3"> <property name="visible">True</property> <property name="border_width">6</property> <property name="n_rows">2</property> @@ -175,23 +186,25 @@ Vertical</property> <property name="column_spacing">12</property> <property name="row_spacing">6</property> <child> - <widget class="GtkLabel" id="label6"> + <object class="GtkLabel" id="label19"> <property name="visible">True</property> <property name="xalign">0</property> <property name="label" translatable="yes">_Size (pixels):</property> <property name="use_underline">True</property> - </widget> + <property name="mnemonic_widget">size-scale</property> + </object> <packing> <property name="x_options">GTK_FILL</property> </packing> </child> <child> - <widget class="GtkLabel" id="label7"> + <object class="GtkLabel" id="label20"> <property name="visible">True</property> <property name="xalign">0</property> <property name="label" translatable="yes">L_ength (%):</property> <property name="use_underline">True</property> - </widget> + <property name="mnemonic_widget">length-scale</property> + </object> <packing> <property name="top_attach">1</property> <property name="bottom_attach">2</property> @@ -199,14 +212,14 @@ Vertical</property> </packing> </child> <child> - <widget class="GtkHScale" id="hscale1"> + <object class="GtkHScale" id="length-scale"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="update_policy">GTK_UPDATE_DISCONTINUOUS</property> - <property name="adjustment">50 1 100 1 10 10</property> + <property name="adjustment">length</property> <property name="digits">0</property> <property name="value_pos">GTK_POS_RIGHT</property> - </widget> + </object> <packing> <property name="left_attach">1</property> <property name="right_attach">2</property> @@ -215,123 +228,121 @@ Vertical</property> </packing> </child> <child> - <widget class="GtkHScale" id="hscale2"> + <object class="GtkHScale" id="size-scale"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="update_policy">GTK_UPDATE_DISCONTINUOUS</property> - <property name="adjustment">48 16 128 1 10 10</property> + <property name="adjustment">size</property> <property name="digits">0</property> <property name="value_pos">GTK_POS_RIGHT</property> - </widget> + </object> <packing> <property name="left_attach">1</property> <property name="right_attach">2</property> </packing> </child> - </widget> + </object> </child> - </widget> + </object> </child> - <child> - <widget class="GtkLabel" id="label5"> + <child type="label"> + <object class="GtkLabel" id="label21"> <property name="visible">True</property> <property name="label" translatable="yes"><b>Measurements</b></property> <property name="use_markup">True</property> - </widget> - <packing> - <property name="type">label_item</property> - </packing> + </object> </child> - </widget> + </object> <packing> + <property name="expand">False</property> <property name="position">1</property> </packing> </child> - </widget> + </object> </child> - <child> - <widget class="GtkLabel" id="label1"> + <child type="tab"> + <object class="GtkLabel" id="label22"> <property name="visible">True</property> - <property name="label" translatable="yes">Display</property> - </widget> + <property name="label" translatable="yes">D_isplay</property> + <property name="use_underline">True</property> + </object> <packing> - <property name="type">tab</property> <property name="tab_fill">False</property> </packing> </child> <child> - <widget class="GtkVBox" id="vbox3"> + <object class="GtkVBox" id="vbox7"> <property name="visible">True</property> <property name="border_width">6</property> <property name="spacing">6</property> <child> - <widget class="GtkFrame" id="frame3"> + <object class="GtkFrame" id="frame7"> <property name="visible">True</property> <property name="label_xalign">0</property> <property name="shadow_type">GTK_SHADOW_NONE</property> <child> - <widget class="GtkAlignment" id="alignment3"> + <object class="GtkAlignment" id="alignment7"> <property name="visible">True</property> <property name="bottom_padding">6</property> <property name="left_padding">12</property> <child> - <widget class="GtkHBox" id="hbox2"> + <object class="GtkHBox" id="hbox5"> <property name="visible">True</property> <property name="border_width">6</property> <property name="spacing">12</property> <child> - <widget class="GtkLabel" id="label11"> + <object class="GtkLabel" id="label23"> <property name="visible">True</property> <property name="label" translatable="yes">_Alpha:</property> <property name="use_underline">True</property> - </widget> + <property name="mnemonic_widget">alpha-scale</property> + </object> <packing> <property name="expand">False</property> + <property name="position">0</property> </packing> </child> <child> - <widget class="GtkHScale" id="hscale3"> + <object class="GtkHScale" id="alpha-scale"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="adjustment">0 0 100 1 10 10</property> + <property name="adjustment">background-alpha</property> <property name="digits">0</property> <property name="value_pos">GTK_POS_RIGHT</property> - </widget> + </object> <packing> <property name="position">1</property> </packing> </child> - </widget> + </object> </child> - </widget> + </object> </child> - <child> - <widget class="GtkLabel" id="label9"> + <child type="label"> + <object class="GtkLabel" id="label24"> <property name="visible">True</property> <property name="label" translatable="yes"><b>Background</b></property> <property name="use_markup">True</property> - </widget> - <packing> - <property name="type">label_item</property> - </packing> + </object> </child> - </widget> + </object> <packing> <property name="expand">False</property> + <property name="position">0</property> </packing> </child> <child> - <widget class="GtkFrame" id="frame4"> + <object class="GtkFrame" id="frame8"> <property name="visible">True</property> <property name="label_xalign">0</property> <property name="shadow_type">GTK_SHADOW_NONE</property> <child> - <widget class="GtkAlignment" id="alignment4"> + <object class="GtkAlignment" id="alignment8"> <property name="visible">True</property> <property name="bottom_padding">6</property> <property name="left_padding">12</property> <child> - <widget class="GtkTable" id="table2"> + <object class="GtkTable" id="table4"> <property name="visible">True</property> <property name="border_width">6</property> <property name="n_rows">2</property> @@ -339,23 +350,25 @@ Vertical</property> <property name="column_spacing">12</property> <property name="row_spacing">6</property> <child> - <widget class="GtkLabel" id="label12"> + <object class="GtkLabel" id="label25"> <property name="visible">True</property> <property name="xalign">0</property> <property name="label" translatable="yes">_Enter:</property> <property name="use_underline">True</property> - </widget> + <property name="mnemonic_widget">enter-opacity-scale</property> + </object> <packing> <property name="x_options">GTK_FILL</property> </packing> </child> <child> - <widget class="GtkLabel" id="label13"> + <object class="GtkLabel" id="label26"> <property name="visible">True</property> <property name="xalign">0</property> <property name="label" translatable="yes">_Leave:</property> <property name="use_underline">True</property> - </widget> + <property name="mnemonic_widget">leave-opacity-scale</property> + </object> <packing> <property name="top_attach">1</property> <property name="bottom_attach">2</property> @@ -363,26 +376,26 @@ Vertical</property> </packing> </child> <child> - <widget class="GtkHScale" id="hscale4"> + <object class="GtkHScale" id="enter-opacity-scale"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="adjustment">0 0 100 1 10 10</property> + <property name="adjustment">enter-opacity</property> <property name="digits">0</property> <property name="value_pos">GTK_POS_RIGHT</property> - </widget> + </object> <packing> <property name="left_attach">1</property> <property name="right_attach">2</property> </packing> </child> <child> - <widget class="GtkHScale" id="hscale5"> + <object class="GtkHScale" id="leave-opacity-scale"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="adjustment">0 0 100 1 10 10</property> + <property name="adjustment">leave-opacity</property> <property name="digits">0</property> <property name="value_pos">GTK_POS_RIGHT</property> - </widget> + </object> <packing> <property name="left_attach">1</property> <property name="right_attach">2</property> @@ -390,175 +403,157 @@ Vertical</property> <property name="bottom_attach">2</property> </packing> </child> - </widget> + </object> </child> - </widget> + </object> </child> - <child> - <widget class="GtkLabel" id="label10"> + <child type="label"> + <object class="GtkLabel" id="label27"> <property name="visible">True</property> <property name="label" translatable="yes"><b>Transparency</b></property> <property name="use_markup">True</property> - </widget> - <packing> - <property name="type">label_item</property> - </packing> + </object> </child> - </widget> + </object> <packing> <property name="expand">False</property> <property name="position">1</property> </packing> </child> - </widget> + </object> <packing> <property name="position">1</property> </packing> </child> - <child> - <widget class="GtkLabel" id="label2"> + <child type="tab"> + <object class="GtkLabel" id="label28"> <property name="visible">True</property> - <property name="label" translatable="yes">Compositing</property> - </widget> + <property name="label" translatable="yes">C_ompositing</property> + <property name="use_underline">True</property> + </object> <packing> - <property name="type">tab</property> <property name="position">1</property> <property name="tab_fill">False</property> </packing> </child> <child> - <placeholder/> + <object class="GtkLabel" id="label33"> + <property name="visible">True</property> + </object> + <packing> + <property name="position">2</property> + </packing> </child> - <child> - <widget class="GtkLabel" id="label3"> + <child type="tab"> + <object class="GtkLabel" id="label32"> <property name="visible">True</property> - <property name="label" translatable="yes">Multi Screen</property> - </widget> + <property name="label" translatable="yes">_Multi Screen</property> + <property name="use_underline">True</property> + </object> <packing> - <property name="type">tab</property> <property name="position">2</property> <property name="tab_fill">False</property> </packing> </child> - </widget> + </object> <packing> <property name="position">1</property> </packing> </child> - </widget> + </object> <packing> <property name="position">1</property> </packing> </child> <child internal-child="action_area"> - <widget class="GtkHButtonBox" id="dialog-action_area1"> + <object class="GtkHButtonBox" id="dialog-action_area1"> <property name="visible">True</property> <property name="layout_style">GTK_BUTTONBOX_END</property> <child> - <widget class="GtkButton" id="button1"> + <object class="GtkButton" id="close-button"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> <property name="label" translatable="yes">gtk-close</property> <property name="use_stock">True</property> - <property name="response_id">0</property> - </widget> - </child> - </widget> - <packing> - <property name="expand">False</property> - <property name="pack_type">GTK_PACK_END</property> - </packing> - </child> - </widget> - </child> - </widget> - <widget class="XfceTitledDialog" id="xfce-panel-items"> - <property name="title" translatable="yes">Xfce Panel Add Items</property> - <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property> - <property name="icon_name">gtk-add</property> - <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> - <property name="has_separator">False</property> - <child internal-child="vbox"> - <widget class="GtkVBox" id="dialog-vbox2"> - <property name="visible">True</property> - <property name="spacing">2</property> - <child> - <widget class="GtkVBox" id="vbox5"> - <property name="visible">True</property> - <property name="border_width">6</property> - <property name="spacing">6</property> - <child> - <widget class="GtkHBox" id="hbox4"> - <property name="visible">True</property> - <property name="spacing">12</property> - <child> - <widget class="GtkLabel" id="label14"> - <property name="visible">True</property> - <property name="xalign">1</property> - <property name="label" translatable="yes">_Search:</property> - <property name="use_underline">True</property> - </widget> - </child> - <child> - <widget class="GtkEntry" id="entry1"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </widget> - <packing> - <property name="expand">False</property> - <property name="position">1</property> - </packing> - </child> - </widget> + </object> <packing> - <property name="expand">False</property> + <property name="position">0</property> </packing> </child> <child> - <widget class="GtkScrolledWindow" id="scrolledwindow1"> + <object class="GtkButton" id="help-button"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> - <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> - <property name="shadow_type">GTK_SHADOW_IN</property> - <child> - <widget class="GtkTreeView" id="treeview1"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </widget> - </child> - </widget> + <property name="receives_default">True</property> + <property name="label" translatable="yes">gtk-help</property> + <property name="use_stock">True</property> + </object> <packing> <property name="position">1</property> + <property name="secondary">True</property> </packing> </child> - </widget> - <packing> - <property name="position">1</property> - </packing> - </child> - <child internal-child="action_area"> - <widget class="GtkHButtonBox" id="dialog-action_area2"> - <property name="visible">True</property> - <property name="layout_style">GTK_BUTTONBOX_END</property> - <child> - <widget class="GtkButton" id="button4"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="label" translatable="yes">gtk-close</property> - <property name="use_stock">True</property> - <property name="response_id">0</property> - </widget> - </child> - </widget> + </object> <packing> <property name="expand">False</property> <property name="pack_type">GTK_PACK_END</property> + <property name="position">0</property> </packing> </child> - </widget> + </object> </child> - </widget> -</glade-interface> + </object> + <object class="GtkListStore" id="orientation-store"> + <columns> + <!-- column-name title --> + <column type="gchararray"/> + </columns> + <data> + <row> + <col id="0" translatable="yes">Vertical</col> + </row> + <row> + <col id="0" translatable="yes">Horizontal</col> + </row> + </data> + </object> + <object class="GtkListStore" id="panels-store"> + <columns> + <!-- column-name title --> + <column type="gchararray"/> + </columns> + </object> + <object class="GtkAdjustment" id="size"> + <property name="value">16</property> + <property name="lower">16</property> + <property name="upper">128</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> + <object class="GtkAdjustment" id="length"> + <property name="value">25</property> + <property name="lower">1</property> + <property name="upper">100</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> + <object class="GtkAdjustment" id="background-alpha"> + <property name="value">100</property> + <property name="upper">100</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> + <object class="GtkAdjustment" id="enter-opacity"> + <property name="value">100</property> + <property name="upper">100</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> + <object class="GtkAdjustment" id="leave-opacity"> + <property name="value">100</property> + <property name="upper">100</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> +</interface> diff --git a/panel/panel-window.c b/panel/panel-window.c index d1141d43..cb95fb55 100644 --- a/panel/panel-window.c +++ b/panel/panel-window.c @@ -33,6 +33,10 @@ #include <panel/panel-glue.h> #include <panel/panel-application.h> #include <panel/panel-plugin-external.h> +#include <panel/panel-item-dialog.h> +#include <panel/panel-preferences-dialog.h> +#include <panel/panel-dialogs.h> +#include <panel/panel-dbus-service.h> #define HANDLE_SIZE (8) #define HANDLE_SPACING (2) @@ -48,6 +52,7 @@ static void panel_window_class_init (PanelWindowClass *klass); static void panel_window_init (PanelWindow *window); static void panel_window_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); +static void panel_window_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); static void panel_window_finalize (GObject *object); static void panel_window_realize (GtkWidget *widget); static gboolean panel_window_expose_event (GtkWidget *widget, GdkEventExpose *event); @@ -68,11 +73,31 @@ static void panel_window_struts_update (PanelWindow *window, gint x, gint y, gi static void panel_window_set_colormap (PanelWindow *window); static void panel_window_get_position (PanelWindow *window, gint *root_x, gint *root_y); static void panel_window_set_borders (PanelWindow *window); +static void panel_window_set_autohide (PanelWindow *window, gboolean autohide); +static void panel_window_menu_quit (gpointer boolean); +static void panel_window_menu_deactivate (GtkMenu *menu, PanelWindow *window); +static void panel_window_menu_popup (PanelWindow *window); + +static void panel_window_set_plugin_active_panel (GtkWidget *widget, gpointer user_data); +static void panel_window_set_plugin_background_alpha (GtkWidget *widget, gpointer user_data); +static void panel_window_set_plugin_size (GtkWidget *widget, gpointer user_data); +static void panel_window_set_plugin_orientation (GtkWidget *widget, gpointer user_data); enum { PROP_0, - PROP_ORIENTATION + PROP_HORIZONTAL, + PROP_SIZE, + PROP_LENGTH, + PROP_LOCKED, + PROP_X_OFFSET, + PROP_Y_OFFSET, + PROP_ENTER_OPACITY, + PROP_LEAVE_OPACITY, + PROP_SNAP_EDGE, + PROP_BACKGROUND_ALPHA, + PROP_SPAN_MONITORS, + PROP_AUTOHIDE }; enum @@ -98,18 +123,18 @@ AutohideStatus; enum { STRUT_LEFT = 0, - STRUT_RIGHT, - STRUT_TOP, - STRUT_BOTTOM, - STRUT_LEFT_START_Y, - STRUT_LEFT_END_Y, - STRUT_RIGHT_START_Y, - STRUT_RIGHT_END_Y, - STRUT_TOP_START_X, - STRUT_TOP_END_X, - STRUT_BOTTOM_START_X, - STRUT_BOTTOM_END_X, - N_STRUTS + STRUT_RIGHT, + STRUT_TOP, + STRUT_BOTTOM, + STRUT_LEFT_START_Y, + STRUT_LEFT_END_Y, + STRUT_RIGHT_START_Y, + STRUT_RIGHT_END_Y, + STRUT_TOP_START_X, + STRUT_TOP_END_X, + STRUT_BOTTOM_START_X, + STRUT_BOTTOM_END_X, + N_STRUTS }; struct _PanelWindowClass @@ -152,10 +177,10 @@ struct _PanelWindow guint is_active_panel : 1; /* panel orientation */ - guint horizontal; + guint horizontal : 1; /* panel size (px) and length (%) */ - gint size; + guint size; gdouble length; /* autohide */ @@ -199,6 +224,7 @@ panel_window_class_init (PanelWindowClass *klass) gobject_class = G_OBJECT_CLASS (klass); gobject_class->get_property = panel_window_get_property; + gobject_class->set_property = panel_window_set_property; gobject_class->finalize = panel_window_finalize; gtkwidget_class = GTK_WIDGET_CLASS (klass); @@ -220,11 +246,76 @@ panel_window_class_init (PanelWindowClass *klass) * panel orientation with that of the itembar, using exo bindings. **/ g_object_class_install_property (gobject_class, - PROP_ORIENTATION, - g_param_spec_enum ("orientation", "orientation", "orientation", - GTK_TYPE_ORIENTATION, - GTK_ORIENTATION_HORIZONTAL, - EXO_PARAM_READABLE)); + PROP_HORIZONTAL, + g_param_spec_boolean ("horizontal", NULL, NULL, + TRUE, + EXO_PARAM_READWRITE)); + + g_object_class_install_property (gobject_class, + PROP_SIZE, + g_param_spec_uint ("size", NULL, NULL, + 16, 128, 48, + EXO_PARAM_READWRITE)); + + g_object_class_install_property (gobject_class, + PROP_LENGTH, + g_param_spec_uint ("length", NULL, NULL, + 1, 100, 25, + EXO_PARAM_READWRITE)); + + g_object_class_install_property (gobject_class, + PROP_LOCKED, + g_param_spec_boolean ("locked", NULL, NULL, + FALSE, + EXO_PARAM_READWRITE)); + + g_object_class_install_property (gobject_class, + PROP_X_OFFSET, + g_param_spec_uint ("x-offset", NULL, NULL, + 0, G_MAXUINT, 0, + EXO_PARAM_READWRITE)); + + g_object_class_install_property (gobject_class, + PROP_Y_OFFSET, + g_param_spec_uint ("y-offset", NULL, NULL, + 0, G_MAXUINT, 0, + EXO_PARAM_READWRITE)); + + g_object_class_install_property (gobject_class, + PROP_ENTER_OPACITY, + g_param_spec_uint ("enter-opacity", NULL, NULL, + 0, 100, 100, + EXO_PARAM_READWRITE)); + + g_object_class_install_property (gobject_class, + PROP_LEAVE_OPACITY, + g_param_spec_uint ("leave-opacity", NULL, NULL, + 0, 100, 100, + EXO_PARAM_READWRITE)); + + g_object_class_install_property (gobject_class, + PROP_BACKGROUND_ALPHA, + g_param_spec_uint ("background-alpha", NULL, NULL, + 0, 100, 100, + EXO_PARAM_READWRITE)); + + g_object_class_install_property (gobject_class, + PROP_AUTOHIDE, + g_param_spec_boolean ("autohide", NULL, NULL, + FALSE, + EXO_PARAM_READWRITE)); + + g_object_class_install_property (gobject_class, + PROP_SPAN_MONITORS, + g_param_spec_boolean ("span-monitors", NULL, NULL, + FALSE, + EXO_PARAM_READWRITE)); + + g_object_class_install_property (gobject_class, + PROP_SNAP_EDGE, + g_param_spec_uint ("snap-edge", NULL, NULL, + PANEL_SNAP_EGDE_NONE, PANEL_SNAP_EGDE_S, PANEL_SNAP_EGDE_NONE, + EXO_PARAM_READWRITE)); /* initialize the atoms */ cardinal_atom = gdk_atom_intern_static_string ("CARDINAL"); @@ -292,11 +383,187 @@ panel_window_get_property (GObject *object, GParamSpec *pspec) { PanelWindow *window = PANEL_WINDOW (object); + //gint pos; switch (prop_id) { - case PROP_ORIENTATION: - g_value_set_enum (value, panel_window_get_orientation (window)); + case PROP_HORIZONTAL: + g_value_set_boolean (value, window->horizontal); + break; + + case PROP_SIZE: + g_value_set_uint (value, window->size); + break; + + case PROP_LENGTH: + g_value_set_uint (value, rint (window->length * 100.00)); + break; + + case PROP_LOCKED: + g_value_set_boolean (value, window->locked); + break; + + case PROP_X_OFFSET: + //panel_window_get_position (window, &pos, NULL); + //g_value_set_uint (value, pos); + g_value_set_uint (value, 0); + break; + + case PROP_Y_OFFSET: + //panel_window_get_position (window, NULL, &pos); + //g_value_set_uint (value, pos); + g_value_set_uint (value, 0); + break; + + case PROP_ENTER_OPACITY: + g_value_set_uint (value, rint (window->enter_opacity * 100.00)); + break; + + case PROP_LEAVE_OPACITY: + g_value_set_uint (value, rint (window->leave_opacity * 100.00)); + break; + + case PROP_BACKGROUND_ALPHA: + g_value_set_uint (value, rint (window->background_alpha * 100.00)); + break; + + case PROP_SNAP_EDGE: + g_value_set_uint (value, window->snap_edge); + break; + + case PROP_SPAN_MONITORS: + g_value_set_boolean (value, window->span_monitors); + break; + + case PROP_AUTOHIDE: + g_value_set_boolean (value, !!(window->autohide_status != DISABLED)); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + + + +static void +panel_window_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + PanelWindow *window = PANEL_WINDOW (object); + //gint pos; + + switch (prop_id) + { + case PROP_HORIZONTAL: + /* set whether the panel */ + window->horizontal = g_value_get_boolean (value); + + /* update all the panel plugins */ + gtk_container_foreach (GTK_CONTAINER (gtk_bin_get_child (GTK_BIN (window))), + panel_window_set_plugin_orientation, + GUINT_TO_POINTER (window->horizontal ? GTK_ORIENTATION_HORIZONTAL: + GTK_ORIENTATION_VERTICAL)); + + /* queue a resize */ + gtk_widget_queue_resize (GTK_WIDGET (window)); + break; + + case PROP_SIZE: + /* update the panel size */ + window->size = g_value_get_uint (value); + + /* update all the panel plugins */ + gtk_container_foreach (GTK_CONTAINER (gtk_bin_get_child (GTK_BIN (window))), + panel_window_set_plugin_size, + GUINT_TO_POINTER (window->size)); + + /* queue a resize */ + gtk_widget_queue_resize (GTK_WIDGET (window)); + break; + + case PROP_LENGTH: + /* set the new length */ + window->length = g_value_get_uint (value) / 100.00; + + /* update the border and resize */ + panel_window_set_borders (window); + gtk_widget_queue_resize (GTK_WIDGET (window)); + break; + + case PROP_LOCKED: + /* set new lock value and resize */ + window->locked = g_value_get_boolean (value); + gtk_widget_queue_resize (GTK_WIDGET (window)); + break; + + case PROP_X_OFFSET: + /* get window position */ + //gtk_window_get_position (GTK_WINDOW (window), NULL, &pos); + //gtk_window_move (GTK_WINDOW (window), g_value_get_uint (value), pos); + break; + + case PROP_Y_OFFSET: + /* get window position */ + //gtk_window_get_position (GTK_WINDOW (window), &pos, NULL); + //gtk_window_move (GTK_WINDOW (window), pos, g_value_get_uint (value)); + break; + + case PROP_ENTER_OPACITY: + /* set the new enter opacity */ + window->enter_opacity = g_value_get_uint (value) / 100.00; + break; + + case PROP_LEAVE_OPACITY: + /* set the new leave opacity */ + window->leave_opacity = g_value_get_uint (value) / 100.00; + + /* set the autohide window opacity if created */ + if (window->autohide_window) + _window_set_opacity (GTK_WINDOW (window->autohide_window), window->leave_opacity); + + /* update the panel window opacity */ + _window_set_opacity (GTK_WINDOW (window), window->leave_opacity); + break; + + case PROP_BACKGROUND_ALPHA: + /* set the new value and redraw the panel */ + window->background_alpha = g_value_get_uint (value) / 100.00; + gtk_widget_queue_draw (GTK_WIDGET (window)); + + /* update the external plugins */ + gtk_container_foreach (GTK_CONTAINER (gtk_bin_get_child (GTK_BIN (window))), + panel_window_set_plugin_background_alpha, + GUINT_TO_POINTER (g_value_get_uint (value))); + break; + + case PROP_SNAP_EDGE: + /* set snap edge value */ + window->snap_edge = g_value_get_uint (value); + + /* update the window borders */ + panel_window_set_borders (window); + + /* queue a resize */ + gtk_widget_queue_resize (GTK_WIDGET (window)); + break; + + case PROP_SPAN_MONITORS: + /* store new value */ + window->span_monitors = g_value_get_boolean (value); + + /* update the working area */ + panel_window_working_area (window, -1, -1, &window->working_area); + + /* resize the panel */ + gtk_widget_queue_resize (GTK_WIDGET (window)); + break; + + case PROP_AUTOHIDE: + panel_window_set_autohide (window, g_value_get_boolean (value)); break; default: @@ -518,6 +785,9 @@ panel_window_motion_notify (GtkWidget *widget, /* set the new value */ window->snap_edge = snap_edge; + /* notify the property */ + g_object_notify (G_OBJECT (window), "snap-edge"); + /* update the borders */ panel_window_set_borders (window); } @@ -566,7 +836,7 @@ panel_window_button_press_event (GtkWidget *widget, else if (event->button == 3 || (event->button == 1 && modifiers == GDK_CONTROL_MASK)) { /* popup the panel menu */ - panel_glue_popup_menu (window); + panel_window_menu_popup (window); return TRUE; } @@ -597,7 +867,7 @@ panel_window_button_release_event (GtkWidget *widget, panel_window_screen_changed (widget, gtk_window_get_screen (GTK_WINDOW (widget))); /* update the plugins */ - panel_glue_set_screen_position (window); + /* TODO panel function for this */ return TRUE; } @@ -1683,299 +1953,7 @@ panel_window_set_borders (PanelWindow *window) -GtkWidget * -panel_window_new (void) -{ - return g_object_new (PANEL_TYPE_WINDOW, NULL); -} - - - -gboolean -panel_window_is_composited (PanelWindow *window) -{ - panel_return_val_if_fail (PANEL_IS_WINDOW (window), FALSE); - - return window->is_composited; -} - - - static void -panel_window_plugin_set_active_panel (GtkWidget *widget, - gpointer user_data) -{ - panel_return_if_fail (PANEL_IS_WINDOW (user_data)); - panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (widget)); - - if (PANEL_IS_PLUGIN_EXTERNAL (widget)) - panel_plugin_external_set_active_panel (PANEL_PLUGIN_EXTERNAL (widget), PANEL_WINDOW (user_data)->is_active_panel); -} - - - -void -panel_window_set_active_panel (PanelWindow *window, - gboolean active) -{ - GtkWidget *itembar; - - panel_return_if_fail (PANEL_IS_WINDOW (window)); - - if (G_UNLIKELY (window->is_active_panel != active)) - { - /* set new value */ - window->is_active_panel = !!active; - - /* queue a redraw */ - gtk_widget_queue_draw (GTK_WIDGET (window)); - - /* get the itembar */ - itembar = gtk_bin_get_child (GTK_BIN (window)); - - /* poke all the plugins */ - gtk_container_foreach (GTK_CONTAINER (itembar), panel_window_plugin_set_active_panel, window); - } -} - - - -PanelWindowSnapEdge -panel_window_get_snap_edge (PanelWindow *window) -{ - panel_return_val_if_fail (PANEL_IS_WINDOW (window), PANEL_SNAP_EGDE_NONE); - - return window->snap_edge; -} - - - -void -panel_window_set_snap_edge (PanelWindow *window, - PanelWindowSnapEdge snap_edge) -{ - panel_return_if_fail (PANEL_IS_WINDOW (window)); - - if (G_LIKELY (window->snap_edge != snap_edge)) - { - /* set snap edge value */ - window->snap_edge = snap_edge; - - /* update the window borders */ - panel_window_set_borders (window); - - /* queue a resize */ - gtk_widget_queue_resize (GTK_WIDGET (window)); - } -} - - - -gboolean -panel_window_get_locked (PanelWindow *window) -{ - panel_return_val_if_fail (PANEL_IS_WINDOW (window), FALSE); - - return window->locked; -} - - - -void -panel_window_set_locked (PanelWindow *window, - gboolean locked) -{ - panel_return_if_fail (PANEL_IS_WINDOW (window)); - - if (G_LIKELY (window->locked != locked)) - { - /* set new lock value */ - window->locked = !!locked; - - /* queue a resize */ - gtk_widget_queue_resize (GTK_WIDGET (window)); - } -} - - - -GtkOrientation -panel_window_get_orientation (PanelWindow *window) -{ - panel_return_val_if_fail (PANEL_IS_WINDOW (window), GTK_ORIENTATION_HORIZONTAL); - - return window->horizontal ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL; -} - - - -void -panel_window_set_orientation (PanelWindow *window, - GtkOrientation orientation) -{ - gboolean horizontal; - - panel_return_if_fail (PANEL_IS_WINDOW (window)); - - /* whether the orientation is horizontal */ - horizontal = !!(orientation == GTK_ORIENTATION_HORIZONTAL); - - if (G_LIKELY ((gboolean) window->horizontal != horizontal)) - { - /* set new orientation */ - window->horizontal = horizontal; - - /* resize */ - gtk_widget_queue_resize (GTK_WIDGET (window)); - - /* notify listeners */ - g_object_notify (G_OBJECT (window), "orientation"); - } -} - - - -gint -panel_window_get_size (PanelWindow *window) -{ - panel_return_val_if_fail (PANEL_IS_WINDOW (window), 0); - - return window->size; -} - - - -void -panel_window_set_size (PanelWindow *window, - gint size) -{ - panel_return_if_fail (PANEL_IS_WINDOW (window)); - - if (G_LIKELY (window->size != size)) - { - /* set new size */ - window->size = size; - - /* resize */ - gtk_widget_queue_resize (GTK_WIDGET (window)); - } -} - - - -gint -panel_window_get_length (PanelWindow *window) -{ - panel_return_val_if_fail (PANEL_IS_WINDOW (window), 0); - - return rint (window->length * 100.00); -} - - - -void -panel_window_set_length (PanelWindow *window, - gint percentage) -{ - gdouble length; - - panel_return_if_fail (PANEL_IS_WINDOW (window)); - - /* normalize value */ - length = CLAMP (percentage, 1, 100) / 100.00; - - if (G_LIKELY (window->length != length)) - { - /* set new length */ - window->length = length; - - /* update the panel borders */ - panel_window_set_borders (window); - - /* resize */ - gtk_widget_queue_resize (GTK_WIDGET (window)); - } -} - - - -gint -panel_window_get_xoffset (PanelWindow *window) -{ - gint root_x; - - panel_return_val_if_fail (PANEL_IS_WINDOW (window), 0); - - /* get the panel window position */ - panel_window_get_position (window, &root_x, NULL); - - return root_x; -} - - - -void -panel_window_set_xoffset (PanelWindow *window, - gint xoffset) -{ - gint x, y; - - panel_return_if_fail (PANEL_IS_WINDOW (window)); - - /* get window position */ - gtk_window_get_position (GTK_WINDOW (window), &x, &y); - - /* move window is needed */ - if (G_LIKELY (x != xoffset)) - gtk_window_move (GTK_WINDOW (window), xoffset, y); -} - - - -gint -panel_window_get_yoffset (PanelWindow *window) -{ - gint root_y; - - panel_return_val_if_fail (PANEL_IS_WINDOW (window), 0); - - /* get the panel window position */ - panel_window_get_position (window, NULL, &root_y); - - return root_y; -} - - - -void -panel_window_set_yoffset (PanelWindow *window, - gint yoffset) -{ - gint x, y; - - panel_return_if_fail (PANEL_IS_WINDOW (window)); - - /* get window position */ - gtk_window_get_position (GTK_WINDOW (window), &x, &y); - - /* move window if needed */ - if (G_LIKELY (y != yoffset)) - gtk_window_move (GTK_WINDOW (window), x, yoffset); -} - - - -gboolean -panel_window_get_autohide (PanelWindow *window) -{ - panel_return_val_if_fail (PANEL_IS_WINDOW (window), FALSE); - - return !!(window->autohide_status != DISABLED); -} - - - -void panel_window_set_autohide (PanelWindow *window, gboolean autohide) { @@ -1983,7 +1961,7 @@ panel_window_set_autohide (PanelWindow *window, panel_return_if_fail (PANEL_IS_WINDOW (window)); - if (G_LIKELY (panel_window_get_autohide (window) != autohide)) + if (G_LIKELY ((window->autohide_status != DISABLED) != autohide)) { /* determ whether struts are possible on the next resize */ window->struts_possible = -1; @@ -2017,183 +1995,237 @@ panel_window_set_autohide (PanelWindow *window, -void -panel_window_freeze_autohide (PanelWindow *window) +static void +panel_window_menu_quit (gpointer boolean) { - panel_return_if_fail (PANEL_IS_WINDOW (window)); - panel_return_if_fail (window->autohide_block >= 0); + extern gboolean dbus_quit_with_restart; - /* increase autohide block counter */ - window->autohide_block++; + /* restart or quit */ + dbus_quit_with_restart = !!(GPOINTER_TO_UINT (boolean)); - /* block autohide */ - if (window->autohide_block == 1 && window->autohide_status != DISABLED) - panel_window_autohide_queue (window, BLOCKED); + /* quit main loop */ + gtk_main_quit (); } -void -panel_window_thaw_autohide (PanelWindow *window) +static void +panel_window_menu_deactivate (GtkMenu *menu, + PanelWindow *window) { + panel_return_if_fail (GTK_IS_MENU (menu)); panel_return_if_fail (PANEL_IS_WINDOW (window)); - panel_return_if_fail (window->autohide_block > 0); - /* decrease autohide block counter */ - window->autohide_block--; + /* thaw autohide block */ + panel_window_thaw_autohide (window); - /* queue an autohide when needed */ - if (window->autohide_block == 0 && window->autohide_status != DISABLED) - panel_window_autohide_queue (window, POPDOWN_QUEUED); + /* destroy the menu */ + g_object_unref (G_OBJECT (menu)); } -gint -panel_window_get_background_alpha (PanelWindow *window) +static void +panel_window_menu_popup (PanelWindow *window) { - panel_return_val_if_fail (PANEL_IS_WINDOW (window), 100); + GtkWidget *menu; + GtkWidget *item; + GtkWidget *image; + + panel_return_if_fail (PANEL_IS_WINDOW (window)); - return rint (window->background_alpha * 100.00); + /* 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_window_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_window_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_window_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 ()); } + static void -panel_window_set_plugin_background_alpha (GtkWidget *widget, - gpointer user_data) +panel_window_set_plugin_active_panel (GtkWidget *widget, + gpointer user_data) { panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (widget)); - panel_return_if_fail (PANEL_IS_WINDOW (user_data)); - /* we only have to send the alpha to external plugins */ if (PANEL_IS_PLUGIN_EXTERNAL (widget)) - panel_plugin_external_set_background_alpha (PANEL_PLUGIN_EXTERNAL (widget), panel_window_get_background_alpha (PANEL_WINDOW (user_data))); + panel_plugin_external_set_active_panel (PANEL_PLUGIN_EXTERNAL (widget), + !!GPOINTER_TO_UINT (user_data)); } -void -panel_window_set_background_alpha (PanelWindow *window, - gint alpha) +static void +panel_window_set_plugin_background_alpha (GtkWidget *widget, + gpointer user_data) { - gdouble value; - GtkWidget *itembar; - - panel_return_if_fail (PANEL_IS_WINDOW (window)); - panel_return_if_fail (alpha >= 0 && alpha <= 100); - - value = CLAMP (alpha, 0, 100) / 100.00; - - if (G_LIKELY (window->background_alpha != value)) - { - /* set new alpha value */ - window->background_alpha = value; - - /* redraw the window */ - gtk_widget_queue_draw (GTK_WIDGET (window)); - - /* get the itembar */ - itembar = gtk_bin_get_child (GTK_BIN (window)); + panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (widget)); - /* walk the plugins */ - gtk_container_foreach (GTK_CONTAINER (itembar), panel_window_set_plugin_background_alpha, window); - } + /* we only have to send the alpha to external plugins */ + if (PANEL_IS_PLUGIN_EXTERNAL (widget)) + panel_plugin_external_set_background_alpha (PANEL_PLUGIN_EXTERNAL (widget), + GPOINTER_TO_UINT (user_data)); } -gint -panel_window_get_enter_opacity (PanelWindow *window) +static void +panel_window_set_plugin_size (GtkWidget *widget, + gpointer user_data) { - panel_return_val_if_fail (PANEL_IS_WINDOW (window), 100); + panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (widget)); - return rint (window->enter_opacity * 100.00); + /* set the new plugin size */ + xfce_panel_plugin_provider_set_size (XFCE_PANEL_PLUGIN_PROVIDER (widget), + GPOINTER_TO_INT (user_data)); } -void -panel_window_set_enter_opacity (PanelWindow *window, - gint opacity) +static void +panel_window_set_plugin_orientation (GtkWidget *widget, + gpointer user_data) { - gdouble value; - - panel_return_if_fail (PANEL_IS_WINDOW (window)); - panel_return_if_fail (opacity >= 0 && opacity <= 100); - - value = CLAMP (opacity, 0, 100) / 100.00; + panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (widget)); - if (G_LIKELY (window->enter_opacity != value)) - { - /* set new opacity */ - window->enter_opacity = value; - } + /* set the new plugin orientation */ + xfce_panel_plugin_provider_set_orientation (XFCE_PANEL_PLUGIN_PROVIDER (widget), + GPOINTER_TO_INT (user_data)); } -gint -panel_window_get_leave_opacity (PanelWindow *window) +gboolean +panel_window_is_composited (PanelWindow *window) { - panel_return_val_if_fail (PANEL_IS_WINDOW (window), 100); + panel_return_val_if_fail (PANEL_IS_WINDOW (window), FALSE); - return rint (window->leave_opacity * 100.00); + return window->is_composited; } void -panel_window_set_leave_opacity (PanelWindow *window, - gint opacity) +panel_window_set_active_panel (PanelWindow *window, + gboolean active) { - gdouble value; - panel_return_if_fail (PANEL_IS_WINDOW (window)); - panel_return_if_fail (opacity >= 0 && opacity <= 100); - value = CLAMP (opacity, 0, 100) / 100.00; - - if (window->leave_opacity != value) + if (G_UNLIKELY (window->is_active_panel != active)) { /* set new value */ - window->leave_opacity = value; + window->is_active_panel = !!active; - /* update the panel window opacity */ - _window_set_opacity (GTK_WINDOW (window), value); + /* queue a redraw */ + gtk_widget_queue_draw (GTK_WIDGET (window)); - /* set the autohide window opacity if created */ - if (window->autohide_window) - _window_set_opacity (GTK_WINDOW (window->autohide_window), value); + /* poke all the plugins */ + gtk_container_foreach (GTK_CONTAINER (gtk_bin_get_child (GTK_BIN (window))), + panel_window_set_plugin_active_panel, + GUINT_TO_POINTER (active)); } } -gboolean -panel_window_get_span_monitors (PanelWindow *window) +void +panel_window_freeze_autohide (PanelWindow *window) { - panel_return_val_if_fail (PANEL_IS_WINDOW (window), FALSE); + panel_return_if_fail (PANEL_IS_WINDOW (window)); + panel_return_if_fail (window->autohide_block >= 0); - return window->span_monitors; + /* increase autohide block counter */ + window->autohide_block++; + + /* block autohide */ + if (window->autohide_block == 1 && window->autohide_status != DISABLED) + panel_window_autohide_queue (window, BLOCKED); } void -panel_window_set_span_monitors (PanelWindow *window, - gboolean span_monitors) +panel_window_thaw_autohide (PanelWindow *window) { panel_return_if_fail (PANEL_IS_WINDOW (window)); + panel_return_if_fail (window->autohide_block > 0); - if (window->span_monitors != span_monitors) - { - /* store new value */ - window->span_monitors = !!span_monitors; - - /* update the working area */ - panel_window_working_area (window, -1, -1, &window->working_area); + /* decrease autohide block counter */ + window->autohide_block--; - /* resize the panel */ - gtk_widget_queue_resize (GTK_WIDGET (window)); - } + /* queue an autohide when needed */ + if (window->autohide_block == 0 && window->autohide_status != DISABLED) + panel_window_autohide_queue (window, POPDOWN_QUEUED); } diff --git a/panel/panel-window.h b/panel/panel-window.h index 1d05a22e..b39e2f65 100644 --- a/panel/panel-window.h +++ b/panel/panel-window.h @@ -82,63 +82,14 @@ enum _PanelWindowBorders GType panel_window_get_type (void) G_GNUC_CONST; -GtkWidget *panel_window_new (void); - gboolean panel_window_is_composited (PanelWindow *window); void panel_window_set_active_panel (PanelWindow *window, gboolean selected); -PanelWindowSnapEdge panel_window_get_snap_edge (PanelWindow *window); -void panel_window_set_snap_edge (PanelWindow *window, - PanelWindowSnapEdge snap_edge); - -gboolean panel_window_get_locked (PanelWindow *window); -void panel_window_set_locked (PanelWindow *window, - gboolean locked); - -GtkOrientation panel_window_get_orientation (PanelWindow *window); -void panel_window_set_orientation (PanelWindow *window, - GtkOrientation orientation); - -gint panel_window_get_size (PanelWindow *window); -void panel_window_set_size (PanelWindow *window, - gint size); - -gint panel_window_get_length (PanelWindow *window); -void panel_window_set_length (PanelWindow *window, - gint percentage); - -gint panel_window_get_xoffset (PanelWindow *window); -void panel_window_set_xoffset (PanelWindow *window, - gint xoffset); - -gint panel_window_get_yoffset (PanelWindow *window); -void panel_window_set_yoffset (PanelWindow *window, - gint yoffset); - -gboolean panel_window_get_autohide (PanelWindow *window); -void panel_window_set_autohide (PanelWindow *window, - gboolean autohide); - void panel_window_freeze_autohide (PanelWindow *window); -void panel_window_thaw_autohide (PanelWindow *window); - -gint panel_window_get_background_alpha (PanelWindow *window); -void panel_window_set_background_alpha (PanelWindow *window, - gint alpha); -gint panel_window_get_enter_opacity (PanelWindow *window); -void panel_window_set_enter_opacity (PanelWindow *window, - gint opacity); - -gint panel_window_get_leave_opacity (PanelWindow *window); -void panel_window_set_leave_opacity (PanelWindow *window, - gint opacity); - -gboolean panel_window_get_span_monitors (PanelWindow *window); -void panel_window_set_span_monitors (PanelWindow *window, - gboolean span_monitors); +void panel_window_thaw_autohide (PanelWindow *window); G_END_DECLS diff --git a/plugins/launcher/Makefile.am b/plugins/launcher/Makefile.am index 475653e5..a8e75c10 100644 --- a/plugins/launcher/Makefile.am +++ b/plugins/launcher/Makefile.am @@ -27,6 +27,7 @@ liblauncher_la_CFLAGS = \ $(LIBXFCE4UTIL_CFLAGS) \ $(LIBXFCE4UI_CFLAGS) \ $(EXO_CFLAGS) \ + $(XFCONF_CFLAGS) \ $(LIBSTARTUP_NOTIFICATION_CFLAGS) \ $(PLATFORM_CFLAGS) @@ -42,6 +43,7 @@ liblauncher_la_LIBADD = \ $(LIBXFCE4UTIL_LIBS) \ $(LIBXFCE4UI_LIBS) \ $(EXO_LIBS) \ + $(XFCONF_LIBS) \ $(LIBSTARTUP_NOTIFICATION_LIBS) liblauncher_la_DEPENDENCIES = \ diff --git a/plugins/launcher/launcher-dialog.c b/plugins/launcher/launcher-dialog.c index 7f17c414..494f51ba 100644 --- a/plugins/launcher/launcher-dialog.c +++ b/plugins/launcher/launcher-dialog.c @@ -31,18 +31,11 @@ static void launcher_dialog_add_button_clicked (GtkWidget *button, GtkWidget *menu) { - gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, 1, + gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, 1, gtk_get_current_event_time()); } -static void -launcher_dialog_builder_died (gpointer user_data, GObject *where_object_was) -{ - g_message ("builder destroyed"); -} - - void launcher_dialog_show (LauncherPlugin *plugin) @@ -50,22 +43,41 @@ launcher_dialog_show (LauncherPlugin *plugin) GtkBuilder *builder; GObject *dialog; GObject *object, *menu; - + panel_return_if_fail (XFCE_IS_LAUNCHER_PLUGIN (plugin)); - + builder = gtk_builder_new (); - g_object_weak_ref (G_OBJECT (builder), launcher_dialog_builder_died, NULL); if (gtk_builder_add_from_string (builder, launcher_dialog_glade, launcher_dialog_glade_length, NULL)) { dialog = gtk_builder_get_object (builder, "dialog"); g_object_weak_ref (G_OBJECT (dialog), (GWeakNotify) g_object_unref, builder); - gtk_widget_show (GTK_WIDGET (dialog)); - + object = gtk_builder_get_object (builder, "close-button"); g_signal_connect_swapped (G_OBJECT (object), "clicked", G_CALLBACK (gtk_widget_destroy), dialog); - + object = gtk_builder_get_object (builder, "entry-add"); menu = gtk_builder_get_object (builder, "add-menu"); g_signal_connect (G_OBJECT (object), "clicked", G_CALLBACK (launcher_dialog_add_button_clicked), GTK_MENU (menu)); + + /* connect binding to the advanced properties */ + object = gtk_builder_get_object (builder, "disable-tooltips"); + xfconf_g_property_bind (plugin->channel, "/disable-tooltips", G_TYPE_BOOLEAN, object, "active"); + + object = gtk_builder_get_object (builder, "show-labels"); + xfconf_g_property_bind (plugin->channel, "/show-labels", G_TYPE_BOOLEAN, object, "active"); + + object = gtk_builder_get_object (builder, "move-first"); + xfconf_g_property_bind (plugin->channel, "/move-first", G_TYPE_BOOLEAN, object, "active"); + + object = gtk_builder_get_object (builder, "arrow-position"); + xfconf_g_property_bind (plugin->channel, "/arrow-position", G_TYPE_UINT, object, "active"); + + /* TODO remove when implemented by glade */ + GtkCellRenderer *cell1 = gtk_cell_renderer_text_new (); + object = gtk_builder_get_object (builder, "arrow-position"); + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (object), cell1, TRUE); + gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (object), cell1, "text", 0, NULL); + + gtk_widget_show (GTK_WIDGET (dialog)); } } diff --git a/plugins/launcher/launcher-dialog.glade b/plugins/launcher/launcher-dialog.glade index 879a224f..c3ef959b 100644 --- a/plugins/launcher/launcher-dialog.glade +++ b/plugins/launcher/launcher-dialog.glade @@ -1,7 +1,8 @@ <?xml version="1.0"?> <interface> - <!--interface-requires gtk+ 2.12--> - <!--interface-requires xfce4 0.0--> + <requires lib="gtk+" version="2.14"/> + <!-- interface-requires xfce4 0.0 --> + <!-- interface-naming-policy toplevel-contextual --> <object class="XfceTitledDialog" id="dialog"> <property name="title" translatable="yes">Launcher Properties</property> <property name="window_position">GTK_WIN_POS_CENTER</property> @@ -283,7 +284,7 @@ </packing> </child> <child> - <object class="GtkButton" id="entry-command-select"> + <object class="GtkButton" id="command-select"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> @@ -319,7 +320,7 @@ </packing> </child> <child> - <object class="GtkCheckButton" id="entry-run-in-terminal"> + <object class="GtkCheckButton" id="entry-terminal"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="label" translatable="yes">Run in _terminal</property> @@ -403,7 +404,7 @@ <property name="border_width">6</property> <property name="spacing">6</property> <child> - <object class="GtkCheckButton" id="adv-disable-tooltips"> + <object class="GtkCheckButton" id="disable-tooltips"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="label" translatable="yes">Disable t_ooltips</property> @@ -416,7 +417,7 @@ </packing> </child> <child> - <object class="GtkCheckButton" id="adv-show-labels"> + <object class="GtkCheckButton" id="show-labels"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="label" translatable="yes">Show _labels instead of icons</property> @@ -429,7 +430,7 @@ </packing> </child> <child> - <object class="GtkCheckButton" id="adv-show-last-used"> + <object class="GtkCheckButton" id="move-first"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="label" translatable="yes">Show last _used entry in panel</property> @@ -450,7 +451,7 @@ <property name="visible">True</property> <property name="label" translatable="yes">_Arrow button position:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">adv-arrow-position</property> + <property name="mnemonic_widget">arrow-position</property> </object> <packing> <property name="expand">False</property> @@ -458,8 +459,9 @@ </packing> </child> <child> - <object class="GtkComboBox" id="adv-arrow-position"> + <object class="GtkComboBox" id="arrow-position"> <property name="visible">True</property> + <property name="model">arrow-position-store</property> <property name="button_sensitivity">GTK_SENSITIVITY_ON</property> </object> <packing> @@ -520,19 +522,30 @@ </object> </child> </object> - <object class="GtkMenu" id="add-menu"> - <property name="visible">True</property> - <child> - <object class="GtkMenuItem" id="add-normal"> - <property name="visible">True</property> - <property name="label" translatable="yes">Normal Entry</property> - </object> - </child> - <child> - <object class="GtkMenuItem" id="add-advanced"> - <property name="visible">True</property> - <property name="label" translatable="yes">Advanced Entry</property> - </object> - </child> + <object class="GtkListStore" id="arrow-position-store"> + <columns> + <!-- column-name title --> + <column type="gchararray"/> + </columns> + <data> + <row> + <col id="0" translatable="yes">Default</col> + </row> + <row> + <col id="0" translatable="yes">Left</col> + </row> + <row> + <col id="0" translatable="yes">Right</col> + </row> + <row> + <col id="0" translatable="yes">Top</col> + </row> + <row> + <col id="0" translatable="yes">Bottom</col> + </row> + <row> + <col id="0" translatable="yes">Inside Button</col> + </row> + </data> </object> </interface> diff --git a/plugins/launcher/launcher.c b/plugins/launcher/launcher.c index 7d738900..a7ae403b 100644 --- a/plugins/launcher/launcher.c +++ b/plugins/launcher/launcher.c @@ -19,6 +19,13 @@ #include <config.h> #endif +#ifdef HAVE_STRING_H +#include <string.h> +#endif +#ifdef HAVE_STDIO_H +#include <stdio.h> +#endif + #include <exo/exo.h> #include <libxfce4util/libxfce4util.h> #include <libxfce4ui/libxfce4ui.h> @@ -49,7 +56,6 @@ static void launcher_plugin_execute_from_clipboard (GdkScreen *screen, LauncherP static void launcher_plugin_icon_theme_changed (GtkIconTheme *icon_theme, LauncherPlugin *plugin); static void launcher_plugin_update_icon (LauncherPlugin *plugin); static void launcher_plugin_reorder_buttons (LauncherPlugin *plugin); -static inline gchar *launcher_plugin_read_entry (XfceRc *rc, const gchar *name); static gboolean launcher_plugin_read (LauncherPlugin *plugin); static void launcher_plugin_button_state_changed (GtkWidget *button_a, GtkStateType state, GtkWidget *button_b); static gboolean launcher_plugin_query_tooltip (GtkWidget *widget, gint x, gint y, gboolean keyboard_mode, GtkTooltip *tooltip, LauncherPluginEntry *entry); @@ -97,7 +103,7 @@ launcher_plugin_class_init (LauncherPluginClass *klass) plugin_class->screen_position_changed = launcher_plugin_screen_position_changed; /* initialize the quark */ - launcher_plugin_quark = g_quark_from_static_string ("xfce-test-plugin"); + launcher_plugin_quark = g_quark_from_static_string ("xfce-launcher-plugin"); } @@ -111,9 +117,8 @@ launcher_plugin_init (LauncherPlugin *plugin) plugin->entries = NULL; plugin->menu = NULL; plugin->popup_timeout_id = 0; - plugin->move_clicked_to_button = FALSE; + plugin->move_first = FALSE; plugin->disable_tooltips = FALSE; - plugin->menu_reversed_order = FALSE; plugin->show_labels = FALSE; /* TODO */ plugin->arrow_position = ARROW_POS_DEFAULT; @@ -169,6 +174,86 @@ launcher_plugin_init (LauncherPlugin *plugin) } +static void +launcher_plugin_property_changed (XfconfChannel *channel, + const gchar *property_name, + const GValue *value, + LauncherPlugin *plugin) +{ + guint nth; + gchar *property; + LauncherPluginEntry *entry; + + panel_return_if_fail (XFCONF_IS_CHANNEL (channel)); + panel_return_if_fail (XFCE_IS_LAUNCHER_PLUGIN (plugin)); + panel_return_if_fail (plugin->channel == channel); + + if (strcmp (property_name, "/disable-tooltips") == 0) + { + plugin->disable_tooltips = g_value_get_boolean (value); + } + else if (strcmp (property_name, "/move-first") == 0) + { + plugin->move_first = g_value_get_boolean (value); + } + else if (strcmp (property_name, "/show-labels") == 0) + { + plugin->show_labels = g_value_get_boolean (value); + } + else if (strcmp (property_name, "/arrow-position") == 0) + { + plugin->arrow_position = CLAMP (g_value_get_uint (value), + ARROW_POS_DEFAULT, ARROW_POS_INSIDE_BUTTON); + } + else if (sscanf (property_name, "/entries/entry-%u/%a[a-z]", &nth, &property) == 2) + { + /* lookup the launcher entry */ + entry = g_list_nth_data (plugin->entries, nth); + if (G_LIKELY (entry)) + { + if (strcmp (property, "name") == 0) + { + g_free (entry->name); + entry->name = g_value_dup_string (value); + + if (nth > 0 || plugin->show_labels) + launcher_plugin_rebuild (plugin, FALSE); + } + else if (strcmp (property, "comment") == 0) + { + g_free (entry->comment); + entry->comment = g_value_dup_string (value); + } + else if (strcmp (property, "icon") == 0) + { + g_free (entry->icon); + entry->icon = g_value_dup_string (value); + + launcher_plugin_rebuild (plugin, (nth == 0)); + } + else if (strcmp (property, "command") == 0) + { + g_free (entry->exec); + entry->exec = g_value_dup_string (value); + } + else if (strcmp (property, "working-directory") == 0) + { + g_free (entry->path); + entry->path = g_value_dup_string (value); + } + else if (strcmp (property, "terminal") == 0) + entry->terminal = g_value_get_boolean (value); +#ifdef HAVE_LIBSTARTUP_NOTIFICATION + else if (strcmp (property, "startup-notify") == 0) + entry->startup_notify = g_value_get_boolean (value); +#endif + } + + g_free (property); + } +} + + static void launcher_plugin_construct (XfcePanelPlugin *panel_plugin) @@ -176,10 +261,13 @@ launcher_plugin_construct (XfcePanelPlugin *panel_plugin) LauncherPlugin *plugin = XFCE_LAUNCHER_PLUGIN (panel_plugin); const gchar * const *filenames; guint i; - + + /* open the xfconf channel */ + plugin->channel = xfce_panel_plugin_xfconf_channel_new (panel_plugin); + g_signal_connect (G_OBJECT (plugin->channel), "property-changed", G_CALLBACK (launcher_plugin_property_changed), plugin); + /* show the configure menu item */ xfce_panel_plugin_menu_show_configure (XFCE_PANEL_PLUGIN (plugin)); - /* read the plugin configuration */ if (launcher_plugin_read (plugin) == FALSE) @@ -209,7 +297,7 @@ launcher_plugin_construct (XfcePanelPlugin *panel_plugin) /* change the visiblity of the arrow button */ launcher_plugin_menu_destroy (plugin); - + /* update the icon */ launcher_plugin_update_icon (plugin); } @@ -221,6 +309,9 @@ launcher_plugin_free_data (XfcePanelPlugin *panel_plugin) { LauncherPlugin *plugin = XFCE_LAUNCHER_PLUGIN (panel_plugin); + /* release the xfconf channel */ + g_object_unref (G_OBJECT (plugin->channel)); + /* stop popup timeout */ if (G_UNLIKELY (plugin->popup_timeout_id)) g_source_remove (plugin->popup_timeout_id); @@ -306,72 +397,63 @@ launcher_plugin_size_changed (XfcePanelPlugin *panel_plugin, static void launcher_plugin_save (XfcePanelPlugin *panel_plugin) { - LauncherPlugin *plugin = XFCE_LAUNCHER_PLUGIN (panel_plugin); - gchar *file; - gchar **groups; - gchar group[10]; - XfceRc *rc; - GList *li; - guint i; - LauncherPluginEntry *entry; - - /* get rc file name, create it if needed */ - file = xfce_panel_plugin_save_location (panel_plugin, TRUE); - if (G_LIKELY (file)) + LauncherPlugin *plugin = XFCE_LAUNCHER_PLUGIN (panel_plugin); + gchar buf[100]; + GList *li; + guint i; + LauncherPluginEntry *entry; + + /* save the global settings */ + xfconf_channel_set_bool (plugin->channel, "/move-first", plugin->move_first); + xfconf_channel_set_bool (plugin->channel, "/disable-tooltips", plugin->disable_tooltips); + xfconf_channel_set_bool (plugin->channel, "/show-labels", plugin->show_labels); + xfconf_channel_set_uint (plugin->channel, "/arrow-position", plugin->arrow_position); + + for (li = plugin->entries, i = 0; li != NULL; li = li->next, i++) { - /* open the config file, writable */ - rc = xfce_rc_simple_open (file, FALSE); - g_free (file); + entry = li->data; - if (G_LIKELY (rc)) - { - /* delete all the existing groups */ - groups = xfce_rc_get_groups (rc); - if (G_LIKELY (groups)) - { - for (i = 0; groups[i] != NULL; i++) - xfce_rc_delete_group (rc, groups[i], TRUE); - g_strfreev (groups); - } + g_snprintf (buf, sizeof (buf), "/entries/entry-%d/name", i); + if (entry->name) + xfconf_channel_set_string (plugin->channel, buf, entry->name); + else + xfconf_channel_reset_property (plugin->channel, buf, FALSE); - /* save global launcher settings */ - xfce_rc_set_group (rc, "Global"); - xfce_rc_write_bool_entry (rc, "MoveFirst", plugin->move_clicked_to_button); - xfce_rc_write_bool_entry (rc, "DisableTooltips", plugin->disable_tooltips); - xfce_rc_write_bool_entry (rc, "ShowLabels", plugin->show_labels); - xfce_rc_write_int_entry (rc, "ArrowPosition", plugin->arrow_position); + g_snprintf (buf, sizeof (buf), "/entries/entry-%d/comment", i); + if (entry->comment) + xfconf_channel_set_string (plugin->channel, buf, entry->comment); + else + xfconf_channel_reset_property (plugin->channel, buf, FALSE); + + g_snprintf (buf, sizeof (buf), "/entries/entry-%d/icon", i); + if (entry->icon) + xfconf_channel_set_string (plugin->channel, buf, entry->icon); + else + xfconf_channel_reset_property (plugin->channel, buf, FALSE); + + g_snprintf (buf, sizeof (buf), "/entries/entry-%d/command", i); + if (entry->exec) + xfconf_channel_set_string (plugin->channel, buf, entry->exec); + else + xfconf_channel_reset_property (plugin->channel, buf, FALSE); + + g_snprintf (buf, sizeof (buf), "/entries/entry-%d/working-directory", i); + if (entry->path) + xfconf_channel_set_string (plugin->channel, buf, entry->path); + else + xfconf_channel_reset_property (plugin->channel, buf, FALSE); + + g_snprintf (buf, sizeof (buf), "/entries/entry-%d/terminal", i); + xfconf_channel_set_bool (plugin->channel, buf, entry->terminal); - /* save all the entries */ - for (li = plugin->entries, i = 0; li != NULL; li = li->next, i++) - { - entry = li->data; - - /* set group */ - g_snprintf (group, sizeof (group), "Entry %d", i); - xfce_rc_set_group (rc, group); - - /* write entry settings */ - if (G_LIKELY (entry->name)) - xfce_rc_write_entry (rc, "Name", entry->name); - if (G_LIKELY (entry->comment)) - xfce_rc_write_entry (rc, "Comment", entry->comment); - if (G_LIKELY (entry->icon)) - xfce_rc_write_entry (rc, "Icon", entry->icon); - if (G_LIKELY (entry->exec)) - xfce_rc_write_entry (rc, "Exec", entry->exec); - if (G_LIKELY (entry->path)) - xfce_rc_write_entry (rc, "Path", entry->path); - - xfce_rc_write_bool_entry (rc, "Terminal", entry->terminal); #ifdef HAVE_LIBSTARTUP_NOTIFICATION - xfce_rc_write_bool_entry (rc, "StartupNotify", entry->startup_notify); + g_snprintf (buf, sizeof (buf), "/entries/entry-%d/startup-notify", i); + xfconf_channel_set_bool (plugin->channel, buf, entry->startup_notify); #endif - } - - /* close the rc file */ - xfce_rc_close (rc); - } } + + /* store the number of launchers */ + xfconf_channel_set_uint (plugin->channel, "/entries", i); } @@ -397,6 +479,9 @@ launcher_plugin_screen_position_changed (XfcePanelPlugin *panel_plugin, /* set the arrow direction */ xfce_arrow_button_set_arrow_type (XFCE_ARROW_BUTTON (plugin->arrow_button), arrow_type); + + /* destroy the menu to update the popup menu order */ + launcher_plugin_menu_destroy (plugin); } @@ -422,7 +507,7 @@ launcher_plugin_execute_parse_command (LauncherPluginEntry *entry, const gchar *p; gchar *tmp; GSList *li; - + /* parse the execute command */ for (p = entry->exec; *p != '\0'; ++p) { @@ -444,11 +529,11 @@ launcher_plugin_execute_parse_command (LauncherPluginEntry *entry, { if (G_LIKELY (li != file_list)) g_string_append_c (cmd, ' '); - + launcher_plugin_execute_string_append_quoted (cmd, (gchar *) li->data); } break; - + /* directory containing the file that would be passed in a %f field */ case 'd': if (file_list != NULL) @@ -461,7 +546,7 @@ launcher_plugin_execute_parse_command (LauncherPluginEntry *entry, } } break; - + /* list of directories containing the files that would be passed in to a %F field */ case 'D': for (li = file_list; li != NULL; li = li->next) @@ -477,7 +562,7 @@ launcher_plugin_execute_parse_command (LauncherPluginEntry *entry, } } break; - + /* a single filename (without path) */ case 'n': if (file_list != NULL) @@ -506,7 +591,7 @@ launcher_plugin_execute_parse_command (LauncherPluginEntry *entry, } } break; - + /* the icon name used in the panel */ case 'i': if (G_LIKELY (entry->icon != NULL)) @@ -515,13 +600,13 @@ launcher_plugin_execute_parse_command (LauncherPluginEntry *entry, launcher_plugin_execute_string_append_quoted (cmd, entry->icon); } break; - + /* the 'translated' name of the application */ case 'c': if (G_LIKELY (entry->name != NULL)) launcher_plugin_execute_string_append_quoted (cmd, entry->name); break; - + /* percentage character */ case '%': g_string_append_c (cmd, '%'); @@ -557,11 +642,11 @@ launcher_plugin_execute (GdkScreen *screen, #else startup_notify = FALSE; #endif - + /* leave when no command has been set */ if (G_UNLIKELY (entry->exec == NULL || *entry->exec == '\0')) return; - + /* make sure we've set a screen */ if (G_UNLIKELY (screen == NULL)) screen = gdk_screen_get_default (); @@ -572,13 +657,13 @@ launcher_plugin_execute (GdkScreen *screen, { /* fake an empty list */ fake.next = NULL; - + /* run a new instance for each file in the list */ for (li = file_list; li != NULL && succeed; li = li->next) { /* point to data */ fake.data = li->data; - + /* parse the command and execute the command */ command_line = launcher_plugin_execute_parse_command (entry, &fake); succeed = xfce_execute_on_screen (screen, command_line, entry->terminal, startup_notify, &error); @@ -592,7 +677,7 @@ launcher_plugin_execute (GdkScreen *screen, succeed = xfce_execute_on_screen (screen, command_line, entry->terminal, startup_notify, &error); g_free (command_line); } - + if (G_UNLIKELY (succeed == FALSE)) { g_message ("Failed to execute: %s", error->message); @@ -610,12 +695,12 @@ launcher_plugin_execute_from_clipboard (GdkScreen *screen, gchar *text = NULL; GSList *filenames; GtkSelectionData selection_data; - + /* get the primary clipboard text */ clipboard = gtk_clipboard_get (GDK_SELECTION_PRIMARY); if (G_LIKELY (clipboard)) text = gtk_clipboard_wait_for_text (clipboard); - + /* try other clipboard if this one was empty */ if (text == NULL) { @@ -624,13 +709,13 @@ launcher_plugin_execute_from_clipboard (GdkScreen *screen, if (G_LIKELY (clipboard)) text = gtk_clipboard_wait_for_text (clipboard); } - + if (G_LIKELY (text)) { /* create some fake selection data */ selection_data.data = (guchar *) text; selection_data.length = 1; - + /* parse the filelist, this way we can handle 'copied' file from thunar */ filenames = launcher_plugin_filenames_from_selection_data (&selection_data); if (G_LIKELY (filenames)) @@ -750,84 +835,59 @@ launcher_plugin_reorder_buttons (LauncherPlugin *plugin) -static inline gchar * -launcher_plugin_read_entry (XfceRc *rc, - const gchar *name) +static gboolean +launcher_plugin_read (LauncherPlugin *plugin) { - const gchar *temp; - gchar *value = NULL; + guint i, n_entries; + gchar buf[100]; + LauncherPluginEntry *entry; - temp = xfce_rc_read_entry (rc, name, NULL); - if (G_LIKELY (temp != NULL && *temp != '\0')) - value = g_strdup (temp); + panel_return_val_if_fail (XFCE_IS_LAUNCHER_PLUGIN (plugin), FALSE); + panel_return_val_if_fail (XFCONF_IS_CHANNEL (plugin->channel), FALSE); + + /* read global settings */ + plugin->move_first = xfconf_channel_get_bool (plugin->channel, "/move-first", FALSE); + plugin->disable_tooltips = xfconf_channel_get_bool (plugin->channel, "/disable-tooltips", FALSE); + plugin->show_labels = xfconf_channel_get_bool (plugin->channel, "/show-labels", FALSE); + plugin->arrow_position = CLAMP (xfconf_channel_get_uint (plugin->channel, "/arrow-position", ARROW_POS_DEFAULT), + ARROW_POS_DEFAULT, ARROW_POS_INSIDE_BUTTON); + + /* number of launcher entries */ + n_entries = xfconf_channel_get_uint (plugin->channel, "/entries", 0); + for (i = 0; i < n_entries; i++) + { + entry = g_slice_new (LauncherPluginEntry); - return value; -} + g_snprintf (buf, sizeof (buf), "/entries/entry-%d/name", i); + entry->name = xfconf_channel_get_string (plugin->channel, buf, NULL); + g_snprintf (buf, sizeof (buf), "/entries/entry-%d/comment", i); + entry->comment = xfconf_channel_get_string (plugin->channel, buf, NULL); + g_snprintf (buf, sizeof (buf), "/entries/entry-%d/icon", i); + entry->icon = xfconf_channel_get_string (plugin->channel, buf, NULL); -static gboolean -launcher_plugin_read (LauncherPlugin *plugin) -{ - gchar *file; - XfceRc *rc; - guint i; - gchar group[10]; - LauncherPluginEntry *entry; + g_snprintf (buf, sizeof (buf), "/entries/entry-%d/command", i); + entry->exec = xfconf_channel_get_string (plugin->channel, buf, NULL); - panel_return_val_if_fail (XFCE_IS_LAUNCHER_PLUGIN (plugin), FALSE); + g_snprintf (buf, sizeof (buf), "/entries/entry-%d/working-directory", i); + entry->path = xfconf_channel_get_string (plugin->channel, buf, NULL); - /* get rc file name, create it if needed */ - file = xfce_panel_plugin_lookup_rc_file (XFCE_PANEL_PLUGIN (plugin)); - if (G_LIKELY (file)) - { - /* open config file, read-only, and cleanup */ - rc = xfce_rc_simple_open (file, TRUE); - g_free (file); + g_snprintf (buf, sizeof (buf), "/entries/entry-%d/terminal", i); + entry->terminal = xfconf_channel_get_bool (plugin->channel, buf, FALSE); - if (G_LIKELY (rc)) - { - /* read the global settings */ - xfce_rc_set_group (rc, "Global"); - plugin->move_clicked_to_button = xfce_rc_read_bool_entry (rc, "MoveFirst", FALSE); - plugin->disable_tooltips = xfce_rc_read_bool_entry (rc, "DisableTooltips", FALSE); - plugin->show_labels = xfce_rc_read_bool_entry (rc, "ShowLabels", FALSE); - plugin->arrow_position = CLAMP (xfce_rc_read_int_entry (rc, "ArrowPosition", ARROW_POS_DEFAULT), - ARROW_POS_DEFAULT, ARROW_POS_INSIDE_BUTTON); - - /* read all the entries */ - for (i = 0; i < 100 /* arbitrary */; i++) - { - /* set group, leave if we reached the last entry */ - g_snprintf (group, sizeof (group), "Entry %d", i); - if (xfce_rc_has_group (rc, group) == FALSE) - break; - xfce_rc_set_group (rc, group); - - /* create entry */ - entry = g_slice_new (LauncherPluginEntry); - entry->name = launcher_plugin_read_entry (rc, "Name"); - entry->comment = launcher_plugin_read_entry (rc, "Comment"); - entry->icon = launcher_plugin_read_entry (rc, "Icon"); - entry->exec = launcher_plugin_read_entry (rc, "Exec"); - entry->path = launcher_plugin_read_entry (rc, "Path"); - entry->terminal = xfce_rc_read_bool_entry (rc, "Terminal", FALSE); #ifdef HAVE_LIBSTARTUP_NOTIFICATION - entry->startup_notify = xfce_rc_read_bool_entry (rc, "StartupNotify", FALSE); + g_snprintf (buf, sizeof (buf), "/entries/entry-%d/startup-notify", i); + entry->startup_notify = xfconf_channel_get_bool (plugin->channel, buf, FALSE); #endif - /* prepend to the list */ - plugin->entries = g_list_prepend (plugin->entries, entry); - } - - /* close the rc file */ - xfce_rc_close (rc); - - /* reverse the order of the list */ - plugin->entries = g_list_reverse (plugin->entries); - } + /* prepend the entry */ + plugin->entries = g_list_prepend (plugin->entries, entry); } + /* reverse the order of the list */ + plugin->entries = g_list_reverse (plugin->entries); + return (plugin->entries != NULL); } @@ -1194,6 +1254,7 @@ launcher_plugin_menu_build (LauncherPlugin *plugin) GtkWidget *mi, *image; GdkScreen *screen; GdkPixbuf *pixbuf; + GtkArrowType arrow_type; panel_return_if_fail (XFCE_IS_LAUNCHER_PLUGIN (plugin)); panel_return_if_fail (plugin->menu == NULL); @@ -1204,6 +1265,9 @@ launcher_plugin_menu_build (LauncherPlugin *plugin) gtk_menu_set_screen (GTK_MENU (plugin->menu), screen); g_signal_connect (G_OBJECT (plugin->menu), "deactivate", G_CALLBACK (launcher_plugin_menu_deactivate), plugin); + /* get the arrow type from the button for the menu direction */ + arrow_type = xfce_arrow_button_get_arrow_type (XFCE_ARROW_BUTTON (plugin->arrow_button)); + /* walk through the entries */ for (li = plugin->entries, n = 0; li != NULL; li = li->next, n++) { @@ -1220,7 +1284,7 @@ launcher_plugin_menu_build (LauncherPlugin *plugin) gtk_widget_show (mi); /* depending on the menu position we append or prepend */ - if (plugin->menu_reversed_order) + if (arrow_type == GTK_ARROW_DOWN) gtk_menu_shell_append (GTK_MENU_SHELL (plugin->menu), mi); else gtk_menu_shell_prepend (GTK_MENU_SHELL (plugin->menu), mi); @@ -1273,7 +1337,7 @@ launcher_plugin_menu_item_released (GtkMenuItem *menu_item, launcher_plugin_execute_from_clipboard (screen, entry); /* move the item to the first position if enabled */ - if (G_UNLIKELY (plugin->move_clicked_to_button)) + if (G_UNLIKELY (plugin->move_first)) { /* remove the item to the first place */ plugin->entries = g_list_remove (plugin->entries, entry); @@ -1299,10 +1363,6 @@ launcher_plugin_entry_new_default (void) entry->name = g_strdup (_("New Item")); entry->icon = g_strdup ("applications-other"); - /* TODO remove after test */ - if (entry->comment) - g_critical ("while crearing the default entry, vars were not null"); - return entry; } diff --git a/plugins/launcher/launcher.h b/plugins/launcher/launcher.h index 4a86a19b..0029bbdf 100644 --- a/plugins/launcher/launcher.h +++ b/plugins/launcher/launcher.h @@ -19,6 +19,7 @@ #define __XFCE_LAUNCHER_PLUGIN_H__ #include <gtk/gtk.h> +#include <xfconf/xfconf.h> #include <libxfce4panel/libxfce4panel.h> G_BEGIN_DECLS @@ -61,8 +62,11 @@ struct _LauncherPlugin { XfcePanelPlugin __parent__; + /* xfconf channel */ + XfconfChannel *channel; + /* settings */ - guint move_clicked_to_button : 1; + guint move_first : 1; guint disable_tooltips : 1; guint show_labels : 1; LauncherPluginArrowPos arrow_position; @@ -82,9 +86,6 @@ struct _LauncherPlugin /* delayout menu popup */ guint popup_timeout_id; - - /* whether the menu appends in revered order */ - guint menu_reversed_order : 1; }; struct _LauncherPluginEntry diff --git a/plugins/test/xfce-test-plugin.c b/plugins/test/xfce-test-plugin.c index a358f4e2..09bd981c 100644 --- a/plugins/test/xfce-test-plugin.c +++ b/plugins/test/xfce-test-plugin.c @@ -51,7 +51,7 @@ xfce_test_plugin_class_init (XfceTestPluginClass *klass) gobject_class = G_OBJECT_CLASS (klass); gobject_class->finalize = xfce_test_plugin_finalize; - + plugin_class = XFCE_PANEL_PLUGIN_CLASS (klass); plugin_class->construct = xfce_test_plugin_construct; plugin_class->free_data = xfce_test_plugin_free_data; @@ -72,11 +72,11 @@ xfce_test_plugin_init (XfceTestPlugin *plugin) -static void +static void xfce_test_plugin_finalize (GObject *object) { g_message ("plugin %s finalized", xfce_panel_plugin_get_name (XFCE_PANEL_PLUGIN (object))); - + (*G_OBJECT_CLASS (xfce_test_plugin_parent_class)->finalize) (object); } diff --git a/wrapper/main.c b/wrapper/main.c index 0659b690..70dd7431 100644 --- a/wrapper/main.c +++ b/wrapper/main.c @@ -371,7 +371,8 @@ main (gint argc, gchar **argv) g_signal_connect (G_OBJECT (provider), "provider-signal", G_CALLBACK (dbus_gproxy_provider_signal), dbus_gproxy); /* connect dbus property change signal */ - dbus_g_proxy_connect_signal (dbus_gproxy, "PropertyChanged", G_CALLBACK (dbus_gproxy_provider_property_changed), provider, NULL); + dbus_g_proxy_connect_signal (dbus_gproxy, "PropertyChanged", G_CALLBACK (dbus_gproxy_provider_property_changed), + g_object_ref (provider), (GClosureNotify) g_object_unref); /* show the plugin */ gtk_container_add (GTK_CONTAINER (plug), GTK_WIDGET (provider)); |