Mercurial > pidgin
comparison src/gtkconv.c @ 6725:e62a504c83d0
[gaim-migrate @ 7252]
I hate the ugly red line.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Wed, 03 Sep 2003 07:27:16 +0000 |
parents | 0c5637b5462e |
children | e7e21e5d1d16 |
comparison
equal
deleted
inserted
replaced
6724:aca39e77db85 | 6725:e62a504c83d0 |
---|---|
1 /** | 1 /** |
2 * @file gtkconv.h GTK+ Conversation API | 2 * @file gtkconv.h GTK+ Conversation API |
3 * @ingroup gtkui | 3 * @ingroup gtkui |
4 * | 4 * |
5 * Copyright (C) 2002-2003 Christian Hammond <chipx86@gnupdate.org> | 5 * Copyright (C) 2002-2003 Christian Hammond <chipx86@gnupdate.org> |
6 * | 6 * |
7 * This program is free software; you can redistribute it and/or modify | 7 * This program is free software; you can redistribute it and/or modify |
8 * it under the terms of the GNU General Public License as published by | 8 * it under the terms of the GNU General Public License as published by |
9 * the Free Software Foundation; either version 2 of the License, or | 9 * the Free Software Foundation; either version 2 of the License, or |
10 * (at your option) any later version. | 10 * (at your option) any later version. |
11 * | 11 * |
204 conv = g_object_get_data(G_OBJECT(wid), "user_data"); | 204 conv = g_object_get_data(G_OBJECT(wid), "user_data"); |
205 gtkconv = GAIM_GTK_CONVERSATION(conv); | 205 gtkconv = GAIM_GTK_CONVERSATION(conv); |
206 im = GAIM_IM(conv); | 206 im = GAIM_IM(conv); |
207 name = gtk_file_selection_get_filename(GTK_FILE_SELECTION(wid)); | 207 name = gtk_file_selection_get_filename(GTK_FILE_SELECTION(wid)); |
208 id = g_slist_length(im->images) + 1; | 208 id = g_slist_length(im->images) + 1; |
209 | 209 |
210 if (gaim_gtk_check_if_dir(name, GTK_FILE_SELECTION(wid))) | 210 if (gaim_gtk_check_if_dir(name, GTK_FILE_SELECTION(wid))) |
211 return; | 211 return; |
212 | 212 |
213 gtk_widget_destroy(wid); | 213 gtk_widget_destroy(wid); |
214 | 214 |
220 "Could not stat image %s\n", name); | 220 "Could not stat image %s\n", name); |
221 return; | 221 return; |
222 } | 222 } |
223 | 223 |
224 filename = name; | 224 filename = name; |
225 while (strchr(filename, '/')) | 225 while (strchr(filename, '/')) |
226 filename = strchr(filename, '/') + 1; | 226 filename = strchr(filename, '/') + 1; |
227 | 227 |
228 buf = g_strdup_printf("<IMG SRC=\"file://%s\" ID=\"%d\" DATASIZE=\"%d\">", | 228 buf = g_strdup_printf("<IMG SRC=\"file://%s\" ID=\"%d\" DATASIZE=\"%d\">", |
229 filename, id, (int)st.st_size); | 229 filename, id, (int)st.st_size); |
230 im->images = g_slist_append(im->images, g_strdup(name)); | 230 im->images = g_slist_append(im->images, g_strdup(name)); |
1379 | 1379 |
1380 return TRUE; | 1380 return TRUE; |
1381 } | 1381 } |
1382 else if ((event->state & GDK_MOD1_MASK) && | 1382 else if ((event->state & GDK_MOD1_MASK) && |
1383 event->keyval > '0' && event->keyval <= '9') { | 1383 event->keyval > '0' && event->keyval <= '9') { |
1384 | 1384 |
1385 gaim_window_switch_conversation(win, event->keyval - '1'); | 1385 gaim_window_switch_conversation(win, event->keyval - '1'); |
1386 | 1386 |
1387 g_signal_stop_emission_by_name(G_OBJECT(entry), "key_press_event"); | 1387 g_signal_stop_emission_by_name(G_OBJECT(entry), "key_press_event"); |
1388 } | 1388 } |
1389 | 1389 |
1390 return FALSE; | 1390 return FALSE; |
1391 } | 1391 } |
1392 | 1392 |
1393 /* | 1393 /* |
1394 * NOTE: | 1394 * NOTE: |
1395 * This guy just kills a single right click from being propagated any | 1395 * This guy just kills a single right click from being propagated any |
1396 * further. I have no idea *why* we need this, but we do ... It | 1396 * further. I have no idea *why* we need this, but we do ... It |
1397 * prevents right clicks on the GtkTextView in a convo dialog from | 1397 * prevents right clicks on the GtkTextView in a convo dialog from |
1398 * going all the way down to the notebook. I suspect a bug in | 1398 * going all the way down to the notebook. I suspect a bug in |
1399 * GtkTextView, but I'm not ready to point any fingers yet. | 1399 * GtkTextView, but I'm not ready to point any fingers yet. |
1400 */ | 1400 */ |
1401 static gboolean | 1401 static gboolean |
1402 entry_stop_rclick_cb(GtkWidget *widget, GdkEventButton *event, gpointer data) | 1402 entry_stop_rclick_cb(GtkWidget *widget, GdkEventButton *event, gpointer data) |
1403 { | 1403 { |
1683 gaim_debug(GAIM_DEBUG_WARNING, "gtkconv", | 1683 gaim_debug(GAIM_DEBUG_WARNING, "gtkconv", |
1684 "Already in the middle of a window drag at tab_press_cb\n"); | 1684 "Already in the middle of a window drag at tab_press_cb\n"); |
1685 return TRUE; | 1685 return TRUE; |
1686 } | 1686 } |
1687 | 1687 |
1688 /* | 1688 /* |
1689 * Make sure a tab was actually clicked. The arrow buttons | 1689 * Make sure a tab was actually clicked. The arrow buttons |
1690 * mess things up. | 1690 * mess things up. |
1691 */ | 1691 */ |
1692 tab_clicked = gaim_gtkconv_get_tab_at_xy(win, e->x_root, e->y_root); | 1692 tab_clicked = gaim_gtkconv_get_tab_at_xy(win, e->x_root, e->y_root); |
1693 | 1693 |
2541 word_start = cursor; | 2541 word_start = cursor; |
2542 | 2542 |
2543 /* if there's nothing there just return */ | 2543 /* if there's nothing there just return */ |
2544 if (!gtk_text_iter_compare(&cursor, &start_buffer)) | 2544 if (!gtk_text_iter_compare(&cursor, &start_buffer)) |
2545 return; | 2545 return; |
2546 | 2546 |
2547 text = gtk_text_buffer_get_text(gtkconv->entry_buffer, &start_buffer, | 2547 text = gtk_text_buffer_get_text(gtkconv->entry_buffer, &start_buffer, |
2548 &cursor, FALSE); | 2548 &cursor, FALSE); |
2549 | 2549 |
2550 /* if we're at the end of ": " we need to move back 2 spaces */ | 2550 /* if we're at the end of ": " we need to move back 2 spaces */ |
2551 start = strlen(text) - 1; | 2551 start = strlen(text) - 1; |
2815 { N_("/_Options"), NULL, NULL, 0, "<Branch>" }, | 2815 { N_("/_Options"), NULL, NULL, 0, "<Branch>" }, |
2816 { N_("/Options/Enable _Logging"), NULL, menu_logging_cb, 0, "<CheckItem>" }, | 2816 { N_("/Options/Enable _Logging"), NULL, menu_logging_cb, 0, "<CheckItem>" }, |
2817 { N_("/Options/Enable _Sounds"), NULL, menu_sounds_cb, 0, "<CheckItem>" }, | 2817 { N_("/Options/Enable _Sounds"), NULL, menu_sounds_cb, 0, "<CheckItem>" }, |
2818 }; | 2818 }; |
2819 | 2819 |
2820 static const int menu_item_count = | 2820 static const int menu_item_count = |
2821 sizeof(menu_items) / sizeof(*menu_items); | 2821 sizeof(menu_items) / sizeof(*menu_items); |
2822 | 2822 |
2823 static char * | 2823 static char * |
2824 item_factory_translate_func (const char *path, gpointer func_data) | 2824 item_factory_translate_func (const char *path, gpointer func_data) |
2825 { | 2825 { |
3921 gtk_container_set_border_width(GTK_CONTAINER(tab_cont), 5); | 3921 gtk_container_set_border_width(GTK_CONTAINER(tab_cont), 5); |
3922 gtk_container_add(GTK_CONTAINER(tab_cont), pane); | 3922 gtk_container_add(GTK_CONTAINER(tab_cont), pane); |
3923 gtk_widget_show(pane); | 3923 gtk_widget_show(pane); |
3924 | 3924 |
3925 new_ui = TRUE; | 3925 new_ui = TRUE; |
3926 | 3926 |
3927 gtkconv->make_sound = TRUE; | 3927 gtkconv->make_sound = TRUE; |
3928 | 3928 |
3929 g_signal_connect_swapped(G_OBJECT(pane), "focus", | 3929 g_signal_connect_swapped(G_OBJECT(pane), "focus", |
3930 G_CALLBACK(gtk_widget_grab_focus), | 3930 G_CALLBACK(gtk_widget_grab_focus), |
3931 gtkconv->entry); | 3931 gtkconv->entry); |
4412 | 4412 |
4413 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf, -1, 0); | 4413 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf, -1, 0); |
4414 } | 4414 } |
4415 else { | 4415 else { |
4416 char *new_message = g_memdup(message, length); | 4416 char *new_message = g_memdup(message, length); |
4417 | 4417 |
4418 if (flags & GAIM_MESSAGE_WHISPER) { | 4418 if (flags & GAIM_MESSAGE_WHISPER) { |
4419 str = g_malloc(1024); | 4419 str = g_malloc(1024); |
4420 | 4420 |
4421 /* If we're whispering, it's not an autoresponse. */ | 4421 /* If we're whispering, it's not an autoresponse. */ |
4422 if (meify(new_message, length)) { | 4422 if (meify(new_message, length)) { |
4693 | 4693 |
4694 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | 4694 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); |
4695 | 4695 |
4696 g_free(val); | 4696 g_free(val); |
4697 } | 4697 } |
4698 | 4698 |
4699 break; | 4699 break; |
4700 } | 4700 } |
4701 } | 4701 } |
4702 | 4702 |
4703 if (!names) | 4703 if (!names) |
5169 G_CALLBACK(stop_anim), conv); | 5169 G_CALLBACK(stop_anim), conv); |
5170 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); | 5170 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); |
5171 gtk_widget_show(button); | 5171 gtk_widget_show(button); |
5172 } | 5172 } |
5173 else if (gtkconv->u.im->anim && | 5173 else if (gtkconv->u.im->anim && |
5174 !(gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim))) | 5174 !(gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim))) |
5175 { | 5175 { |
5176 button = gtk_menu_item_new_with_label(_("Enable Animation")); | 5176 button = gtk_menu_item_new_with_label(_("Enable Animation")); |
5177 g_signal_connect(G_OBJECT(button), "activate", | 5177 g_signal_connect(G_OBJECT(button), "activate", |
5178 G_CALLBACK(start_anim), conv); | 5178 G_CALLBACK(start_anim), conv); |
5179 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); | 5179 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); |
5373 | 5373 |
5374 void | 5374 void |
5375 gaim_gtkconv_update_font_colors(GaimConversation *conv) | 5375 gaim_gtkconv_update_font_colors(GaimConversation *conv) |
5376 { | 5376 { |
5377 GaimGtkConversation *gtkconv; | 5377 GaimGtkConversation *gtkconv; |
5378 | 5378 |
5379 if (!GAIM_IS_GTK_CONVERSATION(conv)) | 5379 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
5380 return; | 5380 return; |
5381 | 5381 |
5382 gtkconv = GAIM_GTK_CONVERSATION(conv); | 5382 gtkconv = GAIM_GTK_CONVERSATION(conv); |
5383 | 5383 |
5384 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), | 5384 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), |
5385 >kconv->fg_color); | 5385 >kconv->fg_color); |
5386 | 5386 |
5745 GaimConversation *conv; | 5745 GaimConversation *conv; |
5746 GaimGtkConversation *gtkconv; | 5746 GaimGtkConversation *gtkconv; |
5747 GtkSpell *spell; | 5747 GtkSpell *spell; |
5748 | 5748 |
5749 for (cl = gaim_get_conversations(); cl != NULL; cl = cl->next) { | 5749 for (cl = gaim_get_conversations(); cl != NULL; cl = cl->next) { |
5750 | 5750 |
5751 conv = (GaimConversation *)cl->data; | 5751 conv = (GaimConversation *)cl->data; |
5752 | 5752 |
5753 if (!GAIM_IS_GTK_CONVERSATION(conv)) | 5753 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
5754 continue; | 5754 continue; |
5755 | 5755 |
5877 for (bcs = g->buddy_chats; bcs != NULL; bcs = bcs->next) { | 5877 for (bcs = g->buddy_chats; bcs != NULL; bcs = bcs->next) { |
5878 conv = (GaimConversation *)bcs->data; | 5878 conv = (GaimConversation *)bcs->data; |
5879 | 5879 |
5880 if (gaim_conversation_get_type(conv) != GAIM_CONV_CHAT) | 5880 if (gaim_conversation_get_type(conv) != GAIM_CONV_CHAT) |
5881 continue; | 5881 continue; |
5882 | 5882 |
5883 if (!GAIM_IS_GTK_CONVERSATION(conv)) | 5883 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
5884 continue; | 5884 continue; |
5885 | 5885 |
5886 gtkconv = GAIM_GTK_CONVERSATION(conv); | 5886 gtkconv = GAIM_GTK_CONVERSATION(conv); |
5887 gtkwin = GAIM_GTK_WINDOW(gaim_conversation_get_window(conv)); | 5887 gtkwin = GAIM_GTK_WINDOW(gaim_conversation_get_window(conv)); |
5990 gaim_prefs_connect_callback("/gaim/gtk/conversations/spellcheck", | 5990 gaim_prefs_connect_callback("/gaim/gtk/conversations/spellcheck", |
5991 spellcheck_pref_cb, NULL); | 5991 spellcheck_pref_cb, NULL); |
5992 gaim_prefs_connect_callback("/gaim/gtk/conversations/tab_side", | 5992 gaim_prefs_connect_callback("/gaim/gtk/conversations/tab_side", |
5993 tab_side_pref_cb, NULL); | 5993 tab_side_pref_cb, NULL); |
5994 | 5994 |
5995 | 5995 |
5996 /* IM callbacks */ | 5996 /* IM callbacks */ |
5997 gaim_prefs_connect_callback("/gaim/gtk/conversations/im/button_type", | 5997 gaim_prefs_connect_callback("/gaim/gtk/conversations/im/button_type", |
5998 im_button_type_pref_cb, NULL); | 5998 im_button_type_pref_cb, NULL); |
5999 gaim_prefs_connect_callback("/gaim/gtk/conversations/im/animate_buddy_icons", | 5999 gaim_prefs_connect_callback("/gaim/gtk/conversations/im/animate_buddy_icons", |
6000 animate_buddy_icons_pref_cb, NULL); | 6000 animate_buddy_icons_pref_cb, NULL); |