[Xfce4-commits] <xfce4-panel:devel> Cleanup some code and complete the glade grouping combobox.

Nick Schermer nick at xfce.org
Tue Aug 11 20:28:31 CEST 2009


Updating branch refs/heads/devel
         to 475878038f3d03b6c2836ea8d06e934c668a1e5f (commit)
       from 5f9defb88a35f137995a46b9e6dc521c98cd92c6 (commit)

commit 475878038f3d03b6c2836ea8d06e934c668a1e5f
Author: Nick Schermer <nick at xfce.org>
Date:   Sat Feb 28 20:56:48 2009 +0100

    Cleanup some code and complete the glade grouping combobox.

 plugins/tasklist/tasklist-dialog.glade |   26 +++++++++++-
 plugins/tasklist/tasklist-widget.c     |   15 ++++++-
 plugins/tasklist/tasklist-widget.h     |   22 ++++++++--
 plugins/tasklist/tasklist.c            |   71 ++++++++++++++++---------------
 4 files changed, 91 insertions(+), 43 deletions(-)

diff --git a/plugins/tasklist/tasklist-dialog.glade b/plugins/tasklist/tasklist-dialog.glade
index 629e3cf..e731293 100644
--- a/plugins/tasklist/tasklist-dialog.glade
+++ b/plugins/tasklist/tasklist-dialog.glade
@@ -149,8 +149,9 @@
                               <object class="GtkLabel" id="label4">
                                 <property name="visible">True</property>
                                 <property name="xalign">0</property>
-                                <property name="label" translatable="yes">_Grouping:</property>
+                                <property name="label" translatable="yes">Window _grouping:</property>
                                 <property name="use_underline">True</property>
+                                <property name="mnemonic_widget">grouping</property>
                               </object>
                               <packing>
                                 <property name="expand">False</property>
@@ -158,10 +159,14 @@
                               </packing>
                             </child>
                             <child>
-                              <object class="GtkComboBox" id="combobox2">
+                              <object class="GtkComboBox" id="grouping">
                                 <property name="visible">True</property>
+                                <property name="model">grouping-model</property>
                                 <child>
                                   <object class="GtkCellRendererText" id="cellrenderertext2"/>
+                                  <attributes>
+                                    <attribute name="text">0</attribute>
+                                  </attributes>
                                 </child>
                               </object>
                               <packing>
@@ -278,4 +283,21 @@
       <action-widget response="0">close-button</action-widget>
     </action-widgets>
   </object>
+  <object class="GtkListStore" id="grouping-model">
+    <columns>
+      <!-- column-name title -->
+      <column type="gchararray"/>
+    </columns>
+    <data>
+      <row>
+        <col id="0" translatable="yes">Never</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">When space is limited</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">Always</col>
+      </row>
+    </data>
+  </object>
 </interface>
diff --git a/plugins/tasklist/tasklist-widget.c b/plugins/tasklist/tasklist-widget.c
index a28ae0f..6ab5954 100644
--- a/plugins/tasklist/tasklist-widget.c
+++ b/plugins/tasklist/tasklist-widget.c
@@ -47,6 +47,7 @@ enum
 {
   PROP_0,
   PROP_STYLE,
+  PROP_GROUPING,
   PROP_INCLUDE_ALL_WORKSPACES,
   PROP_FLAT_BUTTONS,
   PROP_SWITCH_WORKSPACE_ON_UNMINIMIZE,
@@ -214,6 +215,15 @@ xfce_tasklist_class_init (XfceTasklistClass *klass)
                                                       EXO_PARAM_READWRITE));
 
   g_object_class_install_property (gobject_class,
+                                   PROP_GROUPING,
+                                   g_param_spec_uint ("grouping",
+                                                      NULL, NULL,
+                                                      XFCE_TASKLIST_GROUPING_MIN,
+                                                      XFCE_TASKLIST_GROUPING_MAX,
+                                                      XFCE_TASKLIST_GROUPING_DEFAULT,
+                                                      EXO_PARAM_READWRITE));
+
+  g_object_class_install_property (gobject_class,
                                    PROP_INCLUDE_ALL_WORKSPACES,
                                    g_param_spec_boolean ("include-all-workspaces",
                                                          NULL, NULL,
@@ -1341,8 +1351,9 @@ tasklist_button_button_press_event (GtkWidget         *button,
         }
       else
         {
-          /* only switch workspaces if we show application from other workspaces
-           * don't switch when switch on minimize is disabled and the window is minimized */
+          /* only switch workspaces if we show windows from other
+           * workspaces don't switch when switch on minimize is disabled
+           * and the window is minimized */
           if (child->tasklist->all_workspaces
               && (!wnck_window_is_minimized (child->window)
                   || child->tasklist->switch_workspace))
diff --git a/plugins/tasklist/tasklist-widget.h b/plugins/tasklist/tasklist-widget.h
index 3c6f959..e1011ec 100644
--- a/plugins/tasklist/tasklist-widget.h
+++ b/plugins/tasklist/tasklist-widget.h
@@ -1,7 +1,7 @@
 /* $Id$ */
 /*
  * Copyright (C) 2008-2009 Nick Schermer <nick at xfce.org>
- * 
+ *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the Free
  * Software Foundation; either version 2 of the License, or (at your option)
@@ -24,10 +24,11 @@
 
 G_BEGIN_DECLS
 
-typedef struct _XfceTasklistClass XfceTasklistClass;
-typedef struct _XfceTasklist      XfceTasklist;
-typedef struct _XfceTasklistChild XfceTasklistChild;
-typedef enum   _XfceTasklistStyle XfceTasklistStyle;
+typedef struct _XfceTasklistClass    XfceTasklistClass;
+typedef struct _XfceTasklist         XfceTasklist;
+typedef struct _XfceTasklistChild    XfceTasklistChild;
+typedef enum   _XfceTasklistStyle    XfceTasklistStyle;
+typedef enum   _XfceTasklistGrouping XfceTasklistGrouping;
 
 #define XFCE_TYPE_TASKLIST            (xfce_tasklist_get_type ())
 #define XFCE_TASKLIST(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFCE_TYPE_TASKLIST, XfceTasklist))
@@ -48,6 +49,17 @@ enum _XfceTasklistStyle
   XFCE_TASKLIST_STYLE_DEFAULT = XFCE_TASKLIST_STYLE_NORMAL
 };
 
+enum _XfceTasklistGrouping
+{
+  XFCE_TASKLIST_GROUPING_NEVER,
+  XFCE_TASKLIST_GROUPING_AUTO,
+  XFCE_TASKLIST_GROUPING_ALWAYS,
+
+  XFCE_TASKLIST_GROUPING_MIN = XFCE_TASKLIST_GROUPING_NEVER,
+  XFCE_TASKLIST_GROUPING_MAX = XFCE_TASKLIST_GROUPING_ALWAYS,
+  XFCE_TASKLIST_GROUPING_DEFAULT = XFCE_TASKLIST_GROUPING_AUTO
+};
+
 
 
 GType xfce_tasklist_get_type        (void) G_GNUC_CONST;
diff --git a/plugins/tasklist/tasklist.c b/plugins/tasklist/tasklist.c
index 69ed217..ec8ffaa 100644
--- a/plugins/tasklist/tasklist.c
+++ b/plugins/tasklist/tasklist.c
@@ -1,7 +1,7 @@
 /* $Id$ */
 /*
  * Copyright (C) 2008-2009 Nick Schermer <nick at xfce.org>
- * 
+ *
  * This library is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the Free
  * Software Foundation; either version 2 of the License, or (at your option)
@@ -118,19 +118,18 @@ tasklist_plugin_construct (XfcePanelPlugin *panel_plugin)
   /* 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);
+
   /* create bindings */
-  xfconf_g_property_bind (plugin->channel, "/style", G_TYPE_UINT,
-                          plugin->tasklist, "style");
-  xfconf_g_property_bind (plugin->channel, "/include-all-workspaces", G_TYPE_BOOLEAN,
-                          plugin->tasklist, "include-all-workspaces");
-  xfconf_g_property_bind (plugin->channel, "/flat-buttons", G_TYPE_BOOLEAN,
-                          plugin->tasklist, "flat-buttons");
-  xfconf_g_property_bind (plugin->channel, "/switch-workspace-on-unminimize", G_TYPE_BOOLEAN,
-                          plugin->tasklist, "switch-workspace-on-unminimize");
-  xfconf_g_property_bind (plugin->channel, "/show-only-minimized", G_TYPE_BOOLEAN,
-                          plugin->tasklist, "show-only-minimized");
-  xfconf_g_property_bind (plugin->channel, "/show-wireframes", G_TYPE_BOOLEAN,
-                          plugin->tasklist, "show-wireframes");
+  TASKLIST_XFCONF_BIND ("style", G_TYPE_UINT)
+  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)
 
   /* show the tasklist */
   gtk_widget_show (plugin->tasklist);
@@ -188,35 +187,39 @@ tasklist_plugin_configure_plugin (XfcePanelPlugin *panel_plugin)
   GObject        *object;
 
   builder = gtk_builder_new ();
-  if (gtk_builder_add_from_string (builder, tasklist_dialog_glade, tasklist_dialog_glade_length, NULL))
+  if (gtk_builder_add_from_string (builder, tasklist_dialog_glade,
+                                   tasklist_dialog_glade_length, NULL))
     {
       dialog = gtk_builder_get_object (builder, "dialog");
       g_object_weak_ref (G_OBJECT (dialog), (GWeakNotify) g_object_unref, builder);
       xfce_panel_plugin_take_window (panel_plugin, GTK_WINDOW (dialog));
 
       xfce_panel_plugin_block_menu (panel_plugin);
-      g_object_weak_ref (G_OBJECT (dialog), (GWeakNotify) xfce_panel_plugin_unblock_menu, panel_plugin);
+      g_object_weak_ref (G_OBJECT (dialog), (GWeakNotify)
+                         xfce_panel_plugin_unblock_menu, panel_plugin);
 
       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, "style");
-      exo_mutual_binding_new (G_OBJECT (plugin->tasklist), "style", object, "active");
-
-      object = gtk_builder_get_object (builder, "include-all-workspaces");
-      exo_mutual_binding_new (G_OBJECT (plugin->tasklist), "include-all-workspaces", object, "active");
-
-      object = gtk_builder_get_object (builder, "flat-buttons");
-      exo_mutual_binding_new (G_OBJECT (plugin->tasklist), "flat-buttons", object, "active");
-
-      object = gtk_builder_get_object (builder, "switch-workspace-on-unminimize");
-      exo_mutual_binding_new_with_negation (G_OBJECT (plugin->tasklist), "switch-workspace-on-unminimize", object, "active");
-
-      object = gtk_builder_get_object (builder, "show-only-minimized");
-      exo_mutual_binding_new (G_OBJECT (plugin->tasklist), "show-only-minimized", object, "active");
-
-      object = gtk_builder_get_object (builder, "show-wireframes");
-      exo_mutual_binding_new (G_OBJECT (plugin->tasklist), "show-wireframes", object, "active");
+      g_signal_connect_swapped (G_OBJECT (object), "clicked",
+                                G_CALLBACK (gtk_widget_destroy), dialog);
+
+#define TASKLIST_DIALOG_BIND(name, property) \
+      object = gtk_builder_get_object (builder, (name)); \
+      exo_mutual_binding_new (G_OBJECT (plugin->tasklist), (name), \
+                              G_OBJECT (object), (property));
+
+#define TASKLIST_DIALOG_BIND_INV(name, property) \
+      object = gtk_builder_get_object (builder, name); \
+      exo_mutual_binding_new_with_negation (G_OBJECT (plugin->tasklist), \
+                                            name,  G_OBJECT (object), \
+                                            property);
+
+      TASKLIST_DIALOG_BIND ("style", "active")
+      TASKLIST_DIALOG_BIND ("grouping", "active")
+      TASKLIST_DIALOG_BIND ("include-all-workspaces", "active")
+      TASKLIST_DIALOG_BIND ("flat-buttons", "active")
+      TASKLIST_DIALOG_BIND_INV ("switch-workspace-on-unminimize", "active")
+      TASKLIST_DIALOG_BIND ("show-only-minimized", "active")
+      TASKLIST_DIALOG_BIND ("show-wireframes", "active")
 
       gtk_widget_show (GTK_WIDGET (dialog));
 	}



More information about the Xfce4-commits mailing list