Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmake/project.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
7 changes: 7 additions & 0 deletions data/org.valama.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,12 @@
</description>
</key>

<key name="current-color-scheme" type="s">
<default l10n="messages">"classic"</default>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does the l10n do?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I read manual again. As I understand It is no need.

<summary>Current color scheme</summary>
<description>
</description>
</key>

</schema>
</schemalist>
49 changes: 49 additions & 0 deletions src/dialogs/settings.vala
Original file line number Diff line number Diff line change
@@ -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();
}
}
1 change: 1 addition & 0 deletions src/main.vala
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public static int main (string[] args) {
}

load_icons();
load_source_style();

gtk_app = new Valama ();
return gtk_app.run();
Expand Down
4 changes: 4 additions & 0 deletions src/ui/super_source_view.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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)=>{
Expand Down
9 changes: 9 additions & 0 deletions src/ui_main.vala
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ static UiValadocBrowser wdg_valadoc_browser;

static Gee.HashMap<string, Gdk.Pixbuf> map_icons;

static IDESettingsWindow settings_window;

/**
* Main window class. Setup {@link Gdl.Dock} and {@link Gdl.DockBar} stuff.
Expand Down Expand Up @@ -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));

Expand Down Expand Up @@ -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();
Expand Down