[gnome-panel/wip/gnome-3.10+: 69/75] theme: add css style for Adwaita theme



commit bc03d40662e35c70fd6a8ab87ca991848d288f48
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Tue Sep 23 20:09:42 2014 +0300

    theme: add css style for Adwaita theme
    
    This is same style that used to live in gnome-themes-standard.

 gnome-panel/Adwaita.css         |   92 +++++++++++++++++++++++++++++++++++++++
 gnome-panel/Makefile.am         |    1 +
 gnome-panel/main.c              |   38 ++++++++++++++++
 gnome-panel/panel.gresource.xml |    1 +
 4 files changed, 132 insertions(+), 0 deletions(-)
---
diff --git a/gnome-panel/Adwaita.css b/gnome-panel/Adwaita.css
new file mode 100644
index 0000000..1506d8d
--- /dev/null
+++ b/gnome-panel/Adwaita.css
@@ -0,0 +1,92 @@
+ define-color os_chrome_bg_color black;
+ define-color os_chrome_fg_color #ccc;
+ define-color os_chrome_selected_bg_color #333;
+ define-color os_chrome_selected_fg_color white;
+
+.gnome-panel-menu-bar,
+PanelApplet > GtkMenuBar.menubar,
+PanelToplevel,
+PanelWidget,
+PanelAppletFrame,
+PanelApplet {
+    background-color: @os_chrome_bg_color;
+    background-image: none;
+    color: @os_chrome_fg_color;
+}
+
+ClockBox,
+.gnome-panel-menu-bar.menubar,
+PanelApplet > GtkMenuBar.menubar {
+    font: bold;
+}
+
+.gnome-panel-menu-bar.menubar .menuitem *:hover,
+PanelApplet > GtkMenuBar.menubar .menuitem *:hover {
+    text-shadow: 0 1px @os_chrome_bg_color;
+}
+
+.gnome-panel-menu-bar.menubar .menu,
+PanelApplet > GtkMenuBar.menubar .menu {
+    font: regular;
+}
+
+.gnome-panel-menu-bar.menubar .menu *:hover,
+PanelApplet > GtkMenuBar.menubar .menu *:hover {
+    text-shadow: none;
+}
+
+.gnome-panel-menu-bar .menuitem:hover,
+PanelApplet > GtkMenuBar.menubar .menuitem:hover,
+.gnome-panel-menu-bar .menuitem *:hover,
+PanelApplet > GtkMenuBar.menubar .menuitem *:hover {
+    background-color: @os_chrome_selected_bg_color;
+    color: @os_chrome_selected_fg_color;
+}
+
+.gnome-panel-menu-bar .menuitem *:hover,
+PanelApplet > GtkMenuBar.menubar .menuitem *:hover {
+    color: @os_chrome_selected_fg_color;
+}
+
+PanelApplet .button,
+PanelApplet .button:hover {
+    padding: 4px;
+
+    border-image: none;
+    border-width: 0;
+    border-radius: 0;
+
+    background-image: none;
+    background-color: @os_chrome_bg_color;
+
+    color: @os_chrome_fg_color;
+    text-shadow: none;
+}
+
+PanelApplet .button:active:hover,
+PanelApplet .button:active {
+    border-image: none;
+    background-image: none;
+    background-color: @os_chrome_selected_bg_color;
+    border-width: 0;
+    border-radius: 0;
+}
+
+PanelApplet *:hover {
+    color: @os_chrome_selected_fg_color;
+}
+
+PanelApplet *:active,
+PanelApplet *:hover:active {
+    color: @os_chrome_selected_fg_color;
+    text-shadow: 0 1px @os_chrome_bg_color;
+}
+
+WnckPager {
+    background-color: lighter(@os_chrome_selected_bg_color);
+}
+
+NaTrayApplet {
+    -NaTrayApplet-icon-padding: 12;
+    -NaTrayApplet-icon-size: 16;
+}
diff --git a/gnome-panel/Makefile.am b/gnome-panel/Makefile.am
index 3e0227e..bc70305 100644
--- a/gnome-panel/Makefile.am
+++ b/gnome-panel/Makefile.am
@@ -256,6 +256,7 @@ desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
 EXTRA_DIST =                                   \
        $(ui_FILES)                             \
        panel.gresource.xml                     \
+       Adwaita.css \
        $(uitest_FILES)                         \
        panel-test-applets.gresource.xml        \
        nothing.cP                              \
diff --git a/gnome-panel/main.c b/gnome-panel/main.c
index 776f280..dbeb19c 100644
--- a/gnome-panel/main.c
+++ b/gnome-panel/main.c
@@ -36,18 +36,52 @@ GSList *panels = NULL;
 GSList *panel_list = NULL;
 
 static gboolean  replace = FALSE;
+static GtkCssProvider *provider = NULL;
 
 static const GOptionEntry options[] = {
   { "replace", 0, 0, G_OPTION_ARG_NONE, &replace, N_("Replace a currently running panel"), NULL },
   { NULL }
 };
 
+static void
+theme_changed (GtkSettings *settings)
+{
+       GdkScreen *screen;
+       gchar     *theme;
+
+       screen = gdk_screen_get_default ();
+       g_object_get (settings, "gtk-theme-name", &theme, NULL);
+
+       if (g_str_equal (theme, "Adwaita")) {
+               if (provider == NULL) {
+                       GFile *file;
+
+                       file = g_file_new_for_uri ("resource:///org/gnome/panel/Adwaita.css");
+                       provider = gtk_css_provider_new ();
+
+                       gtk_css_provider_load_from_file (provider, file, NULL);
+
+                       g_object_unref (file);
+               }
+
+               gtk_style_context_add_provider_for_screen (screen, GTK_STYLE_PROVIDER (provider),
+                                                          GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+       } else if (provider != NULL) {
+               gtk_style_context_remove_provider_for_screen (screen, GTK_STYLE_PROVIDER (provider));
+               g_object_unref (provider);
+               provider = NULL;
+       }
+
+       g_free (theme);
+}
+
 int
 main (int argc, char **argv)
 {
        char           *desktopfile;
        GOptionContext *context;
        GError         *error;
+       GtkSettings    *settings;
 
        bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
        bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
@@ -111,6 +145,10 @@ main (int argc, char **argv)
         * connecting to the session manager */
        panel_session_init ();
 
+       settings = gtk_settings_get_default ();
+       g_signal_connect (settings, "notify::gtk-theme-name", G_CALLBACK (theme_changed), NULL);
+       theme_changed (settings);
+
        gtk_main ();
 
        panel_cleanup_do ();
diff --git a/gnome-panel/panel.gresource.xml b/gnome-panel/panel.gresource.xml
index 40b9380..0fb1e14 100644
--- a/gnome-panel/panel.gresource.xml
+++ b/gnome-panel/panel.gresource.xml
@@ -4,5 +4,6 @@
     <file compressed="true">panel-properties-dialog.ui</file>
     <file compressed="true">panel-run-dialog.ui</file>
     <file alias="anim/wanda.png">../applets/fish/wanda.png</file>
+    <file>Adwaita.css</file>
   </gresource>
 </gresources>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]