Commit 23c13e5fc945dacca8eb51b9edb5ca35bd32b5e0
1 parent
987ecaa7
Exists in
master
and in
1 other branch
Adding styles to popup dialog.
Showing
2 changed files
with
43 additions
and
7 deletions
Show diff stats
src/dialogs/popups.c
... | ... | @@ -36,6 +36,12 @@ |
36 | 36 | |
37 | 37 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
38 | 38 | |
39 | + static void v3270_dialog_add_class_for_response(GtkWidget *dialog, gint response_id, const char *className) { | |
40 | + GtkWidget * widget = gtk_dialog_get_widget_for_response(GTK_DIALOG(dialog),response_id); | |
41 | + GtkStyleContext *context = gtk_widget_get_style_context(widget); | |
42 | + gtk_style_context_add_class(context,className); | |
43 | + } | |
44 | + | |
39 | 45 | GtkResponseType v3270_popup_dialog_show(GtkWidget *widget, const LIB3270_POPUP *popup, gboolean wait) { |
40 | 46 | |
41 | 47 | g_return_val_if_fail(GTK_IS_WIDGET(widget),GTK_RESPONSE_NONE); |
... | ... | @@ -154,10 +160,41 @@ |
154 | 160 | |
155 | 161 | gtk_dialog_add_button(GTK_DIALOG(dialog), _("_Cancel"), GTK_RESPONSE_CANCEL); |
156 | 162 | gtk_dialog_add_button(GTK_DIALOG(dialog), popup->label, GTK_RESPONSE_APPLY); |
157 | - gtk_dialog_set_default_response( | |
158 | - GTK_DIALOG(dialog), | |
159 | - (popup->type == LIB3270_NOTIFY_SECURE ? GTK_RESPONSE_CANCEL : GTK_RESPONSE_APPLY) | |
160 | - ); | |
163 | + | |
164 | + switch(popup->type) { | |
165 | + case LIB3270_NOTIFY_SECURE: | |
166 | + case LIB3270_NOTIFY_CRITICAL: | |
167 | + gtk_dialog_set_default_response( | |
168 | + GTK_DIALOG(dialog), | |
169 | + GTK_RESPONSE_CANCEL | |
170 | + ); | |
171 | + | |
172 | + v3270_dialog_add_class_for_response(dialog,GTK_RESPONSE_APPLY,"destructive-action"); | |
173 | + v3270_dialog_add_class_for_response(dialog,GTK_RESPONSE_CANCEL,"suggested-action"); | |
174 | + break; | |
175 | + | |
176 | + case LIB3270_NOTIFY_ERROR: | |
177 | + gtk_dialog_set_default_response( | |
178 | + GTK_DIALOG(dialog), | |
179 | + GTK_RESPONSE_CANCEL | |
180 | + ); | |
181 | + v3270_dialog_add_class_for_response(dialog,GTK_RESPONSE_CANCEL,"suggested-action"); | |
182 | + break; | |
183 | + | |
184 | + case LIB3270_NOTIFY_INFO: | |
185 | + gtk_dialog_set_default_response( | |
186 | + GTK_DIALOG(dialog), | |
187 | + GTK_RESPONSE_APPLY | |
188 | + ); | |
189 | + v3270_dialog_add_class_for_response(dialog,GTK_RESPONSE_APPLY,"suggested-action"); | |
190 | + break; | |
191 | + | |
192 | + default: | |
193 | + gtk_dialog_set_default_response( | |
194 | + GTK_DIALOG(dialog), | |
195 | + GTK_RESPONSE_APPLY | |
196 | + ); | |
197 | + } | |
161 | 198 | |
162 | 199 | } else { |
163 | 200 | ... | ... |
src/testprogram/toolbar.c
... | ... | @@ -194,16 +194,15 @@ |
194 | 194 | static void popup_clicked(GtkButton *button, GtkWidget *terminal) |
195 | 195 | { |
196 | 196 | |
197 | - /* | |
198 | 197 | static const LIB3270_POPUP popup = { |
199 | 198 | .name = "sample_popup", |
200 | - .type = LIB3270_NOTIFY_INFO, | |
199 | + .type = LIB3270_NOTIFY_SECURE, | |
200 | + .label = "Continue", | |
201 | 201 | .summary = "This is the summary of message", |
202 | 202 | .body = "This it the body of the message, can be used for a bigger explanation" |
203 | 203 | }; |
204 | 204 | |
205 | 205 | lib3270_popup(v3270_get_session(terminal), &popup, 1); |
206 | - */ | |
207 | 206 | |
208 | 207 | } |
209 | 208 | ... | ... |