The Birdfont Source Code
Store order for theme colors in setting tab
These changes was commited to the Birdfont repository Sat, 14 Mar 2015 11:46:07 +0000.
Contributing
Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
Store order for theme colors in setting tab
--- a/libbirdfont/BirdFont.vala
+++ b/libbirdfont/BirdFont.vala
@@ -428,10 +428,7 @@
Preferences.load ();
- // FIXME: DELETE
- Theme.load_theme ();
- save_default_colors ();
-
+ Theme.set_default_colors ();
Theme.load_theme ();
current_font = new Font ();
@@ -499,85 +496,6 @@
public static Argument get_arguments () {
return args;
- }
-
- void save_default_colors () {
- Theme.save_color ("Background 1", 1, 1, 1, 1);
- Theme.save_color ("Background 2", 101 / 255.0, 108 / 255.0, 116 / 255.0, 1);
- Theme.save_color ("Background 3", 38 / 255.0, 39 / 255.0, 43 / 255.0, 1);
- Theme.save_color ("Background 4", 51 / 255.0, 54 / 255.0, 59 / 255.0, 1);
- Theme.save_color ("Background 5", 0.3, 0.3, 0.3, 1);
- Theme.save_color ("Background 6", 224/255.0, 224/255.0, 224/255.0, 1);
- Theme.save_color ("Background 7", 56 / 255.0, 59 / 255.0, 65 / 255.0, 1);
- Theme.save_color ("Background 8", 55/255.0, 55/255.0, 55/255.0, 1);
- Theme.save_color ("Background 9", 72/255.0, 72/255.0, 72/255.0, 1);
-
- Theme.save_color ("Foreground 1", 0, 0, 0, 1);
- Theme.save_color ("Foreground 2", 101 / 255.0, 108 / 255.0, 116 / 255.0, 1);
- Theme.save_color ("Foreground 3", 26 / 255.0, 30 / 255.0, 32 / 255.0, 1);
- Theme.save_color ("Foreground 4", 40 / 255.0, 57 / 255.0, 65 / 255.0, 1);
- Theme.save_color ("Foreground 5", 70 / 255.0, 77 / 255.0, 83 / 255.0, 1);
-
- Theme.save_color ("Highlighted 1", 234 / 255.0, 77 / 255.0, 26 / 255.0, 1);
-
- Theme.save_color ("Highlighted Guide", 0, 0, 0.3, 1);
- Theme.save_color ("Guide 1", 0.7, 0.7, 0.8, 1);
- Theme.save_color ("Guide 2", 0.7, 0, 0, 0.5);
- Theme.save_color ("Guide 3", 120 / 255.0, 68 / 255.0, 120 / 255.0, 120 / 255.0);
-
- Theme.save_color ("Grid",0.2, 0.6, 0.2, 0.2);
-
- Theme.save_color ("Background Glyph", 0.2, 0.2, 0.2, 0.5);
-
- Theme.save_color ("Tool Border 1", 38 / 255.0, 39 / 255.0, 43 / 255.0, 1);
- Theme.save_color ("Tool Background 1", 14 / 255.0, 16 / 255.0, 17 / 255.0, 1);
-
- Theme.save_color ("Tool Border 2", 38 / 255.0, 39 / 255.0, 43 / 255.0, 1);
- Theme.save_color ("Tool Background 2", 26 / 255.0, 30 / 255.0, 32 / 255.0, 1);
-
- Theme.save_color ("Tool Border 3", 38 / 255.0, 39 / 255.0, 43 / 255.0, 1);
- Theme.save_color ("Tool Background 3", 44 / 255.0, 47 / 255.0, 51 / 255.0, 1);
-
- Theme.save_color ("Tool Border 4", 38 / 255.0, 39 / 255.0, 43 / 255.0, 1);
- Theme.save_color ("Tool Background 4", 33 / 255.0, 36 / 255.0, 39 / 255.0, 1);
-
- Theme.save_color ("Button Foreground", 101 / 255.0, 108 / 255.0, 116 / 255.0, 1);
-
- N_("Background 1");
- N_("Background 2");
- N_("Background 3");
- N_("Background 4");
- N_("Background 5");
- N_("Background 6");
- N_("Background 7");
- N_("Background 8");
- N_("Background 9");
-
- N_("Foreground 1");
- N_("Foreground 2");
- N_("Foreground 3");
- N_("Foreground 4");
- N_("Foreground 5");
-
- N_("Highlighted 1");
- N_("Highlighted Guide");
-
- N_("Grid");
-
- N_("Guide 1");
- N_("Guide 2");
- N_("Guide 3");
-
- N_("Tool Border 1");
- N_("Tool Background 1");
- N_("Tool Border 2");
- N_("Tool Background 2");
- N_("Tool Border 3");
- N_("Tool Background 3");
- N_("Tool Border 4");
- N_("Tool Background 4");
-
- N_("Button Foreground");
}
public static void set_bundle_path (string path) {
--- a/libbirdfont/ResizeTool.vala
+++ b/libbirdfont/ResizeTool.vala
@@ -236,7 +236,7 @@
cy = Glyph.reverse_path_coordinate_y (selection_box_center_y);
cr.save ();
- Theme.color (cr, "Highlight 1");
+ Theme.color (cr, "Highlighted 1");
cr.rectangle (cx - 2.5, cy - 2.5, 5, 5);
cr.fill ();
@@ -248,7 +248,7 @@
cr.line_to (cx + hx, cy + hy);
cr.stroke ();
- Theme.color (cr, "Highlight 1");
+ Theme.color (cr, "Highlighted 1");
cr.rectangle (cx + hx - 2.5, cy + hy - 2.5, 5, 5);
cr.fill ();
--- a/libbirdfont/Theme.vala
+++ b/libbirdfont/Theme.vala
@@ -78,6 +78,94 @@
}
return colors.get (name);
+ }
+
+ public static void set_default_colors () {
+ color_list = new Gee.ArrayList<string> ();
+ colors = new Gee.HashMap<string, Color> ();
+
+ Theme.set_default_color ("Background 1", 1, 1, 1, 1);
+ Theme.set_default_color ("Background 2", 101 / 255.0, 108 / 255.0, 116 / 255.0, 1);
+ Theme.set_default_color ("Background 3", 38 / 255.0, 39 / 255.0, 43 / 255.0, 1);
+ Theme.set_default_color ("Background 4", 51 / 255.0, 54 / 255.0, 59 / 255.0, 1);
+ Theme.set_default_color ("Background 5", 0.3, 0.3, 0.3, 1);
+ Theme.set_default_color ("Background 6", 224/255.0, 224/255.0, 224/255.0, 1);
+ Theme.set_default_color ("Background 7", 56 / 255.0, 59 / 255.0, 65 / 255.0, 1);
+ Theme.set_default_color ("Background 8", 55/255.0, 55/255.0, 55/255.0, 1);
+ Theme.set_default_color ("Background 9", 72/255.0, 72/255.0, 72/255.0, 1);
+
+ Theme.set_default_color ("Foreground 1", 0, 0, 0, 1);
+ Theme.set_default_color ("Foreground 2", 101 / 255.0, 108 / 255.0, 116 / 255.0, 1);
+ Theme.set_default_color ("Foreground 3", 26 / 255.0, 30 / 255.0, 32 / 255.0, 1);
+ Theme.set_default_color ("Foreground 4", 40 / 255.0, 57 / 255.0, 65 / 255.0, 1);
+ Theme.set_default_color ("Foreground 5", 70 / 255.0, 77 / 255.0, 83 / 255.0, 1);
+
+ Theme.set_default_color ("Highlighted 1", 234 / 255.0, 77 / 255.0, 26 / 255.0, 1);
+
+ Theme.set_default_color ("Highlighted Guide", 0, 0, 0.3, 1);
+ Theme.set_default_color ("Guide 1", 0.7, 0.7, 0.8, 1);
+ Theme.set_default_color ("Guide 2", 0.7, 0, 0, 0.5);
+ Theme.set_default_color ("Guide 3", 120 / 255.0, 68 / 255.0, 120 / 255.0, 120 / 255.0);
+
+ Theme.set_default_color ("Grid",0.2, 0.6, 0.2, 0.2);
+
+ Theme.set_default_color ("Background Glyph", 0.2, 0.2, 0.2, 0.5);
+
+ Theme.set_default_color ("Tool Border 1", 38 / 255.0, 39 / 255.0, 43 / 255.0, 1);
+ Theme.set_default_color ("Tool Background 1", 14 / 255.0, 16 / 255.0, 17 / 255.0, 1);
+
+ Theme.set_default_color ("Tool Border 2", 38 / 255.0, 39 / 255.0, 43 / 255.0, 1);
+ Theme.set_default_color ("Tool Background 2", 26 / 255.0, 30 / 255.0, 32 / 255.0, 1);
+
+ Theme.set_default_color ("Tool Border 3", 38 / 255.0, 39 / 255.0, 43 / 255.0, 1);
+ Theme.set_default_color ("Tool Background 3", 44 / 255.0, 47 / 255.0, 51 / 255.0, 1);
+
+ Theme.set_default_color ("Tool Border 4", 38 / 255.0, 39 / 255.0, 43 / 255.0, 1);
+ Theme.set_default_color ("Tool Background 4", 33 / 255.0, 36 / 255.0, 39 / 255.0, 1);
+
+ Theme.set_default_color ("Button Foreground", 101 / 255.0, 108 / 255.0, 116 / 255.0, 1);
+
+ N_("Background 1");
+ N_("Background 2");
+ N_("Background 3");
+ N_("Background 4");
+ N_("Background 5");
+ N_("Background 6");
+ N_("Background 7");
+ N_("Background 8");
+ N_("Background 9");
+
+ N_("Foreground 1");
+ N_("Foreground 2");
+ N_("Foreground 3");
+ N_("Foreground 4");
+ N_("Foreground 5");
+
+ N_("Highlighted 1");
+ N_("Highlighted Guide");
+
+ N_("Grid");
+
+ N_("Guide 1");
+ N_("Guide 2");
+ N_("Guide 3");
+
+ N_("Tool Border 1");
+ N_("Tool Background 1");
+ N_("Tool Border 2");
+ N_("Tool Background 2");
+ N_("Tool Border 3");
+ N_("Tool Background 3");
+ N_("Tool Border 4");
+ N_("Tool Background 4");
+
+ N_("Button Foreground");
+ }
+
+ public static void set_default_color (string name, double r, double g, double b, double a) {
+ color_list.add (name);
+ colors.set (name, new Color (r, g, b, a));
+ write_theme (); // FIXME: don't overwrite color
}
public static void save_color (string name, double r, double g, double b, double a) {
@@ -89,9 +177,6 @@
File default_theme = SearchPaths.find_file (null, "theme.xml");
File user_theme = get_child (BirdFont.get_settings_directory (), "theme.xml");
- colors = new Gee.HashMap<string, Color> ();
- color_list = new Gee.ArrayList<string> ();
-
if (default_theme.query_exists ()) {
parse_theme (default_theme);
}
@@ -99,8 +184,6 @@
if (user_theme.query_exists ()) {
parse_theme (user_theme);
}
-
- color_list.sort ();
}
public static void write_theme () {
@@ -193,11 +276,10 @@
a = double.parse (attr.get_content ());
}
}
-
- color_list.add (name);
+
colors.set (name, new Color (r, g, b, a));
}
}
}