Commit a7693b7d076423475add1c080b1bc2c793012b40

Authored by Perry Werneck
1 parent 320424c6
Exists in master and in 1 other branch develop

Reworking file transfer dialog.

src/include/v3270/filetransfer.h
... ... @@ -94,6 +94,20 @@
94 94  
95 95 LIB3270_EXPORT GtkWidget * v3270_ft_settings_new();
96 96  
  97 + // FT Dialog widget
  98 + #define GTK_TYPE_V3270_FT_DIALOG (V3270FTDialog_get_type ())
  99 + #define GTK_V3270_FT_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_V3270_FT_DIALOG, V3270FTDialog))
  100 + #define GTK_V3270_FT_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_V3270_FT_DIALOG, V3270FTDialogClass))
  101 + #define GTK_IS_V3270_FT_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_V3270_FT_DIALOG))
  102 + #define GTK_IS_V3270_FT_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_V3270_FT_DIALOG))
  103 + #define GTK_V3270_FT_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_V3270_FT_DIALOG, V3270FTDialogClass))
  104 +
  105 + typedef struct _V3270FTDialog V3270FTDialog;
  106 + typedef struct _V3270FTDialogClass V3270FTDialogClass;
  107 +
  108 + LIB3270_EXPORT GtkWidget * v3270_ft_dialog_new(GtkWidget *parent);
  109 +
  110 +
97 111 G_END_DECLS
98 112  
99 113 #endif // V3270FT_H_INCLUDED
... ...
src/testprogram/testprogram.c
... ... @@ -149,20 +149,7 @@ 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   - /*
163   - GtkWidget * dialog = v3270ft_new();
164   - gtk_window_set_transient_for(GTK_WINDOW(dialog),GTK_WINDOW(gtk_widget_get_toplevel(terminal)));
165   - */
  152 + GtkWidget * dialog = v3270_ft_dialog_new(terminal);
166 153  
167 154 gtk_widget_show_all(dialog);
168 155 gtk_dialog_run(GTK_DIALOG(dialog));
... ...
src/v3270ft/dialog.c 0 → 100644
... ... @@ -0,0 +1,152 @@
  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 <v3270.h>
  31 + #include <v3270/filetransfer.h>
  32 + #include "private.h"
  33 +
  34 +/*--[ Widget definition ]----------------------------------------------------------------------------*/
  35 +
  36 + struct _V3270FTDialog
  37 + {
  38 + GtkDialog parent;
  39 +
  40 + GtkWidget * settings;
  41 + // GtkWidget * buttons[FT_BUTTON_COUNT];
  42 +
  43 + };
  44 +
  45 + struct _V3270FTDialogClass
  46 + {
  47 + GtkDialogClass parent_class;
  48 + };
  49 +
  50 + G_DEFINE_TYPE(V3270FTDialog, V3270FTDialog, GTK_TYPE_DIALOG);
  51 +
  52 +/*--[ Implement ]------------------------------------------------------------------------------------*/
  53 +
  54 +static void V3270FTDialog_class_init(G_GNUC_UNUSED V3270FTDialogClass *klass)
  55 +{
  56 +}
  57 +
  58 +/*
  59 +static void apply_clicked(GtkButton G_GNUC_UNUSED(*button), GtkWidget *dialog)
  60 +{
  61 + gtk_dialog_response(GTK_DIALOG(dialog),GTK_RESPONSE_APPLY);
  62 +}
  63 +
  64 +static void cancel_clicked(GtkButton G_GNUC_UNUSED(*button), GtkWidget *dialog)
  65 +{
  66 + gtk_dialog_response(GTK_DIALOG(dialog),GTK_RESPONSE_CANCEL);
  67 +}
  68 +*/
  69 +
  70 +/*
  71 +static GtkWidget * create_button(V3270FTDialog *widget, FT_BUTTON id, const gchar *icon, const gchar *tooltip, GCallback callback)
  72 +{
  73 + widget->buttons[id] = gtk_button_new_from_icon_name(icon,GTK_ICON_SIZE_BUTTON);
  74 + gtk_widget_set_tooltip_markup(widget->buttons[id],tooltip);
  75 +
  76 + // g_signal_connect(widget->buttons[id],"clicked",callback,widget);
  77 +
  78 + return widget->buttons[id];
  79 +}
  80 +*/
  81 +
  82 +static void V3270FTDialog_init(V3270FTDialog *widget)
  83 +{
  84 + widget->settings = v3270_ft_settings_new();
  85 +
  86 + gtk_window_set_title(GTK_WINDOW(widget),_( "3270 File transfer"));
  87 +
  88 + // https://developer.gnome.org/hig/stable/visual-layout.html.en
  89 + gtk_container_set_border_width(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(widget))),18);
  90 +
  91 + // Create box
  92 + GtkWidget * container = gtk_box_new(GTK_ORIENTATION_VERTICAL,6);
  93 + gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(widget))),container,TRUE,TRUE,0);
  94 +
  95 + // Pack settings widget
  96 + gtk_widget_set_halign(GTK_WIDGET(widget->settings),GTK_ALIGN_START);
  97 + gtk_widget_set_hexpand(GTK_WIDGET(widget->settings),FALSE);
  98 + gtk_widget_set_vexpand(GTK_WIDGET(widget->settings),FALSE);
  99 + gtk_box_pack_start(GTK_BOX(container),widget->settings,FALSE,FALSE,0);
  100 +
  101 +
  102 + // Create file list view
  103 + {
  104 + GtkTreeModel * model = GTK_TREE_MODEL(gtk_tree_store_new(1,G_TYPE_STRING));
  105 + GtkWidget * files = gtk_tree_view_new_with_model(model);
  106 +
  107 + gtk_widget_set_tooltip_markup(files,_("Files to transfer"));
  108 +
  109 + gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(files),TRUE);
  110 + gtk_tree_view_insert_column_with_attributes(
  111 + GTK_TREE_VIEW(files),
  112 + -1,
  113 + _( "Local file name" ),gtk_cell_renderer_text_new(),"text",
  114 + 0, NULL
  115 + );
  116 +
  117 + // Put the view inside a scrolled window.
  118 + GtkWidget * scrolled = gtk_scrolled_window_new(NULL,NULL);
  119 + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
  120 + gtk_container_add(GTK_CONTAINER(scrolled),files);
  121 +
  122 + gtk_widget_set_vexpand(scrolled,TRUE);
  123 + gtk_widget_set_hexpand(scrolled,TRUE);
  124 +
  125 + gtk_box_pack_start(GTK_BOX(container),scrolled,TRUE,TRUE,0);
  126 + }
  127 +
  128 +
  129 +}
  130 +
  131 +LIB3270_EXPORT GtkWidget * v3270_ft_dialog_new(GtkWidget *parent)
  132 +{
  133 + gboolean use_header;
  134 + g_object_get(gtk_settings_get_default(), "gtk-dialogs-use-header", &use_header, NULL);
  135 +
  136 + GtkWidget * dialog =
  137 + GTK_WIDGET(g_object_new(
  138 + GTK_TYPE_V3270_FT_DIALOG,
  139 + "use-header-bar", 0, // (use_header ? 1 : 0),
  140 + NULL
  141 + ));
  142 +
  143 + if(parent)
  144 + {
  145 + gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(gtk_widget_get_toplevel(parent)));
  146 + gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
  147 + gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE);
  148 + }
  149 +
  150 + return dialog;
  151 +}
  152 +
... ...
src/v3270ft/ftdialog.cbp
... ... @@ -1,140 +0,0 @@
1   -<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
2   -<CodeBlocks_project_file>
3   - <FileVersion major="1" minor="6" />
4   - <Project>
5   - <Option title="pw3270 File Transfer Dialog" />
6   - <Option pch_mode="2" />
7   - <Option compiler="gcc" />
8   - <Build>
9   - <Target title="Debug">
10   - <Option output=".bin/Debug/v3270ft" prefix_auto="1" extension_auto="1" />
11   - <Option object_output=".obj/Debug/" />
12   - <Option type="1" />
13   - <Option compiler="gcc" />
14   - <Compiler>
15   - <Add option="-g" />
16   - <Add option="-DDEBUG=1" />
17   - </Compiler>
18   - </Target>
19   - <Target title="Release">
20   - <Option output=".bin/Release/v3270ft" prefix_auto="1" extension_auto="1" />
21   - <Option object_output=".obj/Release/" />
22   - <Option type="1" />
23   - <Option compiler="gcc" />
24   - <Compiler>
25   - <Add option="-O2" />
26   - <Add option="-DNDEBUG=1" />
27   - </Compiler>
28   - <Linker>
29   - <Add option="-s" />
30   - </Linker>
31   - </Target>
32   - </Build>
33   - <Compiler>
34   - <Add option="-Wall" />
35   - <Add option="`pkg-config --cflags gtk+-3.0 lib3270`" />
36   - <Add directory="../../include" />
37   - <Add directory="../../include/pw3270" />
38   - </Compiler>
39   - <Linker>
40   - <Add option="`pkg-config --libs gtk+-3.0 lib3270`" />
41   - </Linker>
42   - <ExtraCommands>
43   - <Add before="glib-genmarshal --prefix=v3270ft --header genmarshal &gt; marshal.h" />
44   - <Add before="glib-genmarshal --prefix=v3270ft --body genmarshal &gt; marshal.c" />
45   - </ExtraCommands>
46   - <Unit filename="../include/v3270.h" />
47   - <Unit filename="../include/v3270ft.h" />
48   - <Unit filename="../include/v3270ftprogress.h" />
49   - <Unit filename="../v3270/accessible.c">
50   - <Option compilerVar="CC" />
51   - </Unit>
52   - <Unit filename="../v3270/accessible.h" />
53   - <Unit filename="../v3270/draw.c">
54   - <Option compilerVar="CC" />
55   - </Unit>
56   - <Unit filename="../v3270/hostselect.c">
57   - <Option compilerVar="CC" />
58   - </Unit>
59   - <Unit filename="../v3270/hostselect.h" />
60   - <Unit filename="../v3270/iocallback.c">
61   - <Option compilerVar="CC" />
62   - </Unit>
63   - <Unit filename="../v3270/keyboard.c">
64   - <Option compilerVar="CC" />
65   - </Unit>
66   - <Unit filename="../v3270/macros.c">
67   - <Option compilerVar="CC" />
68   - </Unit>
69   - <Unit filename="../v3270/marshal.c">
70   - <Option compilerVar="CC" />
71   - </Unit>
72   - <Unit filename="../v3270/marshal.h" />
73   - <Unit filename="../v3270/mouse.c">
74   - <Option compilerVar="CC" />
75   - </Unit>
76   - <Unit filename="../v3270/oia.c">
77   - <Option compilerVar="CC" />
78   - </Unit>
79   - <Unit filename="../v3270/private.h" />
80   - <Unit filename="../v3270/properties.c">
81   - <Option compilerVar="CC" />
82   - </Unit>
83   - <Unit filename="../v3270/security.c">
84   - <Option compilerVar="CC" />
85   - </Unit>
86   - <Unit filename="../v3270/selection.c">
87   - <Option compilerVar="CC" />
88   - </Unit>
89   - <Unit filename="../v3270/widget.c">
90   - <Option compilerVar="CC" />
91   - </Unit>
92   - <Unit filename="filelist.c">
93   - <Option compilerVar="CC" />
94   - </Unit>
95   - <Unit filename="genmarshal" />
96   - <Unit filename="get.c">
97   - <Option compilerVar="CC" />
98   - </Unit>
99   - <Unit filename="load.c">
100   - <Option compilerVar="CC" />
101   - </Unit>
102   - <Unit filename="marshal.c">
103   - <Option compilerVar="CC" />
104   - </Unit>
105   - <Unit filename="misc.c">
106   - <Option compilerVar="CC" />
107   - </Unit>
108   - <Unit filename="private.h" />
109   - <Unit filename="save.c">
110   - <Option compilerVar="CC" />
111   - </Unit>
112   - <Unit filename="select.c">
113   - <Option compilerVar="CC" />
114   - </Unit>
115   - <Unit filename="set.c">
116   - <Option compilerVar="CC" />
117   - </Unit>
118   - <Unit filename="tables.c">
119   - <Option compilerVar="CC" />
120   - </Unit>
121   - <Unit filename="testprogram.c">
122   - <Option compilerVar="CC" />
123   - </Unit>
124   - <Unit filename="transfer.c">
125   - <Option compilerVar="CC" />
126   - </Unit>
127   - <Unit filename="v3270ft.c">
128   - <Option compilerVar="CC" />
129   - </Unit>
130   - <Unit filename="v3270ftprogress.c">
131   - <Option compilerVar="CC" />
132   - </Unit>
133   - <Extensions>
134   - <code_completion />
135   - <envvars />
136   - <debugger />
137   - <lib_finder disable_auto="1" />
138   - </Extensions>
139   - </Project>
140   -</CodeBlocks_project_file>
src/v3270ft/settings.c
... ... @@ -180,6 +180,7 @@ static void open_select_file_dialog(GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconP
180 180 }
181 181 else
182 182 {
  183 +
183 184 debug("%s option selected","LIB3270_FT_OPTION_SEND");
184 185  
185 186 gtk_widget_set_sensitive(widget->recordFormatBox,TRUE);
... ... @@ -199,6 +200,9 @@ static void open_select_file_dialog(GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconP
199 200 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget->options[ix]),(options & ft_option[ix].opt) == ft_option[ix].opt);
200 201 }
201 202  
  203 + gtk_widget_set_sensitive(GTK_WIDGET(widget->file.local),TRUE);
  204 + gtk_widget_set_sensitive(GTK_WIDGET(widget->file.remote),TRUE);
  205 +
202 206 }
203 207  
204 208 static void transfer_type_changed(GtkComboBox *widget, V3270FTSettings *dialog)
... ... @@ -208,7 +212,14 @@ static void open_select_file_dialog(GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconP
208 212 debug("Transfer type=%u", (unsigned int) selected);
209 213  
210 214 if(selected >= 0)
  215 + {
211 216 set_options(dialog,ft_type[selected].opt);
  217 + }
  218 + else
  219 + {
  220 + gtk_widget_set_sensitive(GTK_WIDGET(dialog->file.local),FALSE);
  221 + gtk_widget_set_sensitive(GTK_WIDGET(dialog->file.remote),FALSE);
  222 + }
212 223  
213 224 }
214 225  
... ... @@ -343,6 +354,9 @@ static void open_select_file_dialog(GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconP
343 354  
344 355 }
345 356  
  357 + gtk_widget_set_sensitive(GTK_WIDGET(widget->file.local),FALSE);
  358 + gtk_widget_set_sensitive(GTK_WIDGET(widget->file.remote),FALSE);
  359 +
346 360 }
347 361  
348 362 LIB3270_EXPORT GtkWidget * v3270_ft_settings_new()
... ...
v3270.cbp
... ... @@ -141,6 +141,9 @@
141 141 <Unit filename="src/v3270/windows/iosource.c">
142 142 <Option compilerVar="CC" />
143 143 </Unit>
  144 + <Unit filename="src/v3270ft/dialog.c">
  145 + <Option compilerVar="CC" />
  146 + </Unit>
144 147 <Unit filename="src/v3270ft/filelist.c">
145 148 <Option compilerVar="CC" />
146 149 </Unit>
... ...