summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/xrandr/msd-xrandr-manager.c122
1 files changed, 51 insertions, 71 deletions
diff --git a/plugins/xrandr/msd-xrandr-manager.c b/plugins/xrandr/msd-xrandr-manager.c
index c82d7e9..c58ecf5 100644
--- a/plugins/xrandr/msd-xrandr-manager.c
+++ b/plugins/xrandr/msd-xrandr-manager.c
@@ -1671,47 +1671,6 @@ status_icon_popup_menu_selection_done_cb (GtkMenuShell *menu_shell, gpointer dat
#define OUTPUT_TITLE_ITEM_BORDER 2
#define OUTPUT_TITLE_ITEM_PADDING 4
-static gboolean
-output_title_label_draw_cb (GtkWidget *widget, cairo_t *cr, gpointer data)
-{
- MsdXrandrManager *manager = MSD_XRANDR_MANAGER (data);
- struct MsdXrandrManagerPrivate *priv = manager->priv;
- MateRROutputInfo *output;
- GdkRGBA color;
- GString *string;
- gchar *css, *color_string;
- GtkStyleContext *context;
- GtkCssProvider *provider;
-
- output = g_object_get_data (G_OBJECT (widget), "output");
-
- mate_rr_labeler_get_rgba_for_output (priv->labeler, output, &color);
-
- color_string = gdk_rgba_to_string (&color);
-
- /*This can be overriden by themes, check all label:insensitive entries if it does not show up*/
- string = g_string_new(NULL);
- g_string_append (string, ".mate-panel-menu-bar menuitem.xrandr-applet:disabled>box>label{\n");
- /* g_string_append (string, "color: black;"); Does not work-overridden in all themes*/
- g_string_append (string, "padding-left: 4px; padding-right: 4px;");
- g_string_append (string, "border-color: gray;");
- g_string_append (string, "background-color:");
- g_string_append (string, color_string);
- g_string_append (string," }");
-
- css = g_string_free (string, FALSE);
-
- context = gtk_widget_get_style_context (widget);
- provider = gtk_css_provider_new ();
- gtk_css_provider_load_from_data (provider,css, -1, NULL);
-
- gtk_style_context_add_provider (context,
- GTK_STYLE_PROVIDER (provider),
- GTK_STYLE_PROVIDER_PRIORITY_FALLBACK);
- g_object_unref (provider);
-
- return FALSE;
-}
static void
title_item_size_allocate_cb (GtkWidget *widget, GtkAllocation *allocation, gpointer data)
@@ -1762,6 +1721,11 @@ make_menu_item_for_output_title (MsdXrandrManager *manager, MateRROutputInfo *ou
GtkWidget *image;
GtkWidget *box;
char *str;
+ GString *string;
+ GdkRGBA color;
+ gchar *css, *color_string;
+
+ struct MsdXrandrManagerPrivate *priv = manager->priv;
item = gtk_menu_item_new ();
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
@@ -1769,33 +1733,6 @@ make_menu_item_for_output_title (MsdXrandrManager *manager, MateRROutputInfo *ou
context = gtk_widget_get_style_context (item);
gtk_style_context_add_class (context, "xrandr-applet");
- /*This is NOT overrridden by themes as FALLBACK won't work here
- *
- *Disable dim/opacity effects applied to icons in an insensitive menu item
- *And apply the final label border width and style here
- *(style required too because "none" will define zero width)
- *before the draw call so label width is defined here
- *Draw call is too late and will cause scrollbars to appear from
- *delayed expansion of the label
- */
-
- provider = gtk_css_provider_new ();
- gtk_css_provider_load_from_data (provider,
- ".mate-panel-menu-bar menuitem.xrandr-applet:disabled>box>image{\n"
- "opacity: 1.0; \n"
- "-gtk-icon-effect: none; \n"
- "}"
- ".mate-panel-menu-bar menuitem.xrandr-applet:disabled>box>label{\n"
- "border-width: 1px;"
- "border-style: inset;"
- "}",
- -1, NULL);
- /*Need to handle both the image and the label, so has to be for screen to work*/
- gtk_style_context_add_provider_for_screen (gdk_screen_get_default(),
- GTK_STYLE_PROVIDER (provider),
- GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
- g_object_unref (provider);
-
g_signal_connect (item, "size-allocate",
G_CALLBACK (title_item_size_allocate_cb), NULL);
@@ -1816,10 +1753,53 @@ make_menu_item_for_output_title (MsdXrandrManager *manager, MateRROutputInfo *ou
gtk_container_add (GTK_CONTAINER (box), label);
gtk_container_add (GTK_CONTAINER (item), box);
- g_signal_connect (label, "draw",
- G_CALLBACK (output_title_label_draw_cb), manager);
+ mate_rr_labeler_get_rgba_for_output (priv->labeler, output, &color);
+
+ color_string = gdk_rgba_to_string (&color);
+
+ /*This can be overriden by themes, check all label:insensitive entries if it does not show up*/
+ string = g_string_new(NULL);
+ g_string_append (string, ".mate-panel-menu-bar menuitem.xrandr-applet:disabled>box>label{\n");
+ /*g_string_append (string, "color: black;"); Does not work-overridden in all themes*/
+ g_string_append (string, "padding-left: 4px; padding-right: 4px;");
+ g_string_append (string, "border-color: gray;");
+ g_string_append (string,"border-width: 1px;");
+ g_string_append (string,"border-style: inset;");
+ g_string_append (string, "background-color:");
+ g_string_append (string, color_string);
+ g_string_append (string," }");
+
+ css = g_string_free (string, FALSE);
+
+ context = gtk_widget_get_style_context (label);
+ provider = gtk_css_provider_new ();
+ gtk_css_provider_load_from_data (provider,css, -1, NULL);
+
+ gtk_style_context_add_provider (context,
+ GTK_STYLE_PROVIDER (provider),
+ GTK_STYLE_PROVIDER_PRIORITY_FALLBACK);
+
+ g_object_unref (provider);
+ g_free (color_string);
+ g_free (css);
+
+ /*This is NOT overrridden by themes as FALLBACK won't work here
+ *Disable dim/opacity effects applied to icons in an insensitive menu item
+ */
- g_object_set_data (G_OBJECT (label), "output", output);
+ context = gtk_widget_get_style_context (image);
+ provider = gtk_css_provider_new ();
+
+ gtk_css_provider_load_from_data (provider,
+ ".mate-panel-menu-bar menuitem.xrandr-applet:disabled>box>image{\n"
+ "opacity: 1.0; \n"
+ "-gtk-icon-effect: none; \n"
+ "}",
+ -1, NULL);
+ gtk_style_context_add_provider (context,
+ GTK_STYLE_PROVIDER (provider),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ g_object_unref (provider);
gtk_widget_set_sensitive (item, FALSE); /* the title is not selectable */