[SF#834] Allow task button icons match panel icon settings (configurable to allow...
authorAndriy Grytsenko <andrej@rep.kiev.ua>
Mon, 31 Oct 2016 11:53:05 +0000 (13:53 +0200)
committerAndriy Grytsenko <andrej@rep.kiev.ua>
Mon, 31 Oct 2016 11:53:05 +0000 (13:53 +0200)
ChangeLog
data/ui/launchtaskbar.glade
plugins/launchtaskbar.c
plugins/task-button.c
plugins/task-button.h

index 4ff2e50..0469df6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
     so some icons might be invisible or placed under other plugins.
 * Removed call to gtk_widget_set_style() from volume slider to fix colors
     of current theme.
+* Changed icon size handling on task bar - it may now maintain the same
+    size as rest of icons. It may affect users who are used to have them
+    smaller, it's why this feature was made configurable, corresponding
+    config variable is UseSmallerIcons and default is 1 (old behavior).
 
 0.8.2
 -------------------------------------------------------------------------
index 2444647..6a45d23 100644 (file)
                   </packing>
                 </child>
                 <child>
+                  <object class="GtkCheckButton" id="checkbutton_use_smaller_icons">
+                    <property name="label" translatable="yes">Show task icons lesser than rest of panel icons</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="draw_indicator">True</property>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                    <property name="position">8</property>
+                  </packing>
+                </child>
+                <child>
                   <object class="GtkHBox" id="hbox2">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
index 8a21c92..7079699 100644 (file)
@@ -1007,11 +1007,14 @@ static void launchtaskbar_constructor_task(LaunchTaskBarPlugin *ltbp)
             ltbp->flags.flat_button = (tmp_int != 0);
         if (config_setting_lookup_int(s, "GroupedTasks", &tmp_int))
             ltbp->grouped_tasks = (tmp_int != 0);
+        if (config_setting_lookup_int(s, "UseSmallerIcons", &tmp_int))
+            ltbp->flags.use_smaller_icons = (tmp_int != 0);
 
         /* Make container for task buttons as a child of top level widget. */
         ltbp->tb_icon_grid = panel_icon_grid_new(panel_get_orientation(ltbp->panel),
-                                                 ltbp->task_width_max,
-                                                 ltbp->icon_size, ltbp->spacing, 0,
+                                                 ((ltbp->flags.icons_only) ? ltbp->icon_size + ICON_ONLY_EXTRA : ltbp->task_width_max),
+                                                 ((ltbp->flags.icons_only) ? ltbp->icon_size + ICON_ONLY_EXTRA : ltbp->icon_size + ICON_BUTTON_TRIM),
+                                                 ltbp->spacing, 0,
                                                  panel_get_height(ltbp->panel));
         panel_icon_grid_set_constrain_width(PANEL_ICON_GRID(ltbp->tb_icon_grid), TRUE);
         gtk_box_pack_start(GTK_BOX(ltbp->plugin), ltbp->tb_icon_grid, TRUE, TRUE, 0);
@@ -1068,6 +1071,7 @@ static GtkWidget *_launchtaskbar_constructor(LXPanel *panel, config_setting_t *s
     ltbp->spacing           = 1;
     ltbp->flags.use_mouse_wheel = TRUE;
     ltbp->flags.use_urgency_hint = TRUE;
+    ltbp->flags.use_smaller_icons = TRUE;
     ltbp->grouped_tasks     = FALSE;
     ltbp->fixed_mode        = (mode == LAUNCHBAR) || (mode == TASKBAR);
 
@@ -1489,6 +1493,14 @@ static void on_checkbutton_disable_taskbar_upscale_toggled(GtkToggleButton *p_to
     taskbar_apply_configuration(ltbp);
 }
 
+static void on_checkbutton_use_smaller_icons_toggled(GtkToggleButton *p_togglebutton, gpointer p_data)
+{
+    LaunchTaskBarPlugin *ltbp = (LaunchTaskBarPlugin *)p_data;
+    ltbp->flags.use_smaller_icons = gtk_toggle_button_get_active(p_togglebutton);
+    config_group_set_int(ltbp->settings, "UseSmallerIcons", ltbp->flags.use_smaller_icons);
+    taskbar_apply_configuration(ltbp);
+}
+
 static void on_checkbutton_mouse_wheel_toggled(GtkToggleButton *p_togglebutton, gpointer p_data)
 {
     LaunchTaskBarPlugin *ltbp = (LaunchTaskBarPlugin *)p_data;
@@ -1725,17 +1737,18 @@ static GtkWidget *launchtaskbar_configure(LXPanel *panel, GtkWidget *p)
         SETUP_TOGGLE_BUTTON(checkbutton_same_monitor_only, same_monitor_only);
         SETUP_TOGGLE_BUTTON(checkbutton_mouse_wheel, use_mouse_wheel);
         SETUP_TOGGLE_BUTTON(checkbutton_urgency_hint, use_urgency_hint);
-        //SETUP_TOGGLE_BUTTON(checkbutton_disable_taskbar_upscale, disable_taskbar_upscale);
+        SETUP_TOGGLE_BUTTON(checkbutton_disable_taskbar_upscale, disable_taskbar_upscale);
+        //SETUP_TOGGLE_BUTTON(checkbutton_use_smaller_icons, use_smaller_icons);
 #undef SETUP_TOGGLE_BUTTON
         object = gtk_builder_get_object(builder, "checkbutton_grouped_tasks");
         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(object), ltbp->grouped_tasks);
         g_signal_connect(object, "toggled", G_CALLBACK(on_checkbutton_grouped_tasks_toggled), ltbp);
         /* FIXME: for transitional period, turn into SETUP_TOGGLE_BUTTON later */
-        object = gtk_builder_get_object(builder, "checkbutton_disable_taskbar_upscale");
+        object = gtk_builder_get_object(builder, "checkbutton_use_smaller_icons");
         if (object)
         {
-            gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(object), ltbp->flags.disable_taskbar_upscale);
-            g_signal_connect(object, "toggled", G_CALLBACK(on_checkbutton_disable_taskbar_upscale_toggled), ltbp);
+            gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(object), ltbp->flags.use_smaller_icons);
+            g_signal_connect(object, "toggled", G_CALLBACK(on_checkbutton_use_smaller_icons_toggled), ltbp);
         }
 
 #define SETUP_SPIN_BUTTON(button,member) \
@@ -1797,7 +1810,8 @@ static void launchtaskbar_panel_configuration_changed(LXPanel *panel, GtkWidget
         panel_icon_grid_set_geometry(PANEL_ICON_GRID(ltbp->tb_icon_grid),
             panel_get_orientation(ltbp->panel),
             ((ltbp->flags.icons_only) ? ltbp->icon_size + ICON_ONLY_EXTRA : ltbp->task_width_max),
-            ltbp->icon_size, ltbp->spacing, 0, panel_get_height(ltbp->panel));
+            ((ltbp->flags.icons_only) ? ltbp->icon_size + ICON_ONLY_EXTRA : ltbp->icon_size + ICON_BUTTON_TRIM),
+            ltbp->spacing, 0, panel_get_height(ltbp->panel));
         taskbar_reset_menu(ltbp);
         taskbar_redraw(ltbp);
     }
@@ -1836,6 +1850,8 @@ static void taskbar_redraw(LaunchTaskBarPlugin * tb)
     guint mon = panel_get_monitor(tb->panel);
     guint icon_size = panel_get_icon_size(tb->panel);
 
+    if (tb->flags.use_smaller_icons)
+        icon_size -= 4;
     for (l = children; l; l = l->next)
         task_button_update(l->data, tb->current_desktop, tb->number_of_desktops,
                            mon, icon_size, tb->flags);
index 81d618f..20b9fa3 100644 (file)
@@ -53,7 +53,6 @@
 #include "gtk-compat.h"
 
 #define ALL_WORKSPACES       -1
-#define ICON_BUTTON_TRIM      4      /* Amount needed to have button remain on panel */
 
 /* -----------------------------------------------------------------------------
  * Class data
@@ -1050,9 +1049,7 @@ static void _task_update_icon(TaskButton *task, TaskDetails *details, Atom sourc
     /* Get the icon from the window's hints. */
     if (details != NULL && pixbuf == NULL)
     {
-        pixbuf = get_wm_icon(details->win,
-                             MAX(0, (int)task->icon_size - ICON_BUTTON_TRIM),
-                             MAX(0, (int)task->icon_size - ICON_BUTTON_TRIM),
+        pixbuf = get_wm_icon(details->win, task->icon_size, task->icon_size,
                              source, &details->image_source, task);
         if (pixbuf)
         {
@@ -1455,6 +1452,8 @@ TaskButton *task_button_new(Window win, gint desk, gint desks, LXPanel *panel,
     self->panel = panel;
     self->monitor = panel_get_monitor(panel);
     self->icon_size = panel_get_icon_size(panel);
+    if (flags.use_smaller_icons)
+        self->icon_size -= 4;
     self->res_class = g_strdup(res_class);
     self->flags = flags;
     /* create empty image and label */
index 837ed8e..e6acc6d 100644 (file)
@@ -36,6 +36,7 @@ typedef struct /* bitwise rendering options for taskbar */
     gboolean same_monitor_only : 1;     /* only show windows that are in the same monitor as the taskbar */
     gboolean disable_taskbar_upscale : 1; /* don't upscale taskbar icons */
     gboolean use_net_active : 1;        /* NET_WM_ACTIVE_WINDOW is supported by the window manager */
+    gboolean use_smaller_icons : 1;     /* use icons 4 pixels less than panel default */
 } TaskShowFlags;
 
 #define PANEL_TYPE_TASK_BUTTON             (task_button_get_type())