[Xfce4-commits] <xfce4-taskbar-plugin:master> Option is now customizable: drag button

Valentin Dudouyt noreply at xfce.org
Tue Nov 13 15:18:01 CET 2012


Updating branch refs/heads/master
         to d7d880f979dd3b3bc4875a54a97d803f69cb3882 (commit)
       from 224aacca0c3ca7cd031200a03f905896d9bf1bfd (commit)

commit d7d880f979dd3b3bc4875a54a97d803f69cb3882
Author: Valentin Dudouyt <valentin.dudouyt at gmail.com>
Date:   Tue Nov 13 21:16:16 2012 +0700

    Option is now customizable: drag button

 taskbar-dialog.glade |   64 +++++++++++++++++++++--
 taskbar-dialog_ui.h  |  143 ++++++++++++++++++++++++++++---------------------
 taskbar-widget.c     |   69 +++++++++++++++++-------
 taskbar.c            |    2 +
 4 files changed, 193 insertions(+), 85 deletions(-)

diff --git a/taskbar-dialog.glade b/taskbar-dialog.glade
index 0ee317a..6fb5722 100644
--- a/taskbar-dialog.glade
+++ b/taskbar-dialog.glade
@@ -211,6 +211,47 @@
                             <property name="position">3</property>
                           </packing>
                         </child>
+                        <child>
+                          <object class="GtkHBox" id="hbox2">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <child>
+                              <object class="GtkLabel" id="label4">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="label" translatable="yes">Drag-n-drop: </property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkComboBox" id="drag-button">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="model">liststore1</property>
+                                <child>
+                                  <object class="GtkCellRendererText" id="cellrenderertext1"/>
+                                  <attributes>
+                                    <attribute name="text">0</attribute>
+                                  </attributes>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">True</property>
+                            <property name="fill">True</property>
+                            <property name="position">4</property>
+                          </packing>
+                        </child>
                       </object>
                     </child>
                   </object>
@@ -266,8 +307,8 @@
                           </packing>
                         </child>
                         <child>
-                          <object class="GtkCheckButton" id="show-only-minimized">
-                            <property name="label" translatable="yes">Show only _minimized windows</property>
+                          <object class="GtkCheckButton" id="include-all-monitors">
+                            <property name="label" translatable="yes">Show windows from all mo_nitors</property>
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
                             <property name="receives_default">False</property>
@@ -282,8 +323,8 @@
                           </packing>
                         </child>
                         <child>
-                          <object class="GtkCheckButton" id="include-all-monitors">
-                            <property name="label" translatable="yes">Show windows from all mo_nitors</property>
+                          <object class="GtkCheckButton" id="show-only-minimized">
+                            <property name="label" translatable="yes">Show only _minimized windows</property>
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
                             <property name="receives_default">False</property>
@@ -332,5 +373,18 @@
       <action-widget response="0">help-button</action-widget>
     </action-widgets>
   </object>
-  <object class="GtkListStore" id="liststore1"/>
+  <object class="GtkListStore" id="liststore1">
+    <columns>
+      <!-- column-name Text1 -->
+      <column type="gchararray"/>
+    </columns>
+    <data>
+      <row>
+        <col id="0" translatable="yes">Left button</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">Middle button</col>
+      </row>
+    </data>
+  </object>
 </interface>
diff --git a/taskbar-dialog_ui.h b/taskbar-dialog_ui.h
index 8746046..6a3d6a5 100644
--- a/taskbar-dialog_ui.h
+++ b/taskbar-dialog_ui.h
@@ -123,66 +123,87 @@ static const char taskbar_dialog_ui[] =
   "\">0.51999998092651367</property><property name=\"draw_indicator"
   "\">True</property></object><packing><property name=\"expand\">Tr"
   "ue</property><property name=\"fill\">True</property><property na"
-  "me=\"position\">3</property></packing></child></object></child><"
-  "/object></child><child type=\"label\"><object class=\"GtkLabel\""
-  " id=\"label3\"><property name=\"visible\">True</property><proper"
-  "ty name=\"can_focus\">False</property><property name=\"label\" t"
-  "ranslatable=\"yes\">Behaviour</property><attributes><attribute n"
-  "ame=\"weight\" value=\"bold\"/></attributes></object></child></o"
-  "bject><packing><property name=\"expand\">False</property><proper"
-  "ty name=\"fill\">True</property><property name=\"position\">1</p"
-  "roperty></packing></child><child><object class=\"GtkFrame\" id=\""
-  "frame2\"><property name=\"visible\">True</property><property nam"
-  "e=\"can_focus\">False</property><property name=\"label_xalign\">"
-  "0</property><property name=\"shadow_type\">none</property><child"
-  "><object class=\"GtkAlignment\" id=\"alignment2\"><property name"
-  "=\"visible\">True</property><property name=\"can_focus\">False</"
-  "property><property name=\"left_padding\">12</property><child><ob"
-  "ject class=\"GtkVBox\" id=\"vbox4\"><property name=\"visible\">T"
-  "rue</property><property name=\"can_focus\">False</property><prop"
-  "erty name=\"border_width\">6</property><property name=\"spacing\""
-  ">6</property><child><object class=\"GtkCheckButton\" id=\"includ"
-  "e-all-workspaces\"><property name=\"label\" translatable=\"yes\""
-  ">Show windows from _all workspaces or viewports</property><prope"
+  "me=\"position\">3</property></packing></child><child><object cla"
+  "ss=\"GtkHBox\" id=\"hbox2\"><property name=\"visible\">True</pro"
+  "perty><property name=\"can_focus\">False</property><child><objec"
+  "t class=\"GtkLabel\" id=\"label4\"><property name=\"visible\">Tr"
+  "ue</property><property name=\"can_focus\">False</property><prope"
+  "rty name=\"label\" translatable=\"yes\">Drag-n-drop: </property>"
+  "</object><packing><property name=\"expand\">False</property><pro"
+  "perty name=\"fill\">True</property><property name=\"position\">0"
+  "</property></packing></child><child><object class=\"GtkComboBox\""
+  " id=\"drag-button\"><property name=\"visible\">True</property><p"
+  "roperty name=\"can_focus\">False</property><property name=\"mode"
+  "l\">liststore1</property><child><object class=\"GtkCellRendererT"
+  "ext\" id=\"cellrenderertext1\"/><attributes><attribute name=\"te"
+  "xt\">0</attribute></attributes></child></object><packing><proper"
+  "ty name=\"expand\">False</property><property name=\"fill\">True<"
+  "/property><property name=\"position\">1</property></packing></ch"
+  "ild></object><packing><property name=\"expand\">True</property><"
+  "property name=\"fill\">True</property><property name=\"position\""
+  ">4</property></packing></child></object></child></object></child"
+  "><child type=\"label\"><object class=\"GtkLabel\" id=\"label3\">"
+  "<property name=\"visible\">True</property><property name=\"can_f"
+  "ocus\">False</property><property name=\"label\" translatable=\"y"
+  "es\">Behaviour</property><attributes><attribute name=\"weight\" "
+  "value=\"bold\"/></attributes></object></child></object><packing>"
+  "<property name=\"expand\">False</property><property name=\"fill\""
+  ">True</property><property name=\"position\">1</property></packin"
+  "g></child><child><object class=\"GtkFrame\" id=\"frame2\"><prope"
   "rty name=\"visible\">True</property><property name=\"can_focus\""
-  ">True</property><property name=\"receives_default\">False</prope"
-  "rty><property name=\"use_action_appearance\">False</property><pr"
-  "operty name=\"use_underline\">True</property><property name=\"dr"
-  "aw_indicator\">True</property></object><packing><property name=\""
-  "expand\">True</property><property name=\"fill\">True</property><"
-  "property name=\"position\">0</property></packing></child><child>"
-  "<object class=\"GtkCheckButton\" id=\"show-only-minimized\"><pro"
-  "perty name=\"label\" translatable=\"yes\">Show only _minimized w"
-  "indows</property><property name=\"visible\">True</property><prop"
-  "erty name=\"can_focus\">True</property><property name=\"receives"
-  "_default\">False</property><property name=\"use_action_appearanc"
-  "e\">False</property><property name=\"use_underline\">True</prope"
-  "rty><property name=\"draw_indicator\">True</property></object><p"
-  "acking><property name=\"expand\">True</property><property name=\""
-  "fill\">True</property><property name=\"position\">1</property></"
-  "packing></child><child><object class=\"GtkCheckButton\" id=\"inc"
-  "lude-all-monitors\"><property name=\"label\" translatable=\"yes\""
-  ">Show windows from all mo_nitors</property><property name=\"visi"
-  "ble\">True</property><property name=\"can_focus\">True</property"
-  "><property name=\"receives_default\">False</property><property n"
-  "ame=\"use_action_appearance\">False</property><property name=\"u"
-  "se_underline\">True</property><property name=\"draw_indicator\">"
-  "True</property></object><packing><property name=\"expand\">True<"
-  "/property><property name=\"fill\">True</property><property name="
-  "\"position\">1</property></packing></child></object></child></ob"
-  "ject></child><child type=\"label\"><object class=\"GtkLabel\" id"
-  "=\"label2\"><property name=\"visible\">True</property><property "
-  "name=\"can_focus\">False</property><property name=\"label\" tran"
-  "slatable=\"yes\">Filtering</property><attributes><attribute name"
-  "=\"weight\" value=\"bold\"/></attributes></object></child></obje"
-  "ct><packing><property name=\"expand\">True</property><property n"
-  "ame=\"fill\">True</property><property name=\"position\">2</prope"
-  "rty></packing></child></object><packing><property name=\"expand\""
-  ">False</property><property name=\"fill\">True</property><propert"
-  "y name=\"position\">1</property></packing></child></object></chi"
-  "ld><action-widgets><action-widget response=\"0\">close-button</a"
-  "ction-widget><action-widget response=\"0\">help-button</action-w"
-  "idget></action-widgets></object><object class=\"GtkListStore\" i"
-  "d=\"liststore1\"/></interface>"
+  ">False</property><property name=\"label_xalign\">0</property><pr"
+  "operty name=\"shadow_type\">none</property><child><object class="
+  "\"GtkAlignment\" id=\"alignment2\"><property name=\"visible\">Tr"
+  "ue</property><property name=\"can_focus\">False</property><prope"
+  "rty name=\"left_padding\">12</property><child><object class=\"Gt"
+  "kVBox\" id=\"vbox4\"><property name=\"visible\">True</property><"
+  "property name=\"can_focus\">False</property><property name=\"bor"
+  "der_width\">6</property><property name=\"spacing\">6</property><"
+  "child><object class=\"GtkCheckButton\" id=\"include-all-workspac"
+  "es\"><property name=\"label\" translatable=\"yes\">Show windows "
+  "from _all workspaces or viewports</property><property name=\"vis"
+  "ible\">True</property><property name=\"can_focus\">True</propert"
+  "y><property name=\"receives_default\">False</property><property "
+  "name=\"use_action_appearance\">False</property><property name=\""
+  "use_underline\">True</property><property name=\"draw_indicator\""
+  ">True</property></object><packing><property name=\"expand\">True"
+  "</property><property name=\"fill\">True</property><property name"
+  "=\"position\">0</property></packing></child><child><object class"
+  "=\"GtkCheckButton\" id=\"include-all-monitors\"><property name=\""
+  "label\" translatable=\"yes\">Show windows from all mo_nitors</pr"
+  "operty><property name=\"visible\">True</property><property name="
+  "\"can_focus\">True</property><property name=\"receives_default\""
+  ">False</property><property name=\"use_action_appearance\">False<"
+  "/property><property name=\"use_underline\">True</property><prope"
+  "rty name=\"draw_indicator\">True</property></object><packing><pr"
+  "operty name=\"expand\">True</property><property name=\"fill\">Tr"
+  "ue</property><property name=\"position\">1</property></packing><"
+  "/child><child><object class=\"GtkCheckButton\" id=\"show-only-mi"
+  "nimized\"><property name=\"label\" translatable=\"yes\">Show onl"
+  "y _minimized windows</property><property name=\"visible\">True</"
+  "property><property name=\"can_focus\">True</property><property n"
+  "ame=\"receives_default\">False</property><property name=\"use_ac"
+  "tion_appearance\">False</property><property name=\"use_underline"
+  "\">True</property><property name=\"draw_indicator\">True</proper"
+  "ty></object><packing><property name=\"expand\">True</property><p"
+  "roperty name=\"fill\">True</property><property name=\"position\""
+  ">1</property></packing></child></object></child></object></child"
+  "><child type=\"label\"><object class=\"GtkLabel\" id=\"label2\">"
+  "<property name=\"visible\">True</property><property name=\"can_f"
+  "ocus\">False</property><property name=\"label\" translatable=\"y"
+  "es\">Filtering</property><attributes><attribute name=\"weight\" "
+  "value=\"bold\"/></attributes></object></child></object><packing>"
+  "<property name=\"expand\">True</property><property name=\"fill\""
+  ">True</property><property name=\"position\">2</property></packin"
+  "g></child></object><packing><property name=\"expand\">False</pro"
+  "perty><property name=\"fill\">True</property><property name=\"po"
+  "sition\">1</property></packing></child></object></child><action-"
+  "widgets><action-widget response=\"0\">close-button</action-widge"
+  "t><action-widget response=\"0\">help-button</action-widget></act"
+  "ion-widgets></object><object class=\"GtkListStore\" id=\"liststo"
+  "re1\"><columns><!-- column-name Text1 --><column type=\"gchararr"
+  "ay\"/></columns><data><row><col id=\"0\" translatable=\"yes\">Le"
+  "ft button</col></row><row><col id=\"0\" translatable=\"yes\">Mid"
+  "dle button</col></row></data></object></interface>"
 };
-static const unsigned taskbar_dialog_ui_length = 11302u;
+static const unsigned taskbar_dialog_ui_length = 12664u;
diff --git a/taskbar-widget.c b/taskbar-widget.c
index 0c38b1b..52b68ab 100644
--- a/taskbar-widget.c
+++ b/taskbar-widget.c
@@ -70,6 +70,7 @@ enum
     PROP_SHOW_WIREFRAMES,
     PROP_SHOW_HANDLE,
     PROP_SHOW_INSTANCES_HOVER,
+    PROP_DRAG_BUTTON,
 };
 
 
@@ -142,7 +143,8 @@ struct _XfceTaskBar
 
     /* dummy properties */
     guint show_handle : 1;
-    guint show_instances_hover;
+    guint show_instances_hover : 1;
+    guint drag_button; /* Middle */
 
     guint unique_id_counter ;
     
@@ -315,6 +317,7 @@ static void xfce_taskbar_class_init (XfceTaskBarClass *klass)
     g_object_class_install_property (gobject_class, PROP_SHOW_WIREFRAMES, g_param_spec_boolean ("show-wireframes", NULL, NULL, 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));
     g_object_class_install_property (gobject_class, PROP_SHOW_INSTANCES_HOVER, g_param_spec_boolean ("show-instances-on-hover", NULL, NULL, TRUE, EXO_PARAM_READWRITE));
+    g_object_class_install_property (gobject_class, PROP_DRAG_BUTTON, g_param_spec_int ("drag-button", NULL, NULL, -1, G_MAXINT, 0, EXO_PARAM_READWRITE));
     
     gtk_widget_class_install_style_property (gtkwidget_class, g_param_spec_int ("max-button-length", NULL, "The maximum length of a window button", -1, G_MAXINT, DEFAULT_MAX_BUTTON_LENGTH, EXO_PARAM_READABLE));
     gtk_widget_class_install_style_property (gtkwidget_class, g_param_spec_int ("min-button-length", NULL, "The minumum length of a window button", 1, G_MAXINT, DEFAULT_MIN_BUTTON_LENGTH, EXO_PARAM_READABLE));
@@ -347,6 +350,8 @@ static void xfce_taskbar_init (XfceTaskBar *taskbar)
     taskbar->only_minimized = FALSE;
     taskbar->show_wireframes = TRUE;
     taskbar->show_handle = TRUE;
+    taskbar->show_instances_hover = FALSE;
+    taskbar->drag_button = 1; /* Middle */
     taskbar->all_monitors = TRUE;
     taskbar->unique_id_counter = 0x0 ;
     xfce_taskbar_geometry_set_invalid (taskbar);
@@ -403,6 +408,10 @@ static void xfce_taskbar_get_property (GObject *object, guint prop_id, GValue *v
             g_value_set_boolean (value, taskbar->show_instances_hover);
             break;
 
+        case PROP_DRAG_BUTTON:
+            g_value_set_int (value, taskbar->drag_button);
+            break;
+
         default:
             G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
             break;
@@ -443,6 +452,10 @@ static void xfce_taskbar_set_property (GObject *object, guint prop_id, const GVa
             taskbar->show_instances_hover = g_value_get_boolean (value);
             break;
 
+        case PROP_DRAG_BUTTON:
+            taskbar->drag_button = g_value_get_int (value);
+            break;
+
         default:
             G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
             break;
@@ -2262,10 +2275,40 @@ static void xfce_taskbar_group_button_menu_destroy(GtkWidget *menu_widget, XfceT
 }
 
 
+// Get the active_child and visible_count of current group
+void get_active_child(XfceTaskBarGroup *group, XfceTaskBarWNode **active_child, int *visible_count) {
+    XfceTaskBarWNode *child;
+    *active_child = NULL;
+    *visible_count = 0;
+    GSList *li;
+    for (li = group->wnodes; li != NULL; li = li->next)
+    {
+        child = li->data;
+        if(child->visible)
+        {
+            *visible_count += 1 ;
+            if(*active_child == 0x0 && *visible_count == 1)
+                *active_child = child ;
+            else
+            {
+                *active_child = 0x0 ;
+            }
+        }
+    }
+}
+
 static gboolean xfce_taskbar_group_button_press_event
 (GtkWidget *button, GdkEventButton *event, XfceTaskBarGroup *group)
 {
     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (group->button), TRUE);
+    XfceTaskBarWNode *active_child;
+    int visible_count;
+    get_active_child(group, &active_child, &visible_count);
+    if(group->taskbar->drag_button == 1 && visible_count > 1) {
+        GtkWidget *menu_widget = xfce_taskbar_group_button_menu_show_active (group);
+        xfce_taskbar_activate_hover_menu(menu_widget, group, event->button);
+	return TRUE;
+    }
     return FALSE ;
 }
 
@@ -2274,6 +2317,7 @@ static gboolean xfce_taskbar_group_button_press_event
 static gboolean xfce_taskbar_group_button_release_event
 (GtkWidget *button, GdkEventButton *event, XfceTaskBarGroup *group)
 {
+    g_message("xfce_taskbar_group_button_release_event");
     GtkWidget *panel_plugin;
     GtkWidget *menu_widget;
     
@@ -2303,23 +2347,9 @@ static gboolean xfce_taskbar_group_button_release_event
     //If there's only a single window visible, set active_child
     //otherwise active_child will be NULL, regardless of multiple
     //active windows
-    GSList *li;
-    XfceTaskBarWNode *child, *active_child=0x0 ;
+    XfceTaskBarWNode *active_child=0x0 ;
     int visible_count=0x0 ;
-    for (li = group->wnodes; li != NULL; li = li->next)
-    {
-        child = li->data;
-        if(child->visible)
-        {
-            visible_count += 1 ;
-            if(active_child == 0x0 && visible_count == 1)
-                active_child = child ;
-            else
-            {
-                active_child = 0x0 ;
-            }
-        }
-    }
+    get_active_child(group, &active_child, &visible_count);
     
     //Check if there's a hover menu active, if so, dismiss it, but only if it's outside the cooloff period
     //If possible, detect menu_source to reflect the mouse button which invoked the hover menu
@@ -2382,7 +2412,8 @@ static gboolean xfce_taskbar_group_button_release_event
             }
         }
         
-        xfce_taskbar_activate_hover_menu(menu_widget, group, event->button);
+	if(group->taskbar->drag_button == 0)
+        	xfce_taskbar_activate_hover_menu(menu_widget, group, event->button);
         
         return TRUE;
     }
@@ -2667,7 +2698,7 @@ static XfceTaskBarGroup * xfce_taskbar_group_button_new (const char *group_name,
     
     /* drag and drop to the pager */
     gtk_drag_dest_set     (group->button, GTK_DEST_DEFAULT_ALL,    source_targets, G_N_ELEMENTS (source_targets), GDK_ACTION_MOVE);
-    gtk_drag_source_set (group->button, GDK_BUTTON1_MASK,            source_targets, G_N_ELEMENTS (source_targets), GDK_ACTION_MOVE);
+    gtk_drag_source_set (group->button, taskbar->drag_button ? GDK_BUTTON2_MASK : GDK_BUTTON1_MASK,            source_targets, G_N_ELEMENTS (source_targets), GDK_ACTION_MOVE);
     
     g_signal_connect (G_OBJECT (group->button), "drag-data-get",            G_CALLBACK (xfce_taskbar_button_drag_data_get), group);
     g_signal_connect (G_OBJECT (group->button), "drag-begin",                 G_CALLBACK (xfce_taskbar_button_drag_begin), group);
diff --git a/taskbar.c b/taskbar.c
index 51adab2..aec7804 100644
--- a/taskbar.c
+++ b/taskbar.c
@@ -102,6 +102,7 @@ static void taskbar_plugin_construct (XfcePanelPlugin *panel_plugin)
     { "show-wireframes", G_TYPE_BOOLEAN },
     { "show-handle", G_TYPE_BOOLEAN },
     { "show-instances-on-hover", G_TYPE_BOOLEAN },
+    { "drag-button", G_TYPE_INT },
     { NULL }
   };
 
@@ -179,6 +180,7 @@ static void taskbar_plugin_configure_plugin (XfcePanelPlugin *panel_plugin)
   TASKBAR_DIALOG_BIND ("show-wireframes", "active")
   TASKBAR_DIALOG_BIND ("show-handle", "active")
   TASKBAR_DIALOG_BIND ("show-instances-on-hover", "active")
+  TASKBAR_DIALOG_BIND ("drag-button", "active")
 
 #ifndef GDK_WINDOWING_X11
   /* not functional in x11, so avoid confusion */


More information about the Xfce4-commits mailing list