@@ -1671,47 +1671,6 @@ status_icon_popup_menu_selection_done_cb (GtkMenuShell *menu_shell, gpointer dat
16711671
16721672#define OUTPUT_TITLE_ITEM_BORDER 2
16731673#define OUTPUT_TITLE_ITEM_PADDING 4
1674- static gboolean
1675- output_title_label_draw_cb (GtkWidget * widget , cairo_t * cr , gpointer data )
1676- {
1677- MsdXrandrManager * manager = MSD_XRANDR_MANAGER (data );
1678- struct MsdXrandrManagerPrivate * priv = manager -> priv ;
1679- MateRROutputInfo * output ;
1680- GdkRGBA color ;
1681- GString * string ;
1682- gchar * css , * color_string ;
1683- GtkStyleContext * context ;
1684- GtkCssProvider * provider ;
1685-
1686- output = g_object_get_data (G_OBJECT (widget ), "output" );
1687-
1688- mate_rr_labeler_get_rgba_for_output (priv -> labeler , output , & color );
1689-
1690- color_string = gdk_rgba_to_string (& color );
1691-
1692- /*This can be overriden by themes, check all label:insensitive entries if it does not show up*/
1693- string = g_string_new (NULL );
1694- g_string_append (string , ".mate-panel-menu-bar menuitem.xrandr-applet:disabled>box>label{\n" );
1695- /* g_string_append (string, "color: black;"); Does not work-overridden in all themes*/
1696- g_string_append (string , "padding-left: 4px; padding-right: 4px;" );
1697- g_string_append (string , "border-color: gray;" );
1698- g_string_append (string , "background-color:" );
1699- g_string_append (string , color_string );
1700- g_string_append (string ," }" );
1701-
1702- css = g_string_free (string , FALSE);
1703-
1704- context = gtk_widget_get_style_context (widget );
1705- provider = gtk_css_provider_new ();
1706- gtk_css_provider_load_from_data (provider ,css , -1 , NULL );
1707-
1708- gtk_style_context_add_provider (context ,
1709- GTK_STYLE_PROVIDER (provider ),
1710- GTK_STYLE_PROVIDER_PRIORITY_FALLBACK );
1711- g_object_unref (provider );
1712-
1713- return FALSE;
1714- }
17151674
17161675static void
17171676title_item_size_allocate_cb (GtkWidget * widget , GtkAllocation * allocation , gpointer data )
@@ -1762,40 +1721,18 @@ make_menu_item_for_output_title (MsdXrandrManager *manager, MateRROutputInfo *ou
17621721 GtkWidget * image ;
17631722 GtkWidget * box ;
17641723 char * str ;
1724+ GString * string ;
1725+ GdkRGBA color ;
1726+ gchar * css , * color_string ;
1727+
1728+ struct MsdXrandrManagerPrivate * priv = manager -> priv ;
17651729
17661730 item = gtk_menu_item_new ();
17671731 box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL , 6 );
17681732 image = gtk_image_new_from_icon_name ("computer" , GTK_ICON_SIZE_MENU );
17691733 context = gtk_widget_get_style_context (item );
17701734 gtk_style_context_add_class (context , "xrandr-applet" );
17711735
1772- /*This is NOT overrridden by themes as FALLBACK won't work here
1773- *
1774- *Disable dim/opacity effects applied to icons in an insensitive menu item
1775- *And apply the final label border width and style here
1776- *(style required too because "none" will define zero width)
1777- *before the draw call so label width is defined here
1778- *Draw call is too late and will cause scrollbars to appear from
1779- *delayed expansion of the label
1780- */
1781-
1782- provider = gtk_css_provider_new ();
1783- gtk_css_provider_load_from_data (provider ,
1784- ".mate-panel-menu-bar menuitem.xrandr-applet:disabled>box>image{\n"
1785- "opacity: 1.0; \n"
1786- "-gtk-icon-effect: none; \n"
1787- "}"
1788- ".mate-panel-menu-bar menuitem.xrandr-applet:disabled>box>label{\n"
1789- "border-width: 1px;"
1790- "border-style: inset;"
1791- "}" ,
1792- -1 , NULL );
1793- /*Need to handle both the image and the label, so has to be for screen to work*/
1794- gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
1795- GTK_STYLE_PROVIDER (provider ),
1796- GTK_STYLE_PROVIDER_PRIORITY_APPLICATION );
1797- g_object_unref (provider );
1798-
17991736 g_signal_connect (item , "size-allocate" ,
18001737 G_CALLBACK (title_item_size_allocate_cb ), NULL );
18011738
@@ -1816,10 +1753,53 @@ make_menu_item_for_output_title (MsdXrandrManager *manager, MateRROutputInfo *ou
18161753 gtk_container_add (GTK_CONTAINER (box ), label );
18171754 gtk_container_add (GTK_CONTAINER (item ), box );
18181755
1819- g_signal_connect (label , "draw" ,
1820- G_CALLBACK (output_title_label_draw_cb ), manager );
1756+ mate_rr_labeler_get_rgba_for_output (priv -> labeler , output , & color );
1757+
1758+ color_string = gdk_rgba_to_string (& color );
1759+
1760+ /*This can be overriden by themes, check all label:insensitive entries if it does not show up*/
1761+ string = g_string_new (NULL );
1762+ g_string_append (string , ".mate-panel-menu-bar menuitem.xrandr-applet:disabled>box>label{\n" );
1763+ /*g_string_append (string, "color: black;"); Does not work-overridden in all themes*/
1764+ g_string_append (string , "padding-left: 4px; padding-right: 4px;" );
1765+ g_string_append (string , "border-color: gray;" );
1766+ g_string_append (string ,"border-width: 1px;" );
1767+ g_string_append (string ,"border-style: inset;" );
1768+ g_string_append (string , "background-color:" );
1769+ g_string_append (string , color_string );
1770+ g_string_append (string ," }" );
1771+
1772+ css = g_string_free (string , FALSE);
1773+
1774+ context = gtk_widget_get_style_context (label );
1775+ provider = gtk_css_provider_new ();
1776+ gtk_css_provider_load_from_data (provider ,css , -1 , NULL );
1777+
1778+ gtk_style_context_add_provider (context ,
1779+ GTK_STYLE_PROVIDER (provider ),
1780+ GTK_STYLE_PROVIDER_PRIORITY_FALLBACK );
1781+
1782+ g_object_unref (provider );
1783+ g_free (color_string );
1784+ g_free (css );
1785+
1786+ /*This is NOT overrridden by themes as FALLBACK won't work here
1787+ *Disable dim/opacity effects applied to icons in an insensitive menu item
1788+ */
18211789
1822- g_object_set_data (G_OBJECT (label ), "output" , output );
1790+ context = gtk_widget_get_style_context (image );
1791+ provider = gtk_css_provider_new ();
1792+
1793+ gtk_css_provider_load_from_data (provider ,
1794+ ".mate-panel-menu-bar menuitem.xrandr-applet:disabled>box>image{\n"
1795+ "opacity: 1.0; \n"
1796+ "-gtk-icon-effect: none; \n"
1797+ "}" ,
1798+ -1 , NULL );
1799+ gtk_style_context_add_provider (context ,
1800+ GTK_STYLE_PROVIDER (provider ),
1801+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION );
1802+ g_object_unref (provider );
18231803
18241804 gtk_widget_set_sensitive (item , FALSE); /* the title is not selectable */
18251805
0 commit comments