From 397032053791e9742fad4e105121099e681237d5 Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Wed, 15 Jan 2020 16:46:03 -0300 Subject: [PATCH] Adjustments in the action object. --- src/include/v3270/actions.h | 14 +++++++------- src/terminal/actions/action.c | 36 ++++++++++++++++++++++-------------- src/terminal/actions/pakey.c | 6 +++++- src/terminal/actions/pfkey.c | 6 +++++- src/terminal/actions/toggle.c | 6 +++++- 5 files changed, 44 insertions(+), 24 deletions(-) diff --git a/src/include/v3270/actions.h b/src/include/v3270/actions.h index c654f9c..fbdb6f2 100644 --- a/src/include/v3270/actions.h +++ b/src/include/v3270/actions.h @@ -138,16 +138,16 @@ 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); - void (*change_widget)(GAction *action, GtkWidget *from, GtkWidget *to); + const gchar * (*translate)(GAction *action, const gchar *text); - gboolean (*get_enabled)(GAction *action, GtkWidget *terminal); + const GVariantType * (*get_state_type)(GAction *object); GVariant * (*get_state)(GAction *action, GtkWidget *terminal); - const gchar * (*translate)(GAction *action, const gchar *text); + + const GVariantType * (*get_parameter_type)(GAction *object); + + gboolean (*get_enabled)(GAction *action, GtkWidget *terminal); const gchar * (*get_name)(GAction *action); const gchar * (*get_icon_name)(GAction *action); diff --git a/src/terminal/actions/action.c b/src/terminal/actions/action.c index 2dfb4dc..2b8ce43 100644 --- a/src/terminal/actions/action.c +++ b/src/terminal/actions/action.c @@ -43,10 +43,12 @@ static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); - static const gchar * get_icon_name(GAction *action); - static const gchar * get_label(GAction *action); - static const gchar * get_tooltip(GAction *action); - static const gchar * get_name(GAction *action); + static const gchar * get_icon_name(GAction *action); + static const gchar * get_label(GAction *action); + static const gchar * get_tooltip(GAction *action); + static const gchar * get_name(GAction *action); + static const GVariantType * get_state_type(GAction *action); + static const GVariantType * get_parameter_type(GAction *object); static void change_widget(GAction *action, GtkWidget *from, GtkWidget *to); static void finalize(GObject *object); @@ -95,9 +97,8 @@ klass->get_icon_name = get_icon_name; klass->get_label = get_label; klass->get_tooltip = get_tooltip; - - klass->type.state = NULL; - klass->type.parameter = NULL; + klass->get_state_type = get_state_type; + klass->get_parameter_type = get_parameter_type; object_class->finalize = finalize; object_class->get_property = get_property; @@ -267,7 +268,7 @@ } void v3270_action_notify_state(GAction *action) { - if(V3270_ACTION_GET_CLASS(action)->type.state) + if(g_action_get_state_type(action)) g_idle_add((GSourceFunc) bg_notify_state, G_OBJECT(action)); } @@ -294,8 +295,7 @@ g_idle_add((GSourceFunc) bg_notify_enabled, G_OBJECT(action)); - if(V3270_ACTION_GET_CLASS(action)->type.state) - g_idle_add((GSourceFunc) bg_notify_state, G_OBJECT(action)); + v3270_action_notify_state(object); } @@ -405,9 +405,9 @@ GVariant * state = NULL; - if(V3270_ACTION_GET_CLASS(object)->type.state) { + if(g_action_get_state_type(object)) { - GtkWidget * terminal = V3270_ACTION(object)->terminal; + GtkWidget * terminal = V3270_ACTION(object)->terminal; if(terminal) { state = V3270_ACTION_GET_CLASS(object)->get_state(object,terminal); @@ -424,12 +424,13 @@ } + const GVariantType * iface_get_parameter_type(GAction *object) { - return V3270_ACTION_GET_CLASS(object)->type.parameter; + return V3270_ACTION_GET_CLASS(object)->get_parameter_type(object); } const GVariantType * iface_get_state_type(GAction *object) { - return V3270_ACTION_GET_CLASS(object)->type.state; + return V3270_ACTION_GET_CLASS(object)->get_state_type(object); } GVariant * iface_get_state_hint(GAction G_GNUC_UNUSED(*object)) { @@ -515,3 +516,10 @@ return V3270_ACTION_GET_CLASS(action)->get_tooltip(action); } + const GVariantType * get_state_type(GAction G_GNUC_UNUSED(*object)) { + return NULL; + } + + const GVariantType * get_parameter_type(GAction G_GNUC_UNUSED(*object)) { + return NULL; + } diff --git a/src/terminal/actions/pakey.c b/src/terminal/actions/pakey.c index 7620203..cb25bdc 100644 --- a/src/terminal/actions/pakey.c +++ b/src/terminal/actions/pakey.c @@ -82,8 +82,12 @@ } + static const GVariantType * get_parameter_type(GAction G_GNUC_UNUSED(*object)) { + return G_VARIANT_TYPE_UINT32; + } + void Lib3270PaAction_class_init(Lib3270PaActionClass *klass) { - klass->parent_class.type.parameter = G_VARIANT_TYPE_UINT32; + klass->parent_class.get_parameter_type = get_parameter_type; } void Lib3270PaAction_init(Lib3270PaAction *action) { diff --git a/src/terminal/actions/pfkey.c b/src/terminal/actions/pfkey.c index fcfb002..d9c8c5f 100644 --- a/src/terminal/actions/pfkey.c +++ b/src/terminal/actions/pfkey.c @@ -82,8 +82,12 @@ } + static const GVariantType * get_parameter_type(GAction G_GNUC_UNUSED(*object)) { + return G_VARIANT_TYPE_UINT32; + } + void Lib3270PfAction_class_init(Lib3270PfActionClass *klass) { - klass->parent_class.type.parameter = G_VARIANT_TYPE_UINT32; + klass->parent_class.get_parameter_type = get_parameter_type; } void Lib3270PfAction_init(Lib3270PfAction *action) { diff --git a/src/terminal/actions/toggle.c b/src/terminal/actions/toggle.c index 2f743df..7e14e7a 100644 --- a/src/terminal/actions/toggle.c +++ b/src/terminal/actions/toggle.c @@ -107,11 +107,15 @@ } + static const GVariantType * get_state_type(GAction G_GNUC_UNUSED(*object)) { + return G_VARIANT_TYPE_BOOLEAN; + } + void Lib3270ToggleAction_class_init(Lib3270ToggleActionClass *klass) { klass->parent_class.change_widget = change_widget; - klass->parent_class.type.state = G_VARIANT_TYPE_BOOLEAN; klass->parent_class.get_state = get_state; + klass->parent_class.get_state_type = get_state_type; } -- libgit2 0.21.2