[gnome-mines/wip/theming-support] Moved default theme resources to theme directory
- From: Robert Roth <robertroth src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-mines/wip/theming-support] Moved default theme resources to theme directory
- Date: Sun, 4 Jan 2015 02:22:44 +0000 (UTC)
commit 20be5041d112c896841eef0c66ff27f09701c795
Author: Robert Roth <robert roth off gmail com>
Date: Sun Jan 4 04:22:26 2015 +0200
Moved default theme resources to theme directory
configure.ac | 2 +
data/Makefile.am | 21 ++---------
data/gnome-mines.css | 11 ++++++
data/themes/Makefile.am | 3 ++
data/{ => themes/default}/1mines.svg | 0
data/{ => themes/default}/2mines.svg | 0
data/{ => themes/default}/3mines.svg | 0
data/{ => themes/default}/4mines.svg | 0
data/{ => themes/default}/5mines.svg | 0
data/{ => themes/default}/6mines.svg | 0
data/{ => themes/default}/7mines.svg | 0
data/{ => themes/default}/8mines.svg | 0
data/themes/default/Makefile.am | 9 +++++
data/{ => themes/default}/exploded.svg | 0
data/{ => themes/default}/flag.svg | 0
data/{ => themes/default}/maybe.svg | 0
data/{ => themes/default}/mine.svg | 0
data/{ => themes/default}/overmine.svg | 0
.../default/theme.css} | 24 +++----------
src/gnome-mines.vala | 36 +++++++++++++++++++-
20 files changed, 69 insertions(+), 37 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 4098fdb..84822cb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -53,6 +53,8 @@ data/Makefile
data/icons/Makefile
data/icons/hicolor/Makefile
data/icons/HighContrast/Makefile
+data/themes/Makefile
+data/themes/default/Makefile
help/Makefile
src/Makefile
])
diff --git a/data/Makefile.am b/data/Makefile.am
index 2be8ed4..bb1a14c 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -1,26 +1,15 @@
-SUBDIRS = icons
+SUBDIRS = icons themes
gsettings_SCHEMAS = org.gnome.mines.gschema.xml
@GSETTINGS_RULES@
man_MANS = gnome-mines.6
-pixmapdir = $(pkgdatadir)
-pixmap_DATA = mine.svg exploded.svg overmine.svg \
- 1mines.svg 2mines.svg 3mines.svg 4mines.svg \
- 5mines.svg 6mines.svg 7mines.svg 8mines.svg \
- flag.svg flag-symbolic.svg maybe.svg
-
-
icon_symbolicdir=$(datadir)/icons/hicolor/16x16/actions
icon_symbolic_DATA=flag-symbolic.svg
-gnome-mines.css: gnome-mines.css.in Makefile
- $(AM_V_GEN) sed -e "s|\ pkgdatadir\@|$(pkgdatadir)|" $< > $@
-
cssdir = $(pkgdatadir)
-css_in_files = gnome-mines.css.in
-css_DATA = $(css_in_files:.css.in=.css)
+css_DATA = gnome-mines.css
uidir = $(pkgdatadir)
ui_DATA = interface.ui
@@ -40,15 +29,13 @@ EXTRA_DIST = \
$(gsettings_SCHEMAS) \
$(desktop_in_files) \
$(man_MANS) \
- $(pixmap_DATA) \
$(icon_symbolic_DATA) \
- $(css_in_files) \
+ $(css_DATA) \
$(ui_DATA)
CLEANFILES = \
$(appstream_XML) \
- $(desktop_DATA) \
- $(css_DATA)
+ $(desktop_DATA)
check-local: $(desktop_DATA) \
$(DESKTOP_FILE_VALIDATE) $(desktop_DATA)
diff --git a/data/gnome-mines.css b/data/gnome-mines.css
new file mode 100644
index 0000000..ff0d6fa
--- /dev/null
+++ b/data/gnome-mines.css
@@ -0,0 +1,11 @@
+.pausedOverlay {
+ background-color:#babdb6;
+ color: white;
+ font-size:32px;
+ border-radius: 3px;
+}
+
+.pausedOverlay:backdrop {
+ background-color: shade(#babdb6,1.1);
+}
+
diff --git a/data/themes/Makefile.am b/data/themes/Makefile.am
new file mode 100644
index 0000000..6bf2660
--- /dev/null
+++ b/data/themes/Makefile.am
@@ -0,0 +1,3 @@
+SUBDIRS = default
+
+-include $(top_srcdir)/git.mk
diff --git a/data/1mines.svg b/data/themes/default/1mines.svg
similarity index 100%
rename from data/1mines.svg
rename to data/themes/default/1mines.svg
diff --git a/data/2mines.svg b/data/themes/default/2mines.svg
similarity index 100%
rename from data/2mines.svg
rename to data/themes/default/2mines.svg
diff --git a/data/3mines.svg b/data/themes/default/3mines.svg
similarity index 100%
rename from data/3mines.svg
rename to data/themes/default/3mines.svg
diff --git a/data/4mines.svg b/data/themes/default/4mines.svg
similarity index 100%
rename from data/4mines.svg
rename to data/themes/default/4mines.svg
diff --git a/data/5mines.svg b/data/themes/default/5mines.svg
similarity index 100%
rename from data/5mines.svg
rename to data/themes/default/5mines.svg
diff --git a/data/6mines.svg b/data/themes/default/6mines.svg
similarity index 100%
rename from data/6mines.svg
rename to data/themes/default/6mines.svg
diff --git a/data/7mines.svg b/data/themes/default/7mines.svg
similarity index 100%
rename from data/7mines.svg
rename to data/themes/default/7mines.svg
diff --git a/data/8mines.svg b/data/themes/default/8mines.svg
similarity index 100%
rename from data/8mines.svg
rename to data/themes/default/8mines.svg
diff --git a/data/themes/default/Makefile.am b/data/themes/default/Makefile.am
new file mode 100644
index 0000000..c810ed7
--- /dev/null
+++ b/data/themes/default/Makefile.am
@@ -0,0 +1,9 @@
+themedir = $(pkgdatadir)/themes/default
+theme_DATA = mine.svg exploded.svg overmine.svg \
+ 1mines.svg 2mines.svg 3mines.svg 4mines.svg \
+ 5mines.svg 6mines.svg 7mines.svg 8mines.svg \
+ flag.svg maybe.svg theme.css
+
+EXTRA_DIST = ${theme_DATA}
+
+-include $(top_srcdir)/git.mk
diff --git a/data/exploded.svg b/data/themes/default/exploded.svg
similarity index 100%
rename from data/exploded.svg
rename to data/themes/default/exploded.svg
diff --git a/data/flag.svg b/data/themes/default/flag.svg
similarity index 100%
rename from data/flag.svg
rename to data/themes/default/flag.svg
diff --git a/data/maybe.svg b/data/themes/default/maybe.svg
similarity index 100%
rename from data/maybe.svg
rename to data/themes/default/maybe.svg
diff --git a/data/mine.svg b/data/themes/default/mine.svg
similarity index 100%
rename from data/mine.svg
rename to data/themes/default/mine.svg
diff --git a/data/overmine.svg b/data/themes/default/overmine.svg
similarity index 100%
rename from data/overmine.svg
rename to data/themes/default/overmine.svg
diff --git a/data/gnome-mines.css.in b/data/themes/default/theme.css
similarity index 71%
rename from data/gnome-mines.css.in
rename to data/themes/default/theme.css
index 0b30f6e..23bd9ef 100644
--- a/data/gnome-mines.css.in
+++ b/data/themes/default/theme.css
@@ -1,12 +1,4 @@
-/*
-You can type here any CSS rule recognized by GTK+.
-You can temporarily disable this custom CSS by clicking on the "Pause" button above.
-
-Changes are applied instantly and globally, for the whole application.
-*/
-
-/* Standard 1px border for all styles */
-
+/* Common style for all tiles */
.tile {
background-image:none;
background-color:#babdb6;
@@ -34,6 +26,7 @@ Changes are applied instantly and globally, for the whole application.
box-shadow: inset 0 2px 1px rgba(0,0,0,.2);
}
+/* Style for revealed fields showing numbers */
.count {
color:black;
font-size:0px;
@@ -46,24 +39,17 @@ Changes are applied instantly and globally, for the whole application.
background-color:#dededc;
}
+/* Style for mines */
.mine {
background-color:#729fcf;
}
+/* Style of the keyboard cursor */
.cursor {
background-color:#e9b96e;
}
-.pausedOverlay {
- background-color:#babdb6;
- color: white;
- font-size:32px;
- border-radius: 3px;
-}
- .pausedOverlay:backdrop {
- background-color: shade(#babdb6,1.1);
- }
-
+/* Style of the unrevealed tiles after game over */
.explodedField .tile {
background-color:#888a85;
transition-duration:1s;
diff --git a/src/gnome-mines.vala b/src/gnome-mines.vala
index a32f61e..d1b52ee 100644
--- a/src/gnome-mines.vala
+++ b/src/gnome-mines.vala
@@ -75,6 +75,7 @@ public class Mines : Gtk.Application
private SimpleAction pause_action;
private Gtk.AspectFrame new_game_screen;
private Gtk.AspectFrame custom_game_screen;
+ private Gtk.CssProvider theme_provider;
private const OptionEntry[] option_entries =
{
@@ -104,6 +105,39 @@ public class Mines : Gtk.Application
add_main_option_entries (option_entries);
}
+ private void set_game_theme (string theme)
+ {
+ string theme_path = theme;
+ bool is_switch = theme_provider != null;
+
+ if (!Path.is_absolute (theme_path)) {
+ theme_path = Path.build_path (Path.DIR_SEPARATOR_S, DATA_DIRECTORY, "themes", theme);
+ }
+ if (!is_switch) {
+ Gtk.IconTheme.get_default ().append_search_path (theme_path);
+ } else {
+ string[] icon_search_path;
+ Gtk.IconTheme.get_default ().get_search_path (out icon_search_path);
+ icon_search_path[icon_search_path.length - 1] = theme_path;
+ Gtk.IconTheme.get_default ().set_search_path (icon_search_path);
+ }
+
+ var theme_css_path = Path.build_filename (theme_path, "theme.css");
+ try
+ {
+ if (is_switch) {
+ Gtk.StyleContext.remove_provider_for_screen (Gdk.Screen.get_default (), theme_provider);
+ }
+ theme_provider = new Gtk.CssProvider ();
+ theme_provider.load_from_path (theme_css_path);
+ Gtk.StyleContext.add_provider_for_screen (Gdk.Screen.get_default (), theme_provider,
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
+ }
+ catch (GLib.Error e)
+ {
+ warning ("Error loading css styles from %s: %s", theme_css_path, e.message);
+ }
+ }
+
protected override void startup ()
{
base.startup ();
@@ -140,7 +174,7 @@ public class Mines : Gtk.Application
warning ("Could not load game UI: %s", e.message);
}
- Gtk.IconTheme.get_default ().append_search_path (DATA_DIRECTORY);
+ set_game_theme ("default");
add_action_entries (action_entries, this);
new_game_action = lookup_action ("new-game") as SimpleAction;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]