20 while (GLib.MainContext.default().pending())
21 GLib.MainContext.default().iteration(
false);
28 win.set_cursor_from_name(
"wait");
30 win.set_cursor_from_name(
null);
35 public static void gtk_messagebox(
string title,
string message, Gtk.Window? parent_win,
bool is_error =
false){
39 Gtk.MessageType type = is_error ? Gtk.MessageType.ERROR : Gtk.MessageType.INFO;
46 public string?
gtk_inputbox(
string title,
string message, Gtk.Window? parent_win,
bool mask_password =
false){
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;
54 Gtk.Label lbl_input =
new Gtk.Label(title);
55 lbl_input.xalign = (float) 0.0;
56 lbl_input.label = message;
58 Gtk.Entry txt_input =
new Gtk.Entry();
59 txt_input.margin_top = 3;
60 txt_input.set_visibility(!mask_password);
62 var dlg =
new Gtk.Dialog.with_buttons(title, parent_win, DialogFlags.MODAL);
64 dlg.set_default_size (300, -1);
65 if (parent_win !=
null){
66 dlg.set_transient_for(parent_win);
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); });
83 string input_text = txt_input.text;
86 if (response == Gtk.ResponseType.CANCEL){
97 while(millis < milliseconds){
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; });
122 for (
int i = 0; ; i++) {
124 var text = combo.get_active_text();
139 var text = combo.get_active_text();
140 return (text !=
null) ? text : default_value;
146 public static Gtk.Stack
add_notebook(Gtk.Box box,
bool show_tabs =
true,
bool show_border =
true){
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;
161 public static Gtk.ListBox
add_treeview(Gtk.Box box, Gtk.SelectionMode selection_mode = Gtk.SelectionMode.SINGLE){
163 var listbox =
new Gtk.ListBox();
164 listbox.selection_mode = selection_mode;
166 var scrollwin =
new Gtk.ScrolledWindow();
167 scrollwin.set_child(listbox);
168 scrollwin.hexpand =
true;
169 scrollwin.vexpand =
true;
170 box.append(scrollwin);
176 public static Gtk.Label
add_column_text(Gtk.ListBox listbox,
string title, out Gtk.Label cell){
177 cell =
new Gtk.Label(title);
184 out Gtk.Image cell_pix, out Gtk.CheckButton cell_radio, out Gtk.Label cell_text){
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);
197 public static Gtk.Label
add_label_scrolled(Gtk.Box box,
string text,
bool show_border =
false,
bool wrap =
false,
int ellipsize_chars = 40){
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;
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);
219 label.wrap_mode = Pango.WrapMode.WORD;
223 label.ellipsize = Pango.EllipsizeMode.MIDDLE;
224 label.max_width_chars = ellipsize_chars;
234 private Gtk.Label
add_label(Gtk.Box box,
string text,
bool bold =
false,
bool italic =
false,
bool large =
false){
236 string msg =
"<span%s%s%s>%s</span>".printf(
237 (bold ?
" weight=\"bold\"" :
""),
238 (italic ?
" style=\"italic\"" :
""),
239 (large ?
" size=\"x-large\"" :
""),
242 var label =
new Gtk.Label(msg);
243 label.set_use_markup(
true);
244 label.xalign = (float) 0.0;
246 label.wrap_mode = Pango.WrapMode.WORD;
251 public static string format_text(
string text,
bool bold =
false,
bool italic =
false,
bool large =
false){
253 string msg =
"<span%s%s%s>%s</span>".printf(
254 (bold ?
" weight=\"bold\"" :
""),
255 (italic ?
" style=\"italic\"" :
""),
256 (large ?
" size=\"x-large\"" :
""),
263 public static Gtk.Label
add_label_header(Gtk.Box box,
string text,
bool large_heading =
false){
266 label.margin_bottom = 12;
273 var chk =
new Gtk.CheckButton.with_label(text);
288 public static Gtk.SpinButton
add_spin(Gtk.Box box,
double min,
double max,
double val,
int digits = 0,
double step = 1,
double step_page = 1){
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;
305 public static Gtk.Button
add_button(Gtk.Box box,
string text,
string tooltip, Gtk.SizeGroup? size_group, Gtk.Image? icon =
null){
307 var button =
new Gtk.Button();
310 button.set_label(text);
311 button.set_tooltip_text(tooltip);
314 button.set_child(icon);
317 if (size_group !=
null){
318 size_group.add_widget(button);
324 public static Gtk.Box
add_button_box(Gtk.Box box, Gtk.Orientation orientation = Gtk.Orientation.HORIZONTAL,
325 Gtk.Align halign = Gtk.Align.CENTER,
int spacing = 6){
327 var bbox =
new Gtk.Box(orientation, spacing);
328 bbox.halign = halign;
CustomMessageDialog(string _msg_title, string _msg_body, Gtk.MessageType _msg_type, Window? parent, Gtk.ButtonsType _buttons_type)
static Gtk.Label add_column_text(Gtk.ListBox listbox, string title, out Gtk.Label cell)
string gtk_combobox_get_value(Gtk.ComboBoxText combo, int index, string default_value)
string? gtk_inputbox(string title, string message, Gtk.Window? parent_win, bool mask_password=false)
static Gtk.SpinButton add_spin(Gtk.Box box, double min, double max, double val, int digits=0, double step=1, double step_page=1)
void gtk_set_busy(bool busy, Gtk.Window win)
static Gtk.Box add_button_box(Gtk.Box box, Gtk.Orientation orientation=Gtk.Orientation.HORIZONTAL, Gtk.Align halign=Gtk.Align.CENTER, int spacing=6)
Gtk.Label add_label(Gtk.Box box, string text, bool bold=false, bool italic=false, bool large=false)
int gtk_dialog_run(Gtk.Dialog dlg)
static Gtk.Button add_button(Gtk.Box box, string text, string tooltip, Gtk.SizeGroup? size_group, Gtk.Image? icon=null)
static Gtk.Label add_label_header(Gtk.Box box, string text, bool large_heading=false)
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.Stack add_notebook(Gtk.Box box, bool show_tabs=true, bool show_border=true)
static Gtk.CheckButton add_checkbox(Gtk.Box box, string text)
static Gtk.ListBox add_treeview(Gtk.Box box, Gtk.SelectionMode selection_mode=Gtk.SelectionMode.SINGLE)
bool gtk_combobox_set_value(Gtk.ComboBoxText combo, int index, string val)
static string format_text(string text, bool bold=false, bool italic=false, bool large=false)
static void gtk_messagebox(string title, string message, Gtk.Window? parent_win, bool is_error=false)
static Gtk.Label add_label_scrolled(Gtk.Box box, string text, bool show_border=false, bool wrap=false, int ellipsize_chars=40)
void wait_and_close_window(int milliseconds, Gtk.Window window)
string escape_html(string html)
void sleep(int milliseconds)