Mercurial > pidgin
changeset 832:0142b4c66394
[gaim-migrate @ 842]
redesigned the away messages page
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Sat, 02 Sep 2000 10:41:53 +0000 |
parents | 97f1ae636ed7 |
children | 8d8ef8c3afe2 |
files | TODO src/dialogs.c src/prefs.c |
diffstat | 3 files changed, 86 insertions(+), 79 deletions(-) [+] |
line wrap: on
line diff
--- a/TODO Sat Sep 02 09:02:47 2000 +0000 +++ b/TODO Sat Sep 02 10:41:53 2000 +0000 @@ -6,7 +6,6 @@ there just needs to be some way to actually change the values. Have a page in the prefs for the Applet - Redesign the Away Messages page in the prefs The about window is very ugly. I think this shall be fixed. You know, I really like the gnome look to some apps but I dont want to tie gnome into gaim. oh life sucks
--- a/src/dialogs.c Sat Sep 02 09:02:47 2000 +0000 +++ b/src/dialogs.c Sat Sep 02 10:41:53 2000 +0000 @@ -82,6 +82,7 @@ GtkWidget *entry; GtkWidget *text; GtkWidget *checkbx; + struct away_message *mess; }; @@ -2815,7 +2816,10 @@ guint text_len; gchar *away_message; - am = g_new0(struct away_message, 1); + if (!ca->mess) + am = g_new0(struct away_message, 1); + else + am = ca->mess; g_snprintf(am->name, sizeof(am->name), "%s", gtk_entry_get_text(GTK_ENTRY(ca->entry))); text_len = gtk_text_get_length(GTK_TEXT(ca->text)); away_message = gtk_editable_get_chars(GTK_EDITABLE(ca->text), 0, text_len); @@ -2823,50 +2827,22 @@ g_snprintf(am->message, sizeof(am->message), "%s", away_message); g_free(away_message); - away_messages = g_list_append(away_messages, am); + if (!ca->mess) { + away_messages = g_list_append(away_messages, am); + if (GTK_TOGGLE_BUTTON(ca->checkbx)->active) + do_away_message(NULL, am); + } + save_prefs(); do_away_menu(); + if (prefs_away_list != NULL) + gtk_list_select_item(GTK_LIST(prefs_away_list), g_list_index(away_messages, am)); destroy_dialog(NULL, ca->window); return; } -void create_mess(GtkWidget *widget, struct create_away *ca) -{ - struct away_message *b; - gchar *away_message; - guint text_len; - int is_checked; - - /* Grab the appropriate data */ - b = g_new0(struct away_message, 1); - g_snprintf(b->name, sizeof(b->name), "%s", gtk_entry_get_text(GTK_ENTRY(ca->entry))); - - /* Get proper Length */ - text_len = gtk_text_get_length(GTK_TEXT(ca->text)); - away_message = gtk_editable_get_chars(GTK_EDITABLE(ca->text), 0, text_len); - - g_snprintf(b->message, sizeof(b->message), "%s", away_message); - g_free(away_message); - is_checked = GTK_TOGGLE_BUTTON(ca->checkbx)->active; - - if (is_checked) { - away_messages = g_list_append(away_messages, b); - save_prefs(); - do_away_menu(); - if (prefs_away_list != NULL) - gtk_list_select_item(GTK_LIST(prefs_away_list), g_list_index(away_messages, b)); - } - - /* stick it on the away list */ - if (!strlen(b->name)) - g_snprintf(b->name, sizeof(b->name), "I'm away!"); - do_away_message(NULL, b); - - destroy_dialog(NULL, ca->window); -} - void create_away_mess(GtkWidget *widget, void *dummy) { GtkWidget *bbox; @@ -2925,22 +2901,8 @@ gtk_widget_show(ca->text); gtk_box_pack_start(GTK_BOX(bbox), sw, TRUE, TRUE, 5); - /* Checkbox for showing away msg */ - ca->checkbx = gtk_check_button_new_with_label(_("Save for later use")); - - if (!dummy) /* this only exits if we're comming from the prefs dialog */ - { - gtk_widget_show(ca->checkbx); - - button = picture_button(ca->window, _("Away"), save_xpm); - gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(create_mess), ca); - - } - else - { - button = picture_button(ca->window, _("Save"), save_xpm); - gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(save_away_mess), ca); - } + button = picture_button(ca->window, _("Save"), save_xpm); + gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(save_away_mess), ca); gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 5); @@ -2951,7 +2913,6 @@ /* pack boxes where they belong */ gtk_box_pack_start(GTK_BOX(fbox), titlebox, TRUE, TRUE, 5); gtk_box_pack_start(GTK_BOX(fbox), bbox, TRUE, TRUE, 5); - gtk_box_pack_start(GTK_BOX(fbox), ca->checkbx, TRUE, TRUE, 5); gtk_container_add(GTK_CONTAINER(frame), fbox); gtk_container_set_border_width(GTK_CONTAINER(frame), 5); gtk_box_pack_start(GTK_BOX(tbox), frame, TRUE, TRUE, 0); @@ -2959,9 +2920,21 @@ gtk_container_add(GTK_CONTAINER(ca->window), tbox); + if (dummy && GTK_LIST(prefs_away_list)->selection) { + GtkWidget *item = GTK_LIST(prefs_away_list)->selection->data; + struct away_message *amt = gtk_object_get_user_data(GTK_OBJECT(item)); + int pos = 0; + gtk_entry_set_text(GTK_ENTRY(ca->entry), amt->name); + gtk_editable_insert_text(GTK_EDITABLE(ca->text), amt->message, strlen(amt->message), &pos); + ca->mess = amt; + } else { + /* Checkbox for showing away msg */ + ca->checkbx = gtk_check_button_new_with_label(_("Make Away Now")); + gtk_box_pack_start(GTK_BOX(fbox), ca->checkbx, TRUE, TRUE, 5); + gtk_widget_show(ca->checkbx); + } + /* let the world see what we have done. */ - if (!dummy) - gtk_widget_show(ca->checkbx); gtk_widget_show(label); gtk_widget_show(ca->entry); gtk_widget_show(titlebox);
--- a/src/prefs.c Sat Sep 02 09:02:47 2000 +0000 +++ b/src/prefs.c Sat Sep 02 10:41:53 2000 +0000 @@ -40,6 +40,7 @@ #include "pixmaps/refresh.xpm" #include "pixmaps/gnome_add.xpm" #include "pixmaps/gnome_remove.xpm" +#include "pixmaps/gnome_preferences.xpm" #include "pixmaps/palette.xpm" #include "pixmaps/save.xpm" @@ -1150,19 +1151,7 @@ strcpy(buffer, a->message); gtk_text_insert(GTK_TEXT(away_text), NULL, NULL, NULL, buffer, -1); } -/* -void away_list_unclicked(GtkWidget *widget, struct away_message *a) -{ - if (prefs_away_list == NULL) - return; - strcpy(a->message, edited_message); - save_prefs(); - - /* point edited_message to the new text */ -/* edited_message = gtk_editable_get_chars(GTK_EDITABLE(away_text), 0, -1); -} -*/ void save_away_message(GtkWidget *widget, void *dummy) { /* grab the current message */ @@ -1178,9 +1167,13 @@ i = GTK_LIST(prefs_away_list)->selection; - a = gtk_object_get_user_data(GTK_OBJECT(i->data)); - - rem_away_mess(NULL, a); + if (!i->next) { + int text_len = gtk_text_get_length(GTK_TEXT(away_text)); + gtk_text_set_point(GTK_TEXT(away_text), 0 ); + gtk_text_forward_delete (GTK_TEXT(away_text), text_len); + } + a = gtk_object_get_user_data(GTK_OBJECT(i->data)); + rem_away_mess(NULL, a); } static void paldest(GtkWidget *m, gpointer n) @@ -1189,10 +1182,18 @@ prefs_away_list = NULL; } +static void do_away_mess(GtkWidget *m, gpointer n) +{ + GList *i = GTK_LIST(prefs_away_list)->selection; + if (i) + do_away_message(NULL, gtk_object_get_user_data(GTK_OBJECT(i->data))); +} + static void away_page() { GtkWidget *parent; GtkWidget *box; + GtkWidget *hbox; GtkWidget *top; GtkWidget *bot; GtkWidget *sw; @@ -1200,6 +1201,7 @@ GtkWidget *button; GtkWidget *label; GtkWidget *list_item; + GtkWidget *sep; GList *awy = away_messages; struct away_message *a; char buffer[BUF_LONG]; @@ -1214,14 +1216,32 @@ gtk_container_add(GTK_CONTAINER(prefdialog), box); gtk_widget_show(box); + hbox = gtk_hbox_new(TRUE, 0); + gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 5); + gtk_widget_set_usize(hbox, -1, 30); + gtk_widget_show(hbox); + + hbox = gtk_hbox_new(TRUE, 0); + gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 5); + gtk_widget_show(hbox); + + label = gtk_label_new(_("Title")); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); + gtk_widget_show(label); + + label = gtk_label_new(_("Message")); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); + gtk_widget_show(label); + top = gtk_hbox_new(FALSE, 0); - gtk_box_pack_start(GTK_BOX(box), top, TRUE, TRUE, 0); + gtk_box_pack_start(GTK_BOX(box), top, FALSE, TRUE, 0); gtk_widget_show(top); sw = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_box_pack_start(GTK_BOX(top), sw, TRUE, TRUE, 0); + gtk_widget_set_usize(sw, -1, 225); gtk_widget_show(sw); prefs_away_list = gtk_list_new(); @@ -1238,25 +1258,29 @@ away_text = gtk_text_new(NULL, NULL); gtk_container_add(GTK_CONTAINER(sw2), away_text); gtk_text_set_word_wrap(GTK_TEXT(away_text), TRUE); - gtk_text_set_editable(GTK_TEXT(away_text), TRUE); + gtk_text_set_editable(GTK_TEXT(away_text), FALSE); gtk_widget_show(away_text); bot = gtk_hbox_new(FALSE, 0); - gtk_box_pack_start(GTK_BOX(box), bot, FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(box), bot, FALSE, FALSE, 5); gtk_widget_show(bot); button = picture_button(prefs, _("Add"), gnome_add_xpm); + gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(create_away_mess), NULL); + gtk_box_pack_start(GTK_BOX(bot), button, TRUE, FALSE, 5); + + button = picture_button(prefs, _("Edit"), save_xpm); gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(create_away_mess), button); gtk_box_pack_start(GTK_BOX(bot), button, TRUE, FALSE, 5); + + button = picture_button(prefs, _("Make Away"), gnome_preferences_xpm); + gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(do_away_mess), NULL); + gtk_box_pack_start(GTK_BOX(bot), button, TRUE, FALSE, 5); button = picture_button(prefs, _("Remove"), gnome_remove_xpm); gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(remove_away_message), NULL); gtk_box_pack_start(GTK_BOX(bot), button, TRUE, FALSE, 5); - button = picture_button(prefs, _("Save"), save_xpm); - gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(save_away_message), NULL); - gtk_box_pack_start(GTK_BOX(bot), button, TRUE, FALSE, 5); - if (awy != NULL) { a = (struct away_message *)awy->data; g_snprintf(buffer, sizeof(buffer), "%s", a->message); @@ -1279,6 +1303,17 @@ awy = awy->next; } + sep = gtk_hseparator_new(); + gtk_box_pack_start(GTK_BOX(box), sep, FALSE, FALSE, 0); + gtk_widget_show(sep); + + hbox = gtk_hbox_new(TRUE, 0); + gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 0); + gtk_widget_show(hbox); + + gaim_button(_("Ignore new conversations when away"), &general_options, OPT_GEN_DISCARD_WHEN_AWAY, hbox); + gaim_button(_("Sounds while away"), &sound_options, OPT_SOUND_WHEN_AWAY, hbox); + gtk_widget_show(prefdialog); }