pidgin/gtkconv.c

changeset 21774
24a248e00ba5
parent 21656
acb7fa0ac03d
child 21777
0662651f6902
equal deleted inserted replaced
21773:b4650781e8bb 21774:24a248e00ba5
264 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/chat/userlist_width", allocation->width == 1 ? 0 : allocation->width); 264 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/chat/userlist_width", allocation->width == 1 ? 0 : allocation->width);
265 265
266 return FALSE; 266 return FALSE;
267 } 267 }
268 268
269 static gboolean
270 size_allocate_cb(GtkWidget *w, GtkAllocation *allocation, PidginConversation *gtkconv)
271 {
272 PurpleConversation *conv = gtkconv->active_conv;
273
274 if (!GTK_WIDGET_VISIBLE(w))
275 return FALSE;
276
277 if (!PIDGIN_IS_PIDGIN_CONVERSATION(conv))
278 return FALSE;
279 if (gtkconv->auto_resize) {
280 return FALSE;
281 }
282
283 if (gdk_window_get_state(gtkconv->win->window->window) & GDK_WINDOW_STATE_MAXIMIZED) {
284 return FALSE;
285 }
286
287 /* I find that I resize the window when it has a bunch of conversations in it, mostly so that the
288 * tab bar will fit, but then I don't want new windows taking up the entire screen. I check to see
289 * if there is only one conversation in the window. This way we'll be setting new windows to the
290 * size of the last resized new window. */
291 /* I think that the above justification is not the majority, and that the new tab resizing should
292 * negate it anyway. --luke */
293 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM)
294 {
295 if (w == gtkconv->lower_hbox)
296 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/im/entry_height", allocation->height);
297 }
298 else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT)
299 {
300 if (w == gtkconv->lower_hbox)
301 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/chat/entry_height", allocation->height);
302 }
303 return FALSE;
304 }
305
306 static void 269 static void
307 default_formatize(PidginConversation *c) 270 default_formatize(PidginConversation *c)
308 { 271 {
309 PurpleConversation *conv = c->active_conv; 272 PurpleConversation *conv = c->active_conv;
310 gtk_imhtml_setup_entry(GTK_IMHTML(c->entry), conv->features); 273 gtk_imhtml_setup_entry(GTK_IMHTML(c->entry), conv->features);
448 411
449 first = g_list_first(gtkconv->send_history); 412 first = g_list_first(gtkconv->send_history);
450 g_free(first->data); 413 g_free(first->data);
451 first->data = g_strdup(message); 414 first->data = g_strdup(message);
452 gtkconv->send_history = g_list_prepend(first, NULL); 415 gtkconv->send_history = g_list_prepend(first, NULL);
453 }
454
455 static void
456 reset_default_size(PidginConversation *gtkconv)
457 {
458 PurpleConversation *conv = gtkconv->active_conv;
459 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT)
460 gtk_widget_set_size_request(gtkconv->lower_hbox, -1,
461 purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/chat/entry_height"));
462 else
463 gtk_widget_set_size_request(gtkconv->lower_hbox, -1,
464 purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/im/entry_height"));
465 } 416 }
466 417
467 static gboolean 418 static gboolean
468 check_for_and_do_command(PurpleConversation *conv) 419 check_for_and_do_command(PurpleConversation *conv)
469 { 420 {
571 522
572 account = purple_conversation_get_account(conv); 523 account = purple_conversation_get_account(conv);
573 524
574 if (check_for_and_do_command(conv)) { 525 if (check_for_and_do_command(conv)) {
575 if (gtkconv->entry_growing) { 526 if (gtkconv->entry_growing) {
576 reset_default_size(gtkconv);
577 gtkconv->entry_growing = FALSE; 527 gtkconv->entry_growing = FALSE;
578 } 528 }
579 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); 529 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry));
580 return; 530 return;
581 } 531 }
631 g_free(clean); 581 g_free(clean);
632 g_free(buf); 582 g_free(buf);
633 583
634 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); 584 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry));
635 if (gtkconv->entry_growing) { 585 if (gtkconv->entry_growing) {
636 reset_default_size(gtkconv);
637 gtkconv->entry_growing = FALSE; 586 gtkconv->entry_growing = FALSE;
638 } 587 }
639 gtkconv_set_unseen(gtkconv, PIDGIN_UNSEEN_NONE); 588 gtkconv_set_unseen(gtkconv, PIDGIN_UNSEEN_NONE);
640 } 589 }
641 590
4367 menuitem = gtk_separator_menu_item_new(); 4316 menuitem = gtk_separator_menu_item_new();
4368 gtk_widget_show(menuitem); 4317 gtk_widget_show(menuitem);
4369 gtk_menu_shell_insert(GTK_MENU_SHELL(menu), menuitem, 1); 4318 gtk_menu_shell_insert(GTK_MENU_SHELL(menu), menuitem, 1);
4370 } 4319 }
4371 4320
4372 static void resize_imhtml_cb(PidginConversation *gtkconv) 4321 static gboolean resize_imhtml_cb(PidginConversation *gtkconv)
4373 { 4322 {
4374 GtkTextBuffer *buffer; 4323 GtkTextBuffer *buffer;
4375 GtkTextIter iter; 4324 GtkTextIter iter;
4376 int wrapped_lines; 4325 int wrapped_lines;
4377 int lines; 4326 int lines;
4404 gtkconv->auto_resize = TRUE; 4353 gtkconv->auto_resize = TRUE;
4405 g_idle_add(reset_auto_resize_cb, gtkconv); 4354 g_idle_add(reset_auto_resize_cb, gtkconv);
4406 4355
4407 diff = height - gtkconv->entry->allocation.height; 4356 diff = height - gtkconv->entry->allocation.height;
4408 4357
4409 if (diff > 0) { 4358 gtk_widget_size_request(gtkconv->lower_hbox, &sr);
4410 gtk_widget_size_request(gtkconv->lower_hbox, &sr); 4359 gtkconv->entry_growing = TRUE;
4411 gtkconv->entry_growing = TRUE; 4360
4412 4361 gtk_widget_set_size_request(gtkconv->lower_hbox, -1,
4413 /* uncomment this to auto resize even after the user manually 4362 diff + gtkconv->lower_hbox->allocation.height);
4414 resizes 4363 return FALSE;
4415 gtk_paned_set_position(GTK_PANED(gtkconv->lower_hbox->parent->parent),
4416 -1);
4417 */
4418 gtk_widget_set_size_request(gtkconv->lower_hbox, -1,
4419 diff + gtkconv->lower_hbox->allocation.height);
4420 }
4421 } 4364 }
4422 4365
4423 static void 4366 static void
4424 setup_chat_topic(PidginConversation *gtkconv, GtkWidget *vbox) 4367 setup_chat_topic(PidginConversation *gtkconv, GtkWidget *vbox)
4425 { 4368 {
4685 } 4628 }
4686 4629
4687 static GtkWidget * 4630 static GtkWidget *
4688 setup_common_pane(PidginConversation *gtkconv) 4631 setup_common_pane(PidginConversation *gtkconv)
4689 { 4632 {
4690 GtkWidget *paned, *vbox, *frame, *imhtml_sw, *event_box; 4633 GtkWidget *vbox, *frame, *imhtml_sw, *event_box;
4691 GtkCellRenderer *rend; 4634 GtkCellRenderer *rend;
4692 GtkTreePath *path; 4635 GtkTreePath *path;
4693 PurpleConversation *conv = gtkconv->active_conv; 4636 PurpleConversation *conv = gtkconv->active_conv;
4694 gboolean chat = (conv->type == PURPLE_CONV_TYPE_CHAT); 4637 gboolean chat = (conv->type == PURPLE_CONV_TYPE_CHAT);
4695 GtkPolicyType imhtml_sw_hscroll; 4638 GtkPolicyType imhtml_sw_hscroll;
4696 4639
4697 paned = gtk_vpaned_new();
4698 gtk_widget_show(paned);
4699
4700 /* Setup the top part of the pane */ 4640 /* Setup the top part of the pane */
4701 vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); 4641 vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
4702 gtk_paned_pack1(GTK_PANED(paned), vbox, TRUE, TRUE);
4703 gtk_widget_show(vbox); 4642 gtk_widget_show(vbox);
4704 4643
4705 /* Setup the info pane */ 4644 /* Setup the info pane */
4706 event_box = gtk_event_box_new(); 4645 event_box = gtk_event_box_new();
4707 #if GTK_CHECK_VERSION(2,4,0) 4646 #if GTK_CHECK_VERSION(2,4,0)
4792 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_press_event", 4731 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_press_event",
4793 G_CALLBACK(refocus_entry_cb), gtkconv); 4732 G_CALLBACK(refocus_entry_cb), gtkconv);
4794 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_release_event", 4733 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_release_event",
4795 G_CALLBACK(refocus_entry_cb), gtkconv); 4734 G_CALLBACK(refocus_entry_cb), gtkconv);
4796 4735
4797 /* Setup the bottom half of the conversation window */
4798 vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
4799 gtk_paned_pack2(GTK_PANED(paned), vbox, FALSE, TRUE);
4800 gtk_widget_show(vbox);
4801
4802 gtkconv->lower_hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); 4736 gtkconv->lower_hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
4803 gtk_box_pack_start(GTK_BOX(vbox), gtkconv->lower_hbox, TRUE, TRUE, 0); 4737 gtk_box_pack_start(GTK_BOX(vbox), gtkconv->lower_hbox, FALSE, FALSE, 0);
4804 gtk_widget_show(gtkconv->lower_hbox); 4738 gtk_widget_show(gtkconv->lower_hbox);
4805
4806 vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
4807 gtk_box_pack_end(GTK_BOX(gtkconv->lower_hbox), vbox, TRUE, TRUE, 0);
4808 gtk_widget_show(vbox);
4809 4739
4810 /* Setup the toolbar, entry widget and all signals */ 4740 /* Setup the toolbar, entry widget and all signals */
4811 frame = pidgin_create_imhtml(TRUE, &gtkconv->entry, &gtkconv->toolbar, NULL); 4741 frame = pidgin_create_imhtml(TRUE, &gtkconv->entry, &gtkconv->toolbar, NULL);
4812 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); 4742 gtk_box_pack_start(GTK_BOX(gtkconv->lower_hbox), frame, TRUE, TRUE, 0);
4813 gtk_widget_show(frame); 4743 gtk_widget_show(frame);
4814 4744
4815 gtk_widget_set_name(gtkconv->entry, "pidgin_conv_entry"); 4745 gtk_widget_set_name(gtkconv->entry, "pidgin_conv_entry");
4816 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), 4746 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry),
4817 purple_account_get_protocol_name(conv->account)); 4747 purple_account_get_protocol_name(conv->account));
4818 gtk_widget_set_size_request(gtkconv->lower_hbox, -1,
4819 chat ? purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/chat/entry_height") :
4820 purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/im/entry_height"));
4821 4748
4822 g_signal_connect(G_OBJECT(gtkconv->entry), "populate-popup", 4749 g_signal_connect(G_OBJECT(gtkconv->entry), "populate-popup",
4823 G_CALLBACK(entry_popup_menu_cb), gtkconv); 4750 G_CALLBACK(entry_popup_menu_cb), gtkconv);
4824 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", 4751 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event",
4825 G_CALLBACK(entry_key_press_cb), gtkconv); 4752 G_CALLBACK(entry_key_press_cb), gtkconv);
4826 g_signal_connect_after(G_OBJECT(gtkconv->entry), "message_send", 4753 g_signal_connect_after(G_OBJECT(gtkconv->entry), "message_send",
4827 G_CALLBACK(send_cb), gtkconv); 4754 G_CALLBACK(send_cb), gtkconv);
4828 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", 4755 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event",
4829 G_CALLBACK(entry_stop_rclick_cb), NULL); 4756 G_CALLBACK(entry_stop_rclick_cb), NULL);
4830 g_signal_connect(G_OBJECT(gtkconv->lower_hbox), "size-allocate",
4831 G_CALLBACK(size_allocate_cb), gtkconv);
4832 4757
4833 gtkconv->entry_buffer = 4758 gtkconv->entry_buffer =
4834 gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); 4759 gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry));
4835 g_object_set_data(G_OBJECT(gtkconv->entry_buffer), "user_data", gtkconv); 4760 g_object_set_data(G_OBJECT(gtkconv->entry_buffer), "user_data", gtkconv);
4836 4761
4849 G_CALLBACK(resize_imhtml_cb), gtkconv); 4774 G_CALLBACK(resize_imhtml_cb), gtkconv);
4850 4775
4851 default_formatize(gtkconv); 4776 default_formatize(gtkconv);
4852 g_signal_connect_after(G_OBJECT(gtkconv->entry), "format_function_clear", 4777 g_signal_connect_after(G_OBJECT(gtkconv->entry), "format_function_clear",
4853 G_CALLBACK(clear_formatting_cb), gtkconv); 4778 G_CALLBACK(clear_formatting_cb), gtkconv);
4854 return paned; 4779 return vbox;
4855 } 4780 }
4856 4781
4857 static void 4782 static void
4858 conv_dnd_recv(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, 4783 conv_dnd_recv(GtkWidget *widget, GdkDragContext *dc, guint x, guint y,
4859 GtkSelectionData *sd, guint info, guint t, 4784 GtkSelectionData *sd, guint info, guint t,
5109 5034
5110 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/show_formatting_toolbar")) 5035 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/show_formatting_toolbar"))
5111 gtk_widget_show(gtkconv->toolbar); 5036 gtk_widget_show(gtkconv->toolbar);
5112 else 5037 else
5113 gtk_widget_hide(gtkconv->toolbar); 5038 gtk_widget_hide(gtkconv->toolbar);
5039 g_idle_add(resize_imhtml_cb, gtkconv);
5114 5040
5115 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/im/show_buddy_icons")) 5041 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/im/show_buddy_icons"))
5116 gtk_widget_show(gtkconv->infopane_hbox); 5042 gtk_widget_show(gtkconv->infopane_hbox);
5117 else 5043 else
5118 gtk_widget_hide(gtkconv->infopane_hbox); 5044 gtk_widget_hide(gtkconv->infopane_hbox);
7119 7045
7120 if ((gboolean)GPOINTER_TO_INT(value)) 7046 if ((gboolean)GPOINTER_TO_INT(value))
7121 gtk_widget_show(gtkconv->toolbar); 7047 gtk_widget_show(gtkconv->toolbar);
7122 else 7048 else
7123 gtk_widget_hide(gtkconv->toolbar); 7049 gtk_widget_hide(gtkconv->toolbar);
7050
7051 g_idle_add(resize_imhtml_cb,gtkconv);
7124 } 7052 }
7125 } 7053 }
7126 7054
7127 static void 7055 static void
7128 animate_buddy_icons_pref_cb(const char *name, PurplePrefType type, 7056 animate_buddy_icons_pref_cb(const char *name, PurplePrefType type,

mercurial