Commit 3d7c20ac495bb2044d9a806df4526e595f0dfa18
1 parent
b349e0c4
Exists in
master
and in
1 other branch
Working on the new FT Dialog.
Showing
7 changed files
with
85 additions
and
11 deletions
Show diff stats
src/include/internals.h
| ... | ... | @@ -82,6 +82,7 @@ |
| 82 | 82 | |
| 83 | 83 | G_GNUC_INTERNAL GtkWidget * v3270_activity_list_new(); |
| 84 | 84 | G_GNUC_INTERNAL void v3270_activity_list_append(GtkWidget *widget, GObject *activity); |
| 85 | + G_GNUC_INTERNAL void v3270_activity_list_remove(GtkWidget *widget, GObject *activity); | |
| 85 | 86 | G_GNUC_INTERNAL void v3270_activity_list_load(GtkWidget *widget); |
| 86 | 87 | G_GNUC_INTERNAL void v3270_activity_list_save(GtkWidget *widget); |
| 87 | 88 | G_GNUC_INTERNAL void v3270_activity_list_save_as(GtkWidget *widget); | ... | ... |
src/include/v3270/filetransfer.h
| ... | ... | @@ -95,6 +95,8 @@ |
| 95 | 95 | LIB3270_EXPORT GtkWidget * v3270_ft_settings_new(); |
| 96 | 96 | |
| 97 | 97 | LIB3270_EXPORT void v3270_ft_settings_set_activity(GtkWidget *widget, GObject *activity); |
| 98 | + LIB3270_EXPORT GObject * v3270_ft_settings_get_activity(GtkWidget *widget); | |
| 99 | + | |
| 98 | 100 | LIB3270_EXPORT GObject * v3270_ft_settings_create_activity(GtkWidget *widget); |
| 99 | 101 | |
| 100 | 102 | LIB3270_EXPORT void v3270_ft_settings_reset(GtkWidget *widget); | ... | ... |
src/v3270ft/activity.c
| ... | ... | @@ -28,6 +28,8 @@ |
| 28 | 28 | */ |
| 29 | 29 | |
| 30 | 30 | #include <internals.h> |
| 31 | + #include <stdlib.h> | |
| 32 | + #include "private.h" | |
| 31 | 33 | #include <v3270/filetransfer.h> |
| 32 | 34 | |
| 33 | 35 | /*--[ Widget definition ]----------------------------------------------------------------------------*/ |
| ... | ... | @@ -192,8 +194,11 @@ |
| 192 | 194 | G_V3270_FT_ACTIVITY(object)->values[id] = value; |
| 193 | 195 | } |
| 194 | 196 | |
| 195 | - static void element_start(GMarkupParseContext *context, const gchar *element_name, const gchar **names,const gchar **values, V3270FTActivity *activity, GError **error) | |
| 197 | + static void element_start(GMarkupParseContext G_GNUC_UNUSED(*context), const gchar *element_name, const gchar **names,const gchar **values, V3270FTActivity *activity, GError **error) | |
| 196 | 198 | { |
| 199 | + size_t ix; | |
| 200 | + | |
| 201 | + debug("%s(%s)",__FUNCTION__, element_name); | |
| 197 | 202 | if(!g_ascii_strcasecmp(element_name,"file")) |
| 198 | 203 | { |
| 199 | 204 | const gchar *type; |
| ... | ... | @@ -232,6 +237,17 @@ |
| 232 | 237 | |
| 233 | 238 | } |
| 234 | 239 | |
| 240 | + debug("%s.%s(%s,%s)",__FUNCTION__, element_name, name, value); | |
| 241 | + | |
| 242 | + for(ix = 0; v3270_activity_list_options[ix].name; ix++) | |
| 243 | + { | |
| 244 | + if(! (g_ascii_strcasecmp(name,v3270_activity_list_options[ix].name) || g_ascii_strcasecmp(value,v3270_activity_list_options[ix].value)) ) | |
| 245 | + { | |
| 246 | + activity->options |= v3270_activity_list_options[ix].option; | |
| 247 | + debug("Setting option %s.%s(%08lx) =%08lx", v3270_activity_list_options[ix].name, v3270_activity_list_options[ix].value, (unsigned int) v3270_activity_list_options[ix].option,(unsigned int) activity->options) | |
| 248 | + break; | |
| 249 | + } | |
| 250 | + } | |
| 235 | 251 | |
| 236 | 252 | } |
| 237 | 253 | else if(!g_ascii_strcasecmp(element_name,"parameter")) |
| ... | ... | @@ -250,6 +266,17 @@ |
| 250 | 266 | |
| 251 | 267 | } |
| 252 | 268 | |
| 269 | + debug("%s.%s(%s)",__FUNCTION__, element_name, name, value); | |
| 270 | + | |
| 271 | + for(ix=0;ix<LIB3270_FT_VALUE_COUNT;ix++) | |
| 272 | + { | |
| 273 | + if(!g_ascii_strcasecmp(ft_value[ix].name,name)) | |
| 274 | + { | |
| 275 | + activity->values[ix] = atoi(value); | |
| 276 | + break; | |
| 277 | + } | |
| 278 | + } | |
| 279 | + | |
| 253 | 280 | } |
| 254 | 281 | |
| 255 | 282 | } |
| ... | ... | @@ -264,6 +291,8 @@ |
| 264 | 291 | (void (*)(GMarkupParseContext *, GError *, gpointer)) NULL |
| 265 | 292 | }; |
| 266 | 293 | |
| 294 | + G_V3270_FT_ACTIVITY(activity)->options = 0; | |
| 295 | + | |
| 267 | 296 | g_markup_parse_context_push(context,&parser,activity); |
| 268 | 297 | |
| 269 | 298 | } | ... | ... |
src/v3270ft/activitylist.c
| ... | ... | @@ -157,8 +157,38 @@ |
| 157 | 157 | gtk_list_store_set((GtkListStore *) model, &iter, 0, activity, -1); |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | + void v3270_activity_list_remove(GtkWidget *widget, GObject *activity) | |
| 161 | + { | |
| 162 | + if(!activity) | |
| 163 | + return; | |
| 164 | + | |
| 165 | + GtkTreeModel * model = gtk_tree_view_get_model(GTK_TREE_VIEW(widget)); | |
| 166 | + GtkTreeIter iter; | |
| 167 | + | |
| 168 | + if(gtk_tree_model_get_iter_first(model,&iter)) | |
| 169 | + { | |
| 170 | + do | |
| 171 | + { | |
| 172 | + GObject * stored = NULL; | |
| 173 | + gtk_tree_model_get(model, &iter, 0, &stored, -1); | |
| 174 | + | |
| 175 | + if(stored == activity) | |
| 176 | + { | |
| 177 | + gtk_list_store_remove(GTK_LIST_STORE(model),&iter); | |
| 178 | + return; | |
| 179 | + } | |
| 180 | + | |
| 181 | + | |
| 182 | + } | |
| 183 | + while(gtk_tree_model_iter_next(model,&iter)); | |
| 184 | + } | |
| 185 | + | |
| 186 | + } | |
| 187 | + | |
| 188 | + | |
| 160 | 189 | static void element_start(GMarkupParseContext *context, const gchar *element_name, const gchar **names,const gchar **values, V3270FTActivityList *widget, GError **error) |
| 161 | 190 | { |
| 191 | + debug("%s(%s)",__FUNCTION__, element_name); | |
| 162 | 192 | if(!g_ascii_strcasecmp(element_name,"entry")) |
| 163 | 193 | { |
| 164 | 194 | // Create new activity |
| ... | ... | @@ -171,6 +201,7 @@ |
| 171 | 201 | |
| 172 | 202 | static void element_end(GMarkupParseContext *context, const gchar *element_name, G_GNUC_UNUSED void *info,G_GNUC_UNUSED GError **error) |
| 173 | 203 | { |
| 204 | + debug("%s(%s)",__FUNCTION__, element_name); | |
| 174 | 205 | if(!g_ascii_strcasecmp(element_name,"entry")) |
| 175 | 206 | { |
| 176 | 207 | g_markup_parse_context_pop(context); |
| ... | ... | @@ -200,11 +231,8 @@ |
| 200 | 231 | NULL |
| 201 | 232 | ); |
| 202 | 233 | |
| 203 | - /* | |
| 204 | - GMarkupParseContext * context = g_markup_parse_context_new(&parser,G_MARKUP_TREAT_CDATA_AS_TEXT|G_MARKUP_PREFIX_ERROR_POSITION,GTK_V3270FT(widget),NULL); | |
| 205 | 234 | g_markup_parse_context_parse(context,text,strlen(text),&error); |
| 206 | 235 | g_markup_parse_context_free(context); |
| 207 | - */ | |
| 208 | 236 | |
| 209 | 237 | } |
| 210 | 238 | |
| ... | ... | @@ -262,13 +290,14 @@ |
| 262 | 290 | g_string_append_printf(str,"\t\t<file type=\'remote\' path=\'%s\' />\n",v3270_ft_activity_get_remote_filename(activity)); |
| 263 | 291 | |
| 264 | 292 | LIB3270_FT_OPTION options = v3270_ft_activity_get_options(activity); |
| 265 | - for(ix = 0; ix < v3270_activity_list_options[ix].name;ix++) | |
| 293 | + for(ix = 0; v3270_activity_list_options[ix].name; ix++) | |
| 266 | 294 | { |
| 267 | - if(options & v3270_activity_list_options[ix].option) | |
| 295 | + if((options & v3270_activity_list_options[ix].option) == v3270_activity_list_options[ix].option) | |
| 268 | 296 | g_string_append_printf(str,"\t\t<option name=\'%s\' value=\'%s\' />\n",v3270_activity_list_options[ix].name,v3270_activity_list_options[ix].value); |
| 269 | 297 | } |
| 270 | 298 | |
| 271 | - for(ix=0;ix<LIB3270_FT_VALUE_COUNT;ix++) { | |
| 299 | + for(ix=0;ix<LIB3270_FT_VALUE_COUNT;ix++) | |
| 300 | + { | |
| 272 | 301 | g_string_append_printf(str,"\t\t<parameter name=\"%s\" value=\"%u\"/>\n",ft_value[ix].name,v3270_ft_activity_get_value(activity,(LIB3270_FT_VALUE) ix)); |
| 273 | 302 | } |
| 274 | 303 | ... | ... |
src/v3270ft/dialog.c
| ... | ... | @@ -43,6 +43,7 @@ |
| 43 | 43 | GtkWidget * valid; |
| 44 | 44 | GtkWidget * insert; |
| 45 | 45 | GtkWidget * update; |
| 46 | + GtkWidget * remove; | |
| 46 | 47 | GtkWidget * reset; |
| 47 | 48 | } button; |
| 48 | 49 | |
| ... | ... | @@ -80,6 +81,7 @@ void activity_selected(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn G |
| 80 | 81 | v3270_ft_settings_set_activity(widget->settings,activity); |
| 81 | 82 | |
| 82 | 83 | gtk_widget_set_sensitive(widget->button.update,TRUE); |
| 84 | + gtk_widget_set_sensitive(widget->button.remove,TRUE); | |
| 83 | 85 | gtk_widget_set_sensitive(widget->button.reset,TRUE); |
| 84 | 86 | |
| 85 | 87 | } |
| ... | ... | @@ -165,6 +167,12 @@ static void insert_clicked(GtkWidget *button, V3270FTDialog *widget) |
| 165 | 167 | |
| 166 | 168 | } |
| 167 | 169 | |
| 170 | +static void remove_clicked(GtkWidget G_GNUC_UNUSED(*button), V3270FTDialog *widget) | |
| 171 | +{ | |
| 172 | + v3270_activity_list_remove(widget->queue.view,v3270_ft_settings_get_activity(widget->settings)); | |
| 173 | + v3270_ft_settings_set_activity(widget->settings,NULL); | |
| 174 | +} | |
| 175 | + | |
| 168 | 176 | static void enable_queue_save(GtkWidget G_GNUC_UNUSED(*save), gboolean enabled, GtkWidget *button) |
| 169 | 177 | { |
| 170 | 178 | gtk_widget_set_sensitive(button,enabled); |
| ... | ... | @@ -208,10 +216,14 @@ static void V3270FTDialog_init(V3270FTDialog *widget) |
| 208 | 216 | widget->button.update = v3270_box_pack_end(widget->button.valid,gtk_button_new_with_mnemonic("_Update"),FALSE,FALSE,0); |
| 209 | 217 | g_signal_connect(widget->button.update,"clicked",G_CALLBACK(update_clicked),widget); |
| 210 | 218 | |
| 219 | + widget->button.insert = v3270_box_pack_end(widget->button.valid,gtk_button_new_with_mnemonic("_Delete"),FALSE,FALSE,0); | |
| 220 | + g_signal_connect(widget->button.insert,"clicked",G_CALLBACK(remove_clicked),widget); | |
| 221 | + | |
| 211 | 222 | widget->button.insert = v3270_box_pack_end(widget->button.valid,gtk_button_new_with_mnemonic("_Insert"),FALSE,FALSE,0); |
| 212 | 223 | g_signal_connect(widget->button.insert,"clicked",G_CALLBACK(insert_clicked),widget); |
| 213 | 224 | |
| 214 | 225 | gtk_widget_set_sensitive(widget->button.update,FALSE); |
| 226 | + gtk_widget_set_sensitive(widget->button.remove,FALSE); | |
| 215 | 227 | gtk_widget_set_sensitive(widget->button.reset,FALSE); |
| 216 | 228 | |
| 217 | 229 | gtk_box_pack_start(GTK_BOX(container),widget->button.valid,FALSE,FALSE,0); | ... | ... |
src/v3270ft/settings.c
| ... | ... | @@ -528,6 +528,11 @@ static void open_select_file_dialog(GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconP |
| 528 | 528 | v3270_ft_settings_reset(widget); |
| 529 | 529 | } |
| 530 | 530 | |
| 531 | + LIB3270_EXPORT GObject * v3270_ft_settings_get_activity(GtkWidget *widget) | |
| 532 | + { | |
| 533 | + return GTK_V3270_FT_SETTINGS(widget)->activity; | |
| 534 | + } | |
| 535 | + | |
| 531 | 536 | LIB3270_EXPORT void v3270_ft_settings_reset(GtkWidget *widget) |
| 532 | 537 | { |
| 533 | 538 | int ix; | ... | ... |
src/v3270ft/tables.c
| ... | ... | @@ -199,19 +199,15 @@ const struct v3270ft_value ft_value[] = { |
| 199 | 199 | |
| 200 | 200 | const struct v3270_activity_list_option v3270_activity_list_options[] = |
| 201 | 201 | { |
| 202 | - | |
| 203 | - { LIB3270_FT_OPTION_SEND, "type", "send" }, | |
| 204 | 202 | { LIB3270_FT_OPTION_RECEIVE, "type", "receive" }, |
| 205 | 203 | { LIB3270_FT_OPTION_ASCII, "format", "ascii" }, |
| 206 | 204 | { LIB3270_FT_OPTION_CRLF, "format", "crlf" }, |
| 207 | 205 | { LIB3270_FT_OPTION_APPEND, "format", "append" }, |
| 208 | 206 | { LIB3270_FT_OPTION_REMAP, "format", "remap" }, |
| 209 | 207 | { LIB3270_FT_OPTION_UNIX, "file-format", "unix" }, |
| 210 | - { LIB3270_FT_RECORD_FORMAT_DEFAULT, "record-format", "default" }, | |
| 211 | 208 | { LIB3270_FT_RECORD_FORMAT_FIXED, "record-format", "fixed" }, |
| 212 | 209 | { LIB3270_FT_RECORD_FORMAT_VARIABLE, "record-format", "variable" }, |
| 213 | 210 | { LIB3270_FT_RECORD_FORMAT_UNDEFINED, "record-format", "undefined" }, |
| 214 | - { LIB3270_FT_ALLOCATION_UNITS_DEFAULT, "units", "default" }, | |
| 215 | 211 | { LIB3270_FT_ALLOCATION_UNITS_TRACKS, "units", "tracks" }, |
| 216 | 212 | { LIB3270_FT_ALLOCATION_UNITS_CYLINDERS, "units", "cylinders" }, |
| 217 | 213 | { LIB3270_FT_ALLOCATION_UNITS_AVBLOCK, "units", "avblock" }, | ... | ... |