Commit e021dd9f214420a924a7661dccbfa31e67bb1e4e
1 parent
a71ea169
Exists in
master
and in
1 other branch
Adding convenience method for dialog box creation.
Showing
4 changed files
with
138 additions
and
1 deletions
Show diff stats
| ... | ... | @@ -0,0 +1,123 @@ |
| 1 | +/* | |
| 2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
| 3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
| 4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | |
| 5 | + * | |
| 6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | |
| 7 | + * | |
| 8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
| 9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
| 10 | + * Free Software Foundation. | |
| 11 | + * | |
| 12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
| 13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
| 14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
| 15 | + * obter mais detalhes. | |
| 16 | + * | |
| 17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
| 18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
| 19 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | |
| 20 | + * | |
| 21 | + * Este programa está nomeado como - e possui - linhas de código. | |
| 22 | + * | |
| 23 | + * Contatos: | |
| 24 | + * | |
| 25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
| 26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
| 27 | + * | |
| 28 | + */ | |
| 29 | + | |
| 30 | + | |
| 31 | + #include "private.h" | |
| 32 | + #include <internals.h> | |
| 33 | + #include <lib3270.h> | |
| 34 | + #include <lib3270/selection.h> | |
| 35 | + #include <clipboard.h> | |
| 36 | + #include <limits.h> | |
| 37 | + #include <v3270/dialogs.h> | |
| 38 | + | |
| 39 | + | |
| 40 | +/*--[ Implement ]------------------------------------------------------------------------------------*/ | |
| 41 | + | |
| 42 | + GtkWidget * v3270_dialog_new_with_buttons(const gchar *title, GtkWidget *widget, const gchar *first_button_text, ...) { | |
| 43 | + | |
| 44 | + g_return_val_if_fail(GTK_IS_V3270(widget),NULL); | |
| 45 | + | |
| 46 | +#ifdef _WIN32 | |
| 47 | + | |
| 48 | + GtkWidget * dialog = | |
| 49 | + GTK_WIDGET(g_object_new( | |
| 50 | + GTK_TYPE_DIALOG, | |
| 51 | + "use-header-bar", FALSE, | |
| 52 | + NULL | |
| 53 | + )); | |
| 54 | + | |
| 55 | +#elif GTK_CHECK_VERSION(3,12,0) | |
| 56 | + | |
| 57 | + gboolean use_header; | |
| 58 | + g_object_get(gtk_settings_get_default(), "gtk-dialogs-use-header", &use_header, NULL); | |
| 59 | + | |
| 60 | + GtkWidget * dialog = | |
| 61 | + GTK_WIDGET(g_object_new( | |
| 62 | + GTK_TYPE_DIALOG, | |
| 63 | + "use-header-bar", (use_header ? 1 : 0), | |
| 64 | + NULL | |
| 65 | + )); | |
| 66 | + | |
| 67 | +#else | |
| 68 | + | |
| 69 | + GtkWidget * dialog = GTK_WIDGET(g_object_new(GTK_TYPE_DIALOG, NULL)); | |
| 70 | + | |
| 71 | +#endif // GTK 3.12 | |
| 72 | + | |
| 73 | + // Setup visual elements | |
| 74 | + // https://developer.gnome.org/hig/stable/visual-layout.html.en | |
| 75 | + gtk_window_set_resizable(GTK_WINDOW(dialog),FALSE); | |
| 76 | + | |
| 77 | +#ifdef G_OS_UNIX | |
| 78 | + gtk_container_set_border_width(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),18); | |
| 79 | +#endif // UNIX | |
| 80 | + | |
| 81 | + // Setup window | |
| 82 | + gtk_window_set_title(GTK_WINDOW(dialog),title); | |
| 83 | + gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE); | |
| 84 | + gtk_window_set_transient_for(GTK_WINDOW(dialog),GTK_WINDOW(gtk_widget_get_toplevel(widget))); | |
| 85 | + gtk_window_set_modal(GTK_WINDOW(dialog),TRUE); | |
| 86 | + | |
| 87 | + g_signal_connect(dialog,"close",G_CALLBACK(gtk_widget_destroy),NULL); | |
| 88 | + | |
| 89 | + // Add buttons | |
| 90 | + const gchar* text; | |
| 91 | + gint response_id; | |
| 92 | + | |
| 93 | + va_list args; | |
| 94 | + va_start (args, first_button_text); | |
| 95 | + | |
| 96 | + text = first_button_text; | |
| 97 | + response_id = va_arg (args, gint); | |
| 98 | + while(text != NULL) { | |
| 99 | + | |
| 100 | +#ifdef G_OS_UNIX | |
| 101 | + | |
| 102 | + gtk_dialog_add_button(GTK_DIALOG(dialog), text, response_id); | |
| 103 | +#else | |
| 104 | + | |
| 105 | + GtkWidget * button = gtk_dialog_add_button(GTK_DIALOG(dialog), text, response_id); | |
| 106 | + gtk_widget_set_margin_top(button,3); | |
| 107 | + | |
| 108 | +#endif // G_OS_UNIX | |
| 109 | + | |
| 110 | + text = va_arg (args, gchar*); | |
| 111 | + if (text == NULL) | |
| 112 | + break; | |
| 113 | + response_id = va_arg (args, int); | |
| 114 | + } | |
| 115 | + | |
| 116 | + va_end(args); | |
| 117 | + | |
| 118 | + return dialog; | |
| 119 | + | |
| 120 | + } | |
| 121 | + | |
| 122 | + | |
| 123 | + | ... | ... |
src/include/v3270/dialogs.h
| ... | ... | @@ -35,6 +35,8 @@ |
| 35 | 35 | |
| 36 | 36 | G_BEGIN_DECLS |
| 37 | 37 | |
| 38 | + LIB3270_EXPORT GtkWidget * v3270_dialog_new_with_buttons(const gchar *title, GtkWidget *widget, const gchar *first_button_text, ...) G_GNUC_NULL_TERMINATED; | |
| 39 | + | |
| 38 | 40 | LIB3270_EXPORT void v3270_error_popup(GtkWidget *widget, const gchar *title, const gchar *summary, const gchar *body); |
| 39 | 41 | |
| 40 | 42 | LIB3270_EXPORT GtkWidget * v3270_save_dialog_new(GtkWidget *widget, LIB3270_CONTENT_OPTION mode, const gchar *filename); | ... | ... |
src/testprogram/toolbar.c
| ... | ... | @@ -115,7 +115,16 @@ |
| 115 | 115 | |
| 116 | 116 | static void ft_clicked(GtkButton *button, GtkWidget *terminal) |
| 117 | 117 | { |
| 118 | - v3270_error_popup(terminal,"title","summary","body"); | |
| 118 | + // v3270_error_popup(terminal,"title","summary","body"); | |
| 119 | + | |
| 120 | + { | |
| 121 | + GtkWidget * dialog = v3270_dialog_new_with_buttons("Testing dialog", terminal, "Ok", GTK_RESPONSE_OK, "Cancel", GTK_RESPONSE_CANCEL, NULL); | |
| 122 | + | |
| 123 | + g_signal_connect(dialog,"response",G_CALLBACK(gtk_widget_destroy),NULL); | |
| 124 | + gtk_widget_show_all(dialog); | |
| 125 | + | |
| 126 | + } | |
| 127 | + | |
| 119 | 128 | |
| 120 | 129 | /* |
| 121 | 130 | // | ... | ... |
v3270.cbp
| ... | ... | @@ -48,6 +48,9 @@ |
| 48 | 48 | <Unit filename="src/dialogs/commondialog.c"> |
| 49 | 49 | <Option compilerVar="CC" /> |
| 50 | 50 | </Unit> |
| 51 | + <Unit filename="src/dialogs/dialog.c"> | |
| 52 | + <Option compilerVar="CC" /> | |
| 53 | + </Unit> | |
| 51 | 54 | <Unit filename="src/dialogs/font/chooser.c"> |
| 52 | 55 | <Option compilerVar="CC" /> |
| 53 | 56 | </Unit> | ... | ... |