2 * Claws Mail -- a GTK based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2022 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/>.
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"
44 #include "file-utils.h"
52 static struct DisplayHeader
{
56 GtkWidget
*cancel_btn
;
60 GtkWidget
*headers_list_view
;
61 GtkWidget
*hidden_headers_list_view
;
63 GtkWidget
*other_headers
;
66 /* widget creating functions */
67 static void prefs_display_header_create (void);
69 static void prefs_display_header_set_dialog (void);
70 static void prefs_display_header_set_list (void);
71 static void prefs_display_header_list_view_set_row (gboolean hidden
);
73 /* callback functions */
74 static void prefs_display_header_register_cb (GtkButton
*btn
,
75 gpointer hidden_data
);
76 static void prefs_display_header_delete_cb (GtkButton
*btn
,
77 gpointer list_view_data
);
78 static void prefs_display_header_up (void);
79 static void prefs_display_header_down (void);
81 static gboolean
prefs_display_header_key_pressed (GtkWidget
*widget
,
84 static void prefs_display_header_ok (void);
85 static void prefs_display_header_cancel (void);
86 static gint
prefs_display_header_deleted (GtkWidget
*widget
,
91 static GtkListStore
*prefs_display_header_create_store (void);
92 static void prefs_display_header_insert_header (GtkListStore
*store
,
94 DisplayHeaderProp
*dp
);
95 static GtkWidget
*prefs_display_header_list_view_create (const gchar
*name
);
96 static void prefs_filtering_create_list_view_columns (GtkWidget
*list_view
,
98 static void headers_list_model_rows_reordered (GtkTreeModel
*model
,
102 GtkTreeView
*list_view
);
104 static void drag_end (GtkTreeView
*list_view
,
105 GdkDragContext
*context
,
109 static gchar
*defaults
[] =
131 "-Content-Transfer-Encoding",
139 static gchar
*defaults
[] =
161 "-Content-Transfer-Encoding",
169 static void prefs_display_header_set_default(void)
172 DisplayHeaderProp
*dp
;
174 for(i
= 0; i
< sizeof(defaults
) / sizeof(defaults
[0]); i
++) {
175 dp
= display_header_prop_read_str(defaults
[i
]);
176 prefs_common
.disphdr_list
=
177 g_slist_append(prefs_common
.disphdr_list
, dp
);
181 void prefs_display_header_open(void)
183 if (prefs_rc_is_readonly(DISPLAY_HEADER_RC
))
186 if (!dispheader
.window
) {
187 prefs_display_header_create();
190 manage_window_set_transient(GTK_WINDOW(dispheader
.window
));
191 gtk_widget_grab_focus(dispheader
.ok_btn
);
193 prefs_display_header_set_dialog();
195 gtk_widget_show(dispheader
.window
);
196 gtk_window_set_modal(GTK_WINDOW(dispheader
.window
), TRUE
);
199 static void prefs_display_header_create(void)
205 GtkWidget
*cancel_btn
;
206 GtkWidget
*confirm_area
;
211 GtkWidget
*hdr_label
;
212 GtkWidget
*hdr_combo
;
220 GtkWidget
*list_view_hbox
;
221 GtkWidget
*list_view_hbox1
;
222 GtkWidget
*list_view_hbox2
;
223 GtkWidget
*list_view_scrolledwin
;
224 GtkWidget
*headers_list_view
;
225 GtkWidget
*hidden_headers_list_view
;
227 GtkWidget
*checkbtn_other_headers
;
230 debug_print("Creating display header setting window...\n");
232 window
= gtkut_window_new(GTK_WINDOW_TOPLEVEL
, "prefs_display_header");
233 gtk_container_set_border_width (GTK_CONTAINER (window
), 8);
234 gtk_window_set_position (GTK_WINDOW (window
), GTK_WIN_POS_CENTER
);
235 gtk_window_set_resizable(GTK_WINDOW (window
), TRUE
);
236 gtk_window_set_type_hint(GTK_WINDOW(window
), GDK_WINDOW_TYPE_HINT_DIALOG
);
238 vbox
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, 6);
239 gtk_widget_show (vbox
);
240 gtk_container_add (GTK_CONTAINER (window
), vbox
);
242 btn_hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 8);
243 gtk_widget_show (btn_hbox
);
244 gtk_box_pack_end (GTK_BOX (vbox
), btn_hbox
, FALSE
, FALSE
, 0);
246 gtkut_stock_button_set_create(&confirm_area
, &cancel_btn
, NULL
, _("_Cancel"),
247 &ok_btn
, NULL
, _("_OK"), NULL
, NULL
, NULL
);
248 gtk_widget_show (confirm_area
);
249 gtk_box_pack_end (GTK_BOX(btn_hbox
), confirm_area
, FALSE
, FALSE
, 0);
250 gtk_widget_grab_default (ok_btn
);
252 gtk_window_set_title (GTK_WINDOW(window
),
253 _("Displayed header configuration"));
254 MANAGE_WINDOW_SIGNALS_CONNECT(window
);
255 g_signal_connect (G_OBJECT(window
), "delete_event",
256 G_CALLBACK(prefs_display_header_deleted
),
258 g_signal_connect (G_OBJECT(window
), "key_press_event",
259 G_CALLBACK(prefs_display_header_key_pressed
),
261 g_signal_connect (G_OBJECT(ok_btn
), "clicked",
262 G_CALLBACK(prefs_display_header_ok
),
264 g_signal_connect (G_OBJECT(cancel_btn
), "clicked",
265 G_CALLBACK(prefs_display_header_cancel
),
268 vbox1
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, VSPACING
);
269 gtk_widget_show (vbox1
);
270 gtk_box_pack_start (GTK_BOX (vbox
), vbox1
, TRUE
, TRUE
, 0);
271 gtk_container_set_border_width (GTK_CONTAINER (vbox1
), 2);
273 hbox1
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 8);
274 gtk_widget_show (hbox1
);
275 gtk_box_pack_start (GTK_BOX (vbox1
), hbox1
, FALSE
, TRUE
, 0);
277 hdr_label
= gtk_label_new (_("Header name"));
278 gtk_widget_show (hdr_label
);
279 gtk_box_pack_start (GTK_BOX (hbox1
), hdr_label
, FALSE
, FALSE
, 0);
281 hdr_combo
= gtk_combo_box_text_new_with_entry();
282 for(i
=0; i
< 9 ; i
++)
283 gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT (hdr_combo
),
284 (*defaults
[i
] == '-') ? defaults
[i
]+1 : defaults
[i
]);
285 gtk_combo_box_set_active(GTK_COMBO_BOX(hdr_combo
), 0);
286 gtk_widget_show (hdr_combo
);
287 gtk_box_pack_start (GTK_BOX (hbox1
), hdr_combo
, TRUE
, TRUE
, 0);
288 gtk_widget_set_size_request (hdr_combo
, 150, -1);
290 list_view_hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 10);
291 gtk_widget_show (list_view_hbox
);
292 gtk_box_pack_start (GTK_BOX (vbox1
), list_view_hbox
, TRUE
, TRUE
, 0);
294 /* hidden headers list */
296 list_view_hbox2
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 8);
297 gtk_widget_show (list_view_hbox2
);
298 gtk_box_pack_start (GTK_BOX (list_view_hbox
), list_view_hbox2
, TRUE
, TRUE
, 0);
300 list_view_scrolledwin
= gtk_scrolled_window_new (NULL
, NULL
);
301 gtk_widget_set_size_request (list_view_scrolledwin
, 200, 210);
302 gtk_widget_show (list_view_scrolledwin
);
303 gtk_box_pack_start (GTK_BOX (list_view_hbox2
), list_view_scrolledwin
,
305 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (list_view_scrolledwin
),
306 GTK_POLICY_AUTOMATIC
,
307 GTK_POLICY_AUTOMATIC
);
308 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(list_view_scrolledwin
),
311 hidden_headers_list_view
= prefs_display_header_list_view_create
312 (_("Hidden headers"));
313 gtk_widget_show (hidden_headers_list_view
);
314 gtk_container_add (GTK_CONTAINER (list_view_scrolledwin
),
315 hidden_headers_list_view
);
317 btn_vbox
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, 8);
318 gtk_widget_show (btn_vbox
);
319 gtk_box_pack_start (GTK_BOX (list_view_hbox2
), btn_vbox
, FALSE
, FALSE
, 0);
321 reg_btn
= gtkut_stock_button("list-add", _("_Add"));
322 gtk_widget_show (reg_btn
);
323 gtk_box_pack_start (GTK_BOX (btn_vbox
), reg_btn
, FALSE
, TRUE
, 0);
324 g_signal_connect (G_OBJECT (reg_btn
), "clicked",
326 (prefs_display_header_register_cb
),
327 GINT_TO_POINTER(TRUE
));
328 del_btn
= gtkut_stock_button("edit-delete", _("_Delete"));
329 gtk_widget_show (del_btn
);
330 gtk_box_pack_start (GTK_BOX (btn_vbox
), del_btn
, FALSE
, TRUE
, 0);
331 g_signal_connect (G_OBJECT (del_btn
), "clicked",
332 G_CALLBACK (prefs_display_header_delete_cb
),
333 hidden_headers_list_view
);
335 /* display headers list */
337 list_view_hbox1
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 8);
338 gtk_widget_show (list_view_hbox1
);
339 gtk_box_pack_start (GTK_BOX (list_view_hbox
), list_view_hbox1
, TRUE
, TRUE
, 0);
341 list_view_scrolledwin
= gtk_scrolled_window_new (NULL
, NULL
);
342 gtk_widget_set_size_request (list_view_scrolledwin
, 200, 210);
343 gtk_widget_show (list_view_scrolledwin
);
344 gtk_box_pack_start (GTK_BOX (list_view_hbox1
), list_view_scrolledwin
,
346 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (list_view_scrolledwin
),
347 GTK_POLICY_AUTOMATIC
,
348 GTK_POLICY_AUTOMATIC
);
349 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(list_view_scrolledwin
),
352 headers_list_view
= prefs_display_header_list_view_create
353 (_("Displayed Headers"));
354 gtk_widget_show (headers_list_view
);
355 gtk_container_add(GTK_CONTAINER(list_view_scrolledwin
), headers_list_view
);
356 gtk_tree_view_set_reorderable(GTK_TREE_VIEW(headers_list_view
), TRUE
);
358 g_signal_connect(G_OBJECT(headers_list_view
), "drag_end",
359 G_CALLBACK(drag_end
),
362 /* connect rows change for this list view's model */
363 g_signal_connect(G_OBJECT(gtk_tree_view_get_model(GTK_TREE_VIEW(headers_list_view
))),
365 G_CALLBACK(headers_list_model_rows_reordered
),
368 btn_vbox
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, 8);
369 gtk_widget_show (btn_vbox
);
370 gtk_box_pack_start (GTK_BOX (list_view_hbox1
), btn_vbox
, FALSE
, FALSE
, 0);
372 reg_btn
= gtkut_stock_button("list-add", _("_Add"));
373 gtk_widget_show (reg_btn
);
374 gtk_box_pack_start (GTK_BOX (btn_vbox
), reg_btn
, FALSE
, TRUE
, 0);
375 g_signal_connect (G_OBJECT (reg_btn
), "clicked",
376 G_CALLBACK (prefs_display_header_register_cb
),
377 GINT_TO_POINTER(FALSE
));
378 del_btn
= gtkut_stock_button("list-remove", _("_Remove"));
379 gtk_widget_show (del_btn
);
380 gtk_box_pack_start (GTK_BOX (btn_vbox
), del_btn
, FALSE
, TRUE
, 0);
381 g_signal_connect (G_OBJECT (del_btn
), "clicked",
382 G_CALLBACK (prefs_display_header_delete_cb
),
385 up_btn
= gtkut_stock_button("go-up", _("_Up"));
386 gtk_widget_show (up_btn
);
387 gtk_box_pack_start (GTK_BOX (btn_vbox
), up_btn
, FALSE
, FALSE
, 0);
388 g_signal_connect (G_OBJECT (up_btn
), "clicked",
389 G_CALLBACK (prefs_display_header_up
), NULL
);
391 down_btn
= gtkut_stock_button("go-down", _("_Down"));
392 gtk_widget_show (down_btn
);
393 gtk_box_pack_start (GTK_BOX (btn_vbox
), down_btn
, FALSE
, FALSE
, 0);
394 g_signal_connect (G_OBJECT (down_btn
), "clicked",
395 G_CALLBACK (prefs_display_header_down
), NULL
);
397 PACK_CHECK_BUTTON (vbox
, checkbtn_other_headers
,
398 _("Show all unspecified headers"));
399 SET_TOGGLE_SENSITIVITY (checkbtn_other_headers
, list_view_hbox2
);
401 gtk_widget_show_all(window
);
403 dispheader
.window
= window
;
404 dispheader
.ok_btn
= ok_btn
;
405 dispheader
.cancel_btn
= cancel_btn
;
407 dispheader
.hdr_combo
= hdr_combo
;
409 dispheader
.headers_list_view
= headers_list_view
;
410 dispheader
.hidden_headers_list_view
= hidden_headers_list_view
;
412 dispheader
.other_headers
= checkbtn_other_headers
;
415 void prefs_display_header_read_config(void)
419 gchar buf
[PREFSBUFSIZE
];
420 DisplayHeaderProp
*dp
;
422 debug_print("Reading configuration for displaying headers...\n");
424 rcpath
= g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S
,
425 DISPLAY_HEADER_RC
, NULL
);
426 if ((fp
= claws_fopen(rcpath
, "rb")) == NULL
) {
427 if (ENOENT
!= errno
) FILE_OP_ERROR(rcpath
, "claws_fopen");
429 prefs_common
.disphdr_list
= NULL
;
430 prefs_display_header_set_default();
435 /* remove all previous headers list */
436 while (prefs_common
.disphdr_list
!= NULL
) {
437 dp
= (DisplayHeaderProp
*)prefs_common
.disphdr_list
->data
;
438 prefs_common
.disphdr_list
=
439 g_slist_remove(prefs_common
.disphdr_list
, dp
);
440 display_header_prop_free(dp
);
443 while (claws_fgets(buf
, sizeof(buf
), fp
) != NULL
) {
444 g_strdelimit(buf
, "\r\n", '\0');
445 dp
= display_header_prop_read_str(buf
);
447 prefs_common
.disphdr_list
=
448 g_slist_append(prefs_common
.disphdr_list
, dp
);
454 static void prefs_display_header_write_config(void)
460 debug_print("Writing configuration for displaying headers...\n");
462 rcpath
= g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S
,
463 DISPLAY_HEADER_RC
, NULL
);
465 if ((pfile
= prefs_write_open(rcpath
)) == NULL
) {
466 g_warning("failed to write configuration to file");
471 for (cur
= prefs_common
.disphdr_list
; cur
!= NULL
;
473 DisplayHeaderProp
*dp
= (DisplayHeaderProp
*)cur
->data
;
476 dpstr
= display_header_prop_get_str(dp
);
477 if (claws_fputs(dpstr
, pfile
->fp
) == EOF
||
478 claws_fputc('\n', pfile
->fp
) == EOF
) {
479 FILE_OP_ERROR(rcpath
, "claws_fputs || claws_fputc");
480 prefs_file_close_revert(pfile
);
490 if (prefs_file_close(pfile
) < 0) {
491 g_warning("failed to write configuration to file");
496 static void prefs_display_header_set_dialog(void)
498 GtkTreeView
*list_view
= GTK_TREE_VIEW(dispheader
.headers_list_view
);
499 GtkTreeView
*hidden_list_view
= GTK_TREE_VIEW(dispheader
.hidden_headers_list_view
);
501 GtkTreeModel
*model_list
, *model_hidden
;
503 model_list
= gtk_tree_view_get_model(list_view
);
504 model_hidden
= gtk_tree_view_get_model(hidden_list_view
);
506 gtk_list_store_clear(GTK_LIST_STORE(model_list
));
507 gtk_list_store_clear(GTK_LIST_STORE(model_hidden
));
509 for (cur
= prefs_common
.disphdr_list
; cur
!= NULL
;
511 DisplayHeaderProp
*dp
= (DisplayHeaderProp
*)cur
->data
;
514 prefs_display_header_insert_header(GTK_LIST_STORE
515 (model_hidden
), dp
->name
, dp
);
517 prefs_display_header_insert_header(GTK_LIST_STORE
518 (model_list
), dp
->name
, dp
);
521 gtk_toggle_button_set_active
522 (GTK_TOGGLE_BUTTON(dispheader
.other_headers
),
523 prefs_common
.show_other_header
);
526 static void prefs_display_header_set_list(void)
529 DisplayHeaderProp
*dp
;
533 g_slist_free(prefs_common
.disphdr_list
);
534 prefs_common
.disphdr_list
= NULL
;
536 model
= gtk_tree_view_get_model(GTK_TREE_VIEW(dispheader
.headers_list_view
));
537 while (gtk_tree_model_iter_nth_child(model
, &iter
, NULL
, row
)) {
538 gtk_tree_model_get(model
, &iter
, PREFS_HDR_DATA
, &dp
, -1);
540 prefs_common
.disphdr_list
=
541 g_slist_append(prefs_common
.disphdr_list
, dp
);
545 model
= gtk_tree_view_get_model
546 (GTK_TREE_VIEW(dispheader
.hidden_headers_list_view
));
548 while (gtk_tree_model_iter_nth_child(model
, &iter
, NULL
, row
)) {
549 gtk_tree_model_get(model
, &iter
, PREFS_HDR_DATA
, &dp
, -1);
551 prefs_common
.disphdr_list
=
552 g_slist_append(prefs_common
.disphdr_list
, dp
);
557 static gint
prefs_display_header_find_header(GtkTreeView
*list_view
,
561 DisplayHeaderProp
*dp
;
565 model
= gtk_tree_view_get_model(list_view
);
566 while (gtk_tree_model_iter_nth_child(model
, &iter
, NULL
, row
)) {
567 gtk_tree_model_get(model
, &iter
, PREFS_HDR_DATA
, &dp
, -1);
568 if (dp
&& g_ascii_strcasecmp(dp
->name
, header
) == 0)
576 static void prefs_display_header_list_view_set_row(gboolean hidden
)
578 GtkTreeView
*list_view
;
579 DisplayHeaderProp
*dp
;
583 entry_text
= gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(dispheader
.hdr_combo
));
585 entry_text
= gtk_editable_get_chars(
586 GTK_EDITABLE(gtk_bin_get_child(GTK_BIN(dispheader
.hdr_combo
))),0,-1);
587 if (!entry_text
|| entry_text
[0] == '\0') {
588 alertpanel_error(_("Header name is not set."));
593 list_view
= GTK_TREE_VIEW(dispheader
.hidden_headers_list_view
);
595 list_view
= GTK_TREE_VIEW(dispheader
.headers_list_view
);
597 if (prefs_display_header_find_header(list_view
, entry_text
) != -1) {
598 alertpanel_error(_("This header is already in the list."));
602 dp
= g_new0(DisplayHeaderProp
, 1);
604 dp
->name
= g_strdup(entry_text
);
607 model
= gtk_tree_view_get_model(list_view
);
608 prefs_display_header_insert_header(GTK_LIST_STORE(model
),
611 prefs_display_header_set_list();
616 static void prefs_display_header_register_cb(GtkButton
*btn
,
617 gpointer hidden_data
)
619 prefs_display_header_list_view_set_row(GPOINTER_TO_INT(hidden_data
));
622 static void prefs_display_header_delete_cb(GtkButton
*btn
, gpointer list_view_data
)
624 GtkTreeView
*list_view
= GTK_TREE_VIEW(list_view_data
);
625 DisplayHeaderProp
*dp
;
626 GtkListStore
*store
= GTK_LIST_STORE(gtk_tree_view_get_model(list_view
));
627 GtkTreeSelection
*selection
= gtk_tree_view_get_selection(list_view
);
630 if (!gtk_tree_selection_get_selected(selection
, NULL
, &iter
))
633 gtk_tree_model_get(GTK_TREE_MODEL(store
), &iter
, PREFS_HDR_DATA
, &dp
, -1);
637 prefs_common
.disphdr_list
=
638 g_slist_remove(prefs_common
.disphdr_list
, dp
);
639 display_header_prop_free(dp
);
640 gtk_list_store_remove(store
, &iter
);
643 static void prefs_display_header_up(void)
645 GtkTreePath
*prev
, *sel
, *try;
647 GtkListStore
*store
= NULL
;
648 GtkTreeModel
*model
= NULL
;
651 if (!gtk_tree_selection_get_selected
652 (gtk_tree_view_get_selection
653 (GTK_TREE_VIEW(dispheader
.headers_list_view
)),
657 store
= (GtkListStore
*)model
;
658 sel
= gtk_tree_model_get_path(GTK_TREE_MODEL(store
), &isel
);
662 /* no move if we're at row 0... */
663 try = gtk_tree_path_copy(sel
);
664 if (!gtk_tree_path_prev(try)) {
665 gtk_tree_path_free(try);
666 gtk_tree_path_free(sel
);
671 gtk_tree_model_get_iter(GTK_TREE_MODEL(store
),
673 gtk_list_store_swap(store
, &iprev
, &isel
);
675 gtk_tree_path_free(sel
);
676 gtk_tree_path_free(prev
);
679 static void prefs_display_header_down(void)
681 GtkListStore
*store
= NULL
;
682 GtkTreeModel
*model
= NULL
;
683 GtkTreeIter next
, sel
;
686 if (!gtk_tree_selection_get_selected
687 (gtk_tree_view_get_selection
688 (GTK_TREE_VIEW(dispheader
.headers_list_view
)),
692 store
= (GtkListStore
*)model
;
693 try = gtk_tree_model_get_path(GTK_TREE_MODEL(store
), &sel
);
698 if (gtk_tree_model_iter_next(GTK_TREE_MODEL(store
), &next
))
699 gtk_list_store_swap(store
, &next
, &sel
);
701 gtk_tree_path_free(try);
704 static gboolean
prefs_display_header_key_pressed(GtkWidget
*widget
,
708 if (event
&& event
->keyval
== GDK_KEY_Escape
)
709 prefs_display_header_cancel();
713 static void prefs_display_header_ok(void)
715 prefs_common
.show_other_header
=
716 gtk_toggle_button_get_active
717 (GTK_TOGGLE_BUTTON(dispheader
.other_headers
));
718 prefs_display_header_write_config();
719 gtk_widget_hide(dispheader
.window
);
720 gtk_window_set_modal(GTK_WINDOW(dispheader
.window
), FALSE
);
723 static void prefs_display_header_cancel(void)
725 prefs_display_header_read_config();
726 gtk_widget_hide(dispheader
.window
);
727 gtk_window_set_modal(GTK_WINDOW(dispheader
.window
), FALSE
);
730 static gint
prefs_display_header_deleted(GtkWidget
*widget
, GdkEventAny
*event
,
733 prefs_display_header_cancel();
737 static GtkListStore
*prefs_display_header_create_store(void)
739 return gtk_list_store_new(N_PREFS_HDR_COLUMNS
,
745 static void prefs_display_header_insert_header(GtkListStore
*store
,
747 DisplayHeaderProp
*dp
)
752 gtk_list_store_append(store
, &iter
);
753 gtk_list_store_set(store
, &iter
,
760 static GtkWidget
*prefs_display_header_list_view_create(const gchar
*name
)
762 GtkWidget
*list_view
;
763 GtkTreeSelection
*selector
;
766 model
= GTK_TREE_MODEL(prefs_display_header_create_store());
767 list_view
= gtk_tree_view_new_with_model(model
);
768 g_object_unref(G_OBJECT(model
));
770 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(list_view
),
771 prefs_common
.use_stripes_everywhere
);
773 selector
= gtk_tree_view_get_selection(GTK_TREE_VIEW(list_view
));
774 gtk_tree_selection_set_mode(selector
, GTK_SELECTION_BROWSE
);
776 prefs_filtering_create_list_view_columns(GTK_WIDGET(list_view
), name
);
781 static void prefs_filtering_create_list_view_columns(GtkWidget
*list_view
,
784 GtkTreeViewColumn
*column
;
785 GtkCellRenderer
*renderer
;
787 renderer
= gtk_cell_renderer_text_new();
788 column
= gtk_tree_view_column_new_with_attributes
789 (name
, renderer
, "text", PREFS_HDR_HEADER
, NULL
);
790 gtk_tree_view_append_column(GTK_TREE_VIEW(list_view
), column
);
794 *\brief Called as a result of a gtk_list_store_swap()
796 static void headers_list_model_rows_reordered(GtkTreeModel
*model
,
800 GtkTreeView
*list_view
)
802 prefs_display_header_set_list();
806 *\brief Called as a result of a drag & drop
808 static void drag_end(GtkTreeView
*list_view
,
809 GdkDragContext
*context
,
812 prefs_display_header_set_list();