2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2012 Hiroyuki Yamamoto and the Claws Mail team
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 3 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, see <http://www.gnu.org/licenses/>.
22 #include "claws-features.h"
28 #include <glib/gi18n.h>
30 #include <gdk/gdkkeysyms.h>
36 #include "prefs_gtk.h"
37 #include "prefs_display_header.h"
38 #include "prefs_common.h"
39 #include "manage_window.h"
40 #include "alertpanel.h"
41 #include "displayheader.h"
51 static struct DisplayHeader
{
55 GtkWidget
*cancel_btn
;
59 GtkWidget
*headers_list_view
;
60 GtkWidget
*hidden_headers_list_view
;
62 GtkWidget
*other_headers
;
65 /* widget creating functions */
66 static void prefs_display_header_create (void);
68 static void prefs_display_header_set_dialog (void);
69 static void prefs_display_header_set_list (void);
70 static void prefs_display_header_list_view_set_row (gboolean hidden
);
72 /* callback functions */
73 static void prefs_display_header_register_cb (GtkButton
*btn
,
74 gpointer hidden_data
);
75 static void prefs_display_header_delete_cb (GtkButton
*btn
,
76 gpointer list_view_data
);
77 static void prefs_display_header_up (void);
78 static void prefs_display_header_down (void);
80 static gboolean
prefs_display_header_key_pressed (GtkWidget
*widget
,
83 static void prefs_display_header_ok (void);
84 static void prefs_display_header_cancel (void);
85 static gint
prefs_display_header_deleted (GtkWidget
*widget
,
90 static GtkListStore
*prefs_display_header_create_store (void);
91 static void prefs_display_header_insert_header (GtkListStore
*store
,
93 DisplayHeaderProp
*dp
);
94 static GtkWidget
*prefs_display_header_list_view_create (const gchar
*name
);
95 static void prefs_filtering_create_list_view_columns (GtkWidget
*list_view
,
97 static void headers_list_model_rows_reordered (GtkTreeModel
*model
,
101 GtkTreeView
*list_view
);
103 static void drag_end (GtkTreeView
*list_view
,
104 GdkDragContext
*context
,
108 static gchar
*defaults
[] =
129 "-Content-Transfer-Encoding",
137 static gchar
*defaults
[] =
158 "-Content-Transfer-Encoding",
166 static void prefs_display_header_set_default(void)
169 DisplayHeaderProp
*dp
;
171 for(i
= 0; i
< sizeof(defaults
) / sizeof(defaults
[0]); i
++) {
172 dp
= display_header_prop_read_str(defaults
[i
]);
173 prefs_common
.disphdr_list
=
174 g_slist_append(prefs_common
.disphdr_list
, dp
);
178 void prefs_display_header_open(void)
180 if (prefs_rc_is_readonly(DISPLAY_HEADER_RC
))
183 if (!dispheader
.window
) {
184 prefs_display_header_create();
187 manage_window_set_transient(GTK_WINDOW(dispheader
.window
));
188 gtk_widget_grab_focus(dispheader
.ok_btn
);
190 prefs_display_header_set_dialog();
192 gtk_widget_show(dispheader
.window
);
193 gtk_window_set_modal(GTK_WINDOW(dispheader
.window
), TRUE
);
196 static void prefs_display_header_create(void)
202 GtkWidget
*cancel_btn
;
203 GtkWidget
*confirm_area
;
208 GtkWidget
*hdr_label
;
209 GtkWidget
*hdr_combo
;
217 GtkWidget
*list_view_hbox
;
218 GtkWidget
*list_view_hbox1
;
219 GtkWidget
*list_view_hbox2
;
220 GtkWidget
*list_view_scrolledwin
;
221 GtkWidget
*headers_list_view
;
222 GtkWidget
*hidden_headers_list_view
;
224 GtkWidget
*checkbtn_other_headers
;
227 debug_print("Creating display header setting window...\n");
229 window
= gtkut_window_new(GTK_WINDOW_TOPLEVEL
, "prefs_display_header");
230 gtk_container_set_border_width (GTK_CONTAINER (window
), 8);
231 gtk_window_set_position (GTK_WINDOW (window
), GTK_WIN_POS_CENTER
);
232 gtk_window_set_resizable(GTK_WINDOW (window
), TRUE
);
234 vbox
= gtk_vbox_new (FALSE
, 6);
235 gtk_widget_show (vbox
);
236 gtk_container_add (GTK_CONTAINER (window
), vbox
);
238 btn_hbox
= gtk_hbox_new (FALSE
, 8);
239 gtk_widget_show (btn_hbox
);
240 gtk_box_pack_end (GTK_BOX (vbox
), btn_hbox
, FALSE
, FALSE
, 0);
242 gtkut_stock_button_set_create(&confirm_area
, &cancel_btn
, GTK_STOCK_CANCEL
,
243 &ok_btn
, GTK_STOCK_OK
,
245 gtk_widget_show (confirm_area
);
246 gtk_box_pack_end (GTK_BOX(btn_hbox
), confirm_area
, FALSE
, FALSE
, 0);
247 gtk_widget_grab_default (ok_btn
);
249 gtk_window_set_title (GTK_WINDOW(window
),
250 _("Displayed header configuration"));
251 MANAGE_WINDOW_SIGNALS_CONNECT(window
);
252 g_signal_connect (G_OBJECT(window
), "delete_event",
253 G_CALLBACK(prefs_display_header_deleted
),
255 g_signal_connect (G_OBJECT(window
), "key_press_event",
256 G_CALLBACK(prefs_display_header_key_pressed
),
258 g_signal_connect (G_OBJECT(ok_btn
), "clicked",
259 G_CALLBACK(prefs_display_header_ok
),
261 g_signal_connect (G_OBJECT(cancel_btn
), "clicked",
262 G_CALLBACK(prefs_display_header_cancel
),
265 vbox1
= gtk_vbox_new (FALSE
, VSPACING
);
266 gtk_widget_show (vbox1
);
267 gtk_box_pack_start (GTK_BOX (vbox
), vbox1
, TRUE
, TRUE
, 0);
268 gtk_container_set_border_width (GTK_CONTAINER (vbox1
), 2);
270 hbox1
= gtk_hbox_new (FALSE
, 8);
271 gtk_widget_show (hbox1
);
272 gtk_box_pack_start (GTK_BOX (vbox1
), hbox1
, FALSE
, TRUE
, 0);
274 hdr_label
= gtk_label_new (_("Header name"));
275 gtk_widget_show (hdr_label
);
276 gtk_box_pack_start (GTK_BOX (hbox1
), hdr_label
, FALSE
, FALSE
, 0);
278 #if !GTK_CHECK_VERSION(2, 24, 0)
279 hdr_combo
= gtk_combo_box_entry_new_text();
281 hdr_combo
= gtk_combo_box_text_new_with_entry();
283 for(i
=0; i
< 9 ; i
++)
284 #if !GTK_CHECK_VERSION(2, 24, 0)
285 gtk_combo_box_append_text(GTK_COMBO_BOX (hdr_combo
),
287 gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT (hdr_combo
),
289 (*defaults
[i
] == '-') ? defaults
[i
]+1 : defaults
[i
]);
290 gtk_combo_box_set_active(GTK_COMBO_BOX(hdr_combo
), 0);
291 gtk_widget_show (hdr_combo
);
292 gtk_box_pack_start (GTK_BOX (hbox1
), hdr_combo
, TRUE
, TRUE
, 0);
293 gtk_widget_set_size_request (hdr_combo
, 150, -1);
295 list_view_hbox
= gtk_hbox_new (FALSE
, 10);
296 gtk_widget_show (list_view_hbox
);
297 gtk_box_pack_start (GTK_BOX (vbox1
), list_view_hbox
, TRUE
, TRUE
, 0);
299 /* display headers list */
301 list_view_hbox1
= gtk_hbox_new (FALSE
, 8);
302 gtk_widget_show (list_view_hbox1
);
303 gtk_box_pack_start (GTK_BOX (list_view_hbox
), list_view_hbox1
, TRUE
, TRUE
, 0);
305 list_view_scrolledwin
= gtk_scrolled_window_new (NULL
, NULL
);
306 gtk_widget_set_size_request (list_view_scrolledwin
, 200, 210);
307 gtk_widget_show (list_view_scrolledwin
);
308 gtk_box_pack_start (GTK_BOX (list_view_hbox1
), list_view_scrolledwin
,
310 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (list_view_scrolledwin
),
311 GTK_POLICY_AUTOMATIC
,
312 GTK_POLICY_AUTOMATIC
);
313 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(list_view_scrolledwin
),
316 headers_list_view
= prefs_display_header_list_view_create
317 (_("Displayed Headers"));
318 gtk_widget_show (headers_list_view
);
319 gtk_container_add(GTK_CONTAINER(list_view_scrolledwin
), headers_list_view
);
320 gtk_tree_view_set_reorderable(GTK_TREE_VIEW(headers_list_view
), TRUE
);
322 g_signal_connect(G_OBJECT(headers_list_view
), "drag_end",
323 G_CALLBACK(drag_end
),
326 /* connect rows change for this list view's model */
327 g_signal_connect(G_OBJECT(gtk_tree_view_get_model(GTK_TREE_VIEW(headers_list_view
))),
329 G_CALLBACK(headers_list_model_rows_reordered
),
332 btn_vbox
= gtk_vbox_new (FALSE
, 8);
333 gtk_widget_show (btn_vbox
);
334 gtk_box_pack_start (GTK_BOX (list_view_hbox1
), btn_vbox
, FALSE
, FALSE
, 0);
336 reg_btn
= gtk_button_new_from_stock (GTK_STOCK_ADD
);
337 gtk_widget_show (reg_btn
);
338 gtk_box_pack_start (GTK_BOX (btn_vbox
), reg_btn
, FALSE
, TRUE
, 0);
339 g_signal_connect (G_OBJECT (reg_btn
), "clicked",
340 G_CALLBACK (prefs_display_header_register_cb
),
341 GINT_TO_POINTER(FALSE
));
342 del_btn
= gtk_button_new_from_stock (GTK_STOCK_REMOVE
);
343 gtk_widget_show (del_btn
);
344 gtk_box_pack_start (GTK_BOX (btn_vbox
), del_btn
, FALSE
, TRUE
, 0);
345 g_signal_connect (G_OBJECT (del_btn
), "clicked",
346 G_CALLBACK (prefs_display_header_delete_cb
),
349 up_btn
= gtk_button_new_from_stock (GTK_STOCK_GO_UP
);
350 gtk_widget_show (up_btn
);
351 gtk_box_pack_start (GTK_BOX (btn_vbox
), up_btn
, FALSE
, FALSE
, 0);
352 g_signal_connect (G_OBJECT (up_btn
), "clicked",
353 G_CALLBACK (prefs_display_header_up
), NULL
);
355 down_btn
= gtk_button_new_from_stock (GTK_STOCK_GO_DOWN
);
356 gtk_widget_show (down_btn
);
357 gtk_box_pack_start (GTK_BOX (btn_vbox
), down_btn
, FALSE
, FALSE
, 0);
358 g_signal_connect (G_OBJECT (down_btn
), "clicked",
359 G_CALLBACK (prefs_display_header_down
), NULL
);
361 /* hidden headers list */
363 list_view_hbox2
= gtk_hbox_new (FALSE
, 8);
364 gtk_widget_show (list_view_hbox2
);
365 gtk_box_pack_start (GTK_BOX (list_view_hbox
), list_view_hbox2
, TRUE
, TRUE
, 0);
367 list_view_scrolledwin
= gtk_scrolled_window_new (NULL
, NULL
);
368 gtk_widget_set_size_request (list_view_scrolledwin
, 200, 210);
369 gtk_widget_show (list_view_scrolledwin
);
370 gtk_box_pack_start (GTK_BOX (list_view_hbox2
), list_view_scrolledwin
,
372 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (list_view_scrolledwin
),
373 GTK_POLICY_AUTOMATIC
,
374 GTK_POLICY_AUTOMATIC
);
375 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(list_view_scrolledwin
),
378 hidden_headers_list_view
= prefs_display_header_list_view_create
379 (_("Hidden headers"));
380 gtk_widget_show (hidden_headers_list_view
);
381 gtk_container_add (GTK_CONTAINER (list_view_scrolledwin
),
382 hidden_headers_list_view
);
384 btn_vbox
= gtk_vbox_new (FALSE
, 8);
385 gtk_widget_show (btn_vbox
);
386 gtk_box_pack_start (GTK_BOX (list_view_hbox2
), btn_vbox
, FALSE
, FALSE
, 0);
388 reg_btn
= gtk_button_new_from_stock (GTK_STOCK_ADD
);
389 gtk_widget_show (reg_btn
);
390 gtk_box_pack_start (GTK_BOX (btn_vbox
), reg_btn
, FALSE
, TRUE
, 0);
391 g_signal_connect (G_OBJECT (reg_btn
), "clicked",
393 (prefs_display_header_register_cb
),
394 GINT_TO_POINTER(TRUE
));
395 del_btn
= gtk_button_new_from_stock (GTK_STOCK_DELETE
);
396 gtk_widget_show (del_btn
);
397 gtk_box_pack_start (GTK_BOX (btn_vbox
), del_btn
, FALSE
, TRUE
, 0);
398 g_signal_connect (G_OBJECT (del_btn
), "clicked",
399 G_CALLBACK (prefs_display_header_delete_cb
),
400 hidden_headers_list_view
);
404 PACK_CHECK_BUTTON (vbox
, checkbtn_other_headers
,
405 _("Show all unspecified headers"));
406 SET_TOGGLE_SENSITIVITY (checkbtn_other_headers
, list_view_hbox2
);
408 gtk_widget_show_all(window
);
410 dispheader
.window
= window
;
411 dispheader
.ok_btn
= ok_btn
;
412 dispheader
.cancel_btn
= cancel_btn
;
414 dispheader
.hdr_combo
= hdr_combo
;
416 dispheader
.headers_list_view
= headers_list_view
;
417 dispheader
.hidden_headers_list_view
= hidden_headers_list_view
;
419 dispheader
.other_headers
= checkbtn_other_headers
;
422 void prefs_display_header_read_config(void)
426 gchar buf
[PREFSBUFSIZE
];
427 DisplayHeaderProp
*dp
;
429 debug_print("Reading configuration for displaying headers...\n");
431 rcpath
= g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S
,
432 DISPLAY_HEADER_RC
, NULL
);
433 if ((fp
= g_fopen(rcpath
, "rb")) == NULL
) {
434 if (ENOENT
!= errno
) FILE_OP_ERROR(rcpath
, "fopen");
436 prefs_common
.disphdr_list
= NULL
;
437 prefs_display_header_set_default();
442 /* remove all previous headers list */
443 while (prefs_common
.disphdr_list
!= NULL
) {
444 dp
= (DisplayHeaderProp
*)prefs_common
.disphdr_list
->data
;
445 display_header_prop_free(dp
);
446 prefs_common
.disphdr_list
=
447 g_slist_remove(prefs_common
.disphdr_list
, dp
);
450 while (fgets(buf
, sizeof(buf
), fp
) != NULL
) {
451 g_strdelimit(buf
, "\r\n", '\0');
452 dp
= display_header_prop_read_str(buf
);
454 prefs_common
.disphdr_list
=
455 g_slist_append(prefs_common
.disphdr_list
, dp
);
461 static void prefs_display_header_write_config(void)
467 debug_print("Writing configuration for displaying headers...\n");
469 rcpath
= g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S
,
470 DISPLAY_HEADER_RC
, NULL
);
472 if ((pfile
= prefs_write_open(rcpath
)) == NULL
) {
473 g_warning("failed to write configuration to file");
478 for (cur
= prefs_common
.disphdr_list
; cur
!= NULL
;
480 DisplayHeaderProp
*dp
= (DisplayHeaderProp
*)cur
->data
;
483 dpstr
= display_header_prop_get_str(dp
);
484 if (fputs(dpstr
, pfile
->fp
) == EOF
||
485 fputc('\n', pfile
->fp
) == EOF
) {
486 FILE_OP_ERROR(rcpath
, "fputs || fputc");
487 prefs_file_close_revert(pfile
);
497 if (prefs_file_close(pfile
) < 0) {
498 g_warning("failed to write configuration to file");
503 static void prefs_display_header_set_dialog(void)
505 GtkTreeView
*list_view
= GTK_TREE_VIEW(dispheader
.headers_list_view
);
506 GtkTreeView
*hidden_list_view
= GTK_TREE_VIEW(dispheader
.hidden_headers_list_view
);
508 GtkTreeModel
*model_list
, *model_hidden
;
510 model_list
= gtk_tree_view_get_model(list_view
);
511 model_hidden
= gtk_tree_view_get_model(hidden_list_view
);
513 gtk_list_store_clear(GTK_LIST_STORE(model_list
));
514 gtk_list_store_clear(GTK_LIST_STORE(model_hidden
));
516 for (cur
= prefs_common
.disphdr_list
; cur
!= NULL
;
518 DisplayHeaderProp
*dp
= (DisplayHeaderProp
*)cur
->data
;
521 prefs_display_header_insert_header(GTK_LIST_STORE
522 (model_hidden
), dp
->name
, dp
);
524 prefs_display_header_insert_header(GTK_LIST_STORE
525 (model_list
), dp
->name
, dp
);
528 gtk_toggle_button_set_active
529 (GTK_TOGGLE_BUTTON(dispheader
.other_headers
),
530 prefs_common
.show_other_header
);
533 static void prefs_display_header_set_list(void)
536 DisplayHeaderProp
*dp
;
540 g_slist_free(prefs_common
.disphdr_list
);
541 prefs_common
.disphdr_list
= NULL
;
543 model
= gtk_tree_view_get_model(GTK_TREE_VIEW(dispheader
.headers_list_view
));
544 while (gtk_tree_model_iter_nth_child(model
, &iter
, NULL
, row
)) {
545 gtk_tree_model_get(model
, &iter
, PREFS_HDR_DATA
, &dp
, -1);
547 prefs_common
.disphdr_list
=
548 g_slist_append(prefs_common
.disphdr_list
, dp
);
552 model
= gtk_tree_view_get_model
553 (GTK_TREE_VIEW(dispheader
.hidden_headers_list_view
));
555 while (gtk_tree_model_iter_nth_child(model
, &iter
, NULL
, row
)) {
556 gtk_tree_model_get(model
, &iter
, PREFS_HDR_DATA
, &dp
, -1);
558 prefs_common
.disphdr_list
=
559 g_slist_append(prefs_common
.disphdr_list
, dp
);
564 static gint
prefs_display_header_find_header(GtkTreeView
*list_view
,
568 DisplayHeaderProp
*dp
;
572 model
= gtk_tree_view_get_model(list_view
);
573 while (gtk_tree_model_iter_nth_child(model
, &iter
, NULL
, row
)) {
574 gtk_tree_model_get(model
, &iter
, PREFS_HDR_DATA
, &dp
, -1);
575 if (dp
&& g_ascii_strcasecmp(dp
->name
, header
) == 0)
583 static void prefs_display_header_list_view_set_row(gboolean hidden
)
585 GtkTreeView
*list_view
;
586 DisplayHeaderProp
*dp
;
590 #if !GTK_CHECK_VERSION(2, 24, 0)
591 entry_text
= gtk_combo_box_get_active_text(GTK_COMBO_BOX(dispheader
.hdr_combo
));
593 entry_text
= gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(dispheader
.hdr_combo
));
596 entry_text
= gtk_editable_get_chars(
597 GTK_EDITABLE(gtk_bin_get_child(GTK_BIN(dispheader
.hdr_combo
))),0,-1);
598 if (!entry_text
|| entry_text
[0] == '\0') {
599 alertpanel_error(_("Header name is not set."));
604 list_view
= GTK_TREE_VIEW(dispheader
.hidden_headers_list_view
);
606 list_view
= GTK_TREE_VIEW(dispheader
.headers_list_view
);
608 if (prefs_display_header_find_header(list_view
, entry_text
) != -1) {
609 alertpanel_error(_("This header is already in the list."));
613 dp
= g_new0(DisplayHeaderProp
, 1);
615 dp
->name
= g_strdup(entry_text
);
618 model
= gtk_tree_view_get_model(list_view
);
619 prefs_display_header_insert_header(GTK_LIST_STORE(model
),
622 prefs_display_header_set_list();
627 static void prefs_display_header_register_cb(GtkButton
*btn
,
628 gpointer hidden_data
)
630 prefs_display_header_list_view_set_row(GPOINTER_TO_INT(hidden_data
));
633 static void prefs_display_header_delete_cb(GtkButton
*btn
, gpointer list_view_data
)
635 GtkTreeView
*list_view
= GTK_TREE_VIEW(list_view_data
);
636 DisplayHeaderProp
*dp
;
637 GtkListStore
*store
= GTK_LIST_STORE(gtk_tree_view_get_model(list_view
));
638 GtkTreeSelection
*selection
= gtk_tree_view_get_selection(list_view
);
641 if (!gtk_tree_selection_get_selected(selection
, NULL
, &iter
))
644 gtk_tree_model_get(GTK_TREE_MODEL(store
), &iter
, PREFS_HDR_DATA
, &dp
, -1);
648 prefs_common
.disphdr_list
=
649 g_slist_remove(prefs_common
.disphdr_list
, dp
);
650 display_header_prop_free(dp
);
651 gtk_list_store_remove(store
, &iter
);
654 static void prefs_display_header_up(void)
656 GtkTreePath
*prev
, *sel
, *try;
658 GtkListStore
*store
= NULL
;
659 GtkTreeModel
*model
= NULL
;
662 if (!gtk_tree_selection_get_selected
663 (gtk_tree_view_get_selection
664 (GTK_TREE_VIEW(dispheader
.headers_list_view
)),
668 store
= (GtkListStore
*)model
;
669 sel
= gtk_tree_model_get_path(GTK_TREE_MODEL(store
), &isel
);
673 /* no move if we're at row 0... */
674 try = gtk_tree_path_copy(sel
);
675 if (!gtk_tree_path_prev(try)) {
676 gtk_tree_path_free(try);
677 gtk_tree_path_free(sel
);
682 gtk_tree_model_get_iter(GTK_TREE_MODEL(store
),
684 gtk_list_store_swap(store
, &iprev
, &isel
);
686 gtk_tree_path_free(sel
);
687 gtk_tree_path_free(prev
);
690 static void prefs_display_header_down(void)
692 GtkListStore
*store
= NULL
;
693 GtkTreeModel
*model
= NULL
;
694 GtkTreeIter next
, sel
;
697 if (!gtk_tree_selection_get_selected
698 (gtk_tree_view_get_selection
699 (GTK_TREE_VIEW(dispheader
.headers_list_view
)),
703 store
= (GtkListStore
*)model
;
704 try = gtk_tree_model_get_path(GTK_TREE_MODEL(store
), &sel
);
709 if (gtk_tree_model_iter_next(GTK_TREE_MODEL(store
), &next
))
710 gtk_list_store_swap(store
, &next
, &sel
);
712 gtk_tree_path_free(try);
715 static gboolean
prefs_display_header_key_pressed(GtkWidget
*widget
,
719 if (event
&& event
->keyval
== GDK_KEY_Escape
)
720 prefs_display_header_cancel();
724 static void prefs_display_header_ok(void)
726 prefs_common
.show_other_header
=
727 gtk_toggle_button_get_active
728 (GTK_TOGGLE_BUTTON(dispheader
.other_headers
));
729 prefs_display_header_write_config();
730 gtk_widget_hide(dispheader
.window
);
731 gtk_window_set_modal(GTK_WINDOW(dispheader
.window
), FALSE
);
734 static void prefs_display_header_cancel(void)
736 prefs_display_header_read_config();
737 gtk_widget_hide(dispheader
.window
);
738 gtk_window_set_modal(GTK_WINDOW(dispheader
.window
), FALSE
);
741 static gint
prefs_display_header_deleted(GtkWidget
*widget
, GdkEventAny
*event
,
744 prefs_display_header_cancel();
748 static GtkListStore
*prefs_display_header_create_store(void)
750 return gtk_list_store_new(N_PREFS_HDR_COLUMNS
,
756 static void prefs_display_header_insert_header(GtkListStore
*store
,
758 DisplayHeaderProp
*dp
)
763 gtk_list_store_append(store
, &iter
);
764 gtk_list_store_set(store
, &iter
,
771 static GtkWidget
*prefs_display_header_list_view_create(const gchar
*name
)
773 GtkWidget
*list_view
;
774 GtkTreeSelection
*selector
;
777 model
= GTK_TREE_MODEL(prefs_display_header_create_store());
778 list_view
= gtk_tree_view_new_with_model(model
);
779 g_object_unref(G_OBJECT(model
));
781 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(list_view
),
782 prefs_common
.use_stripes_everywhere
);
784 selector
= gtk_tree_view_get_selection(GTK_TREE_VIEW(list_view
));
785 gtk_tree_selection_set_mode(selector
, GTK_SELECTION_BROWSE
);
787 prefs_filtering_create_list_view_columns(GTK_WIDGET(list_view
), name
);
792 static void prefs_filtering_create_list_view_columns(GtkWidget
*list_view
,
795 GtkTreeViewColumn
*column
;
796 GtkCellRenderer
*renderer
;
798 renderer
= gtk_cell_renderer_text_new();
799 column
= gtk_tree_view_column_new_with_attributes
800 (name
, renderer
, "text", PREFS_HDR_HEADER
, NULL
);
801 gtk_tree_view_append_column(GTK_TREE_VIEW(list_view
), column
);
805 *\brief Called as a result of a gtk_list_store_swap()
807 static void headers_list_model_rows_reordered(GtkTreeModel
*model
,
811 GtkTreeView
*list_view
)
813 prefs_display_header_set_list();
817 *\brief Called as a result of a drag & drop
819 static void drag_end(GtkTreeView
*list_view
,
820 GdkDragContext
*context
,
823 prefs_display_header_set_list();