Browse Source

Put some xfconf code in a macro to make things easier.

upstream/xfce4-panel-4.10.1
Nick Schermer 13 years ago
parent
commit
58f89a3cea
  1. 10
      common/panel-xfconf.c
  2. 20
      common/panel-xfconf.h
  3. 18
      plugins/actions/actions.c
  4. 4
      plugins/clock/Makefile.am
  5. 8
      plugins/clock/clock.c
  6. 7
      plugins/launcher/launcher.c
  7. 10
      plugins/pager/pager.c
  8. 18
      plugins/separator/separator.c
  9. 8
      plugins/systray/systray.c
  10. 16
      plugins/tasklist/tasklist.c
  11. 5
      plugins/windowmenu/windowmenu.c

10
common/panel-xfconf.c

@ -302,3 +302,13 @@ panel_properties_shared_hash_table (GHashTable *hash_table)
else
shared_hash_table = NULL;
}
void
panel_properties_shutdown (gpointer user_data,
GObject *where_the_object_was)
{
/* delay this a bit to avoid warnings */
g_idle_add ((GSourceFunc) xfconf_shutdown, NULL);
}

20
common/panel-xfconf.h

@ -22,6 +22,21 @@
#include <xfconf/xfconf.h>
#define PANEL_PROPERTIES_INIT(panel_plugin) do { \
GError *__err = NULL; \
if (G_LIKELY (xfconf_init (&__err))) \
{ \
g_object_weak_ref (G_OBJECT (panel_plugin), \
panel_properties_shutdown, NULL); \
} \
else \
{ \
g_critical ("Failed to initialize Xfconf: %s", __err->message); \
g_error_free (__err); \
} } while (0)
typedef struct _PanelProperty PanelProperty;
struct _PanelProperty
{
@ -29,6 +44,8 @@ struct _PanelProperty
GType type;
};
XfconfChannel *panel_properties_get_channel (void);
void panel_properties_bind (XfconfChannel *channel,
@ -41,4 +58,7 @@ void panel_properties_unbind (GObject *object);
void panel_properties_shared_hash_table (GHashTable *hash_table);
void panel_properties_shutdown (gpointer user_data,
GObject *where_the_object_was);
#endif /* !__PANEL_XFCONF_H__ */

18
plugins/actions/actions.c

@ -26,7 +26,6 @@
#include <libxfce4util/libxfce4util.h>
#include <libxfce4ui/libxfce4ui.h>
#include <common/panel-xfconf.h>
#include <xfconf/xfconf.h>
#include <exo/exo.h>
#include "actions.h"
@ -43,7 +42,6 @@ static void actions_plugin_set_property (GObject *objec
const GValue *value,
GParamSpec *pspec);
static void actions_plugin_construct (XfcePanelPlugin *panel_plugin);
static void actions_plugin_free_data (XfcePanelPlugin *panel_plugin);
static gboolean actions_plugin_size_changed (XfcePanelPlugin *panel_plugin,
gint size);
static void actions_plugin_configure_plugin (XfcePanelPlugin *panel_plugin);
@ -146,7 +144,6 @@ actions_plugin_class_init (ActionsPluginClass *klass)
plugin_class = XFCE_PANEL_PLUGIN_CLASS (klass);
plugin_class->construct = actions_plugin_construct;
plugin_class->free_data = actions_plugin_free_data;
plugin_class->size_changed = actions_plugin_size_changed;
plugin_class->configure_plugin = actions_plugin_configure_plugin;
plugin_class->orientation_changed = actions_plugin_orientation_changed;
@ -182,12 +179,12 @@ actions_plugin_init (ActionsPlugin *plugin)
plugin->first_action = ACTION_LOG_OUT_DIALOG;
plugin->second_action = ACTION_DISABLED;
/* initialize properties */
PANEL_PROPERTIES_INIT (plugin);
/* show the properties dialog */
xfce_panel_plugin_menu_show_configure (XFCE_PANEL_PLUGIN (plugin));
/* initialize xfconf */
xfconf_init (NULL);
plugin->box = xfce_hvbox_new (GTK_ORIENTATION_HORIZONTAL, TRUE, 0);
gtk_container_add (GTK_CONTAINER (plugin), plugin->box);
@ -322,15 +319,6 @@ actions_plugin_construct (XfcePanelPlugin *panel_plugin)
static void
actions_plugin_free_data (XfcePanelPlugin *panel_plugin)
{
/* shutdown xfconf */
xfconf_shutdown ();
}
static gboolean
actions_plugin_size_changed (XfcePanelPlugin *panel_plugin,
gint size)

4
plugins/clock/Makefile.am

@ -45,6 +45,7 @@ libclock_la_LDFLAGS = \
libclock_la_LIBADD = \
$(top_builddir)/libxfce4panel/libxfce4panel.la \
$(top_builddir)/common/libpanel-xfconf.la \
$(GTK_LIBS) \
$(CAIRO_LIBS) \
$(LIBXFCE4UTIL_LIBS) \
@ -52,7 +53,8 @@ libclock_la_LIBADD = \
$(XFCONF_LIBS)
libclock_la_DEPENDENCIES = \
$(top_builddir)/libxfce4panel/libxfce4panel.la
$(top_builddir)/libxfce4panel/libxfce4panel.la \
$(top_builddir)/common/libpanel-xfconf.la
#
# .desktop file

8
plugins/clock/clock.c

@ -30,6 +30,7 @@
#include <libxfce4panel/libxfce4panel.h>
#include <libxfce4ui/libxfce4ui.h>
#include <xfconf/xfconf.h>
#include <common/panel-xfconf.h>
#include "clock.h"
#include "clock-analog.h"
@ -161,8 +162,8 @@ clock_plugin_init (ClockPlugin *plugin)
plugin->tooltip_interval = 0;
plugin->clock_timeout_id = 0;
/* initialize xfconf */
xfconf_init (NULL);
/* initialize properties */
PANEL_PROPERTIES_INIT (plugin);
/* show configure */
xfce_panel_plugin_menu_show_configure (XFCE_PANEL_PLUGIN (plugin));
@ -260,9 +261,6 @@ clock_plugin_free_data (XfcePanelPlugin *panel_plugin)
/* free the tooltip string */
g_free (plugin->tooltip_format);
/* shutdown xfconf */
xfconf_shutdown ();
}

7
plugins/launcher/launcher.c

@ -246,8 +246,8 @@ launcher_plugin_init (LauncherPlugin *plugin)
plugin->menu_timeout_id = 0;
plugin->menu_icon_size = DEFAULT_MENU_ICON_SIZE;
/* initialize xfconf */
xfconf_init (NULL);
/* initialize properties */
PANEL_PROPERTIES_INIT (plugin);
/* show the configure menu item */
xfce_panel_plugin_menu_show_configure (XFCE_PANEL_PLUGIN (plugin));
@ -599,9 +599,6 @@ launcher_plugin_free_data (XfcePanelPlugin *panel_plugin)
/* destroy the menu and timeout */
launcher_plugin_menu_destroy (plugin);
/* shutdown xfconf */
xfconf_shutdown ();
/* free items */
g_slist_foreach (plugin->items, (GFunc) g_object_unref, NULL);
g_slist_free (plugin->items);

10
plugins/pager/pager.c

@ -27,7 +27,6 @@
#include <libxfce4util/libxfce4util.h>
#include <libxfce4ui/libxfce4ui.h>
#include <common/panel-xfconf.h>
#include <xfconf/xfconf.h>
#include <libwnck/libwnck.h>
#include <exo/exo.h>
@ -150,11 +149,11 @@ pager_plugin_init (PagerPlugin *plugin)
plugin->rows = 1;
plugin->wnck_pager = NULL;
/* initialize properties */
PANEL_PROPERTIES_INIT (plugin);
/* show the properties dialog */
xfce_panel_plugin_menu_show_configure (XFCE_PANEL_PLUGIN (plugin));
/* initialize xfconf */
xfconf_init (NULL);
}
@ -335,9 +334,6 @@ pager_plugin_free_data (XfcePanelPlugin *panel_plugin)
/* disconnect screen changed signal */
g_signal_handlers_disconnect_by_func (G_OBJECT (plugin),
pager_plugin_screen_changed, NULL);
/* shutdown xfconf */
xfconf_shutdown ();
}

18
plugins/separator/separator.c

@ -26,7 +26,6 @@
#include <libxfce4panel/libxfce4panel.h>
#include <libxfce4util/libxfce4util.h>
#include <common/panel-xfconf.h>
#include <xfconf/xfconf.h>
#include <exo/exo.h>
#include "separator.h"
@ -49,7 +48,6 @@ static void separator_plugin_set_property (GObject
static gboolean separator_plugin_expose_event (GtkWidget *widget,
GdkEventExpose *event);
static void separator_plugin_construct (XfcePanelPlugin *panel_plugin);
static void separator_plugin_free_data (XfcePanelPlugin *panel_plugin);
static gboolean separator_plugin_size_changed (XfcePanelPlugin *panel_plugin,
gint size);
static void separator_plugin_configure_plugin (XfcePanelPlugin *panel_plugin);
@ -111,7 +109,6 @@ separator_plugin_class_init (SeparatorPluginClass *klass)
plugin_class = XFCE_PANEL_PLUGIN_CLASS (klass);
plugin_class->construct = separator_plugin_construct;
plugin_class->free_data = separator_plugin_free_data;
plugin_class->size_changed = separator_plugin_size_changed;
plugin_class->configure_plugin = separator_plugin_configure_plugin;
plugin_class->orientation_changed = separator_plugin_orientation_changed;
@ -141,11 +138,11 @@ separator_plugin_init (SeparatorPlugin *plugin)
/* initialize */
plugin->style = SEPARATOR_PLUGIN_STYLE_SEPARATOR;
/* initialize properties */
PANEL_PROPERTIES_INIT (plugin);
/* show the properties dialog */
xfce_panel_plugin_menu_show_configure (XFCE_PANEL_PLUGIN (plugin));
/* initialize xfconf */
xfconf_init (NULL);
}
@ -291,15 +288,6 @@ separator_plugin_construct (XfcePanelPlugin *panel_plugin)
static void
separator_plugin_free_data (XfcePanelPlugin *panel_plugin)
{
/* shutdown xfconf */
xfconf_shutdown ();
}
static gboolean
separator_plugin_size_changed (XfcePanelPlugin *panel_plugin,
gint size)

8
plugins/systray/systray.c

@ -26,7 +26,6 @@
#include <libxfce4ui/libxfce4ui.h>
#include <common/panel-private.h>
#include <common/panel-xfconf.h>
#include <xfconf/xfconf.h>
#include <exo/exo.h>
#include "systray.h"
@ -156,8 +155,8 @@ systray_plugin_init (SystrayPlugin *plugin)
plugin->manager = NULL;
plugin->show_frame = FALSE;
/* initialize xfconf */
xfconf_init (NULL);
/* initialize properties */
PANEL_PROPERTIES_INIT (plugin);
/* show configure */
xfce_panel_plugin_menu_show_configure (XFCE_PANEL_PLUGIN (plugin));
@ -329,9 +328,6 @@ systray_plugin_free_data (XfcePanelPlugin *panel_plugin)
/* release the manager */
if (G_LIKELY (plugin->manager))
g_object_unref (G_OBJECT (plugin->manager));
/* shutdown xfconf */
xfconf_shutdown ();
}

16
plugins/tasklist/tasklist.c

@ -21,7 +21,6 @@
#include <config.h>
#endif
#include <xfconf/xfconf.h>
#include <exo/exo.h>
#include <libxfce4ui/libxfce4ui.h>
#include <common/panel-xfconf.h>
@ -60,7 +59,6 @@ struct _TasklistPlugin
static void tasklist_plugin_construct (XfcePanelPlugin *panel_plugin);
static void tasklist_plugin_free_data (XfcePanelPlugin *panel_plugin);
static void tasklist_plugin_orientation_changed (XfcePanelPlugin *panel_plugin, GtkOrientation orientation);
static gboolean tasklist_plugin_size_changed (XfcePanelPlugin *panel_plugin, gint size);
static void tasklist_plugin_configure_plugin (XfcePanelPlugin *panel_plugin);
@ -80,7 +78,6 @@ tasklist_plugin_class_init (TasklistPluginClass *klass)
plugin_class = XFCE_PANEL_PLUGIN_CLASS (klass);
plugin_class->construct = tasklist_plugin_construct;
plugin_class->free_data = tasklist_plugin_free_data;
plugin_class->orientation_changed = tasklist_plugin_orientation_changed;
plugin_class->size_changed = tasklist_plugin_size_changed;
plugin_class->configure_plugin = tasklist_plugin_configure_plugin;
@ -93,8 +90,8 @@ tasklist_plugin_init (TasklistPlugin *plugin)
{
GtkWidget *box;
/* initialize xfconf */
xfconf_init (NULL);
/* initialize properties */
PANEL_PROPERTIES_INIT (plugin);
/* show configure */
xfce_panel_plugin_menu_show_configure (XFCE_PANEL_PLUGIN (plugin));
@ -152,15 +149,6 @@ tasklist_plugin_construct (XfcePanelPlugin *panel_plugin)
static void
tasklist_plugin_free_data (XfcePanelPlugin *panel_plugin)
{
/* shutdown xfconf */
xfconf_shutdown ();
}
static void
tasklist_plugin_orientation_changed (XfcePanelPlugin *panel_plugin,
GtkOrientation orientation)

5
plugins/windowmenu/windowmenu.c

@ -21,7 +21,6 @@
#include <config.h>
#endif
#include <xfconf/xfconf.h>
#include <exo/exo.h>
#include <libxfce4ui/libxfce4ui.h>
#include <libxfce4panel/libxfce4panel.h>
@ -202,8 +201,8 @@ window_menu_plugin_init (WindowMenuPlugin *plugin)
plugin->all_workspaces = TRUE;
plugin->urgent_windows = 0;
/* initialize xfconf */
xfconf_init (NULL);
/* initialize properties */
PANEL_PROPERTIES_INIT (plugin);
/* show configure */
xfce_panel_plugin_menu_show_configure (XFCE_PANEL_PLUGIN (plugin));

Loading…
Cancel
Save