Mercurial > pidgin.yaz
comparison src/gtkconv.c @ 7295:c7f0a4397d9e
[gaim-migrate @ 7879]
I added a search feature to conversations. I actually did most of this a
while ago for the log viewer. GtkIMHtml has some functions to handle searching
itself. I just added a new item to the conversation menu to handle it.
This should be useful for long IRC channel backlogs and the sorts.
It's case-sensitive right now. That kinda sucks, but that's all GTK lets me
do. GtkSourceView has some nice case-insensitive search functions that I'll
likely bring in before the release.
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Sat, 18 Oct 2003 01:58:02 +0000 |
parents | 1930e3d00ecd |
children | caca74a75e4c |
comparison
equal
deleted
inserted
replaced
7294:e5d0f5cb61fb | 7295:c7f0a4397d9e |
---|---|
713 conv = gaim_conv_window_get_active_conversation(win); | 713 conv = gaim_conv_window_get_active_conversation(win); |
714 | 714 |
715 conv_show_log(NULL, (char *)gaim_conversation_get_name(conv)); | 715 conv_show_log(NULL, (char *)gaim_conversation_get_name(conv)); |
716 } | 716 } |
717 | 717 |
718 struct _search { | |
719 GaimGtkConversation *gtkconv; | |
720 GtkWidget *entry; | |
721 }; | |
722 | |
723 static void do_search_cb(GtkWidget *widget, gint resp, struct _search *s) | |
724 { | |
725 switch (resp) { | |
726 case GTK_RESPONSE_OK: | |
727 gtk_imhtml_search_find(s->gtkconv->imhtml, gtk_entry_get_text(GTK_ENTRY(s->entry))); | |
728 break; | |
729 case GTK_RESPONSE_CLOSE: | |
730 gtk_imhtml_search_clear(s->gtkconv->imhtml); | |
731 gtk_widget_destroy(s->gtkconv->dialogs.search); | |
732 s->gtkconv->dialogs.search = NULL; | |
733 g_free(s); | |
734 break; | |
735 } | |
736 } | |
737 | |
738 static void | |
739 menu_search_cb(gpointer data, guint action, GtkWidget *widget) | |
740 { | |
741 GaimConvWindow *win = (GaimConvWindow *)data; | |
742 GaimConversation *conv = gaim_conv_window_get_active_conversation(win); | |
743 GaimGtkWindow *gtkwin = GAIM_GTK_WINDOW(win); | |
744 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); | |
745 GtkWidget *hbox, *vbox; | |
746 GtkWidget *img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG); | |
747 GtkWidget *label, *entry; | |
748 struct _search *s; | |
749 | |
750 if (gtkconv->dialogs.search) | |
751 return; | |
752 | |
753 gtkconv->dialogs.search = gtk_dialog_new_with_buttons("", GTK_WINDOW(gtkwin->window), | |
754 GTK_DIALOG_DESTROY_WITH_PARENT, | |
755 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, | |
756 GTK_STOCK_FIND, GTK_RESPONSE_OK, NULL); | |
757 gtk_container_set_border_width (GTK_CONTAINER(gtkconv->dialogs.search), 6); | |
758 gtk_window_set_resizable(GTK_WINDOW(gtkconv->dialogs.search), FALSE); | |
759 gtk_dialog_set_has_separator(GTK_DIALOG(gtkconv->dialogs.search), FALSE); | |
760 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(gtkconv->dialogs.search)->vbox), 12); | |
761 gtk_container_set_border_width (GTK_CONTAINER(GTK_DIALOG(gtkconv->dialogs.search)->vbox), 6); | |
762 | |
763 hbox = gtk_hbox_new(FALSE, 6); | |
764 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(gtkconv->dialogs.search)->vbox), hbox); | |
765 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
766 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
767 | |
768 vbox = gtk_vbox_new(FALSE, 0); | |
769 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
770 | |
771 label = gtk_label_new(NULL); | |
772 gtk_label_set_markup(GTK_LABEL(label), _("<span weight='bold' size='larger'>Enter a search phrase\n</span>")); | |
773 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
774 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
775 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
776 | |
777 hbox = gtk_hbox_new(FALSE, 6); | |
778 gtk_container_add(GTK_CONTAINER(vbox), hbox); | |
779 label = gtk_label_new(_("Search term: ")); | |
780 entry = gtk_entry_new(); | |
781 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
782 gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0); | |
783 | |
784 s = g_malloc(sizeof(struct _search)); | |
785 s->gtkconv = gtkconv; | |
786 s->entry = entry; | |
787 | |
788 gtk_dialog_set_default_response (GTK_DIALOG(gtkconv->dialogs.search), GTK_RESPONSE_OK); | |
789 g_signal_connect(G_OBJECT(gtkconv->dialogs.search), "response", G_CALLBACK(do_search_cb), s); | |
790 | |
791 gtk_widget_show_all(gtkconv->dialogs.search); | |
792 } | |
793 | |
718 static void | 794 static void |
719 menu_add_pounce_cb(gpointer data, guint action, GtkWidget *widget) | 795 menu_add_pounce_cb(gpointer data, guint action, GtkWidget *widget) |
720 { | 796 { |
721 GaimConvWindow *win = (GaimConvWindow *)data; | 797 GaimConvWindow *win = (GaimConvWindow *)data; |
722 GaimConversation *conv; | 798 GaimConversation *conv; |
2835 /* Conversation menu */ | 2911 /* Conversation menu */ |
2836 { N_("/_Conversation"), NULL, NULL, 0, "<Branch>" }, | 2912 { N_("/_Conversation"), NULL, NULL, 0, "<Branch>" }, |
2837 | 2913 |
2838 { N_("/Conversation/_Save As..."), NULL, menu_save_as_cb, 0, | 2914 { N_("/Conversation/_Save As..."), NULL, menu_save_as_cb, 0, |
2839 "<StockItem>", GTK_STOCK_SAVE_AS }, | 2915 "<StockItem>", GTK_STOCK_SAVE_AS }, |
2840 { N_("/Conversation/View _Log..."), NULL, menu_view_log_cb, 0, NULL }, | 2916 { N_("/Conversation/View _Log"), NULL, menu_view_log_cb, 0, NULL }, |
2917 { N_("/Conversation/Search..."), NULL, menu_search_cb, 0, "<StockItem>", GTK_STOCK_FIND }, | |
2841 | 2918 |
2842 { "/Conversation/sep1", NULL, NULL, 0, "<Separator>" }, | 2919 { "/Conversation/sep1", NULL, NULL, 0, "<Separator>" }, |
2843 | 2920 |
2844 { N_("/Conversation/Add Buddy _Pounce..."), NULL, menu_add_pounce_cb, | 2921 { N_("/Conversation/Add Buddy _Pounce..."), NULL, menu_add_pounce_cb, |
2845 0, NULL }, | 2922 0, NULL }, |
2914 gtk_item_factory_get_widget(gtkwin->menu.item_factory, "<main>"); | 2991 gtk_item_factory_get_widget(gtkwin->menu.item_factory, "<main>"); |
2915 | 2992 |
2916 | 2993 |
2917 gtkwin->menu.view_log = | 2994 gtkwin->menu.view_log = |
2918 gtk_item_factory_get_widget(gtkwin->menu.item_factory, | 2995 gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
2919 N_("/Conversation/View Log...")); | 2996 N_("/Conversation/View Log")); |
2920 /* --- */ | 2997 /* --- */ |
2921 | 2998 |
2922 gtkwin->menu.add_pounce = | 2999 gtkwin->menu.add_pounce = |
2923 gtk_item_factory_get_widget(gtkwin->menu.item_factory, | 3000 gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
2924 N_("/Conversation/Add Buddy Pounce...")); | 3001 N_("/Conversation/Add Buddy Pounce...")); |
4244 if (gtkconv->dialogs.link != NULL) | 4321 if (gtkconv->dialogs.link != NULL) |
4245 gtk_widget_destroy(gtkconv->dialogs.link); | 4322 gtk_widget_destroy(gtkconv->dialogs.link); |
4246 | 4323 |
4247 if (gtkconv->dialogs.log != NULL) | 4324 if (gtkconv->dialogs.log != NULL) |
4248 gtk_widget_destroy(gtkconv->dialogs.log); | 4325 gtk_widget_destroy(gtkconv->dialogs.log); |
4326 | |
4327 if (gtkconv->dialogs.search != NULL) | |
4328 gtk_widget_destroy(gtkconv->dialogs.search); | |
4249 | 4329 |
4250 gtk_widget_destroy(gtkconv->tab_cont); | 4330 gtk_widget_destroy(gtkconv->tab_cont); |
4251 g_object_unref(gtkconv->tab_cont); | 4331 g_object_unref(gtkconv->tab_cont); |
4252 | 4332 |
4253 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) { | 4333 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) { |