Mercurial > pidgin.yaz
diff pidgin/gtkconv.c @ 22795:42dfa1139b5c
merge of '21d37789f674809d615fc7676a092f1da438b0f5'
and 'aafbbc317ab5f69e31e0bb6cabc264bb70745ef2'
author | Evan Schoenberg <evan.s@dreskin.net> |
---|---|
date | Fri, 02 May 2008 22:51:14 +0000 |
parents | 9cbb7c2aba23 |
children | 958f9379eb1a |
line wrap: on
line diff
--- a/pidgin/gtkconv.c Fri May 02 22:50:13 2008 +0000 +++ b/pidgin/gtkconv.c Fri May 02 22:51:14 2008 +0000 @@ -3052,7 +3052,7 @@ { N_("/Options/Enable _Sounds"), NULL, menu_sounds_cb, 0, "<CheckItem>", NULL }, { "/Options/sep0", NULL, NULL, 0, "<Separator>", NULL }, { N_("/Options/Show Formatting _Toolbars"), NULL, menu_toolbar_cb, 0, "<CheckItem>", NULL }, - { N_("/Options/Show Ti_mestamps"), "F2", menu_timestamps_cb, 0, "<CheckItem>", NULL }, + { N_("/Options/Show Ti_mestamps"), NULL, menu_timestamps_cb, 0, "<CheckItem>", NULL }, }; static const int menu_item_count = @@ -3980,11 +3980,10 @@ } static void -tab_complete_process_item(int *most_matched, char *entered, char **partial, char *nick_partial, +tab_complete_process_item(int *most_matched, char *entered, gsize entered_bytes, char **partial, char *nick_partial, GList **matches, gboolean command, char *name) { - strncpy(nick_partial, name, strlen(entered)); - nick_partial[strlen(entered)] = '\0'; + memcpy(nick_partial, name, entered_bytes); if (purple_utf8_strcasecmp(nick_partial, entered)) return; @@ -4029,6 +4028,7 @@ const char *prefix; GList *matches = NULL; gboolean command = FALSE; + gsize entered_bytes = 0; gtkconv = PIDGIN_CONVERSATION(conv); @@ -4048,19 +4048,24 @@ /* if we're at the end of ": " we need to move back 2 spaces */ start = strlen(text) - 1; - if (strlen(text) >= 2 && !strncmp(&text[start-1], ": ", 2)) { + if (start >= 1 && !strncmp(&text[start-1], ": ", 2)) { gtk_text_iter_backward_chars(&word_start, 2); - start-=2; - } - - /* find the start of the word that we're tabbing */ - while (start >= 0 && text[start] != ' ') { - gtk_text_iter_backward_char(&word_start); - start--; + } + + /* find the start of the word that we're tabbing. + * Using gtk_text_iter_backward_word_start won't work, because a nick can contain + * characters (e.g. '.', '/' etc.) that Pango may think are word separators. */ + while (gtk_text_iter_backward_char(&word_start)) { + if (gtk_text_iter_get_char(&word_start) == ' ') { + /* Reached the whitespace before the start of the word. Move forward once */ + gtk_text_iter_forward_char(&word_start); + break; + } } prefix = pidgin_get_cmd_prefix(); - if (start == -1 && (strlen(text) >= strlen(prefix)) && !strncmp(text, prefix, strlen(prefix))) { + if (gtk_text_iter_get_offset(&word_start) == 0 && + (strlen(text) >= strlen(prefix)) && !strncmp(text, prefix, strlen(prefix))) { command = TRUE; gtk_text_iter_forward_chars(&word_start, strlen(prefix)); } @@ -4069,13 +4074,14 @@ entered = gtk_text_buffer_get_text(gtkconv->entry_buffer, &word_start, &cursor, FALSE); + entered_bytes = strlen(entered); if (!g_utf8_strlen(entered, -1)) { g_free(entered); return (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) ? TRUE : FALSE; } - nick_partial = g_malloc(strlen(entered)+1); + nick_partial = g_malloc0(entered_bytes + 1); if (command) { GList *list = purple_cmd_list(conv); @@ -4083,7 +4089,7 @@ /* Commands */ for (l = list; l != NULL; l = l->next) { - tab_complete_process_item(&most_matched, entered, &partial, nick_partial, + tab_complete_process_item(&most_matched, entered, entered_bytes, &partial, nick_partial, &matches, TRUE, l->data); } g_list_free(list); @@ -4096,7 +4102,7 @@ /* Users */ for (; l != NULL; l = l->next) { - tab_complete_process_item(&most_matched, entered, &partial, nick_partial, + tab_complete_process_item(&most_matched, entered, entered_bytes, &partial, nick_partial, &matches, TRUE, ((PurpleConvChatBuddy *)l->data)->name); } @@ -4114,7 +4120,7 @@ -1); if (name && alias && strcmp(name, alias)) - tab_complete_process_item(&most_matched, entered, &partial, nick_partial, + tab_complete_process_item(&most_matched, entered, entered_bytes, &partial, nick_partial, &matches, FALSE, alias); g_free(name); g_free(alias); @@ -4452,7 +4458,9 @@ GdkRectangle oneline; int height, diff; int pad_top, pad_inside, pad_bottom; - int max_height = gtkconv->tab_cont->allocation.height / 2; + int total_height = (gtkconv->imhtml->allocation.height + gtkconv->entry->allocation.height); + int max_height = total_height / 2; + int min_height; pad_top = gtk_text_view_get_pixels_above_lines(GTK_TEXT_VIEW(gtkconv->entry)); pad_bottom = gtk_text_view_get_pixels_below_lines(GTK_TEXT_VIEW(gtkconv->entry)); @@ -4476,12 +4484,11 @@ /* Make sure there's enough room for at least two lines. Allocate enough space to * prevent scrolling when the second line is a continuation of the first line, or * is the beginning of a new paragraph. */ - height = MAX(height, 2 * (oneline.height + MAX(pad_inside, pad_top + pad_bottom))); - - height = MIN(height, max_height); + min_height = 2 * (oneline.height + MAX(pad_inside, pad_top + pad_bottom)); + height = CLAMP(height, min_height, max_height); diff = height - gtkconv->entry->allocation.height; - if (diff == 0 || (diff < 0 && -diff < oneline.height / 2)) + if (ABS(diff) < oneline.height / 2) return FALSE; gtk_widget_set_size_request(gtkconv->lower_hbox, -1, @@ -4758,6 +4765,7 @@ /* Setup the gtkimhtml widget */ frame = pidgin_create_imhtml(FALSE, >kconv->imhtml, NULL, &imhtml_sw); + gtk_widget_set_size_request(gtkconv->imhtml, -1, 0); if (chat) { GtkWidget *hpaned;