2 * Claws Mail -- a GTK based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2024 the Claws Mail team and 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 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/>.
21 #include "claws-features.h"
27 #include <glib/gi18n.h>
29 #include <gdk/gdkkeysyms.h>
35 #include "prefs_gtk.h"
36 #include "prefs_display_header.h"
37 #include "prefs_common.h"
38 #include "manage_window.h"
39 #include "alertpanel.h"
40 #include "displayheader.h"
43 #include "file-utils.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
[] =
130 "-Content-Transfer-Encoding",
138 static gchar
*defaults
[] =
160 "-Content-Transfer-Encoding",
168 static void prefs_display_header_set_default(void)
171 DisplayHeaderProp
*dp
;
173 for(i
= 0; i
< sizeof(defaults
) / sizeof(defaults
[0]); i
++) {
174 dp
= display_header_prop_read_str(defaults
[i
]);
175 prefs_common
.disphdr_list
=
176 g_slist_append(prefs_common
.disphdr_list
, dp
);
180 void prefs_display_header_open(void)
182 if (prefs_rc_is_readonly(DISPLAY_HEADER_RC
))
185 if (!dispheader
.window
) {
186 prefs_display_header_create();
189 manage_window_set_transient(GTK_WINDOW(dispheader
.window
));
190 gtk_widget_grab_focus(dispheader
.ok_btn
);
192 prefs_display_header_set_dialog();
194 gtk_widget_show(dispheader
.window
);
195 gtk_window_set_modal(GTK_WINDOW(dispheader
.window
), TRUE
);
198 static void prefs_display_header_create(void)
204 GtkWidget
*cancel_btn
;
205 GtkWidget
*confirm_area
;
210 GtkWidget
*hdr_label
;
211 GtkWidget
*hdr_combo
;
219 GtkWidget
*list_view_hbox
;
220 GtkWidget
*list_view_hbox1
;
221 GtkWidget
*list_view_hbox2
;
222 GtkWidget
*list_view_scrolledwin
;
223 GtkWidget
*headers_list_view
;
224 GtkWidget
*hidden_headers_list_view
;
226 GtkWidget
*checkbtn_other_headers
;
229 debug_print("Creating display header setting window...\n");
231 window
= gtkut_window_new(GTK_WINDOW_TOPLEVEL
, "prefs_display_header");
232 gtk_container_set_border_width (GTK_CONTAINER (window
), 8);
233 gtk_window_set_position (GTK_WINDOW (window
), GTK_WIN_POS_CENTER
);
234 gtk_window_set_resizable(GTK_WINDOW (window
), TRUE
);
235 gtk_window_set_type_hint(GTK_WINDOW(window
), GDK_WINDOW_TYPE_HINT_DIALOG
);
237 vbox
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, 6);
238 gtk_widget_show (vbox
);
239 gtk_container_add (GTK_CONTAINER (window
), vbox
);
241 btn_hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 8);
242 gtk_widget_show (btn_hbox
);
243 gtk_box_pack_end (GTK_BOX (vbox
), btn_hbox
, FALSE
, FALSE
, 0);
245 gtkut_stock_button_set_create(&confirm_area
, &cancel_btn
, NULL
, _("_Cancel"),
246 &ok_btn
, NULL
, _("_OK"), NULL
, NULL
, NULL
);
247 gtk_widget_show (confirm_area
);
248 gtk_box_pack_end (GTK_BOX(btn_hbox
), confirm_area
, FALSE
, FALSE
, 0);
249 gtk_widget_grab_default (ok_btn
);
251 gtk_window_set_title (GTK_WINDOW(window
),
252 _("Displayed header configuration"));
253 MANAGE_WINDOW_SIGNALS_CONNECT(window
);
254 g_signal_connect (G_OBJECT(window
), "delete_event",
255 G_CALLBACK(prefs_display_header_deleted
),
257 g_signal_connect (G_OBJECT(window
), "key_press_event",
258 G_CALLBACK(prefs_display_header_key_pressed
),
260 g_signal_connect (G_OBJECT(ok_btn
), "clicked",
261 G_CALLBACK(prefs_display_header_ok
),
263 g_signal_connect (G_OBJECT(cancel_btn
), "clicked",
264 G_CALLBACK(prefs_display_header_cancel
),
267 vbox1
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, VSPACING
);
268 gtk_widget_show (vbox1
);
269 gtk_box_pack_start (GTK_BOX (vbox
), vbox1
, TRUE
, TRUE
, 0);
270 gtk_container_set_border_width (GTK_CONTAINER (vbox1
), 2);
272 hbox1
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 8);
273 gtk_widget_show (hbox1
);
274 gtk_box_pack_start (GTK_BOX (vbox1
), hbox1
, FALSE
, TRUE
, 0);
276 hdr_label
= gtk_label_new (_("Header name"));
277 gtk_widget_show (hdr_label
);
278 gtk_box_pack_start (GTK_BOX (hbox1
), hdr_label
, FALSE
, FALSE
, 0);
280 hdr_combo
= gtk_combo_box_text_new_with_entry();
281 for(i
=0; i
< 9 ; i
++)
282 gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT (hdr_combo
),
283 (*defaults
[i
] == '-') ? defaults
[i
]+1 : defaults
[i
]);
284 gtk_combo_box_set_active(GTK_COMBO_BOX(hdr_combo
), 0);
285 gtk_widget_show (hdr_combo
);
286 gtk_box_pack_start (GTK_BOX (hbox1
), hdr_combo
, TRUE
, TRUE
, 0);
287 gtk_widget_set_size_request (hdr_combo
, 150, -1);
289 list_view_hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 10);
290 gtk_widget_show (list_view_hbox
);
291 gtk_box_pack_start (GTK_BOX (vbox1
), list_view_hbox
, TRUE
, TRUE
, 0);
293 /* hidden headers list */
295 list_view_hbox2
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 8);
296 gtk_widget_show (list_view_hbox2
);
297 gtk_box_pack_start (GTK_BOX (list_view_hbox
), list_view_hbox2
, TRUE
, TRUE
, 0);
299 list_view_scrolledwin
= gtk_scrolled_window_new (NULL
, NULL
);
300 gtk_widget_set_size_request (list_view_scrolledwin
, 200, 210);
301 gtk_widget_show (list_view_scrolledwin
);
302 gtk_box_pack_start (GTK_BOX (list_view_hbox2
), list_view_scrolledwin
,
304 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (list_view_scrolledwin
),
305 GTK_POLICY_AUTOMATIC
,
306 GTK_POLICY_AUTOMATIC
);
307 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(list_view_scrolledwin
),
310 hidden_headers_list_view
= prefs_display_header_list_view_create
311 (_("Hidden headers"));
312 gtk_widget_show (hidden_headers_list_view
);
313 gtk_container_add (GTK_CONTAINER (list_view_scrolledwin
),
314 hidden_headers_list_view
);
316 btn_vbox
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, 8);
317 gtk_widget_show (btn_vbox
);
318 gtk_box_pack_start (GTK_BOX (list_view_hbox2
), btn_vbox
, FALSE
, FALSE
, 0);
320 reg_btn
= gtkut_stock_button("list-add", _("_Add"));
321 gtk_widget_show (reg_btn
);
322 gtk_box_pack_start (GTK_BOX (btn_vbox
), reg_btn
, FALSE
, TRUE
, 0);
323 g_signal_connect (G_OBJECT (reg_btn
), "clicked",
325 (prefs_display_header_register_cb
),
326 GINT_TO_POINTER(TRUE
));
327 del_btn
= gtkut_stock_button("edit-delete", _("_Delete"));
328 gtk_widget_show (del_btn
);
329 gtk_box_pack_start (GTK_BOX (btn_vbox
), del_btn
, FALSE
, TRUE
, 0);
330 g_signal_connect (G_OBJECT (del_btn
), "clicked",
331 G_CALLBACK (prefs_display_header_delete_cb
),
332 hidden_headers_list_view
);
334 /* display headers list */
336 list_view_hbox1
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 8);
337 gtk_widget_show (list_view_hbox1
);
338 gtk_box_pack_start (GTK_BOX (list_view_hbox
), list_view_hbox1
, TRUE
, TRUE
, 0);
340 list_view_scrolledwin
= gtk_scrolled_window_new (NULL
, NULL
);
341 gtk_widget_set_size_request (list_view_scrolledwin
, 200, 210);
342 gtk_widget_show (list_view_scrolledwin
);
343 gtk_box_pack_start (GTK_BOX (list_view_hbox1
), list_view_scrolledwin
,
345 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (list_view_scrolledwin
),
346 GTK_POLICY_AUTOMATIC
,
347 GTK_POLICY_AUTOMATIC
);
348 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(list_view_scrolledwin
),
351 headers_list_view
= prefs_display_header_list_view_create
352 (_("Displayed Headers"));
353 gtk_widget_show (headers_list_view
);
354 gtk_container_add(GTK_CONTAINER(list_view_scrolledwin
), headers_list_view
);
355 gtk_tree_view_set_reorderable(GTK_TREE_VIEW(headers_list_view
), TRUE
);
357 g_signal_connect(G_OBJECT(headers_list_view
), "drag_end",
358 G_CALLBACK(drag_end
),
361 /* connect rows change for this list view's model */
362 g_signal_connect(G_OBJECT(gtk_tree_view_get_model(GTK_TREE_VIEW(headers_list_view
))),
364 G_CALLBACK(headers_list_model_rows_reordered
),
367 btn_vbox
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, 8);
368 gtk_widget_show (btn_vbox
);
369 gtk_box_pack_start (GTK_BOX (list_view_hbox1
), btn_vbox
, FALSE
, FALSE
, 0);
371 reg_btn
= gtkut_stock_button("list-add", _("_Add"));
372 gtk_widget_show (reg_btn
);
373 gtk_box_pack_start (GTK_BOX (btn_vbox
), reg_btn
, FALSE
, TRUE
, 0);
374 g_signal_connect (G_OBJECT (reg_btn
), "clicked",
375 G_CALLBACK (prefs_display_header_register_cb
),
376 GINT_TO_POINTER(FALSE
));
377 del_btn
= gtkut_stock_button("list-remove", _("_Remove"));
378 gtk_widget_show (del_btn
);
379 gtk_box_pack_start (GTK_BOX (btn_vbox
), del_btn
, FALSE
, TRUE
, 0);
380 g_signal_connect (G_OBJECT (del_btn
), "clicked",
381 G_CALLBACK (prefs_display_header_delete_cb
),
384 up_btn
= gtkut_stock_button("go-up", _("_Up"));
385 gtk_widget_show (up_btn
);
386 gtk_box_pack_start (GTK_BOX (btn_vbox
), up_btn
, FALSE
, FALSE
, 0);
387 g_signal_connect (G_OBJECT (up_btn
), "clicked",
388 G_CALLBACK (prefs_display_header_up
), NULL
);
390 down_btn
= gtkut_stock_button("go-down", _("_Down"));
391 gtk_widget_show (down_btn
);
392 gtk_box_pack_start (GTK_BOX (btn_vbox
), down_btn
, FALSE
, FALSE
, 0);
393 g_signal_connect (G_OBJECT (down_btn
), "clicked",
394 G_CALLBACK (prefs_display_header_down
), NULL
);
396 PACK_CHECK_BUTTON (vbox
, checkbtn_other_headers
,
397 _("Show all unspecified headers"));
398 SET_TOGGLE_SENSITIVITY (checkbtn_other_headers
, list_view_hbox2
);
400 gtk_widget_show_all(window
);
402 dispheader
.window
= window
;
403 dispheader
.ok_btn
= ok_btn
;
404 dispheader
.cancel_btn
= cancel_btn
;
406 dispheader
.hdr_combo
= hdr_combo
;
408 dispheader
.headers_list_view
= headers_list_view
;
409 dispheader
.hidden_headers_list_view
= hidden_headers_list_view
;
411 dispheader
.other_headers
= checkbtn_other_headers
;
414 void prefs_display_header_read_config(void)
418 gchar buf
[PREFSBUFSIZE
];
419 DisplayHeaderProp
*dp
;
421 debug_print("Reading configuration for displaying headers...\n");
423 rcpath
= g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S
,
424 DISPLAY_HEADER_RC
, NULL
);
425 if ((fp
= claws_fopen(rcpath
, "rb")) == NULL
) {
426 if (ENOENT
!= errno
) FILE_OP_ERROR(rcpath
, "claws_fopen");
428 prefs_common
.disphdr_list
= NULL
;
429 prefs_display_header_set_default();
434 /* remove all previous headers list */
435 while (prefs_common
.disphdr_list
!= NULL
) {
436 dp
= (DisplayHeaderProp
*)prefs_common
.disphdr_list
->data
;
437 prefs_common
.disphdr_list
=
438 g_slist_remove(prefs_common
.disphdr_list
, dp
);
439 display_header_prop_free(dp
);
442 while (claws_fgets(buf
, sizeof(buf
), fp
) != NULL
) {
443 g_strdelimit(buf
, "\r\n", '\0');
444 dp
= display_header_prop_read_str(buf
);
446 prefs_common
.disphdr_list
=
447 g_slist_append(prefs_common
.disphdr_list
, dp
);
453 static void prefs_display_header_write_config(void)
459 debug_print("Writing configuration for displaying headers...\n");
461 rcpath
= g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S
,
462 DISPLAY_HEADER_RC
, NULL
);
464 if ((pfile
= prefs_write_open(rcpath
)) == NULL
) {
465 g_warning("failed to write configuration to file");
470 for (cur
= prefs_common
.disphdr_list
; cur
!= NULL
;
472 DisplayHeaderProp
*dp
= (DisplayHeaderProp
*)cur
->data
;
475 dpstr
= display_header_prop_get_str(dp
);
476 if (claws_fputs(dpstr
, pfile
->fp
) == EOF
||
477 claws_fputc('\n', pfile
->fp
) == EOF
) {
478 FILE_OP_ERROR(rcpath
, "claws_fputs || claws_fputc");
479 prefs_file_close_revert(pfile
);
489 if (prefs_file_close(pfile
) < 0) {
490 g_warning("failed to write configuration to file");
495 static void prefs_display_header_set_dialog(void)
497 GtkTreeView
*list_view
= GTK_TREE_VIEW(dispheader
.headers_list_view
);
498 GtkTreeView
*hidden_list_view
= GTK_TREE_VIEW(dispheader
.hidden_headers_list_view
);
500 GtkTreeModel
*model_list
, *model_hidden
;
502 model_list
= gtk_tree_view_get_model(list_view
);
503 model_hidden
= gtk_tree_view_get_model(hidden_list_view
);
505 gtk_list_store_clear(GTK_LIST_STORE(model_list
));
506 gtk_list_store_clear(GTK_LIST_STORE(model_hidden
));
508 for (cur
= prefs_common
.disphdr_list
; cur
!= NULL
;
510 DisplayHeaderProp
*dp
= (DisplayHeaderProp
*)cur
->data
;
513 prefs_display_header_insert_header(GTK_LIST_STORE
514 (model_hidden
), dp
->name
, dp
);
516 prefs_display_header_insert_header(GTK_LIST_STORE
517 (model_list
), dp
->name
, dp
);
520 gtk_toggle_button_set_active
521 (GTK_TOGGLE_BUTTON(dispheader
.other_headers
),
522 prefs_common
.show_other_header
);
525 static void prefs_display_header_set_list(void)
528 DisplayHeaderProp
*dp
;
532 g_slist_free(prefs_common
.disphdr_list
);
533 prefs_common
.disphdr_list
= NULL
;
535 model
= gtk_tree_view_get_model(GTK_TREE_VIEW(dispheader
.headers_list_view
));
536 while (gtk_tree_model_iter_nth_child(model
, &iter
, NULL
, row
)) {
537 gtk_tree_model_get(model
, &iter
, PREFS_HDR_DATA
, &dp
, -1);
539 prefs_common
.disphdr_list
=
540 g_slist_append(prefs_common
.disphdr_list
, dp
);
544 model
= gtk_tree_view_get_model
545 (GTK_TREE_VIEW(dispheader
.hidden_headers_list_view
));
547 while (gtk_tree_model_iter_nth_child(model
, &iter
, NULL
, row
)) {
548 gtk_tree_model_get(model
, &iter
, PREFS_HDR_DATA
, &dp
, -1);
550 prefs_common
.disphdr_list
=
551 g_slist_append(prefs_common
.disphdr_list
, dp
);
556 static gint
prefs_display_header_find_header(GtkTreeView
*list_view
,
560 DisplayHeaderProp
*dp
;
564 model
= gtk_tree_view_get_model(list_view
);
565 while (gtk_tree_model_iter_nth_child(model
, &iter
, NULL
, row
)) {
566 gtk_tree_model_get(model
, &iter
, PREFS_HDR_DATA
, &dp
, -1);
567 if (dp
&& g_ascii_strcasecmp(dp
->name
, header
) == 0)
575 static void prefs_display_header_list_view_set_row(gboolean hidden
)
577 GtkTreeView
*list_view
;
578 DisplayHeaderProp
*dp
;
582 entry_text
= gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(dispheader
.hdr_combo
));
584 entry_text
= gtk_editable_get_chars(
585 GTK_EDITABLE(gtk_bin_get_child(GTK_BIN(dispheader
.hdr_combo
))),0,-1);
586 if (!entry_text
|| entry_text
[0] == '\0') {
587 alertpanel_error(_("Header name is not set."));
592 list_view
= GTK_TREE_VIEW(dispheader
.hidden_headers_list_view
);
594 list_view
= GTK_TREE_VIEW(dispheader
.headers_list_view
);
596 if (prefs_display_header_find_header(list_view
, entry_text
) != -1) {
597 alertpanel_error(_("This header is already in the list."));
601 dp
= g_new0(DisplayHeaderProp
, 1);
603 dp
->name
= g_strdup(entry_text
);
606 model
= gtk_tree_view_get_model(list_view
);
607 prefs_display_header_insert_header(GTK_LIST_STORE(model
),
610 prefs_display_header_set_list();
615 static void prefs_display_header_register_cb(GtkButton
*btn
,
616 gpointer hidden_data
)
618 prefs_display_header_list_view_set_row(GPOINTER_TO_INT(hidden_data
));
621 static void prefs_display_header_delete_cb(GtkButton
*btn
, gpointer list_view_data
)
623 GtkTreeView
*list_view
= GTK_TREE_VIEW(list_view_data
);
624 DisplayHeaderProp
*dp
;
625 GtkListStore
*store
= GTK_LIST_STORE(gtk_tree_view_get_model(list_view
));
626 GtkTreeSelection
*selection
= gtk_tree_view_get_selection(list_view
);
629 if (!gtk_tree_selection_get_selected(selection
, NULL
, &iter
))
632 gtk_tree_model_get(GTK_TREE_MODEL(store
), &iter
, PREFS_HDR_DATA
, &dp
, -1);
636 prefs_common
.disphdr_list
=
637 g_slist_remove(prefs_common
.disphdr_list
, dp
);
638 display_header_prop_free(dp
);
639 gtk_list_store_remove(store
, &iter
);
642 static void prefs_display_header_up(void)
644 GtkTreePath
*prev
, *sel
, *try;
646 GtkListStore
*store
= NULL
;
647 GtkTreeModel
*model
= NULL
;
650 if (!gtk_tree_selection_get_selected
651 (gtk_tree_view_get_selection
652 (GTK_TREE_VIEW(dispheader
.headers_list_view
)),
656 store
= (GtkListStore
*)model
;
657 sel
= gtk_tree_model_get_path(GTK_TREE_MODEL(store
), &isel
);
661 /* no move if we're at row 0... */
662 try = gtk_tree_path_copy(sel
);
663 if (!gtk_tree_path_prev(try)) {
664 gtk_tree_path_free(try);
665 gtk_tree_path_free(sel
);
670 gtk_tree_model_get_iter(GTK_TREE_MODEL(store
),
672 gtk_list_store_swap(store
, &iprev
, &isel
);
674 gtk_tree_path_free(sel
);
675 gtk_tree_path_free(prev
);
678 static void prefs_display_header_down(void)
680 GtkListStore
*store
= NULL
;
681 GtkTreeModel
*model
= NULL
;
682 GtkTreeIter next
, sel
;
685 if (!gtk_tree_selection_get_selected
686 (gtk_tree_view_get_selection
687 (GTK_TREE_VIEW(dispheader
.headers_list_view
)),
691 store
= (GtkListStore
*)model
;
692 try = gtk_tree_model_get_path(GTK_TREE_MODEL(store
), &sel
);
697 if (gtk_tree_model_iter_next(GTK_TREE_MODEL(store
), &next
))
698 gtk_list_store_swap(store
, &next
, &sel
);
700 gtk_tree_path_free(try);
703 static gboolean
prefs_display_header_key_pressed(GtkWidget
*widget
,
707 if (event
&& event
->keyval
== GDK_KEY_Escape
)
708 prefs_display_header_cancel();
712 static void prefs_display_header_ok(void)
714 prefs_common
.show_other_header
=
715 gtk_toggle_button_get_active
716 (GTK_TOGGLE_BUTTON(dispheader
.other_headers
));
717 prefs_display_header_write_config();
718 gtk_widget_hide(dispheader
.window
);
719 gtk_window_set_modal(GTK_WINDOW(dispheader
.window
), FALSE
);
722 static void prefs_display_header_cancel(void)
724 prefs_display_header_read_config();
725 gtk_widget_hide(dispheader
.window
);
726 gtk_window_set_modal(GTK_WINDOW(dispheader
.window
), FALSE
);
729 static gint
prefs_display_header_deleted(GtkWidget
*widget
, GdkEventAny
*event
,
732 prefs_display_header_cancel();
736 static GtkListStore
*prefs_display_header_create_store(void)
738 return gtk_list_store_new(N_PREFS_HDR_COLUMNS
,
744 static void prefs_display_header_insert_header(GtkListStore
*store
,
746 DisplayHeaderProp
*dp
)
751 gtk_list_store_append(store
, &iter
);
752 gtk_list_store_set(store
, &iter
,
759 static GtkWidget
*prefs_display_header_list_view_create(const gchar
*name
)
761 GtkWidget
*list_view
;
762 GtkTreeSelection
*selector
;
765 model
= GTK_TREE_MODEL(prefs_display_header_create_store());
766 list_view
= gtk_tree_view_new_with_model(model
);
767 g_object_unref(G_OBJECT(model
));
769 selector
= gtk_tree_view_get_selection(GTK_TREE_VIEW(list_view
));
770 gtk_tree_selection_set_mode(selector
, GTK_SELECTION_BROWSE
);
772 prefs_filtering_create_list_view_columns(GTK_WIDGET(list_view
), name
);
777 static void prefs_filtering_create_list_view_columns(GtkWidget
*list_view
,
780 GtkTreeViewColumn
*column
;
781 GtkCellRenderer
*renderer
;
783 renderer
= gtk_cell_renderer_text_new();
784 column
= gtk_tree_view_column_new_with_attributes
785 (name
, renderer
, "text", PREFS_HDR_HEADER
, NULL
);
786 gtk_tree_view_append_column(GTK_TREE_VIEW(list_view
), column
);
790 *\brief Called as a result of a gtk_list_store_swap()
792 static void headers_list_model_rows_reordered(GtkTreeModel
*model
,
796 GtkTreeView
*list_view
)
798 prefs_display_header_set_list();
802 *\brief Called as a result of a drag & drop
804 static void drag_end(GtkTreeView
*list_view
,
805 GdkDragContext
*context
,
808 prefs_display_header_set_list();