From: Nathan W. <fac...@us...> - 2003-10-13 00:11:53
|
Update of /cvsroot/gaim/gaim/src In directory sc8-pr-cvs1:/tmp/cvs-serv25838/src Modified Files: blist.c dialogs.c gtkblist.c ui.h Log Message: contact aliasing support (sorry, I had to touch ui.h) Index: blist.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/blist.c,v retrieving revision 1.101 retrieving revision 1.102 diff -u -d -p -r1.101 -r1.102 --- blist.c 5 Oct 2003 18:32:43 -0000 1.101 +++ blist.c 13 Oct 2003 00:11:48 -0000 1.102 @@ -757,12 +757,20 @@ GaimContact *gaim_contact_new() void gaim_contact_set_alias(GaimContact* contact, const char *alias) { + GaimBlistUiOps *ops = gaimbuddylist->ui_ops; + g_return_if_fail(contact != NULL); if(contact->alias) g_free(contact->alias); - contact->alias = g_strdup(alias); + if(alias && *alias) + contact->alias = g_strdup(alias); + else + contact->alias = NULL; + + if (ops) + ops->update(gaimbuddylist, (GaimBlistNode*)contact); } const char *gaim_contact_get_alias(GaimContact* contact) @@ -1156,17 +1164,11 @@ const char *gaim_get_buddy_alias_only(Ga const char * gaim_get_buddy_alias (GaimBuddy *buddy) { - GaimContact *contact; const char *ret; if(!buddy) return _("Unknown"); - contact = (GaimContact*)((GaimBlistNode*)buddy)->parent; - - if(contact && contact->alias) - return contact->alias; - ret= gaim_get_buddy_alias_only(buddy); return ret ? ret : buddy->name; @@ -1936,14 +1938,13 @@ static void parse_contact(GaimGroup *gro { GaimContact *contact = gaim_contact_new(); xmlnode *x; + const char *alias; gaim_blist_add_contact(contact, group, gaim_blist_get_last_child((GaimBlistNode*)group)); - if((x = xmlnode_get_child(cnode, "alias"))) { - char *alias = xmlnode_get_data(x); + if((alias = xmlnode_get_attrib(cnode, "alias"))) { gaim_contact_set_alias(contact, alias); - g_free(alias); } for(x = cnode->child; x; x = x->next) { Index: dialogs.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/dialogs.c,v retrieving revision 1.549 retrieving revision 1.550 diff -u -d -p -r1.549 -r1.550 --- dialogs.c 2 Oct 2003 05:26:40 -0000 1.549 +++ dialogs.c 13 Oct 2003 00:11:48 -0000 1.550 @@ -1814,6 +1814,23 @@ alias_dialog_blist_chat(GaimChat *chat) } static void +alias_contact_cb(GaimContact *contact, const char *new_alias) +{ + gaim_contact_set_alias(contact, new_alias); + gaim_blist_save(); +} + +void +alias_dialog_contact(GaimContact *contact) +{ + gaim_request_input(NULL, _("Alias Contact"), _("Alias contact"), + _("Please enter an aliased name for this contact."), + contact->alias, FALSE, FALSE, + _("OK"), G_CALLBACK(alias_contact_cb), + _("Cancel"), NULL, contact); +} + +static void alias_buddy_cb(GaimBuddy *buddy, GaimRequestFields *fields) { const char *alias; Index: gtkblist.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/gtkblist.c,v retrieving revision 1.109 retrieving revision 1.110 diff -u -d -p -r1.109 -r1.110 --- gtkblist.c 7 Oct 2003 04:43:02 -0000 1.109 +++ gtkblist.c 13 Oct 2003 00:11:48 -0000 1.110 @@ -222,6 +222,8 @@ static void gtk_blist_menu_alias_cb(GtkW { if(GAIM_BLIST_NODE_IS_BUDDY(node)) alias_dialog_bud((GaimBuddy*)node); + else if(GAIM_BLIST_NODE_IS_CONTACT(node)) + alias_dialog_contact((GaimContact*)node); else if(GAIM_BLIST_NODE_IS_CHAT(node)) alias_dialog_blist_chat((GaimChat*)node); } @@ -619,8 +621,9 @@ static gboolean gtk_blist_button_press_c G_CALLBACK(gaim_gtk_blist_remove_cb), node, 0, 0, NULL); } } else if (GAIM_BLIST_NODE_IS_CONTACT(node) && gtknode->contact_expanded) { - gaim_new_item_from_stock(menu, _("_Collapse"), - GTK_STOCK_ZOOM_OUT, + gaim_new_item_from_stock(menu, _("_Alias"), GAIM_STOCK_EDIT, + G_CALLBACK(gtk_blist_menu_alias_cb), node, 0, 0, NULL); + gaim_new_item_from_stock(menu, _("_Collapse"), GTK_STOCK_ZOOM_OUT, G_CALLBACK(gaim_gtk_blist_collapse_contact_cb), node, 0, 0, NULL); gaim_new_item_from_stock(menu, _("_Remove"), GTK_STOCK_REMOVE, @@ -1193,14 +1196,18 @@ static char *gaim_get_tooltip_text(GaimB GAIM_BLIST_NODE_IS_BUDDY(node)) { GaimBuddy *b; char *statustext = NULL; + char *contactaliastext = NULL; char *aliastext = NULL, *nicktext = NULL; char *warning = NULL, *idletime = NULL; char *accounttext = NULL; if(GAIM_BLIST_NODE_IS_CONTACT(node)) { + GaimContact *contact = (GaimContact*)node; if(gtknode->contact_expanded) return NULL; - b = gaim_contact_get_priority_buddy((GaimContact*)node); + b = gaim_contact_get_priority_buddy(contact); + if(contact->alias) + contactaliastext = g_markup_escape_text(contact->alias, -1); } else { b = (GaimBuddy *)node; } @@ -1240,6 +1247,7 @@ static char *gaim_get_tooltip_text(GaimB text = g_strdup_printf("<span size='larger' weight='bold'>%s</span>" "%s %s" /* Account */ + "%s %s" /* Contact Alias */ "%s %s" /* Alias */ "%s %s" /* Nickname */ "%s %s" /* Idle */ @@ -1248,6 +1256,7 @@ static char *gaim_get_tooltip_text(GaimB "%s", b->name, accounttext ? _("\n<b>Account:</b>") : "", accounttext ? accounttext : "", + contactaliastext ? _("\n<b>Contact Alias:</b>") : "", contactaliastext ? contactaliastext : "", aliastext ? _("\n<b>Alias:</b>") : "", aliastext ? aliastext : "", nicktext ? _("\n<b>Nickname:</b>") : "", nicktext ? nicktext : "", idletime ? _("\n<b>Idle:</b>") : "", idletime ? idletime : "", @@ -1431,11 +1440,23 @@ static GdkPixbuf *gaim_gtk_blist_get_bud static gchar *gaim_gtk_blist_get_name_markup(GaimBuddy *b, gboolean selected) { - const char *name = gaim_get_buddy_alias(b); - char *esc = g_markup_escape_text(name, strlen(name)), *text = NULL; + const char *name; + char *esc, *text = NULL; GaimPlugin *prpl; GaimPluginProtocolInfo *prpl_info = NULL; + GaimContact *contact; + struct _gaim_gtk_blist_node *gtkcontactnode = NULL; /* XXX Clean up this crap */ + + contact = (GaimContact*)((GaimBlistNode*)b)->parent; + if(contact) + gtkcontactnode = ((GaimBlistNode*)contact)->ui_data; + + if(gtkcontactnode && !gtkcontactnode->contact_expanded && contact->alias) + name = contact->alias; + else + name = gaim_get_buddy_alias(b); + esc = g_markup_escape_text(name, strlen(name)); int ihrs, imin; char *idletime = NULL, *warning = NULL, *statustext = NULL; Index: ui.h =================================================================== RCS file: /cvsroot/gaim/gaim/src/ui.h,v retrieving revision 1.142 retrieving revision 1.143 diff -u -d -p -r1.142 -r1.143 --- ui.h 3 Oct 2003 23:19:21 -0000 1.142 +++ ui.h 13 Oct 2003 00:11:48 -0000 1.143 @@ -120,6 +120,7 @@ extern void do_im_back(GtkWidget *w, Gtk /* Functions in dialogs.c */ extern void alias_dialog_bud(GaimBuddy *); +extern void alias_dialog_contact(GaimContact *); extern void alias_dialog_blist_chat(GaimChat *); extern void show_warn_dialog(GaimConnection *, char *); extern void show_im_dialog(); |