Commit 574dbb76ae37c0c99702c92b42302727cb291e39
1 parent
60dd822f
Exists in
master
and in
4 other branches
Fixing "cut" & "copy" actions.
Showing
3 changed files
with
63 additions
and
83 deletions
Show diff stats
src/objects/actions/clipboard.c
@@ -35,17 +35,55 @@ | @@ -35,17 +35,55 @@ | ||
35 | #include "private.h" | 35 | #include "private.h" |
36 | #include <v3270.h> | 36 | #include <v3270.h> |
37 | 37 | ||
38 | - static void activate_copy(GAction G_GNUC_UNUSED(*action), GVariant G_GNUC_UNUSED(*parameter), GtkWidget *terminal) { | 38 | + static V3270_COPY_MODE get_copy_mode_from_parameter(GVariant *parameter) { |
39 | + | ||
40 | + static const struct { | ||
41 | + const gchar * name; | ||
42 | + V3270_COPY_MODE value; | ||
43 | + } targets[] = { | ||
44 | + { "auto", V3270_COPY_DEFAULT }, | ||
45 | + { "system", V3270_COPY_DEFAULT }, | ||
46 | + { "default", V3270_COPY_DEFAULT }, | ||
47 | + { "system default", V3270_COPY_DEFAULT }, | ||
48 | + { "formatted", V3270_COPY_FORMATTED }, | ||
49 | + { "text", V3270_COPY_TEXT }, | ||
50 | + { "table", V3270_COPY_TABLE }, | ||
51 | + { "append", V3270_COPY_APPEND } | ||
52 | + | ||
53 | + }; | ||
54 | + | ||
55 | + if(parameter) { | ||
56 | + | ||
57 | + const gchar * target = g_variant_get_string(parameter,NULL); | ||
58 | + | ||
59 | + if(target && *target) { | ||
60 | + | ||
61 | + size_t ix; | ||
62 | + for(ix = 0; ix < G_N_ELEMENTS(targets); ix++) { | ||
63 | + | ||
64 | + if(!g_ascii_strcasecmp(target,targets[ix].name)) | ||
65 | + return targets[ix].value; | ||
66 | + | ||
67 | + } | ||
68 | + | ||
69 | + } | ||
70 | + | ||
71 | + } | ||
72 | + | ||
73 | + return V3270_COPY_DEFAULT; | ||
74 | + } | ||
75 | + | ||
76 | + static void activate_copy(GAction G_GNUC_UNUSED(*action), GVariant *parameter, GtkWidget *terminal) { | ||
39 | 77 | ||
40 | debug("%s",__FUNCTION__); | 78 | debug("%s",__FUNCTION__); |
41 | - v3270_copy_selection(terminal,V3270_SELECT_TEXT,FALSE); | 79 | + v3270_clipboard_set(terminal,get_copy_mode_from_parameter(parameter),FALSE); |
42 | 80 | ||
43 | } | 81 | } |
44 | 82 | ||
45 | static void activate_cut(GAction G_GNUC_UNUSED(*action), GVariant G_GNUC_UNUSED(*parameter), GtkWidget *terminal) { | 83 | static void activate_cut(GAction G_GNUC_UNUSED(*action), GVariant G_GNUC_UNUSED(*parameter), GtkWidget *terminal) { |
46 | 84 | ||
47 | debug("%s",__FUNCTION__); | 85 | debug("%s",__FUNCTION__); |
48 | - v3270_copy_selection(terminal,V3270_SELECT_TEXT,TRUE); | 86 | + v3270_clipboard_set(terminal,get_copy_mode_from_parameter(parameter),TRUE); |
49 | 87 | ||
50 | } | 88 | } |
51 | 89 | ||
@@ -54,47 +92,23 @@ | @@ -54,47 +92,23 @@ | ||
54 | 92 | ||
55 | if(!parameter) { | 93 | if(!parameter) { |
56 | debug("%s %p",__FUNCTION__,"NULL"); | 94 | debug("%s %p",__FUNCTION__,"NULL"); |
57 | - v3270_paste_from_url(terminal,NULL); | 95 | + v3270_clipboard_get_from_url(terminal,NULL); |
58 | } else { | 96 | } else { |
59 | debug("%s \"%s\"",__FUNCTION__,g_variant_get_string(parameter,NULL)); | 97 | debug("%s \"%s\"",__FUNCTION__,g_variant_get_string(parameter,NULL)); |
60 | - v3270_paste_from_url(terminal,g_variant_get_string(parameter,NULL)); | 98 | + v3270_clipboard_get_from_url(terminal,g_variant_get_string(parameter,NULL)); |
61 | } | 99 | } |
62 | 100 | ||
63 | } | 101 | } |
64 | 102 | ||
65 | GAction * pw3270_copy_action_new(void) { | 103 | GAction * pw3270_copy_action_new(void) { |
66 | 104 | ||
67 | - /* | ||
68 | - static const LIB3270_ACTION action_descriptor = { | ||
69 | - .name = "copy", | ||
70 | - .type = LIB3270_ACTION_TYPE_SELECTION, | ||
71 | - | ||
72 | - .key = "<ctrl>c", | ||
73 | - .icon = "edit-copy", | ||
74 | - .label = N_( "_Copy" ), | ||
75 | - .summary = N_( "Copy selected area to clipboard." ), | ||
76 | - .activate = NULL, | ||
77 | - | ||
78 | - .group = LIB3270_ACTION_GROUP_SELECTION, | ||
79 | - .activatable = lib3270_has_selection | ||
80 | - | ||
81 | - }; | ||
82 | - | ||
83 | - GAction * action = pw3270_action_new_from_lib3270(&action_descriptor); | ||
84 | - | ||
85 | - PW3270_ACTION(action)->activate = activate_copy; | ||
86 | - | ||
87 | - | ||
88 | - return action; | ||
89 | - | ||
90 | - | ||
91 | - */ | ||
92 | - | ||
93 | pw3270SimpleAction * action = pw3270_simple_action_new(); | 105 | pw3270SimpleAction * action = pw3270_simple_action_new(); |
94 | 106 | ||
95 | action->parent.activate = activate_copy; | 107 | action->parent.activate = activate_copy; |
108 | + action->parent.types.parameter = G_VARIANT_TYPE_STRING; | ||
109 | + | ||
96 | action->group.id = LIB3270_ACTION_GROUP_SELECTION; | 110 | action->group.id = LIB3270_ACTION_GROUP_SELECTION; |
97 | - action->parent.name = "file.transfer"; | 111 | + action->parent.name = "copy"; |
98 | action->icon_name = "edit-copy"; | 112 | action->icon_name = "edit-copy"; |
99 | action->label = N_( "_Copy" ); | 113 | action->label = N_( "_Copy" ); |
100 | action->tooltip = N_( "Copy selected area to clipboard." ); | 114 | action->tooltip = N_( "Copy selected area to clipboard." ); |
@@ -105,34 +119,13 @@ | @@ -105,34 +119,13 @@ | ||
105 | 119 | ||
106 | GAction * pw3270_cut_action_new(void) { | 120 | GAction * pw3270_cut_action_new(void) { |
107 | 121 | ||
108 | - /* | ||
109 | - static const LIB3270_ACTION action_descriptor = { | ||
110 | - .name = "cut", | ||
111 | - .type = LIB3270_ACTION_TYPE_SELECTION, | ||
112 | - | ||
113 | - .key = "<ctrl>x", | ||
114 | - .icon = "edit-cut", | ||
115 | - .label = N_( "_Cut" ), | ||
116 | - .summary = N_( "Cut selected area." ), | ||
117 | - .activate = NULL, | ||
118 | - | ||
119 | - .group = LIB3270_ACTION_GROUP_SELECTION, | ||
120 | - .activatable = lib3270_has_selection | ||
121 | - | ||
122 | - }; | ||
123 | - | ||
124 | - GAction * action = pw3270_action_new_from_lib3270(&action_descriptor); | ||
125 | - | ||
126 | - PW3270_ACTION(action)->activate = activate_cut; | ||
127 | - | ||
128 | - return action; | ||
129 | - */ | ||
130 | - | ||
131 | pw3270SimpleAction * action = pw3270_simple_action_new(); | 122 | pw3270SimpleAction * action = pw3270_simple_action_new(); |
132 | 123 | ||
133 | action->parent.activate = activate_cut; | 124 | action->parent.activate = activate_cut; |
125 | + action->parent.types.parameter = G_VARIANT_TYPE_STRING; | ||
126 | + | ||
134 | action->group.id = LIB3270_ACTION_GROUP_SELECTION; | 127 | action->group.id = LIB3270_ACTION_GROUP_SELECTION; |
135 | - action->parent.name = "file.transfer"; | 128 | + action->parent.name = "cut"; |
136 | action->icon_name = "edit-cut"; | 129 | action->icon_name = "edit-cut"; |
137 | action->label = N_( "C_ut" ); | 130 | action->label = N_( "C_ut" ); |
138 | action->tooltip = N_( "Cut selected area." ); | 131 | action->tooltip = N_( "Cut selected area." ); |
@@ -143,29 +136,6 @@ | @@ -143,29 +136,6 @@ | ||
143 | 136 | ||
144 | GAction * pw3270_paste_action_new(void) { | 137 | GAction * pw3270_paste_action_new(void) { |
145 | 138 | ||
146 | - /* | ||
147 | - static const LIB3270_ACTION action_descriptor = { | ||
148 | - .name = "paste", | ||
149 | - .type = LIB3270_ACTION_TYPE_SELECTION, | ||
150 | - | ||
151 | - .key = "<ctrl>v", | ||
152 | - .icon = "edit-paste", | ||
153 | - .label = N_( "_Paste" ), | ||
154 | - .summary = N_( "Paste data from clipboard." ), | ||
155 | - .activate = NULL, | ||
156 | - | ||
157 | - .group = LIB3270_ACTION_GROUP_LOCK_STATE, | ||
158 | - .activatable = lib3270_is_unlocked | ||
159 | - | ||
160 | - }; | ||
161 | - | ||
162 | - pw3270Action * action = PW3270_ACTION(pw3270_action_new_from_lib3270(&action_descriptor)); | ||
163 | - | ||
164 | - action->types.parameter = G_VARIANT_TYPE_STRING; | ||
165 | - action->activate = activate_paste; | ||
166 | - | ||
167 | - return G_ACTION(action); | ||
168 | - */ | ||
169 | 139 | ||
170 | pw3270SimpleAction * action = pw3270_simple_action_new(); | 140 | pw3270SimpleAction * action = pw3270_simple_action_new(); |
171 | 141 |
src/objects/application/actions/window.c
@@ -56,14 +56,14 @@ | @@ -56,14 +56,14 @@ | ||
56 | 56 | ||
57 | } | 57 | } |
58 | 58 | ||
59 | - void pw3270_application_new_tab_activated(GSimpleAction * action, GVariant *parameter, gpointer application) { | 59 | + void pw3270_application_new_tab_activated(GSimpleAction G_GNUC_UNUSED(* action), GVariant G_GNUC_UNUSED(*parameter), gpointer application) { |
60 | 60 | ||
61 | debug("%s",__FUNCTION__); | 61 | debug("%s",__FUNCTION__); |
62 | pw3270_terminal_new(GTK_WIDGET(gtk_application_get_active_window(GTK_APPLICATION(application)))); | 62 | pw3270_terminal_new(GTK_WIDGET(gtk_application_get_active_window(GTK_APPLICATION(application)))); |
63 | 63 | ||
64 | } | 64 | } |
65 | 65 | ||
66 | - void pw3270_application_new_window_activated(GSimpleAction * action, GVariant *parameter, gpointer application) { | 66 | + void pw3270_application_new_window_activated(GSimpleAction G_GNUC_UNUSED(* action), GVariant G_GNUC_UNUSED(*parameter), gpointer application) { |
67 | 67 | ||
68 | debug("%s",__FUNCTION__); | 68 | debug("%s",__FUNCTION__); |
69 | g_application_activate(application); | 69 | g_application_activate(application); |
ui/application.xml
@@ -115,21 +115,31 @@ | @@ -115,21 +115,31 @@ | ||
115 | <item> | 115 | <item> |
116 | <attribute name="label" translatable="yes">Copy</attribute> | 116 | <attribute name="label" translatable="yes">Copy</attribute> |
117 | <attribute name="action">win.copy</attribute> | 117 | <attribute name="action">win.copy</attribute> |
118 | + <attribute name="target">auto</attribute> | ||
119 | + </item> | ||
120 | + | ||
121 | + <item> | ||
122 | + <attribute name="label" translatable="yes">Copy as text</attribute> | ||
123 | + <attribute name="action">win.copy</attribute> | ||
124 | + <attribute name="target">text</attribute> | ||
118 | </item> | 125 | </item> |
119 | 126 | ||
120 | <item> | 127 | <item> |
121 | <attribute name="label" translatable="yes">Copy as table</attribute> | 128 | <attribute name="label" translatable="yes">Copy as table</attribute> |
122 | - <attribute name="action">win.copy_as_table</attribute> | 129 | + <attribute name="action">win.copy</attribute> |
130 | + <attribute name="target">table</attribute> | ||
123 | </item> | 131 | </item> |
124 | 132 | ||
125 | <item> | 133 | <item> |
126 | <attribute name="label" translatable="yes">Append to copy</attribute> | 134 | <attribute name="label" translatable="yes">Append to copy</attribute> |
127 | - <attribute name="action">win.append_to_copy</attribute> | 135 | + <attribute name="action">win.copy</attribute> |
136 | + <attribute name="target">append</attribute> | ||
128 | </item> | 137 | </item> |
129 | 138 | ||
130 | <item> | 139 | <item> |
131 | <attribute name="label" translatable="yes">Cut</attribute> | 140 | <attribute name="label" translatable="yes">Cut</attribute> |
132 | <attribute name="action">win.cut</attribute> | 141 | <attribute name="action">win.cut</attribute> |
142 | + <attribute name="target">auto</attribute> | ||
133 | </item> | 143 | </item> |
134 | 144 | ||
135 | <item> | 145 | <item> |