Commit b079db7b57c80140086d9b319e6cb0463f95f8d7
1 parent
a7693b7d
Exists in
master
and in
1 other branch
Moving customized "pack" methods to global methods to avoid code
repetition.
Showing
5 changed files
with
173 additions
and
27 deletions
Show diff stats
| ... | ... | @@ -0,0 +1,66 @@ |
| 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 | + #include <internals.h> | |
| 31 | + | |
| 32 | +/*--[ Implement ]------------------------------------------------------------------------------------*/ | |
| 33 | + | |
| 34 | + GtkWidget * v3270_dialog_create_grid(GtkAlign align) | |
| 35 | + { | |
| 36 | + GtkWidget * grid = gtk_grid_new(); | |
| 37 | + | |
| 38 | + gtk_grid_set_row_spacing(GTK_GRID(grid),6); | |
| 39 | + gtk_grid_set_column_spacing(GTK_GRID(grid),12); | |
| 40 | + | |
| 41 | + g_object_set(G_OBJECT(grid),"margin-top",6,NULL); | |
| 42 | + gtk_widget_set_halign(GTK_WIDGET(grid),align); | |
| 43 | + | |
| 44 | + return grid; | |
| 45 | + } | |
| 46 | + | |
| 47 | + GtkWidget * v3270_box_pack_frame(GtkWidget *box, GtkWidget *child, const gchar *title, GtkAlign align, gboolean expand, gboolean fill, guint padding) | |
| 48 | + { | |
| 49 | + GtkFrame * frame = GTK_FRAME(gtk_frame_new("")); | |
| 50 | + g_autofree gchar * markup = g_strdup_printf("<b>%s</b>",title); | |
| 51 | + GtkWidget * label = gtk_label_new(NULL); | |
| 52 | + | |
| 53 | + gtk_frame_set_shadow_type(GTK_FRAME(frame),GTK_SHADOW_NONE); | |
| 54 | + gtk_label_set_markup(GTK_LABEL(label),markup); | |
| 55 | + gtk_frame_set_label_widget(GTK_FRAME(frame),label); | |
| 56 | + | |
| 57 | + gtk_container_add(GTK_CONTAINER(frame),GTK_WIDGET(child)); | |
| 58 | + gtk_widget_set_halign(GTK_WIDGET(frame),align); | |
| 59 | + | |
| 60 | + g_object_set(G_OBJECT(frame),"margin-top",6,NULL); | |
| 61 | + | |
| 62 | + gtk_box_pack_start(GTK_BOX(box),GTK_WIDGET(frame),expand,fill,padding); | |
| 63 | + | |
| 64 | + return child; | |
| 65 | + } | |
| 66 | + | ... | ... |
| ... | ... | @@ -0,0 +1,67 @@ |
| 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 | +#ifndef V3270_INTERNALS_H_INCLUDED | |
| 31 | + | |
| 32 | + #define V3270_INTERNALS_H_INCLUDED 1 | |
| 33 | + | |
| 34 | + #include <glib.h> | |
| 35 | + #include <gtk/gtk.h> | |
| 36 | + #include <lib3270.h> | |
| 37 | + #include <lib3270/log.h> | |
| 38 | + #include <v3270.h> | |
| 39 | + | |
| 40 | + #if ! GLIB_CHECK_VERSION(2,44,0) | |
| 41 | + | |
| 42 | + // Reference: https://github.com/ImageMagick/glib/blob/master/glib/glib-autocleanups.h | |
| 43 | + static inline void v3270_autoptr_cleanup_generic_gfree(void *p) | |
| 44 | + { | |
| 45 | + void **pp = (void**)p; | |
| 46 | + g_free (*pp); | |
| 47 | + } | |
| 48 | + | |
| 49 | + #define g_autofree __attribute__((cleanup(v3270_autoptr_cleanup_generic_gfree))) | |
| 50 | + | |
| 51 | + #endif // ! GLIB(2,44,0) | |
| 52 | + | |
| 53 | + G_BEGIN_DECLS | |
| 54 | + | |
| 55 | + inline GtkWidget * v3270_box_pack_start(GtkWidget *box, GtkWidget *child, gboolean expand, gboolean fill, guint padding) | |
| 56 | + { | |
| 57 | + gtk_box_pack_start(GTK_BOX(box),child,expand,fill,padding); | |
| 58 | + return child; | |
| 59 | + } | |
| 60 | + | |
| 61 | + G_GNUC_INTERNAL GtkWidget * v3270_box_pack_frame(GtkWidget *box, GtkWidget *child, const gchar *title, GtkAlign align, gboolean expand, gboolean fill, guint padding); | |
| 62 | + G_GNUC_INTERNAL GtkWidget * v3270_dialog_create_grid(GtkAlign align); | |
| 63 | + | |
| 64 | + | |
| 65 | + G_END_DECLS | |
| 66 | + | |
| 67 | +#endif // V3270_INTERNALS_H_INCLUDED | ... | ... |
src/testprogram/testprogram.c
| ... | ... | @@ -260,7 +260,7 @@ static void activate(GtkApplication* app, G_GNUC_UNUSED gpointer user_data) { |
| 260 | 260 | GtkWidget * toolbar = gtk_toolbar_new(); |
| 261 | 261 | for(f = 0; f < G_N_ELEMENTS(buttons); f++) |
| 262 | 262 | { |
| 263 | - GtkWidget * button = gtk_tool_button_new_from_stock(buttons[f].icon); | |
| 263 | + GtkWidget * button = GTK_WIDGET(gtk_tool_button_new_from_stock(buttons[f].icon)); | |
| 264 | 264 | gtk_widget_set_tooltip_markup(button,buttons[f].tooltip); |
| 265 | 265 | g_signal_connect(G_OBJECT(button),"clicked",buttons[f].callback,terminal); |
| 266 | 266 | gtk_toolbar_insert(GTK_TOOLBAR(toolbar),GTK_TOOL_ITEM(button),-1); | ... | ... |
src/v3270ft/private.h
| ... | ... | @@ -43,6 +43,7 @@ |
| 43 | 43 | #include <v3270/filetransfer.h> |
| 44 | 44 | #include <v3270/ftprogress.h> |
| 45 | 45 | #include <lib3270.h> |
| 46 | + #include <lib3270/log.h> | |
| 46 | 47 | #include <lib3270/filetransfer.h> |
| 47 | 48 | |
| 48 | 49 | #define NUM_OPTIONS_WIDGETS 12 |
| ... | ... | @@ -179,17 +180,6 @@ |
| 179 | 180 | |
| 180 | 181 | }; |
| 181 | 182 | |
| 182 | - #ifdef DEBUG | |
| 183 | - | |
| 184 | - #define debug(fmt, ...) g_message( "%s(%d) " fmt , __FILE__, (int) __LINE__, __VA_ARGS__ ) | |
| 185 | - | |
| 186 | - #else | |
| 187 | - | |
| 188 | - #define debug(fmt, ...) /* */ | |
| 189 | - | |
| 190 | - #endif // DEBUG | |
| 191 | - | |
| 192 | - | |
| 193 | 183 | G_GNUC_INTERNAL guint v3270ftprogress_signal[V3270FTPROGRESS_SIGNAL_COUNT]; |
| 194 | 184 | |
| 195 | 185 | ... | ... |
src/v3270ft/settings.c
| ... | ... | @@ -28,9 +28,9 @@ |
| 28 | 28 | */ |
| 29 | 29 | |
| 30 | 30 | #include <string.h> |
| 31 | - #include <v3270.h> | |
| 32 | - #include <v3270/filetransfer.h> | |
| 31 | + #include <internals.h> | |
| 33 | 32 | #include "private.h" |
| 33 | + #include <v3270/filetransfer.h> | |
| 34 | 34 | |
| 35 | 35 | /*--[ Widget definition ]----------------------------------------------------------------------------*/ |
| 36 | 36 | |
| ... | ... | @@ -83,8 +83,11 @@ |
| 83 | 83 | return entry; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | + /* | |
| 86 | 87 | static GtkWidget * create_frame(GtkWidget *container, const gchar *title, GtkWidget *box, GtkAlign align) |
| 87 | 88 | { |
| 89 | + gtk_box_pack_start(GTK_BOX(container),v3270_dialog_create_frame(title,box,align),TRUE,TRUE,0); | |
| 90 | + | |
| 88 | 91 | GtkFrame * frame = GTK_FRAME(gtk_frame_new("")); |
| 89 | 92 | g_autofree gchar * markup = g_strdup_printf("<b>%s</b>",title); |
| 90 | 93 | GtkWidget * label = gtk_label_new(NULL); |
| ... | ... | @@ -102,19 +105,11 @@ |
| 102 | 105 | |
| 103 | 106 | return box; |
| 104 | 107 | } |
| 108 | + */ | |
| 105 | 109 | |
| 106 | 110 | static GtkWidget * create_grid(GtkWidget *container, GtkAlign align) |
| 107 | 111 | { |
| 108 | - GtkWidget * grid = gtk_grid_new(); | |
| 109 | - | |
| 110 | - gtk_grid_set_row_spacing(GTK_GRID(grid),6); | |
| 111 | - gtk_grid_set_column_spacing(GTK_GRID(grid),12); | |
| 112 | - | |
| 113 | - g_object_set(G_OBJECT(grid),"margin-top",6,NULL); | |
| 114 | - gtk_widget_set_halign(GTK_WIDGET(grid),align); | |
| 115 | - gtk_box_pack_start(GTK_BOX(container),GTK_WIDGET(grid),TRUE,TRUE,0); | |
| 116 | - | |
| 117 | - return grid; | |
| 112 | + return v3270_box_pack_start(container,v3270_dialog_create_grid(align),TRUE,TRUE,0); | |
| 118 | 113 | } |
| 119 | 114 | |
| 120 | 115 | GtkWidget * create_spin_button(V3270FTSettings *widget, GtkWidget *grid, size_t row, LIB3270_FT_VALUE id) |
| ... | ... | @@ -277,7 +272,16 @@ static void open_select_file_dialog(GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconP |
| 277 | 272 | |
| 278 | 273 | // Transfer options |
| 279 | 274 | { |
| 280 | - GtkWidget * box = create_frame(options, _("Transfer options"), gtk_box_new(GTK_ORIENTATION_VERTICAL,6),GTK_ALIGN_START); | |
| 275 | + GtkWidget * box = | |
| 276 | + v3270_box_pack_frame( | |
| 277 | + options, | |
| 278 | + gtk_box_new(GTK_ORIENTATION_VERTICAL,6), | |
| 279 | + _("Transfer options"), | |
| 280 | + GTK_ALIGN_START, | |
| 281 | + FALSE, | |
| 282 | + FALSE, | |
| 283 | + 0 | |
| 284 | + ); | |
| 281 | 285 | |
| 282 | 286 | for(ix=0;ix<4;ix++) |
| 283 | 287 | { |
| ... | ... | @@ -293,7 +297,17 @@ static void open_select_file_dialog(GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconP |
| 293 | 297 | // Record format |
| 294 | 298 | { |
| 295 | 299 | GSList * group = NULL; |
| 296 | - widget->recordFormatBox = create_frame(options, _("Record format"), gtk_box_new(GTK_ORIENTATION_VERTICAL,6),GTK_ALIGN_CENTER); | |
| 300 | + | |
| 301 | + widget->recordFormatBox = | |
| 302 | + v3270_box_pack_frame( | |
| 303 | + options, | |
| 304 | + gtk_box_new(GTK_ORIENTATION_VERTICAL,6), | |
| 305 | + _("Record format"), | |
| 306 | + GTK_ALIGN_CENTER, | |
| 307 | + FALSE, | |
| 308 | + FALSE, | |
| 309 | + 0 | |
| 310 | + ); | |
| 297 | 311 | |
| 298 | 312 | for(ix=4;ix<8;ix++) |
| 299 | 313 | { |
| ... | ... | @@ -309,7 +323,16 @@ static void open_select_file_dialog(GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconP |
| 309 | 323 | // Space allocation units |
| 310 | 324 | { |
| 311 | 325 | GSList * group = NULL; |
| 312 | - widget->spaceAllocationBox = create_frame(options, _("Space allocation units"), gtk_box_new(GTK_ORIENTATION_VERTICAL,6),GTK_ALIGN_END); | |
| 326 | + widget->spaceAllocationBox = | |
| 327 | + v3270_box_pack_frame( | |
| 328 | + options, | |
| 329 | + gtk_box_new(GTK_ORIENTATION_VERTICAL,6), | |
| 330 | + _("Space allocation units"), | |
| 331 | + GTK_ALIGN_END, | |
| 332 | + FALSE, | |
| 333 | + FALSE, | |
| 334 | + 0 | |
| 335 | + ); | |
| 313 | 336 | |
| 314 | 337 | for(ix=8;ix<12;ix++) |
| 315 | 338 | { | ... | ... |