Commit 7c6b733e300dd13089092c3c642a5297890e2367
1 parent
66ae11a5
Exists in
master
and in
1 other branch
Implementing signal 'open-url'.
Showing
5 changed files
with
66 additions
and
64 deletions
Show diff stats
src/dialogs/settings/popup.c
@@ -32,7 +32,7 @@ | @@ -32,7 +32,7 @@ | ||
32 | g_object_ref_sink(settings); | 32 | g_object_ref_sink(settings); |
33 | } | 33 | } |
34 | g_object_unref(settings); | 34 | g_object_unref(settings); |
35 | - return; | 35 | + return NULL; |
36 | } | 36 | } |
37 | 37 | ||
38 | GtkWidget * dialog = v3270_settings_dialog_new(); | 38 | GtkWidget * dialog = v3270_settings_dialog_new(); |
src/include/internals.h
@@ -121,6 +121,7 @@ | @@ -121,6 +121,7 @@ | ||
121 | // Misc signals | 121 | // Misc signals |
122 | // | 122 | // |
123 | V3270_SIGNAL_FIRE_ACTION, ///< @brief Fire action by name. | 123 | V3270_SIGNAL_FIRE_ACTION, ///< @brief Fire action by name. |
124 | + V3270_SIGNAL_OPEN_URL, ///< @brief An URL was selected. | ||
124 | 125 | ||
125 | V3270_SIGNAL_LAST | 126 | V3270_SIGNAL_LAST |
126 | }; | 127 | }; |
src/terminal/actions/table.c
@@ -355,7 +355,7 @@ | @@ -355,7 +355,7 @@ | ||
355 | return 0; | 355 | return 0; |
356 | } | 356 | } |
357 | 357 | ||
358 | - static int fire_accelerators_dialog(GtkWidget *widget, const struct _v3270_action * action) { | 358 | + static int fire_accelerators_dialog(GtkWidget *widget, const struct _v3270_action G_GNUC_UNUSED(* action)) { |
359 | 359 | ||
360 | GtkWidget * dialog = | 360 | GtkWidget * dialog = |
361 | v3270_settings_popup_dialog( | 361 | v3270_settings_popup_dialog( |
@@ -370,7 +370,7 @@ | @@ -370,7 +370,7 @@ | ||
370 | return 0; | 370 | return 0; |
371 | } | 371 | } |
372 | 372 | ||
373 | - static int fire_host_dialog(GtkWidget *widget, const struct _v3270_action * action) { | 373 | + static int fire_host_dialog(GtkWidget *widget, const struct _v3270_action G_GNUC_UNUSED(* action)) { |
374 | 374 | ||
375 | gtk_widget_show_all( | 375 | gtk_widget_show_all( |
376 | v3270_settings_popup_dialog( | 376 | v3270_settings_popup_dialog( |
src/terminal/callbacks.c
1 | +/* SPDX-License-Identifier: LGPL-3.0-or-later */ | ||
2 | + | ||
1 | /* | 3 | /* |
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. | 4 | + * Copyright (C) 2008 Banco do Brasil S.A. |
22 | * | 5 | * |
23 | - * Contatos: | 6 | + * This program is free software: you can redistribute it and/or modify |
7 | + * it under the terms of the GNU Lesser General Public License as published | ||
8 | + * by the Free Software Foundation, either version 3 of the License, or | ||
9 | + * (at your option) any later version. | ||
24 | * | 10 | * |
25 | - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | ||
26 | - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | 11 | + * This program is distributed in the hope that it will be useful, |
12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | + * GNU General Public License for more details. | ||
27 | * | 15 | * |
16 | + * You should have received a copy of the GNU Lesser General Public License | ||
17 | + * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
28 | */ | 18 | */ |
29 | 19 | ||
30 | #include <config.h> | 20 | #include <config.h> |
@@ -287,21 +277,6 @@ static void update_selection(H3270 *session, G_GNUC_UNUSED int start, G_GNUC_UNU | @@ -287,21 +277,6 @@ static void update_selection(H3270 *session, G_GNUC_UNUSED int start, G_GNUC_UNU | ||
287 | 277 | ||
288 | } | 278 | } |
289 | 279 | ||
290 | -/* | ||
291 | -static void message(H3270 *session, LIB3270_NOTIFY type , const char *title, const char *message, const char *text) | ||
292 | -{ | ||
293 | - LIB3270_POPUP popup = { | ||
294 | - .type = type, | ||
295 | - .title = title, | ||
296 | - .summary = message, | ||
297 | - .body = text | ||
298 | - }; | ||
299 | - | ||
300 | - v3270_popup_dialog_show(GTK_WIDGET(lib3270_get_user_data(session)),&popup,0); | ||
301 | - | ||
302 | -} | ||
303 | -*/ | ||
304 | - | ||
305 | static int print(H3270 *session, LIB3270_CONTENT_OPTION mode) | 280 | static int print(H3270 *session, LIB3270_CONTENT_OPTION mode) |
306 | { | 281 | { |
307 | return v3270_print_dialog(GTK_WIDGET(lib3270_get_user_data(session)), mode, NULL); | 282 | return v3270_print_dialog(GTK_WIDGET(lib3270_get_user_data(session)), mode, NULL); |
@@ -337,27 +312,6 @@ static int load(H3270 *session, const char *filename) | @@ -337,27 +312,6 @@ static int load(H3270 *session, const char *filename) | ||
337 | return 0; | 312 | return 0; |
338 | } | 313 | } |
339 | 314 | ||
340 | -/* | ||
341 | -static void popup_handler(H3270 *session, LIB3270_NOTIFY type, const char *title, const char *msg, const char *fmt, va_list args) | ||
342 | -{ | ||
343 | - LIB3270_POPUP popup = { | ||
344 | - .type = type, | ||
345 | - .title = title, | ||
346 | - .summary = msg | ||
347 | - }; | ||
348 | - | ||
349 | - g_autofree gchar * body = NULL; | ||
350 | - | ||
351 | - if(fmt) { | ||
352 | - body = g_strdup_vprintf(fmt,args); | ||
353 | - popup.body = body; | ||
354 | - } | ||
355 | - | ||
356 | - v3270_popup_dialog_show(GTK_WIDGET(lib3270_get_user_data(session)),&popup,0); | ||
357 | - | ||
358 | - } | ||
359 | - */ | ||
360 | - | ||
361 | static gboolean bg_update_ssl(H3270 *session) | 315 | static gboolean bg_update_ssl(H3270 *session) |
362 | { | 316 | { |
363 | v3270 *terminal = GTK_V3270(lib3270_get_user_data(session)); | 317 | v3270 *terminal = GTK_V3270(lib3270_get_user_data(session)); |
@@ -382,8 +336,6 @@ static void popup_handler(H3270 *session, LIB3270_NOTIFY type, const char *title | @@ -382,8 +336,6 @@ static void popup_handler(H3270 *session, LIB3270_NOTIFY type, const char *title | ||
382 | 336 | ||
383 | static void update_ssl(H3270 *session, G_GNUC_UNUSED LIB3270_SSL_STATE state) | 337 | static void update_ssl(H3270 *session, G_GNUC_UNUSED LIB3270_SSL_STATE state) |
384 | { | 338 | { |
385 | - debug("----------------------> %d", (int) state); | ||
386 | - | ||
387 | g_idle_add((GSourceFunc) bg_update_ssl, session); | 339 | g_idle_add((GSourceFunc) bg_update_ssl, session); |
388 | } | 340 | } |
389 | 341 | ||
@@ -461,6 +413,45 @@ static void popup_handler(H3270 *session, LIB3270_NOTIFY type, const char *title | @@ -461,6 +413,45 @@ static void popup_handler(H3270 *session, LIB3270_NOTIFY type, const char *title | ||
461 | return 0; | 413 | return 0; |
462 | } | 414 | } |
463 | 415 | ||
416 | + struct _word_selected | ||
417 | + { | ||
418 | + H3270 *hSession; | ||
419 | + int offset; | ||
420 | + int len; | ||
421 | + }; | ||
422 | + | ||
423 | + static gboolean bg_word_selected(struct _word_selected *cfg) | ||
424 | + { | ||
425 | + if(cfg->len > 3) { | ||
426 | + lib3270_autoptr(char) text = lib3270_get_string_at_address(cfg->hSession,cfg->offset,cfg->len,0); | ||
427 | + | ||
428 | + if(text && (g_str_has_prefix(text,"http://") || g_str_has_prefix(text,"https://")) ) { | ||
429 | + | ||
430 | + v3270_signal_emit( | ||
431 | + lib3270_get_user_data(cfg->hSession), | ||
432 | + V3270_SIGNAL_OPEN_URL, | ||
433 | + text | ||
434 | + ); | ||
435 | + | ||
436 | + } | ||
437 | + | ||
438 | + } | ||
439 | + | ||
440 | + return G_SOURCE_REMOVE; | ||
441 | + } | ||
442 | + | ||
443 | + static void word_selected(H3270 *hSession, int from, int to) { | ||
444 | + | ||
445 | + struct _word_selected *cfg = g_new0(struct _word_selected, 1); | ||
446 | + | ||
447 | + cfg->hSession = hSession; | ||
448 | + cfg->offset = from; | ||
449 | + cfg->len = (to-from)+1; | ||
450 | + | ||
451 | + g_idle_add_full(G_PRIORITY_DEFAULT_IDLE,(GSourceFunc) bg_word_selected, cfg, g_free); | ||
452 | + | ||
453 | + } | ||
454 | + | ||
464 | void v3270_install_callbacks(v3270 *widget) | 455 | void v3270_install_callbacks(v3270 *widget) |
465 | { | 456 | { |
466 | struct lib3270_session_callbacks *cbk; | 457 | struct lib3270_session_callbacks *cbk; |
@@ -516,6 +507,7 @@ static void popup_handler(H3270 *session, LIB3270_NOTIFY type, const char *title | @@ -516,6 +507,7 @@ static void popup_handler(H3270 *session, LIB3270_NOTIFY type, const char *title | ||
516 | cbk->popup = popup; | 507 | cbk->popup = popup; |
517 | cbk->action = action; | 508 | cbk->action = action; |
518 | cbk->reconnect = reconnect; | 509 | cbk->reconnect = reconnect; |
510 | + cbk->word_selected = word_selected; | ||
519 | 511 | ||
520 | } | 512 | } |
521 | 513 |
src/terminal/widget.c
@@ -537,6 +537,15 @@ static void finalize(GObject *object) { | @@ -537,6 +537,15 @@ static void finalize(GObject *object) { | ||
537 | v3270_UINT__POINTER, | 537 | v3270_UINT__POINTER, |
538 | G_TYPE_UINT, 1, G_TYPE_POINTER); | 538 | G_TYPE_UINT, 1, G_TYPE_POINTER); |
539 | 539 | ||
540 | + v3270_widget_signal[V3270_SIGNAL_OPEN_URL] = | ||
541 | + g_signal_new( I_("open-url"), | ||
542 | + G_OBJECT_CLASS_TYPE (gobject_class), | ||
543 | + G_SIGNAL_RUN_LAST, | ||
544 | + 0, | ||
545 | + NULL, NULL, | ||
546 | + v3270_VOID__POINTER, | ||
547 | + G_TYPE_NONE, 1, G_TYPE_STRING); | ||
548 | + | ||
540 | v3270_widget_signal[V3270_SIGNAL_SAVE_POPUP_RESPONSE] = | 549 | v3270_widget_signal[V3270_SIGNAL_SAVE_POPUP_RESPONSE] = |
541 | g_signal_new( I_("save-popup-response"), | 550 | g_signal_new( I_("save-popup-response"), |
542 | G_OBJECT_CLASS_TYPE (gobject_class), | 551 | G_OBJECT_CLASS_TYPE (gobject_class), |