Commit 5de056344c3bb1b9c7d8bf0b7c6642210fd84beb
1 parent
045bce44
Exists in
master
and in
1 other branch
Improving "paste" methods.
Showing
5 changed files
with
43 additions
and
28 deletions
Show diff stats
src/dialogs/load.c
@@ -245,7 +245,7 @@ static void icon_press(GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconPosition icon_ | @@ -245,7 +245,7 @@ static void icon_press(GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconPosition icon_ | ||
245 | 245 | ||
246 | gtk_window_set_title(GTK_WINDOW(dialog),_("Paste from file")); | 246 | gtk_window_set_title(GTK_WINDOW(dialog),_("Paste from file")); |
247 | 247 | ||
248 | - if(filename) | 248 | + if(filename && *filename) |
249 | gtk_entry_set_text(GTK_ENTRY(dialog->filename),filename); | 249 | gtk_entry_set_text(GTK_ENTRY(dialog->filename),filename); |
250 | 250 | ||
251 | gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(gtk_widget_get_toplevel(widget))); | 251 | gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(gtk_widget_get_toplevel(widget))); |
src/include/v3270.h
@@ -227,9 +227,12 @@ | @@ -227,9 +227,12 @@ | ||
227 | LIB3270_EXPORT void v3270_copy_selection(GtkWidget *widget, V3270_SELECT_FORMAT mode, gboolean cut); | 227 | LIB3270_EXPORT void v3270_copy_selection(GtkWidget *widget, V3270_SELECT_FORMAT mode, gboolean cut); |
228 | LIB3270_EXPORT void v3270_append_selection(GtkWidget *widget, gboolean cut); | 228 | LIB3270_EXPORT void v3270_append_selection(GtkWidget *widget, gboolean cut); |
229 | 229 | ||
230 | - LIB3270_EXPORT void v3270_paste(GtkWidget *widget); | ||
231 | - LIB3270_EXPORT void v3270_paste_text(GtkWidget *widget); | ||
232 | - LIB3270_EXPORT void v3270_paste_from_file(GtkWidget *widget); | 230 | + LIB3270_EXPORT void v3270_paste_from_url(GtkWidget *widget, const gchar *url); |
231 | + | ||
232 | + LIB3270_EXPORT void v3270_paste(GtkWidget *widget) G_GNUC_DEPRECATED; | ||
233 | + LIB3270_EXPORT void v3270_paste_text(GtkWidget *widget) G_GNUC_DEPRECATED; | ||
234 | + LIB3270_EXPORT void v3270_paste_from_file(GtkWidget *widget) G_GNUC_DEPRECATED; | ||
235 | + | ||
233 | LIB3270_EXPORT void v3270_input_text(GtkWidget *widget, const gchar *text, const gchar *encoding); | 236 | LIB3270_EXPORT void v3270_input_text(GtkWidget *widget, const gchar *text, const gchar *encoding); |
234 | 237 | ||
235 | // Colors | 238 | // Colors |
src/selection/linux/paste.c
@@ -29,6 +29,7 @@ | @@ -29,6 +29,7 @@ | ||
29 | 29 | ||
30 | #include <clipboard.h> | 30 | #include <clipboard.h> |
31 | #include <lib3270/toggle.h> | 31 | #include <lib3270/toggle.h> |
32 | + #include <v3270/dialogs.h> | ||
32 | 33 | ||
33 | /*--[ Implement ]------------------------------------------------------------------------------------*/ | 34 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
34 | 35 | ||
@@ -176,25 +177,47 @@ static void targets_received(GtkClipboard *clipboard, GdkAtom *atoms, gint n_ato | @@ -176,25 +177,47 @@ static void targets_received(GtkClipboard *clipboard, GdkAtom *atoms, gint n_ato | ||
176 | 177 | ||
177 | } | 178 | } |
178 | 179 | ||
179 | -LIB3270_EXPORT void v3270_paste(GtkWidget *widget) | 180 | +LIB3270_EXPORT void v3270_paste_from_url(GtkWidget *widget, const gchar *url) |
180 | { | 181 | { |
181 | g_return_if_fail(GTK_IS_V3270(widget)); | 182 | g_return_if_fail(GTK_IS_V3270(widget)); |
182 | 183 | ||
183 | GtkClipboard * clipboard = gtk_widget_get_clipboard(widget,GTK_V3270(widget)->selection.target); | 184 | GtkClipboard * clipboard = gtk_widget_get_clipboard(widget,GTK_V3270(widget)->selection.target); |
184 | - gtk_clipboard_request_targets(clipboard, (GtkClipboardTargetsReceivedFunc) targets_received, (gpointer) widget); | 185 | + |
186 | + if(!url || g_str_has_prefix(url,"clipboard://")) | ||
187 | + { | ||
188 | + gtk_clipboard_request_targets( | ||
189 | + clipboard, | ||
190 | + (GtkClipboardTargetsReceivedFunc) targets_received, | ||
191 | + (gpointer) widget | ||
192 | + ); | ||
193 | + } | ||
194 | + else if(g_str_has_prefix(url,"text://")) | ||
195 | + { | ||
196 | + gtk_clipboard_request_text( | ||
197 | + clipboard, | ||
198 | + (GtkClipboardTextReceivedFunc) text_received, | ||
199 | + (gpointer) widget | ||
200 | + ); | ||
201 | + | ||
202 | + } | ||
203 | + else if(g_str_has_prefix(url,"file://")) | ||
204 | + { | ||
205 | + GtkWidget * dialog = v3270_load_dialog_new(widget, url+7); | ||
206 | + gtk_widget_show_all(dialog); | ||
207 | + v3270_load_dialog_run(dialog); | ||
208 | + gtk_widget_destroy(dialog); | ||
209 | + } | ||
185 | 210 | ||
186 | } | 211 | } |
187 | 212 | ||
188 | -LIB3270_EXPORT void v3270_paste_text(GtkWidget *widget) | ||
189 | -{ | ||
190 | - g_return_if_fail(GTK_IS_V3270(widget)); | ||
191 | - GtkClipboard * clipboard = gtk_widget_get_clipboard(widget,GTK_V3270(widget)->selection.target); | ||
192 | 213 | ||
193 | - gtk_clipboard_request_text( | ||
194 | - clipboard, | ||
195 | - (GtkClipboardTextReceivedFunc) text_received, | ||
196 | - (gpointer) widget | ||
197 | - ); | 214 | +LIB3270_EXPORT void v3270_paste(GtkWidget *widget) |
215 | +{ | ||
216 | + v3270_paste_from_url(widget,NULL); | ||
217 | +} | ||
198 | 218 | ||
219 | +LIB3270_EXPORT void v3270_paste_text(GtkWidget *widget) | ||
220 | +{ | ||
221 | + v3270_paste_from_url(widget,"text://"); | ||
199 | } | 222 | } |
200 | 223 |
src/testprogram/toolbar.c
@@ -157,7 +157,7 @@ | @@ -157,7 +157,7 @@ | ||
157 | 157 | ||
158 | static void paste_clicked(GtkButton G_GNUC_UNUSED(*button), GtkWidget *terminal) | 158 | static void paste_clicked(GtkButton G_GNUC_UNUSED(*button), GtkWidget *terminal) |
159 | { | 159 | { |
160 | - v3270_paste(terminal); | 160 | + v3270_paste_from_url(terminal,NULL); |
161 | } | 161 | } |
162 | 162 | ||
163 | static void copy_clicked(GtkButton G_GNUC_UNUSED(*button), GtkWidget *terminal) | 163 | static void copy_clicked(GtkButton G_GNUC_UNUSED(*button), GtkWidget *terminal) |
src/trace/exec.c
@@ -237,18 +237,7 @@ | @@ -237,18 +237,7 @@ | ||
237 | gchar * arg = cmdline+5; | 237 | gchar * arg = cmdline+5; |
238 | g_strstrip(arg); | 238 | g_strstrip(arg); |
239 | 239 | ||
240 | - if(!*arg) | ||
241 | - { | ||
242 | - v3270_paste(trace->terminal); | ||
243 | - } | ||
244 | - else if(!g_ascii_strcasecmp(arg,"text")) | ||
245 | - { | ||
246 | - v3270_paste_text(trace->terminal); | ||
247 | - } | ||
248 | - else | ||
249 | - { | ||
250 | - return errno = EINVAL; | ||
251 | - } | 240 | + v3270_paste_from_url(trace->terminal,arg); |
252 | 241 | ||
253 | return 0; | 242 | return 0; |
254 | } | 243 | } |