Clone in a terminal:
Commit 5a3b8c9
Johan Mattsson - 2015-04-24T09:12:14+00:00
5a3b8c9a5b5618c92729e010c47d1714ce911129johan.mattsson.m@gmail.com

Theme selection label in file tools

Changed files (3)

Diff

diff --git a/libbirdfont/FileTools.vala b/libbirdfont/FileTools.valaindex 5cfd7e9..eb3839e 100644--- a/libbirdfont/FileTools.vala+++ b/libbirdfont/FileTools.vala@@ -51,9 +51,39 @@ public class FileTools : ToolCollection  { 			MenuTab.show_settings_tab (); 		});	 		file_tools.add_tool (settings);+		+		Expander themes = new Expander (t_("Themes"));++		foreach (string theme in Theme.themes) {			+			string label;+			LabelTool theme_label;+			+			label = ThemeTab.get_label_from_file_name (theme);+			+			theme_label = new LabelTool (label);+			theme_label.data = theme;+			+			theme_label.select_action.connect((self) => {+				TabBar tb;+				LabelTool s = (LabelTool) self;+				string theme_file = s.data;++				Preferences.set ("theme", theme_file);+				Theme.load_theme (theme_file);++				Toolbox.redraw_tool_box ();+				GlyphCanvas.redraw (); 				+				tb = MainWindow.get_tab_bar ();+				tb.redraw (0, 0, tb.width, tb.height);+			});+			+			themes.add_tool (theme_label);+		}+		 		expanders.add (font_name);					 		expanders.add (file_tools);+		expanders.add (themes); 	}  	public override Gee.ArrayList<string> get_displays () {diff --git a/libbirdfont/LabelTool.vala b/libbirdfont/LabelTool.valaindex 2bbfc5c..88569ac 100644--- a/libbirdfont/LabelTool.vala+++ b/libbirdfont/LabelTool.vala@@ -23,6 +23,7 @@ public class LabelTool : Tool { 	public bool has_counter { get; set; } 	public bool has_delete_button { get; set; } 	public signal void delete_action (LabelTool self);+	public string data = "";  	double counter_box_width = 24; 	double counter_box_height = 11;diff --git a/libbirdfont/ThemeTab.vala b/libbirdfont/ThemeTab.valaindex 1a6c3c7..9e4e049 100644--- a/libbirdfont/ThemeTab.vala+++ b/libbirdfont/ThemeTab.vala@@ -30,7 +30,7 @@ public class ThemeTab : SettingsDisplay { 		 		Gee.ArrayList<Tool> theme_buttons = new Gee.ArrayList<Tool> (); 		-		foreach (string theme in Theme.themes) {			+		foreach (string theme in Theme.themes) { 			string label; 			Tool select_theme = new Tool (theme); 			@@ -62,17 +62,7 @@ public class ThemeTab : SettingsDisplay { 			 			select_theme.set_icon ("theme"); 			-			if (theme == "dark.theme") {-				label = t_("Dark theme");-			} else if (theme == "bright.theme") {-				label = t_("Bright theme");-			} else if (theme == "high_contrast.theme") {-				label = t_("High contrast theme");-			} else if (theme == "custom.theme") {-				label = t_("Custom theme");-			} else {-				label = theme.replace (".theme", "");-			}+			label = get_label_from_file_name (theme); 			 			tools.add (new SettingsItem (select_theme, label)); 			theme_buttons.add (select_theme);@@ -113,6 +103,24 @@ public class ThemeTab : SettingsDisplay { 		}		 	} +	public static string get_label_from_file_name (string theme) {+		string label;+		+		if (theme == "dark.theme") {+			label = t_("Dark");+		} else if (theme == "bright.theme") {+			label = t_("Bright");+		} else if (theme == "high_contrast.theme") {+			label = t_("High contrast");+		} else if (theme == "custom.theme") {+			label = t_("Custom");+		} else {+			label = theme.replace (".theme", "");+		}+		+		return label;+	}+ 	public override string get_label () { 		return t_("Themes"); 	}

Contact

Email: johan.mattsson.m@gmail.com
Mastodon: typo.social/@birdfont
GitHub: johanmattssonm
LinkedIn: johan-mattsson-2ab324112