Commit 669a2ae0ef5d8c7874f76479fec3fe4269be55c0
1 parent
27b1185a
Exists in
master
and in
4 other branches
Implementing toggle action object.
Showing
1 changed file
with
98 additions
and
0 deletions
Show diff stats
@@ -0,0 +1,98 @@ | @@ -0,0 +1,98 @@ | ||
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 toggles. | ||
32 | + * | ||
33 | + */ | ||
34 | + | ||
35 | + #include "../private.h" | ||
36 | + #include <pw3270/window.h> | ||
37 | + | ||
38 | + #define PW3270_TYPE_LIB3270_TOGGLE_ACTION (Lib3270ToggleAction_get_type()) | ||
39 | + #define PW3270_LIB3270_TOGGLE_ACTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), PW3270_TYPE_LIB3270_TOGGLE_ACTION, Lib3270Action)) | ||
40 | + #define PW3270_IS_LIB3270_TOGGLE_ACTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), PW3270_TYPE_LIB3270_TOGGLE_ACTION)) | ||
41 | + | ||
42 | + typedef struct _Lib3270ToggleActionClass { | ||
43 | + pw3270ActionClass parent_class; | ||
44 | + | ||
45 | + } Lib3270ToggleActionClass; | ||
46 | + | ||
47 | + typedef struct _Lib3270ToggleAction { | ||
48 | + pw3270Action parent; | ||
49 | + | ||
50 | + const LIB3270_TOGGLE_ENTRY * definition; | ||
51 | + | ||
52 | + } Lib3270ToggleAction; | ||
53 | + | ||
54 | + static void Lib3270ToggleAction_class_init(Lib3270ActionClass *klass); | ||
55 | + static void Lib3270ToggleAction_init(Lib3270Action *action); | ||
56 | + | ||
57 | + G_DEFINE_TYPE(Lib3270ToggleAction, Lib3270ToggleAction, PW3270_TYPE_ACTION); | ||
58 | + | ||
59 | + static gboolean action_enabled(GAction *action, GtkWidget *window) { | ||
60 | + | ||
61 | + | ||
62 | + return FALSE; | ||
63 | + } | ||
64 | + | ||
65 | + static void action_activate(GAction *action, GtkWidget *window) { | ||
66 | + | ||
67 | + | ||
68 | + } | ||
69 | + | ||
70 | + void Lib3270Action_class_init(Lib3270ActionClass *klass) { | ||
71 | + | ||
72 | + pw3270ActionClass * action = PW3270_TOGGLE_ACTION_CLASS(klass); | ||
73 | + | ||
74 | + action->get_enabled = action_enabled; | ||
75 | + action->activate = action_activate; | ||
76 | + | ||
77 | + } | ||
78 | + | ||
79 | + void Lib3270Action_init(Lib3270Action *action) { | ||
80 | + } | ||
81 | + | ||
82 | + GAction * pw3270_toggle_action_new_from_lib3270(const LIB3270_TOGGLE_ENTRY * definition, GtkWidget *window) { | ||
83 | + | ||
84 | + Lib3270Action * action = (Lib3270Action *) g_object_new(PW3270_TYPE_LIB3270_TOGGLE_ACTION, NULL); | ||
85 | + pw3270Action * abstract = PW3270_ACTION(action); | ||
86 | + | ||
87 | + action->definition = definition; | ||
88 | + abstract->window = window; | ||
89 | + | ||
90 | + if(abstract->name) | ||
91 | + g_free(abstract->name); | ||
92 | + | ||
93 | + abstract->name = g_strconcat("win.",definition->name,NULL); | ||
94 | + | ||
95 | + return G_ACTION(action); | ||
96 | + } | ||
97 | + | ||
98 | + |