diff --git a/src/include/pw3270/actions.h b/src/include/pw3270/actions.h index 492c299..6f622d6 100644 --- a/src/include/pw3270/actions.h +++ b/src/include/pw3270/actions.h @@ -38,6 +38,7 @@ #include #include + #include G_BEGIN_DECLS @@ -48,13 +49,45 @@ #define PW3270_IS_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PW3270_TYPE_ACTION)) #define PW3270_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PW3270_TYPE_ACTION, pw3270ActionClass)) - typedef struct _pw3270Action pw3270Action; - typedef struct _pw3270ActionClass pw3270ActionClass; + typedef struct _pw3270Action { + + GObject parent; + + const gchar * name; /// @brief Action name (const string). + GVariantType * parameter_type; /// @brief Parameter type. + GVariant * state; /// @brief Action state. + GtkWidget * terminal; /// @brief The active terminal widget. + + /// @brief Activation method. + void (*activate)(GAction *action, GVariant *parameter, GtkWidget *terminal); + + } pw3270Action; + + typedef struct _pw3270ActionClass { + + GObjectClass parent_class; + + struct { + GParamSpec * state; + GParamSpec * enabled; + } properties; + + void (*change_widget)(GAction *action, GtkWidget *from, GtkWidget *to); + gboolean (*get_enabled)(GAction *action, GtkWidget *terminal); + const GVariantType * (*get_parameter_type)(GAction *action); + const gchar * (*get_icon_name)(GAction *action); + const gchar * (*get_label)(GAction *action); + const gchar * (*get_tooltip)(GAction *action); + + } pw3270ActionClass; GType pw3270Action_get_type(void) G_GNUC_CONST; + /// @brief New action from LIB3270's control data. + GAction * pw3270_action_new_from_lib3270(const LIB3270_ACTION * definition); + + /// @brief Get action name. const gchar * pw3270_action_get_name(GAction *action); - void pw3270_action_set_name(GAction *action, const gchar *name); /// @brief Get the action icon name. const gchar * pw3270_action_get_icon_name(GAction *action); diff --git a/src/objects/actions/private.h b/src/objects/actions/private.h index 22d9838..e68e31a 100644 --- a/src/objects/actions/private.h +++ b/src/objects/actions/private.h @@ -51,42 +51,13 @@ /* not really I18N-related, but also a string marker macro */ #define I_(string) g_intern_static_string (string) - struct _pw3270Action { - GObject parent; - - const gchar * name; - GVariantType * parameter_type; - GVariant * state; - GtkWidget * terminal; - - void (*activate)(GAction *action, GVariant *parameter, GtkWidget *terminal); - - }; - - struct _pw3270ActionClass { - GObjectClass parent_class; - - struct { - GParamSpec * state; - GParamSpec * enabled; - } properties; - - void (*change_widget)(GAction *action, GtkWidget *from, GtkWidget *to); - gboolean (*get_enabled)(GAction *action, GtkWidget *terminal); - const GVariantType * (*get_parameter_type)(GAction *action); - const gchar * (*get_icon_name)(GAction *action); - const gchar * (*get_label)(GAction *action); - const gchar * (*get_tooltip)(GAction *action); - - }; - - G_GNUC_INTERNAL GAction * pw3270_action_new_from_lib3270(const LIB3270_ACTION * definition); G_GNUC_INTERNAL GAction * pw3270_toggle_action_new_from_lib3270(const LIB3270_TOGGLE * definition); G_GNUC_INTERNAL GAction * pw3270_action_new_pfkey(void); G_GNUC_INTERNAL GAction * pw3270_action_new_pakey(void); G_GNUC_INTERNAL void pw3270_action_change_state_boolean(GAction *action, gboolean state); G_GNUC_INTERNAL void pw3270_action_notify_enabled(GAction *action); + G_GNUC_INTERNAL void pw3270_action_set_name(GAction *object, const gchar *name); // Internal actions G_GNUC_INTERNAL GAction * pw3270_connect_action_new(void); diff --git a/src/objects/window/actions/sethost.c b/src/objects/window/actions/sethost.c index 5b66339..f8650d0 100644 --- a/src/objects/window/actions/sethost.c +++ b/src/objects/window/actions/sethost.c @@ -29,9 +29,23 @@ #include "../private.h" #include + #include #include #include + static void activate(GAction G_GNUC_UNUSED(*action), GVariant G_GNUC_UNUSED(*parameter), GtkWidget *terminal); + + GAction * pw3270_set_host_action_new(void) { + + pw3270Action * action = PW3270_ACTION(pw3270_action_new_from_lib3270(lib3270_action_get_by_name("reconnect"))); + + action->activate = activate; + action->name = "set.host"; + + return G_ACTION(action); + + } + static void on_response(GtkDialog *dialog, gint response_id, GtkWidget *settings) { v3270_settings_on_dialog_response(dialog,response_id,settings); @@ -44,14 +58,8 @@ } - void pw3270_window_set_host_activated(GSimpleAction G_GNUC_UNUSED(* action), GVariant G_GNUC_UNUSED(*parameter), gpointer window) { - - debug("%s",__FUNCTION__); + void activate(GAction G_GNUC_UNUSED(*action), GVariant G_GNUC_UNUSED(*parameter), GtkWidget *terminal) { - if(!PW3270_IS_APPLICATION_WINDOW(window)) - return; - - GtkWidget * terminal = gtk_window_get_default_widget(GTK_WINDOW(window)); if(!GTK_IS_V3270(terminal)) return; @@ -65,8 +73,7 @@ if(dialog) { v3270_dialog_setup(dialog,_("Setup host"),_("C_onnect")); - - gtk_window_set_default_size(GTK_WINDOW(dialog), 700, 150); + gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); g_signal_connect(dialog,"close",G_CALLBACK(gtk_widget_destroy),NULL); g_signal_connect(dialog,"response",G_CALLBACK(on_response),settings); diff --git a/src/objects/window/private.h b/src/objects/window/private.h index f83c721..5804cdb 100644 --- a/src/objects/window/private.h +++ b/src/objects/window/private.h @@ -65,10 +65,11 @@ G_GNUC_INTERNAL GtkWidget * pw3270_setup_image_button(GtkWidget *button, const gchar *image_name); // Actions + GAction * pw3270_set_host_action_new(void); + G_GNUC_INTERNAL void pw3270_window_open_activated(GSimpleAction * action, GVariant *parameter, gpointer application); G_GNUC_INTERNAL void pw3270_window_close_activated(GSimpleAction * action, GVariant *parameter, gpointer application); G_GNUC_INTERNAL void pw3270_window_preferences_activated(GSimpleAction * action, GVariant *parameter, gpointer application); - G_GNUC_INTERNAL void pw3270_window_set_host_activated(GSimpleAction G_GNUC_UNUSED(* action), GVariant G_GNUC_UNUSED(*parameter), gpointer application); #endif // PRIVATE_H_INCLUDED diff --git a/src/objects/window/window.c b/src/objects/window/window.c index f9ced01..0ebfb4d 100644 --- a/src/objects/window/window.c +++ b/src/objects/window/window.c @@ -95,6 +95,20 @@ // pw3270_window_add_actions(GTK_WIDGET(widget)); + // Map special actions + { + size_t ix; + + GAction * actions[] = { + pw3270_set_host_action_new() + }; + + for(ix = 0; ix < G_N_ELEMENTS(actions); ix++) { + g_action_map_add_action(G_ACTION_MAP(widget),actions[ix]); + } + + } + // // Setup Window actions. // @@ -115,12 +129,6 @@ .activate = pw3270_window_preferences_activated, }, - { - .name = "set.host", - .activate = pw3270_window_set_host_activated, - }, - - }; g_action_map_add_action_entries( -- libgit2 0.21.2