Commit 7449e7afec8d5966abc290b62d9da0a42710a92f

Authored by Perry Werneck
1 parent 9db919ee

Implementing action dialog.

pw3270.cbp
... ... @@ -63,6 +63,9 @@
63 63 <Unit filename="src/objects/actions/connect.c">
64 64 <Option compilerVar="CC" />
65 65 </Unit>
  66 + <Unit filename="src/objects/actions/dialog.c">
  67 + <Option compilerVar="CC" />
  68 + </Unit>
66 69 <Unit filename="src/objects/actions/lib3270/action.c">
67 70 <Option compilerVar="CC" />
68 71 </Unit>
... ...
src/include/pw3270/actions.h
... ... @@ -160,6 +160,22 @@
160 160 /// @brief New simple action from LIB3270's action name.
161 161 pw3270SimpleAction * pw3270_simple_action_new_from_name(const gchar *source_name, const gchar *name);
162 162  
  163 +
  164 + //
  165 + // Dialog action
  166 + //
  167 + #define PW3270_TYPE_DIALOG_ACTION (pw3270DialogAction_get_type())
  168 + #define PW3270_DIALOG_ACTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), PW3270_TYPE_DIALOG_ACTION, pw3270DialogAction))
  169 + #define PW3270_DIALOG_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PW3270_TYPE_DIALOG_ACTION, pw3270DialogActionClass))
  170 + #define PW3270_IS_DIALOG_ACTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), PW3270_TYPE_DIALOG_ACTION))
  171 + #define PW3270_IS_DIALOG_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PW3270_TYPE_DIALOG_ACTION))
  172 + #define PW3270_DIALOG_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PW3270_TYPE_DIALOG_ACTION, pw3270DialogActionClass))
  173 +
  174 + typedef struct _pw3270DialogAction pw3270DialogAction;
  175 + typedef struct _pw3270DialogActionClass pw3270DialogActionClass;
  176 +
  177 + pw3270SimpleAction * pw3270_dialog_action_new(GtkWidget * (*factory)(GtkWidget *));
  178 +
163 179 G_END_DECLS
164 180  
165 181 #endif // PW3270_ACTIONS_H_INCLUDED
... ...
src/objects/window/actions/sethost.c
... ... @@ -33,17 +33,18 @@
33 33 #include <v3270/settings.h>
34 34 #include <v3270/dialogs.h>
35 35  
36   - static void activate(GAction G_GNUC_UNUSED(*action), GVariant G_GNUC_UNUSED(*parameter), GtkWidget *terminal);
  36 + static GtkWidget * factory(GtkWidget *terminal);
37 37  
38 38 GAction * pw3270_set_host_action_new(void) {
39 39  
40   - pw3270Action * action = PW3270_ACTION(pw3270_action_new_from_lib3270(lib3270_action_get_by_name("reconnect")));
  40 + pw3270SimpleAction * action = pw3270_dialog_action_new(factory);
41 41  
42   - action->activate = activate;
43   - action->name = "set.host";
  42 + action->parent.name = "set.host";
  43 + action->group.id = LIB3270_ACTION_GROUP_OFFLINE;
  44 + action->icon_name = "network-server";
  45 + action->label = N_("Configure host");
44 46  
45 47 return G_ACTION(action);
46   -
47 48 }
48 49  
49 50 static void on_response(GtkDialog *dialog, gint response_id, GtkWidget *settings) {
... ... @@ -58,10 +59,7 @@
58 59  
59 60 }
60 61  
61   - void activate(GAction G_GNUC_UNUSED(*action), GVariant G_GNUC_UNUSED(*parameter), GtkWidget *terminal) {
62   -
63   - if(!GTK_IS_V3270(terminal))
64   - return;
  62 + GtkWidget * factory(GtkWidget *terminal) {
65 63  
66 64 GtkWidget * settings = v3270_host_select_new();
67 65 GtkWidget * dialog =
... ... @@ -74,12 +72,11 @@
74 72  
75 73 v3270_dialog_setup(dialog,_("Setup host"),_("C_onnect"));
76 74 gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
77   -
78   - g_signal_connect(dialog,"close",G_CALLBACK(gtk_widget_destroy),NULL);
79 75 g_signal_connect(dialog,"response",G_CALLBACK(on_response),settings);
80 76  
81   - gtk_widget_show_all(dialog);
82 77 }
83 78  
  79 + return dialog;
  80 +
84 81 }
85 82  
... ...