Commit d1bc4ea45d7db3946218fbc3ae8f60c9cc970152
1 parent
a195cce0
Exists in
master
and in
4 other branches
Fixing set host action.
Showing
5 changed files
with
69 additions
and
49 deletions
Show diff stats
src/include/pw3270/actions.h
| ... | ... | @@ -38,6 +38,7 @@ |
| 38 | 38 | |
| 39 | 39 | #include <gio/gio.h> |
| 40 | 40 | #include <lib3270.h> |
| 41 | + #include <lib3270/actions.h> | |
| 41 | 42 | |
| 42 | 43 | G_BEGIN_DECLS |
| 43 | 44 | |
| ... | ... | @@ -48,13 +49,45 @@ |
| 48 | 49 | #define PW3270_IS_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PW3270_TYPE_ACTION)) |
| 49 | 50 | #define PW3270_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PW3270_TYPE_ACTION, pw3270ActionClass)) |
| 50 | 51 | |
| 51 | - typedef struct _pw3270Action pw3270Action; | |
| 52 | - typedef struct _pw3270ActionClass pw3270ActionClass; | |
| 52 | + typedef struct _pw3270Action { | |
| 53 | + | |
| 54 | + GObject parent; | |
| 55 | + | |
| 56 | + const gchar * name; /// @brief Action name (const string). | |
| 57 | + GVariantType * parameter_type; /// @brief Parameter type. | |
| 58 | + GVariant * state; /// @brief Action state. | |
| 59 | + GtkWidget * terminal; /// @brief The active terminal widget. | |
| 60 | + | |
| 61 | + /// @brief Activation method. | |
| 62 | + void (*activate)(GAction *action, GVariant *parameter, GtkWidget *terminal); | |
| 63 | + | |
| 64 | + } pw3270Action; | |
| 65 | + | |
| 66 | + typedef struct _pw3270ActionClass { | |
| 67 | + | |
| 68 | + GObjectClass parent_class; | |
| 69 | + | |
| 70 | + struct { | |
| 71 | + GParamSpec * state; | |
| 72 | + GParamSpec * enabled; | |
| 73 | + } properties; | |
| 74 | + | |
| 75 | + void (*change_widget)(GAction *action, GtkWidget *from, GtkWidget *to); | |
| 76 | + gboolean (*get_enabled)(GAction *action, GtkWidget *terminal); | |
| 77 | + const GVariantType * (*get_parameter_type)(GAction *action); | |
| 78 | + const gchar * (*get_icon_name)(GAction *action); | |
| 79 | + const gchar * (*get_label)(GAction *action); | |
| 80 | + const gchar * (*get_tooltip)(GAction *action); | |
| 81 | + | |
| 82 | + } pw3270ActionClass; | |
| 53 | 83 | |
| 54 | 84 | GType pw3270Action_get_type(void) G_GNUC_CONST; |
| 55 | 85 | |
| 86 | + /// @brief New action from LIB3270's control data. | |
| 87 | + GAction * pw3270_action_new_from_lib3270(const LIB3270_ACTION * definition); | |
| 88 | + | |
| 89 | + /// @brief Get action name. | |
| 56 | 90 | const gchar * pw3270_action_get_name(GAction *action); |
| 57 | - void pw3270_action_set_name(GAction *action, const gchar *name); | |
| 58 | 91 | |
| 59 | 92 | /// @brief Get the action icon name. |
| 60 | 93 | const gchar * pw3270_action_get_icon_name(GAction *action); | ... | ... |
src/objects/actions/private.h
| ... | ... | @@ -51,42 +51,13 @@ |
| 51 | 51 | /* not really I18N-related, but also a string marker macro */ |
| 52 | 52 | #define I_(string) g_intern_static_string (string) |
| 53 | 53 | |
| 54 | - struct _pw3270Action { | |
| 55 | - GObject parent; | |
| 56 | - | |
| 57 | - const gchar * name; | |
| 58 | - GVariantType * parameter_type; | |
| 59 | - GVariant * state; | |
| 60 | - GtkWidget * terminal; | |
| 61 | - | |
| 62 | - void (*activate)(GAction *action, GVariant *parameter, GtkWidget *terminal); | |
| 63 | - | |
| 64 | - }; | |
| 65 | - | |
| 66 | - struct _pw3270ActionClass { | |
| 67 | - GObjectClass parent_class; | |
| 68 | - | |
| 69 | - struct { | |
| 70 | - GParamSpec * state; | |
| 71 | - GParamSpec * enabled; | |
| 72 | - } properties; | |
| 73 | - | |
| 74 | - void (*change_widget)(GAction *action, GtkWidget *from, GtkWidget *to); | |
| 75 | - gboolean (*get_enabled)(GAction *action, GtkWidget *terminal); | |
| 76 | - const GVariantType * (*get_parameter_type)(GAction *action); | |
| 77 | - const gchar * (*get_icon_name)(GAction *action); | |
| 78 | - const gchar * (*get_label)(GAction *action); | |
| 79 | - const gchar * (*get_tooltip)(GAction *action); | |
| 80 | - | |
| 81 | - }; | |
| 82 | - | |
| 83 | - G_GNUC_INTERNAL GAction * pw3270_action_new_from_lib3270(const LIB3270_ACTION * definition); | |
| 84 | 54 | G_GNUC_INTERNAL GAction * pw3270_toggle_action_new_from_lib3270(const LIB3270_TOGGLE * definition); |
| 85 | 55 | G_GNUC_INTERNAL GAction * pw3270_action_new_pfkey(void); |
| 86 | 56 | G_GNUC_INTERNAL GAction * pw3270_action_new_pakey(void); |
| 87 | 57 | |
| 88 | 58 | G_GNUC_INTERNAL void pw3270_action_change_state_boolean(GAction *action, gboolean state); |
| 89 | 59 | G_GNUC_INTERNAL void pw3270_action_notify_enabled(GAction *action); |
| 60 | + G_GNUC_INTERNAL void pw3270_action_set_name(GAction *object, const gchar *name); | |
| 90 | 61 | |
| 91 | 62 | // Internal actions |
| 92 | 63 | G_GNUC_INTERNAL GAction * pw3270_connect_action_new(void); | ... | ... |
src/objects/window/actions/sethost.c
| ... | ... | @@ -29,9 +29,23 @@ |
| 29 | 29 | |
| 30 | 30 | #include "../private.h" |
| 31 | 31 | #include <pw3270/window.h> |
| 32 | + #include <pw3270/actions.h> | |
| 32 | 33 | #include <v3270/settings.h> |
| 33 | 34 | #include <v3270/dialogs.h> |
| 34 | 35 | |
| 36 | + static void activate(GAction G_GNUC_UNUSED(*action), GVariant G_GNUC_UNUSED(*parameter), GtkWidget *terminal); | |
| 37 | + | |
| 38 | + GAction * pw3270_set_host_action_new(void) { | |
| 39 | + | |
| 40 | + pw3270Action * action = PW3270_ACTION(pw3270_action_new_from_lib3270(lib3270_action_get_by_name("reconnect"))); | |
| 41 | + | |
| 42 | + action->activate = activate; | |
| 43 | + action->name = "set.host"; | |
| 44 | + | |
| 45 | + return G_ACTION(action); | |
| 46 | + | |
| 47 | + } | |
| 48 | + | |
| 35 | 49 | static void on_response(GtkDialog *dialog, gint response_id, GtkWidget *settings) { |
| 36 | 50 | |
| 37 | 51 | v3270_settings_on_dialog_response(dialog,response_id,settings); |
| ... | ... | @@ -44,14 +58,8 @@ |
| 44 | 58 | |
| 45 | 59 | } |
| 46 | 60 | |
| 47 | - void pw3270_window_set_host_activated(GSimpleAction G_GNUC_UNUSED(* action), GVariant G_GNUC_UNUSED(*parameter), gpointer window) { | |
| 48 | - | |
| 49 | - debug("%s",__FUNCTION__); | |
| 61 | + void activate(GAction G_GNUC_UNUSED(*action), GVariant G_GNUC_UNUSED(*parameter), GtkWidget *terminal) { | |
| 50 | 62 | |
| 51 | - if(!PW3270_IS_APPLICATION_WINDOW(window)) | |
| 52 | - return; | |
| 53 | - | |
| 54 | - GtkWidget * terminal = gtk_window_get_default_widget(GTK_WINDOW(window)); | |
| 55 | 63 | if(!GTK_IS_V3270(terminal)) |
| 56 | 64 | return; |
| 57 | 65 | |
| ... | ... | @@ -65,8 +73,7 @@ |
| 65 | 73 | if(dialog) { |
| 66 | 74 | |
| 67 | 75 | v3270_dialog_setup(dialog,_("Setup host"),_("C_onnect")); |
| 68 | - | |
| 69 | - gtk_window_set_default_size(GTK_WINDOW(dialog), 700, 150); | |
| 76 | + gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); | |
| 70 | 77 | |
| 71 | 78 | g_signal_connect(dialog,"close",G_CALLBACK(gtk_widget_destroy),NULL); |
| 72 | 79 | g_signal_connect(dialog,"response",G_CALLBACK(on_response),settings); | ... | ... |
src/objects/window/private.h
| ... | ... | @@ -65,10 +65,11 @@ |
| 65 | 65 | G_GNUC_INTERNAL GtkWidget * pw3270_setup_image_button(GtkWidget *button, const gchar *image_name); |
| 66 | 66 | |
| 67 | 67 | // Actions |
| 68 | + GAction * pw3270_set_host_action_new(void); | |
| 69 | + | |
| 68 | 70 | G_GNUC_INTERNAL void pw3270_window_open_activated(GSimpleAction * action, GVariant *parameter, gpointer application); |
| 69 | 71 | G_GNUC_INTERNAL void pw3270_window_close_activated(GSimpleAction * action, GVariant *parameter, gpointer application); |
| 70 | 72 | G_GNUC_INTERNAL void pw3270_window_preferences_activated(GSimpleAction * action, GVariant *parameter, gpointer application); |
| 71 | - G_GNUC_INTERNAL void pw3270_window_set_host_activated(GSimpleAction G_GNUC_UNUSED(* action), GVariant G_GNUC_UNUSED(*parameter), gpointer application); | |
| 72 | 73 | |
| 73 | 74 | |
| 74 | 75 | #endif // PRIVATE_H_INCLUDED | ... | ... |
src/objects/window/window.c
| ... | ... | @@ -95,6 +95,20 @@ |
| 95 | 95 | // |
| 96 | 96 | pw3270_window_add_actions(GTK_WIDGET(widget)); |
| 97 | 97 | |
| 98 | + // Map special actions | |
| 99 | + { | |
| 100 | + size_t ix; | |
| 101 | + | |
| 102 | + GAction * actions[] = { | |
| 103 | + pw3270_set_host_action_new() | |
| 104 | + }; | |
| 105 | + | |
| 106 | + for(ix = 0; ix < G_N_ELEMENTS(actions); ix++) { | |
| 107 | + g_action_map_add_action(G_ACTION_MAP(widget),actions[ix]); | |
| 108 | + } | |
| 109 | + | |
| 110 | + } | |
| 111 | + | |
| 98 | 112 | // |
| 99 | 113 | // Setup Window actions. |
| 100 | 114 | // |
| ... | ... | @@ -115,12 +129,6 @@ |
| 115 | 129 | .activate = pw3270_window_preferences_activated, |
| 116 | 130 | }, |
| 117 | 131 | |
| 118 | - { | |
| 119 | - .name = "set.host", | |
| 120 | - .activate = pw3270_window_set_host_activated, | |
| 121 | - }, | |
| 122 | - | |
| 123 | - | |
| 124 | 132 | }; |
| 125 | 133 | |
| 126 | 134 | g_action_map_add_action_entries( | ... | ... |