diff --git a/src/gtk/actions.c b/src/gtk/actions.c index e6166b9..89ab939 100644 --- a/src/gtk/actions.c +++ b/src/gtk/actions.c @@ -240,12 +240,22 @@ static void action_pakey(GtkAction *action, GtkWidget *widget) lib3270_pakey(GTK_V3270(widget)->host,(int) g_object_get_data(G_OBJECT(action),"pakey")); } -/* -static void action_fullscreen(GtkAction *action, GtkWidget *widget) +static void action_set_toggle(GtkAction *action, GtkWidget *widget) +{ + LIB3270_TOGGLE id = (LIB3270_TOGGLE) g_object_get_data(G_OBJECT(action),"toggle_id"); + trace("Action %s activated on widget %p toggle=%d",gtk_action_get_name(action),widget,id); + lib3270_set_toggle(GTK_V3270(widget)->host,id,1); +} + +static void action_reset_toggle(GtkAction *action, GtkWidget *widget) { - lib3270_set_toggle(GTK_V3270(widget)->host,LIB3270_TOGGLE_FULL_SCREEN,1); + LIB3270_TOGGLE id = (LIB3270_TOGGLE) g_object_get_data(G_OBJECT(action),"toggle_id"); + trace("Action %s activated on widget %p toggle=%d",gtk_action_get_name(action),widget,id); + lib3270_set_toggle(GTK_V3270(widget)->host,id,0); } +/* + static void action_reselect(GtkAction *action, GtkWidget *widget) { lib3270_reselect(GTK_V3270(widget)->host); @@ -261,12 +271,6 @@ static void action_pastnext(GtkAction *action, GtkWidget *widget) lib3270_pastenext(GTK_V3270(widget)->host); } -void ui_connect_pakey(GtkAction *action, GtkWidget *widget, const gchar *name, const gchar *id) -{ - g_object_set_data(G_OBJECT(action),"pakey",(gpointer) atoi(id)); - g_signal_connect(action,"activate",G_CALLBACK(action_pakey),widget); -} - void ui_connect_index_action(GtkAction *action, GtkWidget *widget, int ix, GtkAction **lst) { // trace("action(%d): %p",ix,action); @@ -298,6 +302,11 @@ void ui_connect_index_action(GtkAction *action, GtkWidget *widget, int ix, GtkAc GtkAction * ui_get_action(GtkWidget *widget, const gchar *name, GHashTable *hash, const gchar **names, const gchar **values, GError **error) { + static const gchar *actionname[ACTION_COUNT] = { "pastenext", + "reselect", + "setfullscreen", + "resetfullscreen" + }; GtkAction * action = NULL; GtkAction **toggle_action = (GtkAction **) g_object_get_data(G_OBJECT(widget),"toggle_actions"); const gchar * direction = ui_get_attribute("direction",names,values); @@ -305,6 +314,7 @@ GtkAction * ui_get_action(GtkWidget *widget, const gchar *name, GHashTable *hash const gchar * attr; int id = 0; gchar * nm = NULL; + int f; enum _action_type { @@ -365,6 +375,7 @@ GtkAction * ui_get_action(GtkWidget *widget, const gchar *name, GHashTable *hash } else if(!g_strcasecmp(name,"set")) { + action_type = ACTION_TYPE_SET; attr = ui_get_attribute("toggle",names,values); id = lib3270_get_toggle_id(attr); if(id < 0) @@ -376,6 +387,7 @@ GtkAction * ui_get_action(GtkWidget *widget, const gchar *name, GHashTable *hash } else if(!g_strcasecmp(name,"reset")) { + action_type = ACTION_TYPE_RESET; attr = ui_get_attribute("toggle",names,values); id = lib3270_get_toggle_id(attr); if(id < 0) @@ -455,13 +467,27 @@ GtkAction * ui_get_action(GtkWidget *widget, const gchar *name, GHashTable *hash case ACTION_TYPE_SET: action = gtk_action_new(nm,NULL,NULL,NULL); + g_object_set_data(G_OBJECT(action),"toggle_id",(gpointer) id); + g_signal_connect(action,"activate",G_CALLBACK(action_set_toggle),widget); break; case ACTION_TYPE_RESET: action = gtk_action_new(nm,NULL,NULL,NULL); + g_object_set_data(G_OBJECT(action),"toggle_id",(gpointer) id); + g_signal_connect(action,"activate",G_CALLBACK(action_reset_toggle),widget); break; } + for(f=0;f +#endif + /*--[ Globals ]--------------------------------------------------------------------------------------*/ enum action_group @@ -74,11 +78,6 @@ NULL }; - static const gchar *actionname[ACTION_COUNT+1] = { "pastenext", - "reselect", - "setfullscreen", - "resetfullscreen" - }; /*--[ Implement ]------------------------------------------------------------------------------------*/ static void toggle_changed(GtkWidget *widget, LIB3270_TOGGLE id, gboolean toggled, const gchar *name, GtkWindow *toplevel) @@ -104,7 +103,7 @@ static gboolean window_state_event(GtkWidget *window, GdkEventWindowState *event, GtkWidget *widget) { gboolean fullscreen = event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN ? TRUE : FALSE; - GtkAction **action = (GtkAction **) g_object_get_data(G_OBJECT(window),"named_actions"); + GtkAction **action = (GtkAction **) g_object_get_data(G_OBJECT(widget),"named_actions"); // Update fullscreen toggles if(action[ACTION_FULLSCREEN]) @@ -284,11 +283,13 @@ H3270 * host = v3270_get_session(terminal); gchar * path = build_data_filename("ui",NULL); GtkActionGroup **group; - GtkAction **action; + GtkAction **action = g_new0(GtkAction *,ACTION_COUNT); GtkWidget **popup; int f; g_object_set_data_full(G_OBJECT(terminal),"toggle_actions",g_new0(GtkAction *,LIB3270_TOGGLE_COUNT),g_free); + g_object_set_data_full(G_OBJECT(terminal),"named_actions",(gpointer) action, (GDestroyNotify) g_free); + // Initialize terminal config for(f=0;factions,name); if(!action) { - action = gtk_action_new(name,NULL,NULL,NULL); + action = gtk_action_new(name,NULL,NULL,GTK_STOCK_QUIT); g_signal_connect(action,"activate",G_CALLBACK(gtk_main_quit), NULL); } } @@ -155,95 +155,8 @@ action = ui_get_action(info->center_widget,name,info->actions,names,values,error); } - if(!action) - return action; - -/* - const gchar * target = NULL; - const gchar * direction = ui_get_attribute("direction",names,values); - const gchar * id = ui_get_attribute("id",names,values); - GtkAction * action; - gchar * nm; - void (*connect)(GtkAction *action, GtkWidget *widget, const gchar *name, const gchar *id) = ui_connect_action; - GtkAction * (*create)(const gchar *,const gchar *,const gchar *,const gchar *) = gtk_action_new; - - if(!g_strcasecmp(name,"toggle")) - { - nm = g_strconcat(name,id,NULL); - create = (GtkAction * (*)(const gchar *,const gchar *,const gchar *,const gchar *)) gtk_toggle_action_new; - connect = ui_connect_toggle; - } - else if(!g_strcasecmp(name,"move")) - { - target = ui_get_attribute("target",names,values); - - if(!(target && direction)) - { - *error = g_error_new(ERROR_DOMAIN,EINVAL,"%s",_("Move action needs target & direction attributes" )); - return NULL; - } - - nm = g_strconcat((flags & 0x80) ? "select" : "move",target,direction, NULL); - - } - else if(!g_strcasecmp(name,"toggleset")) - { - nm = g_strconcat("set",id,NULL); - } - else if(!g_strcasecmp(name,"togglereset")) - { - nm = g_strconcat("reset",id,NULL); - } - else if(!g_strcasecmp(name,"pfkey")) - { - nm = g_strdup_printf("pf%02d",atoi(id ? id : "0")); - connect = ui_connect_pfkey; - } - else if(!g_strcasecmp(name,"pakey")) - { - nm = g_strdup_printf("pa%02d",atoi(id ? id : "0")); - connect = ui_connect_pakey; - } - else - { - nm = g_strdup(name); - } - - action = g_hash_table_lookup(info->actions,nm); - if(action) - { - g_free(nm); - } - else - { - int ix = -1; - - action = GTK_ACTION(create(nm,NULL,NULL,NULL)); - g_hash_table_insert(info->actions,nm,action); - - if(info->actionname) - { - int f; - for(f=0;info->actionname[f] && ix < 0;f++) - { - if(!g_strcasecmp(nm,info->actionname[f])) - ix = f; - } - } - - if(ix >= 0) - ui_connect_index_action(info->action[ix] = action,info->center_widget,ix,info->action); - else if(target) - ui_connect_target_action(action,info->center_widget,target,flags,error); - else if(g_strcasecmp(name,"quit")) - connect(action,info->center_widget,name,id); - else - g_signal_connect(action,"activate",G_CALLBACK(gtk_main_quit), NULL); - - } -*/ - ui_action_set_options(action,info,names,values,error); + ui_action_set_options(action,info,names,values,error); return action; } diff --git a/src/gtk/uiparser/parser.c b/src/gtk/uiparser/parser.c index c4792cc..8473818 100644 --- a/src/gtk/uiparser/parser.c +++ b/src/gtk/uiparser/parser.c @@ -217,7 +217,7 @@ static void release_list(GObject **obj) g_free(obj); } -GtkWidget * ui_parse_xml_folder(const gchar *path, const gchar ** groupname, const gchar **popupname, const gchar **actionname, GtkWidget *widget, const UI_WIDGET_SETUP *setup) +GtkWidget * ui_parse_xml_folder(const gchar *path, const gchar ** groupname, const gchar **popupname, GtkWidget *widget, const UI_WIDGET_SETUP *setup) { struct parser p; GDir * dir; @@ -270,17 +270,12 @@ GtkWidget * ui_parse_xml_folder(const gchar *path, const gchar ** groupname, con p.popupname = popupname; p.strings = g_string_chunk_new(0); p.setup = setup; - p.actionname = actionname; sz = (g_strv_length((gchar **) p.popupname)); p.popup = g_new0(GtkWidget *,sz+1); p.popup[sz] = (GtkWidget *) -1; g_object_set_data_full(G_OBJECT(p.toplevel),"popup_menus",(gpointer) p.popup, (GDestroyNotify) release_list); - sz = (g_strv_length((gchar **) p.actionname)); - p.action = g_new0(GtkAction *,sz); - g_object_set_data_full(G_OBJECT(p.toplevel),"named_actions",(gpointer) p.action, (GDestroyNotify) g_free); - for(current = g_list_first(file);current;current = g_list_next(current)) { ui_parse_file(&p,(gchar *) current->data); diff --git a/src/gtk/uiparser/parser.h b/src/gtk/uiparser/parser.h index 42cabed..6ef694a 100644 --- a/src/gtk/uiparser/parser.h +++ b/src/gtk/uiparser/parser.h @@ -51,17 +51,9 @@ void (*setup)(GtkWidget *widget, GtkWidget *obj); } UI_WIDGET_SETUP; - GtkWidget * ui_parse_xml_folder(const gchar *path, const gchar ** groupname, const gchar **popupname, const gchar **actionname, GtkWidget *widget, const UI_WIDGET_SETUP *itn); + GtkWidget * ui_parse_xml_folder(const gchar *path, const gchar ** groupname, const gchar **popupname, GtkWidget *widget, const UI_WIDGET_SETUP *itn); const gchar * ui_get_attribute(const gchar *key, const gchar **name, const gchar **value); gboolean ui_get_bool_attribute(const gchar *key, const gchar **name, const gchar **value, gboolean def); GtkAction * ui_get_action(GtkWidget *widget, const gchar *name, GHashTable *hash, const gchar **names, const gchar **values, GError **error); - -// void ui_connect_action(GtkAction *action, GtkWidget *widget, const gchar *name, const gchar *id); -// void ui_connect_target_action(GtkAction *action, GtkWidget *widget, const gchar *target, unsigned short flags, GError **error); -// void ui_connect_index_action(GtkAction *action, GtkWidget *widget, int ix, GtkAction **lst); -// void ui_connect_toggle(GtkAction *action, GtkWidget *widget, const gchar *name, const gchar *id); -// void ui_connect_pfkey(GtkAction *action, GtkWidget *widget, const gchar *name, const gchar *id); -// void ui_connect_pakey(GtkAction *action, GtkWidget *widget, const gchar *name, const gchar *id); - #endif // UI_PARSER_H_INCLUDED diff --git a/src/gtk/uiparser/private.h b/src/gtk/uiparser/private.h index 1b0a19f..38be306 100644 --- a/src/gtk/uiparser/private.h +++ b/src/gtk/uiparser/private.h @@ -59,11 +59,9 @@ GObject * element; GtkWidget * center_widget; GtkWidget ** popup; /**< Popup widgets */ - GtkAction ** action; /**< Named actions */ GStringChunk * strings; const gchar ** group; /**< Action group list */ const gchar ** popupname; /**< Popup names */ - const gchar ** actionname; /**< Action names */ GHashTable * actions; /**< List of actions */ GHashTable * element_list[UI_ELEMENT_COUNT]; const UI_WIDGET_SETUP * setup; diff --git a/src/gtk/v3270/clipboard.c b/src/gtk/v3270/clipboard.c index 55e4793..29d9db2 100644 --- a/src/gtk/v3270/clipboard.c +++ b/src/gtk/v3270/clipboard.c @@ -32,6 +32,7 @@ #include #include "v3270.h" #include "private.h" + #include /*--[ Globals ]--------------------------------------------------------------------------------------*/ @@ -225,7 +226,7 @@ void v3270_paste_string(GtkWidget *widget, const gchar *text, const gchar *encod return; } - next = lib3270_paste(session,buffer) ? TRUE : FALSE; + next = lib3270_paste(session,(unsigned char *) buffer) ? TRUE : FALSE; trace("Pastenext is %s",next ? "On" : "Off"); diff --git a/src/gtk/v3270/widget.c b/src/gtk/v3270/widget.c index 88e7a19..71d7a75 100644 --- a/src/gtk/v3270/widget.c +++ b/src/gtk/v3270/widget.c @@ -328,7 +328,6 @@ void v3270_update_font_metrics(v3270 *terminal, cairo_t *cr, int width, int heig cairo_set_font_size(cr,size); - /* double sx, sy; cairo_matrix_t font_matrix; @@ -833,6 +832,8 @@ void v3270_set_font_family(GtkWidget *widget, const gchar *name) name = "courier new"; } + trace("%s(%s)",__FUNCTION__,name); + terminal->font_family = g_strdup(name); terminal->font_weight = CAIRO_FONT_WEIGHT_NORMAL; -- libgit2 0.21.2