blob: de6506922bf66720987e39925891d4503a7a2bc2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
/////////////////////////////////////////////////////////////////////////
// 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 {
/////////////////////////////////////////////////////////////////////////
/// A window which allows selection of a new name for a Pie.
/////////////////////////////////////////////////////////////////////////
public class RenameWindow : GLib.Object {
/////////////////////////////////////////////////////////////////////
/// Gets emitted when the user selects a new name.
/////////////////////////////////////////////////////////////////////
public signal void on_ok(string new_name);
/////////////////////////////////////////////////////////////////////
/// Some Widgets used by this dialog.
/////////////////////////////////////////////////////////////////////
private Gtk.Dialog window = null;
private Gtk.Entry entry = null;
/////////////////////////////////////////////////////////////////////
/// C'tor, constructs the Widget.
/////////////////////////////////////////////////////////////////////
public RenameWindow() {
try {
Gtk.Builder builder = new Gtk.Builder();
builder.add_from_file (Paths.ui_files + "/rename_pie.ui");
window = builder.get_object("window") as Gtk.Dialog;
entry = builder.get_object("name-entry") as Gtk.Entry;
entry.activate.connect(this.on_ok_button_clicked);
(builder.get_object("ok-button") as Gtk.Button).clicked.connect(on_ok_button_clicked);
(builder.get_object("cancel-button") as Gtk.Button).clicked.connect(on_cancel_button_clicked);
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.window.show_all();
this.entry.is_focus = true;
}
/////////////////////////////////////////////////////////////////////
/// Make the text entry display the name of the Pie with given ID.
/////////////////////////////////////////////////////////////////////
public void set_pie(string id) {
entry.text = PieManager.get_name_of(id);
}
/////////////////////////////////////////////////////////////////////
/// Called when the ok button is pressed.
/////////////////////////////////////////////////////////////////////
private void on_ok_button_clicked() {
this.on_ok(entry.text);
this.window.hide();
}
/////////////////////////////////////////////////////////////////////
/// Called when the cancel button is pressed.
/////////////////////////////////////////////////////////////////////
private void on_cancel_button_clicked() {
this.window.hide();
}
}
}
|