Mercurial > pidgin.yaz
comparison pidgin/gtkconv.c @ 27766:056fb36a5770
propagate from branch 'im.pidgin.pidgin' (head 7a8f58fc7611c332a05ed1c1b8417be24c9cf981)
to branch 'im.pidgin.pidgin.yaz' (head 9937b0516237dfce73c86fd0407e37b0619e3037)
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Wed, 20 Feb 2008 06:56:39 +0000 |
parents | 36036b9489fe ed6de6a3604f |
children | 969a2aeae461 |
comparison
equal
deleted
inserted
replaced
22313:42724bd41274 | 27766:056fb36a5770 |
---|---|
112 | 112 |
113 #define NUM_NICK_COLORS 220 | 113 #define NUM_NICK_COLORS 220 |
114 static GdkColor *nick_colors = NULL; | 114 static GdkColor *nick_colors = NULL; |
115 static guint nbr_nick_colors; | 115 static guint nbr_nick_colors; |
116 | 116 |
117 /* yaz. If you want to use shortcut keys that may conflict with | |
118 inputmethods, change this to 1. */ | |
119 #define ENABLE_SHORTCUT 0 | |
120 | |
117 typedef struct { | 121 typedef struct { |
118 GtkWidget *window; | 122 GtkWidget *window; |
119 | 123 |
120 GtkWidget *entry; | 124 GtkWidget *entry; |
121 GtkWidget *message; | 125 GtkWidget *message; |
267 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/chat/userlist_width", allocation->width == 1 ? 0 : allocation->width); | 271 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/chat/userlist_width", allocation->width == 1 ? 0 : allocation->width); |
268 | 272 |
269 return FALSE; | 273 return FALSE; |
270 } | 274 } |
271 | 275 |
276 static gboolean | |
277 size_allocate_cb(GtkWidget *w, GtkAllocation *allocation, PidginConversation *gtkconv) | |
278 { | |
279 PurpleConversation *conv = gtkconv->active_conv; | |
280 | |
281 if (!GTK_WIDGET_VISIBLE(w)) | |
282 return FALSE; | |
283 | |
284 if (!PIDGIN_IS_PIDGIN_CONVERSATION(conv)) | |
285 return FALSE; | |
286 if (gtkconv->auto_resize) { | |
287 return FALSE; | |
288 } | |
289 | |
290 if (gdk_window_get_state(gtkconv->win->window->window) & GDK_WINDOW_STATE_MAXIMIZED) { | |
291 return FALSE; | |
292 } | |
293 | |
294 /* I find that I resize the window when it has a bunch of conversations in it, mostly so that the | |
295 * tab bar will fit, but then I don't want new windows taking up the entire screen. I check to see | |
296 * if there is only one conversation in the window. This way we'll be setting new windows to the | |
297 * size of the last resized new window. */ | |
298 /* I think that the above justification is not the majority, and that the new tab resizing should | |
299 * negate it anyway. --luke */ | |
300 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) | |
301 { | |
302 if (w == gtkconv->lower_hbox) | |
303 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/im/entry_height", allocation->height); | |
304 } | |
305 else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) | |
306 { | |
307 if (w == gtkconv->lower_hbox) | |
308 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/chat/entry_height", allocation->height); | |
309 } | |
310 return FALSE; | |
311 } | |
312 | |
272 static void | 313 static void |
273 default_formatize(PidginConversation *c) | 314 default_formatize(PidginConversation *c) |
274 { | 315 { |
275 PurpleConversation *conv = c->active_conv; | 316 PurpleConversation *conv = c->active_conv; |
276 gtk_imhtml_setup_entry(GTK_IMHTML(c->entry), conv->features); | 317 gtk_imhtml_setup_entry(GTK_IMHTML(c->entry), conv->features); |
414 | 455 |
415 first = g_list_first(gtkconv->send_history); | 456 first = g_list_first(gtkconv->send_history); |
416 g_free(first->data); | 457 g_free(first->data); |
417 first->data = g_strdup(message); | 458 first->data = g_strdup(message); |
418 gtkconv->send_history = g_list_prepend(first, NULL); | 459 gtkconv->send_history = g_list_prepend(first, NULL); |
460 } | |
461 | |
462 static void | |
463 reset_default_size(PidginConversation *gtkconv) | |
464 { | |
465 PurpleConversation *conv = gtkconv->active_conv; | |
466 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) | |
467 gtk_widget_set_size_request(gtkconv->lower_hbox, -1, | |
468 purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/chat/entry_height")); | |
469 else | |
470 gtk_widget_set_size_request(gtkconv->lower_hbox, -1, | |
471 purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/im/entry_height")); | |
419 } | 472 } |
420 | 473 |
421 static gboolean | 474 static gboolean |
422 check_for_and_do_command(PurpleConversation *conv) | 475 check_for_and_do_command(PurpleConversation *conv) |
423 { | 476 { |
532 | 585 |
533 account = purple_conversation_get_account(conv); | 586 account = purple_conversation_get_account(conv); |
534 | 587 |
535 if (check_for_and_do_command(conv)) { | 588 if (check_for_and_do_command(conv)) { |
536 if (gtkconv->entry_growing) { | 589 if (gtkconv->entry_growing) { |
590 reset_default_size(gtkconv); | |
537 gtkconv->entry_growing = FALSE; | 591 gtkconv->entry_growing = FALSE; |
538 } | 592 } |
539 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); | 593 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
540 return; | 594 return; |
541 } | 595 } |
591 g_free(clean); | 645 g_free(clean); |
592 g_free(buf); | 646 g_free(buf); |
593 | 647 |
594 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); | 648 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
595 if (gtkconv->entry_growing) { | 649 if (gtkconv->entry_growing) { |
650 reset_default_size(gtkconv); | |
596 gtkconv->entry_growing = FALSE; | 651 gtkconv->entry_growing = FALSE; |
597 } | 652 } |
598 gtkconv_set_unseen(gtkconv, PIDGIN_UNSEEN_NONE); | 653 gtkconv_set_unseen(gtkconv, PIDGIN_UNSEEN_NONE); |
599 } | 654 } |
600 | 655 |
2943 { N_("/Conversation/New Instant _Message..."), "<CTL>M", menu_new_conv_cb, | 2998 { N_("/Conversation/New Instant _Message..."), "<CTL>M", menu_new_conv_cb, |
2944 0, "<StockItem>", PIDGIN_STOCK_TOOLBAR_MESSAGE_NEW }, | 2999 0, "<StockItem>", PIDGIN_STOCK_TOOLBAR_MESSAGE_NEW }, |
2945 | 3000 |
2946 { "/Conversation/sep0", NULL, NULL, 0, "<Separator>", NULL }, | 3001 { "/Conversation/sep0", NULL, NULL, 0, "<Separator>", NULL }, |
2947 | 3002 |
3003 #if ENABLE_SHORTCUT | |
2948 { N_("/Conversation/_Find..."), NULL, menu_find_cb, 0, | 3004 { N_("/Conversation/_Find..."), NULL, menu_find_cb, 0, |
2949 "<StockItem>", GTK_STOCK_FIND }, | 3005 "<StockItem>", GTK_STOCK_FIND }, |
3006 #else | |
3007 { N_("/Conversation/_Find..."), NULL, menu_find_cb, 0, | |
3008 "<Item>", NULL }, | |
3009 #endif | |
2950 { N_("/Conversation/View _Log"), NULL, menu_view_log_cb, 0, "<Item>", NULL }, | 3010 { N_("/Conversation/View _Log"), NULL, menu_view_log_cb, 0, "<Item>", NULL }, |
2951 { N_("/Conversation/_Save As..."), NULL, menu_save_as_cb, 0, | 3011 { N_("/Conversation/_Save As..."), NULL, menu_save_as_cb, 0, |
2952 "<StockItem>", GTK_STOCK_SAVE_AS }, | 3012 "<StockItem>", GTK_STOCK_SAVE_AS }, |
3013 #if ENABLE_SHORTCUT | |
2953 { N_("/Conversation/Clea_r Scrollback"), "<CTL>L", menu_clear_cb, 0, "<StockItem>", GTK_STOCK_CLEAR }, | 3014 { N_("/Conversation/Clea_r Scrollback"), "<CTL>L", menu_clear_cb, 0, "<StockItem>", GTK_STOCK_CLEAR }, |
2954 | 3015 #else |
3016 { N_("/Conversation/Clea_r Scrollback"), NULL, menu_clear_cb, 0, "<Item>", NULL }, | |
3017 #endif | |
2955 { "/Conversation/sep1", NULL, NULL, 0, "<Separator>", NULL }, | 3018 { "/Conversation/sep1", NULL, NULL, 0, "<Separator>", NULL }, |
2956 | 3019 |
2957 { N_("/Conversation/Se_nd File..."), NULL, menu_send_file_cb, 0, "<StockItem>", PIDGIN_STOCK_TOOLBAR_SEND_FILE }, | 3020 { N_("/Conversation/Se_nd File..."), NULL, menu_send_file_cb, 0, "<StockItem>", PIDGIN_STOCK_TOOLBAR_SEND_FILE }, |
2958 { N_("/Conversation/Add Buddy _Pounce..."), NULL, menu_add_pounce_cb, | 3021 { N_("/Conversation/Add Buddy _Pounce..."), NULL, menu_add_pounce_cb, |
2959 0, "<Item>", NULL }, | 3022 0, "<Item>", NULL }, |
3023 #if ENABLE_SHORTCUT | |
2960 { N_("/Conversation/_Get Info"), "<CTL>O", menu_get_info_cb, 0, | 3024 { N_("/Conversation/_Get Info"), "<CTL>O", menu_get_info_cb, 0, |
2961 "<StockItem>", PIDGIN_STOCK_TOOLBAR_USER_INFO }, | 3025 "<StockItem>", PIDGIN_STOCK_TOOLBAR_USER_INFO }, |
3026 #else | |
3027 { N_("/Conversation/_Get Info"), NULL, menu_get_info_cb, 0, | |
3028 "<StockItem>", PIDGIN_STOCK_TOOLBAR_USER_INFO }, | |
3029 #endif | |
2962 { N_("/Conversation/In_vite..."), NULL, menu_invite_cb, 0, | 3030 { N_("/Conversation/In_vite..."), NULL, menu_invite_cb, 0, |
2963 "<Item>", NULL }, | 3031 "<Item>", NULL }, |
2964 { N_("/Conversation/M_ore"), NULL, NULL, 0, "<Branch>", NULL }, | 3032 { N_("/Conversation/M_ore"), NULL, NULL, 0, "<Branch>", NULL }, |
2965 | 3033 |
2966 { "/Conversation/sep2", NULL, NULL, 0, "<Separator>", NULL }, | 3034 { "/Conversation/sep2", NULL, NULL, 0, "<Separator>", NULL }, |
3642 | 3710 |
3643 if (win->menu.send_to != NULL) | 3711 if (win->menu.send_to != NULL) |
3644 gtk_widget_destroy(win->menu.send_to); | 3712 gtk_widget_destroy(win->menu.send_to); |
3645 | 3713 |
3646 /* Build the Send To menu */ | 3714 /* Build the Send To menu */ |
3715 #if ENABLE_SHORTCUT | |
3647 win->menu.send_to = gtk_menu_item_new_with_mnemonic(_("S_end To")); | 3716 win->menu.send_to = gtk_menu_item_new_with_mnemonic(_("S_end To")); |
3717 #else | |
3718 win->menu.send_to = gtk_menu_item_new_with_mnemonic(_("Send To")); //to free Alt-s. intentional. --yaz | |
3719 #endif | |
3648 gtk_widget_show(win->menu.send_to); | 3720 gtk_widget_show(win->menu.send_to); |
3649 | 3721 |
3650 menu = gtk_menu_new(); | 3722 menu = gtk_menu_new(); |
3651 gtk_menu_shell_insert(GTK_MENU_SHELL(win->menu.menubar), | 3723 gtk_menu_shell_insert(GTK_MENU_SHELL(win->menu.menubar), |
3652 win->menu.send_to, 2); | 3724 win->menu.send_to, 2); |
4116 PurpleConnection *gc; | 4188 PurpleConnection *gc; |
4117 PurpleConversation *conv = gtkconv->active_conv; | 4189 PurpleConversation *conv = gtkconv->active_conv; |
4118 PidginChatPane *gtkchat; | 4190 PidginChatPane *gtkchat; |
4119 char *new_topic; | 4191 char *new_topic; |
4120 const char *current_topic; | 4192 const char *current_topic; |
4193 char dummy[] = "No Topic"; | |
4121 | 4194 |
4122 gc = purple_conversation_get_gc(conv); | 4195 gc = purple_conversation_get_gc(conv); |
4123 | 4196 |
4124 if(!gc || !(prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl))) | 4197 if(!gc || !(prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl))) |
4125 return; | 4198 return; |
4135 if(current_topic && !g_utf8_collate(new_topic, current_topic)){ | 4208 if(current_topic && !g_utf8_collate(new_topic, current_topic)){ |
4136 g_free(new_topic); | 4209 g_free(new_topic); |
4137 return; | 4210 return; |
4138 } | 4211 } |
4139 | 4212 |
4140 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), current_topic); | 4213 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), current_topic ? current_topic : dummy); |
4141 prpl_info->set_chat_topic(gc, purple_conv_chat_get_id(PURPLE_CONV_CHAT(conv)), | 4214 prpl_info->set_chat_topic(gc, purple_conv_chat_get_id(PURPLE_CONV_CHAT(conv)), |
4142 new_topic); | 4215 new_topic); |
4143 | 4216 |
4144 g_free(new_topic); | 4217 g_free(new_topic); |
4145 } | 4218 } |
4366 menuitem = gtk_separator_menu_item_new(); | 4439 menuitem = gtk_separator_menu_item_new(); |
4367 gtk_widget_show(menuitem); | 4440 gtk_widget_show(menuitem); |
4368 gtk_menu_shell_insert(GTK_MENU_SHELL(menu), menuitem, 1); | 4441 gtk_menu_shell_insert(GTK_MENU_SHELL(menu), menuitem, 1); |
4369 } | 4442 } |
4370 | 4443 |
4371 static gboolean resize_imhtml_cb(PidginConversation *gtkconv) | 4444 static void resize_imhtml_cb(PidginConversation *gtkconv) |
4372 { | 4445 { |
4373 GtkTextBuffer *buffer; | 4446 GtkTextBuffer *buffer; |
4374 GtkTextIter iter; | 4447 GtkTextIter iter; |
4375 int wrapped_lines; | 4448 int wrapped_lines; |
4376 int lines; | 4449 int lines; |
4404 gtkconv->auto_resize = TRUE; | 4477 gtkconv->auto_resize = TRUE; |
4405 g_idle_add(reset_auto_resize_cb, gtkconv); | 4478 g_idle_add(reset_auto_resize_cb, gtkconv); |
4406 | 4479 |
4407 diff = height - gtkconv->entry->allocation.height; | 4480 diff = height - gtkconv->entry->allocation.height; |
4408 | 4481 |
4409 gtk_widget_size_request(gtkconv->lower_hbox, &sr); | 4482 if (diff > 0) { |
4410 gtkconv->entry_growing = TRUE; | 4483 gtk_widget_size_request(gtkconv->lower_hbox, &sr); |
4411 | 4484 gtkconv->entry_growing = TRUE; |
4412 gtk_widget_set_size_request(gtkconv->lower_hbox, -1, | 4485 |
4413 diff + gtkconv->lower_hbox->allocation.height); | 4486 /* uncomment this to auto resize even after the user manually |
4414 return FALSE; | 4487 resizes |
4488 gtk_paned_set_position(GTK_PANED(gtkconv->lower_hbox->parent->parent), | |
4489 -1); | |
4490 */ | |
4491 gtk_widget_set_size_request(gtkconv->lower_hbox, -1, | |
4492 diff + gtkconv->lower_hbox->allocation.height); | |
4493 } | |
4415 } | 4494 } |
4416 | 4495 |
4417 static void | 4496 static void |
4418 setup_chat_topic(PidginConversation *gtkconv, GtkWidget *vbox) | 4497 setup_chat_topic(PidginConversation *gtkconv, GtkWidget *vbox) |
4419 { | 4498 { |
4601 } | 4680 } |
4602 | 4681 |
4603 static GtkWidget * | 4682 static GtkWidget * |
4604 setup_common_pane(PidginConversation *gtkconv) | 4683 setup_common_pane(PidginConversation *gtkconv) |
4605 { | 4684 { |
4606 GtkWidget *vbox, *frame, *imhtml_sw, *event_box; | 4685 GtkWidget *paned, *vbox, *frame, *imhtml_sw, *event_box; |
4607 GtkCellRenderer *rend; | 4686 GtkCellRenderer *rend; |
4608 GtkTreePath *path; | 4687 GtkTreePath *path; |
4609 PurpleConversation *conv = gtkconv->active_conv; | 4688 PurpleConversation *conv = gtkconv->active_conv; |
4610 gboolean chat = (conv->type == PURPLE_CONV_TYPE_CHAT); | 4689 gboolean chat = (conv->type == PURPLE_CONV_TYPE_CHAT); |
4611 GtkPolicyType imhtml_sw_hscroll; | 4690 GtkPolicyType imhtml_sw_hscroll; |
4612 | 4691 |
4692 paned = gtk_vpaned_new(); | |
4693 gtk_widget_show(paned); | |
4694 | |
4613 /* Setup the top part of the pane */ | 4695 /* Setup the top part of the pane */ |
4614 vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); | 4696 vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); |
4697 gtk_paned_pack1(GTK_PANED(paned), vbox, TRUE, TRUE); | |
4615 gtk_widget_show(vbox); | 4698 gtk_widget_show(vbox); |
4616 | 4699 |
4617 /* Setup the info pane */ | 4700 /* Setup the info pane */ |
4618 event_box = gtk_event_box_new(); | 4701 event_box = gtk_event_box_new(); |
4619 #if GTK_CHECK_VERSION(2,4,0) | 4702 #if GTK_CHECK_VERSION(2,4,0) |
4702 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_press_event", | 4785 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_press_event", |
4703 G_CALLBACK(refocus_entry_cb), gtkconv); | 4786 G_CALLBACK(refocus_entry_cb), gtkconv); |
4704 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_release_event", | 4787 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_release_event", |
4705 G_CALLBACK(refocus_entry_cb), gtkconv); | 4788 G_CALLBACK(refocus_entry_cb), gtkconv); |
4706 | 4789 |
4790 /* Setup the bottom half of the conversation window */ | |
4791 vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); | |
4792 gtk_paned_pack2(GTK_PANED(paned), vbox, FALSE, TRUE); | |
4793 gtk_widget_show(vbox); | |
4794 | |
4707 gtkconv->lower_hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); | 4795 gtkconv->lower_hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); |
4708 gtk_box_pack_start(GTK_BOX(vbox), gtkconv->lower_hbox, FALSE, FALSE, 0); | 4796 gtk_box_pack_start(GTK_BOX(vbox), gtkconv->lower_hbox, TRUE, TRUE, 0); |
4709 gtk_widget_show(gtkconv->lower_hbox); | 4797 gtk_widget_show(gtkconv->lower_hbox); |
4798 | |
4799 vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); | |
4800 gtk_box_pack_end(GTK_BOX(gtkconv->lower_hbox), vbox, TRUE, TRUE, 0); | |
4801 gtk_widget_show(vbox); | |
4710 | 4802 |
4711 /* Setup the toolbar, entry widget and all signals */ | 4803 /* Setup the toolbar, entry widget and all signals */ |
4712 frame = pidgin_create_imhtml(TRUE, >kconv->entry, >kconv->toolbar, NULL); | 4804 frame = pidgin_create_imhtml(TRUE, >kconv->entry, >kconv->toolbar, NULL); |
4713 gtk_box_pack_start(GTK_BOX(gtkconv->lower_hbox), frame, TRUE, TRUE, 0); | 4805 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
4714 gtk_widget_show(frame); | 4806 gtk_widget_show(frame); |
4715 | 4807 |
4716 gtk_widget_set_name(gtkconv->entry, "pidgin_conv_entry"); | 4808 gtk_widget_set_name(gtkconv->entry, "pidgin_conv_entry"); |
4717 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), | 4809 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
4718 purple_account_get_protocol_name(conv->account)); | 4810 purple_account_get_protocol_name(conv->account)); |
4811 gtk_widget_set_size_request(gtkconv->lower_hbox, -1, | |
4812 chat ? purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/chat/entry_height") : | |
4813 purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/im/entry_height")); | |
4719 | 4814 |
4720 g_signal_connect(G_OBJECT(gtkconv->entry), "populate-popup", | 4815 g_signal_connect(G_OBJECT(gtkconv->entry), "populate-popup", |
4721 G_CALLBACK(entry_popup_menu_cb), gtkconv); | 4816 G_CALLBACK(entry_popup_menu_cb), gtkconv); |
4722 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", | 4817 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", |
4723 G_CALLBACK(entry_key_press_cb), gtkconv); | 4818 G_CALLBACK(entry_key_press_cb), gtkconv); |
4724 g_signal_connect_after(G_OBJECT(gtkconv->entry), "message_send", | 4819 g_signal_connect_after(G_OBJECT(gtkconv->entry), "message_send", |
4725 G_CALLBACK(send_cb), gtkconv); | 4820 G_CALLBACK(send_cb), gtkconv); |
4726 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", | 4821 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", |
4727 G_CALLBACK(entry_stop_rclick_cb), NULL); | 4822 G_CALLBACK(entry_stop_rclick_cb), NULL); |
4823 g_signal_connect(G_OBJECT(gtkconv->lower_hbox), "size-allocate", | |
4824 G_CALLBACK(size_allocate_cb), gtkconv); | |
4728 | 4825 |
4729 gtkconv->entry_buffer = | 4826 gtkconv->entry_buffer = |
4730 gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); | 4827 gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); |
4731 g_object_set_data(G_OBJECT(gtkconv->entry_buffer), "user_data", gtkconv); | 4828 g_object_set_data(G_OBJECT(gtkconv->entry_buffer), "user_data", gtkconv); |
4732 | 4829 |
4745 G_CALLBACK(resize_imhtml_cb), gtkconv); | 4842 G_CALLBACK(resize_imhtml_cb), gtkconv); |
4746 | 4843 |
4747 default_formatize(gtkconv); | 4844 default_formatize(gtkconv); |
4748 g_signal_connect_after(G_OBJECT(gtkconv->entry), "format_function_clear", | 4845 g_signal_connect_after(G_OBJECT(gtkconv->entry), "format_function_clear", |
4749 G_CALLBACK(clear_formatting_cb), gtkconv); | 4846 G_CALLBACK(clear_formatting_cb), gtkconv); |
4750 return vbox; | 4847 return paned; |
4751 } | 4848 } |
4752 | 4849 |
4753 static void | 4850 static void |
4754 conv_dnd_recv(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, | 4851 conv_dnd_recv(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, |
4755 GtkSelectionData *sd, guint info, guint t, | 4852 GtkSelectionData *sd, guint info, guint t, |
5017 | 5114 |
5018 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/show_formatting_toolbar")) | 5115 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/show_formatting_toolbar")) |
5019 gtk_widget_show(gtkconv->toolbar); | 5116 gtk_widget_show(gtkconv->toolbar); |
5020 else | 5117 else |
5021 gtk_widget_hide(gtkconv->toolbar); | 5118 gtk_widget_hide(gtkconv->toolbar); |
5022 g_idle_add((GSourceFunc)resize_imhtml_cb, gtkconv); | 5119 |
5120 // g_idle_add((GSourceFunc)resize_imhtml_cb, gtkconv); | |
5023 | 5121 |
5024 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/im/show_buddy_icons")) | 5122 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/im/show_buddy_icons")) |
5025 gtk_widget_show(gtkconv->infopane_hbox); | 5123 gtk_widget_show(gtkconv->infopane_hbox); |
5026 else | 5124 else |
5027 gtk_widget_hide(gtkconv->infopane_hbox); | 5125 gtk_widget_hide(gtkconv->infopane_hbox); |
6474 PurplePresence *p = NULL; | 6572 PurplePresence *p = NULL; |
6475 char *markup = NULL; | 6573 char *markup = NULL; |
6476 AtkObject *accessibility_obj; | 6574 AtkObject *accessibility_obj; |
6477 /* I think this is a little longer than it needs to be but I'm lazy. */ | 6575 /* I think this is a little longer than it needs to be but I'm lazy. */ |
6478 char *style; | 6576 char *style; |
6577 gboolean ellipsis; | |
6578 int side; | |
6579 char *tab_title = NULL; | |
6479 | 6580 |
6480 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) | 6581 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) |
6481 im = PURPLE_CONV_IM(conv); | 6582 im = PURPLE_CONV_IM(conv); |
6482 | 6583 |
6483 if ((account == NULL) || | 6584 if ((account == NULL) || |
6561 style = "tab-label-event"; | 6662 style = "tab-label-event"; |
6562 } else { | 6663 } else { |
6563 style = NULL; | 6664 style = NULL; |
6564 } | 6665 } |
6565 | 6666 |
6667 // nosuke's tab width patch | |
6668 side = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/tab_side"); | |
6669 side &= ~8; | |
6670 if ( (side == GTK_POS_LEFT || side == GTK_POS_RIGHT) && | |
6671 purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/trim_vertical_tabs") ) | |
6672 ellipsis = TRUE; | |
6673 else | |
6674 ellipsis = FALSE; | |
6675 | |
6676 if (ellipsis) { | |
6677 tab_title = pidgin_gtk_ellipsis_text(gtkconv->tab_label, title, 60, "..."); | |
6678 } | |
6679 else { | |
6680 tab_title = g_strdup(title); | |
6681 } | |
6682 | |
6566 gtk_widget_set_name(gtkconv->tab_label, style); | 6683 gtk_widget_set_name(gtkconv->tab_label, style); |
6567 gtk_label_set_text(GTK_LABEL(gtkconv->tab_label), title); | 6684 gtk_label_set_text(GTK_LABEL(gtkconv->tab_label), tab_title); |
6685 g_free(tab_title); tab_title = NULL; | |
6686 | |
6568 gtk_widget_set_state(gtkconv->tab_label, GTK_STATE_ACTIVE); | 6687 gtk_widget_set_state(gtkconv->tab_label, GTK_STATE_ACTIVE); |
6569 | 6688 |
6570 if (gtkconv->unseen_state == PIDGIN_UNSEEN_TEXT || | 6689 if (gtkconv->unseen_state == PIDGIN_UNSEEN_TEXT || |
6571 gtkconv->unseen_state == PIDGIN_UNSEEN_NICK || | 6690 gtkconv->unseen_state == PIDGIN_UNSEEN_NICK || |
6572 gtkconv->unseen_state == PIDGIN_UNSEEN_EVENT) { | 6691 gtkconv->unseen_state == PIDGIN_UNSEEN_EVENT) { |
6968 } | 7087 } |
6969 | 7088 |
6970 return page_num; | 7089 return page_num; |
6971 } | 7090 } |
6972 | 7091 |
7092 //nosuke | |
7093 static void | |
7094 trim_vertical_tabs_pref_cb(const char *name, PurplePrefType type, | |
7095 gconstpointer value, gpointer data) | |
7096 { | |
7097 GList *l; | |
7098 PurpleConversation *conv; | |
7099 | |
7100 for (l = purple_get_conversations(); l != NULL; l = l->next) { | |
7101 conv = (PurpleConversation *)l->data; | |
7102 | |
7103 if (!PIDGIN_IS_PIDGIN_CONVERSATION(conv)) | |
7104 continue; | |
7105 | |
7106 pidgin_conv_update_fields(conv, PIDGIN_CONV_SET_TITLE); | |
7107 } | |
7108 } | |
7109 | |
6973 static void | 7110 static void |
6974 close_on_tabs_pref_cb(const char *name, PurplePrefType type, | 7111 close_on_tabs_pref_cb(const char *name, PurplePrefType type, |
6975 gconstpointer value, gpointer data) | 7112 gconstpointer value, gpointer data) |
6976 { | 7113 { |
6977 GList *l; | 7114 GList *l; |
7037 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(gtkwin->notebook), pos&~8); | 7174 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(gtkwin->notebook), pos&~8); |
7038 for (gtkconvs = gtkwin->gtkconvs; gtkconvs != NULL; gtkconvs = gtkconvs->next) { | 7175 for (gtkconvs = gtkwin->gtkconvs; gtkconvs != NULL; gtkconvs = gtkconvs->next) { |
7039 pidgin_conv_tab_pack(gtkwin, gtkconvs->data); | 7176 pidgin_conv_tab_pack(gtkwin, gtkconvs->data); |
7040 } | 7177 } |
7041 } | 7178 } |
7179 trim_vertical_tabs_pref_cb(name, type, value, data); | |
7042 } | 7180 } |
7043 | 7181 |
7044 static void | 7182 static void |
7045 show_timestamps_pref_cb(const char *name, PurplePrefType type, | 7183 show_timestamps_pref_cb(const char *name, PurplePrefType type, |
7046 gconstpointer value, gpointer data) | 7184 gconstpointer value, gpointer data) |
7095 if ((gboolean)GPOINTER_TO_INT(value)) | 7233 if ((gboolean)GPOINTER_TO_INT(value)) |
7096 gtk_widget_show(gtkconv->toolbar); | 7234 gtk_widget_show(gtkconv->toolbar); |
7097 else | 7235 else |
7098 gtk_widget_hide(gtkconv->toolbar); | 7236 gtk_widget_hide(gtkconv->toolbar); |
7099 | 7237 |
7100 g_idle_add((GSourceFunc)resize_imhtml_cb,gtkconv); | 7238 // g_idle_add((GSourceFunc)resize_imhtml_cb,gtkconv); |
7101 } | 7239 } |
7102 } | 7240 } |
7103 | 7241 |
7104 static void | 7242 static void |
7105 animate_buddy_icons_pref_cb(const char *name, PurplePrefType type, | 7243 animate_buddy_icons_pref_cb(const char *name, PurplePrefType type, |
7598 | 7736 |
7599 /* Conversations */ | 7737 /* Conversations */ |
7600 purple_prefs_add_none(PIDGIN_PREFS_ROOT "/conversations"); | 7738 purple_prefs_add_none(PIDGIN_PREFS_ROOT "/conversations"); |
7601 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/use_smooth_scrolling", TRUE); | 7739 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/use_smooth_scrolling", TRUE); |
7602 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/close_on_tabs", TRUE); | 7740 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/close_on_tabs", TRUE); |
7741 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/trim_vertical_tabs", FALSE); | |
7603 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/send_bold", FALSE); | 7742 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/send_bold", FALSE); |
7604 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/send_italic", FALSE); | 7743 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/send_italic", FALSE); |
7605 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/send_underline", FALSE); | 7744 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/send_underline", FALSE); |
7606 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/spellcheck", TRUE); | 7745 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/spellcheck", TRUE); |
7607 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/show_incoming_formatting", TRUE); | 7746 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/show_incoming_formatting", TRUE); |
7651 #endif | 7790 #endif |
7652 | 7791 |
7653 /* Connect callbacks. */ | 7792 /* Connect callbacks. */ |
7654 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/conversations/close_on_tabs", | 7793 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/conversations/close_on_tabs", |
7655 close_on_tabs_pref_cb, NULL); | 7794 close_on_tabs_pref_cb, NULL); |
7795 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/conversations/trim_vertical_tabs", | |
7796 trim_vertical_tabs_pref_cb, NULL); | |
7656 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/conversations/show_timestamps", | 7797 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/conversations/show_timestamps", |
7657 show_timestamps_pref_cb, NULL); | 7798 show_timestamps_pref_cb, NULL); |
7658 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/conversations/show_formatting_toolbar", | 7799 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/conversations/show_formatting_toolbar", |
7659 show_formatting_toolbar_pref_cb, NULL); | 7800 show_formatting_toolbar_pref_cb, NULL); |
7660 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/conversations/spellcheck", | 7801 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/conversations/spellcheck", |
9139 static GdkCursor *ptr = NULL; | 9280 static GdkCursor *ptr = NULL; |
9140 if (ptr == NULL) { | 9281 if (ptr == NULL) { |
9141 ptr = gdk_cursor_new(GDK_LEFT_PTR); | 9282 ptr = gdk_cursor_new(GDK_LEFT_PTR); |
9142 } | 9283 } |
9143 | 9284 |
9144 gtk_label_set_markup(label, "×"); | 9285 gtk_label_set_markup(label, "×"); |
9145 gdk_window_set_cursor(event->window, ptr); | 9286 gdk_window_set_cursor(event->window, ptr); |
9146 return FALSE; | 9287 return FALSE; |
9147 } | 9288 } |
9148 | 9289 |
9149 static gboolean | 9290 static gboolean |
9152 static GdkCursor *hand = NULL; | 9293 static GdkCursor *hand = NULL; |
9153 if (hand == NULL) { | 9294 if (hand == NULL) { |
9154 hand = gdk_cursor_new(GDK_HAND2); | 9295 hand = gdk_cursor_new(GDK_HAND2); |
9155 } | 9296 } |
9156 | 9297 |
9157 gtk_label_set_markup(label, "<u>×</u>"); | 9298 gtk_label_set_markup(label, "<u>×</u>"); |
9158 gdk_window_set_cursor(event->window, hand); | 9299 gdk_window_set_cursor(event->window, hand); |
9159 return FALSE; | 9300 return FALSE; |
9160 } | 9301 } |
9161 | 9302 |
9162 void | 9303 void |
9182 gtkconv->close = gtk_event_box_new(); | 9323 gtkconv->close = gtk_event_box_new(); |
9183 #if GTK_CHECK_VERSION(2,4,0) | 9324 #if GTK_CHECK_VERSION(2,4,0) |
9184 gtk_event_box_set_visible_window(GTK_EVENT_BOX(gtkconv->close), FALSE); | 9325 gtk_event_box_set_visible_window(GTK_EVENT_BOX(gtkconv->close), FALSE); |
9185 #endif | 9326 #endif |
9186 gtk_widget_set_events(gtkconv->close, GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); | 9327 gtk_widget_set_events(gtkconv->close, GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); |
9187 close_image = gtk_label_new("×"); | 9328 close_image = gtk_label_new("×"); |
9188 g_signal_connect(G_OBJECT(gtkconv->close), "enter-notify-event", G_CALLBACK(close_button_entered_cb), close_image); | 9329 g_signal_connect(G_OBJECT(gtkconv->close), "enter-notify-event", G_CALLBACK(close_button_entered_cb), close_image); |
9189 g_signal_connect(G_OBJECT(gtkconv->close), "leave-notify-event", G_CALLBACK(close_button_left_cb), close_image); | 9330 g_signal_connect(G_OBJECT(gtkconv->close), "leave-notify-event", G_CALLBACK(close_button_left_cb), close_image); |
9190 gtk_widget_show(close_image); | 9331 gtk_widget_show(close_image); |
9191 gtk_container_add(GTK_CONTAINER(gtkconv->close), close_image); | 9332 gtk_container_add(GTK_CONTAINER(gtkconv->close), close_image); |
9192 gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->close, | 9333 gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->close, |