Commit 595c171ea8a1e854aef2eedcee2d77847ff3a3df
1 parent
b97d36d3
Exists in
master
and in
1 other branch
Rewriting trace windows as a standard widget (for use in other apps).
Showing
6 changed files
with
257 additions
and
560 deletions
Show diff stats
src/include/v3270/filetransfer.h
... | ... | @@ -132,11 +132,11 @@ |
132 | 132 | LIB3270_EXPORT H3270FT * v3270_ft_activity_begin_transfer(GObject * object, H3270 *hSession, const char **message); |
133 | 133 | |
134 | 134 | // FT Dialog widget |
135 | - #define GTK_TYPE_V3270_FT_DIALOG (V3270FTSettingsDialog_get_type ()) | |
136 | - #define GTK_V3270_FT_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_V3270_FT_DIALOG, V3270FTSettingsDialog)) | |
135 | + #define GTK_TYPE_V3270_FT_DIALOG (V3270FTSettingsDialog_get_type ()) | |
136 | + #define GTK_V3270_FT_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_V3270_FT_DIALOG, V3270FTSettingsDialog)) | |
137 | 137 | #define GTK_v3270_ft_settings_dialog_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_V3270_FT_DIALOG, V3270FTSettingsDialogClass)) |
138 | - #define GTK_IS_V3270_FT_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_V3270_FT_DIALOG)) | |
139 | - #define GTK_IS_v3270_ft_settings_dialog_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_V3270_FT_DIALOG)) | |
138 | + #define GTK_IS_V3270_FT_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_V3270_FT_DIALOG)) | |
139 | + #define GTK_IS_v3270_ft_settings_dialog_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_V3270_FT_DIALOG)) | |
140 | 140 | #define GTK_v3270_ft_settings_dialog_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_V3270_FT_DIALOG, V3270FTSettingsDialogClass)) |
141 | 141 | |
142 | 142 | typedef struct _V3270FTSettingsDialog V3270FTSettingsDialog; | ... | ... |
src/include/v3270/trace.h
... | ... | @@ -32,34 +32,25 @@ |
32 | 32 | #ifndef PW3270_TRACE_H_INCLUDED |
33 | 33 | |
34 | 34 | #include <gtk/gtk.h> |
35 | - #include <v3270.h> | |
36 | - #include <lib3270.h> | |
37 | 35 | |
38 | 36 | #define PW3270_TRACE_H_INCLUDED 1 |
39 | 37 | |
40 | 38 | G_BEGIN_DECLS |
41 | 39 | |
42 | - #define V3270_TYPE_TRACE (v3270_trace_get_type ()) | |
43 | - #define V3270_TRACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), V3270_TYPE_TRACE, v3270_trace)) | |
44 | - #define V3270_TRACE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), V3270_TYPE_TRACE, pw3270_traceClass)) | |
45 | - #define IS_V3270_TRACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), V3270_TYPE_TRACE)) | |
46 | - #define IS_V3270_TRACE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), V3270_TYPE_TRACE)) | |
47 | - #define V3270_TRACE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), V3270_TYPE_TRACE, v3270_traceClass)) | |
40 | + #define GTK_TYPE_V3270_TRACE (V3270Trace_get_type ()) | |
41 | + #define GTK_V3270_TRACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_V3270_TRACE, V3270Trace)) | |
42 | + #define GTK_V3270_TRACE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_V3270_TRACE, V3270TraceClass)) | |
43 | + #define GTK_IS_V3270_TRACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_V3270_TRACE)) | |
44 | + #define GTK_IS_V3270_TRACE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_V3270_TRACE)) | |
45 | + #define GTK_V3270_TRACE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_V3270_TRACE, V3270TraceClass)) | |
48 | 46 | |
49 | - typedef struct _v3270_trace v3270_trace; | |
50 | - typedef struct _v3270_traceClass v3270_traceClass; | |
47 | + typedef struct _V3270Trace V3270Trace; | |
48 | + typedef struct _V3270TraceClass V3270TraceClass; | |
51 | 49 | |
52 | - LIB3270_EXPORT GtkWidget * v3270_trace_new(); | |
53 | - | |
54 | - LIB3270_EXPORT GtkWidget * v3270_trace_new_from_session(H3270 *hSession, const gchar *header); | |
55 | - | |
56 | - LIB3270_EXPORT void v3270_trace_set_session(GtkWidget *widget, H3270 *hSession); | |
57 | - LIB3270_EXPORT GType v3270_trace_get_type(void); | |
50 | + LIB3270_EXPORT GtkWidget * v3270_trace_new(GtkWidget *terminal); | |
51 | + LIB3270_EXPORT void v3270_trace_append_text(GtkWidget *widget, const gchar *text); | |
58 | 52 | LIB3270_EXPORT void v3270_trace_vprintf(GtkWidget *widget, const char *fmt, va_list args); |
59 | 53 | LIB3270_EXPORT void v3270_trace_printf(GtkWidget *widget, const char *fmt, ... ); |
60 | - LIB3270_EXPORT void v3270_trace_append_text(GtkWidget *widget, const gchar *text); | |
61 | - LIB3270_EXPORT gchar * v3270_trace_get_command(GtkWidget *widget); | |
62 | - LIB3270_EXPORT void v3270_trace_set_destroy_on_close(GtkWidget *widget,gboolean on); | |
63 | 54 | |
64 | 55 | G_END_DECLS |
65 | 56 | ... | ... |
src/testprogram/testprogram.c
... | ... | @@ -37,6 +37,7 @@ |
37 | 37 | #include <v3270/filetransfer.h> |
38 | 38 | #include <v3270/ftprogress.h> |
39 | 39 | #include <v3270/colorscheme.h> |
40 | + #include <v3270/trace.h> | |
40 | 41 | #include <lib3270/log.h> |
41 | 42 | #include <stdlib.h> |
42 | 43 | |
... | ... | @@ -149,6 +150,11 @@ static void disconnect_clicked(GtkButton G_GNUC_UNUSED(*button), GtkWidget *term |
149 | 150 | |
150 | 151 | static void ft_clicked(GtkButton G_GNUC_UNUSED(*button), GtkWidget *terminal) |
151 | 152 | { |
153 | + GtkWidget * dialog = v3270_dialog_new(terminal, _("test"), _("test")); | |
154 | + GtkWidget * trace = v3270_trace_new(terminal); | |
155 | + gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),trace,TRUE,TRUE,2); | |
156 | + | |
157 | + /* | |
152 | 158 | // |
153 | 159 | // Test activity |
154 | 160 | // |
... | ... | @@ -158,13 +164,11 @@ static void ft_clicked(GtkButton G_GNUC_UNUSED(*button), GtkWidget *terminal) |
158 | 164 | v3270_ft_activity_set_remote_filename(activity,"remote_file"); |
159 | 165 | v3270_ft_activity_set_options(activity,LIB3270_FT_OPTION_RECEIVE|LIB3270_FT_OPTION_ASCII|LIB3270_FT_OPTION_REMAP); |
160 | 166 | |
161 | - /* | |
162 | 167 | // |
163 | 168 | // Test settings dialog |
164 | 169 | // |
165 | 170 | GtkWidget * dialog = v3270_ft_settings_dialog_new(terminal); |
166 | 171 | v3270_ft_settings_dialog_append_activity(dialog,activity,NULL); |
167 | - */ | |
168 | 172 | |
169 | 173 | // |
170 | 174 | // Test worker widget |
... | ... | @@ -175,6 +179,7 @@ static void ft_clicked(GtkButton G_GNUC_UNUSED(*button), GtkWidget *terminal) |
175 | 179 | v3270_ft_worker_set_session(worker,v3270_get_session(terminal)); |
176 | 180 | v3270_ft_worker_set_activity(worker,activity); |
177 | 181 | v3270_ft_worker_start(worker); |
182 | + */ | |
178 | 183 | |
179 | 184 | gtk_widget_show_all(dialog); |
180 | 185 | gtk_dialog_run(GTK_DIALOG(dialog)); |
... | ... | @@ -205,6 +210,7 @@ static void color_clicked(GtkButton G_GNUC_UNUSED(*button), GtkWidget *terminal) |
205 | 210 | |
206 | 211 | } |
207 | 212 | |
213 | + | |
208 | 214 | static void activate(GtkApplication* app, G_GNUC_UNUSED gpointer user_data) { |
209 | 215 | |
210 | 216 | GtkWidget * window = gtk_application_window_new(app); |
... | ... | @@ -218,6 +224,7 @@ static void activate(GtkApplication* app, G_GNUC_UNUSED gpointer user_data) { |
218 | 224 | // v3270_set_font_family(terminal,"Droid Sans Mono"); |
219 | 225 | g_signal_connect(terminal,"field_clicked",G_CALLBACK(field_clicked),window); |
220 | 226 | |
227 | + /* | |
221 | 228 | GtkWidget *trace = v3270_new_trace_window(terminal,NULL); |
222 | 229 | if(trace) { |
223 | 230 | g_signal_connect(trace, "destroy", G_CALLBACK(trace_window_destroy), v3270_get_session(terminal)); |
... | ... | @@ -225,6 +232,7 @@ static void activate(GtkApplication* app, G_GNUC_UNUSED gpointer user_data) { |
225 | 232 | lib3270_toggle(v3270_get_session(terminal),LIB3270_TOGGLE_DS_TRACE); |
226 | 233 | gtk_widget_show_all(trace); |
227 | 234 | } |
235 | + */ | |
228 | 236 | |
229 | 237 | /* |
230 | 238 | v3270_connect(terminal); | ... | ... |
src/trace/exec.c
... | ... | @@ -42,6 +42,7 @@ |
42 | 42 | #include <lib3270/properties.h> |
43 | 43 | #include <v3270/trace.h> |
44 | 44 | |
45 | + /* | |
45 | 46 | static const gchar * get_word(gchar **ptr) |
46 | 47 | { |
47 | 48 | gchar *rc = g_strstrip(*ptr); |
... | ... | @@ -58,7 +59,9 @@ |
58 | 59 | |
59 | 60 | return rc; |
60 | 61 | } |
62 | + */ | |
61 | 63 | |
64 | + /* | |
62 | 65 | static int set_property(H3270 *hSession, const gchar *name, const gchar * value) |
63 | 66 | { |
64 | 67 | size_t ix; |
... | ... | @@ -103,9 +106,11 @@ |
103 | 106 | return errno = ENOENT; |
104 | 107 | |
105 | 108 | } |
109 | + */ | |
106 | 110 | |
107 | 111 | int v3270_exec_command(GtkWidget *widget, const gchar *text) |
108 | 112 | { |
113 | + /* | |
109 | 114 | H3270 *hSession = v3270_get_session(widget); |
110 | 115 | g_autofree gchar * cmdline = g_strdup(text); |
111 | 116 | |
... | ... | @@ -145,6 +150,7 @@ |
145 | 150 | *(sep++) = 0; |
146 | 151 | set_property(hSession,g_strstrip(cmdline),g_strstrip(sep)); |
147 | 152 | } |
153 | + */ | |
148 | 154 | |
149 | 155 | return errno = ENOENT; |
150 | 156 | } | ... | ... |
src/trace/trace.c
... | ... | @@ -1,535 +0,0 @@ |
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 trace.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 <gtk/gtk.h> | |
31 | - | |
32 | - #define ENABLE_NLS | |
33 | - #define GETTEXT_PACKAGE PACKAGE_NAME | |
34 | - | |
35 | - #include <libintl.h> | |
36 | - #include <glib/gi18n.h> | |
37 | - | |
38 | - #include <lib3270.h> | |
39 | - #include <lib3270/log.h> | |
40 | - #include <lib3270/trace.h> | |
41 | - #include <lib3270/properties.h> | |
42 | - #include <v3270/trace.h> | |
43 | - | |
44 | -#if defined( HAVE_SYSLOG ) | |
45 | - #include <syslog.h> | |
46 | -#endif // HAVE_SYSLOG | |
47 | - | |
48 | -/*--[ Widget definition ]----------------------------------------------------------------------------*/ | |
49 | - | |
50 | - G_BEGIN_DECLS | |
51 | - | |
52 | - struct _v3270_traceClass | |
53 | - { | |
54 | - GtkWindowClass parent_class; | |
55 | - }; | |
56 | - | |
57 | - struct _v3270_trace | |
58 | - { | |
59 | - GtkWindow parent; | |
60 | - GtkTextBuffer * text; | |
61 | - GtkWidget * entry; | |
62 | - GtkWidget * button; | |
63 | - GtkWidget * scroll; | |
64 | - GtkWidget * view; | |
65 | - H3270 * hSession; | |
66 | - gchar **line; | |
67 | - guint log_handler; | |
68 | - gboolean * enabled; | |
69 | - gboolean destroy_on_close; | |
70 | - | |
71 | - /// @brief lib3270's saved trace handler. | |
72 | - struct { | |
73 | - void (*handler)(H3270 *session, void *userdata, const char *fmt, va_list args); | |
74 | - void *userdata; | |
75 | - } trace; | |
76 | - | |
77 | - }; | |
78 | - | |
79 | - const GtkWindowClass * v3270_trace_get_parent_class(void); | |
80 | - | |
81 | - G_END_DECLS | |
82 | - | |
83 | - G_DEFINE_TYPE(v3270_trace, v3270_trace, GTK_TYPE_WINDOW); | |
84 | - | |
85 | - static void append_text(v3270_trace *hwnd, const gchar *text); | |
86 | - | |
87 | -/*--[ Implement ]------------------------------------------------------------------------------------*/ | |
88 | - | |
89 | - const GtkWindowClass * v3270_trace_get_parent_class(void) | |
90 | - { | |
91 | - return GTK_WINDOW_CLASS(v3270_trace_parent_class); | |
92 | - } | |
93 | - | |
94 | - static void activate_default(GtkWindow *window) | |
95 | - { | |
96 | - v3270_trace * hwnd = V3270_TRACE(window); | |
97 | - | |
98 | - if(hwnd->enabled) | |
99 | - { | |
100 | - if(*hwnd->line) | |
101 | - g_free(*hwnd->line); | |
102 | - | |
103 | - *hwnd->line = g_strdup(gtk_entry_get_text(GTK_ENTRY(hwnd->entry))); | |
104 | - | |
105 | - gtk_widget_set_sensitive(hwnd->entry,FALSE); | |
106 | - gtk_widget_set_sensitive(hwnd->button,FALSE); | |
107 | - | |
108 | - *hwnd->enabled = FALSE; | |
109 | - } | |
110 | - | |
111 | - } | |
112 | - | |
113 | -static void destroy(GtkWidget *widget) | |
114 | -{ | |
115 | - v3270_trace * hwnd = V3270_TRACE(widget); | |
116 | - | |
117 | - if(hwnd->hSession) | |
118 | - { | |
119 | - lib3270_set_trace_handler(hwnd->hSession,hwnd->trace.handler,hwnd->trace.userdata); | |
120 | - } | |
121 | - | |
122 | - if(hwnd->log_handler) | |
123 | - { | |
124 | - g_log_remove_handler(NULL,hwnd->log_handler); | |
125 | - hwnd->log_handler = 0; | |
126 | - } | |
127 | - | |
128 | - if(hwnd->line) | |
129 | - *hwnd->line = NULL; | |
130 | - | |
131 | - if(hwnd->enabled) | |
132 | - *hwnd->enabled = FALSE; | |
133 | - | |
134 | - } | |
135 | - | |
136 | - static gboolean delete_event(GtkWidget *widget, G_GNUC_UNUSED GdkEventAny *event) | |
137 | - { | |
138 | - v3270_trace * hwnd = V3270_TRACE(widget); | |
139 | - | |
140 | - if(hwnd->line) | |
141 | - *hwnd->line = NULL; | |
142 | - | |
143 | - if(hwnd->enabled) | |
144 | - *hwnd->enabled = FALSE; | |
145 | - | |
146 | - if(hwnd->destroy_on_close) | |
147 | - return FALSE; | |
148 | - | |
149 | - gtk_widget_hide(widget); | |
150 | - return TRUE; | |
151 | - } | |
152 | - | |
153 | - static void v3270_trace_class_init(v3270_traceClass *klass) | |
154 | - { | |
155 | - GtkWindowClass * window_class = GTK_WINDOW_CLASS(klass); | |
156 | - GtkWidgetClass * widget_class = GTK_WIDGET_CLASS(klass); | |
157 | - | |
158 | - window_class->activate_default = activate_default; | |
159 | - widget_class->delete_event = delete_event; | |
160 | - | |
161 | - widget_class->destroy = destroy; | |
162 | - | |
163 | - } | |
164 | - | |
165 | - static void activate(G_GNUC_UNUSED GtkButton *button, v3270_trace *window) | |
166 | - { | |
167 | - GtkWidget * terminal = GTK_WIDGET(lib3270_get_user_data(window->hSession)); | |
168 | - | |
169 | - int rc = v3270_exec_command(terminal,gtk_entry_get_text(GTK_ENTRY(window->entry))); | |
170 | - | |
171 | - v3270_trace_printf(GTK_WIDGET(window),"exec(\"%s\") exits with rc=%d (%s)\n",gtk_entry_get_text(GTK_ENTRY(window->entry)),rc,strerror(rc)); | |
172 | - gtk_entry_set_text(GTK_ENTRY(window->entry),""); | |
173 | - } | |
174 | - | |
175 | - static void menu_save(G_GNUC_UNUSED GtkWidget *button, v3270_trace *window) | |
176 | - { | |
177 | - GtkWindow * toplevel = GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(window))); | |
178 | - GtkWidget * dialog; | |
179 | - | |
180 | - dialog = gtk_file_chooser_dialog_new( _( "Save trace file" ), | |
181 | - toplevel, | |
182 | - GTK_FILE_CHOOSER_ACTION_SAVE, | |
183 | - _( "Cancel" ), GTK_RESPONSE_CANCEL, | |
184 | - _( "Save" ), GTK_RESPONSE_ACCEPT, | |
185 | - NULL ); | |
186 | - | |
187 | - gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog), TRUE); | |
188 | - | |
189 | - gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog),g_get_user_special_dir(G_USER_DIRECTORY_DOCUMENTS)); | |
190 | - | |
191 | - if(gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) | |
192 | - { | |
193 | - gchar *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); | |
194 | - if(filename) | |
195 | - { | |
196 | - GError * error = NULL; | |
197 | - gchar * text; | |
198 | - GtkTextIter start; | |
199 | - GtkTextIter end; | |
200 | - | |
201 | - gtk_text_buffer_get_start_iter(window->text,&start); | |
202 | - gtk_text_buffer_get_end_iter(window->text,&end); | |
203 | - text = gtk_text_buffer_get_text(window->text,&start,&end,FALSE); | |
204 | - | |
205 | - g_file_set_contents(filename,text,-1,&error); | |
206 | - | |
207 | - g_free(text); | |
208 | - | |
209 | - if(error) | |
210 | - { | |
211 | - GtkWidget *popup = gtk_message_dialog_new_with_markup(GTK_WINDOW(dialog),GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,GTK_MESSAGE_ERROR,GTK_BUTTONS_CLOSE,_( "Can't save %s" ),filename); | |
212 | - | |
213 | - gtk_window_set_title(GTK_WINDOW(popup),_("Can't save file")); | |
214 | - | |
215 | - gtk_message_dialog_format_secondary_markup(GTK_MESSAGE_DIALOG(popup),"%s",error->message); | |
216 | - g_error_free(error); | |
217 | - | |
218 | - gtk_dialog_run(GTK_DIALOG(popup)); | |
219 | - gtk_widget_destroy(popup); | |
220 | - | |
221 | - } | |
222 | - | |
223 | - g_free(filename); | |
224 | - } | |
225 | - } | |
226 | - | |
227 | - gtk_widget_destroy(dialog); | |
228 | - | |
229 | - } | |
230 | - | |
231 | - static void menu_close(G_GNUC_UNUSED GtkWidget *button, GtkWidget *window) | |
232 | - { | |
233 | - gtk_widget_destroy(window); | |
234 | - } | |
235 | - | |
236 | - struct submenu | |
237 | - { | |
238 | - const gchar * label; | |
239 | - GCallback action; | |
240 | - }; | |
241 | - | |
242 | - static void build_menu(GtkWidget *menubar, v3270_trace *window, const gchar *label, const struct submenu *item, size_t sz) | |
243 | - { | |
244 | - size_t f; | |
245 | - GtkWidget * menu = gtk_menu_new(); | |
246 | - GtkWidget * topitem = gtk_menu_item_new_with_mnemonic(label); | |
247 | - | |
248 | - gtk_menu_item_set_submenu(GTK_MENU_ITEM(topitem), menu); | |
249 | - | |
250 | - for(f=0;f<sz;f++) | |
251 | - { | |
252 | - GtkWidget *widget = gtk_menu_item_new_with_mnemonic(gettext(item[f].label)); | |
253 | - gtk_menu_shell_append(GTK_MENU_SHELL(menu),widget); | |
254 | - g_signal_connect(G_OBJECT(widget), "activate",item[f].action,window); | |
255 | - } | |
256 | - | |
257 | - gtk_menu_shell_append(GTK_MENU_SHELL(menubar), topitem); | |
258 | - } | |
259 | - | |
260 | - static void glog(const gchar *log_domain,GLogLevelFlags log_level,const gchar *message,GtkWidget *window) | |
261 | - { | |
262 | - #ifndef LOG_INFO | |
263 | - #define LOG_INFO 0 | |
264 | - #endif // LOG_INFO | |
265 | - | |
266 | - #ifndef LOG_ERR | |
267 | - #define LOG_ERR 0 | |
268 | - #endif // LOG_ERR | |
269 | - | |
270 | - #ifndef LOG_DEBUG | |
271 | - #define LOG_DEBUG 0 | |
272 | - #endif // LOG_DEBUG | |
273 | - | |
274 | - static const struct _logtype | |
275 | - { | |
276 | - GLogLevelFlags log_level; | |
277 | - int priority; | |
278 | - const gchar * msg; | |
279 | - } logtype[] = | |
280 | - { | |
281 | - { G_LOG_FLAG_RECURSION, LOG_INFO, "recursion" }, | |
282 | - { G_LOG_FLAG_FATAL, LOG_ERR, "fatal error" }, | |
283 | - | |
284 | - /* GLib log levels */ | |
285 | - { G_LOG_LEVEL_ERROR, LOG_ERR, "error" }, | |
286 | - { G_LOG_LEVEL_CRITICAL, LOG_ERR, "critical error" }, | |
287 | - { G_LOG_LEVEL_WARNING, LOG_ERR, "warning" }, | |
288 | - { G_LOG_LEVEL_MESSAGE, LOG_ERR, "message" }, | |
289 | - { G_LOG_LEVEL_INFO, LOG_INFO, "info" }, | |
290 | - { G_LOG_LEVEL_DEBUG, LOG_DEBUG, "debug" }, | |
291 | - }; | |
292 | - | |
293 | - size_t f; | |
294 | - | |
295 | - for(f=0;f<G_N_ELEMENTS(logtype);f++) | |
296 | - { | |
297 | - if(logtype[f].log_level == log_level) | |
298 | - { | |
299 | - gchar *ptr; | |
300 | - gchar *text = g_strdup_printf("%s: %s %s",logtype[f].msg,log_domain ? log_domain : "",message); | |
301 | - for(ptr = text;*ptr;ptr++) | |
302 | - { | |
303 | - if(*ptr < ' ') | |
304 | - *ptr = ' '; | |
305 | - } | |
306 | - | |
307 | - v3270_trace_printf(window,"%s\n",text); | |
308 | - | |
309 | -#ifdef HAVE_SYSLOG | |
310 | - syslog(logtype[f].priority,"%s",text); | |
311 | -#endif // HAVE_SYSLOG | |
312 | - g_free(text); | |
313 | - return; | |
314 | - } | |
315 | - } | |
316 | - | |
317 | - v3270_trace_printf(window,"%s %s\n",log_domain ? log_domain : "", message); | |
318 | - | |
319 | -#ifdef HAVE_SYSLOG | |
320 | - syslog(LOG_INFO,"%s %s",log_domain ? log_domain : "", message); | |
321 | -#endif // HAVE_SYSLOG | |
322 | - | |
323 | - } | |
324 | - | |
325 | - static void v3270_trace_init(v3270_trace *window) | |
326 | -{ | |
327 | - GtkWidget * widget; | |
328 | - GtkWidget * vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL,0); | |
329 | - | |
330 | - // Top menu | |
331 | - { | |
332 | - | |
333 | - // https://specifications.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html | |
334 | - static const struct submenu filemenu[] = | |
335 | - { | |
336 | - { N_("_Save trace to file"), G_CALLBACK(menu_save) }, | |
337 | - { N_("_Close window"), G_CALLBACK(menu_close) }, | |
338 | - | |
339 | - }; | |
340 | - | |
341 | - widget = gtk_menu_bar_new(); | |
342 | - | |
343 | - build_menu(widget, window, _( "_File" ), filemenu, G_N_ELEMENTS(filemenu)); | |
344 | - | |
345 | - gtk_box_pack_start(GTK_BOX(vbox),widget,FALSE,TRUE,0); | |
346 | - } | |
347 | - | |
348 | - window->hSession = NULL; | |
349 | - | |
350 | - // Trace container | |
351 | - window->scroll = gtk_scrolled_window_new(NULL,NULL); | |
352 | - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(window->scroll),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC); | |
353 | - | |
354 | - window->view = gtk_text_view_new(); | |
355 | - gtk_text_view_set_monospace(GTK_TEXT_VIEW(window->view),TRUE); | |
356 | - | |
357 | - window->text = gtk_text_view_get_buffer(GTK_TEXT_VIEW(window->view)); | |
358 | - gtk_text_view_set_editable(GTK_TEXT_VIEW(window->view), TRUE); | |
359 | - | |
360 | - gtk_container_add(GTK_CONTAINER(window->scroll),window->view); | |
361 | - gtk_box_pack_start(GTK_BOX(vbox),window->scroll,TRUE,TRUE,0); | |
362 | - | |
363 | - // Edit box | |
364 | - widget = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0); | |
365 | - gtk_box_pack_start(GTK_BOX(widget),gtk_label_new( _( "Command:" )),FALSE,TRUE,4); | |
366 | - window->entry = gtk_entry_new(); | |
367 | - gtk_box_pack_start(GTK_BOX(widget),window->entry,TRUE,TRUE,4); | |
368 | - //gtk_widget_set_sensitive(window->entry,FALSE); | |
369 | - g_signal_connect(G_OBJECT(window->entry),"activate",G_CALLBACK(activate),window); | |
370 | - | |
371 | - window->button = gtk_button_new_from_icon_name("system-run",GTK_ICON_SIZE_BUTTON); | |
372 | - gtk_box_pack_end(GTK_BOX(widget),window->button,FALSE,FALSE,4); | |
373 | - gtk_widget_set_focus_on_click(GTK_WIDGET(window->button),FALSE); | |
374 | - g_signal_connect(G_OBJECT(window->button),"clicked",G_CALLBACK(activate),window); | |
375 | - | |
376 | - gtk_box_pack_start(GTK_BOX(vbox),widget,FALSE,TRUE,0); | |
377 | - | |
378 | - gtk_widget_show_all(vbox); | |
379 | - | |
380 | - gtk_container_add(GTK_CONTAINER(window),vbox); | |
381 | - | |
382 | - window->log_handler = g_log_set_handler(NULL,G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION,(GLogFunc) glog,window); | |
383 | - } | |
384 | - | |
385 | - GtkWidget * v3270_trace_new() | |
386 | - { | |
387 | - return g_object_new(V3270_TYPE_TRACE, NULL); | |
388 | - } | |
389 | - | |
390 | - LIB3270_EXPORT GtkWidget * v3270_new_trace_window(GtkWidget *widget, const gchar *header) | |
391 | - { | |
392 | - g_return_val_if_fail(GTK_IS_V3270(widget),NULL); | |
393 | - return v3270_trace_new_from_session(v3270_get_session(widget), header); | |
394 | - } | |
395 | - | |
396 | - static void trace_handler(H3270 *hSession, void *userdata, const char *fmt, va_list args) | |
397 | - { | |
398 | - gchar *ptr = g_strdup_vprintf(fmt,args); | |
399 | - gchar * utftext = g_convert_with_fallback(ptr,-1,"UTF-8",lib3270_get_display_charset(hSession),"?",NULL,NULL,NULL); | |
400 | - v3270_trace_printf(GTK_WIDGET(userdata),"%s",utftext); | |
401 | - g_free(utftext); | |
402 | - g_free(ptr); | |
403 | - } | |
404 | - | |
405 | - void v3270_trace_set_session(GtkWidget *widget, H3270 *hSession) { | |
406 | - | |
407 | - v3270_trace * trace = V3270_TRACE(widget); | |
408 | - | |
409 | - if(trace->hSession) { | |
410 | - lib3270_set_trace_handler(trace->hSession,trace->trace.handler,trace->trace.userdata); | |
411 | - } | |
412 | - | |
413 | - trace->hSession = hSession; | |
414 | - | |
415 | - if(hSession) { | |
416 | - lib3270_get_trace_handler(hSession,&trace->trace.handler,&trace->trace.userdata); | |
417 | - lib3270_set_trace_handler(hSession,trace_handler,(void *) widget); | |
418 | - } | |
419 | - | |
420 | - } | |
421 | - | |
422 | - LIB3270_EXPORT GtkWidget * v3270_trace_new_from_session(H3270 *hSession, const gchar *header) { | |
423 | - | |
424 | - GtkWidget * widget = g_object_new(V3270_TYPE_TRACE, NULL); | |
425 | - void * terminal = lib3270_get_user_data(hSession); | |
426 | - | |
427 | - V3270_TRACE(widget)->hSession = NULL; | |
428 | - | |
429 | - gtk_window_set_default_size(GTK_WINDOW(widget),590,430); | |
430 | - | |
431 | - if(terminal && GTK_IS_V3270(terminal)) | |
432 | - { | |
433 | - gtk_window_set_attached_to(GTK_WINDOW(widget),GTK_WIDGET(terminal)); | |
434 | - } | |
435 | - | |
436 | - v3270_trace_set_session(widget, hSession); | |
437 | - | |
438 | - if(header) | |
439 | - append_text(V3270_TRACE(widget), header); | |
440 | - | |
441 | - return widget; | |
442 | - } | |
443 | - | |
444 | - struct bg_print_data | |
445 | - { | |
446 | - GtkWidget * widget; | |
447 | - gchar * msg; | |
448 | - }; | |
449 | - | |
450 | - static void append_text(v3270_trace *hwnd, const gchar *text) | |
451 | - { | |
452 | - GtkTextIter itr; | |
453 | - gtk_text_buffer_get_end_iter(hwnd->text,&itr); | |
454 | - | |
455 | - if(g_utf8_validate(text,strlen(text),NULL)) | |
456 | - { | |
457 | - gtk_text_buffer_insert(hwnd->text,&itr,text,strlen(text)); | |
458 | - } | |
459 | - else | |
460 | - { | |
461 | - gtk_text_buffer_insert(hwnd->text,&itr,"** Invalid UTF8 String **",-1); | |
462 | - } | |
463 | - | |
464 | - // gtk_text_buffer_get_end_iter(hwnd->text,&itr); | |
465 | - // gtk_text_view_scroll_to_iter (GTK_TEXT_VIEW(hwnd->view), &itr, 0.0, FALSE, 0.0, 0.0); | |
466 | - | |
467 | - //GtkAdjustment *vadj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(hwnd->scroll)); | |
468 | - //gtk_adjustment_set_value(vadj,gtk_adjustment_get_upper(vadj)); | |
469 | - //gtk_scrolled_window_set_vadjustment(GTK_SCROLLED_WINDOW(hwnd->scroll), vadj); | |
470 | - } | |
471 | - | |
472 | - static gboolean bg_trace_append_text(struct bg_print_data *data) | |
473 | - { | |
474 | - append_text(V3270_TRACE(data->widget),data->msg); | |
475 | - g_free(data->msg); | |
476 | - return FALSE; | |
477 | - } | |
478 | - | |
479 | - void v3270_trace_append_text(GtkWidget *widget, const gchar *text) | |
480 | - { | |
481 | - struct bg_print_data * data = g_new0(struct bg_print_data,1); | |
482 | - | |
483 | - data->widget = widget; | |
484 | - data->msg = g_strdup(text); | |
485 | - | |
486 | - g_idle_add_full(G_PRIORITY_DEFAULT_IDLE,(GSourceFunc) bg_trace_append_text, data, g_free); | |
487 | - } | |
488 | - | |
489 | - void v3270_trace_vprintf(GtkWidget *widget, const char *fmt, va_list args) | |
490 | - { | |
491 | - struct bg_print_data * data = g_new0(struct bg_print_data,1); | |
492 | - | |
493 | - data->widget = widget; | |
494 | - data->msg = g_strdup_vprintf(fmt,args); | |
495 | - | |
496 | - g_idle_add_full(G_PRIORITY_DEFAULT_IDLE,(GSourceFunc) bg_trace_append_text, data, g_free); | |
497 | - } | |
498 | - | |
499 | - void v3270_trace_printf(GtkWidget *widget, const char *fmt, ... ) | |
500 | - { | |
501 | - va_list arg_ptr; | |
502 | - va_start(arg_ptr, fmt); | |
503 | - v3270_trace_vprintf(widget,fmt,arg_ptr); | |
504 | - va_end(arg_ptr); | |
505 | - } | |
506 | - | |
507 | - LIB3270_EXPORT gchar * v3270_trace_get_command(GtkWidget *widget) | |
508 | - { | |
509 | - v3270_trace * hwnd = V3270_TRACE(widget); | |
510 | - gchar * line = NULL; | |
511 | - gboolean enabled = TRUE; | |
512 | - | |
513 | - hwnd->line = &line; | |
514 | - hwnd->enabled = &enabled; | |
515 | - | |
516 | - gtk_window_present(GTK_WINDOW(widget)); | |
517 | - gtk_widget_set_sensitive(hwnd->entry,TRUE); | |
518 | - gtk_widget_set_sensitive(hwnd->button,TRUE); | |
519 | - gtk_widget_grab_focus(hwnd->entry); | |
520 | - | |
521 | - while(enabled) | |
522 | - { | |
523 | - gtk_main_iteration(); | |
524 | - } | |
525 | - | |
526 | - hwnd->line = NULL; | |
527 | - hwnd->enabled = NULL; | |
528 | - | |
529 | - return line; | |
530 | - } | |
531 | - | |
532 | - LIB3270_EXPORT void v3270_trace_set_destroy_on_close(GtkWidget *widget,gboolean on) | |
533 | - { | |
534 | - V3270_TRACE(widget)->destroy_on_close = on; | |
535 | - } |
... | ... | @@ -0,0 +1,227 @@ |
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 trace.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 | +/** | |
31 | + * SECTION:V3270Trace | |
32 | + * @Short_description: A trace monitor widget. | |
33 | + * @Title: V3270Trace | |
34 | + * | |
35 | + * The #V3270Trace shows a text area with the lib3270 trace output. | |
36 | + * | |
37 | + */ | |
38 | + | |
39 | + #include <gtk/gtk.h> | |
40 | + | |
41 | + #define ENABLE_NLS | |
42 | + #define GETTEXT_PACKAGE PACKAGE_NAME | |
43 | + | |
44 | + #include <libintl.h> | |
45 | + #include <glib/gi18n.h> | |
46 | + | |
47 | + #include <v3270.h> | |
48 | + #include <lib3270.h> | |
49 | + #include <lib3270/log.h> | |
50 | + #include <lib3270/trace.h> | |
51 | + #include <lib3270/properties.h> | |
52 | + #include <v3270/trace.h> | |
53 | + | |
54 | +#if defined( HAVE_SYSLOG ) | |
55 | + #include <syslog.h> | |
56 | +#endif // HAVE_SYSLOG | |
57 | + | |
58 | +/*--[ Widget definition ]----------------------------------------------------------------------------*/ | |
59 | + | |
60 | + G_BEGIN_DECLS | |
61 | + | |
62 | + struct _V3270TraceClass | |
63 | + { | |
64 | + GtkGridClass parent_class; | |
65 | + | |
66 | + }; | |
67 | + | |
68 | + struct _V3270Trace | |
69 | + { | |
70 | + GtkGrid parent; | |
71 | + H3270 * hSession; /// @brief TN3270 Session. | |
72 | + | |
73 | + GtkTextBuffer * text; /// @brief Trace window contents. | |
74 | + GtkWidget * entry; /// @brief Command line entry. | |
75 | + GtkWidget * run; /// @brief "exec" button. | |
76 | + | |
77 | + /// @brief lib3270's saved trace handler. | |
78 | + struct { | |
79 | + void (*handler)(H3270 *session, void *userdata, const char *fmt, va_list args); | |
80 | + void *userdata; | |
81 | + } trace; | |
82 | + | |
83 | + }; | |
84 | + | |
85 | + G_END_DECLS | |
86 | + | |
87 | + G_DEFINE_TYPE(V3270Trace, V3270Trace, GTK_TYPE_GRID); | |
88 | + | |
89 | +/*--[ Implement ]------------------------------------------------------------------------------------*/ | |
90 | + | |
91 | + static void trace_handler(H3270 *hSession, void *userdata, const char *fmt, va_list args) | |
92 | + { | |
93 | + g_autofree gchar *ptr = g_strdup_vprintf(fmt,args); | |
94 | + g_autofree gchar * utftext = g_convert_with_fallback(ptr,-1,"UTF-8",lib3270_get_display_charset(hSession),"?",NULL,NULL,NULL); | |
95 | + | |
96 | + v3270_trace_append_text(GTK_WIDGET(userdata),utftext); | |
97 | + | |
98 | + } | |
99 | + | |
100 | + static void set_session(V3270Trace *widget, H3270 *hSession) | |
101 | + { | |
102 | + if(widget->hSession) { | |
103 | + lib3270_set_trace_handler(widget->hSession,widget->trace.handler,widget->trace.userdata); | |
104 | + } | |
105 | + | |
106 | + widget->hSession = hSession; | |
107 | + | |
108 | + if(hSession) { | |
109 | + lib3270_get_trace_handler(hSession,&widget->trace.handler,&widget->trace.userdata); | |
110 | + lib3270_set_trace_handler(hSession,trace_handler,(void *) widget); | |
111 | + } | |
112 | + | |
113 | + } | |
114 | + | |
115 | + static void finalize(GObject *object) | |
116 | + { | |
117 | + debug("V3270Trace::%s",__FUNCTION__); | |
118 | + | |
119 | + set_session(GTK_V3270_TRACE(object),NULL); | |
120 | + | |
121 | + G_OBJECT_CLASS(V3270Trace_parent_class)->finalize(object); | |
122 | + } | |
123 | + | |
124 | + static void V3270Trace_class_init(G_GNUC_UNUSED V3270TraceClass *klass) | |
125 | + { | |
126 | + G_OBJECT_CLASS(klass)->finalize = finalize; | |
127 | + } | |
128 | + | |
129 | + static void V3270Trace_init(V3270Trace *widget) | |
130 | + { | |
131 | + | |
132 | + // Create text view | |
133 | + { | |
134 | + GtkWidget *scrolled = gtk_scrolled_window_new(NULL,NULL); | |
135 | + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC); | |
136 | + gtk_widget_set_vexpand(scrolled,TRUE); | |
137 | + gtk_widget_set_hexpand(scrolled,TRUE); | |
138 | + gtk_grid_attach(GTK_GRID(widget),scrolled,0,0,10,1); | |
139 | + | |
140 | + GtkWidget *view = gtk_text_view_new(); | |
141 | + gtk_text_view_set_monospace(GTK_TEXT_VIEW(view),TRUE); | |
142 | + | |
143 | + widget->text = gtk_text_view_get_buffer(GTK_TEXT_VIEW(view)); | |
144 | + gtk_text_view_set_editable(GTK_TEXT_VIEW(view), TRUE); | |
145 | + | |
146 | + gtk_container_add(GTK_CONTAINER(scrolled),view); | |
147 | + | |
148 | + } | |
149 | + | |
150 | + // Create command line | |
151 | + { | |
152 | + widget->entry = gtk_entry_new(); | |
153 | + gtk_grid_attach(GTK_GRID(widget),widget->entry,0,1,8,1); | |
154 | + gtk_widget_set_sensitive(widget->entry,FALSE); | |
155 | + | |
156 | + widget->run = gtk_button_new_from_icon_name("system-run",GTK_ICON_SIZE_BUTTON); | |
157 | + gtk_grid_attach(GTK_GRID(widget),widget->run,9,1,1,1); | |
158 | + gtk_widget_set_sensitive(widget->run,FALSE); | |
159 | + | |
160 | + } | |
161 | + | |
162 | + | |
163 | + } | |
164 | + | |
165 | + LIB3270_EXPORT GtkWidget * v3270_trace_new(GtkWidget *terminal) | |
166 | + { | |
167 | + g_return_val_if_fail(GTK_IS_V3270(terminal),NULL); | |
168 | + | |
169 | + V3270Trace * widget = GTK_V3270_TRACE(g_object_new(GTK_TYPE_V3270_TRACE, NULL)); | |
170 | + | |
171 | + set_session(widget, v3270_get_session(terminal)); | |
172 | + | |
173 | + return GTK_WIDGET(widget); | |
174 | + } | |
175 | + | |
176 | + struct _append_text | |
177 | + { | |
178 | + V3270Trace *widget; | |
179 | + gchar text[1]; | |
180 | + }; | |
181 | + | |
182 | + static void bg_append_text(struct _append_text *cfg) | |
183 | + { | |
184 | + GtkTextIter itr; | |
185 | + gtk_text_buffer_get_end_iter(cfg->widget->text,&itr); | |
186 | + | |
187 | + if(g_utf8_validate(cfg->text,strlen(cfg->text),NULL)) | |
188 | + { | |
189 | + gtk_text_buffer_insert(cfg->widget->text,&itr,cfg->text,strlen(cfg->text)); | |
190 | + } | |
191 | + else | |
192 | + { | |
193 | + gtk_text_buffer_insert(cfg->widget->text,&itr,"** Invalid UTF8 String **",-1); | |
194 | + } | |
195 | + | |
196 | + // gtk_text_buffer_get_end_iter(hwnd->text,&itr); | |
197 | + // gtk_text_view_scroll_to_iter (GTK_TEXT_VIEW(hwnd->view), &itr, 0.0, FALSE, 0.0, 0.0); | |
198 | + | |
199 | + //GtkAdjustment *vadj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(hwnd->scroll)); | |
200 | + //gtk_adjustment_set_value(vadj,gtk_adjustment_get_upper(vadj)); | |
201 | + //gtk_scrolled_window_set_vadjustment(GTK_SCROLLED_WINDOW(hwnd->scroll), vadj); | |
202 | + } | |
203 | + | |
204 | + LIB3270_EXPORT void v3270_trace_append_text(GtkWidget *widget, const gchar *text) | |
205 | + { | |
206 | + g_return_if_fail(GTK_IS_V3270_TRACE(widget)); | |
207 | + | |
208 | + // Enqueue update. | |
209 | + struct _append_text * cfg = g_malloc0(sizeof(struct _append_text)+strlen(text)+1); | |
210 | + gdk_threads_add_idle_full(G_PRIORITY_LOW,(GSourceFunc) bg_append_text,cfg,g_free); | |
211 | + | |
212 | + } | |
213 | + | |
214 | + LIB3270_EXPORT void v3270_trace_vprintf(GtkWidget *widget, const char *fmt, va_list args) | |
215 | + { | |
216 | + g_autofree * text = g_strdup_vprintf(fmt,args); | |
217 | + v3270_trace_append_text(widget,text); | |
218 | + } | |
219 | + | |
220 | + LIB3270_EXPORT void v3270_trace_printf(GtkWidget *widget, const char *fmt, ... ) | |
221 | + { | |
222 | + va_list arg_ptr; | |
223 | + va_start(arg_ptr, fmt); | |
224 | + v3270_trace_vprintf(widget,fmt,arg_ptr); | |
225 | + va_end(arg_ptr); | |
226 | + } | |
227 | + | ... | ... |