Commit 4688b17d90b388105e1ec9ef933e733806102840
Committed by
GitHub
Exists in
master
and in
1 other branch
Merge pull request #17 from PerryWerneck/macos
Fixing MAC builds.
Showing
10 changed files
with
770 additions
and
5 deletions
Show diff stats
.gitignore
Makefile.in
... | ... | @@ -363,6 +363,18 @@ install-linux-lib: \ |
363 | 363 | $(BINRLS)/$(SONAME) \ |
364 | 364 | $(DESTDIR)$(libdir)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ |
365 | 365 | |
366 | +install-macos-lib: \ | |
367 | + $(BINRLS)/$(SONAME) \ | |
368 | + install-conf \ | |
369 | + install-locale | |
370 | + | |
371 | + # Install library | |
372 | + @$(MKDIR) $(DESTDIR)$(libdir) | |
373 | + | |
374 | + @$(INSTALL_PROGRAM) \ | |
375 | + $(BINRLS)/$(SONAME) \ | |
376 | + $(DESTDIR)$(libdir)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ | |
377 | + | |
366 | 378 | install-windows-lib: \ |
367 | 379 | $(BINRLS)/$(SONAME) \ |
368 | 380 | install-conf \ |
... | ... | @@ -439,6 +451,15 @@ install-linux-dev: |
439 | 451 | $(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ \ |
440 | 452 | $(DESTDIR)$(libdir)/$(LIBNAME)@DLLEXT@ |
441 | 453 | |
454 | +install-macos-dev: | |
455 | + | |
456 | + @$(MKDIR) \ | |
457 | + $(DESTDIR)$(libdir) | |
458 | + | |
459 | + @$(LN_S) \ | |
460 | + $(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ \ | |
461 | + $(DESTDIR)$(libdir)/$(LIBNAME)@DLLEXT@ | |
462 | + | |
442 | 463 | install-windows-dev: \ |
443 | 464 | strip \ |
444 | 465 | $(BINRLS)/$(LIBNAME).dll.a |
... | ... | @@ -549,7 +570,7 @@ $(BINDBG)/$(SONAME): \ |
549 | 570 | @$(MKDIR) $(@D) |
550 | 571 | @echo $< ... |
551 | 572 | @$(LD) \ |
552 | - -shared -Wl,-soname,$(@F) \ | |
573 | + @DLL_LDFLAGS@ \ | |
553 | 574 | -o $@ \ |
554 | 575 | -L$(BINDBG) \ |
555 | 576 | $(LDFLAGS) \ | ... | ... |
README.md
... | ... | @@ -106,7 +106,7 @@ For the supported distributions get the install repositories and instructions fr |
106 | 106 | 3. Configure, build and install |
107 | 107 | |
108 | 108 | ```shell |
109 | - ./autogen.sh --prefix="$(brew --cellar)/libv3270/5.3" | |
109 | + ./autogen.sh --prefix="$(brew --cellar)/libv3270/5.4" | |
110 | 110 | make all && make install |
111 | 111 | brew link libv3270 |
112 | 112 | ``` | ... | ... |
autogen.sh
configure.ac
... | ... | @@ -52,6 +52,9 @@ AM_INIT_AUTOMAKE |
52 | 52 | dnl Check for iconv |
53 | 53 | AM_ICONV |
54 | 54 | |
55 | +dnl Set gettext version | |
56 | +AM_GNU_GETTEXT_VERSION([0.14]) | |
57 | + | |
55 | 58 | dnl Checks for programs. |
56 | 59 | AC_PROG_CC |
57 | 60 | AC_PROG_SED |
... | ... | @@ -103,9 +106,9 @@ case "$host" in |
103 | 106 | *-apple-darwin*) |
104 | 107 | CFLAGS="$CFLAGS -pthread" |
105 | 108 | LDFLAGS="$LDFLAGS -pthread" |
106 | - app_cv_osname="linux" | |
109 | + app_cv_osname="macos" | |
107 | 110 | LOGDIR="/var/log" |
108 | - DLLEXT=".so" | |
111 | + DLLEXT=".dylib" | |
109 | 112 | DLL_LDFLAGS="-shared -Wl,-install_name,\$(@F)" |
110 | 113 | |
111 | 114 | INSTALL_PACKAGES="linux-lib ${INSTALL_PACKAGES}" |
... | ... | @@ -200,7 +203,7 @@ case "$host" in |
200 | 203 | ;; |
201 | 204 | |
202 | 205 | *) |
203 | - AC_SUBST(SONAME,libv3270.so.$app_vrs_major.$app_vrs_minor) | |
206 | + AC_SUBST(SONAME,libv3270.dylib.$app_vrs_major.$app_vrs_minor) | |
204 | 207 | |
205 | 208 | esac |
206 | 209 | ... | ... |
... | ... | @@ -0,0 +1,96 @@ |
1 | +/* | |
2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob | |
5 | + * o nome G3270. | |
6 | + * | |
7 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | |
8 | + * | |
9 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
10 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
11 | + * Free Software Foundation. | |
12 | + * | |
13 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
14 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
15 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
16 | + * obter mais detalhes. | |
17 | + * | |
18 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
19 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
20 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | |
21 | + * | |
22 | + * Este programa está nomeado como - possui - linhas de código. | |
23 | + * | |
24 | + * Contatos: | |
25 | + * | |
26 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
27 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
28 | + * | |
29 | + */ | |
30 | + | |
31 | +#include "../private.h" | |
32 | +#include <stdarg.h> | |
33 | + | |
34 | +/*--[ Implement ]------------------------------------------------------------------------------------*/ | |
35 | + | |
36 | +gchar * v3270_select_file(GtkWidget *widget, const gchar *title, const gchar *button, GtkFileChooserAction action, const gchar *filename) | |
37 | +{ | |
38 | + gchar *rc = NULL; | |
39 | + | |
40 | +#if GTK_CHECK_VERSION(3,20,0) | |
41 | + | |
42 | + debug("%s action=%d",__FUNCTION__,(int) action); | |
43 | + | |
44 | + GtkFileChooserNative *native = | |
45 | + gtk_file_chooser_native_new | |
46 | + ( | |
47 | + title, | |
48 | + GTK_WINDOW(widget), | |
49 | + action, | |
50 | + button, | |
51 | + _( "_Cancel" ) | |
52 | + ); | |
53 | + | |
54 | + | |
55 | + // Setup filename | |
56 | + if(filename && *filename) | |
57 | + gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(native),filename); | |
58 | + | |
59 | + | |
60 | + // Run dialog | |
61 | + if(gtk_native_dialog_run(GTK_NATIVE_DIALOG (native)) == GTK_RESPONSE_ACCEPT) { | |
62 | + rc = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(native)); | |
63 | + } | |
64 | + | |
65 | + g_object_unref(native); | |
66 | + | |
67 | +#else | |
68 | + | |
69 | + debug("%s action=%d",__FUNCTION__,(int) action); | |
70 | + | |
71 | + GtkWidget * chooser = | |
72 | + gtk_file_chooser_dialog_new | |
73 | + ( | |
74 | + title, | |
75 | + GTK_WINDOW(widget), | |
76 | + action, | |
77 | + _("_Cancel" ), GTK_RESPONSE_CANCEL, | |
78 | + button, GTK_RESPONSE_ACCEPT, | |
79 | + NULL | |
80 | + ); | |
81 | + | |
82 | + if(filename && *filename) | |
83 | + gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(chooser),filename); | |
84 | + | |
85 | + if(gtk_dialog_run(GTK_DIALOG(chooser)) == GTK_RESPONSE_ACCEPT) { | |
86 | + rc = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(chooser)); | |
87 | + } | |
88 | + | |
89 | + gtk_widget_destroy(chooser); | |
90 | + | |
91 | +#endif // GTK 3.20 | |
92 | + | |
93 | + return rc; | |
94 | + | |
95 | +} | |
96 | + | ... | ... |
... | ... | @@ -0,0 +1,196 @@ |
1 | +/* | |
2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | |
5 | + * | |
6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | |
7 | + * | |
8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
10 | + * Free Software Foundation. | |
11 | + * | |
12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
15 | + * obter mais detalhes. | |
16 | + * | |
17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
19 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | |
20 | + * | |
21 | + * Este programa está nomeado como - possui - linhas de código. | |
22 | + * | |
23 | + * Contatos: | |
24 | + * | |
25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
27 | + * | |
28 | + */ | |
29 | + | |
30 | + #include <clipboard.h> | |
31 | + #include <lib3270/selection.h> | |
32 | + #include <lib3270/toggle.h> | |
33 | + | |
34 | +/*--[ Implement ]------------------------------------------------------------------------------------*/ | |
35 | + | |
36 | +void v3270_clipboard_clear(G_GNUC_UNUSED GtkClipboard *clipboard, G_GNUC_UNUSED GObject *obj) | |
37 | +{ | |
38 | + v3270 * terminal = GTK_V3270(obj); | |
39 | + | |
40 | + if(!lib3270_get_toggle(terminal->host,LIB3270_TOGGLE_KEEP_SELECTED)) | |
41 | + { | |
42 | + v3270_unselect(GTK_WIDGET(obj)); | |
43 | + v3270_clear_selection(terminal); | |
44 | + } | |
45 | + | |
46 | +} | |
47 | + | |
48 | +void v3270_clipboard_get(G_GNUC_UNUSED GtkClipboard *clipboard, GtkSelectionData *selection, guint target, GObject *obj) | |
49 | +{ | |
50 | + v3270 * terminal = GTK_V3270(obj); | |
51 | + | |
52 | + if(!terminal->selection.blocks) | |
53 | + { | |
54 | + return; | |
55 | + } | |
56 | + | |
57 | + switch(target) | |
58 | + { | |
59 | + case CLIPBOARD_TYPE_TEXT: // Get clipboard contents as text | |
60 | + { | |
61 | + g_autofree gchar *text = v3270_get_copy_as_text(terminal,"UTF-8"); | |
62 | + gtk_selection_data_set_text(selection,text,-1); | |
63 | + } | |
64 | + break; | |
65 | + | |
66 | + case CLIPBOARD_TYPE_CSV: | |
67 | + { | |
68 | + g_autofree gchar *text = v3270_get_copy_as_table(terminal,";","UTF-8"); | |
69 | + debug("Selection:\n%s",text); | |
70 | + gtk_selection_data_set( | |
71 | + selection, | |
72 | + gdk_atom_intern_static_string("text/csv"), | |
73 | + 8, | |
74 | + (guchar *) text, | |
75 | + strlen(text) | |
76 | + ); | |
77 | + } | |
78 | + break; | |
79 | + | |
80 | + case CLIPBOARD_TYPE_HTML: | |
81 | + { | |
82 | + g_autofree gchar *text = v3270_get_copy_as_html(terminal,"UTF-8"); | |
83 | + //debug("Selection:\n%s",text); | |
84 | + gtk_selection_data_set( | |
85 | + selection, | |
86 | + gdk_atom_intern_static_string("text/html"), | |
87 | + 8, | |
88 | + (guchar *) text, | |
89 | + strlen(text) | |
90 | + ); | |
91 | + } | |
92 | + break; | |
93 | + | |
94 | + case CLIPBOARD_TYPE_V3270_FORMATTED: | |
95 | + { | |
96 | + g_autofree gchar *data = v3270_get_copy_as_data_block(terminal); | |
97 | + gtk_selection_data_set( | |
98 | + selection, | |
99 | + GTK_V3270_GET_CLASS(obj)->clipboard_formatted, | |
100 | + 8, | |
101 | + (guchar *) data, | |
102 | + ((struct SelectionHeader *) data)->length | |
103 | + ); | |
104 | + } | |
105 | + break; | |
106 | + | |
107 | + case CLIPBOARD_TYPE_PIXBUFF: | |
108 | + { | |
109 | + GdkPixbuf * pixbuff = v3270_get_selection_as_pixbuf(terminal, terminal->selection.blocks, FALSE); | |
110 | + | |
111 | + debug("%s: pixbuff=%p (blocks=%p)",__FUNCTION__,pixbuff,terminal->selection.blocks); | |
112 | + | |
113 | + if(pixbuff) | |
114 | + { | |
115 | + gtk_selection_data_set_pixbuf(selection,pixbuff); | |
116 | + g_object_unref(pixbuff); | |
117 | + } | |
118 | + } | |
119 | + break; | |
120 | + | |
121 | + default: | |
122 | + g_warning("Unexpected clipboard type %d\n",target); | |
123 | + } | |
124 | +} | |
125 | + | |
126 | +void v3270_update_system_clipboard(GtkWidget *widget) | |
127 | +{ | |
128 | + v3270 * terminal = GTK_V3270(widget); | |
129 | + | |
130 | + if(!terminal->selection.blocks) | |
131 | + { | |
132 | + // No clipboard data, return. | |
133 | + v3270_emit_copy_state(widget); | |
134 | + return; | |
135 | + } | |
136 | + | |
137 | + // Has clipboard data, inform system. | |
138 | + GtkClipboard * clipboard = gtk_widget_get_clipboard(widget,terminal->selection.target); | |
139 | + | |
140 | + // Create target list | |
141 | + // | |
142 | + // Reference: https://cpp.hotexamples.com/examples/-/-/g_list_insert_sorted/cpp-g_list_insert_sorted-function-examples.html | |
143 | + // | |
144 | + GtkTargetList * list = gtk_target_list_new(NULL,0); | |
145 | + | |
146 | + gtk_target_list_add_text_targets(list, CLIPBOARD_TYPE_TEXT); | |
147 | + | |
148 | + if((terminal->selection.options & V3270_SELECTION_PLAIN_TEXT) == 0) | |
149 | + { | |
150 | + static const GtkTargetEntry targets[] = { | |
151 | + { "text/csv", 0, CLIPBOARD_TYPE_CSV }, | |
152 | + { "text/html", 0, CLIPBOARD_TYPE_HTML }, | |
153 | + { "application/x-v3270-formatted", 0, CLIPBOARD_TYPE_V3270_FORMATTED }, | |
154 | + }; | |
155 | + | |
156 | + gtk_target_list_add_table(list, targets, G_N_ELEMENTS(targets)); | |
157 | + | |
158 | + } | |
159 | + | |
160 | + if(terminal->selection.options & V3270_SELECTION_PIXBUFF) | |
161 | + { | |
162 | + gtk_target_list_add_image_targets(list,CLIPBOARD_TYPE_PIXBUFF,TRUE); | |
163 | + } | |
164 | + | |
165 | + int n_targets; | |
166 | + GtkTargetEntry * targets = gtk_target_table_new_from_list(list, &n_targets); | |
167 | + | |
168 | +#ifdef DEBUG | |
169 | + { | |
170 | + int ix; | |
171 | + for(ix = 0; ix < n_targets; ix++) { | |
172 | + debug("target(%d)=\"%s\"",ix,targets[ix].target); | |
173 | + } | |
174 | + } | |
175 | +#endif // DEBUG | |
176 | + | |
177 | + if(gtk_clipboard_set_with_owner( | |
178 | + clipboard, | |
179 | + targets, | |
180 | + n_targets, | |
181 | + (GtkClipboardGetFunc) v3270_clipboard_get, | |
182 | + (GtkClipboardClearFunc) v3270_clipboard_clear, | |
183 | + G_OBJECT(widget) | |
184 | + )) | |
185 | + { | |
186 | + gtk_clipboard_set_can_store(clipboard,targets,1); | |
187 | + } | |
188 | + | |
189 | + gtk_target_table_free(targets, n_targets); | |
190 | + gtk_target_list_unref(list); | |
191 | + | |
192 | + v3270_emit_copy_state(widget); | |
193 | + | |
194 | +} | |
195 | + | |
196 | + | ... | ... |
... | ... | @@ -0,0 +1,219 @@ |
1 | +/* | |
2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | |
5 | + * | |
6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | |
7 | + * | |
8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
10 | + * Free Software Foundation. | |
11 | + * | |
12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
15 | + * obter mais detalhes. | |
16 | + * | |
17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
19 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | |
20 | + * | |
21 | + * Este programa está nomeado como selection.c e possui - linhas de código. | |
22 | + * | |
23 | + * Contatos: | |
24 | + * | |
25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
27 | + * | |
28 | + */ | |
29 | + | |
30 | + #include <clipboard.h> | |
31 | + #include <lib3270/toggle.h> | |
32 | + #include <v3270/dialogs.h> | |
33 | + #include <lib3270/popup.h> | |
34 | + | |
35 | +/*--[ Implement ]------------------------------------------------------------------------------------*/ | |
36 | + | |
37 | +static void text_received(G_GNUC_UNUSED GtkClipboard *clipboard, const gchar *text, GtkWidget *widget) | |
38 | +{ | |
39 | + v3270_input_text(widget,text,"UTF-8"); | |
40 | +} | |
41 | + | |
42 | +static gboolean has_target(const GdkAtom atom, const GdkAtom *atoms, const gint n_atoms) | |
43 | +{ | |
44 | + gint ix; | |
45 | + | |
46 | + for(ix = 0; ix < n_atoms; ix++) | |
47 | + { | |
48 | + if(atom == atoms[ix]) | |
49 | + return TRUE; | |
50 | + } | |
51 | + | |
52 | + return FALSE; | |
53 | +} | |
54 | + | |
55 | +static void formatted_received(GtkClipboard *clipboard, GtkSelectionData *selection_data, GtkWidget *widget) | |
56 | +{ | |
57 | + const struct SelectionHeader *selection = (const struct SelectionHeader *) gtk_selection_data_get_data(selection_data); | |
58 | + | |
59 | + v3270 * terminal = GTK_V3270(widget); | |
60 | + | |
61 | + debug( | |
62 | + "Received formatted data with %u bytes: Build=%u rows=%u cols=%u", | |
63 | + selection->length, | |
64 | + selection->build, | |
65 | + selection->rows, | |
66 | + selection->cols | |
67 | + ); | |
68 | + | |
69 | + if(selection->cols != lib3270_get_width(terminal->host) || selection->rows != lib3270_get_height(terminal->host)) | |
70 | + { | |
71 | + GtkWidget * dialog = | |
72 | + gtk_message_dialog_new( | |
73 | + GTK_WINDOW(gtk_widget_get_toplevel(widget)), | |
74 | + GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, | |
75 | + GTK_MESSAGE_INFO, | |
76 | + GTK_BUTTONS_NONE, | |
77 | + _("Not the same terminal type") | |
78 | + ); | |
79 | + | |
80 | + | |
81 | + gtk_window_set_title(GTK_WINDOW(dialog),_("Can't paste")); | |
82 | + | |
83 | + gtk_dialog_add_buttons( | |
84 | + GTK_DIALOG (dialog), | |
85 | + _("_Cancel"), GTK_RESPONSE_CANCEL, | |
86 | + _("_Paste as text"), GTK_RESPONSE_APPLY, | |
87 | + NULL | |
88 | + ); | |
89 | + | |
90 | + gtk_dialog_set_default_response(GTK_DIALOG (dialog),GTK_RESPONSE_APPLY); | |
91 | + | |
92 | + gint response = gtk_dialog_run(GTK_DIALOG(dialog)); | |
93 | + | |
94 | + gtk_widget_destroy(dialog); | |
95 | + | |
96 | + if(response == GTK_RESPONSE_APPLY) | |
97 | + { | |
98 | + gtk_clipboard_request_text( | |
99 | + clipboard, | |
100 | + (GtkClipboardTextReceivedFunc) text_received, | |
101 | + (gpointer) widget | |
102 | + ); | |
103 | + } | |
104 | + | |
105 | + return; | |
106 | + | |
107 | + } | |
108 | + | |
109 | + if(!v3270_set_from_data_block(terminal, selection)) | |
110 | + { | |
111 | + debug("%s: Can't paste data",__FUNCTION__); | |
112 | + | |
113 | + LIB3270_POPUP popup = { | |
114 | + .name = "cantpaste", | |
115 | + .title = _("Can't paste"), | |
116 | + .summary = _("Unable to paste formatted data."), | |
117 | + .body = _("None of the screens in the clipboard match with the current one."), | |
118 | + .label = _("_Paste as text") | |
119 | + }; | |
120 | + | |
121 | + if(v3270_popup_dialog_show(widget,&popup,1) == GTK_RESPONSE_APPLY) | |
122 | + { | |
123 | + gtk_clipboard_request_text( | |
124 | + clipboard, | |
125 | + (GtkClipboardTextReceivedFunc) text_received, | |
126 | + (gpointer) widget | |
127 | + ); | |
128 | + } | |
129 | + | |
130 | + return; | |
131 | + | |
132 | + } | |
133 | + | |
134 | +} | |
135 | + | |
136 | +static void targets_received(GtkClipboard *clipboard, GdkAtom *atoms, gint n_atoms, GtkWidget *widget) { | |
137 | + | |
138 | + // If smart paste is enabled try to get formatted clipboard. | |
139 | + gboolean screen_paste = ((GTK_V3270(widget)->selection.options & V3270_SELECTION_SCREEN_PASTE) != 0); | |
140 | + | |
141 | + debug("%s: Screen paste is %s", __FUNCTION__, screen_paste ? "enabled" : "disabled"); | |
142 | + | |
143 | + if(screen_paste && has_target(GTK_V3270_GET_CLASS(widget)->clipboard_formatted,atoms,n_atoms)) { | |
144 | + | |
145 | + debug("Clipboard as TN3270 \"%s\" data",gdk_atom_name(GTK_V3270_GET_CLASS(widget)->clipboard_formatted)); | |
146 | + | |
147 | + gtk_clipboard_request_contents( | |
148 | + clipboard, | |
149 | + GTK_V3270_GET_CLASS(widget)->clipboard_formatted, | |
150 | + (GtkClipboardReceivedFunc) formatted_received, | |
151 | + (gpointer) widget | |
152 | + ); | |
153 | + | |
154 | + return; | |
155 | + } | |
156 | + | |
157 | + // No smart paste or formatted data on clipboard, request as text. | |
158 | + gtk_clipboard_request_text( | |
159 | + clipboard, | |
160 | + (GtkClipboardTextReceivedFunc) text_received, | |
161 | + (gpointer) widget | |
162 | + ); | |
163 | + | |
164 | +} | |
165 | + | |
166 | +LIB3270_EXPORT void v3270_clipboard_get_from_url(GtkWidget *widget, const gchar *url) | |
167 | +{ | |
168 | + g_return_if_fail(GTK_IS_V3270(widget)); | |
169 | + | |
170 | + GtkClipboard * clipboard = gtk_widget_get_clipboard(widget,GTK_V3270(widget)->selection.target); | |
171 | + | |
172 | + if(!url || !*url || g_str_has_prefix(url,"clipboard://") || g_str_has_prefix(url,"tn3270://")) | |
173 | + { | |
174 | + gtk_clipboard_request_targets( | |
175 | + clipboard, | |
176 | + (GtkClipboardTargetsReceivedFunc) targets_received, | |
177 | + (gpointer) widget | |
178 | + ); | |
179 | + } | |
180 | + else if(g_str_has_prefix(url,"text://")) | |
181 | + { | |
182 | + gtk_clipboard_request_text( | |
183 | + clipboard, | |
184 | + (GtkClipboardTextReceivedFunc) text_received, | |
185 | + (gpointer) widget | |
186 | + ); | |
187 | + } | |
188 | + else if(g_str_has_prefix(url,"file://")) | |
189 | + { | |
190 | + GtkWidget * dialog = v3270_load_dialog_new(widget, url+7); | |
191 | + gtk_widget_show_all(dialog); | |
192 | + v3270_load_dialog_run(dialog); | |
193 | + gtk_widget_destroy(dialog); | |
194 | + } | |
195 | + else if(g_str_has_prefix(url,"screen://")) | |
196 | + { | |
197 | + gtk_clipboard_request_contents( | |
198 | + clipboard, | |
199 | + GTK_V3270_GET_CLASS(widget)->clipboard_formatted, | |
200 | + (GtkClipboardReceivedFunc) formatted_received, | |
201 | + (gpointer) widget | |
202 | + ); | |
203 | + } | |
204 | + | |
205 | +} | |
206 | + | |
207 | + | |
208 | +LIB3270_EXPORT void v3270_paste(GtkWidget *widget) | |
209 | +{ | |
210 | + debug("%s",__FUNCTION__); | |
211 | + v3270_clipboard_get_from_url(widget,NULL); | |
212 | +} | |
213 | + | |
214 | +LIB3270_EXPORT void v3270_paste_text(GtkWidget *widget) | |
215 | +{ | |
216 | + debug("%s",__FUNCTION__); | |
217 | + v3270_clipboard_get_from_url(widget,"text://"); | |
218 | +} | |
219 | + | ... | ... |
... | ... | @@ -0,0 +1,56 @@ |
1 | +/* | |
2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | |
5 | + * | |
6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | |
7 | + * | |
8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
10 | + * Free Software Foundation. | |
11 | + * | |
12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
15 | + * obter mais detalhes. | |
16 | + * | |
17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
19 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | |
20 | + * | |
21 | + * Este programa está nomeado como - e possui - linhas de código. | |
22 | + * | |
23 | + * Contatos: | |
24 | + * | |
25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
27 | + * | |
28 | + */ | |
29 | + | |
30 | + #include <config.h> | |
31 | + #include <lib3270.h> | |
32 | + #include <locale.h> | |
33 | + #include <libintl.h> | |
34 | + #include <lib3270/log.h> | |
35 | + | |
36 | + int libv3270_loaded(void) __attribute__((constructor)); | |
37 | + int libv3270_unloaded(void) __attribute__((destructor)); | |
38 | + | |
39 | +/*---[ Implement ]-----------------------------------------------------------------------------------------*/ | |
40 | + | |
41 | + int libv3270_loaded(void) { | |
42 | + | |
43 | + debug("LocaleDIR(%s)=%s",PACKAGE_NAME,LIB3270_STRINGIZE_VALUE_OF(LOCALEDIR)); | |
44 | + | |
45 | + bindtextdomain(PACKAGE_NAME, LIB3270_STRINGIZE_VALUE_OF(LOCALEDIR)); | |
46 | + bind_textdomain_codeset(PACKAGE_NAME, "UTF-8"); | |
47 | + | |
48 | + return 0; | |
49 | + | |
50 | + } | |
51 | + | |
52 | + int libv3270_unloaded(void) { | |
53 | + | |
54 | + return 0; | |
55 | + | |
56 | + } | ... | ... |
... | ... | @@ -0,0 +1,169 @@ |
1 | +/* | |
2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | |
5 | + * | |
6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | |
7 | + * | |
8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
10 | + * Free Software Foundation. | |
11 | + * | |
12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
15 | + * obter mais detalhes. | |
16 | + * | |
17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
19 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | |
20 | + * | |
21 | + * Este programa está nomeado como - e possui - linhas de código. | |
22 | + * | |
23 | + * Contatos: | |
24 | + * | |
25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
27 | + * | |
28 | + */ | |
29 | + | |
30 | + #include <config.h> | |
31 | + #include <lib3270.h> | |
32 | + #include <lib3270/log.h> | |
33 | + #include <poll.h> | |
34 | + #include <internals.h> | |
35 | + #include <terminal.h> | |
36 | + | |
37 | +/*---[ Structs ]-------------------------------------------------------------------------------------------*/ | |
38 | + | |
39 | + typedef struct _IO_Source | |
40 | + { | |
41 | + GSource gsrc; | |
42 | + GPollFD poll; | |
43 | + gboolean enabled; | |
44 | + int fd; | |
45 | + void (*call)(H3270 *, int, LIB3270_IO_FLAG, void *); | |
46 | + H3270 * session; | |
47 | + void * userdata; | |
48 | + } IO_Source; | |
49 | + | |
50 | +static gboolean IO_prepare(GSource *source, gint *timeout); | |
51 | +static gboolean IO_check(GSource *source); | |
52 | +static gboolean IO_dispatch(GSource *source, GSourceFunc callback, gpointer user_data); | |
53 | +static void IO_finalize(GSource *source); /* Can be NULL */ | |
54 | +static gboolean IO_closure(gpointer data); | |
55 | + | |
56 | +/*---[ Implement ]-----------------------------------------------------------------------------------------*/ | |
57 | + | |
58 | +GSource * IO_source_new(H3270 *session, int fd, LIB3270_IO_FLAG flag, void(*call)(H3270 *, int, LIB3270_IO_FLAG, void *), void *userdata) | |
59 | +{ | |
60 | + static GSourceFuncs IOSources = | |
61 | + { | |
62 | + IO_prepare, | |
63 | + IO_check, | |
64 | + IO_dispatch, | |
65 | + IO_finalize, | |
66 | + IO_closure, | |
67 | + NULL | |
68 | + }; | |
69 | + | |
70 | + IO_Source *src = (IO_Source *) g_source_new(&IOSources,sizeof(IO_Source)); | |
71 | + | |
72 | + src->fd = fd; | |
73 | + src->enabled = TRUE; | |
74 | + src->call = call; | |
75 | + src->userdata = userdata; | |
76 | + src->session = session; | |
77 | + | |
78 | + src->poll.fd = (int) fd; | |
79 | + src->poll.events = G_IO_HUP|G_IO_ERR; | |
80 | + | |
81 | + if(flag & LIB3270_IO_FLAG_READ) | |
82 | + src->poll.events |= G_IO_IN; | |
83 | + | |
84 | + if(flag & LIB3270_IO_FLAG_WRITE) | |
85 | + src->poll.events |= G_IO_OUT; | |
86 | + | |
87 | + IO_source_set_state((GSource *) src, TRUE); | |
88 | + | |
89 | + g_source_attach((GSource *) src,NULL); | |
90 | + g_source_add_poll((GSource *) src, &((IO_Source *)src)->poll); | |
91 | + | |
92 | + return (GSource *) src; | |
93 | +} | |
94 | + | |
95 | +void IO_source_set_state(GSource *source, gboolean enable) | |
96 | +{ | |
97 | + ((IO_Source *)source)->enabled = enable; | |
98 | +} | |
99 | + | |
100 | +gboolean IO_prepare(G_GNUC_UNUSED GSource *source, G_GNUC_UNUSED gint *timeout) | |
101 | +{ | |
102 | + /* | |
103 | + * Called before all the file descriptors are polled. | |
104 | + * If the source can determine that it is ready here | |
105 | + * (without waiting for the results of the poll() call) | |
106 | + * it should return TRUE. | |
107 | + * | |
108 | + * It can also return a timeout_ value which should be the maximum | |
109 | + * timeout (in milliseconds) which should be passed to the poll() call. | |
110 | + * The actual timeout used will be -1 if all sources returned -1, | |
111 | + * or it will be the minimum of all the timeout_ values | |
112 | + * returned which were >= 0. | |
113 | + * | |
114 | + */ | |
115 | + return 0; | |
116 | +} | |
117 | + | |
118 | +gboolean IO_check(GSource *source) | |
119 | +{ | |
120 | + /* | |
121 | + * Called after all the file descriptors are polled. | |
122 | + * The source should return TRUE if it is ready to be dispatched. | |
123 | + * Note that some time may have passed since the previous prepare | |
124 | + * function was called, so the source should be checked again here. | |
125 | + * | |
126 | + */ | |
127 | + if(((IO_Source *) source)->enabled) | |
128 | + { | |
129 | + struct pollfd fds; | |
130 | + | |
131 | + memset(&fds,0,sizeof(fds)); | |
132 | + | |
133 | + fds.fd = ((IO_Source *) source)->poll.fd; | |
134 | + fds.events = ((IO_Source *) source)->poll.events; | |
135 | + | |
136 | + if(poll(&fds,1,0) > 0) | |
137 | + return TRUE; | |
138 | + } | |
139 | + | |
140 | + return FALSE; | |
141 | +} | |
142 | + | |
143 | +gboolean IO_dispatch(GSource *source, G_GNUC_UNUSED GSourceFunc callback, G_GNUC_UNUSED gpointer user_data) | |
144 | +{ | |
145 | + /* | |
146 | + * Called to dispatch the event source, | |
147 | + * after it has returned TRUE in either its prepare or its check function. | |
148 | + * The dispatch function is passed in a callback function and data. | |
149 | + * The callback function may be NULL if the source was never connected | |
150 | + * to a callback using g_source_set_callback(). The dispatch function | |
151 | + * should call the callback function with user_data and whatever additional | |
152 | + * parameters are needed for this type of event source. | |
153 | + */ | |
154 | + IO_Source *obj = (IO_Source *) source; | |
155 | + | |
156 | + obj->call(obj->session,obj->fd,0,obj->userdata); | |
157 | + | |
158 | + return TRUE; | |
159 | +} | |
160 | + | |
161 | +void IO_finalize(G_GNUC_UNUSED GSource *source) | |
162 | +{ | |
163 | + | |
164 | +} | |
165 | + | |
166 | +gboolean IO_closure(G_GNUC_UNUSED gpointer data) | |
167 | +{ | |
168 | + return 0; | |
169 | +} | ... | ... |