2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2002 Hiroyuki Yamamoto
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 #include <gtk/gtkoptionmenu.h>
29 #include <gdk/gdkkeysyms.h>
35 #include "prefs_gtk.h"
37 #include "mainwindow.h"
38 #include "manage_window.h"
40 #include "stock_pixmap.h"
43 #include "alertpanel.h"
45 #include "filtering.h"
47 #include "procheader.h"
48 #include "selective_download.h"
51 static struct _SDView
{
56 GtkWidget
*preview_btn
;
57 GtkWidget
*remove_btn
;
58 GtkWidget
*download_btn
;
62 GtkWidget
*preview_popup
;
63 GtkWidget
*msgs_label
;
64 GtkWidget
*show_old_chkbtn
;
69 static GdkPixmap
*checkboxonxpm
;
70 static GdkBitmap
*checkboxonxpmmask
;
71 static GdkPixmap
*checkboxoffxpm
;
72 static GdkBitmap
*checkboxoffxpmmask
;
73 static GdkPixmap
*markxpm
;
74 static GdkBitmap
*markxpmmask
;
75 static GdkPixmap
*deletedxpm
;
76 static GdkBitmap
*deletedxpmmask
;
79 static void sd_clear_msglist (void);
80 static void sd_remove_header_files (void);
81 static void sd_toggle_btn (void);
82 static SD_State
sd_header_filter (MsgInfo
*msginfo
);
83 static MsgInfo
*sd_get_msginfo_from_file (const gchar
*filename
);
85 static void sd_clist_set_pixmap (HeaderItems
*items
,
87 static void sd_clist_get_items (void);
88 static void sd_clist_set_items (void);
89 static void sd_update_msg_num (PrefsAccount
*acc
);
101 static void sd_action_cb (GtkWidget
*widget
,
104 static void sd_select_row_cb (GtkCList
*clist
,
109 static gint
sd_key_pressed (GtkWidget
*widget
,
112 static gint
sd_delete_event_cb (GtkWidget
*widget
,
117 static gint
sd_ac_label_pressed (GtkWidget
*widget
,
118 GdkEventButton
*event
,
121 static void sd_ac_menu_popup_closed (GtkMenuShell
*menu_shell
);
122 static void sd_ac_menu_cb (GtkMenuItem
*menuitem
,
124 static void sd_ac_menu_set (void);
127 static void sd_preview_popup_closed (GtkMenuShell
*menu_shell
);
128 static gint
sd_preview_popup_cb (GtkWidget
*widget
,
129 GdkEventButton
*event
,
132 static GtkItemFactoryEntry preview_popup_entries
[] =
134 {N_("/Preview _new messages"), NULL
, sd_action_cb
, PREVIEW_NEW
, NULL
},
135 {N_("/Preview _all messages"), NULL
, sd_action_cb
, PREVIEW_ALL
, NULL
}
139 static void sd_window_create (MainWindow
*mainwin
);
140 static void sd_create_toolbar (MainWindow
*mainwin
,
141 GtkWidget
*container
);
144 void sd_init_pixmaps (MainWindow
*mainwin
);
146 void selective_download(MainWindow
*mainwin
)
148 sd_remove_header_files();
152 if (!selective
.window
) {
153 sd_init_pixmaps(mainwin
);
154 sd_window_create(mainwin
);
157 manage_window_set_transient(GTK_WINDOW(selective
.window
));
158 gtk_widget_show(selective
.window
);
161 gtk_clist_clear(GTK_CLIST(selective
.clist
));
164 void sd_init_pixmaps(MainWindow
*mainwin
)
166 GtkWidget
*widget
= mainwin
->window
;
168 g_return_if_fail(mainwin
!= NULL
);
171 stock_pixmap_gdk(widget
, STOCK_PIXMAP_CHECKBOX_OFF
,
172 &checkboxoffxpm
, &checkboxoffxpmmask
);
173 stock_pixmap_gdk(widget
, STOCK_PIXMAP_CHECKBOX_ON
,
174 &checkboxonxpm
, &checkboxonxpmmask
);
175 stock_pixmap_gdk(widget
, STOCK_PIXMAP_DELETED
,
176 &deletedxpm
, &deletedxpmmask
);
177 stock_pixmap_gdk(widget
, STOCK_PIXMAP_MARK
,
178 &markxpm
, &markxpmmask
);
181 void sd_reflect_prefs_pixmap_theme()
183 if (selective
.window
)
184 selective
.window
= NULL
;
187 static void sd_clear_msglist()
189 PrefsAccount
*acc
= cur_account
;
190 while (acc
->msg_list
!= NULL
) {
191 HeaderItems
*item
= (HeaderItems
*)acc
->msg_list
->data
;
193 acc
->msg_list
= g_slist_remove(acc
->msg_list
, item
);
195 g_free(item
->subject
);
199 g_slist_free(acc
->msg_list
);
200 sd_update_msg_num(acc
);
203 /* sd_remove_header_files()
205 * - removes any stale header files in HEADER_CACHE_DIR
208 static void sd_remove_header_files()
210 gchar
*path
= g_strconcat(get_header_cache_dir(), G_DIR_SEPARATOR_S
, NULL
);
212 remove_all_files(path
);
218 * - checks whether at least on email is selected
219 * if so, untoggle remove / download button
221 static void sd_toggle_btn()
223 PrefsAccount
*acc
= cur_account
;
226 for (cur
= acc
->msg_list
; cur
!= NULL
; cur
= cur
->next
) {
227 HeaderItems
*items
= (HeaderItems
*)cur
->data
;
229 if (items
->state
== SD_CHECKED
) {
230 gtk_widget_set_sensitive (selective
.remove_btn
, TRUE
);
231 gtk_widget_set_sensitive (selective
.download_btn
, TRUE
);
236 gtk_widget_set_sensitive (selective
.remove_btn
, FALSE
);
239 /* sd_header_filter(MsgInfo *msginfo)
241 * - parse header line and look for any applying filtering rules
242 * - if message matches other MATCHACTION --> return
245 SD_State
sd_header_filter(MsgInfo
*msginfo
)
249 /* parse header line for line */
250 for (rules
= global_processing
; rules
!= NULL
; rules
= rules
->next
) {
252 FilteringProp
*prop
= (FilteringProp
*) rules
->data
;
254 if ( matcherlist_match(prop
->matchers
, msginfo
) ) {
255 if (prop
->action
->type
== MATCHACTION_DELETE_ON_SERVER
) {
256 debug_print("action matched\n");
260 debug_print("action not matched\n");
268 /* sd_get_msginfo_from_file(const gchar *filename)
270 * - retrieve msginfo from saved header files
272 static MsgInfo
*sd_get_msginfo_from_file(const gchar
*filename
)
275 MsgFlags msgflags
= { 0, 0 };
278 msginfo
= procheader_parse_file(filename
, msgflags
, TRUE
, FALSE
);
280 if (msginfo
&& msginfo
->date_t
) {
281 procheader_date_get_localtime(date
, sizeof date
, msginfo
->date_t
);
282 if (msginfo
->date
) g_free(msginfo
->date
);
283 msginfo
->date
= g_strdup(date
);
287 msginfo
= g_new0(MsgInfo
, 1);
290 msginfo
->date
= g_strdup(_("(No date)"));
292 msginfo
->from
= g_strdup(_("(No sender)"));
293 if (!msginfo
->subject
)
294 msginfo
->subject
= g_strdup(_("(No subject)"));
299 static void sd_clist_set_pixmap(HeaderItems
*items
, gint row
)
302 switch (items
->state
) {
304 gtk_clist_set_pixmap (GTK_CLIST (selective
.clist
),
306 deletedxpm
, deletedxpmmask
);
309 gtk_clist_set_pixmap (GTK_CLIST (selective
.clist
),
311 checkboxonxpm
, checkboxonxpmmask
);
314 gtk_clist_set_pixmap (GTK_CLIST (selective
.clist
),
316 markxpm
, markxpmmask
);
319 gtk_clist_set_pixmap (GTK_CLIST (selective
.clist
),
321 checkboxoffxpm
, checkboxoffxpmmask
);
326 static void sd_clist_set_items()
328 PrefsAccount
*acc
= cur_account
;
331 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(selective
.show_old_chkbtn
));
333 gtk_clist_clear(GTK_CLIST(selective
.clist
));
334 gtk_clist_freeze(GTK_CLIST(selective
.clist
));
336 for (cur
= acc
->msg_list
; cur
!= NULL
; cur
= cur
->next
) {
337 HeaderItems
*items
= (HeaderItems
*)cur
->data
;
342 row
[1] = items
->from
;
343 row
[2] = items
->subject
;
344 row
[3] = items
->date
;
345 row
[4] = g_strdup_printf("%i KB", items
->size
/1024);
347 switch (items
->state
) {
350 items
->del_by_old_session
= TRUE
;
355 if (items
->received
) {
356 row_num
= gtk_clist_append(GTK_CLIST(selective
.clist
), row
);
357 sd_clist_set_pixmap(items
, row_num
);
361 row_num
= gtk_clist_append(GTK_CLIST(selective
.clist
), row
);
362 sd_clist_set_pixmap(items
, row_num
);
367 gtk_clist_thaw(GTK_CLIST(selective
.clist
));
371 /* sd_update_msg_num(PrefsAccount *acc)
372 * - keep track of msgs still on server
373 * - count UNCHECKED items as well as downloaded but not removed
375 static void sd_update_msg_num(PrefsAccount
*acc
)
378 gint msg_num
= g_slist_length(acc
->msg_list
);
381 for (cur
= acc
->msg_list
; cur
!= NULL
; cur
= cur
->next
) {
382 HeaderItems
*items
= (HeaderItems
*) cur
->data
;
384 if (items
->state
!= SD_UNCHECKED
)
386 if (items
->state
== SD_DOWNLOADED
)
387 if (!acc
->sd_rmmail_on_download
)
391 text
= g_strdup_printf(_("%i Messages"), msg_num
);
392 gtk_label_set_text(GTK_LABEL(selective
.msgs_label
), text
);
397 /* sd_clist_get_items()
399 * - get items for clist from Files
401 static void sd_clist_get_items(void)
404 PrefsAccount
*acc
= cur_account
;
405 gchar
*path
= g_strconcat(get_header_cache_dir(), G_DIR_SEPARATOR_S
, NULL
);
407 for (cur
= acc
->msg_list
; cur
!= NULL
; cur
= cur
->next
) {
409 HeaderItems
*items
= (HeaderItems
*) cur
->data
;
410 gchar
*filename
= g_strdup_printf("%s%i", path
, items
->index
);
411 MsgInfo
*msginfo
= sd_get_msginfo_from_file(filename
);
413 items
->from
= g_strdup(msginfo
->from
);
414 items
->subject
= g_strdup(msginfo
->subject
);
415 items
->date
= g_strdup(msginfo
->date
);
417 msginfo
->folder
= folder_get_default_processing();
419 /* move msg file to drop folder */
420 if ((msginfo
->msgnum
= folder_item_add_msg(msginfo
->folder
,
421 filename
, TRUE
)) < 0) {
426 if (acc
->sd_filter_on_recv
)
427 items
->state
= sd_header_filter(msginfo
);
429 folder_item_remove_msg(msginfo
->folder
, msginfo
->msgnum
);
431 procmsg_msginfo_free(msginfo
);
437 /* --- Callbacks -- */
438 static void sd_action_cb(GtkWidget
*widget
, guint action
)
440 PrefsAccount
*acc
= cur_account
;
445 if ( (acc
->protocol
!= A_APOP
) &&
446 (acc
->protocol
!= A_POP3
) ) {
448 _("Selected account \"%s\" is not a POP mail server.\nPlease select a different account"), acc
->account_name
);
452 if (action
== PREVIEW_NEW
) {
453 gtk_widget_set_sensitive(selective
.show_old_chkbtn
, FALSE
);
454 inc_selective_download(selective
.mainwin
, acc
, STYPE_PREVIEW_NEW
);
457 gtk_widget_set_sensitive(selective
.show_old_chkbtn
, TRUE
);
458 inc_selective_download(selective
.mainwin
, acc
, STYPE_PREVIEW_ALL
);
461 gtk_clist_clear(GTK_CLIST(selective
.clist
));
462 sd_clist_get_items();
463 sd_clist_set_items();
466 inc_selective_download(selective
.mainwin
, acc
, STYPE_DELETE
);
467 sd_clist_set_items();
470 inc_selective_download(selective
.mainwin
, acc
, STYPE_DOWNLOAD
);
471 sd_clist_set_items();
474 sd_remove_header_files();
476 gtk_widget_hide(selective
.window
);
480 sd_clist_set_items();
486 sd_update_msg_num(acc
);
490 static void sd_select_row_cb(GtkCList
*clist
, gint row
, gint column
,
491 GdkEvent
*event
, gpointer user_data
)
493 if ((row
>= 0) && (column
>= 0)) {
494 PrefsAccount
*acc
= cur_account
;
495 HeaderItems
*items
= (HeaderItems
*) g_slist_nth_data (acc
->msg_list
, row
);
498 if (!gtk_clist_get_selectable(GTK_CLIST(selective
.clist
), row
)) return;
500 if (items
->state
== SD_UNCHECKED
) {
501 items
->state
= SD_CHECKED
;
502 gtk_clist_set_pixmap (GTK_CLIST (selective
.clist
), row
, 0,
503 checkboxonxpm
, checkboxonxpmmask
);
504 } else if (items
->state
== SD_CHECKED
) {
505 items
->state
= SD_UNCHECKED
;
506 gtk_clist_set_pixmap (GTK_CLIST (selective
.clist
), row
, 0,
507 checkboxoffxpm
, checkboxoffxpmmask
);
513 static gint
sd_key_pressed(GtkWidget
*widget
,
517 if (event
&& event
->keyval
== GDK_Escape
) {
518 sd_action_cb(widget
, DONE
);
524 static gint
sd_delete_event_cb(GtkWidget
*widget
,
528 sd_action_cb(widget
, DONE
);
533 static gint
sd_ac_label_pressed(GtkWidget
*widget
, GdkEventButton
*event
,
536 if (!event
) return FALSE
;
538 gtk_button_set_relief(GTK_BUTTON(widget
), GTK_RELIEF_NORMAL
);
539 gtk_object_set_data(GTK_OBJECT(selective
.ac_menu
), "menu_button",
542 gtk_menu_popup(GTK_MENU(selective
.ac_menu
), NULL
, NULL
,
543 menu_button_position
, widget
,
544 event
->button
, event
->time
);
548 static void sd_ac_menu_popup_closed(GtkMenuShell
*menu_shell
)
552 button
= gtk_object_get_data(GTK_OBJECT(menu_shell
), "menu_button");
554 gtk_button_set_relief(GTK_BUTTON(button
), GTK_RELIEF_NONE
);
555 gtk_clist_clear(GTK_CLIST(selective
.clist
));
558 gtk_object_remove_data(GTK_OBJECT(selective
.ac_menu
), "menu_button");
561 static void sd_ac_menu_cb(GtkMenuItem
*menuitem
, gpointer data
)
563 cur_account
= (PrefsAccount
*)data
;
564 gtk_label_set_text(GTK_LABEL(selective
.ac_label
), cur_account
->account_name
);
565 gtk_widget_queue_resize(selective
.ac_button
);
566 main_window_reflect_prefs_all();
569 static void sd_ac_menu_set()
571 GList
*cur_ac
, *cur_item
;
573 PrefsAccount
*ac_prefs
;
574 GList
*account_list
= account_get_list();
576 /* destroy all previous menu item */
577 cur_item
= GTK_MENU_SHELL(selective
.ac_menu
)->children
;
578 while (cur_item
!= NULL
) {
579 GList
*next
= cur_item
->next
;
580 gtk_widget_destroy(GTK_WIDGET(cur_item
->data
));
584 gtk_label_set_text(GTK_LABEL(selective
.ac_label
), cur_account
->account_name
);
586 for (cur_ac
= account_list
; cur_ac
!= NULL
; cur_ac
= cur_ac
->next
) {
587 ac_prefs
= (PrefsAccount
*)cur_ac
->data
;
589 menuitem
= gtk_menu_item_new_with_label
590 (ac_prefs
->account_name
591 ? ac_prefs
->account_name
: _("Untitled"));
592 gtk_widget_show(menuitem
);
593 gtk_menu_append(GTK_MENU(selective
.ac_menu
), menuitem
);
594 gtk_signal_connect(GTK_OBJECT(menuitem
), "activate",
595 GTK_SIGNAL_FUNC(sd_ac_menu_cb
),
600 /* receive button popup */
601 static void sd_preview_popup_closed(GtkMenuShell
*menu_shell
)
603 gtk_button_set_relief(GTK_BUTTON(selective
.preview_btn
), GTK_RELIEF_NORMAL
);
604 manage_window_focus_in(selective
.window
, NULL
, NULL
);
607 static gint
sd_preview_popup_cb(GtkWidget
*widget
, GdkEventButton
*event
,
610 if (!event
) return FALSE
;
612 if (event
->button
== 1) {
613 gtk_button_set_relief(GTK_BUTTON(widget
), GTK_RELIEF_NORMAL
);
614 gtk_menu_popup(GTK_MENU(selective
.preview_popup
), NULL
, NULL
,
615 menu_button_position
, widget
,
616 event
->button
, event
->time
);
622 static void sd_create_toolbar(MainWindow
*mainwin
, GtkWidget
*container
)
625 GtkWidget
*tmp_toolbar_icon
;
626 GtkWidget
*preview_btn
;
627 GtkWidget
*remove_btn
;
628 GtkWidget
*download_btn
;
630 GtkWidget
*preview_popup
;
633 toolbar
= gtk_toolbar_new (GTK_ORIENTATION_VERTICAL
, GTK_TOOLBAR_BOTH
);
635 gtk_container_add (GTK_CONTAINER(container
), toolbar
);
636 gtk_container_set_border_width (GTK_CONTAINER(container
), 2);
638 gtk_toolbar_set_space_size (GTK_TOOLBAR (toolbar
), 30);
639 gtk_toolbar_set_space_style (GTK_TOOLBAR (toolbar
), GTK_TOOLBAR_SPACE_LINE
);
641 tmp_toolbar_icon
= stock_pixmap_widget (container
, STOCK_PIXMAP_MAIL_RECEIVE
);
642 preview_btn
= gtk_toolbar_append_element (GTK_TOOLBAR (toolbar
),
643 GTK_TOOLBAR_CHILD_BUTTON
,
646 _("Preview old/new mail on account"), NULL
,
647 tmp_toolbar_icon
, NULL
, NULL
);
649 n_menu_entries
= sizeof (preview_popup_entries
)/sizeof (preview_popup_entries
[0]);
650 preview_popup
= popupmenu_create (preview_btn
, preview_popup_entries
, n_menu_entries
,
651 "<SelectiveDownload>", mainwin
);
653 gtk_signal_connect (GTK_OBJECT(preview_popup
), "selection_done",
654 GTK_SIGNAL_FUNC(sd_preview_popup_closed
), NULL
);
656 gtk_toolbar_append_space (GTK_TOOLBAR (toolbar
));
658 tmp_toolbar_icon
= stock_pixmap_widget (container
, STOCK_PIXMAP_CLOSE
);
659 remove_btn
= gtk_toolbar_append_element (GTK_TOOLBAR (toolbar
),
660 GTK_TOOLBAR_CHILD_BUTTON
,
663 _("Remove selected mail"), NULL
,
664 tmp_toolbar_icon
, NULL
, NULL
);
666 gtk_widget_set_sensitive (remove_btn
, FALSE
);
668 tmp_toolbar_icon
= stock_pixmap_widget(container
, STOCK_PIXMAP_DOWN_ARROW
);
669 download_btn
= gtk_toolbar_append_element (GTK_TOOLBAR (toolbar
),
670 GTK_TOOLBAR_CHILD_BUTTON
,
673 _("Download selected mail"), NULL
,
674 tmp_toolbar_icon
, NULL
, NULL
);
676 gtk_widget_set_sensitive (download_btn
, FALSE
);
678 gtk_toolbar_append_space (GTK_TOOLBAR (toolbar
));
680 tmp_toolbar_icon
= stock_pixmap_widget (container
, STOCK_PIXMAP_COMPLETE
);
682 done_btn
= gtk_toolbar_append_element (GTK_TOOLBAR (toolbar
),
683 GTK_TOOLBAR_CHILD_BUTTON
,
686 _("Exit dialog"), NULL
,
687 tmp_toolbar_icon
, NULL
, NULL
);
689 gtk_signal_connect (GTK_OBJECT (preview_btn
), "button_press_event",
690 GTK_SIGNAL_FUNC (sd_preview_popup_cb
),
692 gtk_signal_connect (GTK_OBJECT (remove_btn
), "clicked",
693 GTK_SIGNAL_FUNC (sd_action_cb
),
694 GUINT_TO_POINTER(REMOVE
));
695 gtk_signal_connect (GTK_OBJECT (download_btn
), "clicked",
696 GTK_SIGNAL_FUNC (sd_action_cb
),
697 GUINT_TO_POINTER(DOWNLOAD
));
698 gtk_signal_connect (GTK_OBJECT (done_btn
), "clicked",
699 GTK_SIGNAL_FUNC (sd_action_cb
),
700 GUINT_TO_POINTER(DONE
));
702 selective
.preview_btn
= preview_btn
;
703 selective
.remove_btn
= remove_btn
;
704 selective
.download_btn
= download_btn
;
705 selective
.preview_popup
= preview_popup
;
709 static void sd_window_create(MainWindow
*mainwin
)
713 GtkWidget
*msgs_label
;
714 GtkWidget
*bottom_hbox
;
715 GtkWidget
*fixed_label
;
716 GtkWidget
*expand_label
;
717 GtkWidget
*ac_button
;
720 GtkWidget
*show_old_chkbtn
;
721 GtkWidget
*scrolledwindow
;
723 GtkWidget
*state_label
;
724 GtkWidget
*from_label
;
725 GtkWidget
*subject_label
;
726 GtkWidget
*size_label
;
727 GtkWidget
*date_label
;
728 GtkWidget
*toolbar_hbox
;
730 window
= gtk_window_new (GTK_WINDOW_TOPLEVEL
);
731 gtk_object_set_data (GTK_OBJECT (window
), "window", window
);
732 gtk_window_set_title (GTK_WINDOW (window
), _("Selective download"));
733 gtk_window_set_position (GTK_WINDOW (window
), GTK_WIN_POS_CENTER
);
734 gtk_window_set_modal (GTK_WINDOW (window
), TRUE
);
735 gtk_window_set_policy (GTK_WINDOW (window
), TRUE
, TRUE
, TRUE
);
736 /* avoids GDK warning (pixmap with NULL window) */
737 gtk_widget_realize (window
);
739 table
= gtk_table_new (2, 2, FALSE
);
740 gtk_container_add (GTK_CONTAINER (window
), table
);
742 msgs_label
= gtk_label_new (_("0 messages"));
743 gtk_table_attach (GTK_TABLE (table
), msgs_label
, 1, 2, 1, 2,
744 (GtkAttachOptions
) (GTK_FILL
),
745 (GtkAttachOptions
) (0), 0, 0);
746 gtk_misc_set_alignment (GTK_MISC (msgs_label
), 0, 0.5);
748 bottom_hbox
= gtk_hbox_new (FALSE
, 0);
749 gtk_table_attach (GTK_TABLE (table
), bottom_hbox
, 0, 1, 1, 2,
750 (GtkAttachOptions
) (GTK_FILL
),
751 (GtkAttachOptions
) (GTK_FILL
), 0, 0);
753 show_old_chkbtn
= gtk_check_button_new_with_label(_("Show only old messages"));
754 gtk_box_pack_start (GTK_BOX(bottom_hbox
), show_old_chkbtn
, FALSE
, FALSE
, 0);
756 gtk_signal_connect (GTK_OBJECT(show_old_chkbtn
), "toggled",
757 GTK_SIGNAL_FUNC(sd_action_cb
), GUINT_TO_POINTER(CHECKBTN
));
758 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(show_old_chkbtn
), FALSE
);
759 GTK_WIDGET_UNSET_FLAGS (show_old_chkbtn
, GTK_CAN_FOCUS
);
761 expand_label
= gtk_label_new (" ");
762 gtk_box_pack_start (GTK_BOX (bottom_hbox
), expand_label
, TRUE
, TRUE
, 0);
764 fixed_label
= gtk_label_new (_(" contains "));
765 gtk_box_pack_end (GTK_BOX (bottom_hbox
), fixed_label
, FALSE
, FALSE
, 0);
767 ac_menu
= gtk_menu_new();
768 gtk_signal_connect (GTK_OBJECT(ac_menu
), "selection_done",
769 GTK_SIGNAL_FUNC(sd_ac_menu_popup_closed
), NULL
);
770 ac_button
= gtk_button_new();
771 gtk_button_set_relief (GTK_BUTTON(ac_button
), GTK_RELIEF_NONE
);
772 GTK_WIDGET_UNSET_FLAGS (ac_button
, GTK_CAN_FOCUS
);
773 gtk_widget_set_usize (ac_button
, -1, 1);
774 gtk_box_pack_start (GTK_BOX(bottom_hbox
), ac_button
, FALSE
, FALSE
, 0);
775 gtk_signal_connect (GTK_OBJECT(ac_button
), "button_press_event",
776 GTK_SIGNAL_FUNC(sd_ac_label_pressed
), GTK_OBJECT(ac_menu
));
778 ac_label
= gtk_label_new("");
779 gtk_container_add (GTK_CONTAINER(ac_button
), ac_label
);
781 scrolledwindow
= gtk_scrolled_window_new (NULL
, NULL
);
782 gtk_table_attach (GTK_TABLE (table
), scrolledwindow
, 0, 1, 0, 1,
783 (GtkAttachOptions
) (GTK_EXPAND
| GTK_FILL
),
784 (GtkAttachOptions
) (GTK_EXPAND
| GTK_FILL
), 0, 0);
785 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow
),
787 GTK_POLICY_AUTOMATIC
);
789 clist
= gtk_clist_new (5);
790 gtk_container_add (GTK_CONTAINER (scrolledwindow
), clist
);
791 gtk_container_set_border_width (GTK_CONTAINER (clist
), 5);
792 gtk_clist_set_column_width (GTK_CLIST (clist
), 0, 20);
793 gtk_clist_set_column_width (GTK_CLIST (clist
), 1, 150);
794 gtk_clist_set_column_width (GTK_CLIST (clist
), 2, 150);
795 gtk_clist_set_column_width (GTK_CLIST (clist
), 3, 100);
796 gtk_clist_set_column_width (GTK_CLIST (clist
), 4, 30);
797 gtk_clist_set_selection_mode (GTK_CLIST (clist
), GTK_SELECTION_BROWSE
);
798 gtk_clist_column_titles_show (GTK_CLIST (clist
));
800 state_label
= gtk_label_new (_("#"));
801 gtk_clist_set_column_widget (GTK_CLIST (clist
), 0, state_label
);
803 from_label
= gtk_label_new (_("From"));
804 gtk_clist_set_column_widget (GTK_CLIST (clist
), 1, from_label
);
806 subject_label
= gtk_label_new (_("Subject"));
807 gtk_clist_set_column_widget (GTK_CLIST (clist
), 2, subject_label
);
809 date_label
= gtk_label_new (_("Date"));
810 gtk_clist_set_column_widget (GTK_CLIST (clist
), 3, date_label
);
812 size_label
= gtk_label_new (_("Size"));
813 gtk_widget_ref (size_label
);
814 gtk_clist_set_column_widget (GTK_CLIST (clist
), 4, size_label
);
817 toolbar_hbox
= gtk_hbox_new (FALSE
, 0);
819 gtk_table_attach (GTK_TABLE (table
), toolbar_hbox
, 1, 2, 0, 1,
820 (GtkAttachOptions
) (GTK_FILL
),
821 (GtkAttachOptions
) (GTK_FILL
), 0, 0);
822 sd_create_toolbar(mainwin
, toolbar_hbox
);
825 gtk_signal_connect (GTK_OBJECT (window
), "delete_event",
826 GTK_SIGNAL_FUNC (sd_delete_event_cb
),
828 gtk_signal_connect (GTK_OBJECT(window
), "key_press_event",
829 GTK_SIGNAL_FUNC(sd_key_pressed
),
831 MANAGE_WINDOW_SIGNALS_CONNECT (window
);
833 gtk_signal_connect (GTK_OBJECT (clist
), "select_row",
834 GTK_SIGNAL_FUNC (sd_select_row_cb
),
837 selective
.mainwin
= mainwin
;
838 selective
.window
= window
;
839 selective
.clist
= clist
;
840 selective
.ac_label
= ac_label
;
841 selective
.ac_button
= ac_button
;
842 selective
.ac_menu
= ac_menu
;
843 selective
.msgs_label
= msgs_label
;
844 selective
.show_old_chkbtn
= show_old_chkbtn
;
846 gtk_widget_show_all(window
);