Mercurial > pidgin
changeset 710:efd72a117875
[gaim-migrate @ 720]
yay, icq-style aliasing. joy.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Thu, 17 Aug 2000 13:07:52 +0000 |
parents | 957957d0dc2c |
children | b967d21d7482 |
files | ChangeLog TODO src/buddy.c src/dialogs.c src/gaim.h src/prefs.c src/server.c src/toc.c |
diffstat | 8 files changed, 164 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Thu Aug 17 10:01:50 2000 +0000 +++ b/ChangeLog Thu Aug 17 13:07:52 2000 +0000 @@ -15,7 +15,10 @@ * Removed the Lag-O-Meter * Socks 4/5 Proxy works * Buddy Pounces are now saved in .gaimrc - # Ability to merge gaim, aim2, aim4 buddylists. Thanks again bmiller! + * Ability to merge gaim, aim2, aim4 buddylists. Thanks again bmiller! + * ICQ-style aliases. This lets you change the name you see your buddy + as. For example, if your buddy's SN is 'CouldntGetMyName', you can + alias him as 'Loser'. version 0.9.20 (07/14/2000): * More plugin events, more plugin features
--- a/TODO Thu Aug 17 10:01:50 2000 +0000 +++ b/TODO Thu Aug 17 13:07:52 2000 +0000 @@ -22,9 +22,5 @@ access items in those menus - Possibly make it so that you can create ICQ-style 'aliases' for - buddies on your buddy list. This won't be too hard it'll - just take a bit of work. Maybe we'll save this one for the - release after our next release. Maybe someday in the future gaim will be able to support multiple connections, so you can log on as 2+ names at once. Maybe.
--- a/src/buddy.c Thu Aug 17 10:01:50 2000 +0000 +++ b/src/buddy.c Thu Aug 17 13:07:52 2000 +0000 @@ -395,7 +395,11 @@ void pressed_info(GtkWidget *widget, struct buddy *b) { serv_get_info(b->name); +} +void pressed_alias(GtkWidget *widget, struct buddy *b) +{ + alias_dialog(b); } void pressed_dir_info(GtkWidget *widget, struct buddy *b) @@ -440,6 +444,12 @@ gtk_menu_append(GTK_MENU(menu), button); gtk_widget_show(button); + button = gtk_menu_item_new_with_label(_("Alias")); + gtk_signal_connect(GTK_OBJECT(button), "activate", + GTK_SIGNAL_FUNC(pressed_alias), b); + gtk_menu_append(GTK_MENU(menu), button); + gtk_widget_show(button); + button = gtk_menu_item_new_with_label(_("Dir Info")); gtk_signal_connect(GTK_OBJECT(button), "activate", GTK_SIGNAL_FUNC(pressed_dir_info), b); @@ -806,7 +816,7 @@ } -struct buddy *add_buddy(char *group, char *buddy) +struct buddy *add_buddy(char *group, char *buddy, char *show) { struct buddy *b; struct group *g; @@ -832,6 +842,8 @@ b->item = gtk_tree_item_new(); g_snprintf(b->name, sizeof(b->name), "%s", buddy); + g_snprintf(b->show, sizeof(b->show), "%s", show ? (show[0] ? show : buddy) : buddy); + g->members = g_list_append(g->members, b); @@ -1407,7 +1419,7 @@ } else caps[0] = '\0'; - i = g_snprintf(infotip, sizeof(infotip), _("Name: %s \nLogged in: %s\n%s%s%s%s%s"), b->name, sotime, warn, ((b->idle) ? _("Idle: ") : ""), itime, ((b->idle) ? "\n" : ""), caps); + i = g_snprintf(infotip, sizeof(infotip), _("Name: %s \nLogged in: %s\n%s%s%s%s%s"), b->show, sotime, warn, ((b->idle) ? _("Idle: ") : ""), itime, ((b->idle) ? "\n" : ""), caps); gtk_tooltips_set_tip(tips, GTK_WIDGET(b->item), infotip, ""); @@ -1437,8 +1449,8 @@ play_sound(BUDDY_ARRIVE); b->present = 2; - who = g_malloc(sizeof(b->name) + 10); - strcpy(who, b->name); + who = g_malloc(sizeof(b->show) + 10); + strcpy(who, b->show); gtk_label_set(GTK_LABEL(b->label), who); g_free(who);
--- a/src/dialogs.c Thu Aug 17 10:01:50 2000 +0000 +++ b/src/dialogs.c Thu Aug 17 13:07:52 2000 +0000 @@ -71,6 +71,9 @@ static GtkWidget *imdialog = NULL; /*I only want ONE of these :) */ static GList *dialogwindows = NULL; static GtkWidget *exportdialog, *importdialog; +static GtkWidget *aliasdlg = NULL; +static GtkWidget *aliasentry = NULL; +static GtkWidget *aliasname = NULL; struct create_away { GtkWidget *window; @@ -327,6 +330,12 @@ if (dest == importdialog) importdialog = NULL; + if (dest == aliasdlg) { + aliasdlg = NULL; + aliasentry = NULL; + aliasname = NULL; + } + dialogwindows = g_list_remove(dialogwindows, dest); gtk_widget_destroy(dest); @@ -766,7 +775,7 @@ c = find_conversation(who); - add_buddy(grp, who); + add_buddy(grp, who, NULL); if (c != NULL) { GtkWidget *parent = c->add_button->parent; @@ -893,7 +902,7 @@ gtk_widget_show(bbox); gtk_widget_show(vbox); gtk_widget_show(frame); - gtk_window_set_title(GTK_WINDOW(a->window), _("Gaim - Add Buddy")); + gtk_window_set_title(GTK_WINDOW(a->window), _("Gaim - Add Group")); gtk_window_set_focus(GTK_WINDOW(a->window), a->entry); gtk_container_add(GTK_CONTAINER(frame), vbox); gtk_container_add(GTK_CONTAINER(a->window), frame); @@ -2614,7 +2623,7 @@ return; } if ((f = fopen(path,"w"))) { - serv_build_config(buf, 8192 - 1); + serv_build_config(buf, 8192 - 1, TRUE); fprintf(f, "%s\n", buf); fclose(f); chmod(buf, S_IRUSR | S_IWUSR); @@ -3080,3 +3089,110 @@ return; } + +static void do_alias(GtkWidget *w, gpointer n) +{ + char *name, *who; + struct buddy *b; + name = g_strdup(gtk_entry_get_text(GTK_ENTRY(aliasentry))); + if ((b = find_buddy(name)) == NULL) { + g_free(name); + destroy_dialog(aliasdlg, aliasdlg); + return; + } + g_snprintf(b->show, sizeof(b->show), "%s", gtk_entry_get_text(GTK_ENTRY(aliasname))); + do_export(0, 0); + who = g_malloc(sizeof(b->show) + 10); + strcpy(who, b->show); + gtk_label_set(GTK_LABEL(b->label), who); + g_free(who); + set_buddy(b); + g_free(name); + destroy_dialog(aliasdlg, aliasdlg); +} + +void alias_dialog(struct buddy *b) +{ + GtkWidget *frame; + GtkWidget *vbox; + GtkWidget *bbox; + GtkWidget *cancel; + GtkWidget *add; + GtkWidget *label; + GtkWidget *topbox; + + if (aliasdlg) { + gtk_entry_set_text(GTK_ENTRY(aliasentry), b->name); + gtk_widget_show(aliasdlg); + return; + } + + aliasdlg = gtk_window_new(GTK_WINDOW_DIALOG); + gtk_window_set_policy(GTK_WINDOW(aliasdlg), FALSE, FALSE, TRUE); + gtk_widget_show(aliasdlg); + dialogwindows = g_list_prepend(dialogwindows, aliasdlg); + + bbox = gtk_hbox_new(TRUE, 10); + topbox = gtk_hbox_new(FALSE, 5); + vbox = gtk_vbox_new(FALSE, 5); + + aliasentry = gtk_entry_new(); + aliasname = gtk_entry_new(); + /* Put the buttons in the box */ + + add = picture_button(aliasdlg, _("Add"), add_xpm); + + cancel = picture_button(aliasdlg, _("Cancel"), cancel_xpm); + + gtk_box_pack_start(GTK_BOX(bbox), add, FALSE, FALSE, 5); + gtk_box_pack_end(GTK_BOX(bbox), cancel, FALSE, FALSE, 5); + + frame = gtk_frame_new(NULL); + gtk_frame_set_label(GTK_FRAME(frame), _("Alias Buddy")); + + label = gtk_label_new(_("Buddy")); + gtk_widget_show(label); + gtk_box_pack_start(GTK_BOX(topbox), label, FALSE, FALSE, 5); + gtk_box_pack_start(GTK_BOX(topbox), aliasentry, FALSE, FALSE, 5); + label = gtk_label_new(_("Alias")); + gtk_widget_show(label); + gtk_box_pack_start(GTK_BOX(topbox), label, FALSE, FALSE, 5); + gtk_box_pack_start(GTK_BOX(topbox), aliasname, FALSE, FALSE, 5); + + gtk_entry_set_text(GTK_ENTRY(aliasentry), b->name); + gtk_entry_set_text(GTK_ENTRY(aliasname), b->show); + + /* And the boxes in the box */ + gtk_box_pack_start(GTK_BOX(vbox), topbox, TRUE, TRUE, 5); + gtk_box_pack_start(GTK_BOX(vbox), bbox, TRUE, TRUE, 5); + + /* Handle closes right */ + gtk_signal_connect(GTK_OBJECT(aliasdlg), "destroy", + GTK_SIGNAL_FUNC(destroy_dialog), aliasdlg); + gtk_signal_connect(GTK_OBJECT(cancel), "clicked", + GTK_SIGNAL_FUNC(destroy_dialog), aliasdlg); + gtk_signal_connect(GTK_OBJECT(add), "clicked", + GTK_SIGNAL_FUNC(do_alias), NULL); + gtk_signal_connect(GTK_OBJECT(aliasentry), "activate", + GTK_SIGNAL_FUNC(do_alias), NULL); + gtk_signal_connect(GTK_OBJECT(aliasname), "activate", + GTK_SIGNAL_FUNC(do_alias), NULL); + /* Finish up */ + gtk_widget_show(add); + gtk_widget_show(cancel); + gtk_widget_show(aliasentry); + gtk_widget_show(aliasname); + gtk_widget_show(topbox); + gtk_widget_show(bbox); + gtk_widget_show(vbox); + gtk_widget_show(frame); + gtk_window_set_title(GTK_WINDOW(aliasdlg), _("Gaim - Alias Buddy")); + gtk_window_set_focus(GTK_WINDOW(aliasdlg), aliasentry); + gtk_container_add(GTK_CONTAINER(frame), vbox); + gtk_container_add(GTK_CONTAINER(aliasdlg), frame); + gtk_container_set_border_width(GTK_CONTAINER(aliasdlg), 5); + gtk_widget_realize(aliasdlg); + aol_icon(aliasdlg->window); + + gtk_widget_show(aliasdlg); +}
--- a/src/gaim.h Thu Aug 17 10:01:50 2000 +0000 +++ b/src/gaim.h Thu Aug 17 13:07:52 2000 +0000 @@ -196,6 +196,7 @@ struct buddy { char name[80]; + char show[80]; GtkWidget *item; GtkWidget *label; GtkWidget *pix; @@ -399,7 +400,7 @@ #define TYPE_SIGNOFF 4 #define TYPE_KEEPALIVE 5 -#define REVISION "gaim:$Revision: 715 $" +#define REVISION "gaim:$Revision: 720 $" #define FLAPON "FLAPON\r\n\r\n" #define ROAST "Tic/Toc" @@ -603,7 +604,7 @@ extern void serv_add_permit(char *); extern void serv_add_deny(char *); extern void serv_set_permit_deny(); -extern void serv_build_config(char *, int); +extern void serv_build_config(char *, int, gboolean); extern void serv_save_config(); extern void serv_warn(char *, int); extern void serv_set_dir(char *, char *, char *, char *, char *, char *, char *, int); @@ -686,7 +687,7 @@ extern void update_all_buddies(); extern void show_buddy_list(); extern void refresh_buddy_window(); -extern void toc_build_config(char *, int len); +extern void toc_build_config(char *, int len, gboolean); extern void signoff(); extern void do_im_back(); extern void set_buddy(struct buddy *); @@ -702,7 +703,7 @@ extern struct group *find_group(char *); extern struct group *find_group_by_buddy(char *); extern void remove_buddy(struct group *, struct buddy *); -extern struct buddy *add_buddy(char *, char *); +extern struct buddy *add_buddy(char *, char *, char *); extern void remove_group(struct group *); extern void update_lagometer(int); @@ -757,6 +758,7 @@ /* Functions in dialogs.c */ +extern void alias_dialog(struct buddy *); extern void do_export(GtkWidget *, void *); extern void show_warn_dialog(char *); extern void do_error_dialog(char *, char *);
--- a/src/prefs.c Thu Aug 17 10:01:50 2000 +0000 +++ b/src/prefs.c Thu Aug 17 13:07:52 2000 +0000 @@ -464,8 +464,7 @@ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w))) { permdeny = (int)data; if (blist) { - /* We don't save this 'at home', it's on the server. - * So, we gotta resend the config to the server. */ + do_export(0, 0); serv_save_config(); /* we do this here because we can :) */ serv_set_permit_deny();
--- a/src/server.c Thu Aug 17 10:01:50 2000 +0000 +++ b/src/server.c Thu Aug 17 13:07:52 2000 +0000 @@ -487,8 +487,8 @@ } } -void serv_build_config(char *buf, int len) { - toc_build_config(buf, len); +void serv_build_config(char *buf, int len, gboolean show) { + toc_build_config(buf, len, show); } @@ -497,7 +497,7 @@ if (!USE_OSCAR) { char *buf = g_malloc(BUF_LONG); char *buf2 = g_malloc(MSG_LEN); - serv_build_config(buf, BUF_LONG / 2); + serv_build_config(buf, BUF_LONG / 2, FALSE); g_snprintf(buf2, MSG_LEN, "toc_set_config {%s}", buf); sflap_send(buf2, -1, TYPE_DATA); g_free(buf2);
--- a/src/toc.c Thu Aug 17 10:01:50 2000 +0000 +++ b/src/toc.c Thu Aug 17 13:07:52 2000 +0000 @@ -827,7 +827,7 @@ return NULL; } -void toc_build_config(char *s, int len) +void toc_build_config(char *s, int len, gboolean show) { GList *grp = groups; GList *mem; @@ -848,7 +848,8 @@ mem = g->members; while(mem) { b = (struct buddy *)mem->data; - pos += g_snprintf(&s[pos], len - pos, "b %s\n", b->name); + pos += g_snprintf(&s[pos], len - pos, "b %s%s%s\n", b->name, + show ? ":" : "", show ? b->show : ""); mem = mem->next; } grp = grp ->next; @@ -897,8 +898,19 @@ add_group(current); how_many++; } else if (*c == 'b' && !find_buddy(c+2)) { - add_buddy(current, c+2); + char nm[80], sw[80], *tmp = c+2; + int i = 0; + while (*tmp != ':' && *tmp) + nm[i++] = *tmp++; + if (*tmp == ':') *tmp++ = '\0'; + nm[i] = '\0'; + i = 0; + while (*tmp) sw[i++] = *tmp++; + sw[i] = '\0'; + if (!find_buddy(nm)) + add_buddy(current, nm, sw); how_many++; + bud = g_list_append(bud, c+2); } else if (*c == 'p') { GList *d = permit;