Commit ffdee95ea07e227d6b13771b780f74a6fa1888ea

Authored by Perry Werneck
1 parent 8f7e5643

Implementing application dialog action.

src/include/pw3270/actions.h
@@ -44,142 +44,46 @@ @@ -44,142 +44,46 @@
44 44
45 G_BEGIN_DECLS 45 G_BEGIN_DECLS
46 46
47 - /*  
48 // 47 //
49 // Abstract action 48 // Abstract action
50 // 49 //
51 - #define PW3270_TYPE_ACTION (pw3270Action_get_type())  
52 - #define PW3270_ACTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), PW3270_TYPE_ACTION, pw3270Action))  
53 - #define PW3270_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PW3270_TYPE_ACTION, pw3270ActionClass)) 50 + #define PW3270_TYPE_ACTION (PW3270Action_get_type())
  51 + #define PW3270_ACTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), PW3270_TYPE_ACTION, PW3270Action))
  52 + #define PW3270_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PW3270_TYPE_ACTION, PW3270ActionClass))
54 #define PW3270_IS_ACTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), PW3270_TYPE_ACTION)) 53 #define PW3270_IS_ACTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), PW3270_TYPE_ACTION))
55 #define PW3270_IS_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PW3270_TYPE_ACTION)) 54 #define PW3270_IS_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PW3270_TYPE_ACTION))
56 - #define PW3270_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PW3270_TYPE_ACTION, pw3270ActionClass)) 55 + #define PW3270_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PW3270_TYPE_ACTION, PW3270ActionClass))
57 56
58 - typedef struct _pw3270Action { 57 + typedef struct _PW3270Action {
59 58
60 GObject parent; 59 GObject parent;
61 60
62 - const gchar * name; ///> @brief Action name (const string).  
63 - GtkWidget * terminal; ///> @brief The active terminal widget.  
64 -  
65 - struct {  
66 - const GVariantType * state; ///> @brief State type type.  
67 - const GVariantType * parameter; ///> @brief Parameter type.  
68 - } types; 61 + const gchar * name;
  62 + const gchar * icon_name;
  63 + const gchar * label;
  64 + const gchar * tooltip;
69 65
70 /// @brief Activation method. 66 /// @brief Activation method.
71 - void (*activate)(GAction *action, GVariant *parameter, GtkWidget *terminal);  
72 -  
73 - /// @brief Get State method.  
74 - GVariant * (*get_state_property)(GAction *action, GtkWidget *terminal); 67 + void (*activate)(GAction *action, GVariant *parameter, GtkApplication *application);
75 68
76 - /// @brief Get state hint.  
77 - GVariant * (*get_state_hint)(GAction *action, GtkWidget *terminal); 69 + } PW3270Action;
78 70
79 - } pw3270Action;  
80 -  
81 - typedef struct _pw3270ActionClass { 71 + typedef struct _PW3270ActionClass {
82 72
83 GObjectClass parent_class; 73 GObjectClass parent_class;
84 74
  75 + gboolean (*get_enabled)(GAction *action);
  76 +
85 struct { 77 struct {
86 GParamSpec * state; 78 GParamSpec * state;
87 GParamSpec * enabled; 79 GParamSpec * enabled;
88 } properties; 80 } properties;
89 81
90 - void (*change_widget)(GAction *action, GtkWidget *from, GtkWidget *to);  
91 - gboolean (*get_enabled)(GAction *action, GtkWidget *terminal);  
92 -  
93 - const gchar * (*get_icon_name)(GAction *action);  
94 - const gchar * (*get_label)(GAction *action);  
95 - const gchar * (*get_tooltip)(GAction *action);  
96 -  
97 - } pw3270ActionClass;  
98 -  
99 - GType pw3270Action_get_type(void) G_GNUC_CONST;  
100 -  
101 - /// @brief New generic action.  
102 - GAction * pw3270_action_new();  
103 -  
104 - /// @brief Get action name.  
105 - const gchar * pw3270_action_get_name(GAction *action);  
106 -  
107 - /// @brief Set action name.  
108 - void pw3270_action_set_name(GAction *action, const gchar *name);  
109 -  
110 - /// @brief Get the action icon name.  
111 - const gchar * pw3270_action_get_icon_name(GAction *action);  
112 -  
113 - /// @brief Get the action image icon.  
114 - GtkImage * pw3270_action_get_image(GAction *action, GtkIconSize icon_size);  
115 -  
116 - /// @brief Get the action label.  
117 - const gchar * pw3270_action_get_label(GAction *action);  
118 -  
119 - /// @brief Get the action tooltip.  
120 - const gchar * pw3270_action_get_tooltip(GAction *action);  
121 -  
122 - /// @brief Create a button associated with the action.  
123 - //GtkWidget * pw3270_action_button_new(GAction *action, const gchar *action_name);  
124 -  
125 - /// @brief Associate action with the terminal widget.  
126 - void pw3270_action_set_terminal_widget(GAction *action, GtkWidget *terminal);  
127 -  
128 - /// @brief Get lib3270 session handle.  
129 - H3270 * pw3270_action_get_session(GAction *action);  
130 - */  
131 -  
132 - /*  
133 - //  
134 - // "Simple" action  
135 - //  
136 - #define PW3270_TYPE_SIMPLE_ACTION (pw3270SimpleAction_get_type())  
137 - #define PW3270_SIMPLE_ACTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), PW3270_TYPE_SIMPLE_ACTION, pw3270SimpleAction))  
138 - #define PW3270_SIMPLE_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PW3270_TYPE_SIMPLE_ACTION, pw3270SimpleActionClass))  
139 - #define PW3270_IS_SIMPLE_ACTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), PW3270_TYPE_SIMPLE_ACTION))  
140 - #define PW3270_IS_SIMPLE_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PW3270_TYPE_SIMPLE_ACTION))  
141 - #define PW3270_SIMPLE_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PW3270_TYPE_SIMPLE_ACTION, pw3270SimpleActionClass))  
142 -  
143 - typedef struct _pw3270SimpleAction {  
144 -  
145 - pw3270Action parent;  
146 -  
147 - // Fixed data  
148 - const gchar * icon_name;  
149 - const gchar * label;  
150 - const gchar * tooltip;  
151 -  
152 - // Lib3270 Action group  
153 - struct {  
154 - LIB3270_ACTION_GROUP id;  
155 - const void * listener;  
156 - } group;  
157 -  
158 - /// @brief Activation method.  
159 - void (*activate)(GAction *action, GVariant *parameter, GtkWidget *terminal);  
160 -  
161 - } pw3270SimpleAction;  
162 -  
163 - typedef struct _pw3270SimpleActionClass {  
164 -  
165 - pw3270ActionClass parent_class;  
166 -  
167 - } pw3270SimpleActionClass;  
168 -  
169 - GType pw3270SimpleAction_get_type(void) G_GNUC_CONST;  
170 -  
171 - /// @brief Create an empty simple action.  
172 - pw3270SimpleAction * pw3270_simple_action_new();  
173 -  
174 - /// @brief New simple action from LIB3270's control data.  
175 - pw3270SimpleAction * pw3270_simple_action_new_from_lib3270(const LIB3270_ACTION * definition, const gchar *name);  
176 -  
177 - /// @brief New simple action from LIB3270's action name.  
178 - pw3270SimpleAction * pw3270_simple_action_new_from_name(const gchar *source_name, const gchar *name); 82 + } PW3270ActionClass;
179 83
180 - /// @brief Update simple action from LIB3270's property description.  
181 - void pw3270_simple_action_set_lib3270_property(pw3270SimpleAction *action, const LIB3270_PROPERTY * property);  
182 - */ 84 + GType PW3270Action_get_type(void) G_GNUC_CONST;
  85 + PW3270Action * pw3270action_new();
  86 + PW3270Action * pw3270_dialog_action_new(GtkWidget * (*factory)(PW3270Action *action, GtkApplication *application));
183 87
184 // 88 //
185 // Action view 89 // Action view
src/objects/actions/abstract.c
1 /* 1 /*
2 - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 2 + * "Software v3270, 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 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. 4 * aplicativos mainframe. Registro no INPI sob o nome G3270.
5 * 5 *
@@ -28,34 +28,37 @@ @@ -28,34 +28,37 @@
28 */ 28 */
29 29
30 #include "private.h" 30 #include "private.h"
31 - #include <v3270.h>  
32 -  
33 - /*  
34 -  
35 - static void pw3270_action_iface_init(GActionInterface *iface);  
36 - static void pw3270Action_class_init(pw3270ActionClass *klass);  
37 - static void pw3270Action_init(pw3270Action *action);  
38 - static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);  
39 - static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);  
40 - static gboolean get_enabled(GAction *action);  
41 - static void activate(GAction *action, GVariant *parameter);  
42 -  
43 - static void change_widget(GAction *action, GtkWidget *from, GtkWidget *to);  
44 - static const gchar *get_null(GAction *action);  
45 -  
46 - static void finalize(GObject *object);  
47 -  
48 - static const GVariantType * get_state_type(GAction *action);  
49 - static GVariant * get_state_property(GAction *action);  
50 -  
51 - static GVariant * internal_get_state_property(GAction *action, GtkWidget *terminal);  
52 - static gboolean internal_get_enabled(GAction *action, GtkWidget *terminal);  
53 - static void internal_activate(GAction *action, GVariant *parameter, GtkWidget *terminal);  
54 - static GVariant * internal_get_state_hint(GAction *action, GtkWidget *terminal);  
55 -  
56 - static const GVariantType * get_parameter_type(GAction *action);  
57 - static GVariant * get_state_hint(GAction *action);  
58 - static void change_state(GAction *action, GVariant *value); 31 + #include <pw3270/actions.h>
  32 +
  33 + static void PW3270_action_iface_init(GActionInterface *iface);
  34 + static void PW3270Action_class_init(PW3270ActionClass *klass);
  35 + static void PW3270Action_init(PW3270Action *action);
  36 +
  37 + static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
  38 + static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
  39 +
  40 + static const gchar * get_icon_name(GAction *action);
  41 + static const gchar * get_label(GAction *action);
  42 + static const gchar * get_tooltip(GAction *action);
  43 + static const gchar * get_name(GAction *action);
  44 + static const GVariantType * get_state_type(GAction *action);
  45 + static const GVariantType * get_parameter_type(GAction *object);
  46 +
  47 + static void finalize(GObject *object);
  48 +
  49 + static gboolean get_enabled(GAction *action);
  50 + static void activate(GAction *action, GVariant *parameter, GtkApplication *application);
  51 + static GVariant * get_state(GAction *action);
  52 +
  53 + static const gchar * iface_get_name(GAction *action);
  54 + static const GVariantType * iface_get_parameter_type(GAction *action);
  55 + static GVariant * iface_get_state_hint(GAction *action);
  56 + static const GVariantType * iface_get_state_type(GAction *action);
  57 + static GVariant * iface_get_state(GAction *action);
  58 + static gboolean iface_get_enabled(GAction *action);
  59 + static GVariant * iface_get_state(GAction *object);
  60 + static void iface_change_state(GAction *object, GVariant *value);
  61 + static void iface_activate(GAction *object, GVariant *parameter);
59 62
60 enum { 63 enum {
61 PROP_NONE, 64 PROP_NONE,
@@ -64,40 +67,24 @@ @@ -64,40 +67,24 @@
64 PROP_ENABLED, 67 PROP_ENABLED,
65 PROP_STATE_TYPE, 68 PROP_STATE_TYPE,
66 PROP_STATE, 69 PROP_STATE,
67 - PROP_TOOLBAR_ICON,  
68 PROP_ICON_NAME, 70 PROP_ICON_NAME,
69 PROP_LABEL, 71 PROP_LABEL,
70 PROP_TOOLTIP 72 PROP_TOOLTIP
71 }; 73 };
72 74
73 - G_DEFINE_TYPE_WITH_CODE(pw3270Action, pw3270Action, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE(G_TYPE_ACTION, pw3270_action_iface_init))  
74 -  
75 - void pw3270_action_iface_init(GActionInterface *iface) {  
76 - iface->get_name = pw3270_action_get_name;  
77 - iface->get_parameter_type = get_parameter_type;  
78 - iface->get_state_type = get_state_type;  
79 - iface->get_state_hint = get_state_hint;  
80 - iface->get_enabled = get_enabled;  
81 - iface->get_state = get_state_property;  
82 - iface->change_state = change_state;  
83 - iface->activate = activate;  
84 - } 75 + G_DEFINE_TYPE_WITH_CODE(PW3270Action, PW3270Action, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE(G_TYPE_ACTION, PW3270_action_iface_init))
85 76
86 - void pw3270Action_class_init(pw3270ActionClass *klass) { 77 + void PW3270Action_class_init(PW3270ActionClass *klass) {
87 78
88 GObjectClass *object_class = G_OBJECT_CLASS(klass); 79 GObjectClass *object_class = G_OBJECT_CLASS(klass);
89 80
90 debug("%s",__FUNCTION__); 81 debug("%s",__FUNCTION__);
91 82
92 - klass->change_widget = change_widget;  
93 - klass->get_enabled = internal_get_enabled;  
94 - klass->get_icon_name = get_null;  
95 - klass->get_label = get_null;  
96 - klass->get_tooltip = get_null; 83 + klass->get_enabled = get_enabled;
97 84
98 object_class->finalize = finalize; 85 object_class->finalize = finalize;
99 - object_class->set_property = set_property;  
100 object_class->get_property = get_property; 86 object_class->get_property = get_property;
  87 + object_class->set_property = set_property;
101 88
102 // Install properties 89 // Install properties
103 g_object_class_install_property(object_class, PROP_NAME, 90 g_object_class_install_property(object_class, PROP_NAME,
@@ -106,7 +93,7 @@ @@ -106,7 +93,7 @@
106 N_("Action Name"), 93 N_("Action Name"),
107 N_("The name used to invoke the action"), 94 N_("The name used to invoke the action"),
108 NULL, 95 NULL,
109 - G_PARAM_STATIC_NAME| G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); 96 + G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
110 97
111 g_object_class_install_property(object_class, PROP_ICON_NAME, 98 g_object_class_install_property(object_class, PROP_ICON_NAME,
112 g_param_spec_string ( 99 g_param_spec_string (
@@ -114,15 +101,7 @@ @@ -114,15 +101,7 @@
114 N_("Icon Name"), 101 N_("Icon Name"),
115 N_("The name of the icon associated with the action"), 102 N_("The name of the icon associated with the action"),
116 NULL, 103 NULL,
117 - G_PARAM_STATIC_NAME| G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));  
118 -  
119 - g_object_class_install_property(object_class, PROP_TOOLBAR_ICON,  
120 - g_param_spec_object (  
121 - "toolbar-icon",  
122 - N_("Icon pixbuf"),  
123 - N_("A image widget with the action icon"),  
124 - GTK_TYPE_IMAGE,  
125 - G_PARAM_STATIC_NAME| G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE)); 104 + G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
126 105
127 g_object_class_install_property(object_class, PROP_LABEL, 106 g_object_class_install_property(object_class, PROP_LABEL,
128 g_param_spec_string ( 107 g_param_spec_string (
@@ -130,7 +109,7 @@ @@ -130,7 +109,7 @@
130 N_("The action label"), 109 N_("The action label"),
131 N_("The label for the action"), 110 N_("The label for the action"),
132 NULL, 111 NULL,
133 - G_PARAM_STATIC_NAME| G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); 112 + G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
134 113
135 g_object_class_install_property(object_class, PROP_TOOLTIP, 114 g_object_class_install_property(object_class, PROP_TOOLTIP,
136 g_param_spec_string ( 115 g_param_spec_string (
@@ -138,7 +117,7 @@ @@ -138,7 +117,7 @@
138 N_("The action tooltip"), 117 N_("The action tooltip"),
139 N_("The tooltip for the action"), 118 N_("The tooltip for the action"),
140 NULL, 119 NULL,
141 - G_PARAM_STATIC_NAME| G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); 120 + G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
142 121
143 g_object_class_install_property (object_class, PROP_PARAMETER_TYPE, 122 g_object_class_install_property (object_class, PROP_PARAMETER_TYPE,
144 g_param_spec_boxed ("parameter-type", 123 g_param_spec_boxed ("parameter-type",
@@ -152,7 +131,7 @@ @@ -152,7 +131,7 @@
152 N_("State Type"), 131 N_("State Type"),
153 N_("The type of the state kept by the action"), 132 N_("The type of the state kept by the action"),
154 G_TYPE_VARIANT_TYPE, 133 G_TYPE_VARIANT_TYPE,
155 - G_PARAM_STATIC_NAME| G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); 134 + G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
156 135
157 // Enabled property 136 // Enabled property
158 klass->properties.enabled = 137 klass->properties.enabled =
@@ -161,7 +140,7 @@ @@ -161,7 +140,7 @@
161 N_("Enabled"), 140 N_("Enabled"),
162 N_("If the action can be activated"), 141 N_("If the action can be activated"),
163 TRUE, 142 TRUE,
164 - G_PARAM_STATIC_NAME| G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS 143 + G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS
165 ); 144 );
166 145
167 g_object_class_install_property(object_class, PROP_ENABLED, klass->properties.enabled); 146 g_object_class_install_property(object_class, PROP_ENABLED, klass->properties.enabled);
@@ -174,34 +153,21 @@ @@ -174,34 +153,21 @@
174 N_("The state the action is in"), 153 N_("The state the action is in"),
175 G_VARIANT_TYPE_ANY, 154 G_VARIANT_TYPE_ANY,
176 NULL, 155 NULL,
177 - G_PARAM_STATIC_NAME| G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS 156 + G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS
178 ); 157 );
179 158
180 g_object_class_install_property (object_class, PROP_STATE, klass->properties.state); 159 g_object_class_install_property (object_class, PROP_STATE, klass->properties.state);
181 160
182 } 161 }
183 162
184 - void pw3270Action_init(pw3270Action *action) {  
185 -  
186 - action->terminal = NULL;  
187 - action->types.parameter = NULL;  
188 -  
189 - action->activate = internal_activate;  
190 - action->get_state_property = internal_get_state_property;  
191 - action->get_state_hint = internal_get_state_hint;  
192 - 163 + void PW3270Action_init(PW3270Action *action) {
  164 + action->activate = activate;
193 } 165 }
194 166
195 void finalize(GObject *object) { 167 void finalize(GObject *object) {
196 168
197 - pw3270Action * action = PW3270_ACTION(object);  
198 -  
199 - if(action->terminal) {  
200 - pw3270_action_set_terminal_widget(G_ACTION(object),NULL);  
201 - action->terminal = NULL;  
202 - }  
203 -  
204 - G_OBJECT_CLASS(pw3270Action_parent_class)->finalize(object); 169 + // PW3270Action * action = PW3270_ACTION(object);
  170 + G_OBJECT_CLASS(PW3270Action_parent_class)->finalize(object);
205 171
206 } 172 }
207 173
@@ -209,27 +175,21 @@ @@ -209,27 +175,21 @@
209 175
210 GAction *action = G_ACTION(object); 176 GAction *action = G_ACTION(object);
211 177
212 -// debug("%s(%d)",__FUNCTION__,prop_id);  
213 -  
214 switch (prop_id) { 178 switch (prop_id) {
215 case PROP_NAME: 179 case PROP_NAME:
216 - g_value_set_string(value, pw3270_action_get_name(action)); 180 + g_value_set_string(value, g_action_get_name(action));
217 break; 181 break;
218 182
219 case PROP_ICON_NAME: 183 case PROP_ICON_NAME:
220 - g_value_set_string(value, pw3270_action_get_icon_name(action));  
221 - break;  
222 -  
223 - case PROP_TOOLBAR_ICON:  
224 - g_value_set_object(value, pw3270_action_get_image(action,GTK_ICON_SIZE_LARGE_TOOLBAR)); 184 + g_value_set_string(value, get_icon_name(action));
225 break; 185 break;
226 186
227 case PROP_LABEL: 187 case PROP_LABEL:
228 - g_value_set_string(value, pw3270_action_get_label(action)); 188 + g_value_set_string(value, get_label(action));
229 break; 189 break;
230 190
231 case PROP_TOOLTIP: 191 case PROP_TOOLTIP:
232 - g_value_set_string(value, pw3270_action_get_tooltip(action)); 192 + g_value_set_string(value, get_tooltip(action));
233 break; 193 break;
234 194
235 case PROP_PARAMETER_TYPE: 195 case PROP_PARAMETER_TYPE:
@@ -245,37 +205,7 @@ @@ -245,37 +205,7 @@
245 break; 205 break;
246 206
247 case PROP_STATE: 207 case PROP_STATE:
248 - g_value_take_variant(value, get_state_property(action));  
249 - break;  
250 -  
251 - default:  
252 - g_assert_not_reached ();  
253 - }  
254 -  
255 - }  
256 -  
257 - void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec G_GNUC_UNUSED(*pspec)) {  
258 -  
259 -// debug("%s(%d)",__FUNCTION__,prop_id);  
260 -  
261 - GAction *action = G_ACTION(object);  
262 -  
263 - switch (prop_id)  
264 - {  
265 - case PROP_NAME:  
266 - pw3270_action_set_name(action, g_value_get_string(value));  
267 - break;  
268 -  
269 - case PROP_PARAMETER_TYPE:  
270 -// action->parameter_type = g_value_dup_boxed (value);  
271 - break;  
272 -  
273 - case PROP_ENABLED:  
274 -// action->enabled = g_value_get_boolean (value);  
275 - break;  
276 -  
277 - case PROP_STATE:  
278 -// pw3270_action_set_state(action, g_value_get_variant(value)); 208 + g_value_take_variant(value, get_state(action));
279 break; 209 break;
280 210
281 default: 211 default:
@@ -284,278 +214,148 @@ @@ -284,278 +214,148 @@
284 214
285 } 215 }
286 216
287 - const gchar * pw3270_action_get_name(GAction *action) {  
288 - return PW3270_ACTION(action)->name;  
289 - }  
290 -  
291 - void pw3270_action_set_name(GAction *action, const gchar *name) {  
292 - PW3270_ACTION(action)->name = g_intern_string(name);  
293 - }  
294 -  
295 - GVariant * internal_get_state_hint(GAction G_GNUC_UNUSED(*action), GtkWidget G_GNUC_UNUSED(*terminal)) {  
296 - return NULL;  
297 - }  
298 -  
299 - GVariant * internal_get_state_property(GAction *object, GtkWidget G_GNUC_UNUSED(*terminal)) {  
300 -  
301 - pw3270Action * action = PW3270_ACTION(object);  
302 -  
303 - if(action->types.state == G_VARIANT_TYPE_BOOLEAN)  
304 - return g_variant_new_boolean(FALSE);  
305 -  
306 - return NULL;  
307 - }  
308 -  
309 - GVariant * get_state_property(GAction *object) {  
310 -  
311 - pw3270Action * action = PW3270_ACTION(object);  
312 - GVariant * state;  
313 -  
314 - if(action->terminal)  
315 - state = action->get_state_property(object,action->terminal);  
316 - else  
317 - state = internal_get_state_property(object,NULL);  
318 -  
319 - if(state)  
320 - g_variant_ref(state);  
321 -  
322 - return state;  
323 - }  
324 -  
325 - const GVariantType * get_parameter_type(GAction *action) {  
326 - return PW3270_ACTION(action)->types.parameter;  
327 - }  
328 -  
329 - const GVariantType * get_state_type(GAction *object) {  
330 - return PW3270_ACTION(object)->types.state;  
331 - }  
332 -  
333 - GVariant * get_state_hint(GAction *object) {  
334 - pw3270Action *action = PW3270_ACTION(object);  
335 - return action->get_state_hint(object,action->terminal);  
336 - }  
337 -  
338 - void change_state(GAction G_GNUC_UNUSED(*object), GVariant G_GNUC_UNUSED(*value)) {  
339 - debug("%s",__FUNCTION__) 217 + void set_property(GObject G_GNUC_UNUSED(*object), guint G_GNUC_UNUSED(prop_id), const GValue G_GNUC_UNUSED(*value), GParamSpec *pspec) {
  218 +// g_message("Action %s property %s is read-only",g_action_get_name(G_ACTION(object)),pspec->name);
340 } 219 }
341 220
342 static gboolean bg_notify_enabled(GObject *action) { 221 static gboolean bg_notify_enabled(GObject *action) {
343 - // debug("%s(%s,%s)",__FUNCTION__,g_action_get_name(G_ACTION(action)),(g_action_get_enabled(G_ACTION(action)) ? "enabled" : "disabled")); 222 + debug("%s(%s,%s)",__FUNCTION__,g_action_get_name(G_ACTION(action)),(g_action_get_enabled(G_ACTION(action)) ? "enabled" : "disabled"));
344 g_object_notify(action, "enabled"); 223 g_object_notify(action, "enabled");
345 return FALSE; 224 return FALSE;
346 } 225 }
347 226
348 - void pw3270_action_notify_enabled(GAction *action) {  
349 - g_idle_add((GSourceFunc) bg_notify_enabled, G_OBJECT(action));  
350 - }  
351 -  
352 static gboolean bg_notify_state(GObject *action) { 227 static gboolean bg_notify_state(GObject *action) {
353 g_object_notify(action, "state"); 228 g_object_notify(action, "state");
354 return FALSE; 229 return FALSE;
355 } 230 }
356 231
357 - void pw3270_action_notify_state(GAction *action) {  
358 - g_idle_add((GSourceFunc) bg_notify_state, G_OBJECT(action)); 232 + void pw3270_action_notify_enabled(GAction *action) {
  233 + g_idle_add((GSourceFunc) bg_notify_enabled, G_OBJECT(action));
359 } 234 }
360 235
361 - static void change_widget(GAction *object, GtkWidget *from, GtkWidget *to) {  
362 -  
363 - if(from != to) {  
364 -  
365 - pw3270Action *action = PW3270_ACTION(object);  
366 -  
367 - action->terminal = to;  
368 -  
369 - pw3270_action_notify_enabled(object);  
370 -  
371 - if(action->types.state)  
372 - pw3270_action_notify_state(object);  
373 -  
374 - }  
375 - 236 + void pw3270_action_notify_state(GAction *action) {
  237 + if(g_action_get_state_type(action))
  238 + g_idle_add((GSourceFunc) bg_notify_state, G_OBJECT(action));
376 } 239 }
377 240
378 - void pw3270_action_set_terminal_widget(GAction *object, GtkWidget *widget) {  
379 -  
380 - g_return_if_fail(PW3270_IS_ACTION(object));  
381 -  
382 - if(widget) {  
383 - g_return_if_fail(GTK_IS_V3270(widget));  
384 - }  
385 -  
386 - pw3270Action * action = PW3270_ACTION(object);  
387 -  
388 - if(action->terminal != widget) {  
389 - PW3270_ACTION_GET_CLASS(object)->change_widget(object,action->terminal,widget);  
390 - action->terminal = widget;  
391 - }  
392 - 241 + gboolean get_enabled(GAction G_GNUC_UNUSED(*object)) {
  242 + return TRUE;
393 } 243 }
394 244
395 - gboolean get_enabled(GAction *object) {  
396 -  
397 - gboolean enabled = FALSE;  
398 -  
399 - pw3270Action * action = PW3270_ACTION(object);  
400 -  
401 - if(action && action->terminal) {  
402 - enabled = PW3270_ACTION_GET_CLASS(object)->get_enabled(object,action->terminal);  
403 -// debug("Action %s is %s",g_action_get_name(object),enabled ? "enabled" : "disabled");  
404 - }  
405 -  
406 - return enabled; 245 + void activate(GAction *action, GVariant G_GNUC_UNUSED(*parameter), GtkApplication G_GNUC_UNUSED(*application)) {
  246 + g_message("Action %s can't be activated",g_action_get_name(action));
  247 + }
407 248
  249 + //
  250 + // Action methods.
  251 + //
  252 + GAction * pw3270_action_new() {
  253 + return G_ACTION(g_object_new(PW3270_TYPE_ACTION, NULL));
408 } 254 }
409 255
410 - void activate(GAction *object, GVariant *parameter) { 256 + GdkPixbuf * pw3270_action_get_pixbuf(GAction *action, GtkIconSize icon_size, GtkIconLookupFlags flags) {
411 257
412 - pw3270Action * action = PW3270_ACTION(object); 258 + const gchar * icon_name = v3270_action_get_icon_name(action);
413 259
414 - debug("%s: terminal=%p",__FUNCTION__,action->terminal); 260 + if(!icon_name)
  261 + return NULL;
415 262
416 - if(action && action->terminal) {  
417 - action->activate(object,parameter,action->terminal);  
418 - } 263 + return gtk_icon_theme_load_icon(
  264 + gtk_icon_theme_get_default(),
  265 + icon_name,
  266 + icon_size,
  267 + flags,
  268 + NULL
  269 + );
419 270
420 } 271 }
421 272
422 - gboolean internal_get_enabled(GAction G_GNUC_UNUSED(*object), GtkWidget *terminal) {  
423 - return terminal != NULL; 273 +//
  274 +// Default methods.
  275 +//
  276 + GVariant * get_state(GAction G_GNUC_UNUSED(*object)) {
  277 + return g_variant_new_boolean(TRUE);
424 } 278 }
425 279
426 - void internal_activate(GAction *action, GVariant G_GNUC_UNUSED(*parameter), GtkWidget G_GNUC_UNUSED(*terminal)) {  
427 - debug("%s",__FUNCTION__);  
428 - g_message("Action %s can't be activated",pw3270_action_get_name(action)); 280 +//
  281 +// Interface Methods.
  282 +//
  283 + void PW3270_action_iface_init(GActionInterface *iface) {
  284 + iface->get_name = iface_get_name;
  285 + iface->get_parameter_type = iface_get_parameter_type;
  286 + iface->get_state_type = iface_get_state_type;
  287 + iface->get_state_hint = iface_get_state_hint;
  288 + iface->get_enabled = iface_get_enabled;
  289 + iface->get_state = iface_get_state;
  290 + iface->change_state = iface_change_state;
  291 + iface->activate = iface_activate;
429 } 292 }
430 293
431 - const gchar * get_null(GAction G_GNUC_UNUSED(*action)) {  
432 - return NULL; 294 + const gchar * iface_get_name(GAction *action) {
  295 + return get_name(action);
433 } 296 }
434 297
435 - const gchar * pw3270_action_get_icon_name(GAction *action) {  
436 - return PW3270_ACTION_GET_CLASS(action)->get_icon_name(action);  
437 - } 298 + GVariant * iface_get_state(GAction *object) {
438 299
439 - GtkImage * pw3270_action_get_image(GAction *action, GtkIconSize icon_size) { 300 + GVariant * state = NULL;
440 301
441 - const gchar * icon_name = pw3270_action_get_icon_name(action);  
442 - if(!icon_name)  
443 - return NULL; 302 + if(g_action_get_state_type(object)) {
444 303
445 - return GTK_IMAGE(gtk_image_new_from_icon_name(icon_name,icon_size));  
446 - } 304 + state = get_state(object);
447 305
  306 + if(state)
  307 + g_variant_ref(state);
448 308
449 - const gchar * pw3270_action_get_label(GAction *action) {  
450 - const gchar * label = PW3270_ACTION_GET_CLASS(action)->get_label(action); 309 + }
451 310
452 - if(label)  
453 - return gettext(label); 311 + return state;
454 312
455 - return NULL;  
456 } 313 }
457 314
458 - const gchar * pw3270_action_get_tooltip(GAction *action) {  
459 - const gchar * tooltip = PW3270_ACTION_GET_CLASS(action)->get_tooltip(action); 315 + const GVariantType * iface_get_parameter_type(GAction *object) {
  316 + return get_parameter_type(object);
  317 + }
460 318
461 - if(tooltip)  
462 - return gettext(tooltip); 319 + const GVariantType * iface_get_state_type(GAction *object) {
  320 + return get_state_type(object);
  321 + }
463 322
  323 + GVariant * iface_get_state_hint(GAction G_GNUC_UNUSED(*object)) {
464 return NULL; 324 return NULL;
465 } 325 }
466 326
467 - H3270 * pw3270_action_get_session(GAction *action) {  
468 - return v3270_get_session(PW3270_ACTION(action)->terminal); 327 + void iface_change_state(GAction G_GNUC_UNUSED(*object), GVariant G_GNUC_UNUSED(*value)) {
  328 + debug("%s",__FUNCTION__);
469 } 329 }
470 330
471 - GAction * pw3270_action_new() {  
472 - return G_ACTION(g_object_new(PW3270_TYPE_ACTION, NULL)); 331 + gboolean iface_get_enabled(GAction *object) {
  332 + return PW3270_ACTION_GET_CLASS(object)->get_enabled(object);
473 } 333 }
474 334
475 - gchar * g_action_get_text(GAction *action, const gchar * property_name) {  
476 - gchar *rc = NULL;  
477 -  
478 - GValue value = G_VALUE_INIT;  
479 - g_value_init(&value, G_TYPE_STRING);  
480 - g_object_get_property(G_OBJECT(action),property_name,&value);  
481 -  
482 - const gchar * text = g_value_get_string(&value);  
483 - if(text)  
484 - rc = g_strdup(text);  
485 -  
486 - g_value_unset(&value);  
487 -  
488 - return rc;  
489 - 335 + void iface_activate(GAction *object, GVariant *parameter) {
  336 + PW3270_ACTION(object)->activate(object,parameter,GTK_APPLICATION(g_application_get_default()));
490 } 337 }
491 338
492 - gchar * g_action_get_tooltip(GAction *action) {  
493 - return g_action_get_text(action, "tooltip"); 339 + const gchar * get_icon_name(GAction *action) {
  340 + return PW3270_ACTION(action)->icon_name;
494 } 341 }
495 342
496 - gchar * g_action_get_label(GAction *action) {  
497 - return g_action_get_text(action, "label"); 343 + const gchar * get_label(GAction *action) {
  344 + return PW3270_ACTION(action)->label;
498 } 345 }
499 346
500 - gchar * g_action_get_icon_name(GAction *action) {  
501 - return g_action_get_text(action, "icon-name"); 347 + const gchar * get_tooltip(GAction *action) {
  348 + return PW3270_ACTION(action)->tooltip;
502 } 349 }
503 350
504 - static GdkPixbuf * pixbuf_from_icon_name(GValue *value, gint width, gint G_GNUC_UNUSED(height), GtkIconLookupFlags flags) {  
505 -  
506 - const gchar * icon_name = g_value_get_string(value);  
507 -  
508 - if(!icon_name)  
509 - return NULL;  
510 -  
511 - return gtk_icon_theme_load_icon(  
512 - gtk_icon_theme_get_default(),  
513 - icon_name,  
514 - width,  
515 - flags, // GTK_ICON_LOOKUP_GENERIC_FALLBACK,  
516 - NULL  
517 - );  
518 - 351 + const gchar * get_name(GAction *action) {
  352 + return PW3270_ACTION(action)->name;
519 } 353 }
520 354
521 - GdkPixbuf * g_action_get_pixbuf(GAction *action, GtkIconSize icon_size, GtkIconLookupFlags flags) {  
522 -  
523 - struct Properties {  
524 - const gchar * name;  
525 - GType value_type;  
526 - GdkPixbuf * (*translate)(GValue *value, gint width, gint height, GtkIconLookupFlags flags);  
527 - } properties[] = {  
528 - {  
529 - .name = "icon-name",  
530 - .value_type = G_TYPE_STRING,  
531 - .translate = pixbuf_from_icon_name  
532 - }  
533 - };  
534 -  
535 - size_t ix;  
536 - GdkPixbuf * pixbuf = NULL;  
537 - gint width, height;  
538 -  
539 - gtk_icon_size_lookup(icon_size,&width,&height);  
540 -  
541 - for(ix = 0; ix < G_N_ELEMENTS(properties) && !pixbuf; ix++) {  
542 -  
543 - GParamSpec *spec = g_object_class_find_property(G_OBJECT_GET_CLASS(action),properties[ix].name);  
544 - if(spec && spec->value_type == properties[ix].value_type && (spec->flags & G_PARAM_READABLE) != 0) {  
545 -  
546 - GValue value = G_VALUE_INIT;  
547 - g_value_init(&value, properties[ix].value_type);  
548 -  
549 - g_object_get_property(G_OBJECT(action),properties[ix].name,&value);  
550 -  
551 - pixbuf = properties[ix].translate(&value,width,height,flags);  
552 -  
553 - g_value_unset(&value);  
554 -  
555 - }  
556 -  
557 - } 355 + const GVariantType * get_state_type(GAction G_GNUC_UNUSED(*object)) {
  356 + return NULL;
  357 + }
558 358
559 - return pixbuf; 359 + const GVariantType * get_parameter_type(GAction G_GNUC_UNUSED(*object)) {
  360 + return NULL;
560 } 361 }
561 -*/  
src/objects/actions/dialog.c
@@ -32,95 +32,100 @@ @@ -32,95 +32,100 @@
32 * 32 *
33 */ 33 */
34 34
35 - /*  
36 #include "private.h" 35 #include "private.h"
37 - #include <v3270.h>  
38 - #include <v3270/settings.h> 36 + #include <pw3270/actions.h>
39 37
40 - static void pw3270DialogAction_class_init(pw3270DialogActionClass *klass);  
41 - static void pw3270DialogAction_init(pw3270DialogAction *action);  
42 - static void activate(GAction G_GNUC_UNUSED(*action), GVariant G_GNUC_UNUSED(*parameter), GtkWidget *terminal); 38 + typedef struct _PW3270DialogAction {
43 39
44 - struct _pw3270DialogAction {  
45 -  
46 - pw3270SimpleAction parent; 40 + PW3270Action parent;
47 41
48 GtkWidget * dialog; 42 GtkWidget * dialog;
49 - GtkWidget * (*factory)(pw3270SimpleAction *, GtkWidget *);  
50 -  
51 - }; 43 + GtkWidget * (*factory)(PW3270Action *, GtkApplication *);
52 44
53 - struct _pw3270DialogActionClass { 45 + } PW3270DialogAction;
54 46
55 - pw3270SimpleActionClass parent_class; 47 + typedef struct _PW3270DialogActionClass {
56 48
57 - }; 49 + PW3270ActionClass parent_class;
58 50
59 - G_DEFINE_TYPE(pw3270DialogAction, pw3270DialogAction, PW3270_TYPE_SIMPLE_ACTION); 51 + } PW3270DialogActionClass;
60 52
61 - static gboolean get_enabled(GAction *action, GtkWidget *terminal) {  
62 -  
63 - if((PW3270_DIALOG_ACTION(action)->dialog)) {  
64 - return FALSE;  
65 - } 53 + #define PW3270_TYPE_DIALOG_ACTION (PW3270DialogAction_get_type())
  54 + #define PW3270_DIALOG_ACTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), PW3270_TYPE_DIALOG_ACTION, PW3270DialogAction))
  55 + #define PW3270_DIALOG_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PW3270_TYPE_DIALOG_ACTION, PW3270DialogActionClass))
  56 + #define PW3270_IS_DIALOG_ACTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), PW3270_TYPE_DIALOG_ACTION))
  57 + #define PW3270_IS_DIALOG_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PW3270_TYPE_DIALOG_ACTION))
  58 + #define PW3270_DIALOG_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PW3270_TYPE_DIALOG_ACTION, PW3270DialogActionClass))
66 59
67 - if(terminal) {  
68 - return lib3270_action_group_get_activatable(v3270_get_session(terminal),PW3270_SIMPLE_ACTION(action)->group.id);  
69 - } 60 + static void PW3270DialogAction_class_init(PW3270DialogActionClass *klass);
  61 + static void PW3270DialogAction_init(PW3270DialogAction *action);
  62 + static void activate(GAction *action, GVariant *parameter, GtkApplication *application);
  63 + static GtkWidget * factory(PW3270Action *action, GtkApplication *application);
  64 + static gboolean get_enabled(GAction *action);
70 65
71 - return FALSE; 66 + G_DEFINE_TYPE(PW3270DialogAction, PW3270DialogAction, PW3270_TYPE_ACTION);
72 67
  68 + PW3270Action * pw3270_dialog_action_new(GtkWidget * (*factory)(PW3270Action *, GtkApplication *application)) {
  69 + PW3270DialogAction *action = PW3270_DIALOG_ACTION(g_object_new(PW3270_TYPE_DIALOG_ACTION, NULL));
  70 + action->parent.activate = activate;
  71 + action->factory = factory;
  72 + return PW3270_ACTION(action);
73 } 73 }
74 74
75 - static void pw3270DialogAction_class_init(pw3270DialogActionClass *klass) {  
76 - klass->parent_class.parent_class.get_enabled = get_enabled; 75 + void PW3270DialogAction_class_init(PW3270DialogActionClass *klass) {
  76 + klass->parent_class.get_enabled = get_enabled;
77 } 77 }
78 78
79 - static void pw3270DialogAction_init(pw3270DialogAction *action) {  
80 -  
81 - action->dialog = NULL;  
82 - action->parent.parent.activate = activate; 79 + void PW3270DialogAction_init(PW3270DialogAction *action) {
  80 + action->factory = factory;
  81 + }
83 82
  83 + GtkWidget * factory(PW3270Action *action, GtkApplication G_GNUC_UNUSED(*application)) {
  84 + g_warning("No widget factory for action \"%s\"",g_action_get_name(G_ACTION(action)));
  85 + return NULL;
84 } 86 }
85 87
86 - pw3270SimpleAction * pw3270_dialog_action_new(GtkWidget * (*factory)(pw3270SimpleAction *, GtkWidget *)) { 88 + gboolean get_enabled(GAction *action) {
87 89
88 - pw3270DialogAction * action = (pw3270DialogAction *) g_object_new(PW3270_TYPE_DIALOG_ACTION, NULL);  
89 - action->factory = factory;  
90 - return PW3270_SIMPLE_ACTION(action); 90 + if((PW3270_DIALOG_ACTION(action)->dialog)) {
  91 + return FALSE;
  92 + }
  93 +
  94 + return PW3270_ACTION_CLASS(PW3270DialogAction_parent_class)->get_enabled(action);
91 95
92 } 96 }
93 97
94 - static void on_destroy(GtkWidget *dialog, pw3270DialogAction *action) { 98 +static void on_destroy(GtkWidget *dialog, PW3270DialogAction *action) {
95 99
96 - if(action->dialog == dialog) { 100 + if(action->dialog == dialog) {
97 action->dialog = NULL; 101 action->dialog = NULL;
98 pw3270_action_notify_enabled(G_ACTION(action)); 102 pw3270_action_notify_enabled(G_ACTION(action));
99 - } 103 + }
100 104
101 } 105 }
102 106
103 - void activate(GAction *object, GVariant G_GNUC_UNUSED(*parameter), GtkWidget *terminal) {  
104 -  
105 - if(!GTK_IS_V3270(terminal))  
106 - return; 107 + void activate(GAction *object, GVariant G_GNUC_UNUSED(*parameter), GtkApplication *application) {
107 108
108 - pw3270DialogAction * action = PW3270_DIALOG_ACTION(object); 109 + PW3270DialogAction * action = PW3270_DIALOG_ACTION(object);
109 110
110 - if(action->dialog || !action->factory) 111 + if(action->dialog)
111 return; 112 return;
112 113
113 - action->dialog = action->factory((pw3270SimpleAction *) object, terminal);  
114 - pw3270_action_notify_enabled(G_ACTION(action)); 114 + action->dialog = action->factory(PW3270_ACTION(action), application);
115 115
116 if(action->dialog) { 116 if(action->dialog) {
117 117
  118 + GtkWindow * window = gtk_application_get_active_window(application);
  119 + if(window) {
  120 + gtk_window_set_attached_to(GTK_WINDOW(action->dialog), GTK_WIDGET(window));
  121 + gtk_window_set_transient_for(GTK_WINDOW(action->dialog),window);
  122 + }
  123 +
  124 + pw3270_action_notify_enabled(G_ACTION(action));
118 g_signal_connect(action->dialog,"destroy",G_CALLBACK(on_destroy),action); 125 g_signal_connect(action->dialog,"destroy",G_CALLBACK(on_destroy),action);
119 g_signal_connect(action->dialog,"close",G_CALLBACK(gtk_widget_destroy),NULL); 126 g_signal_connect(action->dialog,"close",G_CALLBACK(gtk_widget_destroy),NULL);
120 - gtk_widget_show_all(GTK_WIDGET(action->dialog)); 127 + gtk_widget_show(GTK_WIDGET(action->dialog));
121 128
122 } 129 }
123 130
124 } 131 }
125 -  
126 -*/  
src/objects/application/actions/about.c
@@ -28,9 +28,10 @@ @@ -28,9 +28,10 @@
28 */ 28 */
29 29
30 #include "../private.h" 30 #include "../private.h"
  31 + #include <pw3270/actions.h>
31 #include <pw3270/application.h> 32 #include <pw3270/application.h>
32 33
33 - void pw3270_application_about_activated(GSimpleAction G_GNUC_UNUSED(* action), GVariant G_GNUC_UNUSED(*parameter), gpointer application) { 34 + static GtkWidget * factory(PW3270Action G_GNUC_UNUSED(*action), GtkApplication G_GNUC_UNUSED(*application)) {
34 35
35 static const gchar *authors[] = 36 static const gchar *authors[] =
36 { 37 {
@@ -119,10 +120,22 @@ @@ -119,10 +120,22 @@
119 gtk_about_dialog_set_authors(dialog,authors); 120 gtk_about_dialog_set_authors(dialog,authors);
120 gtk_about_dialog_set_translator_credits(dialog,_("translator-credits")); 121 gtk_about_dialog_set_translator_credits(dialog,_("translator-credits"));
121 122
122 - g_signal_connect(dialog,"close",G_CALLBACK(gtk_widget_destroy),NULL); 123 + gtk_window_set_modal(GTK_WINDOW(dialog),TRUE);
  124 +
123 g_signal_connect(dialog,"response",G_CALLBACK(gtk_widget_destroy),NULL); 125 g_signal_connect(dialog,"response",G_CALLBACK(gtk_widget_destroy),NULL);
124 gtk_widget_show_all(GTK_WIDGET(dialog)); 126 gtk_widget_show_all(GTK_WIDGET(dialog));
125 127
  128 + return GTK_WIDGET(dialog);
126 129
127 } 130 }
128 131
  132 + GAction * pw3270_about_action_new() {
  133 +
  134 + PW3270Action * action = pw3270_dialog_action_new(factory);
  135 +
  136 + action->name = "about";
  137 + action->label = _("About pw3270");
  138 + action->icon_name = "help-about";
  139 +
  140 + return G_ACTION(action);
  141 + }
src/objects/application/application.c
@@ -321,16 +321,15 @@ @@ -321,16 +321,15 @@
321 321
322 void startup(GApplication *application) { 322 void startup(GApplication *application) {
323 323
  324 + size_t ix;
  325 +
324 G_APPLICATION_CLASS(pw3270Application_parent_class)->startup(application); 326 G_APPLICATION_CLASS(pw3270Application_parent_class)->startup(application);
325 327
  328 + /*
326 // 329 //
327 // Setup application default actions. 330 // Setup application default actions.
328 // 331 //
329 static GActionEntry actions[] = { 332 static GActionEntry actions[] = {
330 - {  
331 - .name = "about",  
332 - .activate = pw3270_application_about_activated,  
333 - },  
334 333
335 { 334 {
336 .name = "preferences", 335 .name = "preferences",
@@ -375,6 +374,15 @@ @@ -375,6 +374,15 @@
375 G_N_ELEMENTS(actions), 374 G_N_ELEMENTS(actions),
376 application 375 application
377 ); 376 );
  377 + */
  378 +
  379 + GAction * actions[] = {
  380 + pw3270_about_action_new()
  381 + };
  382 +
  383 + for(ix = 0; ix < G_N_ELEMENTS(actions); ix++) {
  384 + g_action_map_add_action(G_ACTION_MAP(application),actions[ix]);
  385 + }
378 386
379 // 387 //
380 // Setup application menus 388 // Setup application menus
src/objects/application/private.h
@@ -50,11 +50,12 @@ @@ -50,11 +50,12 @@
50 G_GNUC_INTERNAL GtkWidget * pw3270_terminal_new(const gchar *session_file); 50 G_GNUC_INTERNAL GtkWidget * pw3270_terminal_new(const gchar *session_file);
51 51
52 // Actions 52 // Actions
  53 + G_GNUC_INTERNAL GAction * pw3270_about_action_new();
  54 +
53 G_GNUC_INTERNAL void pw3270_application_generic_activated(GSimpleAction * action, GVariant *parameter, gpointer application); 55 G_GNUC_INTERNAL void pw3270_application_generic_activated(GSimpleAction * action, GVariant *parameter, gpointer application);
54 G_GNUC_INTERNAL void pw3270_application_quit_activated(GSimpleAction * action, GVariant *parameter, gpointer application); 56 G_GNUC_INTERNAL void pw3270_application_quit_activated(GSimpleAction * action, GVariant *parameter, gpointer application);
55 G_GNUC_INTERNAL void pw3270_application_new_tab_activated(GSimpleAction * action, GVariant *parameter, gpointer application); 57 G_GNUC_INTERNAL void pw3270_application_new_tab_activated(GSimpleAction * action, GVariant *parameter, gpointer application);
56 G_GNUC_INTERNAL void pw3270_application_new_window_activated(GSimpleAction * action, GVariant *parameter, gpointer application); 58 G_GNUC_INTERNAL void pw3270_application_new_window_activated(GSimpleAction * action, GVariant *parameter, gpointer application);
57 - G_GNUC_INTERNAL void pw3270_application_about_activated(GSimpleAction * action, GVariant *parameter, gpointer application);  
58 G_GNUC_INTERNAL void pw3270_application_preferences_activated(GSimpleAction * action, GVariant *parameter, gpointer application); 59 G_GNUC_INTERNAL void pw3270_application_preferences_activated(GSimpleAction * action, GVariant *parameter, gpointer application);
59 60
60 G_GNUC_INTERNAL void pw3270_application_open_activated(GSimpleAction * action, GVariant *parameter, gpointer application); 61 G_GNUC_INTERNAL void pw3270_application_open_activated(GSimpleAction * action, GVariant *parameter, gpointer application);