Commit aa1eb8f9d6652fbffd0297691cf95f5723228463

Authored by Perry Werneck
1 parent 7c6b733e
Exists in master and in 1 other branch develop

Implementing the 'open-url' property.

src/include/internals.h
  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 20 #ifndef V3270_INTERNALS_H_INCLUDED
... ...
src/include/terminal.h
  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
  4 + * Copyright (C) 2008 Banco do Brasil S.A.
20 5 *
21   - * Este programa está nomeado como - e possui - linhas de código.
  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.
22 10 *
23   - * Contatos:
24   - *
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>
31   -#include <internals.h>
32   -#include <v3270/selection.h>
33   -
34   -G_BEGIN_DECLS
  20 + #include <config.h>
  21 + #include <internals.h>
  22 + #include <v3270/selection.h>
35 23  
36   -/*
37   - /// @brief V3270 Properties saved to the configuration file.
38   - typedef enum
39   - {
40   - V3270_SETTING_URL,
41   - V3270_SETTING_FONT_FAMILY,
42   - V3270_SETTING_AUTO_DISCONNECT,
43   - V3270_SETTING_REMAP_FILE,
44   - V3270_SETTING_DYNAMIC_SPACING,
45   - V3270_SETTING_LU_NAMES,
46   - V3270_SETTING_MODEL_NUMBER,
47   - V3270_SETTING_OVERSIZE,
48   - V3270_SETTING_HOST_CHARSET,
49   - V3270_SETTING_UNLOCK_DELAY,
50   - V3270_SETTING_COLOR_TYPE,
51   - V3270_SETTING_HOST_TYPE,
52   - V3270_SETTING_CRL_PROTOCOL,
53   - V3270_SETTING_TERMINAL_COLORS,
54   - V3270_SETTING_SELECTION_OPTIONS,
55   -
56   - V3270_SETTING_COUNT ///< @brief Number of setting properties.
57   - } V3270_SETTING;
58   -
59   - G_GNUC_INTERNAL void v3270_notify_setting(GtkWidget *widget, V3270_SETTING id);
60   -*/
  24 + G_BEGIN_DECLS
61 25  
62 26 struct _v3270Class
63 27 {
... ... @@ -151,14 +115,15 @@ G_BEGIN_DECLS
151 115 GtkWidget parent;
152 116  
153 117 // flags
154   - int selecting : 1; /// @brief Selecting region
155   - int moving : 1; /// @brief Moving selected region
156   - int resizing : 1; /// @brief Resizing selected region
157   - int scaled_fonts : 1; /// @brief Use scaled fonts
158   - int drawing : 1; /// @brief Draw widget?
159   - int freeze : 1; /// @brief Truee when the "save settings" signal is disabled.
160   - int append : 1; /// @brief Next smart-copy operation will be append.
161   - int copying : 1; /// @brief Copy with center mouse button
  118 + int selecting : 1; ///< @brief Selecting region
  119 + int moving : 1; ///< @brief Moving selected region
  120 + int resizing : 1; ///< @brief Resizing selected region
  121 + int scaled_fonts : 1; ///< @brief Use scaled fonts
  122 + int drawing : 1; ///< @brief Draw widget?
  123 + int freeze : 1; ///< @brief Truee when the "save settings" signal is disabled.
  124 + int append : 1; ///< @brief Next smart-copy operation will be append.
  125 + int copying : 1; ///< @brief Copy with center mouse button
  126 + int open_url : 1; ///< @brief Emit 'open-url' signal when and http:// or https:// url is selected by 'word-select' action.
162 127  
163 128 /// @brief Action properties.
164 129 // GtkResponseType responses[V3270_TOGGLEABLE_DIALOG_CUSTOM];
... ...
src/terminal/callbacks.c
... ... @@ -422,13 +422,20 @@ static int load(H3270 *session, const char *filename)
422 422  
423 423 static gboolean bg_word_selected(struct _word_selected *cfg)
424 424 {
425   - if(cfg->len > 3) {
  425 + v3270 *terminal = (v3270 *) lib3270_get_user_data(cfg->hSession);
  426 +
  427 + debug("%s(open-url=%d)",__FUNCTION__,terminal->open_url);
  428 +
  429 + if(cfg->len > 3 && terminal->open_url) {
  430 +
426 431 lib3270_autoptr(char) text = lib3270_get_string_at_address(cfg->hSession,cfg->offset,cfg->len,0);
427 432  
428 433 if(text && (g_str_has_prefix(text,"http://") || g_str_has_prefix(text,"https://")) ) {
429 434  
  435 + debug("Emitting '%s'", text);
  436 +
430 437 v3270_signal_emit(
431   - lib3270_get_user_data(cfg->hSession),
  438 + terminal,
432 439 V3270_SIGNAL_OPEN_URL,
433 440 text
434 441 );
... ...
src/terminal/properties/get.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.
  4 + * Copyright (C) 2008 Banco do Brasil S.A.
16 5 *
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
  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.
20 10 *
21   - * Este programa está nomeado como properties.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)
  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 20 #include "private.h"
... ... @@ -147,6 +137,10 @@
147 137 g_value_set_boolean(value,window->timer != NULL);
148 138 break;
149 139  
  140 + case V3270_PROPERTY_OPEN_URL:
  141 + g_value_set_boolean(value,window->open_url != 0);
  142 + break;
  143 +
150 144 default:
151 145 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
152 146  
... ...
src/terminal/properties/init.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
  4 + * Copyright (C) 2008 Banco do Brasil S.A.
20 5 *
21   - * Este programa está nomeado como properties.c e possui - linhas de código.
  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.
22 10 *
23   - * Contatos:
24   - *
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 20 #include "private.h"
... ... @@ -170,6 +160,22 @@
170 160 spec
171 161 );
172 162  
  163 + // Open URL
  164 + spec =
  165 + g_param_spec_boolean(
  166 + "open-url",
  167 + "open-url",
  168 + _( "Emit signal 'open-url' when an http:// or https:// string is selected by action 'word-select'" ),
  169 + FALSE,
  170 + G_PARAM_READABLE|G_PARAM_WRITABLE
  171 + );
  172 +
  173 + g_object_class_install_property(
  174 + gobject_class,
  175 + V3270_PROPERTY_OPEN_URL,
  176 + spec
  177 + );
  178 +
173 179 // Lu names
174 180 spec =
175 181 g_param_spec_string(
... ...
src/terminal/properties/private.h
  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 properties.c 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 20 #ifdef WIN32
... ... @@ -60,8 +50,9 @@
60 50 V3270_PROPERTY_SELECTION_OPTIONS = 11,
61 51 V3270_PROPERTY_HAS_COPY = 12, ///< @brief Terminal has copy.
62 52 V3270_PROPERTY_HAS_TIMER = 13, ///< @brief Timer indicator state.
  53 + V3270_PROPERTY_OPEN_URL = 14, ///< @brief Open URL when 'word' selected.
63 54  
64   - V3270_PROPERTY_DYNAMIC = 14 ///< @brief Id of the first LIB3270 internal property.
  55 + V3270_PROPERTY_DYNAMIC = 15 ///< @brief Id of the first LIB3270 internal property.
65 56 };
66 57  
67 58 G_GNUC_INTERNAL void v3270_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
... ...
src/terminal/properties/set.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.
  4 + * Copyright (C) 2008 Banco do Brasil S.A.
16 5 *
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
  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.
20 10 *
21   - * Este programa está nomeado como properties.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)
  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 20 #include "private.h"
... ... @@ -143,6 +133,10 @@
143 133 GTK_V3270(object)->selection.options = (V3270SelectionOption) g_value_get_uint(value);
144 134 break;
145 135  
  136 + case V3270_PROPERTY_OPEN_URL:
  137 + GTK_V3270(object)->open_url = (g_value_get_boolean(value) ? 1 : 0);
  138 + break;
  139 +
146 140 default:
147 141 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
148 142  
... ...
src/terminal/widget.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 20 #include <config.h>
... ... @@ -63,6 +53,7 @@
63 53 /// @brief Persistent properties (load/save from session file).
64 54 static const gchar *persistent_properties[] = {
65 55 "url",
  56 + "open-url",
66 57 "model-number",
67 58 "oversize",
68 59 "host-charset",
... ...