Skip to content
API Documentation
BastionGuard™
CustomMessageDialog Class Reference
Inheritance diagram for CustomMessageDialog:

Public Member Functions

 CustomMessageDialog (string _msg_title, string _msg_body, Gtk.MessageType _msg_type, Window? parent, Gtk.ButtonsType _buttons_type)
void init_window ()
int run ()

Private Attributes

Gtk.Box vbox_main
Gtk.Label lbl_msg
Gtk.ScrolledWindow sw_msg
Gtk.Button btn_ok
Gtk.Button btn_cancel
Gtk.Button btn_yes
Gtk.Button btn_no
string msg_title
string msg_body
Gtk.MessageType msg_type
Gtk.ButtonsType buttons_type

Detailed Description

Definition at line 36 of file CustomMessageDialog.vala.

Constructor & Destructor Documentation

◆ CustomMessageDialog()

CustomMessageDialog.CustomMessageDialog ( string _msg_title,
string _msg_body,
Gtk.MessageType _msg_type,
Window? parent,
Gtk.ButtonsType _buttons_type )
inline

Definition at line 51 of file CustomMessageDialog.vala.

51 {
52
53 set_transient_for(parent);
54 set_modal(true);
55
56 msg_title = _msg_title;
57 msg_body = _msg_body;
58 msg_type = _msg_type;
59 buttons_type = _buttons_type;
60
62
63 lbl_msg.hexpand = true;
64
65 lbl_msg.vexpand = true;
66 sw_msg.hexpand = true;
67 sw_msg.vexpand = true;
68 sw_msg.vscrollbar_policy = PolicyType.NEVER;
69
70 sw_msg.set_size_request(500, 150); // sets minimum size
71
72 show();
73
74 if (lbl_msg.get_allocated_height() > 400){
75 sw_msg.vscrollbar_policy = PolicyType.AUTOMATIC;
76 sw_msg.set_size_request(500, 400);
77 }
78 }
Gtk.ScrolledWindow sw_msg

References buttons_type, init_window(), lbl_msg, msg_body, msg_title, msg_type, and sw_msg.

Referenced by RestoreWindow.create_actions(), TeeJee.GtkHelper.gtk_messagebox(), and MainWindow.on_close_request().

Member Function Documentation

◆ init_window()

void CustomMessageDialog.init_window ( )
inline

Definition at line 80 of file CustomMessageDialog.vala.

80 {
81
82 this.title = "";
83 this.set_icon_name("bastionguard-backup");
84 this.resizable = false;
85 this.deletable = false;
86
87 //vbox_main
88 vbox_main = get_content_area () as Gtk.Box;
89 vbox_main.margin_start = 6;
90 vbox_main.margin_end = 6;
91 vbox_main.margin_top = 6;
92 vbox_main.margin_bottom = 6;
93
94 //hbox_contents
95 var hbox_contents = new Gtk.Box(Orientation.HORIZONTAL, 6);
96 hbox_contents.margin_start = 6;
97 hbox_contents.margin_end = 6;
98 hbox_contents.margin_top = 6;
99 hbox_contents.margin_bottom = 6;
100 vbox_main.append(hbox_contents);
101
102 string icon_name = "dialog-info";
103
104 switch(msg_type){
105 case Gtk.MessageType.INFO:
106 icon_name = "dialog-info";
107 break;
108 case Gtk.MessageType.WARNING:
109 icon_name = "dialog-warning";
110 break;
111 case Gtk.MessageType.QUESTION:
112 icon_name = "dialog-question";
113 break;
114 case Gtk.MessageType.ERROR:
115 icon_name = "dialog-error";
116 break;
117 case Gtk.MessageType.OTHER:
118 icon_name = "dialog-info";
119 break;
120 }
121
122 // image ----------------
123
124 var img = IconManager.lookup_image(icon_name, 16);
125 hbox_contents.append(img);
126
127 // label -------------------
128
129 var text = "<span weight=\"bold\" size=\"x-large\">%s</span>\n\n%s".printf(
131 msg_body);
132 lbl_msg = new Gtk.Label(text);
133 lbl_msg.xalign = 0.0f;
134 lbl_msg.yalign = 0.0f;
135 lbl_msg.max_width_chars = 70;
136 lbl_msg.wrap = true;
137 lbl_msg.wrap_mode = Pango.WrapMode.WORD_CHAR;
138 lbl_msg.use_markup = true;
139
140 //sw_msg
141 sw_msg = new Gtk.ScrolledWindow();
142 //sw_msg.set_shadow_type (ShadowType.ETCHED_IN);
143 sw_msg.set_child(lbl_msg);
144 sw_msg.hscrollbar_policy = PolicyType.NEVER;
145 sw_msg.vscrollbar_policy = PolicyType.NEVER;
146 //sw_msg.set_size_request(500, 400);
147 hbox_contents.append(sw_msg);
148
149 // actions -------------------------
150
151 switch(buttons_type){
152 case Gtk.ButtonsType.NONE: break;
153 case Gtk.ButtonsType.OK:
154 btn_ok = (Gtk.Button) add_button (_("OK"), Gtk.ResponseType.OK);
155 btn_ok.grab_focus();
156 break;
157 case Gtk.ButtonsType.CLOSE:
158 btn_cancel = (Gtk.Button) add_button (_("Close"), Gtk.ResponseType.CLOSE);
159 btn_cancel.grab_focus();
160 break;
161 case Gtk.ButtonsType.CANCEL:
162 btn_cancel = (Gtk.Button) add_button (_("Cancel"), Gtk.ResponseType.CANCEL);
163 btn_cancel.grab_focus();
164 break;
165 case Gtk.ButtonsType.OK_CANCEL:
166 btn_ok = (Gtk.Button) add_button (_("OK"), Gtk.ResponseType.OK);
167 btn_cancel = (Gtk.Button) add_button (_("Cancel"), Gtk.ResponseType.CANCEL);
168 btn_ok.grab_focus();
169 break;
170 case Gtk.ButtonsType.YES_NO:
171 btn_yes = (Gtk.Button) add_button (_("Yes"), Gtk.ResponseType.YES);
172 btn_no = (Gtk.Button) add_button (_("No"), Gtk.ResponseType.NO);
173 btn_yes.grab_focus();
174 break;
175 }
176 }
#define _(s)
string escape_html(string html)

References _, btn_cancel, btn_no, btn_ok, btn_yes, buttons_type, TeeJee.Misc.escape_html(), lbl_msg, IconManager.lookup_image(), msg_body, msg_title, msg_type, sw_msg, and vbox_main.

Referenced by CustomMessageDialog().

◆ run()

int CustomMessageDialog.run ( )
inline

Definition at line 178 of file CustomMessageDialog.vala.

178 {
179 int result = Gtk.ResponseType.CLOSE;
180 var loop = new GLib.MainLoop(null, false);
181 this.response.connect((response_id) => { result = response_id; loop.quit(); });
182 this.close_request.connect(() => { result = Gtk.ResponseType.CLOSE; if (loop.is_running()) loop.quit(); return false; });
183 this.present();
184 loop.run();
185 return result;
186 }

Member Data Documentation

◆ btn_cancel

Gtk.Button CustomMessageDialog.btn_cancel
private

Definition at line 42 of file CustomMessageDialog.vala.

Referenced by init_window().

◆ btn_no

Gtk.Button CustomMessageDialog.btn_no
private

Definition at line 44 of file CustomMessageDialog.vala.

Referenced by init_window().

◆ btn_ok

Gtk.Button CustomMessageDialog.btn_ok
private

Definition at line 41 of file CustomMessageDialog.vala.

Referenced by init_window().

◆ btn_yes

Gtk.Button CustomMessageDialog.btn_yes
private

Definition at line 43 of file CustomMessageDialog.vala.

Referenced by init_window().

◆ buttons_type

Gtk.ButtonsType CustomMessageDialog.buttons_type
private

Definition at line 49 of file CustomMessageDialog.vala.

Referenced by CustomMessageDialog(), and init_window().

◆ lbl_msg

Gtk.Label CustomMessageDialog.lbl_msg
private

Definition at line 39 of file CustomMessageDialog.vala.

Referenced by CustomMessageDialog(), and init_window().

◆ msg_body

string CustomMessageDialog.msg_body
private

Definition at line 47 of file CustomMessageDialog.vala.

Referenced by CustomMessageDialog(), and init_window().

◆ msg_title

string CustomMessageDialog.msg_title
private

Definition at line 46 of file CustomMessageDialog.vala.

Referenced by CustomMessageDialog(), and init_window().

◆ msg_type

Gtk.MessageType CustomMessageDialog.msg_type
private

Definition at line 48 of file CustomMessageDialog.vala.

Referenced by CustomMessageDialog(), and init_window().

◆ sw_msg

Gtk.ScrolledWindow CustomMessageDialog.sw_msg
private

Definition at line 40 of file CustomMessageDialog.vala.

Referenced by CustomMessageDialog(), and init_window().

◆ vbox_main

Gtk.Box CustomMessageDialog.vbox_main
private

Definition at line 38 of file CustomMessageDialog.vala.

Referenced by init_window().


The documentation for this class was generated from the following file: