Mercurial > pidgin.yaz
changeset 16275:9a4854d71234
Patch #205, from SuperMMX. Fix a bug related to using F2 to alias
buddies in the buddylist.
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Fri, 20 Apr 2007 05:58:57 +0000 |
parents | 3796304f343d |
children | d7e385be0346 |
files | pidgin/gtkblist.c |
diffstat | 1 files changed, 42 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/pidgin/gtkblist.c Fri Apr 20 04:04:24 2007 +0000 +++ b/pidgin/gtkblist.c Fri Apr 20 05:58:57 2007 +0000 @@ -312,6 +312,47 @@ gtk_blist_join_chat(chat); } +static void gtk_blist_renderer_editing_started_cb(GtkCellRenderer *renderer, + GtkCellEditable *editable, + gchar *path_str, + gpointer user_data) +{ + GtkTreeIter iter; + GtkTreePath *path = NULL; + GValue val; + PurpleBlistNode *node; + const char *text = NULL; + char *esc; + + path = gtk_tree_path_new_from_string (path_str); + gtk_tree_model_get_iter (GTK_TREE_MODEL(gtkblist->treemodel), &iter, path); + gtk_tree_path_free (path); + val.g_type = 0; + gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &val); + node = g_value_get_pointer(&val); + + switch (node->type) { + case PURPLE_BLIST_CONTACT_NODE: + text = purple_contact_get_alias((PurpleContact *)node); + break; + case PURPLE_BLIST_BUDDY_NODE: + text = purple_buddy_get_alias((PurpleBuddy *)node); + break; + case PURPLE_BLIST_GROUP_NODE: + text = ((PurpleGroup *)node)->name; + break; + default: + g_return_if_reached(); + } + + esc = g_markup_escape_text(text, -1); + if (GTK_IS_ENTRY (editable)) { + GtkEntry *entry = GTK_ENTRY (editable); + gtk_entry_set_text(entry, esc); + } + g_free(esc); +} + static void gtk_blist_renderer_edited_cb(GtkCellRendererText *text_rend, char *arg1, char *arg2, gpointer nada) { @@ -371,8 +412,6 @@ { GtkTreeIter iter; GtkTreePath *path; - const char *text = NULL; - char *esc; if (!(get_iter_from_node(node, &iter))) { /* This is either a bug, or the buddy is in a collapsed contact */ @@ -382,27 +421,6 @@ return; } - switch (node->type) { - case PURPLE_BLIST_BUDDY_NODE: - text = purple_buddy_get_alias((PurpleBuddy *)node); - break; - case PURPLE_BLIST_CONTACT_NODE: - text = purple_contact_get_alias((PurpleContact *)node); - break; - case PURPLE_BLIST_GROUP_NODE: - text = ((PurpleGroup *)node)->name; - break; - case PURPLE_BLIST_CHAT_NODE: - text = purple_chat_get_name((PurpleChat *)node); - break; - default: - g_return_if_reached(); - } - - esc = g_markup_escape_text(text, -1); - gtk_tree_store_set(gtkblist->treemodel, &iter, NAME_COLUMN, esc, -1); - g_free(esc); - path = gtk_tree_model_get_path(GTK_TREE_MODEL(gtkblist->treemodel), &iter); g_object_set(G_OBJECT(gtkblist->text_rend), "editable", TRUE, NULL); gtk_tree_view_set_enable_search (GTK_TREE_VIEW(gtkblist->treeview), FALSE); @@ -4402,6 +4420,7 @@ #endif "markup", NAME_COLUMN, NULL); + g_signal_connect(G_OBJECT(rend), "editing-started", G_CALLBACK(gtk_blist_renderer_editing_started_cb), NULL); g_signal_connect(G_OBJECT(rend), "edited", G_CALLBACK(gtk_blist_renderer_edited_cb), NULL); g_object_set(rend, "ypad", 0, "yalign", 0.5, NULL); #if GTK_CHECK_VERSION(2,6,0)