diff options
author | Alessandro Ghedini <al3xbio@gmail.com> | 2011-11-20 15:50:38 +0100 |
---|---|---|
committer | Alessandro Ghedini <al3xbio@gmail.com> | 2011-11-20 15:50:38 +0100 |
commit | d6b2677825cbb423e2099563c16321c3e23d7899 (patch) | |
tree | fd04dbf76a9bc0fdd3f7755e65d1c175ac5c99dd /src/gui/cellRendererTrigger.vala | |
parent | 6451a495637c6e3047a5a56573cffc6e3de9a515 (diff) |
Imported Upstream version 0.3.1upstream/0.3.1
Diffstat (limited to 'src/gui/cellRendererTrigger.vala')
-rw-r--r-- | src/gui/cellRendererTrigger.vala | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/src/gui/cellRendererTrigger.vala b/src/gui/cellRendererTrigger.vala new file mode 100644 index 0000000..a825c32 --- /dev/null +++ b/src/gui/cellRendererTrigger.vala @@ -0,0 +1,84 @@ +/* +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/>. +*/ + +namespace GnomePie { + +///////////////////////////////////////////////////////////////////////// +/// A CellRenderer which opens a TriggerSelectWindow. +///////////////////////////////////////////////////////////////////////// + +public class CellRendererTrigger : Gtk.CellRendererText { + + ///////////////////////////////////////////////////////////////////// + /// This signal is emitted when the user selects another trigger. + ///////////////////////////////////////////////////////////////////// + + public signal void on_select(string path, Trigger trigger); + + ///////////////////////////////////////////////////////////////////// + /// The trigger which can be set with this window. + ///////////////////////////////////////////////////////////////////// + + public string trigger { get; set; } + + ///////////////////////////////////////////////////////////////////// + /// The IconSelectWindow which is shown on click. + ///////////////////////////////////////////////////////////////////// + + private TriggerSelectWindow select_window = null; + + ///////////////////////////////////////////////////////////////////// + /// A helper variable, needed to emit the current path. + ///////////////////////////////////////////////////////////////////// + + private string current_path = ""; + + ///////////////////////////////////////////////////////////////////// + /// C'tor, creates a new CellRendererIcon. + ///////////////////////////////////////////////////////////////////// + + public CellRendererTrigger() { + this.select_window = new TriggerSelectWindow(); + + this.select_window.on_select.connect((trigger) => { + this.trigger = trigger.name; + this.on_select(current_path, trigger); + }); + } + + ///////////////////////////////////////////////////////////////////// + /// Open the TriggerSelectWindow on click. + ///////////////////////////////////////////////////////////////////// + + public override unowned Gtk.CellEditable start_editing( + Gdk.Event event, Gtk.Widget widget, string path, Gdk.Rectangle bg_area, + Gdk.Rectangle cell_area, Gtk.CellRendererState flags) { + + this.current_path = path; + + this.select_window.set_transient_for((Gtk.Window)widget.get_toplevel()); + this.select_window.set_modal(true); + this.select_window.set_trigger(new Trigger.from_string(this.trigger)); + + this.select_window.show(); + + return base.start_editing(event, widget, path, bg_area, cell_area, flags); + } +} + +} + |