diff options
| author | Tavmjong Bah <tavmjong@free.fr> | 2013-02-23 12:21:12 +0000 |
|---|---|---|
| committer | tavmjong-free <tavmjong@free.fr> | 2013-02-23 12:21:12 +0000 |
| commit | 8bd06078cf86efa3bc1d3b60975b2fb9b6d97366 (patch) | |
| tree | fde51ac83ab1201f46d98a881405f2aa9a388a47 /src/ink-comboboxentry-action.cpp | |
| parent | Noop: simplify some variable names. (diff) | |
| download | inkscape-8bd06078cf86efa3bc1d3b60975b2fb9b6d97366.tar.gz inkscape-8bd06078cf86efa3bc1d3b60975b2fb9b6d97366.zip | |
Get text from selected row rather than from entry box.
(bzr r12144)
Diffstat (limited to 'src/ink-comboboxentry-action.cpp')
| -rw-r--r-- | src/ink-comboboxentry-action.cpp | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/ink-comboboxentry-action.cpp b/src/ink-comboboxentry-action.cpp index 29dc3ce92..8b8ecfa9e 100644 --- a/src/ink-comboboxentry-action.cpp +++ b/src/ink-comboboxentry-action.cpp @@ -303,7 +303,7 @@ ink_comboboxentry_action_class_init (Ink_ComboBoxEntry_ActionClass *klass) static void ink_comboboxentry_action_init (Ink_ComboBoxEntry_Action *action) { action->active = -1; - action->text = NULL; + action->text = strdup(""); action->entry_completion = NULL; action->indicator = NULL; action->popup = false; @@ -821,18 +821,23 @@ static void combo_box_changed_cb( GtkComboBox* widget, gpointer data ) { // Check if item selected: gint newActive = gtk_combo_box_get_active(widget); - if( newActive >= 0 ) { + if( newActive >= 0 && newActive != action->active ) { - if( newActive != action->active ) { - action->active = newActive; - g_free( action->text ); - GtkWidget *entry = gtk_bin_get_child (GTK_BIN (widget)); - action->text = g_strdup (gtk_entry_get_text (GTK_ENTRY (entry))); + action->active = newActive; + + GtkTreeIter iter; + if( gtk_combo_box_get_active_iter( GTK_COMBO_BOX( action->combobox ), &iter ) ) { - // Now let the world know - g_signal_emit( G_OBJECT(action), signals[CHANGED], 0 ); + gchar* text = 0; + gtk_tree_model_get( action->model, &iter, 0, &text, -1 ); + gtk_entry_set_text( action->entry, text ); + g_free( action->text ); + action->text = text; } + + // Now let the world know + g_signal_emit( G_OBJECT(action), signals[CHANGED], 0 ); } } |
