summaryrefslogtreecommitdiff
path: root/src/gui/triggerSelectWindow.vala
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/triggerSelectWindow.vala')
-rw-r--r--src/gui/triggerSelectWindow.vala98
1 files changed, 79 insertions, 19 deletions
diff --git a/src/gui/triggerSelectWindow.vala b/src/gui/triggerSelectWindow.vala
index 611c179..56781b4 100644
--- a/src/gui/triggerSelectWindow.vala
+++ b/src/gui/triggerSelectWindow.vala
@@ -1,19 +1,19 @@
-/*
-Copyright (c) 2011 by Simon Schneegans
-
-This program is free software: you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by the Free
-Software Foundation, either version 3 of the License, or (at your option)
-any later version.
-
-This program is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-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/>.
-*/
+/////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2011-2015 by Simon Schneegans
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or (at
+// your option) any later version.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or 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/>.
+/////////////////////////////////////////////////////////////////////////
namespace GnomePie {
@@ -39,6 +39,8 @@ public class TriggerSelectWindow : GLib.Object {
private Gtk.CheckButton turbo;
private Gtk.CheckButton delayed;
private Gtk.CheckButton centered;
+ private Gtk.CheckButton warp;
+ private Gtk.RadioButton rshape[10];
private TriggerSelectButton button;
/////////////////////////////////////////////////////////////////////
@@ -56,6 +58,13 @@ public class TriggerSelectWindow : GLib.Object {
private Trigger original_trigger = null;
/////////////////////////////////////////////////////////////////////
+ /// Radioboxes call toggled() twice per selection change.
+ /// This flag is used to discard one of the two notifications.
+ /////////////////////////////////////////////////////////////////////
+
+ private static int notify_toggle= 0;
+
+ /////////////////////////////////////////////////////////////////////
/// C'tor, constructs a new TriggerSelectWindow.
/////////////////////////////////////////////////////////////////////
@@ -76,7 +85,9 @@ public class TriggerSelectWindow : GLib.Object {
trigger.with_mouse,
this.turbo.active,
this.delayed.active,
- this.centered.active);
+ this.centered.active,
+ this.warp.active,
+ this.get_radio_shape());
});
(builder.get_object("trigger-box") as Gtk.Box).pack_start(this.button, true, true);
@@ -93,6 +104,14 @@ public class TriggerSelectWindow : GLib.Object {
this.centered = builder.get_object("center-check") as Gtk.CheckButton;
this.centered.toggled.connect(this.on_check_toggled);
+ this.warp = builder.get_object("warp-check") as Gtk.CheckButton;
+ this.warp.toggled.connect(this.on_check_toggled);
+
+ for (int i= 0; i < 10; i++) {
+ this.rshape[i] = builder.get_object("rshape%d".printf(i)) as Gtk.RadioButton;
+ this.rshape[i].toggled.connect(this.on_radio_toggled);
+ }
+
this.window.delete_event.connect(this.window.hide_on_delete);
} catch (GLib.Error e) {
@@ -128,6 +147,8 @@ public class TriggerSelectWindow : GLib.Object {
this.turbo.active = trigger.turbo;
this.delayed.active = trigger.delayed;
this.centered.active = trigger.centered;
+ this.warp.active = trigger.warp;
+ this.set_radio_shape( trigger.shape );
this.original_trigger = trigger;
this.trigger = trigger;
@@ -135,14 +156,53 @@ public class TriggerSelectWindow : GLib.Object {
}
/////////////////////////////////////////////////////////////////////
- /// Called when one of the three checkoxes is toggled.
+ /// Called when one of the checkboxes is toggled.
/////////////////////////////////////////////////////////////////////
private void on_check_toggled() {
if (this.trigger != null)
this.trigger = new Trigger.from_values(this.trigger.key_sym, this.trigger.modifiers,
this.trigger.with_mouse, this.turbo.active,
- this.delayed.active, this.centered.active);
+ this.delayed.active, this.centered.active,
+ this.warp.active,
+ this.get_radio_shape());
+ }
+
+ /////////////////////////////////////////////////////////////////////
+ /// Returns the current selected radio-button shape: 0= automatic
+ /// 5= full pie; 1,3,7,8= quarters; 2,4,6,8=halves
+ /// 1 | 4 | 7
+ /// 2 | 5 | 8
+ /// 3 | 6 | 9
+ /////////////////////////////////////////////////////////////////////
+
+ private int get_radio_shape() {
+ int rs;
+ for (rs= 0; rs < 10; rs++)
+ if (this.rshape[rs].active)
+ break;
+ return rs;
+ }
+
+ /////////////////////////////////////////////////////////////////////
+ /// Sets the current selected radio-button shape: 0= automatic
+ /// 5= full pie; 1,3,7,8= quarters; 2,4,6,8=halves
+ /////////////////////////////////////////////////////////////////////
+
+ private void set_radio_shape(int rs) {
+ if (rs < 0 || rs > 9)
+ rs= 5; //replace invalid value with default= full pie
+ this.rshape[rs].active= true;
+ }
+
+ /////////////////////////////////////////////////////////////////////
+ /// Called twice when one of the radioboxes is toggled.
+ /////////////////////////////////////////////////////////////////////
+
+ private void on_radio_toggled() {
+ notify_toggle= 1 - notify_toggle;
+ if (notify_toggle == 1)
+ on_check_toggled(); //just call once
}
/////////////////////////////////////////////////////////////////////