[Xfce4-commits] [xfce/xfce4-panel] 01/02: tasklist: Allow to hide label decorations (Bug #10546)

noreply at xfce.org noreply at xfce.org
Sun Oct 15 21:48:13 CEST 2017


This is an automated email from the git hooks/post-receive script.

o   c   h   o   s   i       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository xfce/xfce4-panel.

commit e445b2fab57d43b72d34c69d81cf442acf707737
Author: Viktor Odintsev <ninetls at xfce.org>
Date:   Wed Sep 13 00:32:55 2017 +0300

    tasklist: Allow to hide label decorations (Bug #10546)
---
 plugins/tasklist/tasklist-widget.c | 84 ++++++++++++++++++++++++++++++++++----
 plugins/tasklist/tasklist.c        |  1 +
 2 files changed, 76 insertions(+), 9 deletions(-)

diff --git a/plugins/tasklist/tasklist-widget.c b/plugins/tasklist/tasklist-widget.c
index 9dfe197..faac732 100644
--- a/plugins/tasklist/tasklist-widget.c
+++ b/plugins/tasklist/tasklist-widget.c
@@ -92,7 +92,8 @@ enum
   PROP_WINDOW_SCROLLING,
   PROP_WRAP_WINDOWS,
   PROP_INCLUDE_ALL_BLINKING,
-  PROP_MIDDLE_CLICK
+  PROP_MIDDLE_CLICK,
+  PROP_LABEL_DECORATIONS
 };
 
 struct _XfceTasklistClass
@@ -161,6 +162,9 @@ struct _XfceTasklist
   /* action to preform when middle clicking */
   XfceTasklistMClick    middle_click;
 
+  /* whether decorate labels when window is not visible */
+  guint                 label_decorations : 1;
+
   /* whether we only show windows that are in the geometry of
    * the monitor the tasklist is on */
   guint                 all_monitors : 1;
@@ -355,6 +359,8 @@ static void               xfce_tasklist_set_show_only_minimized          (XfceTa
                                                                           gboolean              only_minimized);
 static void               xfce_tasklist_set_show_wireframes              (XfceTasklist         *tasklist,
                                                                           gboolean              show_wireframes);
+static void               xfce_tasklist_set_label_decorations            (XfceTasklist         *tasklist,
+                                                                          gboolean              label_decorations);
 static void               xfce_tasklist_set_grouping                     (XfceTasklist         *tasklist,
                                                                           XfceTasklistGrouping  grouping);
 
@@ -494,6 +500,13 @@ xfce_tasklist_class_init (XfceTasklistClass *klass)
                                                       XFCE_TASKLIST_MIDDLE_CLICK_DEFAULT,
                                                       G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
+  g_object_class_install_property (gobject_class,
+                                   PROP_LABEL_DECORATIONS,
+                                   g_param_spec_boolean ("label-decorations",
+                                                         NULL, NULL,
+                                                         TRUE,
+                                                         G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
   gtk_widget_class_install_style_property (gtkwidget_class,
                                            g_param_spec_int ("max-button-length",
                                                              NULL,
@@ -572,6 +585,7 @@ xfce_tasklist_init (XfceTasklist *tasklist)
   tasklist->wrap_windows = FALSE;
   tasklist->all_blinking = TRUE;
   tasklist->middle_click = XFCE_TASKLIST_MIDDLE_CLICK_DEFAULT;
+  tasklist->label_decorations = TRUE;
   xfce_tasklist_geometry_set_invalid (tasklist);
 #ifdef GDK_WINDOWING_X11
   tasklist->wireframe_window = 0;
@@ -673,6 +687,10 @@ xfce_tasklist_get_property (GObject    *object,
       g_value_set_uint (value, tasklist->middle_click);
       break;
 
+    case PROP_LABEL_DECORATIONS:
+      g_value_set_boolean (value, tasklist->label_decorations);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -755,6 +773,10 @@ xfce_tasklist_set_property (GObject      *object,
       tasklist->middle_click= g_value_get_uint (value);
       break;
 
+    case PROP_LABEL_DECORATIONS:
+      xfce_tasklist_set_label_decorations (tasklist, g_value_get_boolean (value));
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -2130,6 +2152,7 @@ static XfceTasklistChild *
 xfce_tasklist_child_new (XfceTasklist *tasklist)
 {
   XfceTasklistChild *child;
+  GtkCssProvider    *provider;
 
   panel_return_val_if_fail (XFCE_IS_TASKLIST (tasklist), NULL);
 
@@ -2172,6 +2195,12 @@ xfce_tasklist_child_new (XfceTasklist *tasklist)
       gtk_label_set_angle (GTK_LABEL (child->label), 270);
       /* TODO can we already ellipsize here yet? */
     }
+  provider = gtk_css_provider_new ();
+  gtk_css_provider_load_from_data (provider, ".label-hidden { opacity: 0.75; }", -1, NULL);
+  gtk_style_context_add_provider (gtk_widget_get_style_context (child->label),
+                                  GTK_STYLE_PROVIDER (provider),
+                                  GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+  g_object_unref (provider);
 
   /* don't show the label if we're in iconbox style */
   if (tasklist->show_labels)
@@ -2544,8 +2573,9 @@ static void
 xfce_tasklist_button_name_changed (WnckWindow        *window,
                                    XfceTasklistChild *child)
 {
-  const gchar *name;
-  gchar       *label = NULL;
+  const gchar     *name;
+  gchar           *label = NULL;
+  GtkStyleContext *ctx;
 
   panel_return_if_fail (window == NULL || child->window == window);
   panel_return_if_fail (WNCK_IS_WINDOW (child->window));
@@ -2554,12 +2584,25 @@ xfce_tasklist_button_name_changed (WnckWindow        *window,
   name = wnck_window_get_name (child->window);
   gtk_widget_set_tooltip_text (GTK_WIDGET (child->button), name);
 
-  /* create the button label */
-  if (!child->tasklist->only_minimized
-      && wnck_window_is_minimized (child->window))
-    name = label = g_strdup_printf ("[%s]", name);
-  else if (wnck_window_is_shaded (child->window))
-    name = label = g_strdup_printf ("=%s=", name);
+  ctx = gtk_widget_get_style_context (child->label);
+  gtk_style_context_remove_class (ctx, "label-hidden");
+
+  if (child->tasklist->label_decorations)
+    {
+      /* create the button label */
+      if (!child->tasklist->only_minimized
+          && wnck_window_is_minimized (child->window))
+        name = label = g_strdup_printf ("[%s]", name);
+      else if (wnck_window_is_shaded (child->window))
+        name = label = g_strdup_printf ("=%s=", name);
+    }
+  else
+    {
+      if ((!child->tasklist->only_minimized
+          && wnck_window_is_minimized (child->window))
+          || wnck_window_is_shaded (child->window))
+        gtk_style_context_add_class (ctx, "label-hidden");
+    }
 
   gtk_label_set_text (GTK_LABEL (child->label), name);
 
@@ -3987,6 +4030,29 @@ xfce_tasklist_set_show_wireframes (XfceTasklist *tasklist,
 
 
 static void
+xfce_tasklist_set_label_decorations (XfceTasklist *tasklist,
+                                     gboolean      label_decorations)
+{
+  GList             *li;
+  XfceTasklistChild *child;
+
+  panel_return_if_fail (XFCE_IS_TASKLIST (tasklist));
+
+  if (tasklist->label_decorations != label_decorations)
+    {
+      tasklist->label_decorations = label_decorations;
+
+      for (li = tasklist->windows; li != NULL; li = li->next)
+        {
+          child = li->data;
+          xfce_tasklist_button_name_changed (NULL, child);
+        }
+    }
+}
+
+
+
+static void
 xfce_tasklist_set_grouping (XfceTasklist         *tasklist,
                             XfceTasklistGrouping  grouping)
 {
diff --git a/plugins/tasklist/tasklist.c b/plugins/tasklist/tasklist.c
index e416713..8c06596 100644
--- a/plugins/tasklist/tasklist.c
+++ b/plugins/tasklist/tasklist.c
@@ -150,6 +150,7 @@ tasklist_plugin_construct (XfcePanelPlugin *panel_plugin)
     { "wrap-windows", G_TYPE_BOOLEAN },
     { "include-all-blinking", G_TYPE_BOOLEAN },
     { "middle-click", G_TYPE_UINT },
+    { "label-decorations", G_TYPE_BOOLEAN },
     { NULL }
   };
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list