diff --git a/cmake/project.cmake b/cmake/project.cmake
index 7ca1600..4bdadff 100644
--- a/cmake/project.cmake
+++ b/cmake/project.cmake
@@ -49,6 +49,7 @@ set(srcfiles
"src/dialogs/create_file.vala"
"src/dialogs/missing_packages.vala"
"src/dialogs/project_settings.vala"
+ "src/dialogs/settings.vala"
"src/main.vala"
"src/project/build_project.vala"
"src/project/package_management.vala"
diff --git a/data/org.valama.gschema.xml b/data/org.valama.gschema.xml
index fe40a7f..8a82139 100644
--- a/data/org.valama.gschema.xml
+++ b/data/org.valama.gschema.xml
@@ -15,5 +15,12 @@
+
+ "classic"
+ Current color scheme
+
+
+
+
diff --git a/src/dialogs/settings.vala b/src/dialogs/settings.vala
new file mode 100644
index 0000000..c772fbd
--- /dev/null
+++ b/src/dialogs/settings.vala
@@ -0,0 +1,49 @@
+using Gtk;
+
+public SourceStyleScheme source_style;
+
+void load_source_style() {
+ var settings = new GLib.Settings ("org.valama");
+ var s = new SourceStyleSchemeManager ();
+ source_style = s.get_scheme (settings.get_string ("current-color-scheme"));
+ if(source_style == null) {
+ stderr.printf(" \x1b[31mCouldn't load source style\n\x1b[0m");
+ }
+}
+
+public class IDESettingsWindow : Window {
+ private string[] color_scheme_list;
+ private string current_color_scheme;
+ public signal void color_scheme_changed();
+
+ public IDESettingsWindow () {
+ this.title = "IDE Settings";
+ this.window_position = WindowPosition.CENTER;
+ this.set_default_size (400, 400);
+ var settings = new GLib.Settings ("org.valama");
+ current_color_scheme = settings.get_string ("current-color-scheme");
+ var notebook = new Notebook ();
+ this.add (notebook);
+ var manager = new SourceStyleSchemeManager ();
+ color_scheme_list = manager.get_scheme_ids ();
+ var items = new ListBox ();
+ for(var i = 0; i < color_scheme_list.length; i++) {
+ items.insert(new Label(color_scheme_list[i]), i);
+ if(color_scheme_list[i] == current_color_scheme) {
+ items.select_row (items.get_row_at_index (i));
+ }
+ }
+ items.row_selected.connect(select_item);
+ var scrolled = new ScrolledWindow (null, null);
+ scrolled.add (items);
+ notebook.append_page (scrolled, new Label ("Color scheme"));
+ }
+
+ private void select_item(ListBoxRow? row) {
+ var item = (Label)row.get_child ();
+ var settings = new GLib.Settings ("org.valama");
+ settings.set_string ("current-color-scheme", item.label);
+ load_source_style ();
+ color_scheme_changed();
+ }
+}
diff --git a/src/main.vala b/src/main.vala
index 8e68a64..bae7098 100644
--- a/src/main.vala
+++ b/src/main.vala
@@ -86,6 +86,7 @@ public static int main (string[] args) {
}
load_icons();
+ load_source_style();
gtk_app = new Valama ();
return gtk_app.run();
diff --git a/src/ui/super_source_view.vala b/src/ui/super_source_view.vala
index a26591d..298881d 100644
--- a/src/ui/super_source_view.vala
+++ b/src/ui/super_source_view.vala
@@ -26,6 +26,10 @@ using Vala;
public class SuperSourceView : Gtk.SourceView {
public SuperSourceView(SourceBuffer bfr) {
this.buffer = bfr;
+ settings_window.color_scheme_changed.connect( () => {
+ bfr.style_scheme = source_style;
+ this.queue_draw () ;
+ });
int old_line = -1;
this.motion_notify_event.connect ((event)=>{
diff --git a/src/ui_main.vala b/src/ui_main.vala
index 5f40a64..97c5a02 100644
--- a/src/ui_main.vala
+++ b/src/ui_main.vala
@@ -46,6 +46,7 @@ static UiValadocBrowser wdg_valadoc_browser;
static Gee.HashMap map_icons;
+static IDESettingsWindow settings_window;
/**
* Main window class. Setup {@link Gdl.Dock} and {@link Gdl.DockBar} stuff.
@@ -186,6 +187,7 @@ public class MainWidget : Box {
* Initialize ui_elements, menu and toolbars.
*/
public void init() {
+ settings_window = new IDESettingsWindow ();
source_viewer = new UiSourceViewer();
source_viewer.add_srcitem (project.open_new_buffer ("", "", true));
@@ -522,6 +524,13 @@ public class MainWidget : Box {
this.menu.append (item_help_about);
item_help_about.activate.connect (ui_about_dialog);
+ /* IDE Setting */
+ var item_setting = new ImageMenuItem.with_mnemonic (_("_IDE Setting"));
+ this.menu.append (item_setting);
+ item_setting.activate.connect ( () => {
+ settings_window.show_all ();
+ } );
+
/* Quit */
var item_file_quit = new ImageMenuItem.with_mnemonic (_("_Quit"));
var image_file_quit = new Image();