From b2e581193f1e04ccd6088ad9caa84e324e013647 Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Thu, 26 Dec 2019 17:11:34 -0300 Subject: [PATCH] Adjustments in the v3270 action object. --- src/include/v3270/actions.h | 9 +++------ src/terminal/actions/action.c | 29 ++++++++++------------------- 2 files changed, 13 insertions(+), 25 deletions(-) diff --git a/src/include/v3270/actions.h b/src/include/v3270/actions.h index 9adccfe..02e8a34 100644 --- a/src/include/v3270/actions.h +++ b/src/include/v3270/actions.h @@ -128,12 +128,6 @@ /// @brief Activation method. void (*activate)(GAction *action, GVariant *parameter, GtkWidget *terminal); - /// @brief Get State method. - GVariant * (*get_state_property)(GAction *action, GtkWidget *terminal); - - /// @brief Get state hint. - GVariant * (*get_state_hint)(GAction *action, GtkWidget *terminal); - } V3270Action; typedef struct _V3270ActionClass { @@ -148,6 +142,9 @@ void (*change_widget)(GAction *action, GtkWidget *from, GtkWidget *to); gboolean (*get_enabled)(GAction *action, GtkWidget *terminal); + GVariant * (*get_state)(GAction *action, GtkWidget *terminal); + GVariant * (*get_state_hint)(GAction *action, GtkWidget *terminal); + } V3270ActionClass; LIB3270_EXPORT GType V3270Action_get_type(void) G_GNUC_CONST; diff --git a/src/terminal/actions/action.c b/src/terminal/actions/action.c index f5c7881..ccc872a 100644 --- a/src/terminal/actions/action.c +++ b/src/terminal/actions/action.c @@ -53,9 +53,10 @@ static const GVariantType * get_state_type(GAction *action); static GVariant * get_state_property(GAction *action); - static GVariant * internal_get_state_property(GAction *action, GtkWidget *terminal); static gboolean internal_get_enabled(GAction *action, GtkWidget *terminal); static void internal_activate(GAction *action, GVariant *parameter, GtkWidget *terminal); + + static GVariant * internal_get_state(GAction *action, GtkWidget *terminal); static GVariant * internal_get_state_hint(GAction *action, GtkWidget *terminal); static const GVariantType * get_parameter_type(GAction *action); @@ -97,6 +98,9 @@ klass->change_widget = change_widget; klass->get_enabled = internal_get_enabled; + klass->get_state = internal_get_state; + klass->get_state_hint = internal_get_state_hint; + object_class->finalize = finalize; object_class->get_property = get_property; @@ -187,8 +191,8 @@ action->types.parameter = NULL; action->activate = internal_activate; - action->get_state_property = internal_get_state_property; - action->get_state_hint = internal_get_state_hint; +// action->get_state_property = internal_get_state_property; +// action->get_state_hint = internal_get_state_hint; } @@ -262,7 +266,7 @@ return NULL; } - GVariant * internal_get_state_property(GAction *object, GtkWidget G_GNUC_UNUSED(*terminal)) { + GVariant * internal_get_state(GAction *object, GtkWidget G_GNUC_UNUSED(*terminal)) { V3270Action * action = V3270_ACTION(object); @@ -273,19 +277,7 @@ } GVariant * get_state_property(GAction *object) { - - V3270Action * action = V3270_ACTION(object); - GVariant * state; - - if(action->terminal) - state = action->get_state_property(object,action->terminal); - else - state = internal_get_state_property(object,NULL); - - if(state) - g_variant_ref(state); - - return state; + return V3270_ACTION_GET_CLASS(object)->get_state(object,V3270_ACTION(object)->terminal); } const GVariantType * get_parameter_type(GAction *action) { @@ -297,8 +289,7 @@ } GVariant * get_state_hint(GAction *object) { - V3270Action *action = V3270_ACTION(object); - return action->get_state_hint(object,action->terminal); + return V3270_ACTION_GET_CLASS(object)->get_state_hint(object,V3270_ACTION(object)->terminal); } void change_state(GAction G_GNUC_UNUSED(*object), GVariant G_GNUC_UNUSED(*value)) { -- libgit2 0.21.2