Mercurial > pidgin
changeset 1479:4c62ead808a2
[gaim-migrate @ 1489]
save conversation history
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Wed, 07 Feb 2001 21:46:40 +0000 |
parents | 29d9feaf065b |
children | 4cf6d1704e76 |
files | ChangeLog pixmaps/Makefile.am pixmaps/save_small.xpm src/aim.c src/conversation.c src/gaim.h src/server.c |
diffstat | 7 files changed, 292 insertions(+), 69 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Wed Feb 07 21:13:22 2001 +0000 +++ b/ChangeLog Wed Feb 07 21:46:40 2001 +0000 @@ -15,6 +15,7 @@ * Rewritten file transfer for TOC * Jabber got chat * Log Viewer (courtesy BMiller) + * Can save conversation history version 0.11.0-pre4: * ICQ upgraded to use icqlib 1.1.0
--- a/pixmaps/Makefile.am Wed Feb 07 21:13:22 2001 +0000 +++ b/pixmaps/Makefile.am Wed Feb 07 21:46:40 2001 +0000 @@ -98,6 +98,7 @@ register.xpm \ sad.xpm \ save.xpm \ + save_small.xpm \ scream.xpm \ search_small.xpm \ send_small.xpm \
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pixmaps/save_small.xpm Wed Feb 07 21:46:40 2001 +0000 @@ -0,0 +1,122 @@ +/* XPM */ +static char * save_small_xpm[] = { +"17 14 105 2", +" c None", +". c #000000", +"+ c #353535", +"@ c #8F8F8F", +"# c #D8D8D8", +"$ c #0C0C0C", +"% c #2A271C", +"& c #525252", +"* c #767676", +"= c #DCDCDC", +"- c #E5E5E5", +"; c #606060", +"> c #857955", +", c #524B31", +"' c #929292", +") c #ACACAC", +"! c #CCCCCC", +"~ c #E4E4E4", +"{ c #D9D9D9", +"] c #DEDEDE", +"^ c #B6B6B6", +"/ c #938761", +"( c #796C42", +"_ c #1B180D", +": c #636363", +"< c #E1E1E1", +"[ c #C29191", +"} c #CEBFBF", +"| c #C8C8C8", +"1 c #A7A7A7", +"2 c #D6D6D6", +"3 c #787670", +"4 c #94875F", +"5 c #70643B", +"6 c #424242", +"7 c #BEBEBE", +"8 c #E6E6E6", +"9 c #EDEDED", +"0 c #C39292", +"a c #BFB0B0", +"b c #B0B0B0", +"c c #BBBBBB", +"d c #777570", +"e c #8B7F58", +"f c #6F633D", +"g c #131009", +"h c #989898", +"i c #D9C7C7", +"j c #C58D8D", +"k c #B98080", +"l c #D9CDCD", +"m c #CFCFCF", +"n c #686868", +"o c #9F9369", +"p c #6E623C", +"q c #74736E", +"r c #1F1F1F", +"s c #CDCCCC", +"t c #D6B9B9", +"u c #B67979", +"v c #DCD2D2", +"w c #D5D5D5", +"x c #706E68", +"y c #A09367", +"z c #655B38", +"A c #777777", +"B c #DDDDDC", +"C c #BABAB8", +"D c #1D1D1B", +"E c #EAE9E7", +"F c #A29469", +"G c #52492B", +"H c #51482C", +"I c #72726D", +"J c #C2C2BC", +"K c #C1C1B9", +"L c #B0B0A7", +"M c #585851", +"N c #212121", +"O c #E2E3E3", +"P c #D6DDDB", +"Q c #2B240E", +"R c #4C493C", +"S c #7A7A70", +"T c #ABAB9F", +"U c #A7A79A", +"V c #AEAEA9", +"W c #1D1D1A", +"X c #C8C8C2", +"Y c #A5A59B", +"Z c #A2A49C", +"` c #CDD0CC", +" . c #DCDCD7", +".. c #DDDDD9", +"+. c #C6C6C6", +"@. c #474746", +"#. c #393939", +"$. c #B3B3B3", +"%. c #757575", +"&. c #4A4A4A", +"*. c #838383", +"=. c #DADADA", +"-. c #626262", +";. c #939393", +">. c #808080", +" . ", +" + @ # $ % ", +" . & * = - - ; > , ", +" . ' ) ! ~ { # ] ^ . / ( _ ", +" : < - - [ } { | 1 2 3 4 5 . ", +" 6 7 8 9 0 a b c # d e f g ", +" h i j k l m - n o p q r ", +" . s t u v w x y z A B C D ", +" A - - E F G H I J K L M ", +" N < O P Q R S T U U V W ", +" & X Y Z ` ...+.@.. ", +" #.$.- - - - %.&. ", +" *.~ - =.-. ", +" ;.>.. "};
--- a/src/aim.c Wed Feb 07 21:13:22 2001 +0000 +++ b/src/aim.c Wed Feb 07 21:46:40 2001 +0000 @@ -633,6 +633,7 @@ } else if ((do_login_ret == -1) && !connections) show_login(); + new_conversation("nobody"); gtk_main(); #endif /* USE_APPLET */
--- a/src/conversation.c Wed Feb 07 21:13:22 2001 +0000 +++ b/src/conversation.c Wed Feb 07 21:46:40 2001 +0000 @@ -37,20 +37,21 @@ #include "gtkspell.h" #include "prpl.h" -#include "pixmaps/underline.xpm" #include "pixmaps/bold.xpm" #include "pixmaps/italic.xpm" +#include "pixmaps/underline.xpm" +#include "pixmaps/strike.xpm" #include "pixmaps/small.xpm" #include "pixmaps/normal.xpm" #include "pixmaps/big.xpm" #include "pixmaps/fontface.xpm" -#include "pixmaps/speaker.xpm" +#include "pixmaps/fgcolor.xpm" +#include "pixmaps/bgcolor.xpm" +#include "pixmaps/link.xpm" #include "pixmaps/smile_icon.xpm" #include "pixmaps/wood.xpm" -#include "pixmaps/link.xpm" -#include "pixmaps/strike.xpm" -#include "pixmaps/fgcolor.xpm" -#include "pixmaps/bgcolor.xpm" +#include "pixmaps/save_small.xpm" +#include "pixmaps/speaker.xpm" #include "pixmaps/luke03.xpm" #include "pixmaps/oneeye.xpm" @@ -128,6 +129,7 @@ if (connections) c->gc = (struct gaim_connection *)connections->data; + c->history = g_string_new(""); show_conv(c); conversations = g_list_append(conversations, c); plugin_event(event_new_conversation, name, 0, 0, 0); @@ -214,6 +216,7 @@ gtk_widget_destroy(c->link_dialog); if (c->log_dialog) gtk_widget_destroy(c->log_dialog); + g_string_free(c->history, TRUE); g_free(c); } @@ -317,6 +320,42 @@ cancel_log(NULL, c); } +static void do_save_convo(GtkObject *obj, GtkWidget *wid) +{ + struct conversation *c = gtk_object_get_user_data(obj); + char *filename = gtk_file_selection_get_filename(GTK_FILE_SELECTION(wid)); + FILE *f; + if (file_is_dir(filename, wid)) + return; + if (g_list_find(conversations, c)) + filename = g_strdup(filename); + else + filename = NULL; + gtk_widget_destroy(wid); + if (!filename) + return; + f = fopen(filename, "w+"); + g_free(filename); + if (!f) + return; + fprintf(f, "%s", c->history->str); + fclose(f); +} + +void save_convo(GtkWidget *save, struct conversation *c) +{ + char buf[BUF_LONG]; + GtkWidget *window = gtk_file_selection_new(_("Gaim - Save Conversation")); + g_snprintf(buf, sizeof(buf), "%s/%s.log", g_get_home_dir(), normalize(c->name)); + gtk_file_selection_set_filename(GTK_FILE_SELECTION(window), buf); + gtk_object_set_user_data(GTK_OBJECT(GTK_FILE_SELECTION(window)->ok_button), c); + gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(window)->ok_button), + "clicked", GTK_SIGNAL_FUNC(do_save_convo), window); + gtk_signal_connect_object(GTK_OBJECT(GTK_FILE_SELECTION(window)->cancel_button), + "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy), (gpointer)window); + gtk_widget_show(window); +} + void insert_smiley(GtkWidget *smiley, struct conversation *c) { if (state_lock) @@ -1172,6 +1211,16 @@ gtk_imhtml_append_text(GTK_IMHTML(c->text), "<BR>", 0); + if (general_options & OPT_GEN_STRIP_HTML) { + char *t1 = strip_html(what); + c->history = g_string_append(c->history, t1); + c->history = g_string_append(c->history, "\n"); + g_free(what); + } else { + c->history = g_string_append(c->history, what); + c->history = g_string_append(c->history, "<BR>\n"); + } + if ((general_options & OPT_GEN_LOG_ALL) || find_log_info(c->name)) { char *t1; char nm[256]; @@ -1253,6 +1302,28 @@ gtk_imhtml_append_text(GTK_IMHTML(c->text), "<BR>", 0); + if (general_options & OPT_GEN_STRIP_HTML) { + char *t1, *t2; + t1 = strip_html(buf); + t2 = strip_html(what); + c->history = g_string_append(c->history, t1); + c->history = g_string_append(c->history, t2); + c->history = g_string_append(c->history, "\n"); + g_free(t1); + g_free(t2); + } else { + char *t1, *t2; + t1 = html_logize(buf); + t2 = html_logize(what); + c->history = g_string_append(c->history, t1); + c->history = g_string_append(c->history, t2); + c->history = g_string_append(c->history, "\n"); + c->history = g_string_append(c->history, logstr->str); + c->history = g_string_append(c->history, "<BR>\n"); + g_free(t1); + g_free(t2); + } + if ((general_options & OPT_GEN_LOG_ALL) || find_log_info(c->name)) { char *t1, *t2; char *nm = g_malloc(256); @@ -1306,11 +1377,11 @@ GtkWidget *build_conv_toolbar(struct conversation *c) { GdkPixmap *strike_i, *small_i, *normal_i, *big_i, *bold_i, *italic_i, *underline_i, *speaker_i, - *wood_i, *fgcolor_i, *bgcolor_i, *link_i, *font_i, *smiley_i; + *wood_i, *fgcolor_i, *bgcolor_i, *link_i, *font_i, *smiley_i, *save_i; GtkWidget *strike_p, *small_p, *normal_p, *big_p, *bold_p, *italic_p, *underline_p, *speaker_p, - *wood_p, *fgcolor_p, *bgcolor_p, *link_p, *font_p, *smiley_p; + *wood_p, *fgcolor_p, *bgcolor_p, *link_p, *font_p, *smiley_p, *save_p; GtkWidget *strike, *small, *normal, *big, *bold, *italic, *underline, *speaker, *wood, - *fgcolorbtn, *bgcolorbtn, *link, *font, *smiley; + *fgcolorbtn, *bgcolorbtn, *link, *font, *smiley, *save; GdkBitmap *mask; GtkWidget *toolbar; GtkWidget *win; @@ -1320,9 +1391,45 @@ win = c->window; entry = c->entry; - link_i = gdk_pixmap_create_from_xpm_d(win->window, &mask, &win->style->white, link_xpm); - link_p = gtk_pixmap_new(link_i, mask); - gtk_widget_show(link_p); + bold_i = gdk_pixmap_create_from_xpm_d(win->window, &mask, &win->style->white, bold_xpm); + bold_p = gtk_pixmap_new(bold_i, mask); + gtk_widget_show(bold_p); + gdk_bitmap_unref(mask); + + italic_i = gdk_pixmap_create_from_xpm_d(win->window, &mask, &win->style->white, italic_xpm); + italic_p = gtk_pixmap_new(italic_i, mask); + gtk_widget_show(italic_p); + gdk_bitmap_unref(mask); + + underline_i = gdk_pixmap_create_from_xpm_d(win->window, &mask, + &win->style->white, underline_xpm); + underline_p = gtk_pixmap_new(underline_i, mask); + gtk_widget_show(underline_p); + gdk_bitmap_unref(mask); + + strike_i = gdk_pixmap_create_from_xpm_d(win->window, &mask, &win->style->white, strike_xpm); + strike_p = gtk_pixmap_new(strike_i, mask); + gtk_widget_show(strike_p); + gdk_bitmap_unref(mask); + + small_i = gdk_pixmap_create_from_xpm_d(win->window, &mask, &win->style->white, small_xpm); + small_p = gtk_pixmap_new(small_i, mask); + gtk_widget_show(small_p); + gdk_bitmap_unref(mask); + + normal_i = gdk_pixmap_create_from_xpm_d(win->window, &mask, &win->style->white, normal_xpm); + normal_p = gtk_pixmap_new(normal_i, mask); + gtk_widget_show(normal_p); + gdk_bitmap_unref(mask); + + big_i = gdk_pixmap_create_from_xpm_d(win->window, &mask, &win->style->white, big_xpm); + big_p = gtk_pixmap_new(big_i, mask); + gtk_widget_show(big_p); + gdk_bitmap_unref(mask); + + font_i = gdk_pixmap_create_from_xpm_d(win->window, &mask, &win->style->white, fontface_xpm); + font_p = gtk_pixmap_new(font_i, mask); + gtk_widget_show(font_p); gdk_bitmap_unref(mask); fgcolor_i = gdk_pixmap_create_from_xpm_d(win->window, &mask, &win->style->white, fgcolor_xpm); @@ -1335,52 +1442,31 @@ gtk_widget_show(bgcolor_p); gdk_bitmap_unref(mask); + link_i = gdk_pixmap_create_from_xpm_d(win->window, &mask, &win->style->white, link_xpm); + link_p = gtk_pixmap_new(link_i, mask); + gtk_widget_show(link_p); + gdk_bitmap_unref(mask); + + smiley_i = gdk_pixmap_create_from_xpm_d(win->window, &mask, &win->style->white, smile_icon_xpm); + smiley_p = gtk_pixmap_new(smiley_i, mask); + gtk_widget_show(smiley_p); + gdk_bitmap_unref(mask); + wood_i = gdk_pixmap_create_from_xpm_d(win->window, &mask, &win->style->white, wood_xpm); wood_p = gtk_pixmap_new(wood_i, mask); gtk_widget_show(wood_p); gdk_bitmap_unref(mask); + + save_i = gdk_pixmap_create_from_xpm_d(win->window, &mask, &win->style->white, save_small_xpm); + save_p = gtk_pixmap_new(save_i, mask); + gtk_widget_show(save_p); + gdk_bitmap_unref(mask); + speaker_i = gdk_pixmap_create_from_xpm_d(win->window, &mask, &win->style->white, speaker_xpm); speaker_p = gtk_pixmap_new(speaker_i, mask); gtk_widget_show(speaker_p); gdk_bitmap_unref(mask); c->makesound = 1; - strike_i = gdk_pixmap_create_from_xpm_d(win->window, &mask, &win->style->white, strike_xpm); - strike_p = gtk_pixmap_new(strike_i, mask); - gtk_widget_show(strike_p); - gdk_bitmap_unref(mask); - bold_i = gdk_pixmap_create_from_xpm_d(win->window, &mask, &win->style->white, bold_xpm); - bold_p = gtk_pixmap_new(bold_i, mask); - gtk_widget_show(bold_p); - gdk_bitmap_unref(mask); - italic_i = gdk_pixmap_create_from_xpm_d(win->window, &mask, &win->style->white, italic_xpm); - italic_p = gtk_pixmap_new(italic_i, mask); - gtk_widget_show(italic_p); - gdk_bitmap_unref(mask); - underline_i = gdk_pixmap_create_from_xpm_d(win->window, &mask, - &win->style->white, underline_xpm); - underline_p = gtk_pixmap_new(underline_i, mask); - gtk_widget_show(underline_p); - gdk_bitmap_unref(mask); - small_i = gdk_pixmap_create_from_xpm_d(win->window, &mask, &win->style->white, small_xpm); - small_p = gtk_pixmap_new(small_i, mask); - gtk_widget_show(small_p); - gdk_bitmap_unref(mask); - normal_i = gdk_pixmap_create_from_xpm_d(win->window, &mask, &win->style->white, normal_xpm); - normal_p = gtk_pixmap_new(normal_i, mask); - gtk_widget_show(normal_p); - gdk_bitmap_unref(mask); - big_i = gdk_pixmap_create_from_xpm_d(win->window, &mask, &win->style->white, big_xpm); - big_p = gtk_pixmap_new(big_i, mask); - gtk_widget_show(big_p); - gdk_bitmap_unref(mask); - font_i = gdk_pixmap_create_from_xpm_d(win->window, &mask, &win->style->white, fontface_xpm); - font_p = gtk_pixmap_new(font_i, mask); - gtk_widget_show(font_p); - gdk_bitmap_unref(mask); - smiley_i = gdk_pixmap_create_from_xpm_d(win->window, &mask, &win->style->white, smile_icon_xpm); - smiley_p = gtk_pixmap_new(smiley_i, mask); - gtk_widget_show(smiley_p); - gdk_bitmap_unref(mask); bold = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_CHILD_TOGGLEBUTTON, NULL, @@ -1399,7 +1485,9 @@ gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_CHILD_TOGGLEBUTTON, NULL, _("Strike"), _("Strike through Text"), _("Strike"), strike_p, GTK_SIGNAL_FUNC(do_strike), entry); + gtk_toolbar_append_space(GTK_TOOLBAR(toolbar)); + small = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), _("Small"), _("Decrease font size"), _("Small"), small_p, GTK_SIGNAL_FUNC(do_small), entry); @@ -1443,6 +1531,17 @@ GTK_TOOLBAR_CHILD_TOGGLEBUTTON, NULL, _("Logging"), _("Enable logging"), _("Logging"), wood_p, GTK_SIGNAL_FUNC(toggle_loggle), c); + state_lock = 1; + if (find_log_info(c->name)) + gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(wood), TRUE); + else + gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(wood), FALSE); + state_lock = 0; + + save = gtk_toolbar_append_item (GTK_TOOLBAR(toolbar), + _("Save"), _("Save Conversation"), + _("Save"), save_p, GTK_SIGNAL_FUNC(save_convo), c); + speaker = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_CHILD_TOGGLEBUTTON, NULL, _("Sound"), _("Enable sounds"), @@ -1451,47 +1550,42 @@ c->makesound = 0; gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(speaker), TRUE); - state_lock = 1; - if (find_log_info(c->name)) - gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(wood), TRUE); - else - gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(wood), FALSE); - state_lock = 0; - /* use a slicker look if the user wants to */ if (display_options & OPT_DISP_COOL_LOOK) { - gtk_button_set_relief(GTK_BUTTON(strike), GTK_RELIEF_NONE); - gtk_button_set_relief(GTK_BUTTON(normal), GTK_RELIEF_NONE); - gtk_button_set_relief(GTK_BUTTON(big), GTK_RELIEF_NONE); gtk_button_set_relief(GTK_BUTTON(bold), GTK_RELIEF_NONE); gtk_button_set_relief(GTK_BUTTON(italic), GTK_RELIEF_NONE); gtk_button_set_relief(GTK_BUTTON(underline), GTK_RELIEF_NONE); - gtk_button_set_relief(GTK_BUTTON(speaker), GTK_RELIEF_NONE); - gtk_button_set_relief(GTK_BUTTON(wood), GTK_RELIEF_NONE); + gtk_button_set_relief(GTK_BUTTON(strike), GTK_RELIEF_NONE); + gtk_button_set_relief(GTK_BUTTON(small), GTK_RELIEF_NONE); + gtk_button_set_relief(GTK_BUTTON(normal), GTK_RELIEF_NONE); + gtk_button_set_relief(GTK_BUTTON(big), GTK_RELIEF_NONE); + gtk_button_set_relief(GTK_BUTTON(font), GTK_RELIEF_NONE); gtk_button_set_relief(GTK_BUTTON(fgcolorbtn), GTK_RELIEF_NONE); gtk_button_set_relief(GTK_BUTTON(bgcolorbtn), GTK_RELIEF_NONE); gtk_button_set_relief(GTK_BUTTON(link), GTK_RELIEF_NONE); - gtk_button_set_relief(GTK_BUTTON(font), GTK_RELIEF_NONE); - gtk_button_set_relief(GTK_BUTTON(small), GTK_RELIEF_NONE); gtk_button_set_relief(GTK_BUTTON(smiley), GTK_RELIEF_NONE); + gtk_button_set_relief(GTK_BUTTON(wood), GTK_RELIEF_NONE); + gtk_button_set_relief(GTK_BUTTON(save), GTK_RELIEF_NONE); + gtk_button_set_relief(GTK_BUTTON(speaker), GTK_RELIEF_NONE); } gtk_widget_show(toolbar); - gdk_pixmap_unref(link_i); - gdk_pixmap_unref(fgcolor_i); - gdk_pixmap_unref(bgcolor_i); - gdk_pixmap_unref(wood_i); - gdk_pixmap_unref(speaker_i); - gdk_pixmap_unref(strike_i); gdk_pixmap_unref(bold_i); gdk_pixmap_unref(italic_i); gdk_pixmap_unref(underline_i); + gdk_pixmap_unref(strike_i); gdk_pixmap_unref(small_i); gdk_pixmap_unref(normal_i); gdk_pixmap_unref(big_i); gdk_pixmap_unref(font_i); + gdk_pixmap_unref(fgcolor_i); + gdk_pixmap_unref(bgcolor_i); + gdk_pixmap_unref(link_i); gdk_pixmap_unref(smiley_i); + gdk_pixmap_unref(wood_i); + gdk_pixmap_unref(save_i); + gdk_pixmap_unref(speaker_i); c->bold = bold; c->strike = strike;
--- a/src/gaim.h Wed Feb 07 21:13:22 2001 +0000 +++ b/src/gaim.h Wed Feb 07 21:46:40 2001 +0000 @@ -328,6 +328,8 @@ GdkColor fgcol; int hasfg; + GString *history; + GtkWidget *send; /* stuff used just for IM */
--- a/src/server.c Wed Feb 07 21:13:22 2001 +0000 +++ b/src/server.c Wed Feb 07 21:46:40 2001 +0000 @@ -634,6 +634,7 @@ b->in_room = NULL; b->id = id; b->gc = gc; + b->history = g_string_new(""); g_snprintf(b->name, 80, "%s", name); if ((general_options & OPT_GEN_LOG_ALL) || find_log_info(b->name)) { @@ -693,6 +694,7 @@ b->ignored = g_list_remove(b->ignored, b->ignored->data); } + g_string_free(b->history, TRUE); g_free(b); }