diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1c6f62f..e402d7a 100755 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -38,6 +38,7 @@ vala_precompile(VALA_C ${EXEC_NAME} Dialogs/EditorPreferencesDialog.vala Dialogs/NewFileDialog.vala Dialogs/OpenProjectDialog.vala + Dialogs/PreferencesDialog.vala Services/IDESettings.vala config.vala PACKAGES diff --git a/src/Dialogs/PreferencesDialog.vala b/src/Dialogs/PreferencesDialog.vala new file mode 100644 index 0000000..509a056 --- /dev/null +++ b/src/Dialogs/PreferencesDialog.vala @@ -0,0 +1,48 @@ +namespace IDE { + public class PreferencesDialog : BaseDialog { + + construct { + + resizable = false; + + var general_grid = new Gtk.Grid (); + general_grid.row_spacing = 6; + general_grid.column_spacing = 12; + general_grid.margin = 12; + + var general_header = new SettingsHeader (_("General")); + + SettingsSwitch dark_mode_switch = new SettingsSwitch ("dark-theme"); + + general_grid.attach (general_header, 0, 0, 2, 1); + general_grid.attach (new SettingsLabel (_("Dark theme:")), 0, 1, 1, 1); + general_grid.attach (dark_mode_switch, 1, 1, 1, 1); + + get_content_area ().add (general_grid); + + } + + private class SettingsSwitch : Gtk.Switch { + public SettingsSwitch (string setting) { + halign = Gtk.Align.START; + IDESettings.get_default ().schema.bind (setting, this, "active", SettingsBindFlags.DEFAULT); + } + } + + private class SettingsHeader : Gtk.Label { + public SettingsHeader (string text) { + label = text; + get_style_context ().add_class ("h4"); + halign = Gtk.Align.START; + } + } + + private class SettingsLabel : Gtk.Label { + public SettingsLabel (string text) { + label = text; + halign = Gtk.Align.END; + margin_start = 12; + } + } + } +} diff --git a/src/ToolBar.vala b/src/ToolBar.vala index 1badb50..3ca7888 100755 --- a/src/ToolBar.vala +++ b/src/ToolBar.vala @@ -71,6 +71,9 @@ namespace IDE { menu_item = save_button.add_menu_item (_("Save all opened documents")); menu_item.activate.connect (request_save_opened); + + menu_item = preferences_button.add_menu_item (_("Preferences")); + menu_item.activate.connect (show_preferences); } private void build () { @@ -100,5 +103,10 @@ namespace IDE { new_file_dialog.show_all (); new_file_dialog.hide.connect (() => new_button.sensitive = true); } + + private void show_preferences () { + var preferences_dialog = new PreferencesDialog (); + preferences_dialog.show_all (); + } } -} \ No newline at end of file +}