Mercurial > geeqie
comparison src/layout_util.c @ 1309:55ea4962887a
config file format changed to XML
save and restore all layout windows
save and restore sidebar configuration
author | nadvornik |
---|---|
date | Sun, 22 Feb 2009 15:35:37 +0000 |
parents | 48e064b37ba6 |
children | cd7204a18f14 |
comparison
equal
deleted
inserted
replaced
1308:2320339ca8be | 1309:55ea4962887a |
---|---|
95 if (gtk_widget_event(lw->path_entry, (GdkEvent *)event)) | 95 if (gtk_widget_event(lw->path_entry, (GdkEvent *)event)) |
96 { | 96 { |
97 return TRUE; | 97 return TRUE; |
98 } | 98 } |
99 } | 99 } |
100 if (lw->vd && lw->dir_view_type == DIRVIEW_TREE && GTK_WIDGET_HAS_FOCUS(lw->vd->view) && | 100 if (lw->vd && lw->options.dir_view_type == DIRVIEW_TREE && GTK_WIDGET_HAS_FOCUS(lw->vd->view) && |
101 !layout_key_match(event->keyval) && | 101 !layout_key_match(event->keyval) && |
102 gtk_widget_event(lw->vd->view, (GdkEvent *)event)) | 102 gtk_widget_event(lw->vd->view, (GdkEvent *)event)) |
103 { | 103 { |
104 return TRUE; | 104 return TRUE; |
105 } | 105 } |
192 LayoutWindow *lw = data; | 192 LayoutWindow *lw = data; |
193 LayoutWindow *nw; | 193 LayoutWindow *nw; |
194 | 194 |
195 layout_exit_fullscreen(lw); | 195 layout_exit_fullscreen(lw); |
196 | 196 |
197 nw = layout_new(NULL, FALSE, FALSE); | 197 nw = layout_new(NULL, NULL); |
198 layout_sort_set(nw, options->file_sort.method, options->file_sort.ascending); | 198 layout_sort_set(nw, options->file_sort.method, options->file_sort.ascending); |
199 layout_set_fd(nw, lw->dir_fd); | 199 layout_set_fd(nw, lw->dir_fd); |
200 } | 200 } |
201 | 201 |
202 static void layout_menu_new_cb(GtkAction *action, gpointer data) | 202 static void layout_menu_new_cb(GtkAction *action, gpointer data) |
567 static void layout_menu_list_cb(GtkRadioAction *action, GtkRadioAction *current, gpointer data) | 567 static void layout_menu_list_cb(GtkRadioAction *action, GtkRadioAction *current, gpointer data) |
568 { | 568 { |
569 LayoutWindow *lw = data; | 569 LayoutWindow *lw = data; |
570 | 570 |
571 layout_exit_fullscreen(lw); | 571 layout_exit_fullscreen(lw); |
572 layout_views_set(lw, lw->dir_view_type, (gtk_radio_action_get_current_value(action) == 1) ? FILEVIEW_ICON : FILEVIEW_LIST); | 572 layout_views_set(lw, lw->options.dir_view_type, (gtk_radio_action_get_current_value(action) == 1) ? FILEVIEW_ICON : FILEVIEW_LIST); |
573 } | 573 } |
574 | 574 |
575 static void layout_menu_view_dir_as_cb(GtkRadioAction *action, GtkRadioAction *current, gpointer data) | 575 static void layout_menu_view_dir_as_cb(GtkRadioAction *action, GtkRadioAction *current, gpointer data) |
576 { | 576 { |
577 LayoutWindow *lw = data; | 577 LayoutWindow *lw = data; |
639 { | 639 { |
640 LayoutWindow *lw = data; | 640 LayoutWindow *lw = data; |
641 | 641 |
642 layout_exit_fullscreen(lw); | 642 layout_exit_fullscreen(lw); |
643 | 643 |
644 if (lw->tools_float == gtk_toggle_action_get_active(action)) return; | 644 if (lw->options.tools_float == gtk_toggle_action_get_active(action)) return; |
645 layout_tools_float_toggle(lw); | 645 layout_tools_float_toggle(lw); |
646 } | 646 } |
647 | 647 |
648 static void layout_menu_hide_cb(GtkAction *action, gpointer data) | 648 static void layout_menu_hide_cb(GtkAction *action, gpointer data) |
649 { | 649 { |
657 { | 657 { |
658 LayoutWindow *lw = data; | 658 LayoutWindow *lw = data; |
659 | 659 |
660 layout_exit_fullscreen(lw); | 660 layout_exit_fullscreen(lw); |
661 | 661 |
662 if (lw->toolbar_hidden == gtk_toggle_action_get_active(action)) return; | 662 if (lw->options.toolbar_hidden == gtk_toggle_action_get_active(action)) return; |
663 layout_toolbar_toggle(lw); | 663 layout_toolbar_toggle(lw); |
664 } | 664 } |
665 | 665 |
666 static void layout_menu_bar_cb(GtkToggleAction *action, gpointer data) | 666 static void layout_menu_bar_cb(GtkToggleAction *action, gpointer data) |
667 { | 667 { |
668 LayoutWindow *lw = data; | 668 LayoutWindow *lw = data; |
669 | 669 |
670 layout_exit_fullscreen(lw); | 670 layout_exit_fullscreen(lw); |
671 | 671 |
672 if (lw->bar_enabled == gtk_toggle_action_get_active(action)) return; | 672 if (lw->options.panels.info.enabled == gtk_toggle_action_get_active(action)) return; |
673 layout_bar_toggle(lw); | 673 layout_bar_toggle(lw); |
674 } | 674 } |
675 | 675 |
676 static void layout_menu_bar_exif_cb(GtkToggleAction *action, gpointer data) | 676 static void layout_menu_bar_exif_cb(GtkToggleAction *action, gpointer data) |
677 { | 677 { |
686 { | 686 { |
687 LayoutWindow *lw = data; | 687 LayoutWindow *lw = data; |
688 | 688 |
689 layout_exit_fullscreen(lw); | 689 layout_exit_fullscreen(lw); |
690 | 690 |
691 if (lw->bar_sort_enabled == gtk_toggle_action_get_active(action)) return; | 691 if (lw->options.panels.sort.enabled == gtk_toggle_action_get_active(action)) return; |
692 layout_bar_sort_toggle(lw); | 692 layout_bar_sort_toggle(lw); |
693 } | 693 } |
694 | 694 |
695 static void layout_menu_slideshow_cb(GtkAction *action, gpointer data) | 695 static void layout_menu_slideshow_cb(GtkAction *action, gpointer data) |
696 { | 696 { |
1851 GtkAction *action; | 1851 GtkAction *action; |
1852 | 1852 |
1853 if (!lw->action_group) return; | 1853 if (!lw->action_group) return; |
1854 | 1854 |
1855 action = gtk_action_group_get_action(lw->action_group, "FolderTree"); | 1855 action = gtk_action_group_get_action(lw->action_group, "FolderTree"); |
1856 radio_action_set_current_value(GTK_RADIO_ACTION(action), lw->dir_view_type); | 1856 radio_action_set_current_value(GTK_RADIO_ACTION(action), lw->options.dir_view_type); |
1857 | 1857 |
1858 action = gtk_action_group_get_action(lw->action_group, "ViewIcons"); | 1858 action = gtk_action_group_get_action(lw->action_group, "ViewIcons"); |
1859 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->file_view_type); | 1859 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->file_view_type); |
1860 | 1860 |
1861 action = gtk_action_group_get_action(lw->action_group, "FloatTools"); | 1861 action = gtk_action_group_get_action(lw->action_group, "FloatTools"); |
1862 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->tools_float); | 1862 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->options.tools_float); |
1863 | 1863 |
1864 action = gtk_action_group_get_action(lw->action_group, "SBar"); | 1864 action = gtk_action_group_get_action(lw->action_group, "SBar"); |
1865 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->bar_enabled); | 1865 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->options.panels.info.enabled); |
1866 | 1866 |
1867 action = gtk_action_group_get_action(lw->action_group, "SBarSort"); | 1867 action = gtk_action_group_get_action(lw->action_group, "SBarSort"); |
1868 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->bar_sort_enabled); | 1868 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->options.panels.sort.enabled); |
1869 | 1869 |
1870 action = gtk_action_group_get_action(lw->action_group, "HideToolbar"); | 1870 action = gtk_action_group_get_action(lw->action_group, "HideToolbar"); |
1871 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->toolbar_hidden); | 1871 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->options.toolbar_hidden); |
1872 | 1872 |
1873 action = gtk_action_group_get_action(lw->action_group, "ShowMarks"); | 1873 action = gtk_action_group_get_action(lw->action_group, "ShowMarks"); |
1874 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->marks_enabled); | 1874 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->options.show_marks); |
1875 | 1875 |
1876 action = gtk_action_group_get_action(lw->action_group, "SlideShow"); | 1876 action = gtk_action_group_get_action(lw->action_group, "SlideShow"); |
1877 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), layout_image_slideshow_active(lw)); | 1877 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), layout_image_slideshow_active(lw)); |
1878 | 1878 |
1879 action = gtk_action_group_get_action(lw->action_group, "ExifWin"); | 1879 action = gtk_action_group_get_action(lw->action_group, "ExifWin"); |
1886 GtkAction *action; | 1886 GtkAction *action; |
1887 | 1887 |
1888 if (!lw->action_group) return; | 1888 if (!lw->action_group) return; |
1889 | 1889 |
1890 action = gtk_action_group_get_action(lw->action_group, "Thumbnails"); | 1890 action = gtk_action_group_get_action(lw->action_group, "Thumbnails"); |
1891 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->thumbs_enabled); | 1891 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->options.show_thumbnails); |
1892 g_object_set(action, "sensitive", (lw->file_view_type == FILEVIEW_LIST), NULL); | 1892 g_object_set(action, "sensitive", (lw->file_view_type == FILEVIEW_LIST), NULL); |
1893 | 1893 |
1894 gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(lw->thumb_button), lw->thumbs_enabled); | 1894 gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(lw->thumb_button), lw->options.show_thumbnails); |
1895 gtk_widget_set_sensitive(lw->thumb_button, (lw->file_view_type == FILEVIEW_LIST)); | 1895 gtk_widget_set_sensitive(lw->thumb_button, (lw->file_view_type == FILEVIEW_LIST)); |
1896 } | 1896 } |
1897 | 1897 |
1898 void layout_util_sync(LayoutWindow *lw) | 1898 void layout_util_sync(LayoutWindow *lw) |
1899 { | 1899 { |
1948 lw->bar = NULL; | 1948 lw->bar = NULL; |
1949 | 1949 |
1950 if (lw->utility_box) | 1950 if (lw->utility_box) |
1951 { | 1951 { |
1952 /* destroyed from within itself */ | 1952 /* destroyed from within itself */ |
1953 lw->bar_enabled = FALSE; | 1953 lw->options.panels.info.enabled = FALSE; |
1954 layout_util_sync_views(lw); | 1954 layout_util_sync_views(lw); |
1955 } | 1955 } |
1956 } | 1956 } |
1957 | 1957 |
1958 static GList *layout_bar_list_cb(gpointer data) | 1958 static GList *layout_bar_list_cb(gpointer data) |
1966 { | 1966 { |
1967 LayoutWindow *lw = data; | 1967 LayoutWindow *lw = data; |
1968 | 1968 |
1969 if (!lw->bar) return; | 1969 if (!lw->bar) return; |
1970 | 1970 |
1971 options->panels.info.width = lw->bar_width = allocation->width; | 1971 lw->options.panels.info.width = allocation->width; |
1972 } | 1972 } |
1973 | 1973 |
1974 static void layout_bar_new(LayoutWindow *lw) | 1974 void layout_bar_new(LayoutWindow *lw, gboolean populate) |
1975 { | 1975 { |
1976 if (!lw->utility_box) return; | 1976 if (!lw->utility_box) return; |
1977 | 1977 |
1978 lw->bar = bar_new(lw->utility_box); | 1978 if (!lw->bar) |
1979 bar_set_selection_func(lw->bar, layout_bar_list_cb, lw); | 1979 { |
1980 g_signal_connect(G_OBJECT(lw->bar), "destroy", | 1980 lw->bar = bar_new(lw->utility_box); |
1981 G_CALLBACK(layout_bar_destroyed), lw); | 1981 |
1982 g_signal_connect(G_OBJECT(lw->bar), "size_allocate", | 1982 if (populate) |
1983 G_CALLBACK(layout_bar_sized), lw); | 1983 { |
1984 | 1984 bar_populate_default(lw->bar); |
1985 options->panels.info.enabled = lw->bar_enabled = TRUE; | 1985 } |
1986 gtk_widget_set_size_request(lw->bar, lw->bar_width, -1); | 1986 |
1987 | 1987 bar_set_selection_func(lw->bar, layout_bar_list_cb, lw); |
1988 gtk_box_pack_start(GTK_BOX(lw->utility_box), lw->bar, FALSE, FALSE, 0); | 1988 g_signal_connect(G_OBJECT(lw->bar), "destroy", |
1989 | 1989 G_CALLBACK(layout_bar_destroyed), lw); |
1990 g_signal_connect(G_OBJECT(lw->bar), "size_allocate", | |
1991 G_CALLBACK(layout_bar_sized), lw); | |
1992 | |
1993 | |
1994 gtk_box_pack_start(GTK_BOX(lw->utility_box), lw->bar, FALSE, FALSE, 0); | |
1995 } | |
1996 | |
1997 lw->options.panels.info.enabled = TRUE; | |
1998 gtk_widget_set_size_request(lw->bar, lw->options.panels.info.width, -1); | |
1990 bar_set_fd(lw->bar, layout_image_get_fd(lw)); | 1999 bar_set_fd(lw->bar, layout_image_get_fd(lw)); |
1991 gtk_widget_show(lw->bar); | 2000 gtk_widget_show(lw->bar); |
1992 } | 2001 } |
1993 | 2002 |
1994 static void layout_bar_close(LayoutWindow *lw) | 2003 void layout_bar_close(LayoutWindow *lw) |
1995 { | 2004 { |
1996 if (lw->bar) | 2005 if (lw->bar) |
1997 { | 2006 { |
1998 bar_close(lw->bar); | 2007 bar_close(lw->bar); |
1999 lw->bar = NULL; | 2008 lw->bar = NULL; |
2000 } | 2009 } |
2001 options->panels.info.enabled = lw->bar_enabled = FALSE; | 2010 lw->options.panels.info.enabled = FALSE; |
2011 } | |
2012 | |
2013 static void layout_bar_hide(LayoutWindow *lw) | |
2014 { | |
2015 if (lw->bar) | |
2016 { | |
2017 gtk_widget_hide(lw->bar); | |
2018 } | |
2019 lw->options.panels.info.enabled = FALSE; | |
2002 } | 2020 } |
2003 | 2021 |
2004 void layout_bar_toggle(LayoutWindow *lw) | 2022 void layout_bar_toggle(LayoutWindow *lw) |
2005 { | 2023 { |
2006 if (lw->bar_enabled) | 2024 if (lw->options.panels.info.enabled) |
2007 { | 2025 { |
2008 layout_bar_close(lw); | 2026 layout_bar_hide(lw); |
2009 } | 2027 } |
2010 else | 2028 else |
2011 { | 2029 { |
2012 layout_bar_new(lw); | 2030 layout_bar_new(lw, TRUE); |
2013 } | 2031 } |
2014 } | 2032 } |
2015 | 2033 |
2016 static void layout_bar_new_image(LayoutWindow *lw) | 2034 static void layout_bar_new_image(LayoutWindow *lw) |
2017 { | 2035 { |
2018 if (!lw->bar || !lw->bar_enabled) return; | 2036 if (!lw->bar || !lw->options.panels.info.enabled) return; |
2019 | 2037 |
2020 bar_set_fd(lw->bar, layout_image_get_fd(lw)); | 2038 bar_set_fd(lw->bar, layout_image_get_fd(lw)); |
2021 } | 2039 } |
2022 | 2040 |
2023 static void layout_bar_new_selection(LayoutWindow *lw, gint count) | 2041 static void layout_bar_new_selection(LayoutWindow *lw, gint count) |
2024 { | 2042 { |
2025 if (!lw->bar || !lw->bar_enabled) return; | 2043 if (!lw->bar || !lw->options.panels.info.enabled) return; |
2026 | 2044 |
2027 // bar_info_selection(lw->bar_info, count - 1); | 2045 // bar_info_selection(lw->bar_info, count - 1); |
2028 } | 2046 } |
2029 | 2047 |
2030 static void layout_bar_maint_renamed(LayoutWindow *lw) | 2048 static void layout_bar_maint_renamed(LayoutWindow *lw) |
2031 { | 2049 { |
2032 if (!lw->bar || !lw->bar_enabled) return; | 2050 if (!lw->bar || !lw->options.panels.info.enabled) return; |
2033 | 2051 |
2034 // bar_maint_renamed(lw->bar_info, layout_image_get_fd(lw)); | 2052 // bar_maint_renamed(lw->bar_info, layout_image_get_fd(lw)); |
2035 } | 2053 } |
2036 | 2054 |
2037 static void layout_bar_sort_destroyed(GtkWidget *widget, gpointer data) | 2055 static void layout_bar_sort_destroyed(GtkWidget *widget, gpointer data) |
2041 lw->bar_sort = NULL; | 2059 lw->bar_sort = NULL; |
2042 | 2060 |
2043 if (lw->utility_box) | 2061 if (lw->utility_box) |
2044 { | 2062 { |
2045 /* destroyed from within itself */ | 2063 /* destroyed from within itself */ |
2046 lw->bar_sort_enabled = FALSE; | 2064 lw->options.panels.sort.enabled = FALSE; |
2047 | 2065 |
2048 layout_util_sync_views(lw); | 2066 layout_util_sync_views(lw); |
2049 } | 2067 } |
2050 } | 2068 } |
2051 | 2069 |
2054 if (!lw->utility_box) return; | 2072 if (!lw->utility_box) return; |
2055 | 2073 |
2056 lw->bar_sort = bar_sort_new(lw); | 2074 lw->bar_sort = bar_sort_new(lw); |
2057 g_signal_connect(G_OBJECT(lw->bar_sort), "destroy", | 2075 g_signal_connect(G_OBJECT(lw->bar_sort), "destroy", |
2058 G_CALLBACK(layout_bar_sort_destroyed), lw); | 2076 G_CALLBACK(layout_bar_sort_destroyed), lw); |
2059 options->panels.sort.enabled = lw->bar_sort_enabled = TRUE; | 2077 lw->options.panels.sort.enabled = TRUE; |
2060 | 2078 |
2061 gtk_box_pack_end(GTK_BOX(lw->utility_box), lw->bar_sort, FALSE, FALSE, 0); | 2079 gtk_box_pack_end(GTK_BOX(lw->utility_box), lw->bar_sort, FALSE, FALSE, 0); |
2062 gtk_widget_show(lw->bar_sort); | 2080 gtk_widget_show(lw->bar_sort); |
2063 } | 2081 } |
2064 | 2082 |
2067 if (lw->bar_sort) | 2085 if (lw->bar_sort) |
2068 { | 2086 { |
2069 bar_sort_close(lw->bar_sort); | 2087 bar_sort_close(lw->bar_sort); |
2070 lw->bar_sort = NULL; | 2088 lw->bar_sort = NULL; |
2071 } | 2089 } |
2072 options->panels.sort.enabled = lw->bar_sort_enabled = FALSE; | 2090 lw->options.panels.sort.enabled = FALSE; |
2073 } | 2091 } |
2074 | 2092 |
2075 void layout_bar_sort_toggle(LayoutWindow *lw) | 2093 void layout_bar_sort_toggle(LayoutWindow *lw) |
2076 { | 2094 { |
2077 if (lw->bar_sort_enabled) | 2095 if (lw->options.panels.sort.enabled) |
2078 { | 2096 { |
2079 layout_bar_sort_close(lw); | 2097 layout_bar_sort_close(lw); |
2080 } | 2098 } |
2081 else | 2099 else |
2082 { | 2100 { |
2104 { | 2122 { |
2105 lw->utility_box = gtk_hbox_new(FALSE, PREF_PAD_GAP); | 2123 lw->utility_box = gtk_hbox_new(FALSE, PREF_PAD_GAP); |
2106 gtk_box_pack_start(GTK_BOX(lw->utility_box), image, TRUE, TRUE, 0); | 2124 gtk_box_pack_start(GTK_BOX(lw->utility_box), image, TRUE, TRUE, 0); |
2107 gtk_widget_show(image); | 2125 gtk_widget_show(image); |
2108 | 2126 |
2109 if (lw->bar_sort_enabled) | 2127 if (lw->options.panels.sort.enabled) |
2110 { | 2128 { |
2111 layout_bar_sort_new(lw); | 2129 layout_bar_sort_new(lw); |
2112 } | 2130 } |
2113 | 2131 |
2114 if (lw->bar_enabled) | 2132 if (lw->options.panels.info.enabled) |
2115 { | 2133 { |
2116 layout_bar_new(lw); | 2134 layout_bar_new(lw, TRUE); |
2117 } | 2135 } |
2118 | 2136 |
2119 return lw->utility_box; | 2137 return lw->utility_box; |
2120 } | 2138 } |
2121 | 2139 |