Commit 27b1185a164fa747eb5ace870e6bb7368ebbd28d

Authored by Perry Werneck
1 parent b933d92c

Working on the new action object.

src/actions/actions.cbp
... ... @@ -43,7 +43,10 @@
43 43 <Unit filename="abstract.c">
44 44 <Option compilerVar="CC" />
45 45 </Unit>
46   - <Unit filename="lib3270.c">
  46 + <Unit filename="lib3270/action.c">
  47 + <Option compilerVar="CC" />
  48 + </Unit>
  49 + <Unit filename="lib3270/toggle.c">
47 50 <Option compilerVar="CC" />
48 51 </Unit>
49 52 <Unit filename="private.h" />
... ...
src/actions/lib3270.c
... ... @@ -1,110 +0,0 @@
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 "private.h"
36   - #include <pw3270/window.h>
37   -
38   - #define PW3270_TYPE_LIB3270_ACTION (Lib3270Action_get_type())
39   - #define PW3270_LIB3270_ACTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), PW3270_TYPE_LIB3270_ACTION, Lib3270Action))
40   - #define PW3270_IS_LIB3270_ACTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), PW3270_TYPE_LIB3270_ACTION))
41   -
42   - typedef struct _Lib3270ActionClass {
43   - pw3270ActionClass parent_class;
44   -
45   - } Lib3270ActionClass;
46   -
47   - typedef struct _Lib3270Action {
48   - pw3270Action parent;
49   -
50   - const LIB3270_ACTION * definition;
51   -
52   - } Lib3270Action;
53   -
54   - static void Lib3270Action_class_init(Lib3270ActionClass *klass);
55   - static void Lib3270Action_init(Lib3270Action *action);
56   -
57   - G_DEFINE_TYPE(Lib3270Action, Lib3270Action, PW3270_TYPE_ACTION);
58   -
59   - static gboolean action_enabled(GAction *action, GtkWidget *window) {
60   -
61   - H3270 * hSession = pw3270_window_get_session_handle(window);
62   -
63   - if(hSession)
64   - return PW3270_LIB3270_ACTION(action)->definition->activatable(hSession) > 0 ? TRUE : FALSE;
65   -
66   - return FALSE;
67   - }
68   -
69   - static void action_activate(GAction *action, GtkWidget *window) {
70   -
71   - H3270 * hSession = pw3270_window_get_session_handle(window);
72   -
73   - debug("Activating action %s on hSession %p", pw3270_action_get_name(action), hSession);
74   -
75   - if(hSession)
76   - PW3270_LIB3270_ACTION(action)->definition->activate(hSession);
77   - else
78   - g_message("Action \"%s\" requires a lib3270 session", pw3270_action_get_name(action));
79   -
80   - }
81   -
82   - void Lib3270Action_class_init(Lib3270ActionClass *klass) {
83   -
84   - pw3270ActionClass * action = PW3270_ACTION_CLASS(klass);
85   -
86   - action->get_enabled = action_enabled;
87   - action->activate = action_activate;
88   -
89   - }
90   -
91   - void Lib3270Action_init(Lib3270Action *action) {
92   - }
93   -
94   - GAction * pw3270_action_new_from_lib3270(const LIB3270_ACTION * definition, GtkWidget *window) {
95   -
96   - Lib3270Action * action = (Lib3270Action *) g_object_new(PW3270_TYPE_LIB3270_ACTION, NULL);
97   - pw3270Action * abstract = PW3270_ACTION(action);
98   -
99   - action->definition = definition;
100   - abstract->window = window;
101   -
102   - if(abstract->name)
103   - g_free(abstract->name);
104   -
105   - abstract->name = g_strconcat("win.",definition->name,NULL);
106   -
107   - return G_ACTION(action);
108   - }
109   -
110   -
src/actions/lib3270/action.c 0 → 100644
... ... @@ -0,0 +1,110 @@
  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 "../private.h"
  36 + #include <pw3270/window.h>
  37 +
  38 + #define PW3270_TYPE_LIB3270_ACTION (Lib3270Action_get_type())
  39 + #define PW3270_LIB3270_ACTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), PW3270_TYPE_LIB3270_ACTION, Lib3270Action))
  40 + #define PW3270_IS_LIB3270_ACTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), PW3270_TYPE_LIB3270_ACTION))
  41 +
  42 + typedef struct _Lib3270ActionClass {
  43 + pw3270ActionClass parent_class;
  44 +
  45 + } Lib3270ActionClass;
  46 +
  47 + typedef struct _Lib3270Action {
  48 + pw3270Action parent;
  49 +
  50 + const LIB3270_ACTION * definition;
  51 +
  52 + } Lib3270Action;
  53 +
  54 + static void Lib3270Action_class_init(Lib3270ActionClass *klass);
  55 + static void Lib3270Action_init(Lib3270Action *action);
  56 +
  57 + G_DEFINE_TYPE(Lib3270Action, Lib3270Action, PW3270_TYPE_ACTION);
  58 +
  59 + static gboolean action_enabled(GAction *action, GtkWidget *window) {
  60 +
  61 + H3270 * hSession = pw3270_window_get_session_handle(window);
  62 +
  63 + if(hSession)
  64 + return PW3270_LIB3270_ACTION(action)->definition->activatable(hSession) > 0 ? TRUE : FALSE;
  65 +
  66 + return FALSE;
  67 + }
  68 +
  69 + static void action_activate(GAction *action, GtkWidget *window) {
  70 +
  71 + H3270 * hSession = pw3270_window_get_session_handle(window);
  72 +
  73 + debug("Activating action %s on hSession %p", pw3270_action_get_name(action), hSession);
  74 +
  75 + if(hSession)
  76 + PW3270_LIB3270_ACTION(action)->definition->activate(hSession);
  77 + else
  78 + g_message("Action \"%s\" requires a lib3270 session", pw3270_action_get_name(action));
  79 +
  80 + }
  81 +
  82 + void Lib3270Action_class_init(Lib3270ActionClass *klass) {
  83 +
  84 + pw3270ActionClass * action = PW3270_ACTION_CLASS(klass);
  85 +
  86 + action->get_enabled = action_enabled;
  87 + action->activate = action_activate;
  88 +
  89 + }
  90 +
  91 + void Lib3270Action_init(Lib3270Action *action) {
  92 + }
  93 +
  94 + GAction * pw3270_action_new_from_lib3270(const LIB3270_ACTION * definition, GtkWidget *window) {
  95 +
  96 + Lib3270Action * action = (Lib3270Action *) g_object_new(PW3270_TYPE_LIB3270_ACTION, NULL);
  97 + pw3270Action * abstract = PW3270_ACTION(action);
  98 +
  99 + action->definition = definition;
  100 + abstract->window = window;
  101 +
  102 + if(abstract->name)
  103 + g_free(abstract->name);
  104 +
  105 + abstract->name = g_strconcat("win.",definition->name,NULL);
  106 +
  107 + return G_ACTION(action);
  108 + }
  109 +
  110 +
... ...
src/include/pw3270/actions.h
... ... @@ -55,6 +55,7 @@
55 55 GType pw3270Action_get_type(void) G_GNUC_CONST;
56 56  
57 57 GAction * pw3270_action_new_from_lib3270(const LIB3270_ACTION * definition, GtkWidget *window);
  58 + GAction * pw3270_toggle_action_new_from_lib3270(const LIB3270_TOGGLE_ENTRY * definition, GtkWidget *window);
58 59  
59 60 const gchar * pw3270_action_get_name(GAction *action);
60 61 void pw3270_action_set_name(GAction *action, const gchar *name);
... ...