]> git.0d.be Git - empathy.git/commitdiff
PresetDialog: Select text cell of freshly-added status
authorWill Thompson <will.thompson@collabora.co.uk>
Fri, 10 Jun 2011 20:09:33 +0000 (21:09 +0100)
committerWill Thompson <will.thompson@collabora.co.uk>
Fri, 24 Jun 2011 09:45:38 +0000 (10:45 +0100)
This means you can just mash Enter to edit your mistake. It's more
useful than leaving the text entry focused. It also helps hide a bug
where the entry doesn't get cleared if you just start typing another
message. So previously, typing:

  Hello<Enter>Miaow<Enter>

would give you two statuses, "Hello" and "MiaowEnter Custom Message".

It didn't seem worth fixing this much more since Gtk+ 3.2 will probably
grow native support for placeholder text:
<https://bugzilla.gnome.org/show_bug.cgi?id=440963>

libempathy-gtk/empathy-status-preset-dialog.c

index 7dc77afa02f70a0d4cad5e2680ae082e69245256..8176e9ea758e1c9e6dc578dd94827e2c5efab963 100644 (file)
@@ -65,6 +65,9 @@ struct _EmpathyStatusPresetDialogPriv
        int block_add_combo_changed;
 
        GtkWidget *presets_treeview;
+       GtkTreeViewColumn *column;
+       GtkCellRenderer *text_cell;
+
        GtkWidget *add_combobox;
        GtkWidget *add_button;
 
@@ -278,6 +281,7 @@ status_preset_dialog_setup_presets_treeview (EmpathyStatusPresetDialog *self)
        status_preset_dialog_presets_update (self);
 
        column = gtk_tree_view_column_new ();
+       priv->column = column;
        gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
 
        renderer = gtk_cell_renderer_pixbuf_new ();
@@ -286,6 +290,7 @@ status_preset_dialog_setup_presets_treeview (EmpathyStatusPresetDialog *self)
                        "icon-name", PRESETS_STORE_ICON_NAME);
 
        renderer = gtk_cell_renderer_text_new ();
+       priv->text_cell = renderer;
        gtk_tree_view_column_pack_start (column, renderer, TRUE);
        gtk_tree_view_column_add_attribute (column, renderer,
                        "text", PRESETS_STORE_STATUS);
@@ -460,14 +465,13 @@ status_preset_dialog_add_preset (GtkWidget *widget,
                        GtkTreePath *path;
 
                        path = gtk_tree_model_get_path (model, &iter);
-
-                       gtk_tree_selection_select_iter (
-                               gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->presets_treeview)),
-                               &iter);
-                       gtk_tree_view_scroll_to_cell (
-                                       GTK_TREE_VIEW (priv->presets_treeview),
-                                       path, NULL,
-                                       FALSE, 0., 0.);
+                       gtk_tree_view_set_cursor_on_cell (
+                               GTK_TREE_VIEW (priv->presets_treeview),
+                               path,
+                               priv->column,
+                               priv->text_cell,
+                               FALSE);
+                       gtk_widget_grab_focus (priv->presets_treeview);
                        break;
                }
         }