From 4437af31ff82629c18f53f6f4c38430547378af9 Mon Sep 17 00:00:00 2001 From: lukefromdc Date: Wed, 18 Apr 2018 23:50:46 -0400 Subject: Theme: consistant theming for applet drag handles in all themes * applet drag-handle: use a symbolic image for the default drag handle image * Use an .svg image with --gtk-recolor (like a symbolic icon), load it from the same directory as the css file so the css parser can find it, and use the theme fg color on it for good contrast * load a css file to use the recolorable image globally for the panel, not for each applet to ensure only one cssprovider is loaded (port of 45b25410cddde852554b3153e81ad59a5e6722ad to 1.18 branch, limiting it to GTK+ 3.20/22) --- data/Makefile.am | 8 +- data/mate-panel.css | 10 ++ data/panel-grid-symbolic.svg | 173 +++++++++++++++++++++ mate-panel/Makefile.am | 1 + .../panel-applet-frame-dbus.c | 68 +------- mate-panel/main.c | 22 +++ 6 files changed, 214 insertions(+), 68 deletions(-) create mode 100644 data/mate-panel.css create mode 100644 data/panel-grid-symbolic.svg diff --git a/data/Makefile.am b/data/Makefile.am index 0f64e315..dc8660bf 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -7,6 +7,11 @@ layout_DATA = \ opensuse.layout \ ubuntu.layout +matepaneldir = $(datadir)/mate-panel +matepanel_DATA = \ + mate-panel.css \ + panel-grid-symbolic.svg + @INTLTOOL_XML_NOMERGE_RULE@ gsettings_ENUM_NAMESPACE = org.mate.panel @@ -27,6 +32,7 @@ gsettings_SCHEMAS = $(panel_gschemas_in:.xml.in=.xml) EXTRA_DIST = \ $(panel_gschemas_in) \ - $(layout_DATA) + $(layout_DATA) \ + $(matepanel_DATA) CLEANFILES = $(gsettings_SCHEMAS) diff --git a/data/mate-panel.css b/data/mate-panel.css new file mode 100644 index 00000000..bfa890d1 --- /dev/null +++ b/data/mate-panel.css @@ -0,0 +1,10 @@ + +MatePanelAppletFrameDBus > MatePanelAppletFrameDBus { + border-style: none; + background-repeat: no-repeat; + background-position: left; + color: @theme_fg_color; + background-image: -gtk-recolor(url("panel-grid-symbolic.svg")); + background-size: 12px 22px; +} + diff --git a/data/panel-grid-symbolic.svg b/data/panel-grid-symbolic.svg new file mode 100644 index 00000000..c057ca53 --- /dev/null +++ b/data/panel-grid-symbolic.svg @@ -0,0 +1,173 @@ + + + + + + + + image/svg+xml + + Gnome Symbolic Icon Theme + + + + + + + + Gnome Symbolic Icon Theme + + + + + + + + + + + + + + + diff --git a/mate-panel/Makefile.am b/mate-panel/Makefile.am index 8c07329d..8fd29697 100644 --- a/mate-panel/Makefile.am +++ b/mate-panel/Makefile.am @@ -15,6 +15,7 @@ AM_CPPFLAGS = \ -DMATELOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \ -DBUILDERDIR=\""$(uidir)"\" \ -DPANELDATADIR=\""$(datadir)/mate-panel"\" \ + -DDATADIR=\""$(datadir)"\" -DICONDIR=\""$(datadir)/mate-panel/pixmaps"\" \ $(DISABLE_DEPRECATED_CFLAGS) diff --git a/mate-panel/libmate-panel-applet-private/panel-applet-frame-dbus.c b/mate-panel/libmate-panel-applet-private/panel-applet-frame-dbus.c index 868dcb33..47be5dcc 100644 --- a/mate-panel/libmate-panel-applet-private/panel-applet-frame-dbus.c +++ b/mate-panel/libmate-panel-applet-private/panel-applet-frame-dbus.c @@ -245,10 +245,7 @@ mate_panel_applet_frame_dbus_change_background (MatePanelAppletFrame *frame, MatePanelAppletFrameDBus *dbus_frame = MATE_PANEL_APPLET_FRAME_DBUS (frame); MatePanelAppletFrameDBusPrivate *priv = dbus_frame->priv; char *bg_str; -#if GTK_CHECK_VERSION (3, 20, 0) - gchar *theme_name; - GtkSettings *settings; -#endif + bg_str = _mate_panel_applet_frame_get_background_string ( frame, PANEL_WIDGET (gtk_widget_get_parent (GTK_WIDGET (frame))), type); @@ -265,69 +262,6 @@ mate_panel_applet_frame_dbus_change_background (MatePanelAppletFrame *frame, g_free (bg_str); } -#if GTK_CHECK_VERSION (3, 20, 0) - GtkCssProvider *provider; - provider = gtk_css_provider_new (); - - settings = gtk_settings_get_default(); - g_object_get (settings, "gtk-theme-name", &theme_name, NULL); - - /*Special case the GNOME high contrast themes*/ - if (g_strcmp0 (theme_name, "HighContrast") == 0 || - g_strcmp0 (theme_name, "HighContrastInverse") == 0){ - gtk_css_provider_load_from_data (provider, - "MatePanelAppletFrameDBus > MatePanelAppletFrameDBus { \n" - "border-style: solid; \n" - "border-width: 3px; \n" - "border-color: @theme_bg_color; \n" - "background-repeat: no-repeat; \n" - "background-position: left; \n" - "background-image: linear-gradient(to bottom, \n" - "@theme_fg_color, \n" - "@theme_fg_color 25%, \n" - "@theme_bg_color 28%, \n" - "@theme_bg_color 33%, \n" - "@theme_fg_color 34%, \n" - "@theme_fg_color 65%, \n" - "@theme_bg_color 66%, \n" - "@theme_bg_color 72%, \n" - "@theme_fg_color 75%, \n" - "@theme_fg_color); \n" - "}", - -1, NULL); - } - else{ - gtk_css_provider_load_from_data (provider, - "MatePanelAppletFrameDBus > MatePanelAppletFrameDBus { \n" - "border-style: solid; \n" - "border-width: 3px; \n" - "border-color: transparent; \n" - "background-repeat: no-repeat; \n" - "background-position: left; \n" - "background-image: linear-gradient(to bottom, \n" - "transparent, \n" - "transparent 20%, \n" - "alpha (#999999, 0.6) 21%, \n" - "alpha (#999999, 0.6) 29%, \n" - "transparent 30%, \n" - "transparent 45%, \n" - "alpha (#999999, 0.6) 46%, \n" - "alpha (#999999, 0.6) 54%, \n" - "transparent 55%, \n" - "transparent 70%, \n" - "alpha (#999999, 0.6) 71%, \n" - "alpha (#999999, 0.6) 79%, \n" - "transparent 80%, \n" - "transparent); \n" - "}", - -1, NULL); - } - gtk_style_context_add_provider (gtk_widget_get_style_context(GTK_WIDGET(frame)), - GTK_STYLE_PROVIDER (provider), - GTK_STYLE_PROVIDER_PRIORITY_FALLBACK); - g_object_unref (provider); - g_free (theme_name); -#endif } static void diff --git a/mate-panel/main.c b/mate-panel/main.c index 8355a227..a0820df0 100644 --- a/mate-panel/main.c +++ b/mate-panel/main.c @@ -60,6 +60,9 @@ main (int argc, char **argv) char *desktopfile; GOptionContext *context; GError *error; +#if GTK_CHECK_VERSION (3, 20, 0) + GtkCssProvider *provider; +#endif bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); @@ -165,6 +168,25 @@ main (int argc, char **argv) * connecting to the session manager */ panel_session_init (); +#if GTK_CHECK_VERSION (3, 20, 0) + /*Load a css file from a path so the drag handle image can be loaded*/ + error = NULL; + provider = gtk_css_provider_new (); + gtk_css_provider_load_from_path (provider, + DATADIR "/mate-panel/" "mate-panel.css", &error); + + if (error != NULL) { + g_warning ("Can't parse mate-panel CSS custom description: %s\n", error->message); + g_error_free (error); + } + else { + gtk_style_context_add_provider_for_screen (gdk_screen_get_default(), + GTK_STYLE_PROVIDER (provider), + GTK_STYLE_PROVIDER_PRIORITY_FALLBACK); + } + g_object_unref (provider); +#endif + gtk_main (); panel_lockdown_finalize (); -- cgit v1.2.1