summaryrefslogtreecommitdiff
path: root/src/gui/settingsWindow.vala
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2015-01-24 11:03:07 +0100
committerJörg Frings-Fürst <debian@jff-webhosting.net>2015-01-24 11:03:07 +0100
commit4b7a48bda37da6ac1c08822c7c888be6bf7cb751 (patch)
tree919bbd1c7eeca956a4cb20c8e3b88c9a2e27f821 /src/gui/settingsWindow.vala
parent751a72bc2d2f54e27206a32cd4b7b17e9837228e (diff)
parentb683ce2789d95b2e9f221e75adc30efd91cfb901 (diff)
Merge tag 'upstream/0.5.7'
Upstream version 0.5.7
Diffstat (limited to 'src/gui/settingsWindow.vala')
-rw-r--r--src/gui/settingsWindow.vala88
1 files changed, 48 insertions, 40 deletions
diff --git a/src/gui/settingsWindow.vala b/src/gui/settingsWindow.vala
index 81f8f7e..b03ae2f 100644
--- a/src/gui/settingsWindow.vala
+++ b/src/gui/settingsWindow.vala
@@ -1,4 +1,4 @@
-/*
+/*
Copyright (c) 2011 by Simon Schneegans
This program is free software: you can redistribute it and/or modify it
@@ -12,41 +12,41 @@ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public License along with
-this program. If not, see <http://www.gnu.org/licenses/>.
+this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace GnomePie {
-/////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////
/// The settings menu of Gnome-Pie, with options for theme switching and
/// some general options.
/////////////////////////////////////////////////////////////////////////
public class SettingsWindow : GLib.Object {
-
+
/////////////////////////////////////////////////////////////////////
/// Some widgets.
/////////////////////////////////////////////////////////////////////
-
+
private Gtk.Dialog? window = null;
private ThemeList? theme_list = null;
private Gtk.ToggleButton? indicator = null;
private Gtk.ToggleButton? autostart = null;
private Gtk.ToggleButton? captions = null;
-
+
/////////////////////////////////////////////////////////////////////
/// C'tor creates, the dialog.
/////////////////////////////////////////////////////////////////////
-
+
public SettingsWindow() {
try {
-
+
Gtk.Builder builder = new Gtk.Builder();
builder.add_from_file (Paths.ui_files + "/settings.ui");
this.window = builder.get_object("window") as Gtk.Dialog;
-
+
this.theme_list = new ThemeList();
this.theme_list.on_select_new.connect(() => {
this.captions.active = Config.global.show_captions;
@@ -56,26 +56,26 @@ public class SettingsWindow : GLib.Object {
this.captions.sensitive = false;
}
});
-
+
var scroll_area = builder.get_object("theme-scrolledwindow") as Gtk.ScrolledWindow;
scroll_area.add(this.theme_list);
-
+
(builder.get_object("close-button") as Gtk.Button).clicked.connect(on_close_button_clicked);
-
+
this.autostart = (builder.get_object("autostart-checkbox") as Gtk.ToggleButton);
this.autostart.toggled.connect(on_autostart_toggled);
-
+
this.indicator = (builder.get_object("indicator-checkbox") as Gtk.ToggleButton);
this.indicator.toggled.connect(on_indicator_toggled);
-
+
this.captions = (builder.get_object("captions-checkbox") as Gtk.ToggleButton);
this.captions.toggled.connect(on_captions_toggled);
-
- var scale_slider = (builder.get_object("scale-hscale") as Gtk.HScale);
+
+ var scale_slider = (builder.get_object("scale-hscale") as Gtk.Scale);
scale_slider.set_range(0.5, 2.0);
scale_slider.set_increments(0.05, 0.25);
scale_slider.set_value(Config.global.global_scale);
-
+
bool changing = false;
bool changed_again = false;
@@ -97,56 +97,64 @@ public class SettingsWindow : GLib.Object {
changed_again = true;
}
});
-
+
+ var range_slider = (builder.get_object("range-hscale") as Gtk.Scale);
+ range_slider.set_range(100, 2000);
+ range_slider.set_increments(10, 100);
+ range_slider.set_value(Config.global.activation_range);
+ range_slider.value_changed.connect(() => {
+ Config.global.activation_range = (int)range_slider.get_value();
+ });
+
this.window.delete_event.connect(this.window.hide_on_delete);
-
+
} catch (GLib.Error e) {
error("Could not load UI: %s\n", e.message);
}
}
-
+
/////////////////////////////////////////////////////////////////////
/// Sets the parent window, in order to make this window stay in
/// front.
/////////////////////////////////////////////////////////////////////
-
+
public void set_parent(Gtk.Window parent) {
this.window.set_transient_for(parent);
}
-
+
/////////////////////////////////////////////////////////////////////
/// Displays the window on the screen.
/////////////////////////////////////////////////////////////////////
-
+
public void show() {
this.indicator.active = Config.global.show_indicator;
- this.autostart.active = Config.global.auto_start;
+ this.autostart.active = Config.global.auto_start;
this.captions.active = Config.global.show_captions;
-
+
if (Config.global.theme.has_slice_captions) {
this.captions.sensitive = true;
} else {
this.captions.sensitive = false;
}
-
- this.window.show_all();
+
+ this.window.show_all();
}
-
+
/////////////////////////////////////////////////////////////////////
/// Called when the close button is clicked.
/////////////////////////////////////////////////////////////////////
-
+
private void on_close_button_clicked() {
this.window.hide();
}
-
+
/////////////////////////////////////////////////////////////////////
/// Creates or deletes the autostart file. This code is inspired
/// by project synapse as well.
/////////////////////////////////////////////////////////////////////
-
+
private void on_autostart_toggled(Gtk.ToggleButton check_box) {
-
+
bool active = check_box.active;
if (!active && FileUtils.test(Paths.autostart, FileTest.EXISTS)) {
Config.global.auto_start = false;
@@ -155,9 +163,9 @@ public class SettingsWindow : GLib.Object {
}
else if (active && !FileUtils.test(Paths.autostart, FileTest.EXISTS)) {
Config.global.auto_start = true;
-
- string autostart_entry =
- "#!/usr/bin/env xdg-open\n" +
+
+ string autostart_entry =
+ "#!/usr/bin/env xdg-open\n" +
"[Desktop Entry]\n" +
"Name=Gnome-Pie\n" +
"Exec=" + Paths.executable + "\n" +
@@ -171,7 +179,7 @@ public class SettingsWindow : GLib.Object {
if (!FileUtils.test(autostart_dir, FileTest.EXISTS | FileTest.IS_DIR)) {
DirUtils.create_with_parents(autostart_dir, 0755);
}
-
+
try {
FileUtils.set_contents(Paths.autostart, autostart_entry);
FileUtils.chmod(Paths.autostart, 0755);
@@ -183,20 +191,20 @@ public class SettingsWindow : GLib.Object {
}
}
}
-
+
/////////////////////////////////////////////////////////////////////
/// Shows or hides the indicator.
/////////////////////////////////////////////////////////////////////
-
+
private void on_indicator_toggled(Gtk.ToggleButton check_box) {
var check = check_box as Gtk.CheckButton;
Config.global.show_indicator = check.active;
}
-
+
/////////////////////////////////////////////////////////////////////
/// Shows or hides the captions of Slices.
/////////////////////////////////////////////////////////////////////
-
+
private void on_captions_toggled(Gtk.ToggleButton check_box) {
var check = check_box as Gtk.CheckButton;
Config.global.show_captions = check.active;