2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2013 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"
26 #include <glib/gi18n.h>
29 #include <gdk/gdkkeysyms.h>
32 #include "prefswindow.h"
34 #include "prefs_common.h"
35 #include "gtk/manage_window.h"
37 static void prefs_size_allocate_cb(GtkWidget
*widget
,
38 GtkAllocation
*allocation
, gpointer
*user_data
);
39 static GtkTreeStore
*prefswindow_create_data_store (void);
40 static GtkWidget
*prefswindow_tree_view_create (PrefsWindow
* prefswindow
);
41 static void prefs_filtering_create_tree_view_columns (GtkWidget
*tree_view
);
42 static gboolean
prefswindow_row_selected (GtkTreeSelection
*selector
,
45 gboolean currently_selected
,
48 static void save_all_pages(GSList
*prefs_pages
)
52 for (cur
= prefs_pages
; cur
!= NULL
; cur
= g_slist_next(cur
)) {
53 PrefsPage
*page
= (PrefsPage
*) cur
->data
;
55 if (page
->page_open
) {
56 page
->save_page(page
);
61 static gboolean
query_can_close_all_pages(GSList
*prefs_pages
)
65 for (cur
= prefs_pages
; cur
!= NULL
; cur
= g_slist_next(cur
)) {
66 PrefsPage
*page
= (PrefsPage
*) cur
->data
;
69 if (!page
->can_close(page
))
75 static void close_all_pages(GSList
*prefs_pages
)
79 for (cur
= prefs_pages
; cur
!= NULL
; cur
= g_slist_next(cur
)) {
80 PrefsPage
*page
= (PrefsPage
*) cur
->data
;
82 if (page
->page_open
) {
83 page
->destroy_widget(page
);
84 page
->page_open
= FALSE
;
90 static void prefs_show_sections(PrefsWindow
*prefswindow
)
93 GtkWidget
*paned
= prefswindow
->paned
;
95 g_object_get (G_OBJECT(paned
),
99 gtk_widget_show(gtk_paned_get_child1(GTK_PANED(paned
)));
100 gtk_widget_hide(gtk_paned_get_child2(GTK_PANED(paned
)));
101 gtk_paned_set_position(GTK_PANED(paned
), max
);
104 static void prefs_show_page(PrefsWindow
*prefswindow
)
107 GtkWidget
*paned
= prefswindow
->paned
;
109 g_object_get (G_OBJECT(paned
),
113 gtk_widget_hide(gtk_paned_get_child1(GTK_PANED(paned
)));
114 gtk_widget_show(gtk_paned_get_child2(GTK_PANED(paned
)));
115 gtk_paned_set_position(GTK_PANED(paned
), min
);
119 static void apply_button_clicked(GtkButton
*button
, gpointer user_data
)
121 PrefsWindow
*prefswindow
= (PrefsWindow
*) user_data
;
123 prefswindow
->dialog_response
= PREFSWINDOW_RESPONSE_APPLY
;
125 save_all_pages(prefswindow
->prefs_pages
);
127 prefs_show_sections(prefswindow
);
130 if (prefswindow
->apply_cb
)
131 prefswindow
->apply_cb(prefswindow
);
134 static void close_prefs_window(PrefsWindow
*prefswindow
)
136 debug_print("prefs window closed\n");
138 close_all_pages(prefswindow
->prefs_pages
);
140 if (prefswindow
->close_cb
)
141 prefswindow
->close_cb(prefswindow
);
143 gtk_widget_destroy(prefswindow
->window
);
144 g_slist_free(prefswindow
->prefs_pages
);
145 if(prefswindow
->func
!= NULL
)
146 prefswindow
->func(prefswindow
->data
);
150 static void ok_button_clicked(GtkButton
*button
, gpointer user_data
)
152 PrefsWindow
*prefswindow
= (PrefsWindow
*) user_data
;
154 prefswindow
->dialog_response
= PREFSWINDOW_RESPONSE_OK
;
156 if (query_can_close_all_pages(prefswindow
->prefs_pages
)) {
157 save_all_pages(prefswindow
->prefs_pages
);
158 close_prefs_window(prefswindow
);
162 static void cancel_button_clicked(GtkButton
*button
, gpointer user_data
)
164 PrefsWindow
*prefswindow
= (PrefsWindow
*) user_data
;
166 close_prefs_window(prefswindow
);
169 static gboolean
window_closed(GtkWidget
*widget
, GdkEvent
*event
, gpointer user_data
)
171 PrefsWindow
*prefswindow
= (PrefsWindow
*) user_data
;
174 save_all_pages(prefswindow
->prefs_pages
);
176 close_prefs_window(prefswindow
);
181 static gboolean
prefswindow_key_pressed(GtkWidget
*widget
, GdkEventKey
*event
,
184 GtkWidget
*focused_child
;
187 switch (event
->keyval
) {
188 case GDK_KEY_Escape
:
189 cancel_button_clicked(NULL
, data
);
191 case GDK_KEY_Return
:
192 case GDK_KEY_KP_Enter
:
193 focused_child
= gtkut_get_focused_child
194 (GTK_CONTAINER(data
->notebook
));
195 /* Press ok, if the focused child is not a text view
196 * and text (anything that accepts return) (can pass
197 * NULL to any of the GTK_xxx() casts) */
198 if (!GTK_IS_TEXT_VIEW(focused_child
))
199 ok_button_clicked(NULL
, data
);
208 typedef struct FindNodeByName
{
214 static gboolean
find_node_by_name(GtkTreeModel
*model
, GtkTreePath
*path
,
215 GtkTreeIter
*iter
, FindNodeByName
*data
)
218 gboolean result
= FALSE
;
220 gtk_tree_model_get(model
, iter
, PREFS_PAGE_TITLE
, &name
, -1);
222 result
= strcmp(name
, data
->name
) == 0;
233 static gint
prefswindow_tree_sort_by_weight(GtkTreeModel
*model
,
241 /* From observation sorting should keep in account the original
242 * order in the prefs_pages list. I.e. if equal weight, prefer
243 * the index in the pages list */
244 gtk_tree_model_get(model
, a
,
245 PREFS_PAGE_INDEX
, &i1
,
246 PREFS_PAGE_WEIGHT
, &f1
, -1);
247 gtk_tree_model_get(model
, b
,
248 PREFS_PAGE_INDEX
, &i2
,
249 PREFS_PAGE_WEIGHT
, &f2
, -1);
251 return f1
< f2
? -1 : (f1
> f2
? 1 :
252 (i1
< i2
? 1 : (i1
> i2
? -1 : 0)));
255 static void prefswindow_build_page(PrefsWindow
*prefswindow
, PrefsPage
*page
)
257 GtkWidget
*scrolledwin
, *tmp
;
259 if (!page
->page_open
) {
260 scrolledwin
= gtk_scrolled_window_new(NULL
, NULL
);
261 gtk_widget_show(scrolledwin
);
262 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin
),
263 GTK_POLICY_AUTOMATIC
, GTK_POLICY_AUTOMATIC
);
265 page
->create_widget(page
, GTK_WINDOW(prefswindow
->window
), prefswindow
->data
);
266 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolledwin
),
269 gtk_container_add(GTK_CONTAINER(prefswindow
->notebook
), scrolledwin
);
270 tmp
= gtk_bin_get_child(GTK_BIN(scrolledwin
));
272 gtk_widget_realize(tmp
);
273 gtk_widget_realize(page
->widget
);
275 page
->widget
= scrolledwin
;
276 page
->page_open
= TRUE
;
280 static GSList
*prefswindow_build_all_pages(PrefsWindow
*prefswindow
, GSList
*prefs_pages
)
284 prefs_pages
= g_slist_reverse(prefs_pages
);
285 for (cur
= prefs_pages
; cur
!= NULL
; cur
= g_slist_next(cur
)) {
286 PrefsPage
*page
= (PrefsPage
*) cur
->data
;
288 prefswindow_build_page(prefswindow
, page
);
290 return g_slist_reverse(prefs_pages
);
293 static void prefswindow_build_tree(GtkWidget
*tree_view
, GSList
*prefs_pages
,
294 PrefsWindow
*prefswindow
,
295 gboolean preload_pages
)
297 GtkTreeStore
*store
= GTK_TREE_STORE(gtk_tree_view_get_model
298 (GTK_TREE_VIEW(tree_view
)));
300 gint index
; /* index in pages list */
302 GtkTreeSelection
*selection
;
306 for (cur
= prefs_pages
, index
= 0; cur
!= NULL
; cur
= g_slist_next(cur
), index
++) {
307 PrefsPage
*page
= (PrefsPage
*)cur
->data
;
308 FindNodeByName find_name
;
309 GtkTreeIter node
, child
;
310 PrefsTreeNode
*prefs_node
= NULL
;
313 /* each page tree component string */
314 for (i
= 0; page
->path
[i
] != NULL
; i
++) {
315 find_name
.found
= FALSE
;
316 find_name
.name
= page
->path
[i
];
318 /* find node to attach to
319 * FIXME: we search the entire tree, so this is suboptimal... */
320 gtk_tree_model_foreach(GTK_TREE_MODEL(store
),
321 (GtkTreeModelForeachFunc
) find_node_by_name
,
323 if (find_name
.found
&& page
->path
[i
] != page
->path
[i
-1]) {
324 node
= find_name
.node
;
325 gtk_tree_model_get(GTK_TREE_MODEL(store
), &node
,
326 PREFS_PAGE_DATA
, &prefs_node
,
331 /* create a new top level */
332 gtk_tree_store_append(store
, &child
, i
== 0 ? NULL
: &node
);
333 prefs_node
= g_new0(PrefsTreeNode
, 1);
334 autoptr
= g_auto_pointer_new(prefs_node
);
335 gtk_tree_store_set(store
, &child
,
336 PREFS_PAGE_TITLE
, page
->path
[i
],
337 PREFS_PAGE_DATA
, prefs_node
,
338 PREFS_PAGE_DATA_AUTO_FREE
, autoptr
,
339 PREFS_PAGE_INDEX
, index
,
340 PREFS_PAGE_WEIGHT
, 0.0f
,
342 g_auto_pointer_free(autoptr
);
347 /* right now we have a node and its prefs_node */
349 g_warning("no prefs_node :/");
351 prefs_node
->page
= page
;
353 /* parents "inherit" the max weight of the children */
357 gtk_tree_model_get(GTK_TREE_MODEL(store
), &node
,
358 PREFS_PAGE_WEIGHT
, &f
,
360 if (page
->weight
> f
) {
362 gtk_tree_store_set(store
, &node
,
363 PREFS_PAGE_WEIGHT
, f
,
367 } while (gtk_tree_model_iter_parent(GTK_TREE_MODEL(store
),
371 gtk_tree_view_expand_all(GTK_TREE_VIEW(tree_view
));
373 /* set sort func & sort */
374 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(store
),
376 prefswindow_tree_sort_by_weight
,
378 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(store
),
380 GTK_SORT_DESCENDING
);
383 prefs_pages
= prefswindow_build_all_pages(prefswindow
, prefs_pages
);
385 /* select first one or its first child if necessary */
387 selection
= gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view
));
388 if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store
), &iter
)) {
389 if (gtk_tree_model_iter_has_child(GTK_TREE_MODEL(store
), &iter
)) {
390 GtkTreeIter parent
= iter
;
391 if (!gtk_tree_model_iter_children(GTK_TREE_MODEL(store
), &iter
, &parent
))
394 gtk_tree_selection_select_iter(selection
, &iter
);
399 void prefswindow_open_full(const gchar
*title
, GSList
*prefs_pages
,
400 gpointer data
, GDestroyNotify func
,
401 gint
*save_width
, gint
*save_height
,
402 gboolean preload_pages
,
403 PrefsOpenCallbackFunc open_cb
,
404 PrefsApplyCallbackFunc apply_cb
,
405 PrefsCloseCallbackFunc close_cb
)
407 PrefsWindow
*prefswindow
;
408 gint x
= gdk_screen_width();
409 gint y
= gdk_screen_height();
410 static GdkGeometry geometry
;
413 prefswindow
= g_new0(PrefsWindow
, 1);
415 prefswindow
->data
= data
;
416 prefswindow
->func
= func
;
417 prefswindow
->prefs_pages
= g_slist_copy(prefs_pages
);
418 prefswindow
->save_width
= save_width
;
419 prefswindow
->save_height
= save_height
;
420 prefswindow
->open_cb
= open_cb
;
421 prefswindow
->apply_cb
= apply_cb
;
422 prefswindow
->close_cb
= close_cb
;
423 prefswindow
->dialog_response
= PREFSWINDOW_RESPONSE_CANCEL
;
425 prefswindow
->window
= gtkut_window_new(GTK_WINDOW_TOPLEVEL
, "prefswindow");
426 gtk_window_set_title(GTK_WINDOW(prefswindow
->window
), title
);
428 gtk_window_set_position (GTK_WINDOW(prefswindow
->window
), GTK_WIN_POS_CENTER
);
429 gtk_window_set_modal (GTK_WINDOW (prefswindow
->window
), TRUE
);
430 gtk_window_set_resizable (GTK_WINDOW(prefswindow
->window
), TRUE
);
431 gtk_window_set_transient_for (GTK_WINDOW(prefswindow
->window
),
432 GTK_WINDOW(mainwindow_get_mainwindow()->window
));
433 gtk_container_set_border_width(GTK_CONTAINER(prefswindow
->window
), 4);
435 prefswindow
->vbox
= gtk_vbox_new(FALSE
, 6);
436 gtk_widget_show(prefswindow
->vbox
);
438 prefswindow
->paned
= gtk_hpaned_new();
439 gtk_widget_show(prefswindow
->paned
);
441 gtk_container_add(GTK_CONTAINER(prefswindow
->window
), prefswindow
->vbox
);
443 gtk_box_pack_start(GTK_BOX(prefswindow
->vbox
), prefswindow
->paned
, TRUE
, TRUE
, 0);
445 prefswindow
->scrolledwindow1
= gtk_scrolled_window_new(NULL
, NULL
);
446 gtk_widget_show(prefswindow
->scrolledwindow1
);
447 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(prefswindow
->scrolledwindow1
),
449 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(prefswindow
->scrolledwindow1
),
450 GTK_POLICY_NEVER
, GTK_POLICY_AUTOMATIC
);
452 gtk_paned_add1(GTK_PANED(prefswindow
->paned
), prefswindow
->scrolledwindow1
);
454 prefswindow
->tree_view
= prefswindow_tree_view_create(prefswindow
);
455 gtk_widget_show(prefswindow
->tree_view
);
456 gtk_container_add(GTK_CONTAINER(prefswindow
->scrolledwindow1
),
457 prefswindow
->tree_view
);
459 prefswindow
->vbox2
= gtk_vbox_new(FALSE
, 2);
460 gtk_widget_show(prefswindow
->vbox2
);
462 gtk_paned_add2(GTK_PANED(prefswindow
->paned
), prefswindow
->vbox2
);
464 prefswindow
->table2
= gtk_table_new(1, 2, FALSE
);
465 gtk_widget_show(prefswindow
->table2
);
466 gtk_container_add(GTK_CONTAINER(prefswindow
->vbox2
), prefswindow
->table2
);
468 prefswindow
->labelframe
= gtk_frame_new(NULL
);
469 gtk_widget_show(prefswindow
->labelframe
);
470 gtk_frame_set_shadow_type(GTK_FRAME(prefswindow
->labelframe
), GTK_SHADOW_OUT
);
471 gtk_table_attach(GTK_TABLE(prefswindow
->table2
), prefswindow
->labelframe
,
472 0, 1, 0, 1, GTK_FILL
| GTK_EXPAND
, GTK_FILL
, 1, 1);
474 prefswindow
->pagelabel
= gtk_label_new("");
475 gtk_widget_show(prefswindow
->pagelabel
);
476 gtk_label_set_justify(GTK_LABEL(prefswindow
->pagelabel
), GTK_JUSTIFY_LEFT
);
477 gtk_misc_set_alignment(GTK_MISC(prefswindow
->pagelabel
), 0, 0.0);
478 gtk_container_add(GTK_CONTAINER(prefswindow
->labelframe
), prefswindow
->pagelabel
);
480 prefswindow
->notebook
= gtk_notebook_new();
481 gtk_widget_show(prefswindow
->notebook
);
482 gtk_notebook_set_scrollable(GTK_NOTEBOOK(prefswindow
->notebook
), TRUE
);
483 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(prefswindow
->notebook
), FALSE
);
484 gtk_notebook_set_show_border(GTK_NOTEBOOK(prefswindow
->notebook
), FALSE
);
486 gtk_table_attach(GTK_TABLE(prefswindow
->table2
), prefswindow
->notebook
,
487 0, 1, 1, 2, GTK_FILL
| GTK_EXPAND
, GTK_FILL
| GTK_EXPAND
, 0, 4);
489 prefswindow
->empty_page
= gtk_label_new("");
490 gtk_widget_show(prefswindow
->empty_page
);
491 gtk_container_add(GTK_CONTAINER(prefswindow
->notebook
), prefswindow
->empty_page
);
493 prefswindow_build_tree(prefswindow
->tree_view
, prefs_pages
, prefswindow
,
497 open_cb(prefswindow
);
499 gtk_widget_grab_focus(prefswindow
->tree_view
);
502 gtkut_stock_button_set_create(&prefswindow
->confirm_area
,
503 &prefswindow
->apply_btn
, GTK_STOCK_APPLY
,
504 &prefswindow
->cancel_btn
, GTK_STOCK_CANCEL
,
505 &prefswindow
->ok_btn
, GTK_STOCK_OK
);
507 gtkut_stock_button_set_create(&prefswindow
->confirm_area
,
508 &prefswindow
->apply_btn
, GTK_STOCK_APPLY
,
509 &prefswindow
->ok_btn
, GTK_STOCK_CLOSE
,
512 gtk_widget_show_all(prefswindow
->confirm_area
);
513 gtk_widget_show(prefswindow
->vbox
);
514 gtk_widget_show(prefswindow
->scrolledwindow1
);
516 gtk_box_pack_start(GTK_BOX(prefswindow
->vbox
), prefswindow
->confirm_area
, FALSE
, FALSE
, 0);
519 g_signal_connect(G_OBJECT(prefswindow
->ok_btn
), "clicked",
520 G_CALLBACK(ok_button_clicked
), prefswindow
);
521 g_signal_connect(G_OBJECT(prefswindow
->cancel_btn
), "clicked",
522 G_CALLBACK(cancel_button_clicked
), prefswindow
);
523 g_signal_connect(G_OBJECT(prefswindow
->apply_btn
), "clicked",
524 G_CALLBACK(apply_button_clicked
), prefswindow
);
526 g_signal_connect(G_OBJECT(prefswindow
->ok_btn
), "clicked",
527 G_CALLBACK(ok_button_clicked
), prefswindow
);
528 g_signal_connect(G_OBJECT(prefswindow
->apply_btn
), "clicked",
529 G_CALLBACK(apply_button_clicked
), prefswindow
);
532 g_signal_connect(G_OBJECT(prefswindow
->window
), "delete_event",
533 G_CALLBACK(window_closed
), prefswindow
);
534 g_signal_connect(G_OBJECT(prefswindow
->window
), "key_press_event",
535 G_CALLBACK(prefswindow_key_pressed
), &(prefswindow
->window
));
537 /* connect to callback only if we have non-NULL pointers to store size to */
538 if (prefswindow
->save_width
&& prefswindow
->save_height
) {
539 g_signal_connect(G_OBJECT(prefswindow
->window
), "size_allocate",
540 G_CALLBACK(prefs_size_allocate_cb
), prefswindow
);
543 MANAGE_WINDOW_SIGNALS_CONNECT(prefswindow
->window
);
545 if (!geometry
.min_height
) {
547 if (x
< 800 && y
< 600) {
548 geometry
.min_width
= 600;
549 geometry
.min_height
= 440;
551 geometry
.min_width
= 700;
552 geometry
.min_height
= 550;
555 gtk_window_set_geometry_hints(GTK_WINDOW(prefswindow
->window
), NULL
, &geometry
,
557 if (prefswindow
->save_width
&& prefswindow
->save_height
) {
558 gtk_widget_set_size_request(prefswindow
->window
, *(prefswindow
->save_width
),
559 *(prefswindow
->save_height
));
563 prefs_show_sections(prefswindow
);
565 gtk_widget_show(prefswindow
->window
);
566 adj
= gtk_scrolled_window_get_vadjustment(
567 GTK_SCROLLED_WINDOW(prefswindow
->scrolledwindow1
));
568 gtk_adjustment_set_value(adj
, gtk_adjustment_get_lower(adj
));
569 gtk_adjustment_changed(adj
);
572 void prefswindow_open(const gchar
*title
, GSList
*prefs_pages
, gpointer data
,
573 gint
*save_width
, gint
*save_height
,
574 PrefsOpenCallbackFunc open_cb
,
575 PrefsApplyCallbackFunc apply_cb
,
576 PrefsCloseCallbackFunc close_cb
)
578 prefswindow_open_full(title
, prefs_pages
, data
, NULL
, save_width
, save_height
,
579 FALSE
, open_cb
, apply_cb
, close_cb
);
583 *\brief Save Gtk object size to prefs dataset
585 static void prefs_size_allocate_cb(GtkWidget
*widget
,
586 GtkAllocation
*allocation
, gpointer
*user_data
)
588 PrefsWindow
*prefswindow
= (PrefsWindow
*) user_data
;
590 cm_return_if_fail(allocation
!= NULL
);
592 /* don't try to save size to NULL pointers */
593 if (prefswindow
&& prefswindow
->save_width
&& prefswindow
->save_height
) {
594 *(prefswindow
->save_width
) = allocation
->width
;
595 *(prefswindow
->save_height
) = allocation
->height
;
599 static GtkTreeStore
*prefswindow_create_data_store(void)
601 return gtk_tree_store_new(N_PREFS_PAGE_COLUMNS
,
610 static GtkWidget
*prefswindow_tree_view_create(PrefsWindow
*prefswindow
)
612 GtkTreeView
*tree_view
;
613 GtkTreeSelection
*selector
;
616 model
= GTK_TREE_MODEL(prefswindow_create_data_store());
617 tree_view
= GTK_TREE_VIEW(gtk_tree_view_new_with_model(model
));
618 g_object_unref(model
);
619 gtk_tree_view_set_rules_hint(tree_view
, prefs_common
.use_stripes_everywhere
);
621 selector
= gtk_tree_view_get_selection(tree_view
);
622 gtk_tree_selection_set_mode(selector
, GTK_SELECTION_BROWSE
);
623 gtk_tree_selection_set_select_function(selector
, prefswindow_row_selected
,
626 /* create the columns */
627 prefs_filtering_create_tree_view_columns(GTK_WIDGET(tree_view
));
629 return GTK_WIDGET(tree_view
);
632 static void prefs_filtering_create_tree_view_columns(GtkWidget
*tree_view
)
634 GtkTreeViewColumn
*column
;
635 GtkCellRenderer
*renderer
;
637 renderer
= gtk_cell_renderer_text_new();
638 column
= gtk_tree_view_column_new_with_attributes
641 "text", PREFS_PAGE_TITLE
,
643 gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view
), column
);
646 static gboolean
prefswindow_row_selected(GtkTreeSelection
*selector
,
649 gboolean currently_selected
,
652 PrefsTreeNode
*prefsnode
;
654 PrefsWindow
*prefswindow
= (PrefsWindow
*) data
;
662 if (currently_selected
)
665 if (!gtk_tree_model_get_iter(GTK_TREE_MODEL(model
), &iter
, path
))
668 gtk_tree_model_get(model
, &iter
, PREFS_PAGE_DATA
, &prefsnode
, -1);
669 page
= prefsnode
->page
;
671 debug_print("%f\n", prefsnode
->treeweight
);
674 gtk_label_set_text(GTK_LABEL(prefswindow
->pagelabel
), "");
675 pagenum
= gtk_notebook_page_num(GTK_NOTEBOOK(prefswindow
->notebook
),
676 prefswindow
->empty_page
);
677 gtk_notebook_set_current_page(GTK_NOTEBOOK(prefswindow
->notebook
),
682 prefswindow_build_page(prefswindow
, page
);
685 while (page
->path
[i
+ 1] != 0)
687 labeltext
= page
->path
[i
];
689 gtk_label_set_text(GTK_LABEL(prefswindow
->pagelabel
), labeltext
);
691 pagenum
= gtk_notebook_page_num(GTK_NOTEBOOK(prefswindow
->notebook
),
693 gtk_notebook_set_current_page(GTK_NOTEBOOK(prefswindow
->notebook
),
696 adj
= gtk_scrolled_window_get_vadjustment(
697 GTK_SCROLLED_WINDOW(page
->widget
));
698 lower
= gtk_adjustment_get_lower(adj
);
699 gtk_adjustment_set_value(adj
, lower
);
700 gtk_adjustment_changed(adj
);
701 adj
= gtk_scrolled_window_get_hadjustment(
702 GTK_SCROLLED_WINDOW(page
->widget
));
703 gtk_adjustment_set_value(adj
, lower
);
704 gtk_adjustment_changed(adj
);
707 prefs_show_page(prefswindow
);