Commit 21daedae8945da902d6fc687f1ef74de9d776e6e
1 parent
3b5d2c0c
Exists in
master
and in
1 other branch
Moving lib3270 action to the v3270 library.
Showing
3 changed files
with
133 additions
and
0 deletions
Show diff stats
src/include/v3270/actions.h
@@ -32,6 +32,7 @@ | @@ -32,6 +32,7 @@ | ||
32 | #define V3270_ACTIONS_H_INCLUDED 1 | 32 | #define V3270_ACTIONS_H_INCLUDED 1 |
33 | 33 | ||
34 | #include <gtk/gtk.h> | 34 | #include <gtk/gtk.h> |
35 | + #include <lib3270/actions.h> | ||
35 | 36 | ||
36 | G_BEGIN_DECLS | 37 | G_BEGIN_DECLS |
37 | 38 | ||
@@ -164,6 +165,8 @@ | @@ -164,6 +165,8 @@ | ||
164 | LIB3270_EXPORT const gchar * v3270_action_get_tooltip(GAction *action); | 165 | LIB3270_EXPORT const gchar * v3270_action_get_tooltip(GAction *action); |
165 | LIB3270_EXPORT GdkPixbuf * v3270_action_get_pixbuf(GAction *action, GtkIconSize icon_size, GtkIconLookupFlags flags); | 166 | LIB3270_EXPORT GdkPixbuf * v3270_action_get_pixbuf(GAction *action, GtkIconSize icon_size, GtkIconLookupFlags flags); |
166 | 167 | ||
168 | + LIB3270_EXPORT GAction * g_action_new_from_lib3270(const LIB3270_ACTION * definition); | ||
169 | + | ||
167 | LIB3270_EXPORT void g_action_map_add_v3270_actions(GActionMap *action_map); | 170 | LIB3270_EXPORT void g_action_map_add_v3270_actions(GActionMap *action_map); |
168 | LIB3270_EXPORT void g_action_map_add_lib3270_actions(GActionMap *action_map); | 171 | LIB3270_EXPORT void g_action_map_add_lib3270_actions(GActionMap *action_map); |
169 | 172 |
@@ -0,0 +1,127 @@ | @@ -0,0 +1,127 @@ | ||
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 | + /** | ||
31 | + * @brief Implement GAction "wrapper" for lib3270's actions. | ||
32 | + * | ||
33 | + */ | ||
34 | + | ||
35 | + #include <internals.h> | ||
36 | + #include <lib3270/actions.h> | ||
37 | + #include <v3270.h> | ||
38 | + #include <v3270/actions.h> | ||
39 | + | ||
40 | + #define LIB3270_TYPE_ACTION (Lib3270Action_get_type()) | ||
41 | + #define LIB3270_ACTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), LIB3270_TYPE_ACTION, Lib3270Action)) | ||
42 | + #define LIB3270_IS_ACTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), LIB3270_TYPE_ACTION)) | ||
43 | + | ||
44 | + typedef struct _Lib3270ActionClass { | ||
45 | + V3270ActionClass parent_class; | ||
46 | + } Lib3270ActionClass; | ||
47 | + | ||
48 | + typedef struct _Lib3270Action { | ||
49 | + V3270Action parent; | ||
50 | + } Lib3270Action; | ||
51 | + | ||
52 | + static void Lib3270Action_class_init(Lib3270ActionClass *klass); | ||
53 | + static void Lib3270Action_init(Lib3270Action *action); | ||
54 | + | ||
55 | + #define LIB3270_ACTION_GET_DESCRIPTOR(obj) ((LIB3270_ACTION *) ((V3270Action *) obj)->info) | ||
56 | + | ||
57 | + G_DEFINE_TYPE(Lib3270Action, Lib3270Action, V3270_TYPE_ACTION); | ||
58 | + | ||
59 | + static gboolean get_enabled(GAction *action, GtkWidget *terminal) { | ||
60 | + | ||
61 | + gboolean enabled = V3270_ACTION_CLASS(Lib3270Action_parent_class)->get_enabled(action,terminal); | ||
62 | + | ||
63 | + if(enabled && terminal) { | ||
64 | + | ||
65 | + H3270 * hSession = v3270_get_session(terminal); | ||
66 | + if(hSession) | ||
67 | + return LIB3270_ACTION_GET_DESCRIPTOR(action)->activatable(hSession) > 0 ? TRUE : FALSE; | ||
68 | + | ||
69 | + } | ||
70 | + | ||
71 | + return FALSE; | ||
72 | + | ||
73 | + } | ||
74 | + | ||
75 | + static void activate(GAction *action, GVariant G_GNUC_UNUSED(*parameter), GtkWidget *terminal) { | ||
76 | + | ||
77 | + int rc = LIB3270_ACTION_GET_DESCRIPTOR(action)->activate(v3270_get_session(terminal)); | ||
78 | + | ||
79 | + if(rc) { | ||
80 | + g_message("Can't activate action \"%s\": %s",g_action_get_name(action),strerror(rc)); | ||
81 | + gdk_display_beep(gtk_widget_get_display(terminal)); | ||
82 | + } | ||
83 | + | ||
84 | + } | ||
85 | + | ||
86 | + static void dispose(GObject *object) { | ||
87 | + | ||
88 | + //Lib3270Action *action = LIB3270_ACTION(object); | ||
89 | + | ||
90 | + | ||
91 | + G_OBJECT_CLASS(Lib3270Action_parent_class)->dispose(object); | ||
92 | + } | ||
93 | + | ||
94 | + void Lib3270Action_class_init(Lib3270ActionClass *klass) { | ||
95 | + | ||
96 | + V3270_ACTION_CLASS(klass)->get_enabled = get_enabled; | ||
97 | + G_OBJECT_CLASS(klass)->dispose = dispose; | ||
98 | + | ||
99 | + } | ||
100 | + | ||
101 | + void Lib3270Action_init(Lib3270Action *action) { | ||
102 | + action->parent.activate = activate; | ||
103 | + } | ||
104 | + | ||
105 | + GAction * g_action_new_from_lib3270(const LIB3270_ACTION * definition) { | ||
106 | + | ||
107 | + Lib3270Action * action = (Lib3270Action *) g_object_new(LIB3270_TYPE_ACTION, NULL); | ||
108 | + | ||
109 | + // Setup hooks. | ||
110 | + action->parent.info = (const LIB3270_PROPERTY *) definition; | ||
111 | + | ||
112 | + return G_ACTION(action); | ||
113 | + } | ||
114 | + | ||
115 | + void g_action_map_add_lib3270_actions(GActionMap *action_map) { | ||
116 | + | ||
117 | + size_t ix; | ||
118 | + | ||
119 | + const LIB3270_ACTION * actions = lib3270_get_actions(); | ||
120 | + for(ix = 0; actions[ix].name; ix++) { | ||
121 | + | ||
122 | + GAction *action = g_action_new_from_lib3270(&actions[ix]); | ||
123 | + g_action_map_add_action(action_map,action); | ||
124 | + | ||
125 | + } | ||
126 | + | ||
127 | + } |
v3270.cbp
@@ -234,6 +234,9 @@ | @@ -234,6 +234,9 @@ | ||
234 | <Unit filename="src/terminal/actions/clipboard.c"> | 234 | <Unit filename="src/terminal/actions/clipboard.c"> |
235 | <Option compilerVar="CC" /> | 235 | <Option compilerVar="CC" /> |
236 | </Unit> | 236 | </Unit> |
237 | + <Unit filename="src/terminal/actions/lib3270.c"> | ||
238 | + <Option compilerVar="CC" /> | ||
239 | + </Unit> | ||
237 | <Unit filename="src/terminal/actions/print.c"> | 240 | <Unit filename="src/terminal/actions/print.c"> |
238 | <Option compilerVar="CC" /> | 241 | <Option compilerVar="CC" /> |
239 | </Unit> | 242 | </Unit> |