Commit 78b64d959a192e4b4dc2eda9a4a446a379479431
1 parent
b8df67f8
Exists in
master
and in
1 other branch
Reworking FT settings dialog in a style more compatible with gnome
layout guidelines.
Showing
3 changed files
with
200 additions
and
0 deletions
Show diff stats
src/include/v3270/filetransfer.h
| ... | ... | @@ -39,6 +39,8 @@ |
| 39 | 39 | |
| 40 | 40 | G_BEGIN_DECLS |
| 41 | 41 | |
| 42 | + // Old version (will be deprecated) | |
| 43 | + | |
| 42 | 44 | #define GTK_TYPE_V3270FT (v3270ft_get_type ()) |
| 43 | 45 | #define GTK_V3270FT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_V3270FT, v3270ft)) |
| 44 | 46 | #define GTK_V3270FT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_V3270FT, v3270ftClass)) |
| ... | ... | @@ -79,6 +81,19 @@ |
| 79 | 81 | |
| 80 | 82 | gint v3270ft_transfer(GtkWidget *dialog, H3270 *session); |
| 81 | 83 | |
| 84 | + // FT Settings widget | |
| 85 | + #define GTK_TYPE_V3270_FT_SETTINGS (V3270FTSettings_get_type ()) | |
| 86 | + #define GTK_V3270_FT_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_V3270_FT_SETTINGS, V3270FTSettings)) | |
| 87 | + #define GTK_V3270_FT_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_V3270_FT_SETTINGS, V3270FTSettingsClass)) | |
| 88 | + #define GTK_IS_V3270_FT_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_V3270_FT_SETTINGS)) | |
| 89 | + #define GTK_IS_V3270_FT_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_V3270_FT_SETTINGS)) | |
| 90 | + #define GTK_V3270_FT_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_V3270_FT_SETTINGS, V3270FTSettingsClass)) | |
| 91 | + | |
| 92 | + typedef struct _V3270FTSettings V3270FTSettings; | |
| 93 | + typedef struct _V3270FTSettingsClass V3270FTSettingsClass; | |
| 94 | + | |
| 95 | + LIB3270_EXPORT GtkWidget * v3270_ft_settings_new(); | |
| 96 | + | |
| 82 | 97 | G_END_DECLS |
| 83 | 98 | |
| 84 | 99 | #endif // V3270FT_H_INCLUDED | ... | ... |
src/testprogram/testprogram.c
| ... | ... | @@ -149,8 +149,21 @@ static void disconnect_clicked(GtkButton G_GNUC_UNUSED(*button), GtkWidget *term |
| 149 | 149 | |
| 150 | 150 | static void ft_clicked(GtkButton G_GNUC_UNUSED(*button), GtkWidget *terminal) |
| 151 | 151 | { |
| 152 | + GtkWidget * dialog = gtk_dialog_new_with_buttons( | |
| 153 | + _("FT Settings"), | |
| 154 | + GTK_WINDOW(gtk_widget_get_toplevel(terminal)), | |
| 155 | + GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, | |
| 156 | + _( "_Close" ), GTK_RESPONSE_ACCEPT, | |
| 157 | + NULL | |
| 158 | + ); | |
| 159 | + | |
| 160 | + gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),v3270_ft_settings_new(),TRUE,TRUE,2); | |
| 161 | + | |
| 162 | + /* | |
| 152 | 163 | GtkWidget * dialog = v3270ft_new(); |
| 153 | 164 | gtk_window_set_transient_for(GTK_WINDOW(dialog),GTK_WINDOW(gtk_widget_get_toplevel(terminal))); |
| 165 | + */ | |
| 166 | + | |
| 154 | 167 | gtk_widget_show_all(dialog); |
| 155 | 168 | gtk_dialog_run(GTK_DIALOG(dialog)); |
| 156 | 169 | gtk_widget_destroy(dialog); | ... | ... |
| ... | ... | @@ -0,0 +1,172 @@ |
| 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 <string.h> | |
| 31 | + #include <v3270.h> | |
| 32 | + #include <v3270/filetransfer.h> | |
| 33 | + #include "private.h" | |
| 34 | + | |
| 35 | +/*--[ Widget definition ]----------------------------------------------------------------------------*/ | |
| 36 | + | |
| 37 | + struct _V3270FTSettingsClass | |
| 38 | + { | |
| 39 | + GtkGridClass parent_class; | |
| 40 | + | |
| 41 | + }; | |
| 42 | + | |
| 43 | + struct _V3270FTSettings | |
| 44 | + { | |
| 45 | + GtkGrid parent; | |
| 46 | + | |
| 47 | + struct { | |
| 48 | + GtkEntry * local; | |
| 49 | + GtkEntry * remote; | |
| 50 | + } file; | |
| 51 | + | |
| 52 | + GtkWidget * options[NUM_OPTIONS_WIDGETS]; | |
| 53 | + }; | |
| 54 | + | |
| 55 | + G_DEFINE_TYPE(V3270FTSettings, V3270FTSettings, GTK_TYPE_GRID); | |
| 56 | + | |
| 57 | +/*--[ Implement ]------------------------------------------------------------------------------------*/ | |
| 58 | + | |
| 59 | + static void V3270FTSettings_class_init(G_GNUC_UNUSED V3270FTSettingsClass *klass) | |
| 60 | + { | |
| 61 | + | |
| 62 | + | |
| 63 | + } | |
| 64 | + | |
| 65 | + static GtkWidget * create_label(V3270FTSettings *widget, const gchar *mnemonic, gint left, gint top) | |
| 66 | + { | |
| 67 | + GtkWidget * label = gtk_label_new_with_mnemonic(mnemonic); | |
| 68 | + gtk_widget_set_halign(GTK_WIDGET(label),GTK_ALIGN_END); | |
| 69 | + gtk_grid_attach(GTK_GRID(widget),label,left,top,1,1); | |
| 70 | + return label; | |
| 71 | + } | |
| 72 | + | |
| 73 | + static GtkWidget * create_entry(V3270FTSettings *widget, const gchar *mnemonic, GtkWidget *entry, gint left, gint top, gint width) | |
| 74 | + { | |
| 75 | + GtkWidget * label = create_label(widget,mnemonic,left,top); | |
| 76 | + gtk_grid_attach(GTK_GRID(widget),entry,left+1,top,width,1); | |
| 77 | + gtk_label_set_mnemonic_widget(GTK_LABEL(label),entry); | |
| 78 | + gtk_widget_set_hexpand(entry,TRUE); | |
| 79 | + return entry; | |
| 80 | + } | |
| 81 | + | |
| 82 | + static GtkWidget * create_frame(V3270FTSettings *widget, const gchar *title, GtkWidget *box, gint left, gint top, gint width, gint height, gint margin_top) | |
| 83 | + { | |
| 84 | + GtkFrame * frame = GTK_FRAME(gtk_frame_new("")); | |
| 85 | + g_autofree gchar * markup = g_strdup_printf("<b>%s</b>",title); | |
| 86 | + GtkWidget * label = gtk_label_new(NULL); | |
| 87 | + | |
| 88 | + if(margin_top) | |
| 89 | + g_object_set(G_OBJECT(frame),"margin-top",margin_top,NULL); | |
| 90 | + | |
| 91 | + gtk_frame_set_shadow_type(GTK_FRAME(frame),GTK_SHADOW_NONE); | |
| 92 | + gtk_label_set_markup(GTK_LABEL(label),markup); | |
| 93 | + gtk_frame_set_label_widget(GTK_FRAME(frame),label); | |
| 94 | + | |
| 95 | + gtk_container_add(GTK_CONTAINER(frame),GTK_WIDGET(box)); | |
| 96 | + | |
| 97 | + gtk_grid_attach(GTK_GRID(widget),GTK_WIDGET(frame),left,top,width,height); | |
| 98 | + | |
| 99 | + g_object_set(G_OBJECT(box),"margin-top",6,NULL); | |
| 100 | + | |
| 101 | + return box; | |
| 102 | + } | |
| 103 | + | |
| 104 | + static void V3270FTSettings_init(V3270FTSettings *widget) | |
| 105 | + { | |
| 106 | + size_t ix; | |
| 107 | + | |
| 108 | + // https://developer.gnome.org/hig/stable/visual-layout.html.en | |
| 109 | + gtk_grid_set_row_spacing(GTK_GRID(widget),6); | |
| 110 | + gtk_grid_set_column_spacing(GTK_GRID(widget),12); | |
| 111 | + | |
| 112 | + // Operation type | |
| 113 | + { | |
| 114 | + GtkTreeModel * model = GTK_TREE_MODEL(gtk_list_store_new(2,G_TYPE_STRING,G_TYPE_ULONG)); | |
| 115 | + GtkWidget * entry = create_entry(widget,"_Operation",gtk_combo_box_new_with_model(model),0,0,10); | |
| 116 | + GtkCellRenderer * renderer = gtk_cell_renderer_text_new(); | |
| 117 | + | |
| 118 | + gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(entry), renderer, TRUE); | |
| 119 | + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(entry), renderer, "text", 0, NULL); | |
| 120 | + | |
| 121 | + for(ix=0;ix < NUM_TYPES;ix++) | |
| 122 | + { | |
| 123 | + GtkTreeIter iter; | |
| 124 | + gtk_list_store_append((GtkListStore *) model,&iter); | |
| 125 | + gtk_list_store_set((GtkListStore *) model, &iter, 0, gettext(ft_type[ix].label),-1); | |
| 126 | + } | |
| 127 | + | |
| 128 | + | |
| 129 | + } | |
| 130 | + | |
| 131 | + // Local and remote file names. | |
| 132 | + { | |
| 133 | + // Local file name | |
| 134 | + widget->file.local = GTK_ENTRY(create_entry(widget,"_Local file",gtk_entry_new(),0,1,10)); | |
| 135 | + gtk_entry_set_icon_from_icon_name(widget->file.local,GTK_ENTRY_ICON_SECONDARY,"document-open"); | |
| 136 | + gtk_entry_set_icon_activatable(widget->file.local,GTK_ENTRY_ICON_SECONDARY,TRUE); | |
| 137 | + gtk_entry_set_icon_tooltip_text(widget->file.local,GTK_ENTRY_ICON_SECONDARY,_("Select file")); | |
| 138 | + | |
| 139 | + // g_signal_connect(G_OBJECT(widget->file.local),"icon-press",G_CALLBACK(open_select_file_dialog),dialog); | |
| 140 | + | |
| 141 | + // Remote file name | |
| 142 | + widget->file.remote = GTK_ENTRY(create_entry(widget,"_Remote file",gtk_entry_new(),0,2,10)); | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + } | |
| 147 | + | |
| 148 | + // Transfer options | |
| 149 | + { | |
| 150 | + GtkWidget * box = create_frame(widget, _("Transfer options"), gtk_box_new(GTK_ORIENTATION_VERTICAL,6), 0, 3, 5, 5, 8); | |
| 151 | + | |
| 152 | + for(ix=0;ix<4;ix++) | |
| 153 | + { | |
| 154 | + widget->options[ix] = gtk_check_button_new_with_mnemonic(gettext(ft_option[ix].label)); | |
| 155 | + gtk_widget_set_tooltip_markup(widget->options[ix],gettext(ft_option[ix].tooltip)); | |
| 156 | + // g_signal_connect(G_OBJECT(widget->options[ix]),"toggled",G_CALLBACK(option_toggled),widget); | |
| 157 | + gtk_box_pack_start(GTK_BOX(box),widget->options[ix],FALSE,TRUE,0); | |
| 158 | + } | |
| 159 | + | |
| 160 | + | |
| 161 | + } | |
| 162 | + | |
| 163 | + gtk_widget_show_all(GTK_WIDGET(widget)); | |
| 164 | + | |
| 165 | + } | |
| 166 | + | |
| 167 | + | |
| 168 | + LIB3270_EXPORT GtkWidget * v3270_ft_settings_new() | |
| 169 | + { | |
| 170 | + return GTK_WIDGET(g_object_new(GTK_TYPE_V3270_FT_SETTINGS, NULL)); | |
| 171 | + } | |
| 172 | + | ... | ... |