[Xfce4-commits] <xfce4-panel:master> Add option to tasklist to force a fixed width (bug #5045).

Nick Schermer noreply at xfce.org
Wed Oct 7 22:04:01 CEST 2009


Updating branch refs/heads/master
         to 41984974c34a45a511cba613eb812c9274c12dc1 (commit)
       from 35f316c17d7f29d49040ddb67829aee1ac272364 (commit)

commit 41984974c34a45a511cba613eb812c9274c12dc1
Author: Nick Schermer <nick at xfce.org>
Date:   Wed Oct 7 21:59:03 2009 +0200

    Add option to tasklist to force a fixed width (bug #5045).
    
    This will add a new string to the panel.

 plugins/tasklist/tasklist-dialogs.c |   37 +++++++++++++++++++++++++++++-----
 plugins/tasklist/tasklist.c         |    7 ++++-
 plugins/tasklist/tasklist.h         |    1 +
 3 files changed, 37 insertions(+), 8 deletions(-)

diff --git a/plugins/tasklist/tasklist-dialogs.c b/plugins/tasklist/tasklist-dialogs.c
index 4b9c563..9274997 100644
--- a/plugins/tasklist/tasklist-dialogs.c
+++ b/plugins/tasklist/tasklist-dialogs.c
@@ -100,9 +100,20 @@ tasklist_show_handle_toggled (GtkToggleButton *tb,
     tasklist->show_handles = gtk_toggle_button_get_active (tb);
 
     if (tasklist->show_handles)
-    	gtk_widget_show (tasklist->handle);
+        gtk_widget_show (tasklist->handle);
     else
-    	gtk_widget_hide (tasklist->handle);
+        gtk_widget_hide (tasklist->handle);
+}
+
+
+
+static void
+tasklist_fixed_width_toggled (GtkToggleButton *tb,
+                              TasklistPlugin  *tasklist)
+{
+    tasklist->fixed_width = gtk_toggle_button_get_active (tb);
+
+    gtk_widget_queue_resize (GTK_WIDGET (tasklist->panel_plugin));
 }
 
 
@@ -119,6 +130,15 @@ tasklist_width_changed (GtkSpinButton  *sb,
 
 
 static void
+tasklist_width_sensitive (GtkToggleButton *tb,
+                          GtkWidget       *sb)
+{
+    gtk_widget_set_sensitive (sb, gtk_toggle_button_get_active (tb));
+}
+
+
+
+static void
 tasklist_dialog_response (GtkWidget       *dlg,
                           gint             reponse,
                           TasklistPlugin  *tasklist)
@@ -169,9 +189,11 @@ tasklist_dialogs_configure (TasklistPlugin *tasklist)
     hbox = gtk_hbox_new (FALSE, 12);
     gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
 
-    label = gtk_label_new_with_mnemonic (_("_Minimum width:"));
-    gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
-    gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+    cb = gtk_check_button_new_with_mnemonic (_("Fi_xed length (pixels):"));
+    gtk_box_pack_start (GTK_BOX (hbox), cb, FALSE, FALSE, 0);
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cb), tasklist->fixed_width);
+    g_signal_connect (G_OBJECT (cb), "toggled",
+                      G_CALLBACK (tasklist_fixed_width_toggled), tasklist);
 
     /* an arbitrary max of 4000 should be future proof, right? */
     spin = gtk_spin_button_new_with_range (100, 4000, 10);
@@ -180,6 +202,9 @@ tasklist_dialogs_configure (TasklistPlugin *tasklist)
     gtk_label_set_mnemonic_widget (GTK_LABEL (label), spin);
     g_signal_connect (G_OBJECT (spin), "value-changed",
                       G_CALLBACK (tasklist_width_changed), tasklist);
+    gtk_widget_set_sensitive (spin, tasklist->fixed_width);
+    g_signal_connect (G_OBJECT (cb), "toggled",
+                      G_CALLBACK (tasklist_width_sensitive), spin);
 
     if (tasklist_using_xinerama (tasklist->panel_plugin))
     {
@@ -220,7 +245,7 @@ tasklist_dialogs_configure (TasklistPlugin *tasklist)
     gtk_combo_box_append_text (GTK_COMBO_BOX (cb), _("Never group tasks"));
     gtk_combo_box_append_text (GTK_COMBO_BOX (cb), _("Automatically group tasks"));
     gtk_combo_box_append_text (GTK_COMBO_BOX (cb), _("Always group tasks"));
-    
+
     /* keep order above in sync with WnckTasklistGroupingType */
 
     gtk_combo_box_set_active (GTK_COMBO_BOX (cb), tasklist->grouping);
diff --git a/plugins/tasklist/tasklist.c b/plugins/tasklist/tasklist.c
index 6ab9534..a26e04c 100644
--- a/plugins/tasklist/tasklist.c
+++ b/plugins/tasklist/tasklist.c
@@ -292,8 +292,8 @@ tasklist_plugin_size_request (TasklistPlugin *tasklist,
             size += TASKLIST_HANDLE_SIZE;
 
         /* use the requested size when it is bigger then the prefered size */
-        if (tasklist->width > size)
-           size = tasklist->width;
+        if (tasklist->fixed_width)
+            size = MAX (100, tasklist->width);
 
         /* get plugin orientation */
         orientation = xfce_panel_plugin_get_orientation (tasklist->panel_plugin);
@@ -355,6 +355,7 @@ tasklist_plugin_read (TasklistPlugin *tasklist)
     tasklist->flat_buttons   = TRUE;
     tasklist->show_handles   = TRUE;
     tasklist->width          = 300;
+    tasklist->fixed_width    = FALSE;
 
     /* get rc file name */
     file = xfce_panel_plugin_lookup_rc_file (tasklist->panel_plugin);
@@ -375,6 +376,7 @@ tasklist_plugin_read (TasklistPlugin *tasklist)
             tasklist->flat_buttons   = xfce_rc_read_bool_entry (rc, "flat_buttons", tasklist->flat_buttons);
             tasklist->show_handles   = xfce_rc_read_bool_entry (rc, "show_handles", tasklist->show_handles);
             tasklist->width          = xfce_rc_read_int_entry  (rc, "width",tasklist->width);
+            tasklist->fixed_width    = xfce_rc_read_bool_entry (rc, "fixed_width", tasklist->fixed_width);
 
             /* only set expand flag if xinerama is used */
             if (tasklist_using_xinerama (tasklist->panel_plugin))
@@ -414,6 +416,7 @@ tasklist_plugin_write (TasklistPlugin *tasklist)
             xfce_rc_write_bool_entry (rc, "expand", tasklist->expand);
             xfce_rc_write_bool_entry (rc, "flat_buttons", tasklist->flat_buttons);
             xfce_rc_write_bool_entry (rc, "show_handles", tasklist->show_handles);
+            xfce_rc_write_bool_entry (rc, "fixed_width", tasklist->fixed_width);
 
             /* close the rc file */
             xfce_rc_close (rc);
diff --git a/plugins/tasklist/tasklist.h b/plugins/tasklist/tasklist.h
index 2f6fba8..e5d9510 100644
--- a/plugins/tasklist/tasklist.h
+++ b/plugins/tasklist/tasklist.h
@@ -48,6 +48,7 @@ struct _TasklistPlugin
 
     /* settings */
     gint                      width;
+    guint                     fixed_width : 1;
     WnckTasklistGroupingType  grouping;
     guint                     all_workspaces : 1;
     guint                     show_label : 1;



More information about the Xfce4-commits mailing list