Mercurial > pidgin
changeset 10108:f0100b414d98
[gaim-migrate @ 11141]
Two things:
a. Added Enter as a gtk_binding to GtkIMHtml. This fixes everything.
Input methods now work. The "Enter sends" and "Ctrl-Enter sends" preferences
were removed and defaulted to yes and no respectively, BUT, in a very super-cool
turn of events, you can now add your own bindings to .gtkrc to make WHATEVER
YOU WANT send. Awesome. Someone should use g_signal_accumulator_true_handled
or something to make profiles and away messages able to insert newlines.
b. Removed "Use multi-colored screennames in chats," defaulted to yes, and
wrote a nifty algorithm to automatically adjust the colors to accomodate the
background (see http://gaim.sf.net/sean/porn-chat.png). People should play
around and tweak it a bit. The algorithm takes into consideration the
luminosity of the current background and the base hue to use for the screenname
in generating the new colors. Note that it does this while maintaining the hues.
Someone should optimize this so it skips over the floating point arithmatic when
the background color is white.
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Sun, 17 Oct 2004 23:55:49 +0000 |
parents | 65e7df286076 |
children | 4fa4267b1f59 |
files | src/gtkconv.c src/gtkimhtml.c src/gtkimhtml.h src/gtkprefs.c |
diffstat | 4 files changed, 54 insertions(+), 56 deletions(-) [+] |
line wrap: on
line diff
--- a/src/gtkconv.c Sun Oct 17 22:38:24 2004 +0000 +++ b/src/gtkconv.c Sun Oct 17 23:55:49 2004 +0000 @@ -69,43 +69,24 @@ #define SEND_COLOR "#0d005d" #define RECV_COLOR "#fd4100" -static char nick_colors[][8] = { - "#ba55d3", /* Medium Orchid */ - "#ee82ee", /* Violet */ - "#c715b4", /* Medium Violet Red */ - "#ff69b4", /* Hot Pink */ - "#ff6347", /* Tomato */ - "#fa8c00", /* Dark Orange */ - "#fa8072", /* Salmon */ - "#b22222", /* Fire Brick */ - "#f4a460", /* Sandy Brown */ - "#cd5c5c", /* Indian Red */ - "#bc8f8f", /* Rosy Brown */ - "#f0e68c", /* Khaki */ - "#bdb76b", /* Dark Khaki */ - "#228b22", /* Forest Green */ - "#9acd32", /* Yellow Green */ - "#32cd32", /* Lime Green */ - "#3cb371", /* Medium Sea Green (Medium Sea Green?! What are we women?!) */ - "#2e8b57", /* Sea Green */ - "#8fbc8f", /* Dark Sea Green */ - "#66cdaa", /* Medium Aquamarine */ - "#5f9ea0", /* Cadet Blue */ - "#48d1cc", /* Medium Turquoise */ - "#00ced1", /* Dark Turquoise */ - "#4682b4", /* Stell Blue */ - "#00bfff", /* Deep Sky Blue */ - "#1690ff", /* Dodger Blue */ - "#4169ff", /* Royal Blue */ - "#6a5acd", /* Slate Blue */ - "#6495ed", /* Cornflower Blue */ - "#708090", /* Slate gray */ - "#2f4f4f", /* Dark Slate Gray */ - "#ff8c00", /* Dark Orange */ - "#006400", /* DarkGreen */ - "#8b4513", /* SaddleBrown */ - "#8b8989", /* snow4 */ - "#7d26cd", /* purple3 */ +#define LUMINANCE(c) (float)((0.3*(c.red))+(0.59*(c.green))+(0.11*(c.blue))) + +/* These colors come from the default GNOME palette */ +static GdkColor nick_colors[] = { + {0, 47616, 46336, 43776}, /* Basic 3D Medium */ + {0, 33536, 42496, 32512}, /* Green Medium */ + {0, 49408, 26112, 23040}, /* Red Medium */ + {0, 23808, 29952, 21760}, /* Green Dark */ + {0, 34816, 17920, 12544}, /* Red Dark */ + {0, 45824, 37120, 26880}, /* Face skin Dark */ + {0, 32768, 32000, 29696}, /* Basic 3D Dark */ + {0, 33280, 26112, 18176}, /* Face Skin Shadow */ + {0, 57088, 16896, 7680}, /* Accent Red */ + {0, 17920, 40960, 17920}, /* Accent Green */ + {0, 39168, 0, 0}, /* Accent Red Dark */ + {0, 9728, 50944, 9728}, /* Accent Green Dark */ + {0, 34816, 32512, 41728}, /* Purple Medium */ + {0, 49408, 14336, 8704} /* Red Shadow */ }; #define NUM_NICK_COLORS (sizeof(nick_colors) / sizeof(*nick_colors)) @@ -5223,9 +5204,20 @@ if (flags & GAIM_MESSAGE_NICK) strcpy(color, "#AF7F00"); else if (flags & GAIM_MESSAGE_RECV) { - if (flags & GAIM_MESSAGE_COLORIZE) - strcpy(color, nick_colors[g_str_hash(who) % NUM_NICK_COLORS]); - else + if (flags & GAIM_MESSAGE_COLORIZE) { + GtkStyle *style = gtk_widget_get_style(gtkconv->imhtml); + GdkColor col = nick_colors[g_str_hash(who) % NUM_NICK_COLORS]; + float scale = ((1-(LUMINANCE(style->base[GTK_STATE_NORMAL]) / LUMINANCE(style->white))) * + (LUMINANCE(style->white)/MAX(MAX(col.red, col.blue), col.green))); + if (scale > 1) { /* The colors are chosen to look fine on white; we should never have to darken */ + col.red = col.red * scale; + col.green = col.green * scale; + col.blue = col.blue * scale; + } + + g_snprintf(color, sizeof(color), "#%02X%02X%02X", + col.red >> 8, col.green >> 8, col.blue >> 8); + } else strcpy(color, RECV_COLOR); } else if (flags & GAIM_MESSAGE_SEND) @@ -6334,8 +6326,6 @@ /* Conversations */ gaim_prefs_add_none("/gaim/gtk/conversations"); gaim_prefs_add_bool("/gaim/gtk/conversations/close_on_tabs", TRUE); - gaim_prefs_add_bool("/gaim/gtk/conversations/ctrl_enter_sends", FALSE); - gaim_prefs_add_bool("/gaim/gtk/conversations/enter_sends", TRUE); gaim_prefs_add_bool("/gaim/gtk/conversations/escape_closes", FALSE); gaim_prefs_add_bool("/gaim/gtk/conversations/send_formatting", FALSE); gaim_prefs_add_bool("/gaim/gtk/conversations/send_bold", FALSE); @@ -6350,8 +6340,6 @@ #else gaim_prefs_add_bool("/gaim/gtk/conversations/ignore_formatting", FALSE); #endif - gaim_prefs_add_bool("/gaim/gtk/conversations/html_shortcuts", TRUE); - gaim_prefs_add_bool("/gaim/gtk/conversations/smiley_shortcuts", FALSE); gaim_prefs_add_bool("/gaim/gtk/conversations/show_formatting_toolbar", TRUE); gaim_prefs_add_bool("/gaim/gtk/conversations/passthrough_unknown_commands", FALSE); @@ -6369,7 +6357,6 @@ /* Conversations -> Chat */ gaim_prefs_add_none("/gaim/gtk/conversations/chat"); - gaim_prefs_add_bool("/gaim/gtk/conversations/chat/color_nicks", TRUE); gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_width", 410); gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_height", 160); gaim_prefs_add_int("/gaim/gtk/conversations/chat/entry_height", 50);
--- a/src/gtkimhtml.c Sun Oct 17 22:38:24 2004 +0000 +++ b/src/gtkimhtml.c Sun Oct 17 23:55:49 2004 +0000 @@ -120,6 +120,7 @@ TOGGLE_FORMAT, CLEAR_FORMAT, UPDATE_FORMAT, + MESSAGE_SEND, LAST_SIGNAL }; static guint signals [LAST_SIGNAL] = { 0 }; @@ -522,13 +523,14 @@ case GDK_Home: return TRUE; break; - + case GDK_End: return TRUE; break; - + #endif /* !(Gtk+ >= 2.2.0) */ } + return FALSE; } static void paste_unformatted_cb(GtkMenuItem *menu, GtkIMHtml *imhtml) @@ -888,6 +890,11 @@ return FALSE; } +static gboolean imhtml_message_send(GtkIMHtml *imhtml) +{ + return FALSE; +} + static void imhtml_toggle_format(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons) { switch (buttons) { @@ -1007,9 +1014,17 @@ 0, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + signals[MESSAGE_SEND] = g_signal_new("message_send", + G_TYPE_FROM_CLASS(gobject_class), + G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, + G_STRUCT_OFFSET(GtkIMHtmlClass, message_send), + NULL, + 0, g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); klass->toggle_format = imhtml_toggle_format; - + klass->message_send = imhtml_message_send; + gobject_class->finalize = gtk_imhtml_finalize; widget_class->drag_motion = gtk_text_view_drag_motion; gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("hyperlink-color", @@ -1024,6 +1039,9 @@ gtk_binding_entry_add_signal (binding_set, GDK_plus, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_GROW); gtk_binding_entry_add_signal (binding_set, GDK_equal, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_GROW); gtk_binding_entry_add_signal (binding_set, GDK_minus, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_SHRINK); + binding_set = gtk_binding_set_by_class(klass); + gtk_binding_entry_add_signal (binding_set, GDK_KP_Enter, 0, "message_send", 0); + gtk_binding_entry_add_signal (binding_set, GDK_Return, 0, "message_send", 0); } static void gtk_imhtml_init (GtkIMHtml *imhtml)
--- a/src/gtkimhtml.h Sun Oct 17 22:38:24 2004 +0000 +++ b/src/gtkimhtml.h Sun Oct 17 23:55:49 2004 +0000 @@ -132,6 +132,7 @@ void (*toggle_format)(GtkIMHtml *, GtkIMHtmlButtons); void (*clear_format)(GtkIMHtml *); void (*update_format)(GtkIMHtml *); + gboolean (*message_send)(GtkIMHtml *); }; struct _GtkIMHtmlFontDetail {
--- a/src/gtkprefs.c Sun Oct 17 22:38:24 2004 +0000 +++ b/src/gtkprefs.c Sun Oct 17 23:55:49 2004 +0000 @@ -875,12 +875,6 @@ ret = gtk_vbox_new(FALSE, 18); gtk_container_set_border_width (GTK_CONTAINER (ret), 12); - vbox = gaim_gtk_make_frame(ret, _("Send Message")); - gaim_gtk_prefs_checkbox(_("Enter _sends message"), - "/gaim/gtk/conversations/enter_sends", vbox); - gaim_gtk_prefs_checkbox(_("C_ontrol-Enter sends message"), - "/gaim/gtk/conversations/ctrl_enter_sends", vbox); - vbox = gaim_gtk_make_frame (ret, _("Window Closing")); gaim_gtk_prefs_checkbox(_("_Escape closes window"), "/gaim/gtk/conversations/escape_closes", vbox); @@ -990,8 +984,6 @@ gaim_gtk_prefs_checkbox(_("Raise chat _window on events"), "/gaim/gtk/conversations/chat/raise_on_events", vbox); - gaim_gtk_prefs_checkbox(_("Use _multi-colored screen names in chats"), - "/gaim/gtk/conversations/chat/color_nicks", vbox); /* All the tab options! */ vbox = gaim_gtk_make_frame(ret, _("Tab Options"));