Skip to content
API Documentation
BastionGuard™
TeeJee.GtkHelper Namespace Reference

Functions

void gtk_do_events ()
void gtk_set_busy (bool busy, Gtk.Window win)
static void gtk_messagebox (string title, string message, Gtk.Window? parent_win, bool is_error=false)
string? gtk_inputbox (string title, string message, Gtk.Window? parent_win, bool mask_password=false)
void wait_and_close_window (int milliseconds, Gtk.Window window)
int gtk_dialog_run (Gtk.Dialog dlg)
bool gtk_combobox_set_value (Gtk.ComboBoxText combo, int index, string val)
string gtk_combobox_get_value (Gtk.ComboBoxText combo, int index, string default_value)
static Gtk.Stack add_notebook (Gtk.Box box, bool show_tabs=true, bool show_border=true)
static Gtk.ListBox add_treeview (Gtk.Box box, Gtk.SelectionMode selection_mode=Gtk.SelectionMode.SINGLE)
static Gtk.Label add_column_text (Gtk.ListBox listbox, string title, out Gtk.Label cell)
static Gtk.Box add_column_icon_radio_text (Gtk.ListBox listbox, string title, out Gtk.Image cell_pix, out Gtk.CheckButton cell_radio, out Gtk.Label cell_text)
static Gtk.Label add_label_scrolled (Gtk.Box box, string text, bool show_border=false, bool wrap=false, int ellipsize_chars=40)
Gtk.Label add_label (Gtk.Box box, string text, bool bold=false, bool italic=false, bool large=false)
static string format_text (string text, bool bold=false, bool italic=false, bool large=false)
static Gtk.Label add_label_header (Gtk.Box box, string text, bool large_heading=false)
static Gtk.CheckButton add_checkbox (Gtk.Box box, string text)
static Gtk.SpinButton add_spin (Gtk.Box box, double min, double max, double val, int digits=0, double step=1, double step_page=1)
static Gtk.Button add_button (Gtk.Box box, string text, string tooltip, Gtk.SizeGroup? size_group, Gtk.Image? icon=null)
static Gtk.Box add_button_box (Gtk.Box box, Gtk.Orientation orientation=Gtk.Orientation.HORIZONTAL, Gtk.Align halign=Gtk.Align.CENTER, int spacing=6)

Function Documentation

◆ add_button()

Gtk.Button TeeJee.GtkHelper.add_button ( Gtk.Box box,
string text,
string tooltip,
Gtk.SizeGroup? size_group,
Gtk.Image? icon = null )
static

Definition at line 305 of file GtkHelper.vala.

305 {
306
307 var button = new Gtk.Button();
308 box.append(button);
309
310 button.set_label(text);
311 button.set_tooltip_text(tooltip);
312
313 if (icon != null){
314 button.set_child(icon);
315 }
316
317 if (size_group != null){
318 size_group.add_widget(button);
319 }
320
321 return button;
322 }

References add_button().

Referenced by add_button().

◆ add_button_box()

Gtk.Box TeeJee.GtkHelper.add_button_box ( Gtk.Box box,
Gtk.Orientation orientation = Gtk::Orientation::HORIZONTAL,
Gtk.Align halign = Gtk::Align::CENTER,
int spacing = 6 )
static

Definition at line 324 of file GtkHelper.vala.

325 {
326
327 var bbox = new Gtk.Box(orientation, spacing);
328 bbox.halign = halign;
329 box.append(bbox);
330
331 return bbox;
332 }

References add_button_box().

Referenced by add_button_box().

◆ add_checkbox()

Gtk.CheckButton TeeJee.GtkHelper.add_checkbox ( Gtk.Box box,
string text )
static

Definition at line 271 of file GtkHelper.vala.

271 {
272
273 var chk = new Gtk.CheckButton.with_label(text);
274 chk.label = text;
275 box.append(chk);
276
277
278 /*
279 chk.toggled.connect(()=>{
280 chk.active;
281 });
282 */
283
284 return chk;
285 }

References add_checkbox().

Referenced by add_checkbox().

◆ add_column_icon_radio_text()

Gtk.Box TeeJee.GtkHelper.add_column_icon_radio_text ( Gtk.ListBox listbox,
string title,
out Gtk.Image cell_pix,
out Gtk.CheckButton cell_radio,
out Gtk.Label cell_text )
static

Definition at line 183 of file GtkHelper.vala.

184 {
185 var row = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 6);
186 cell_pix = new Gtk.Image();
187 cell_radio = new Gtk.CheckButton();
188 cell_text = new Gtk.Label(title);
189 cell_text.xalign = 0.0f;
190 row.append(cell_pix);
191 row.append(cell_radio);
192 row.append(cell_text);
193 return row;
194 }

References add_column_icon_radio_text().

Referenced by add_column_icon_radio_text().

◆ add_column_text()

Gtk.Label TeeJee.GtkHelper.add_column_text ( Gtk.ListBox listbox,
string title,
out Gtk.Label cell )
static

Definition at line 176 of file GtkHelper.vala.

176 {
177 cell = new Gtk.Label(title);
178 cell.xalign = 0.0f;
179 return cell;
180 }

References add_column_text().

Referenced by add_column_text().

◆ add_label()

Gtk.Label TeeJee.GtkHelper.add_label ( Gtk.Box box,
string text,
bool bold = false,
bool italic = false,
bool large = false )
private

Definition at line 234 of file GtkHelper.vala.

234 {
235
236 string msg = "<span%s%s%s>%s</span>".printf(
237 (bold ? " weight=\"bold\"" : ""),
238 (italic ? " style=\"italic\"" : ""),
239 (large ? " size=\"x-large\"" : ""),
240 text);
241
242 var label = new Gtk.Label(msg);
243 label.set_use_markup(true);
244 label.xalign = (float) 0.0;
245 label.wrap = true;
246 label.wrap_mode = Pango.WrapMode.WORD;
247 box.append(label);
248 return label;
249 }

References add_label().

Referenced by BackupBox.add_count_label(), RestoreBox.add_count_label(), RestoreDeviceBox.add_device_selection_option(), add_label(), add_label_header(), BackupBox.add_progress_area(), ScheduleBox.add_schedule_option(), BackupBox.BackupBox(), BackupDeviceBox.BackupDeviceBox(), RsyncLogBox.create_filters(), RestoreDeviceBox.create_infobar_location(), RsyncLogBox.create_progressbar(), DeleteBox.DeleteBox(), DeleteWindow.DeleteWindow(), EstimateBox.EstimateBox(), ExcludeAppsBox.ExcludeAppsBox(), ExcludeBox.ExcludeBox(), ExcludeListSummaryWindow.ExcludeListSummaryWindow(), BackupDeviceBox.init_infobar_location(), RestoreBox.RestoreBox(), RestoreDeviceBox.RestoreDeviceBox(), RestoreExcludeBox.RestoreExcludeBox(), RestoreSummaryBox.RestoreSummaryBox(), ScheduleBox.ScheduleBox(), and UsersBox.UsersBox().

◆ add_label_header()

Gtk.Label TeeJee.GtkHelper.add_label_header ( Gtk.Box box,
string text,
bool large_heading = false )
static

Definition at line 263 of file GtkHelper.vala.

263 {
264
265 var label = add_label(box, escape_html(text), true, false, large_heading);
266 label.margin_bottom = 12;
267 return label;
268 }
Gtk.Label add_label(Gtk.Box box, string text, bool bold=false, bool italic=false, bool large=false)
string escape_html(string html)

References add_label(), add_label_header(), and TeeJee.Misc.escape_html().

Referenced by add_label_header().

◆ add_label_scrolled()

Gtk.Label TeeJee.GtkHelper.add_label_scrolled ( Gtk.Box box,
string text,
bool show_border = false,
bool wrap = false,
int ellipsize_chars = 40 )
static

Definition at line 197 of file GtkHelper.vala.

197 {
198
199 // ScrolledWindow
200 var scroll = new Gtk.ScrolledWindow();
201 scroll.hscrollbar_policy = PolicyType.NEVER;
202 scroll.vscrollbar_policy = PolicyType.ALWAYS;
203 scroll.hexpand = true;
204 scroll.vexpand = true;
205 box.append(scroll);
206
207 var label = new Gtk.Label(text);
208 label.xalign = (float) 0.0;
209 label.yalign = (float) 0.0;
210 label.margin_start = 6;
211 label.margin_end = 6;
212 label.margin_top = 6;
213 label.margin_bottom = 6;
214 label.set_use_markup(true);
215 scroll.set_child(label);
216
217 if (wrap){
218 label.wrap = true;
219 label.wrap_mode = Pango.WrapMode.WORD;
220 }
221 else {
222 label.wrap = false;
223 label.ellipsize = Pango.EllipsizeMode.MIDDLE;
224 label.max_width_chars = ellipsize_chars;
225 }
226
227 if (show_border){
228 }
229
230 return label;
231 }

References add_label_scrolled().

Referenced by add_label_scrolled().

◆ add_notebook()

Gtk.Stack TeeJee.GtkHelper.add_notebook ( Gtk.Box box,
bool show_tabs = true,
bool show_border = true )
static

Definition at line 146 of file GtkHelper.vala.

146 {
147
148 var stack = new Gtk.Stack();
149 stack.margin_start = 0;
150 stack.margin_end = 0;
151 stack.margin_top = 0;
152 stack.margin_bottom = 0;
153 stack.hexpand = true;
154 stack.vexpand = true;
155 box.append(stack);
156
157 return stack;
158 }

References add_notebook().

Referenced by add_notebook().

◆ add_spin()

Gtk.SpinButton TeeJee.GtkHelper.add_spin ( Gtk.Box box,
double min,
double max,
double val,
int digits = 0,
double step = 1,
double step_page = 1 )
static

Definition at line 288 of file GtkHelper.vala.

288 {
289
290 var adj = new Gtk.Adjustment(val, min, max, step, step_page, 0);
291 var spin = new Gtk.SpinButton(adj, step, digits);
292 spin.xalign = (float) 0.5;
293 box.append(spin);
294
295 /*
296 spin.value_changed.connect(()=>{
297 label.sensitive = spin.sensitive;
298 });
299 */
300
301 return spin;
302 }

References add_spin().

Referenced by add_spin().

◆ add_treeview()

Gtk.ListBox TeeJee.GtkHelper.add_treeview ( Gtk.Box box,
Gtk.SelectionMode selection_mode = Gtk::SelectionMode::SINGLE )
static

Definition at line 161 of file GtkHelper.vala.

161 {
162
163 var listbox = new Gtk.ListBox();
164 listbox.selection_mode = selection_mode;
165
166 var scrollwin = new Gtk.ScrolledWindow();
167 scrollwin.set_child(listbox);
168 scrollwin.hexpand = true;
169 scrollwin.vexpand = true;
170 box.append(scrollwin);
171
172 return listbox;
173 }

References add_treeview().

Referenced by add_treeview().

◆ format_text()

string TeeJee.GtkHelper.format_text ( string text,
bool bold = false,
bool italic = false,
bool large = false )
static

Definition at line 251 of file GtkHelper.vala.

251 {
252
253 string msg = "<span%s%s%s>%s</span>".printf(
254 (bold ? " weight=\"bold\"" : ""),
255 (italic ? " style=\"italic\"" : ""),
256 (large ? " size=\"x-large\"" : ""),
257 escape_html(text));
258
259 return msg;
260 }

References TeeJee.Misc.escape_html(), and format_text().

Referenced by format_text().

◆ gtk_combobox_get_value()

string TeeJee.GtkHelper.gtk_combobox_get_value ( Gtk.ComboBoxText combo,
int index,
string default_value )

Definition at line 135 of file GtkHelper.vala.

135 {
136
137 /* Convenience function to get combobox value */
138
139 var text = combo.get_active_text();
140 return (text != null) ? text : default_value;
141 }

References gtk_combobox_get_value().

Referenced by gtk_combobox_get_value().

◆ gtk_combobox_set_value()

bool TeeJee.GtkHelper.gtk_combobox_set_value ( Gtk.ComboBoxText combo,
int index,
string val )

Definition at line 118 of file GtkHelper.vala.

118 {
119
120 /* Convenience function to set combobox value */
121
122 for (int i = 0; ; i++) {
123 combo.active = i;
124 var text = combo.get_active_text();
125 if (text == null) {
126 combo.active = -1;
127 return false;
128 }
129 if (text == val) {
130 return true;
131 }
132 }
133 }

References gtk_combobox_set_value().

Referenced by gtk_combobox_set_value().

◆ gtk_dialog_run()

int TeeJee.GtkHelper.gtk_dialog_run ( Gtk.Dialog dlg)

Definition at line 108 of file GtkHelper.vala.

108 {
109 int result = Gtk.ResponseType.CLOSE;
110 var loop = new GLib.MainLoop(null, false);
111 dlg.response.connect((response_id) => { result = response_id; loop.quit(); });
112 dlg.close_request.connect(() => { result = Gtk.ResponseType.CLOSE; if (loop.is_running()) loop.quit(); return false; });
113 dlg.present();
114 loop.run();
115 return result;
116 }

References gtk_dialog_run().

Referenced by RestoreWindow.create_actions(), MainWindow.delete_selected(), gtk_dialog_run(), gtk_inputbox(), MainWindow.on_close_request(), and MainWindow.on_language_changed().

◆ gtk_do_events()

◆ gtk_inputbox()

string? TeeJee.GtkHelper.gtk_inputbox ( string title,
string message,
Gtk.Window? parent_win,
bool mask_password = false )

Definition at line 46 of file GtkHelper.vala.

46 {
47
48 Gtk.Box vbox_main = new Gtk.Box(Orientation.VERTICAL, 0);
49 vbox_main.margin_start = 0;
50 vbox_main.margin_end = 0;
51 vbox_main.margin_top = 0;
52 vbox_main.margin_bottom = 0;
53
54 Gtk.Label lbl_input = new Gtk.Label(title);
55 lbl_input.xalign = (float) 0.0;
56 lbl_input.label = message;
57
58 Gtk.Entry txt_input = new Gtk.Entry();
59 txt_input.margin_top = 3;
60 txt_input.set_visibility(!mask_password);
61
62 var dlg = new Gtk.Dialog.with_buttons(title, parent_win, DialogFlags.MODAL);
63 dlg.title = title;
64 dlg.set_default_size (300, -1);
65 if (parent_win != null){
66 dlg.set_transient_for(parent_win);
67 dlg.set_modal(true);
68 }
69
70 var content = (Box) dlg.get_content_area ();
71 vbox_main.append (lbl_input);
72 vbox_main.append (txt_input);
73 content.append(vbox_main);
74 content.margin_start = 6;
75 content.margin_end = 6;
76 content.margin_top = 6;
77 content.margin_bottom = 6;
78 dlg.add_button(_("OK"),Gtk.ResponseType.OK);
79 dlg.add_button(_("Cancel"),Gtk.ResponseType.CANCEL);
80 txt_input.activate.connect (() => { dlg.response(Gtk.ResponseType.OK); });
81
82 int response = gtk_dialog_run(dlg);
83 string input_text = txt_input.text;
84 dlg.destroy();
85
86 if (response == Gtk.ResponseType.CANCEL){
87 return null;
88 }
89 else{
90 return input_text;
91 }
92 }
#define _(s)
int gtk_dialog_run(Gtk.Dialog dlg)

References _, gtk_dialog_run(), and gtk_inputbox().

Referenced by gtk_inputbox(), ExcludeBox.init_actions(), and Device.luks_unlock().

◆ gtk_messagebox()

void TeeJee.GtkHelper.gtk_messagebox ( string title,
string message,
Gtk.Window? parent_win,
bool is_error = false )
static

Definition at line 35 of file GtkHelper.vala.

35 {
36
37 /* Shows a simple message box */
38
39 Gtk.MessageType type = is_error ? Gtk.MessageType.ERROR : Gtk.MessageType.INFO;
40
41 var dlg = new CustomMessageDialog(title,message,type,parent_win, Gtk.ButtonsType.OK);
42 dlg.present();
43 dlg.destroy();
44 }
CustomMessageDialog(string _msg_title, string _msg_body, Gtk.MessageType _msg_type, Window? parent, Gtk.ButtonsType _buttons_type)

References CustomMessageDialog.CustomMessageDialog(), and gtk_messagebox().

Referenced by gtk_messagebox().

◆ gtk_set_busy()

void TeeJee.GtkHelper.gtk_set_busy ( bool busy,
Gtk.Window win )

Definition at line 24 of file GtkHelper.vala.

24 {
25
26 /* Show or hide busy cursor on window */
27 if (busy)
28 win.set_cursor_from_name("wait");
29 else
30 win.set_cursor_from_name(null);
31
33 }

References gtk_do_events(), and gtk_set_busy().

Referenced by BackupDeviceBox.change_backup_device(), Main.check_btrfs_layout_system(), RestoreWindow.create_actions(), gtk_set_busy(), SmbShareDialog.on_connect_clicked(), BackupDeviceBox.try_change_smb_share(), and MainWindow.ui_sensitive().

◆ wait_and_close_window()

void TeeJee.GtkHelper.wait_and_close_window ( int milliseconds,
Gtk.Window window )

Definition at line 94 of file GtkHelper.vala.

94 {
96 int millis = 0;
97 while(millis < milliseconds){
98 sleep(200);
99 millis += 200;
101 }
102 window.destroy();
103 }
void sleep(int milliseconds)

References gtk_do_events(), TeeJee.System.sleep(), and wait_and_close_window().

Referenced by BackupWindow.initialize_tab(), DeleteWindow.initialize_tab(), and wait_and_close_window().