[Xfce4-commits] <xfce4-panel:devel> Use custom bindings in tasklist plugin.
Nick Schermer
nick at xfce.org
Tue Aug 11 20:34:14 CEST 2009
Updating branch refs/heads/devel
to 7f4c58e7fc743e9402d56d5bf9b829ea65227235 (commit)
from 94136777410af7066b27aab8ba58c30289f37cc9 (commit)
commit 7f4c58e7fc743e9402d56d5bf9b829ea65227235
Author: Nick Schermer <nick at xfce.org>
Date: Mon Jun 1 00:25:06 2009 +0200
Use custom bindings in tasklist plugin.
plugins/tasklist/Makefile.am | 4 ++-
plugins/tasklist/tasklist-widget.c | 22 ++++++++++++++++-
plugins/tasklist/tasklist.c | 45 ++++++++++++++++++-----------------
3 files changed, 47 insertions(+), 24 deletions(-)
diff --git a/plugins/tasklist/Makefile.am b/plugins/tasklist/Makefile.am
index c83685a..7786d3c 100644
--- a/plugins/tasklist/Makefile.am
+++ b/plugins/tasklist/Makefile.am
@@ -38,6 +38,7 @@ libtasklist_la_LDFLAGS = \
libtasklist_la_LIBADD = \
$(top_builddir)/libxfce4panel/libxfce4panel.la \
+ $(top_builddir)/common/libpanel-xfconf.la \
$(EXO_LIBS) \
$(GTK_LIBS) \
$(XFCONF_LIBS) \
@@ -46,7 +47,8 @@ libtasklist_la_LIBADD = \
$(LIBWNCK_LIBS)
libtasklist_la_DEPENDENCIES = \
- $(top_builddir)/libxfce4panel/libxfce4panel.la
+ $(top_builddir)/libxfce4panel/libxfce4panel.la \
+ $(top_builddir)/common/libpanel-xfconf.la
#
# .desktop file
diff --git a/plugins/tasklist/tasklist-widget.c b/plugins/tasklist/tasklist-widget.c
index c4e0f38..d49b69f 100644
--- a/plugins/tasklist/tasklist-widget.c
+++ b/plugins/tasklist/tasklist-widget.c
@@ -52,7 +52,8 @@ enum
PROP_SWITCH_WORKSPACE_ON_UNMINIMIZE,
PROP_SHOW_LABELS,
PROP_SHOW_ONLY_MINIMIZED,
- PROP_SHOW_WIREFRAMES
+ PROP_SHOW_WIREFRAMES,
+ PROP_SHOW_HANDLE
};
struct _XfceTasklistClass
@@ -104,6 +105,9 @@ struct _XfceTasklist
* the tasklist */
guint show_wireframes : 1;
+ /* dummy property */
+ guint show_handle : 1;
+
/* wireframe window */
Window wireframe_window;
@@ -257,6 +261,13 @@ xfce_tasklist_class_init (XfceTasklistClass *klass)
FALSE,
EXO_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class,
+ PROP_SHOW_HANDLE,
+ g_param_spec_boolean ("show-handle",
+ NULL, NULL,
+ TRUE,
+ EXO_PARAM_READWRITE));
+
gtk_widget_class_install_style_property (gtkwidget_class,
g_param_spec_int ("max-button-length",
NULL,
@@ -302,6 +313,7 @@ xfce_tasklist_init (XfceTasklist *tasklist)
tasklist->show_labels = TRUE;
tasklist->class_groups = NULL;
tasklist->show_wireframes = FALSE;
+ tasklist->show_handle = TRUE;
tasklist->wireframe_window = 0;
tasklist->max_button_length = DEFAULT_BUTTON_LENGTH;
tasklist->max_button_size = DEFAULT_BUTTON_SIZE;
@@ -351,6 +363,10 @@ xfce_tasklist_get_property (GObject *object,
g_value_set_boolean (value, tasklist->show_wireframes);
break;
+ case PROP_SHOW_HANDLE:
+ g_value_set_boolean (value, tasklist->show_handle);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -404,6 +420,10 @@ xfce_tasklist_set_property (GObject *object,
xfce_tasklist_set_show_wireframes (tasklist, g_value_get_boolean (value));
break;
+ case PROP_SHOW_HANDLE:
+ tasklist->show_handle = g_value_get_boolean (value);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
diff --git a/plugins/tasklist/tasklist.c b/plugins/tasklist/tasklist.c
index 5440489..fb06483 100644
--- a/plugins/tasklist/tasklist.c
+++ b/plugins/tasklist/tasklist.c
@@ -24,6 +24,7 @@
#include <xfconf/xfconf.h>
#include <exo/exo.h>
#include <libxfce4ui/libxfce4ui.h>
+#include <common/panel-xfconf.h>
#include <libxfce4panel/libxfce4panel.h>
#include "tasklist-widget.h"
@@ -116,6 +117,9 @@ tasklist_plugin_init (TasklistPlugin *plugin)
plugin->tasklist = g_object_new (XFCE_TYPE_TASKLIST, NULL);
gtk_box_pack_start (GTK_BOX (box), plugin->tasklist, TRUE, TRUE, 0);
+
+ exo_binding_new (G_OBJECT (plugin->tasklist), "show-handle",
+ G_OBJECT (plugin->handle), "visible");
}
@@ -123,29 +127,30 @@ tasklist_plugin_init (TasklistPlugin *plugin)
static void
tasklist_plugin_construct (XfcePanelPlugin *panel_plugin)
{
- TasklistPlugin *plugin = XFCE_TASKLIST_PLUGIN (panel_plugin);
+ TasklistPlugin *plugin = XFCE_TASKLIST_PLUGIN (panel_plugin);
+ const PanelProperty properties[] =
+ {
+ { "show-labels", G_TYPE_BOOLEAN },
+ { "grouping", G_TYPE_UINT },
+ { "include-all-workspaces", G_TYPE_BOOLEAN },
+ { "flat-buttons", G_TYPE_BOOLEAN },
+ { "switch-workspace-on-unminimize", G_TYPE_BOOLEAN },
+ { "show-only-minimized", G_TYPE_BOOLEAN },
+ { "show-wireframes", G_TYPE_BOOLEAN },
+ { "show-handle", G_TYPE_BOOLEAN },
+ { NULL, G_TYPE_NONE }
+ };
/* expand the plugin */
xfce_panel_plugin_set_expand (panel_plugin, TRUE);
/* open the xfconf channel */
- plugin->channel = xfce_panel_plugin_xfconf_channel_new (panel_plugin);
-
-#define TASKLIST_XFCONF_BIND(name, gtype) \
- xfconf_g_property_bind (plugin->channel, "/" name, gtype, \
- plugin->tasklist, name);
+ plugin->channel = xfconf_channel_new (XFCE_PANEL_PLUGIN_CHANNEL_NAME);
- /* create bindings */
- TASKLIST_XFCONF_BIND ("show-labels", G_TYPE_BOOLEAN)
- TASKLIST_XFCONF_BIND ("grouping", G_TYPE_UINT)
- TASKLIST_XFCONF_BIND ("include-all-workspaces", G_TYPE_BOOLEAN)
- TASKLIST_XFCONF_BIND ("flat-buttons", G_TYPE_BOOLEAN)
- TASKLIST_XFCONF_BIND ("switch-workspace-on-unminimize", G_TYPE_BOOLEAN)
- TASKLIST_XFCONF_BIND ("show-only-minimized", G_TYPE_BOOLEAN)
- TASKLIST_XFCONF_BIND ("show-wireframes", G_TYPE_BOOLEAN)
-
- xfconf_g_property_bind (plugin->channel, "/show-handle", G_TYPE_BOOLEAN,
- plugin->handle, "visible");
+ /* connect all properties */
+ panel_properties_bind (plugin->channel, G_OBJECT (plugin->tasklist),
+ xfce_panel_plugin_get_property_base (panel_plugin),
+ properties, NULL);
/* show the tasklist */
gtk_widget_show (plugin->tasklist);
@@ -238,11 +243,7 @@ tasklist_plugin_configure_plugin (XfcePanelPlugin *panel_plugin)
TASKLIST_DIALOG_BIND_INV ("switch-workspace-on-unminimize", "active")
TASKLIST_DIALOG_BIND ("show-only-minimized", "active")
TASKLIST_DIALOG_BIND ("show-wireframes", "active")
-
- object = gtk_builder_get_object (builder, "show-handle");
- panel_return_if_fail (G_IS_OBJECT (object));
- exo_mutual_binding_new (G_OBJECT (plugin->handle), "visible",
- G_OBJECT (object), "active");
+ TASKLIST_DIALOG_BIND ("show-handle", "active")
gtk_widget_show (GTK_WIDGET (dialog));
}
More information about the Xfce4-commits
mailing list