Commit 64d8d7a88bdf688f8ce4d92621dde0043a4fa851

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

Working on new FT components.

src/include/v3270/filetransfer.h
... ... @@ -112,10 +112,12 @@
112 112 LIB3270_EXPORT const gchar * v3270_ft_activity_get_local_filename(GObject *object);
113 113 LIB3270_EXPORT const gchar * v3270_ft_activity_get_remote_filename(GObject *object);
114 114 LIB3270_EXPORT LIB3270_FT_OPTION v3270_ft_activity_get_options(GObject *object);
  115 + LIB3270_EXPORT guint v3270_ft_activity_get_value(GObject * object, LIB3270_FT_VALUE id);
115 116  
116 117 LIB3270_EXPORT void v3270_ft_activity_set_local_filename(GObject *object, const gchar *filename);
117 118 LIB3270_EXPORT void v3270_ft_activity_set_remote_filename(GObject *object, const gchar *filename);
118 119 LIB3270_EXPORT void v3270_ft_activity_set_options(GObject * object, LIB3270_FT_OPTION options);
  120 + LIB3270_EXPORT void v3270_ft_activity_set_value(GObject * object, LIB3270_FT_VALUE id, guint value);
119 121  
120 122 // FT Dialog widget
121 123 #define GTK_TYPE_V3270_FT_DIALOG (V3270FTDialog_get_type ())
... ...
src/testprogram/testprogram.c
... ... @@ -189,7 +189,7 @@ static void activate(GtkApplication* app, G_GNUC_UNUSED gpointer user_data) {
189 189 size_t f;
190 190  
191 191 v3270_set_url(terminal,NULL);
192   - v3270_set_toggle(terminal,LIB3270_TOGGLE_RECONNECT,TRUE);
  192 + // v3270_set_toggle(terminal,LIB3270_TOGGLE_RECONNECT,TRUE);
193 193  
194 194 // v3270_set_font_family(terminal,"Droid Sans Mono");
195 195 g_signal_connect(terminal,"field_clicked",G_CALLBACK(field_clicked),window);
... ...
src/v3270ft/activity.c
... ... @@ -42,8 +42,13 @@
42 42 {
43 43 GObject parent;
44 44  
45   - LIB3270_FT_OPTION options;
  45 + /// @brief Transfer options.
  46 + LIB3270_FT_OPTION options;
46 47  
  48 + /// @brief Values.
  49 + guint values[LIB3270_FT_VALUE_COUNT];
  50 +
  51 + /// @brief File names
47 52 struct {
48 53 gchar * local;
49 54 gchar * remote;
... ... @@ -127,6 +132,11 @@
127 132  
128 133 static void V3270FTActivity_init(V3270FTActivity *widget)
129 134 {
  135 + widget->values[LIB3270_FT_VALUE_LRECL] = 0;
  136 + widget->values[LIB3270_FT_VALUE_BLKSIZE] = 0;
  137 + widget->values[LIB3270_FT_VALUE_PRIMSPACE] = 0;
  138 + widget->values[LIB3270_FT_VALUE_SECSPACE] = 0;
  139 + widget->values[LIB3270_FT_VALUE_DFT] = 4096;
130 140 }
131 141  
132 142 LIB3270_EXPORT GObject * v3270_ft_activity_new()
... ... @@ -222,3 +232,14 @@
222 232 gtk_list_store_append((GtkListStore *) model,&iter);
223 233 gtk_list_store_set((GtkListStore *) model, &iter, 0, activity, -1);
224 234 }
  235 +
  236 +guint v3270_ft_activity_get_value(GObject * object, LIB3270_FT_VALUE id)
  237 +{
  238 + return G_V3270_FT_ACTIVITY(object)->values[id];
  239 +}
  240 +
  241 +void v3270_ft_activity_set_value(GObject * object, LIB3270_FT_VALUE id, guint value)
  242 +{
  243 + G_V3270_FT_ACTIVITY(object)->values[id] = value;
  244 +}
  245 +
... ...
src/v3270ft/dialog.c
... ... @@ -120,6 +120,7 @@ static void V3270FTDialog_init(V3270FTDialog *widget)
120 120  
121 121 v3270_ft_activity_set_local_filename(activity,"local---");
122 122 v3270_ft_activity_set_remote_filename(activity,"remote---");
  123 + v3270_ft_activity_set_options(activity,LIB3270_FT_OPTION_SEND|LIB3270_FT_OPTION_ASCII|LIB3270_FT_OPTION_CRLF|LIB3270_FT_OPTION_REMAP|LIB3270_FT_OPTION_APPEND|LIB3270_FT_RECORD_FORMAT_VARIABLE);
123 124  
124 125 v3270_activity_list_append(files,activity);
125 126 v3270_ft_settings_set_activity(widget->settings,activity);
... ...
src/v3270ft/private.h
... ... @@ -85,6 +85,8 @@
85 85 const gchar * label;
86 86 };
87 87  
  88 + #define LIB3270_FT_TYPE_OPTIONS (LIB3270_FT_OPTION_SEND|LIB3270_FT_OPTION_RECEIVE|LIB3270_FT_OPTION_ASCII|LIB3270_FT_OPTION_CRLF|LIB3270_FT_OPTION_REMAP)
  89 +
88 90 struct v3270ft_value {
89 91  
90 92 const gchar * name;
... ...
src/v3270ft/settings.c
... ... @@ -49,11 +49,12 @@
49 49 GtkEntry * remote;
50 50 } file;
51 51  
52   - GtkWidget * recordFormatBox;
53   - GtkWidget * spaceAllocationBox;
  52 + GtkComboBox * type;
  53 + GtkWidget * recordFormatBox;
  54 + GtkWidget * spaceAllocationBox;
54 55  
55   - GtkWidget * options[NUM_OPTIONS_WIDGETS];
56   - GtkWidget * spins[LIB3270_FT_VALUE_COUNT];
  56 + GtkWidget * options[NUM_OPTIONS_WIDGETS];
  57 + GtkWidget * spins[LIB3270_FT_VALUE_COUNT];
57 58 };
58 59  
59 60 G_DEFINE_TYPE(V3270FTSettings, V3270FTSettings, GTK_TYPE_GRID);
... ... @@ -83,34 +84,25 @@
83 84 return entry;
84 85 }
85 86  
86   - /*
87   - static GtkWidget * create_frame(GtkWidget *container, const gchar *title, GtkWidget *box, GtkAlign align)
  87 + static GtkWidget * create_grid(GtkWidget *container, GtkAlign align)
88 88 {
89   - gtk_box_pack_start(GTK_BOX(container),v3270_dialog_create_frame(title,box,align),TRUE,TRUE,0);
90   -
91   - GtkFrame * frame = GTK_FRAME(gtk_frame_new(""));
92   - g_autofree gchar * markup = g_strdup_printf("<b>%s</b>",title);
93   - GtkWidget * label = gtk_label_new(NULL);
94   -
95   - gtk_frame_set_shadow_type(GTK_FRAME(frame),GTK_SHADOW_NONE);
96   - gtk_label_set_markup(GTK_LABEL(label),markup);
97   - gtk_frame_set_label_widget(GTK_FRAME(frame),label);
98   -
99   - gtk_container_add(GTK_CONTAINER(frame),GTK_WIDGET(box));
100   - gtk_widget_set_halign(GTK_WIDGET(frame),align);
  89 + return v3270_box_pack_start(container,v3270_dialog_create_grid(align),TRUE,TRUE,0);
  90 + }
101 91  
102   - g_object_set(G_OBJECT(frame),"margin-top",6,NULL);
  92 +static gboolean spin_format(GtkSpinButton *spin, G_GNUC_UNUSED gpointer data) {
103 93  
104   - gtk_box_pack_start(GTK_BOX(container),GTK_WIDGET(frame),TRUE,TRUE,0);
  94 + GtkAdjustment * adjustment = gtk_spin_button_get_adjustment (spin);
  95 + guint value = (guint) gtk_adjustment_get_value(adjustment);
105 96  
106   - return box;
107   - }
108   - */
  97 + if(value < 1) {
  98 + gtk_entry_set_text(GTK_ENTRY(spin), "");
  99 + } else {
  100 + g_autofree gchar * text = g_strdup_printf ("%d", value);
  101 + gtk_entry_set_text(GTK_ENTRY(spin), text);
  102 + }
109 103  
110   - static GtkWidget * create_grid(GtkWidget *container, GtkAlign align)
111   - {
112   - return v3270_box_pack_start(container,v3270_dialog_create_grid(align),TRUE,TRUE,0);
113   - }
  104 + return TRUE;
  105 +}
114 106  
115 107 GtkWidget * create_spin_button(V3270FTSettings *widget, GtkWidget *grid, size_t row, LIB3270_FT_VALUE id)
116 108 {
... ... @@ -121,7 +113,7 @@
121 113  
122 114 GtkWidget * button = gtk_spin_button_new_with_range(ft_value[id].minval,ft_value[id].maxval,1);
123 115 // g_signal_connect(G_OBJECT(button),"value-changed",G_CALLBACK(spin_changed),dialog);
124   - // g_signal_connect(G_OBJECT(button),"output",G_CALLBACK(spin_format),dialog);
  116 + g_signal_connect(G_OBJECT(button),"output",G_CALLBACK(spin_format),widget);
125 117  
126 118 gtk_widget_set_tooltip_markup(button,gettext(ft_value[id].tooltip));
127 119 gtk_widget_set_tooltip_markup(label,gettext(ft_value[id].tooltip));
... ... @@ -169,7 +161,7 @@ static void open_select_file_dialog(GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconP
169 161  
170 162 for(ix = 0; ix < 4; ix++) {
171 163 gtk_widget_set_sensitive(widget->spins[ix],FALSE);
172   - gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget->spins[ix]),0);
  164 + gtk_entry_set_text(GTK_ENTRY(widget->spins[ix]), "");
173 165 }
174 166  
175 167 }
... ... @@ -183,7 +175,6 @@ static void open_select_file_dialog(GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconP
183 175  
184 176 for(ix = 0; ix < 4; ix++) {
185 177 gtk_widget_set_sensitive(widget->spins[ix],TRUE);
186   - gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget->spins[ix]),0);
187 178 }
188 179  
189 180 }
... ... @@ -229,13 +220,14 @@ static void open_select_file_dialog(GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconP
229 220 // Operation type
230 221 {
231 222 GtkTreeModel * model = GTK_TREE_MODEL(gtk_list_store_new(1,G_TYPE_STRING));
232   - GtkWidget * entry = create_entry(widget,"_Operation",gtk_combo_box_new_with_model(model),0,0,9);
233 223 GtkCellRenderer * renderer = gtk_cell_renderer_text_new();
234 224  
235   - g_signal_connect(G_OBJECT(entry),"changed",G_CALLBACK(transfer_type_changed),widget);
  225 + widget->type = GTK_COMBO_BOX(create_entry(widget,"_Operation",gtk_combo_box_new_with_model(model),0,0,9));
  226 +
  227 + g_signal_connect(G_OBJECT(widget->type),"changed",G_CALLBACK(transfer_type_changed),widget);
236 228  
237   - gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(entry), renderer, TRUE);
238   - gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(entry), renderer, "text", 0, NULL);
  229 + gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(widget->type), renderer, TRUE);
  230 + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(widget->type), renderer, "text", 0, NULL);
239 231  
240 232 for(ix=0;ix < NUM_TYPES;ix++)
241 233 {
... ... @@ -389,15 +381,36 @@ static void open_select_file_dialog(GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconP
389 381  
390 382 LIB3270_EXPORT void v3270_ft_settings_set_activity(GtkWidget *widget, GObject *activity)
391 383 {
  384 + int ix;
392 385 V3270FTSettings * settings = GTK_V3270_FT_SETTINGS(widget);
393 386  
394 387 gtk_entry_set_text(settings->file.local,v3270_ft_activity_get_local_filename(activity));
395 388 gtk_entry_set_text(settings->file.remote,v3270_ft_activity_get_remote_filename(activity));
396 389  
  390 + v3270_ft_settings_set_options(widget,v3270_ft_activity_get_options(activity));
  391 +
  392 + for(ix = 0; ix < LIB3270_FT_VALUE_COUNT; ix++)
  393 + {
  394 + gtk_spin_button_set_value(GTK_SPIN_BUTTON(settings->spins[ix]), v3270_ft_activity_get_value(activity,(LIB3270_FT_VALUE) ix));
  395 + }
  396 +
397 397 }
398 398  
399 399 LIB3270_EXPORT void v3270_ft_settings_set_options(GtkWidget *widget, LIB3270_FT_OPTION options)
400 400 {
401   - V3270FTSettings * settings = GTK_V3270_FT_SETTINGS(widget);
  401 + int ix;
  402 +
  403 + for(ix=0;ix < NUM_TYPES;ix++)
  404 + {
  405 + if(ft_type[ix].opt == (options & LIB3270_FT_TYPE_OPTIONS))
  406 + {
  407 + debug("Selecting option %s",ft_type[ix].label);
  408 + gtk_combo_box_set_active(GTK_COMBO_BOX(GTK_V3270_FT_SETTINGS(widget)->type),ix);
  409 + break;
  410 + }
  411 + }
  412 +
  413 + set_options(GTK_V3270_FT_SETTINGS(widget),options);
  414 +
402 415  
403 416 }
... ...