Commit 9c45e43f authored by Alberts Muktupāvels's avatar Alberts Muktupāvels

data: add theme directory

parent 9162b8b5
......@@ -284,6 +284,10 @@ AC_CONFIG_FILES([
data/48x48/Makefile
data/scalable/Makefile
data/theme/Makefile
data/theme/Adwaita/Makefile
data/theme/HighContrast/Makefile
gnome-panel/Makefile
gnome-panel/libpanel-applet-private/Makefile
gnome-panel/libpanel-util/Makefile
......
SUBDIRS = 16x16 22x22 24x24 32x32 48x48 scalable
NULL =
SUBDIRS = \
16x16 22x22 24x24 32x32 48x48 scalable \
theme \
$(NULL)
gsettings_applets_schemas_in_in = \
org.gnome.gnome-panel.applet.fish.gschema.xml.in.in \
......
NULL =
EXTRA_DIST = \
gnome-panel.css \
gnome-panel-dark.css \
$(NULL)
-include $(top_srcdir)/git.mk
@import url("resource:///org/gnome/panel/Adwaita.css");
@import url("resource:///org/gnome/gnome-panel/theme/common.css");
@import url("resource:///org/gnome/panel/Adwaita.css");
@import url("resource:///org/gnome/gnome-panel/theme/common.css");
NULL =
EXTRA_DIST = \
gnome-panel.css \
gnome-panel-dark.css \
$(NULL)
-include $(top_srcdir)/git.mk
/* HightContrast theme does not have dark variant. */
@import url("resource:///org/gnome/gnome-panel/theme/HighContrast/gnome-panel.css");
@import url("resource:///org/gnome/panel/HighContrast.css");
@import url("resource:///org/gnome/gnome-panel/theme/common.css");
NULL =
SUBDIRS = \
Adwaita \
HighContrast \
$(NULL)
EXTRA_DIST = \
common.css \
$(NULL)
-include $(top_srcdir)/git.mk
/* This file will be included in both themes - Adwaita and HighContrast. */
......@@ -31,7 +31,7 @@ GSList *panel_list = NULL;
static gboolean replace = FALSE;
static gboolean version = FALSE;
static GtkCssProvider *provider = NULL;
static GtkStyleProvider *provider = NULL;
static const GOptionEntry options[] = {
{ "replace", 0, 0, G_OPTION_ARG_NONE, &replace, N_("Replace a currently running panel"), NULL },
......@@ -40,44 +40,49 @@ static const GOptionEntry options[] = {
};
static void
remove_style_provider (GdkScreen *screen)
{
GtkStyleProvider *style_provider;
if (provider == NULL)
return;
style_provider = GTK_STYLE_PROVIDER (provider);
gtk_style_context_remove_provider_for_screen (screen, style_provider);
g_clear_object (&provider);
}
static void
theme_changed (GtkSettings *settings)
theme_changed (GtkSettings *settings,
gpointer user_data)
{
GdkScreen *screen;
gchar *theme;
gchar *theme_name;
gboolean dark_theme;
guint priority;
gchar *resource;
GtkCssProvider *css;
screen = gdk_screen_get_default ();
g_object_get (settings, "gtk-theme-name", &theme, NULL);
remove_style_provider (screen);
if (provider != NULL)
{
gtk_style_context_remove_provider_for_screen (screen, provider);
g_clear_object (&provider);
}
g_object_get (settings, "gtk-theme-name", &theme_name, NULL);
if (g_strcmp0 (theme, "Adwaita") == 0 || g_strcmp0 (theme, "HighContrast") == 0)
if (g_strcmp0 (theme_name, "Adwaita") != 0 &&
g_strcmp0 (theme_name, "HighContrast") != 0)
{
gchar *resource;
g_free (theme_name);
return;
}
provider = gtk_css_provider_new ();
g_object_get (settings,
"gtk-application-prefer-dark-theme", &dark_theme,
NULL);
resource = g_strdup_printf ("/org/gnome/panel/%s.css", theme);
gtk_css_provider_load_from_resource (provider, resource);
g_free (resource);
priority = GTK_STYLE_PROVIDER_PRIORITY_APPLICATION;
resource = g_strdup_printf ("/org/gnome/gnome-panel/theme/%s/gnome-panel%s.css",
theme_name, dark_theme ? "-dark" : "");
gtk_style_context_add_provider_for_screen (screen, GTK_STYLE_PROVIDER (provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
}
css = gtk_css_provider_new ();
provider = GTK_STYLE_PROVIDER (css);
gtk_css_provider_load_from_resource (css, resource);
gtk_style_context_add_provider_for_screen (screen, provider, priority);
g_free (theme);
g_free (theme_name);
g_free (resource);
}
static gboolean
......@@ -162,7 +167,7 @@ main (int argc, char **argv)
settings = gtk_settings_get_default ();
g_signal_connect (settings, "notify::gtk-theme-name", G_CALLBACK (theme_changed), NULL);
theme_changed (settings);
theme_changed (settings, NULL);
gtk_main ();
......
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/gnome/gnome-panel/theme">
<file alias="common.css">../data/theme/common.css</file>
<file alias="Adwaita/gnome-panel.css">../data/theme/Adwaita/gnome-panel.css</file>
<file alias="Adwaita/gnome-panel-dark.css">../data/theme/Adwaita/gnome-panel-dark.css</file>
<file alias="HighContrast/gnome-panel.css">../data/theme/HighContrast/gnome-panel.css</file>
<file alias="HighContrast/gnome-panel-dark.css">../data/theme/HighContrast/gnome-panel-dark.css</file>
</gresource>
<gresource prefix="/org/gnome/panel">
<file compressed="true">panel-addto-dialog.ui</file>
<file compressed="true">panel-properties-dialog.ui</file>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment