Commit 5fc33710f910e2009d7c6e4e08d72ca4b25abf2a
1 parent
5c5fa189
Exists in
master
and in
4 other branches
Implementing application actions.
Showing
6 changed files
with
89 additions
and
26 deletions
Show diff stats
@@ -0,0 +1,66 @@ | @@ -0,0 +1,66 @@ | ||
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 | + * References: | ||
29 | + * | ||
30 | + * https://fossies.org/linux/gtk+/examples/plugman.c | ||
31 | + * | ||
32 | + */ | ||
33 | + | ||
34 | + #include "private.h" | ||
35 | + #include <pw3270/application.h> | ||
36 | + | ||
37 | + void pw3270_application_quit_activated(GSimpleAction * action, GVariant *parameter, gpointer application) { | ||
38 | + | ||
39 | + g_print("Exiting application\n"); | ||
40 | + | ||
41 | + GList *list = gtk_application_get_windows(GTK_APPLICATION(application)); | ||
42 | + | ||
43 | + while(list) { | ||
44 | + | ||
45 | + GtkWidget * window = GTK_WIDGET(list->data); | ||
46 | + list = list->next; | ||
47 | + | ||
48 | + gtk_widget_destroy(window); | ||
49 | + | ||
50 | + } | ||
51 | + | ||
52 | + } | ||
53 | + | ||
54 | + void pw3270_application_new_tab_activated(GSimpleAction * action, GVariant *parameter, gpointer application) { | ||
55 | + | ||
56 | + debug("%s",__FUNCTION__); | ||
57 | + pw3270_terminal_new(GTK_WIDGET(gtk_application_get_active_window(GTK_APPLICATION(application)))); | ||
58 | + | ||
59 | + } | ||
60 | + | ||
61 | + void pw3270_application_new_window_activated(GSimpleAction * action, GVariant *parameter, gpointer application) { | ||
62 | + | ||
63 | + debug("%s",__FUNCTION__); | ||
64 | + g_application_activate(application); | ||
65 | + | ||
66 | + } |
src/objects/window/application.c
@@ -88,42 +88,27 @@ | @@ -88,42 +88,27 @@ | ||
88 | // | 88 | // |
89 | static GActionEntry app_entries[] = { | 89 | static GActionEntry app_entries[] = { |
90 | { | 90 | { |
91 | - "app.about", | ||
92 | - action_activated, | ||
93 | - NULL, | ||
94 | - NULL, | ||
95 | - NULL | 91 | + .name = "about", |
92 | + .activate = action_activated, | ||
96 | }, | 93 | }, |
97 | { | 94 | { |
98 | - "app.preferences", | ||
99 | - action_activated, | ||
100 | - NULL, | ||
101 | - NULL, | ||
102 | - NULL | 95 | + .name = "preferences", |
96 | + .activate = action_activated, | ||
103 | }, | 97 | }, |
104 | 98 | ||
105 | { | 99 | { |
106 | - "app.quit", | ||
107 | - action_activated, | ||
108 | - NULL, | ||
109 | - NULL, | ||
110 | - NULL | 100 | + .name = "quit", |
101 | + .activate = pw3270_application_quit_activated, | ||
111 | }, | 102 | }, |
112 | 103 | ||
113 | { | 104 | { |
114 | - "app.new_tab", | ||
115 | - action_activated, | ||
116 | - NULL, | ||
117 | - NULL, | ||
118 | - NULL | 105 | + .name = "new_tab", |
106 | + .activate = pw3270_application_new_tab_activated, | ||
119 | }, | 107 | }, |
120 | 108 | ||
121 | { | 109 | { |
122 | - "app.new_window", | ||
123 | - action_activated, | ||
124 | - NULL, | ||
125 | - NULL, | ||
126 | - NULL | 110 | + .name = "new_window", |
111 | + .activate = pw3270_application_new_window_activated, | ||
127 | } | 112 | } |
128 | 113 | ||
129 | }; | 114 | }; |
src/objects/window/private.h
@@ -61,4 +61,9 @@ | @@ -61,4 +61,9 @@ | ||
61 | 61 | ||
62 | }; | 62 | }; |
63 | 63 | ||
64 | + // Actions | ||
65 | + G_GNUC_INTERNAL void pw3270_application_quit_activated(GSimpleAction * action, GVariant *parameter, gpointer application); | ||
66 | + G_GNUC_INTERNAL void pw3270_application_new_tab_activated(GSimpleAction * action, GVariant *parameter, gpointer application); | ||
67 | + G_GNUC_INTERNAL void pw3270_application_new_window_activated(GSimpleAction * action, GVariant *parameter, gpointer application); | ||
68 | + | ||
64 | #endif // PRIVATE_H_INCLUDED | 69 | #endif // PRIVATE_H_INCLUDED |
src/objects/window/ui/application.xml
@@ -8,6 +8,10 @@ | @@ -8,6 +8,10 @@ | ||
8 | <attribute name="action">app.about</attribute> | 8 | <attribute name="action">app.about</attribute> |
9 | </item> | 9 | </item> |
10 | <item> | 10 | <item> |
11 | + <attribute name="label" translatable="yes">New Window</attribute> | ||
12 | + <attribute name="action">app.new_window</attribute> | ||
13 | + </item> | ||
14 | + <item> | ||
11 | <attribute name="label" translatable="yes">Preferences</attribute> | 15 | <attribute name="label" translatable="yes">Preferences</attribute> |
12 | <attribute name="action">app.help</attribute> | 16 | <attribute name="action">app.help</attribute> |
13 | </item> | 17 | </item> |
src/objects/window/ui/window.xml
@@ -12,7 +12,7 @@ | @@ -12,7 +12,7 @@ | ||
12 | <attribute name="action">app.help</attribute> | 12 | <attribute name="action">app.help</attribute> |
13 | </item> | 13 | </item> |
14 | <item> | 14 | <item> |
15 | - <attribute name="label" translatable="yes">Quit</attribute> | 15 | + <attribute name="label" translatable="yes">Quit PW3270</attribute> |
16 | <attribute name="action">app.quit</attribute> | 16 | <attribute name="action">app.quit</attribute> |
17 | </item> | 17 | </item> |
18 | </section> | 18 | </section> |
src/objects/window/window.cbp
@@ -42,6 +42,9 @@ | @@ -42,6 +42,9 @@ | ||
42 | <Unit filename="../../include/pw3270/application.h" /> | 42 | <Unit filename="../../include/pw3270/application.h" /> |
43 | <Unit filename="../../include/pw3270/toolbar.h" /> | 43 | <Unit filename="../../include/pw3270/toolbar.h" /> |
44 | <Unit filename="../../include/pw3270/window.h" /> | 44 | <Unit filename="../../include/pw3270/window.h" /> |
45 | + <Unit filename="actions.c"> | ||
46 | + <Option compilerVar="CC" /> | ||
47 | + </Unit> | ||
45 | <Unit filename="application.c"> | 48 | <Unit filename="application.c"> |
46 | <Option compilerVar="CC" /> | 49 | <Option compilerVar="CC" /> |
47 | </Unit> | 50 | </Unit> |