| 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); |
| 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, >kconv->entry, >kconv->toolbar, NULL); |
4741 frame = pidgin_create_imhtml(TRUE, >kconv->entry, >kconv->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, |