Mercurial > geeqie
comparison src/layout.c @ 1511:73cecf473802
startup path options simplified and moved to layout options
author | nadvornik |
---|---|
date | Sat, 04 Apr 2009 21:14:34 +0000 |
parents | d352a44545a6 |
children | 22174e704d0b |
comparison
equal
deleted
inserted
replaced
1510:ad5018434476 | 1511:73cecf473802 |
---|---|
2030 { | 2030 { |
2031 LayoutConfig *lc = data; | 2031 LayoutConfig *lc = data; |
2032 gtk_entry_set_text(GTK_ENTRY(lc->home_path_entry), layout_get_path(lc->lw)); | 2032 gtk_entry_set_text(GTK_ENTRY(lc->home_path_entry), layout_get_path(lc->lw)); |
2033 } | 2033 } |
2034 | 2034 |
2035 static void startup_path_set_current_cb(GtkWidget *widget, gpointer data) | |
2036 { | |
2037 LayoutConfig *lc = data; | |
2038 lc->options.startup_path = STARTUP_PATH_CURRENT; | |
2039 } | |
2040 | |
2041 static void startup_path_set_last_cb(GtkWidget *widget, gpointer data) | |
2042 { | |
2043 LayoutConfig *lc = data; | |
2044 lc->options.startup_path = STARTUP_PATH_LAST; | |
2045 } | |
2046 | |
2047 static void startup_path_set_home_cb(GtkWidget *widget, gpointer data) | |
2048 { | |
2049 LayoutConfig *lc = data; | |
2050 lc->options.startup_path = STARTUP_PATH_HOME; | |
2051 } | |
2052 | |
2053 | |
2035 /* | 2054 /* |
2036 static void layout_config_save_cb(GtkWidget *widget, gpointer data) | 2055 static void layout_config_save_cb(GtkWidget *widget, gpointer data) |
2037 { | 2056 { |
2038 layout_config_apply(); | 2057 layout_config_apply(); |
2039 save_options(options); | 2058 save_options(options); |
2113 | 2132 |
2114 vbox = gtk_vbox_new(FALSE, PREF_PAD_SPACE); | 2133 vbox = gtk_vbox_new(FALSE, PREF_PAD_SPACE); |
2115 gtk_container_add(GTK_CONTAINER(frame), vbox); | 2134 gtk_container_add(GTK_CONTAINER(frame), vbox); |
2116 gtk_widget_show(vbox); | 2135 gtk_widget_show(vbox); |
2117 | 2136 |
2137 | |
2118 group = pref_group_new(vbox, FALSE, _("General options"), GTK_ORIENTATION_VERTICAL); | 2138 group = pref_group_new(vbox, FALSE, _("General options"), GTK_ORIENTATION_VERTICAL); |
2119 | 2139 |
2120 pref_label_new(group, _("Home button path (empty to use your home directory)")); | 2140 pref_label_new(group, _("Home path (empty to use your home directory)")); |
2121 hbox = pref_box_new(group, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_SPACE); | 2141 hbox = pref_box_new(group, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_SPACE); |
2122 | 2142 |
2123 tabcomp = tab_completion_new(&lc->home_path_entry, lc->options.home_path, NULL, NULL); | 2143 tabcomp = tab_completion_new(&lc->home_path_entry, lc->options.home_path, NULL, NULL); |
2124 tab_completion_add_select_button(lc->home_path_entry, NULL, TRUE); | 2144 tab_completion_add_select_button(lc->home_path_entry, NULL, TRUE); |
2125 gtk_box_pack_start(GTK_BOX(hbox), tabcomp, TRUE, TRUE, 0); | 2145 gtk_box_pack_start(GTK_BOX(hbox), tabcomp, TRUE, TRUE, 0); |
2126 gtk_widget_show(tabcomp); | 2146 gtk_widget_show(tabcomp); |
2127 | 2147 |
2128 button = pref_button_new(hbox, NULL, _("Use current"), FALSE, | 2148 button = pref_button_new(hbox, NULL, _("Use current"), FALSE, |
2129 G_CALLBACK(home_path_set_current_cb), lc); | 2149 G_CALLBACK(home_path_set_current_cb), lc); |
2130 | 2150 |
2131 group = pref_group_new(vbox, FALSE, _("Behavior"), GTK_ORIENTATION_VERTICAL); | |
2132 | |
2133 pref_checkbox_new_int(group, _("Show date in directories list view"), | 2151 pref_checkbox_new_int(group, _("Show date in directories list view"), |
2134 lc->options.show_directory_date, &lc->options.show_directory_date); | 2152 lc->options.show_directory_date, &lc->options.show_directory_date); |
2153 | |
2154 group = pref_group_new(vbox, FALSE, _("Start-up directory:"), GTK_ORIENTATION_VERTICAL); | |
2155 | |
2156 button = pref_radiobutton_new(group, NULL, _("No change"), | |
2157 (lc->options.startup_path == STARTUP_PATH_CURRENT), | |
2158 G_CALLBACK(startup_path_set_current_cb), lc); | |
2159 button = pref_radiobutton_new(group, button, _("Restore last path"), | |
2160 (lc->options.startup_path == STARTUP_PATH_LAST), | |
2161 G_CALLBACK(startup_path_set_last_cb), lc); | |
2162 button = pref_radiobutton_new(group, button, _("Home path"), | |
2163 (lc->options.startup_path == STARTUP_PATH_HOME), | |
2164 G_CALLBACK(startup_path_set_home_cb), lc); | |
2135 | 2165 |
2136 group = pref_group_new(vbox, FALSE, _("Layout"), GTK_ORIENTATION_VERTICAL); | 2166 group = pref_group_new(vbox, FALSE, _("Layout"), GTK_ORIENTATION_VERTICAL); |
2137 | 2167 |
2138 lc->layout_widget = layout_config_new(); | 2168 lc->layout_widget = layout_config_new(); |
2139 layout_config_set(lc->layout_widget, lw->options.style, lw->options.order); | 2169 layout_config_set(lc->layout_widget, lw->options.style, lw->options.order); |
2172 histogram = image_osd_get_histogram(lw->image); | 2202 histogram = image_osd_get_histogram(lw->image); |
2173 | 2203 |
2174 lw->options.image_overlay.histogram_channel = histogram->histogram_channel; | 2204 lw->options.image_overlay.histogram_channel = histogram->histogram_channel; |
2175 lw->options.image_overlay.histogram_mode = histogram->histogram_mode; | 2205 lw->options.image_overlay.histogram_mode = histogram->histogram_mode; |
2176 | 2206 |
2177 // if (options->startup.restore_path && options->startup.use_last_path) | 2207 g_free(lw->options.last_path); |
2178 // { | 2208 lw->options.last_path = g_strdup(layout_get_path(lw)); |
2179 // g_free(options->startup.path); | |
2180 // options->startup.path = g_strdup(layout_get_path(NULL)); | |
2181 // } | |
2182 } | 2209 } |
2183 | 2210 |
2184 void layout_apply_options(LayoutWindow *lw, LayoutOptions *lop) | 2211 void layout_apply_options(LayoutWindow *lw, LayoutOptions *lop) |
2185 { | 2212 { |
2186 gboolean refresh_style; | 2213 gboolean refresh_style; |
2404 WRITE_NL(); WRITE_UINT(*layout, file_view_type); | 2431 WRITE_NL(); WRITE_UINT(*layout, file_view_type); |
2405 WRITE_NL(); WRITE_BOOL(*layout, show_marks); | 2432 WRITE_NL(); WRITE_BOOL(*layout, show_marks); |
2406 WRITE_NL(); WRITE_BOOL(*layout, show_thumbnails); | 2433 WRITE_NL(); WRITE_BOOL(*layout, show_thumbnails); |
2407 WRITE_NL(); WRITE_BOOL(*layout, show_directory_date); | 2434 WRITE_NL(); WRITE_BOOL(*layout, show_directory_date); |
2408 WRITE_NL(); WRITE_CHAR(*layout, home_path); | 2435 WRITE_NL(); WRITE_CHAR(*layout, home_path); |
2436 WRITE_NL(); WRITE_CHAR(*layout, last_path); | |
2437 WRITE_NL(); WRITE_UINT(*layout, startup_path); | |
2409 WRITE_SEPARATOR(); | 2438 WRITE_SEPARATOR(); |
2410 | 2439 |
2411 WRITE_NL(); WRITE_INT(*layout, main_window.x); | 2440 WRITE_NL(); WRITE_INT(*layout, main_window.x); |
2412 WRITE_NL(); WRITE_INT(*layout, main_window.y); | 2441 WRITE_NL(); WRITE_INT(*layout, main_window.y); |
2413 WRITE_NL(); WRITE_INT(*layout, main_window.w); | 2442 WRITE_NL(); WRITE_INT(*layout, main_window.w); |
2475 if (READ_UINT(*layout, file_view_type)) continue; | 2504 if (READ_UINT(*layout, file_view_type)) continue; |
2476 if (READ_BOOL(*layout, show_marks)) continue; | 2505 if (READ_BOOL(*layout, show_marks)) continue; |
2477 if (READ_BOOL(*layout, show_thumbnails)) continue; | 2506 if (READ_BOOL(*layout, show_thumbnails)) continue; |
2478 if (READ_BOOL(*layout, show_directory_date)) continue; | 2507 if (READ_BOOL(*layout, show_directory_date)) continue; |
2479 if (READ_CHAR(*layout, home_path)) continue; | 2508 if (READ_CHAR(*layout, home_path)) continue; |
2509 if (READ_CHAR(*layout, last_path)) continue; | |
2510 if (READ_UINT_CLAMP(*layout, startup_path, 0, STARTUP_PATH_HOME)) continue; | |
2480 | 2511 |
2481 /* window positions */ | 2512 /* window positions */ |
2482 | 2513 |
2483 if (READ_INT(*layout, main_window.x)) continue; | 2514 if (READ_INT(*layout, main_window.x)) continue; |
2484 if (READ_INT(*layout, main_window.y)) continue; | 2515 if (READ_INT(*layout, main_window.y)) continue; |
2517 { | 2548 { |
2518 g_free(id); | 2549 g_free(id); |
2519 } | 2550 } |
2520 } | 2551 } |
2521 | 2552 |
2553 static void layout_config_startup_path(LayoutOptions *lop, gchar **path) | |
2554 { | |
2555 switch (lop->startup_path) | |
2556 { | |
2557 case STARTUP_PATH_LAST: | |
2558 *path = (lop->last_path && isdir(lop->last_path)) ? g_strdup(lop->last_path) : get_current_dir(); | |
2559 break; | |
2560 case STARTUP_PATH_HOME: | |
2561 *path = (lop->home_path && isdir(lop->home_path)) ? g_strdup(lop->home_path) : g_strdup(homedir()); | |
2562 break; | |
2563 default: | |
2564 *path = get_current_dir(); | |
2565 break; | |
2566 } | |
2567 } | |
2568 | |
2569 | |
2522 static void layout_config_commandline(LayoutOptions *lop, gchar **path) | 2570 static void layout_config_commandline(LayoutOptions *lop, gchar **path) |
2523 { | 2571 { |
2524 if (command_line->startup_blank) | 2572 if (command_line->startup_blank) |
2525 { | 2573 { |
2526 *path = NULL; | 2574 *path = NULL; |
2531 } | 2579 } |
2532 else if (command_line->path) | 2580 else if (command_line->path) |
2533 { | 2581 { |
2534 *path = g_strdup(command_line->path); | 2582 *path = g_strdup(command_line->path); |
2535 } | 2583 } |
2536 else if (options->startup.restore_path && options->startup.path && isdir(options->startup.path)) | 2584 else layout_config_startup_path(lop, path); |
2537 { | |
2538 *path = g_strdup(options->startup.path); | |
2539 } | |
2540 else | |
2541 { | |
2542 *path = get_current_dir(); | |
2543 } | |
2544 | 2585 |
2545 if (command_line->tools_show) | 2586 if (command_line->tools_show) |
2546 { | 2587 { |
2547 lop->tools_float = FALSE; | 2588 lop->tools_float = FALSE; |
2548 lop->tools_hidden = FALSE; | 2589 lop->tools_hidden = FALSE; |
2565 | 2606 |
2566 if (use_commandline) | 2607 if (use_commandline) |
2567 { | 2608 { |
2568 layout_config_commandline(&lop, &path); | 2609 layout_config_commandline(&lop, &path); |
2569 } | 2610 } |
2570 else if (options->startup.restore_path && options->startup.path && isdir(options->startup.path)) | 2611 else |
2571 { | 2612 { |
2572 path = g_strdup(options->startup.path); | 2613 layout_config_startup_path(&lop, &path); |
2573 } | |
2574 else | |
2575 { | |
2576 path = get_current_dir(); | |
2577 } | 2614 } |
2578 | 2615 |
2579 lw = layout_new_with_geometry(NULL, &lop, use_commandline ? command_line->geometry : NULL); | 2616 lw = layout_new_with_geometry(NULL, &lop, use_commandline ? command_line->geometry : NULL); |
2580 layout_sort_set(lw, options->file_sort.method, options->file_sort.ascending); | 2617 layout_sort_set(lw, options->file_sort.method, options->file_sort.ascending); |
2581 layout_set_path(lw, path); | 2618 layout_set_path(lw, path); |