Mercurial > pidgin
changeset 858:3de6e98e8898
[gaim-migrate @ 868]
the fg/bg buttons work now :-P
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Thu, 07 Sep 2000 23:08:44 +0000 |
parents | 41bfae606d39 |
children | 75172284a1a7 |
files | TODO src/buddy_chat.c src/conversation.c src/dialogs.c src/gaim.h src/prefs.c |
diffstat | 6 files changed, 138 insertions(+), 50 deletions(-) [+] |
line wrap: on
line diff
--- a/TODO Thu Sep 07 22:14:17 2000 +0000 +++ b/TODO Thu Sep 07 23:08:44 2000 +0000 @@ -1,10 +1,6 @@ --- STUFF FOR 0.10.1 RELEASE --- Execute Command on Buddy Pounce Redesign the Foreground/Background color options under preferences. - Add ability to conversaton window to allow changing of foreground/ - background colours per conversation window. This is done, - there just needs to be some way to actually change the - values. Have a page in the prefs for the Applet The about window is very ugly. I think this shall be fixed. You know, I really like the gnome look to some apps
--- a/src/buddy_chat.c Thu Sep 07 22:14:17 2000 +0000 +++ b/src/buddy_chat.c Thu Sep 07 23:08:44 2000 +0000 @@ -674,7 +674,8 @@ gtk_signal_connect(GTK_OBJECT(win), "destroy", GTK_SIGNAL_FUNC(close_callback),b); b->font_dialog = NULL; - b->color_dialog = NULL; + b->fg_color_dialog = NULL; + b->bg_color_dialog = NULL; b->smiley_dialog = NULL; b->link_dialog = NULL; b->log_dialog = NULL;
--- a/src/conversation.c Thu Sep 07 22:14:17 2000 +0000 +++ b/src/conversation.c Thu Sep 07 23:08:44 2000 +0000 @@ -238,8 +238,10 @@ void delete_conversation(struct conversation *c) { conversations = g_list_remove(conversations, c); - if (c->color_dialog) - gtk_widget_destroy(c->color_dialog); + if (c->fg_color_dialog) + gtk_widget_destroy(c->fg_color_dialog); + if (c->bg_color_dialog) + gtk_widget_destroy(c->bg_color_dialog); if (c->font_dialog) gtk_widget_destroy(c->font_dialog); if (c->smiley_dialog) @@ -365,9 +367,12 @@ gtk_widget_destroy(c->window); c->window = NULL; - if (c->color_dialog) - gtk_widget_destroy(c->color_dialog); - c->color_dialog = NULL; + if (c->fg_color_dialog) + gtk_widget_destroy(c->fg_color_dialog); + c->fg_color_dialog = NULL; + if (c->bg_color_dialog) + gtk_widget_destroy(c->bg_color_dialog); + c->bg_color_dialog = NULL; if (c->font_dialog) gtk_widget_destroy(c->font_dialog); c->font_dialog = NULL; @@ -890,14 +895,26 @@ gtk_widget_grab_focus(entry); } -void toggle_color(GtkWidget *color, struct conversation *c) +void toggle_fg_color(GtkWidget *color, struct conversation *c) { if (state_lock) return; if (GTK_TOGGLE_BUTTON(color)->active) - show_color_dialog(c, color); - else if (c->color_dialog) - cancel_color(color, c); + show_fgcolor_dialog(c, color); + else if (c->fg_color_dialog) + cancel_fgcolor(color, c); + else + advance_past(c->entry, "<FONT COLOR>", "</FONT>" ); +} + +void toggle_bg_color(GtkWidget *color, struct conversation *c) +{ + if (state_lock) + return; + if (GTK_TOGGLE_BUTTON(color)->active) + show_bgcolor_dialog(c, color); + else if (c->bg_color_dialog) + cancel_bgcolor(color, c); else advance_past(c->entry, "<FONT COLOR>", "</FONT>" ); } @@ -1461,11 +1478,11 @@ fgcolorbtn = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_CHILD_TOGGLEBUTTON, NULL, _("Color"), _("Text Color"), - _("Color"), fgcolor_p, GTK_SIGNAL_FUNC(toggle_color), c); + _("Color"), fgcolor_p, GTK_SIGNAL_FUNC(toggle_fg_color), c); bgcolorbtn = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_CHILD_TOGGLEBUTTON, NULL, _("Color"), _("Background Color"), - _("Color"), bgcolor_p, GTK_SIGNAL_FUNC(toggle_color), c); + _("Color"), bgcolor_p, GTK_SIGNAL_FUNC(toggle_bg_color), c); bold = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_CHILD_TOGGLEBUTTON, NULL, @@ -1728,7 +1745,8 @@ gtk_widget_show(text); c->font_dialog = NULL; - c->color_dialog = NULL; + c->fg_color_dialog = NULL; + c->bg_color_dialog = NULL; c->smiley_dialog = NULL; c->link_dialog = NULL; c->log_dialog = NULL;
--- a/src/dialogs.c Thu Sep 07 22:14:17 2000 +0000 +++ b/src/dialogs.c Thu Sep 07 23:08:44 2000 +0000 @@ -278,17 +278,19 @@ static gint delete_event_dialog(GtkWidget *w, GdkEventAny *e, struct conversation *c) { gchar *object_data; - dialogwindows = g_list_remove(dialogwindows, w); - gtk_widget_destroy(w); - object_data = gtk_object_get_user_data(GTK_OBJECT(w)); if (GTK_IS_COLOR_SELECTION_DIALOG(w)) { set_state_lock(1); - gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(c->fgcolorbtn), FALSE); + if (w == c->fg_color_dialog) { + gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(c->fgcolorbtn), FALSE); + c->fg_color_dialog = NULL; + } else { + gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(c->bgcolorbtn), FALSE); + c->bg_color_dialog = NULL; + } set_state_lock(0); - c->color_dialog = NULL; } else if (GTK_IS_FONT_SELECTION_DIALOG(w)) { @@ -312,6 +314,9 @@ c->log_dialog = NULL; } + dialogwindows = g_list_remove(dialogwindows, w); + gtk_widget_destroy(w); + return FALSE; } @@ -2317,7 +2322,7 @@ static GtkWidget *fgcseld = NULL; static GtkWidget *bgcseld = NULL; -void cancel_color(GtkWidget *widget, struct conversation *c) +void cancel_fgcolor(GtkWidget *widget, struct conversation *c) { if (c->fgcolorbtn && widget) { @@ -2325,12 +2330,25 @@ gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(c->fgcolorbtn), FALSE); set_state_lock(0); } - dialogwindows = g_list_remove(dialogwindows, c->color_dialog); - gtk_widget_destroy(c->color_dialog); - c->color_dialog = NULL; + dialogwindows = g_list_remove(dialogwindows, c->fg_color_dialog); + gtk_widget_destroy(c->fg_color_dialog); + c->fg_color_dialog = NULL; } -void do_color(GtkWidget *widget, GtkColorSelection *colorsel) +void cancel_bgcolor(GtkWidget *widget, struct conversation *c) +{ + if (c->bgcolorbtn && widget) + { + set_state_lock(1); + gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(c->bgcolorbtn), FALSE); + set_state_lock(0); + } + dialogwindows = g_list_remove(dialogwindows, c->bg_color_dialog); + gtk_widget_destroy(c->bg_color_dialog); + c->bg_color_dialog = NULL; +} + +void do_fgcolor(GtkWidget *widget, GtkColorSelection *colorsel) { gdouble color[3]; GdkColor text_color; @@ -2347,15 +2365,43 @@ text_color.red = ((guint16)(color[0]*65535))>>8; text_color.green = ((guint16)(color[1]*65535))>>8; text_color.blue = ((guint16)(color[2]*65535))>>8; + c->fgcol = text_color; c->hasfg = 1; - g_snprintf(open_tag, 23, "<FONT COLOR=\"#%02X%02X%02X\">", text_color.red, text_color.green, text_color.blue); surround(c->entry, open_tag, "</FONT>"); sprintf(debug_buff,"#%02X%02X%02X\n", text_color.red, text_color.green, text_color.blue); debug_print(debug_buff); g_free(open_tag); - cancel_color(NULL, c); + cancel_fgcolor(NULL, c); +} + +void do_bgcolor(GtkWidget *widget, GtkColorSelection *colorsel) +{ + gdouble color[3]; + GdkColor text_color; + struct conversation *c; + char *open_tag; + + open_tag = g_malloc(30); + + gtk_color_selection_get_color (colorsel, color); + + c = gtk_object_get_user_data(GTK_OBJECT(colorsel)); + /* GTK_IS_EDITABLE(c->entry); huh? */ + + text_color.red = ((guint16)(color[0]*65535))>>8; + text_color.green = ((guint16)(color[1]*65535))>>8; + text_color.blue = ((guint16)(color[2]*65535))>>8; + + c->bgcol = text_color; + c->hasbg = 1; + g_snprintf(open_tag, 25, "<BODY BGCOLOR=\"#%02X%02X%02X\">", text_color.red, text_color.green, text_color.blue); + surround(c->entry, open_tag, "</BODY>"); + sprintf(debug_buff,"#%02X%02X%02X\n", text_color.red, text_color.green, text_color.blue); + debug_print(debug_buff); + g_free(open_tag); + cancel_bgcolor(NULL, c); } static void destroy_colorsel(GtkWidget *w, gpointer d) @@ -2389,11 +2435,11 @@ } } -void show_color_dialog(struct conversation *c, GtkWidget *color) +void show_fgcolor_dialog(struct conversation *c, GtkWidget *color) { GtkWidget *colorsel; - if ((int)color == 1) { /* foreground */ + if (color == NULL) { /* we came from the prefs */ if (fgcseld) return; fgcseld = gtk_color_selection_dialog_new(_("Select Text Color")); @@ -2405,7 +2451,32 @@ gtk_widget_show(fgcseld); gdk_window_raise(fgcseld->window); return; - } else if ((int)color == 2) { /* background */ + } + + if (!c->fg_color_dialog) { + c->fg_color_dialog = gtk_color_selection_dialog_new(_("Select Text Color")); + + colorsel = GTK_COLOR_SELECTION_DIALOG(c->fg_color_dialog)->colorsel; + + gtk_object_set_user_data(GTK_OBJECT(colorsel), c); + + gtk_signal_connect(GTK_OBJECT(c->fg_color_dialog), "delete_event", GTK_SIGNAL_FUNC(delete_event_dialog), c); + gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(c->fg_color_dialog)->ok_button), "clicked", GTK_SIGNAL_FUNC(do_fgcolor), colorsel); + gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(c->fg_color_dialog)->cancel_button), "clicked", GTK_SIGNAL_FUNC(cancel_fgcolor), c); + + gtk_widget_realize(c->fg_color_dialog); + aol_icon(c->fg_color_dialog->window); + } + + gtk_widget_show(c->fg_color_dialog); + gdk_window_raise(c->fg_color_dialog->window); +} + +void show_bgcolor_dialog(struct conversation *c, GtkWidget *color) +{ + GtkWidget *colorsel; + + if (color == NULL) { /* we came from the prefs */ if (bgcseld) return; bgcseld = gtk_color_selection_dialog_new(_("Select Background Color")); @@ -2419,24 +2490,23 @@ return; } - if (!c->color_dialog) - { - c->color_dialog = gtk_color_selection_dialog_new(_("Select Text Color")); + if (!c->bg_color_dialog) { + c->bg_color_dialog = gtk_color_selection_dialog_new(_("Select Text Color")); - colorsel = GTK_COLOR_SELECTION_DIALOG(c->color_dialog)->colorsel; + colorsel = GTK_COLOR_SELECTION_DIALOG(c->bg_color_dialog)->colorsel; gtk_object_set_user_data(GTK_OBJECT(colorsel), c); - gtk_signal_connect(GTK_OBJECT(c->color_dialog), "delete_event", GTK_SIGNAL_FUNC(delete_event_dialog), c); - gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(c->color_dialog)->ok_button), "clicked", GTK_SIGNAL_FUNC(do_color), colorsel); - gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(c->color_dialog)->cancel_button), "clicked", GTK_SIGNAL_FUNC(cancel_color), c); - - gtk_widget_realize(c->color_dialog); - aol_icon(c->color_dialog->window); + gtk_signal_connect(GTK_OBJECT(c->bg_color_dialog), "delete_event", GTK_SIGNAL_FUNC(delete_event_dialog), c); + gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(c->bg_color_dialog)->ok_button), "clicked", GTK_SIGNAL_FUNC(do_bgcolor), colorsel); + gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(c->bg_color_dialog)->cancel_button), "clicked", GTK_SIGNAL_FUNC(cancel_bgcolor), c); + + gtk_widget_realize(c->bg_color_dialog); + aol_icon(c->bg_color_dialog->window); } - gtk_widget_show(c->color_dialog); - gdk_window_raise(c->color_dialog->window); + gtk_widget_show(c->bg_color_dialog); + gdk_window_raise(c->bg_color_dialog->window); } /*------------------------------------------------------------------------*/
--- a/src/gaim.h Thu Sep 07 22:14:17 2000 +0000 +++ b/src/gaim.h Thu Sep 07 23:08:44 2000 +0000 @@ -273,7 +273,8 @@ GtkWidget *strike; GtkWidget *font; GtkWidget *smiley; - GtkWidget *color_dialog; + GtkWidget *fg_color_dialog; + GtkWidget *bg_color_dialog; GtkWidget *font_dialog; GtkWidget *smiley_dialog; GtkWidget *link_dialog; @@ -407,7 +408,7 @@ #define TYPE_SIGNOFF 4 #define TYPE_KEEPALIVE 5 -#define REVISION "gaim:$Revision: 864 $" +#define REVISION "gaim:$Revision: 868 $" #define FLAPON "FLAPON\r\n\r\n" #define ROAST "Tic/Toc" @@ -801,8 +802,10 @@ extern void show_register_dialog(); extern void show_set_info(); extern void show_set_dir(); -extern void show_color_dialog(struct conversation *c, GtkWidget *color); -extern void cancel_color(GtkWidget *widget, struct conversation *c); +extern void show_fgcolor_dialog(struct conversation *c, GtkWidget *color); +extern void show_bgcolor_dialog(struct conversation *c, GtkWidget *color); +extern void cancel_fgcolor(GtkWidget *widget, struct conversation *c); +extern void cancel_bgcolor(GtkWidget *widget, struct conversation *c); extern void create_away_mess(GtkWidget *, void *); extern void show_ee_dialog(int); extern void show_add_link(GtkWidget *,struct conversation *);
--- a/src/prefs.c Thu Sep 07 22:14:17 2000 +0000 +++ b/src/prefs.c Thu Sep 07 23:08:44 2000 +0000 @@ -1017,7 +1017,7 @@ gtk_box_pack_start(GTK_BOX(hbox), select, FALSE, FALSE, 5); if (!(font_options & OPT_FONT_FGCOL)) gtk_widget_set_sensitive(GTK_WIDGET(select), FALSE); - gtk_signal_connect(GTK_OBJECT(select), "clicked", GTK_SIGNAL_FUNC(show_color_dialog), (void *)1); + gtk_signal_connect(GTK_OBJECT(select), "clicked", GTK_SIGNAL_FUNC(show_fgcolor_dialog), NULL); gtk_widget_show(select); gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(toggle_sensitive), select); @@ -1032,7 +1032,7 @@ gtk_box_pack_start(GTK_BOX(hbox), select, FALSE, FALSE, 5); if (!(font_options & OPT_FONT_BGCOL)) gtk_widget_set_sensitive(GTK_WIDGET(select), FALSE); - gtk_signal_connect(GTK_OBJECT(select), "clicked", GTK_SIGNAL_FUNC(show_color_dialog), (void *)2); + gtk_signal_connect(GTK_OBJECT(select), "clicked", GTK_SIGNAL_FUNC(show_bgcolor_dialog), NULL); gtk_widget_show(select); gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(toggle_sensitive), select);