Mercurial > pidgin
comparison src/gtkstatusbox.c @ 12269:f1515af27443
[gaim-migrate @ 14571]
iff you're typing a status message, show a formatting toolbar.
This still needs work, but I'm going home now. Things you can do before I
get home that would make me happy:
- Iff you're typing a message, moving the cursor around should reset the timeout
- Changing the formatting should reset the timeout
- Some sort of "tiny mode" for the gtkimhtml toolbar would be cool, so that
more buttons will fit
- Figure out why things get crack when the timeout expires. Try selecting some
text and setting Bold or something, and then noticing that everything but
what you've selected turns bold. It's crazy.
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Wed, 30 Nov 2005 03:49:10 +0000 |
parents | 6e55515e4b39 |
children | 3d9ef8a98074 |
comparison
equal
deleted
inserted
replaced
12268:deb955f7ebb7 | 12269:f1515af27443 |
---|---|
28 #include "savedstatuses.h" | 28 #include "savedstatuses.h" |
29 #include "status.h" | 29 #include "status.h" |
30 #include "debug.h" | 30 #include "debug.h" |
31 | 31 |
32 #include "gtkgaim.h" | 32 #include "gtkgaim.h" |
33 #include "gtkimhtmltoolbar.h" | |
33 #include "gtksavedstatuses.h" | 34 #include "gtksavedstatuses.h" |
34 #include "gtkstock.h" | 35 #include "gtkstock.h" |
35 #include "gtkstatusbox.h" | 36 #include "gtkstatusbox.h" |
36 #include "gtkutils.h" | 37 #include "gtkutils.h" |
37 | 38 |
484 } | 485 } |
485 | 486 |
486 static void | 487 static void |
487 gtk_gaim_status_box_init (GtkGaimStatusBox *status_box) | 488 gtk_gaim_status_box_init (GtkGaimStatusBox *status_box) |
488 { | 489 { |
490 GtkWidget *vbox; | |
489 GtkCellRenderer *text_rend; | 491 GtkCellRenderer *text_rend; |
490 GtkCellRenderer *icon_rend; | 492 GtkCellRenderer *icon_rend; |
491 GtkTextBuffer *buffer; | 493 GtkTextBuffer *buffer; |
492 GtkTreePath *path; | 494 GtkTreePath *path; |
493 GtkIconSize icon_size; | 495 GtkIconSize icon_size; |
542 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box->cell_view), status_box->text_rend, "markup", TEXT_COLUMN, NULL); | 544 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box->cell_view), status_box->text_rend, "markup", TEXT_COLUMN, NULL); |
543 | 545 |
544 g_object_set(G_OBJECT(status_box->icon_rend), "xpad", 6, NULL); | 546 g_object_set(G_OBJECT(status_box->icon_rend), "xpad", 6, NULL); |
545 | 547 |
546 status_box->vbox = gtk_vbox_new(0, FALSE); | 548 status_box->vbox = gtk_vbox_new(0, FALSE); |
547 status_box->imhtml = gtk_imhtml_new(NULL, NULL); | 549 vbox = gtk_vbox_new(0,FALSE); |
550 status_box->imhtml = gtk_imhtml_new(NULL, NULL); | |
551 status_box->toolbar = gtk_imhtmltoolbar_new(); | |
552 gtk_imhtmltoolbar_attach(GTK_IMHTMLTOOLBAR(status_box->toolbar), status_box->imhtml); | |
553 status_box->hsep = gtk_hseparator_new(); | |
554 | |
548 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(status_box->imhtml)); | 555 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(status_box->imhtml)); |
549 g_signal_connect(G_OBJECT(status_box->toggle_button), "button-press-event", G_CALLBACK(button_pressed_cb), status_box); | 556 g_signal_connect(G_OBJECT(status_box->toggle_button), "button-press-event", G_CALLBACK(button_pressed_cb), status_box); |
550 g_signal_connect(G_OBJECT(status_box->toggle_button), "button-release-event", G_CALLBACK(button_released_cb), status_box); | 557 g_signal_connect(G_OBJECT(status_box->toggle_button), "button-release-event", G_CALLBACK(button_released_cb), status_box); |
551 g_signal_connect(G_OBJECT(buffer), "changed", G_CALLBACK(imhtml_changed_cb), status_box); | 558 g_signal_connect(G_OBJECT(buffer), "changed", G_CALLBACK(imhtml_changed_cb), status_box); |
552 g_signal_connect_swapped(G_OBJECT(status_box->imhtml), "message_send", G_CALLBACK(remove_typing_cb), status_box); | 559 g_signal_connect_swapped(G_OBJECT(status_box->imhtml), "message_send", G_CALLBACK(remove_typing_cb), status_box); |
554 gtk_widget_set_parent(status_box->vbox, GTK_WIDGET(status_box)); | 561 gtk_widget_set_parent(status_box->vbox, GTK_WIDGET(status_box)); |
555 gtk_widget_set_parent(status_box->toggle_button, GTK_WIDGET(status_box)); | 562 gtk_widget_set_parent(status_box->toggle_button, GTK_WIDGET(status_box)); |
556 status_box->sw = gtk_scrolled_window_new(NULL, NULL); | 563 status_box->sw = gtk_scrolled_window_new(NULL, NULL); |
557 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(status_box->sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); | 564 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(status_box->sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
558 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(status_box->sw), GTK_SHADOW_IN); | 565 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(status_box->sw), GTK_SHADOW_IN); |
559 gtk_container_add(GTK_CONTAINER(status_box->sw), status_box->imhtml); | 566 gtk_container_add(GTK_CONTAINER(status_box->sw), vbox); |
567 gtk_box_pack_start(GTK_BOX(vbox), status_box->toolbar, FALSE, FALSE, 0); | |
568 gtk_box_pack_start(GTK_BOX(vbox), status_box->hsep, FALSE, FALSE, 0); | |
569 gtk_box_pack_start(GTK_BOX(vbox), status_box->imhtml, TRUE, TRUE, 0); | |
570 | |
560 gtk_box_pack_start(GTK_BOX(status_box->vbox), status_box->sw, TRUE, TRUE, 0); | 571 gtk_box_pack_start(GTK_BOX(status_box->vbox), status_box->sw, TRUE, TRUE, 0); |
561 | 572 |
562 g_signal_connect(G_OBJECT(status_box->imhtml), "scroll_event", | 573 g_signal_connect(G_OBJECT(status_box->imhtml), "scroll_event", |
563 G_CALLBACK(scroll_event_cb), status_box->imhtml); | 574 G_CALLBACK(scroll_event_cb), status_box->imhtml); |
564 | 575 |
608 requisition->height += 6; | 619 requisition->height += 6; |
609 | 620 |
610 gtk_widget_size_request(GTK_GAIM_STATUS_BOX(widget)->vbox, &box_req); | 621 gtk_widget_size_request(GTK_GAIM_STATUS_BOX(widget)->vbox, &box_req); |
611 if (box_req.height > 1) | 622 if (box_req.height > 1) |
612 requisition->height = requisition->height + box_req.height + 6; | 623 requisition->height = requisition->height + box_req.height + 6; |
613 | 624 |
625 if (GTK_GAIM_STATUS_BOX(widget)->typing) { | |
626 gtk_widget_size_request(GTK_GAIM_STATUS_BOX(widget)->toolbar, &box_req); | |
627 requisition->height = requisition->height + box_req.height; | |
628 } | |
629 | |
614 requisition->width = 1; | 630 requisition->width = 1; |
615 | 631 |
616 } | 632 } |
617 | 633 |
618 static void | 634 static void |
896 activate_currently_selected_status(status_box); | 912 activate_currently_selected_status(status_box); |
897 | 913 |
898 g_source_remove(status_box->typing); | 914 g_source_remove(status_box->typing); |
899 status_box->typing = 0; | 915 status_box->typing = 0; |
900 gtk_gaim_status_box_refresh(status_box); | 916 gtk_gaim_status_box_refresh(status_box); |
917 gtk_widget_hide(status_box->toolbar); | |
918 gtk_widget_hide(status_box->hsep); | |
901 } | 919 } |
902 | 920 |
903 static void gtk_gaim_status_box_changed(GtkComboBox *box) | 921 static void gtk_gaim_status_box_changed(GtkComboBox *box) |
904 { | 922 { |
905 GtkGaimStatusBox *status_box; | 923 GtkGaimStatusBox *status_box; |
928 g_object_unref(status_box->pixbuf); | 946 g_object_unref(status_box->pixbuf); |
929 status_box->pixbuf = pixbuf; | 947 status_box->pixbuf = pixbuf; |
930 if (status_box->typing) | 948 if (status_box->typing) |
931 g_source_remove(status_box->typing); | 949 g_source_remove(status_box->typing); |
932 status_box->typing = 0; | 950 status_box->typing = 0; |
951 gtk_widget_hide(status_box->hsep); | |
952 gtk_widget_hide(status_box->toolbar); | |
933 | 953 |
934 if (GTK_WIDGET_IS_SENSITIVE(GTK_WIDGET(status_box))) | 954 if (GTK_WIDGET_IS_SENSITIVE(GTK_WIDGET(status_box))) |
935 { | 955 { |
936 if (type == GTK_GAIM_STATUS_BOX_TYPE_CUSTOM) | 956 if (type == GTK_GAIM_STATUS_BOX_TYPE_CUSTOM) |
937 { | 957 { |
975 g_list_free(accounts); | 995 g_list_free(accounts); |
976 | 996 |
977 if (status_box->imhtml_visible) | 997 if (status_box->imhtml_visible) |
978 { | 998 { |
979 gtk_widget_show_all(status_box->vbox); | 999 gtk_widget_show_all(status_box->vbox); |
980 if (GTK_WIDGET_IS_SENSITIVE(GTK_WIDGET(status_box))) | 1000 if (GTK_WIDGET_IS_SENSITIVE(GTK_WIDGET(status_box))) |
981 status_box->typing = g_timeout_add(3000, (GSourceFunc)remove_typing_cb, status_box); | 1001 status_box->typing = g_timeout_add(3000, (GSourceFunc)remove_typing_cb, status_box); |
982 gtk_imhtml_clear(GTK_IMHTML(status_box->imhtml)); | 1002 gtk_imhtml_clear(GTK_IMHTML(status_box->imhtml)); |
983 gtk_widget_grab_focus(status_box->imhtml); | 1003 gtk_widget_grab_focus(status_box->imhtml); |
984 } | 1004 } |
985 else | 1005 else |
999 if (box->typing) { | 1019 if (box->typing) { |
1000 gtk_gaim_status_box_pulse_typing(box); | 1020 gtk_gaim_status_box_pulse_typing(box); |
1001 g_source_remove(box->typing); | 1021 g_source_remove(box->typing); |
1002 } | 1022 } |
1003 box->typing = g_timeout_add(3000, (GSourceFunc)remove_typing_cb, box); | 1023 box->typing = g_timeout_add(3000, (GSourceFunc)remove_typing_cb, box); |
1024 gtk_widget_show(box->hsep); | |
1025 gtk_widget_show(box->toolbar); | |
1004 } | 1026 } |
1005 gtk_gaim_status_box_refresh(box); | 1027 gtk_gaim_status_box_refresh(box); |
1006 } | 1028 } |
1007 | 1029 |
1008 GtkGaimStatusBoxItemType gtk_gaim_status_box_get_active_type(GtkGaimStatusBox *status_box) | 1030 GtkGaimStatusBoxItemType gtk_gaim_status_box_get_active_type(GtkGaimStatusBox *status_box) |