From 60dd822f344146a31e9913325c02b94fc91aed24 Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Wed, 13 Nov 2019 17:21:20 -0300 Subject: [PATCH] Working on "paste" actions. --- src/objects/actions/clipboard.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- src/objects/toolbar/actions.c | 11 +++++++++-- src/objects/window/window.c | 2 -- 3 files changed, 56 insertions(+), 6 deletions(-) diff --git a/src/objects/actions/clipboard.c b/src/objects/actions/clipboard.c index d445813..ac775ff 100644 --- a/src/objects/actions/clipboard.c +++ b/src/objects/actions/clipboard.c @@ -51,11 +51,12 @@ static void activate_paste(GAction G_GNUC_UNUSED(*action), GVariant *parameter, GtkWidget *terminal) { - debug("%s %p",__FUNCTION__,parameter); if(!parameter) { - v3270_paste(terminal); + debug("%s %p",__FUNCTION__,"NULL"); + v3270_paste_from_url(terminal,NULL); } else { + debug("%s \"%s\"",__FUNCTION__,g_variant_get_string(parameter,NULL)); v3270_paste_from_url(terminal,g_variant_get_string(parameter,NULL)); } @@ -63,6 +64,7 @@ GAction * pw3270_copy_action_new(void) { + /* static const LIB3270_ACTION action_descriptor = { .name = "copy", .type = LIB3270_ACTION_TYPE_SELECTION, @@ -82,12 +84,28 @@ PW3270_ACTION(action)->activate = activate_copy; + return action; + + */ + + pw3270SimpleAction * action = pw3270_simple_action_new(); + + action->parent.activate = activate_copy; + action->group.id = LIB3270_ACTION_GROUP_SELECTION; + action->parent.name = "file.transfer"; + action->icon_name = "edit-copy"; + action->label = N_( "_Copy" ); + action->tooltip = N_( "Copy selected area to clipboard." ); + + return G_ACTION(action); + } GAction * pw3270_cut_action_new(void) { + /* static const LIB3270_ACTION action_descriptor = { .name = "cut", .type = LIB3270_ACTION_TYPE_SELECTION, @@ -108,11 +126,24 @@ PW3270_ACTION(action)->activate = activate_cut; return action; + */ + + pw3270SimpleAction * action = pw3270_simple_action_new(); + + action->parent.activate = activate_cut; + action->group.id = LIB3270_ACTION_GROUP_SELECTION; + action->parent.name = "file.transfer"; + action->icon_name = "edit-cut"; + action->label = N_( "C_ut" ); + action->tooltip = N_( "Cut selected area." ); + + return G_ACTION(action); } GAction * pw3270_paste_action_new(void) { + /* static const LIB3270_ACTION action_descriptor = { .name = "paste", .type = LIB3270_ACTION_TYPE_SELECTION, @@ -134,5 +165,19 @@ action->activate = activate_paste; return G_ACTION(action); + */ + + pw3270SimpleAction * action = pw3270_simple_action_new(); + + action->parent.activate = activate_paste; + action->parent.types.parameter = G_VARIANT_TYPE_STRING; + + action->group.id = LIB3270_ACTION_GROUP_LOCK_STATE; + action->parent.name = "paste"; + action->icon_name = "edit-paste"; + action->label = N_( "_Paste" ); + action->tooltip = N_( "Paste text from clipboard." ); + + return G_ACTION(action); } diff --git a/src/objects/toolbar/actions.c b/src/objects/toolbar/actions.c index 8ada6ed..ca7ee41 100644 --- a/src/objects/toolbar/actions.c +++ b/src/objects/toolbar/actions.c @@ -60,8 +60,8 @@ if(window) { - GAction *action = g_action_map_lookup_action(G_ACTION_MAP(window), name); GtkToolItem * item = NULL; + GAction *action = g_action_map_lookup_action(G_ACTION_MAP(window), name); if(!action) { const gchar *ptr = strchr(name,'.'); @@ -79,7 +79,14 @@ } if(item) { - gtk_actionable_set_action_name(GTK_ACTIONABLE(item),name); + + if(action && g_action_get_parameter_type(action) == G_VARIANT_TYPE_STRING) { + g_autofree gchar * detailed = g_strconcat(name,"::",NULL); + gtk_actionable_set_detailed_action_name(GTK_ACTIONABLE(item),detailed); + } else { + gtk_actionable_set_action_name(GTK_ACTIONABLE(item),name); + } + gtk_toolbar_insert(GTK_TOOLBAR(toolbar),item,pos); return GTK_WIDGET(item); } diff --git a/src/objects/window/window.c b/src/objects/window/window.c index 6532d70..4c135ab 100644 --- a/src/objects/window/window.c +++ b/src/objects/window/window.c @@ -170,8 +170,6 @@ GtkWidget * pw3270_application_window_new(GtkApplication * application) { - size_t ix; - const gchar * title = _( "IBM 3270 Terminal emulator" ); g_autoptr(GSettings) settings = pw3270_application_get_settings(G_APPLICATION(application)); -- libgit2 0.21.2