Code

Added method to fetch currently active text.
authorJon A. Cruz <jon@joncruz.org>
Tue, 13 Apr 2010 05:36:46 +0000 (22:36 -0700)
committerJon A. Cruz <jon@joncruz.org>
Tue, 13 Apr 2010 05:36:46 +0000 (22:36 -0700)
src/ege-select-one-action.cpp
src/ege-select-one-action.h

index 50967ecb28e4f86100cb99d788ae5e278023d7de..834b06b3b035b4f876e1fa0f6f0cd9faccb7f5fb 100644 (file)
@@ -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 );
index d0c9d6de787603f680c80919591741c6d7bf64b9..2ecf7efc52e2de79288b27a6bbf78edebd3f7cf9 100644 (file)
@@ -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.
  *