actions.h
7.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
/*
* "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
* (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
* aplicativos mainframe. Registro no INPI sob o nome G3270.
*
* Copyright (C) <2008> <Banco do Brasil S.A.>
*
* Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
* os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
* Free Software Foundation.
*
* Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
* GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
* A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
* obter mais detalhes.
*
* Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
* programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
* St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Este programa está nomeado como - e possui - linhas de código.
*
* Contatos:
*
* perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
* erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
*
*/
#ifndef V3270_ACTIONS_H_INCLUDED
#define V3270_ACTIONS_H_INCLUDED 1
#include <gtk/gtk.h>
#include <lib3270/actions.h>
#include <lib3270/toggle.h>
G_BEGIN_DECLS
typedef struct _V3270Accelerator V3270Accelerator;
typedef enum _v3270_action_flag
{
V3270_ACTION_FLAG_DEFAULT = 0x00000000,
V3270_ACTION_FLAG_CUT = 0x10000000,
} V3270_ACTION_FLAGS;
typedef struct _v3270_action V3270_ACTION;
struct _v3270_action
{
LIB3270_PROPERTY_HEAD
V3270_ACTION_FLAGS flags; ///< @brief (The flags for activation).
guint key;
GdkModifierType mods;
int (*activate)(GtkWidget *widget, const V3270_ACTION *action);
};
///
/// @brief Get internal V3270 action table.
///
LIB3270_EXPORT const V3270_ACTION * v3270_get_actions();
//
// Actions
//
LIB3270_EXPORT void v3270_tab(GtkWidget *widget);
//
// Misc
//
LIB3270_EXPORT void v3270_set_scroll_handler(GtkWidget *widget, GdkScrollDirection direction, GCallback callback, gpointer data);
LIB3270_EXPORT void v3270_set_scroll_action(GtkWidget *widget, GdkScrollDirection direction, GtkAction *action) G_GNUC_DEPRECATED;
//
// Keyboard accelerators
//
LIB3270_EXPORT void v3270_backtab(GtkWidget *widget);
/// @brief Reset accelerator map to defaults.
LIB3270_EXPORT void v3270_accelerator_map_reset(GtkWidget *widget);
LIB3270_EXPORT void v3270_accelerator_map_foreach(GtkWidget *widget,void (*call)(const V3270Accelerator * accel, const char *keys, gpointer ptr), gpointer ptr);
LIB3270_EXPORT void v3270_accelerator_map_to_key_file(GtkWidget *widget, GKeyFile *key_file, const gchar *group_name);
LIB3270_EXPORT gboolean v3270_accelerator_map_load_key_file(GtkWidget *widget, GKeyFile *key_file, const gchar *group_name);
LIB3270_EXPORT V3270Accelerator * v3270_accelerator_map_add_entry(GtkWidget *widget, const gchar *name, guint accel_key, GdkModifierType accel_mods, GCallback callback, gpointer data);
LIB3270_EXPORT const V3270Accelerator * v3270_get_accelerator(GtkWidget *widget, guint keyval, GdkModifierType state);
LIB3270_EXPORT void v3270_accelerator_activate(const V3270Accelerator * accel, GtkWidget *terminal);
LIB3270_EXPORT gboolean v3270_accelerator_compare(const V3270Accelerator * accel, const guint keyval, const GdkModifierType mods);
LIB3270_EXPORT const gchar * v3270_accelerator_get_name(const V3270Accelerator * accel);
LIB3270_EXPORT const gchar * v3270_accelerator_get_description(const V3270Accelerator * accel);
LIB3270_EXPORT const gchar * v3270_accelerator_get_summary(const V3270Accelerator * accel);
/// @brief Converts the accelerator into a string which can be used to represent the accelerator to the user.
/// @return A newly-allocated string representing the accelerator.
LIB3270_EXPORT gchar * v3270_accelerator_get_label(const V3270Accelerator * accel);
LIB3270_EXPORT V3270Accelerator * v3270_accelerator_clone(const V3270Accelerator *accel);
LIB3270_EXPORT const V3270Accelerator * v3270_accelerator_map_lookup_entry(GtkWidget *widget, guint keyval, GdkModifierType state);
//
// GAction wrapper for V3270 terminal widget.
//
#define V3270_TYPE_ACTION (V3270Action_get_type())
#define V3270_ACTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), V3270_TYPE_ACTION, V3270Action))
#define V3270_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), V3270_TYPE_ACTION, V3270ActionClass))
#define V3270_IS_ACTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), V3270_TYPE_ACTION))
#define V3270_IS_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), V3270_TYPE_ACTION))
#define V3270_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), V3270_TYPE_ACTION, V3270ActionClass))
typedef struct _V3270Action {
GObject parent;
GtkWidget * terminal; ///> @brief The active terminal widget.
const LIB3270_PROPERTY * info; ///> @brief Action info.
const void * listener; ///> @brief Signal listener for the action group.
const gchar * translation_domain; ///> @brief The translation domain for the action.
/// @brief Activation method.
void (*activate)(GAction *action, GVariant *parameter, GtkWidget *terminal);
} V3270Action;
typedef struct _V3270ActionClass {
GObjectClass parent_class;
struct {
GParamSpec * state;
GParamSpec * enabled;
} properties;
struct {
const GVariantType * state; ///> @brief State type.
const GVariantType * parameter; ///> @brief State type.
} type;
void (*change_widget)(GAction *action, GtkWidget *from, GtkWidget *to);
gboolean (*get_enabled)(GAction *action, GtkWidget *terminal);
GVariant * (*get_state)(GAction *action, GtkWidget *terminal);
const gchar * (*translate)(GAction *action, const gchar *text);
} V3270ActionClass;
LIB3270_EXPORT GType V3270Action_get_type(void) G_GNUC_CONST;
LIB3270_EXPORT GAction * v3270_action_new();
LIB3270_EXPORT void v3270_action_set_terminal_widget(GAction *object, GtkWidget *widget);
LIB3270_EXPORT GtkWidget * v3270_action_get_terminal_widget(GAction *object);
LIB3270_EXPORT void v3270_action_notify_state(GAction *action);
LIB3270_EXPORT void v3270_action_notify_enabled(GAction *action);
LIB3270_EXPORT const gchar * v3270_action_translate(GAction *action, const gchar *text);
LIB3270_EXPORT H3270 * v3270_action_get_session(GAction *action);
LIB3270_EXPORT const gchar * v3270_action_get_icon_name(GAction *action);
LIB3270_EXPORT const gchar * v3270_action_get_label(GAction *action);
LIB3270_EXPORT const gchar * v3270_action_get_tooltip(GAction *action);
LIB3270_EXPORT GdkPixbuf * v3270_action_get_pixbuf(GAction *action, GtkIconSize icon_size, GtkIconLookupFlags flags);
LIB3270_EXPORT GAction * g_action_new_from_lib3270(const LIB3270_ACTION * definition);
LIB3270_EXPORT GAction * g_action_new_from_toggle(const LIB3270_TOGGLE * definition);
LIB3270_EXPORT GAction * v3270_pfkey_action_new(void);
LIB3270_EXPORT GAction * v3270_pakey_action_new(void);
LIB3270_EXPORT void g_action_map_add_v3270_actions(GActionMap *action_map);
LIB3270_EXPORT void g_action_map_add_lib3270_actions(GActionMap *action_map);
LIB3270_EXPORT void g_action_map_add_lib3270_toggles(GActionMap *action_map);
G_END_DECLS
#endif // V3270_ACTIONS_H_INCLUDED