3
* Copyright © 2010, 2011, 2012 Wojciech Kowalczyk
4
* The program is distributed under the terms of the GNU General Public License Version 3.
5
* See LICENCE for details.
12
namespace Glippy.Actions
15
/// Edit action window.
17
internal partial class EditActionWindow : Window
22
private Action action;
27
private TreeIter iter;
32
private TreePath path;
37
private ListStore list;
42
private Actions plugin;
45
/// Initializes a new instance of class.
47
/// <param name="plugin">Plugin.</param>
48
/// <param name="list">List of actions.</param>
49
public EditActionWindow(Actions plugin, ListStore list) : base(WindowType.Toplevel)
57
this.Icon = IconTheme.Default.LoadIcon("glippy", 128, IconLookupFlags.GenericFallback);
61
Core.Tools.PrintInfo(ex, this.GetType());
64
this.Destroyed += (s, e) => this.Purge();
68
/// Initializes a new instance of class.
70
/// <param name="plugin">Plugin.</param>
71
/// <param name="list">List of plugins.</param>
72
/// <param name="action">Edited action.</param>
73
/// <param name="path">Tree path of edited element.</param>
74
/// <param name="iter">Tree iterator of edited element.</param>
75
public EditActionWindow(Actions plugin, ListStore list, Action action, TreePath path, TreeIter iter) : this(plugin, list)
80
this.label.Text = action.Label;
81
this.content.Buffer.Text = action.Content;
82
this.Title = Catalog.GetString("Edit action");
90
this.plugin.EditActionWindow = null;
95
/// Handles key press event event.
97
/// <param name="sender">Sender.</param>
98
/// <param name="args">Event arguments.</param>
99
private void OnKeyPressEvent(object sender, KeyPressEventArgs args)
101
if (args.Event.Key == Gdk.Key.Escape)
106
/// Handles button cancel clicked event.
108
/// <param name="sender">Sender.</param>
109
/// <param name="args">Event arguments.</param>
110
private void OnButtonCancelClicked(object sender, EventArgs args)
116
/// Handles button apply clicked event.
118
/// <param name="sender">Sender.</param>
119
/// <param name="args">Event arguments.</param>
120
private void OnButtonApplyClicked(object sender, EventArgs args)
122
MessageDialog dialog;
124
if (this.label.Text.Length == 0)
126
dialog = new MessageDialog(this, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, false, Catalog.GetString("Label is required."));
131
else if (this.content.Buffer.Text.Length == 0)
133
dialog = new MessageDialog(this, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, false, Catalog.GetString("Content is required."));
140
if (this.action != null)
142
this.action.Label = this.label.Text;
143
this.action.Content = this.content.Buffer.Text;
144
this.list.EmitRowChanged(this.path, this.iter);
148
this.action = new Action();
149
this.action.Label = this.label.Text;
150
this.action.Content = this.content.Buffer.Text;
151
this.list.AppendValues(action);