From 3979780408a42a44f33f2ffd3976850a7eff26ee Mon Sep 17 00:00:00 2001 From: Viktor Odintsev Date: Sat, 24 Jun 2017 13:16:14 +0300 Subject: [PATCH] Allow to hide label decorations in tasklist --- plugins/tasklist/tasklist-widget.c | 59 ++++++++++++++++++++++++++++++++------ plugins/tasklist/tasklist.c | 1 + 2 files changed, 51 insertions(+), 9 deletions(-) diff --git a/plugins/tasklist/tasklist-widget.c b/plugins/tasklist/tasklist-widget.c index d75fc91d..dba8b77f 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; @@ -494,6 +498,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 +583,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 +685,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 +771,10 @@ xfce_tasklist_set_property (GObject *object, tasklist->middle_click= g_value_get_uint (value); break; + case PROP_LABEL_DECORATIONS: + tasklist->label_decorations = g_value_get_boolean (value); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -2117,6 +2137,7 @@ static XfceTasklistChild * xfce_tasklist_child_new (XfceTasklist *tasklist) { XfceTasklistChild *child; + GtkCssProvider *provider; panel_return_val_if_fail (XFCE_IS_TASKLIST (tasklist), NULL); @@ -2157,6 +2178,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) @@ -2529,8 +2556,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)); @@ -2539,12 +2567,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); diff --git a/plugins/tasklist/tasklist.c b/plugins/tasklist/tasklist.c index e4167139..8c06596d 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 } }; -- 2.13.3