From c99316f9975a7d8c990e1af9d7b72f95a4b0d58d Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Mon, 12 Apr 2010 22:36:46 -0700 Subject: Added method to fetch currently active text. (bzr r9322) --- src/ege-select-one-action.cpp | 15 +++++++++++++++ src/ege-select-one-action.h | 8 ++++++++ 2 files changed, 23 insertions(+) (limited to 'src') diff --git a/src/ege-select-one-action.cpp b/src/ege-select-one-action.cpp index 50967ecb2..834b06b3b 100644 --- a/src/ege-select-one-action.cpp +++ b/src/ege-select-one-action.cpp @@ -278,6 +278,21 @@ gint ege_select_one_action_get_active( EgeSelectOneAction* action ) return action->private_data->active; } +gchar *ege_select_one_action_get_active_text( EgeSelectOneAction* action ) +{ + GtkTreeIter iter; + gchar *str = 0; + g_return_val_if_fail( IS_EGE_SELECT_ONE_ACTION(action), 0 ); + + if ( gtk_tree_model_iter_nth_child( action->private_data->model, &iter, NULL, action->private_data->active ) ) { + gtk_tree_model_get( action->private_data->model, &iter, + action->private_data->labelColumn, &str, + -1 ); + } + + return str; +} + void ege_select_one_action_set_active( EgeSelectOneAction* action, gint val ) { g_object_set( G_OBJECT(action), "active", val, NULL ); diff --git a/src/ege-select-one-action.h b/src/ege-select-one-action.h index d0c9d6de7..2ecf7efc5 100644 --- a/src/ege-select-one-action.h +++ b/src/ege-select-one-action.h @@ -121,6 +121,14 @@ GtkTreeModel *ege_select_one_action_get_model(EgeSelectOneAction* action ); */ gint ege_select_one_action_get_active( EgeSelectOneAction* action ); +/** + * Returns the text of the currently selected item. + * + * @param action The action to fetch the text for. + * @return the selected text. The caller is responsible to call g_free() on it when done. + */ +gchar *ege_select_one_action_get_active_text( EgeSelectOneAction* action ); + /** * Sets the currently selected item. * -- cgit v1.2.3