From 3d7c20ac495bb2044d9a806df4526e595f0dfa18 Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Mon, 11 Feb 2019 17:15:34 -0200 Subject: [PATCH] Working on the new FT Dialog. --- src/include/internals.h | 1 + src/include/v3270/filetransfer.h | 2 ++ src/v3270ft/activity.c | 31 ++++++++++++++++++++++++++++++- src/v3270ft/activitylist.c | 41 +++++++++++++++++++++++++++++++++++------ src/v3270ft/dialog.c | 12 ++++++++++++ src/v3270ft/settings.c | 5 +++++ src/v3270ft/tables.c | 4 ---- 7 files changed, 85 insertions(+), 11 deletions(-) diff --git a/src/include/internals.h b/src/include/internals.h index 6b23119..8405fa0 100644 --- a/src/include/internals.h +++ b/src/include/internals.h @@ -82,6 +82,7 @@ G_GNUC_INTERNAL GtkWidget * v3270_activity_list_new(); G_GNUC_INTERNAL void v3270_activity_list_append(GtkWidget *widget, GObject *activity); + G_GNUC_INTERNAL void v3270_activity_list_remove(GtkWidget *widget, GObject *activity); G_GNUC_INTERNAL void v3270_activity_list_load(GtkWidget *widget); G_GNUC_INTERNAL void v3270_activity_list_save(GtkWidget *widget); G_GNUC_INTERNAL void v3270_activity_list_save_as(GtkWidget *widget); diff --git a/src/include/v3270/filetransfer.h b/src/include/v3270/filetransfer.h index 88322d7..b5a1c96 100644 --- a/src/include/v3270/filetransfer.h +++ b/src/include/v3270/filetransfer.h @@ -95,6 +95,8 @@ LIB3270_EXPORT GtkWidget * v3270_ft_settings_new(); LIB3270_EXPORT void v3270_ft_settings_set_activity(GtkWidget *widget, GObject *activity); + LIB3270_EXPORT GObject * v3270_ft_settings_get_activity(GtkWidget *widget); + LIB3270_EXPORT GObject * v3270_ft_settings_create_activity(GtkWidget *widget); LIB3270_EXPORT void v3270_ft_settings_reset(GtkWidget *widget); diff --git a/src/v3270ft/activity.c b/src/v3270ft/activity.c index 726dd27..1caafda 100644 --- a/src/v3270ft/activity.c +++ b/src/v3270ft/activity.c @@ -28,6 +28,8 @@ */ #include + #include + #include "private.h" #include /*--[ Widget definition ]----------------------------------------------------------------------------*/ @@ -192,8 +194,11 @@ G_V3270_FT_ACTIVITY(object)->values[id] = value; } - static void element_start(GMarkupParseContext *context, const gchar *element_name, const gchar **names,const gchar **values, V3270FTActivity *activity, GError **error) + static void element_start(GMarkupParseContext G_GNUC_UNUSED(*context), const gchar *element_name, const gchar **names,const gchar **values, V3270FTActivity *activity, GError **error) { + size_t ix; + + debug("%s(%s)",__FUNCTION__, element_name); if(!g_ascii_strcasecmp(element_name,"file")) { const gchar *type; @@ -232,6 +237,17 @@ } + debug("%s.%s(%s,%s)",__FUNCTION__, element_name, name, value); + + for(ix = 0; v3270_activity_list_options[ix].name; ix++) + { + if(! (g_ascii_strcasecmp(name,v3270_activity_list_options[ix].name) || g_ascii_strcasecmp(value,v3270_activity_list_options[ix].value)) ) + { + activity->options |= v3270_activity_list_options[ix].option; + 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) + break; + } + } } else if(!g_ascii_strcasecmp(element_name,"parameter")) @@ -250,6 +266,17 @@ } + debug("%s.%s(%s)",__FUNCTION__, element_name, name, value); + + for(ix=0;ixvalues[ix] = atoi(value); + break; + } + } + } } @@ -264,6 +291,8 @@ (void (*)(GMarkupParseContext *, GError *, gpointer)) NULL }; + G_V3270_FT_ACTIVITY(activity)->options = 0; + g_markup_parse_context_push(context,&parser,activity); } diff --git a/src/v3270ft/activitylist.c b/src/v3270ft/activitylist.c index 619d235..8aa2238 100644 --- a/src/v3270ft/activitylist.c +++ b/src/v3270ft/activitylist.c @@ -157,8 +157,38 @@ gtk_list_store_set((GtkListStore *) model, &iter, 0, activity, -1); } + void v3270_activity_list_remove(GtkWidget *widget, GObject *activity) + { + if(!activity) + return; + + GtkTreeModel * model = gtk_tree_view_get_model(GTK_TREE_VIEW(widget)); + GtkTreeIter iter; + + if(gtk_tree_model_get_iter_first(model,&iter)) + { + do + { + GObject * stored = NULL; + gtk_tree_model_get(model, &iter, 0, &stored, -1); + + if(stored == activity) + { + gtk_list_store_remove(GTK_LIST_STORE(model),&iter); + return; + } + + + } + while(gtk_tree_model_iter_next(model,&iter)); + } + + } + + static void element_start(GMarkupParseContext *context, const gchar *element_name, const gchar **names,const gchar **values, V3270FTActivityList *widget, GError **error) { + debug("%s(%s)",__FUNCTION__, element_name); if(!g_ascii_strcasecmp(element_name,"entry")) { // Create new activity @@ -171,6 +201,7 @@ static void element_end(GMarkupParseContext *context, const gchar *element_name, G_GNUC_UNUSED void *info,G_GNUC_UNUSED GError **error) { + debug("%s(%s)",__FUNCTION__, element_name); if(!g_ascii_strcasecmp(element_name,"entry")) { g_markup_parse_context_pop(context); @@ -200,11 +231,8 @@ NULL ); - /* - GMarkupParseContext * context = g_markup_parse_context_new(&parser,G_MARKUP_TREAT_CDATA_AS_TEXT|G_MARKUP_PREFIX_ERROR_POSITION,GTK_V3270FT(widget),NULL); g_markup_parse_context_parse(context,text,strlen(text),&error); g_markup_parse_context_free(context); - */ } @@ -262,13 +290,14 @@ g_string_append_printf(str,"\t\t\n",v3270_ft_activity_get_remote_filename(activity)); LIB3270_FT_OPTION options = v3270_ft_activity_get_options(activity); - for(ix = 0; ix < v3270_activity_list_options[ix].name;ix++) + for(ix = 0; v3270_activity_list_options[ix].name; ix++) { - if(options & v3270_activity_list_options[ix].option) + if((options & v3270_activity_list_options[ix].option) == v3270_activity_list_options[ix].option) g_string_append_printf(str,"\t\t