Mercurial > geeqie
comparison src/layout_util.c @ 1317:cd7204a18f14
simplified and improved bar configuration
author | nadvornik |
---|---|
date | Tue, 24 Feb 2009 20:34:39 +0000 |
parents | 55ea4962887a |
children | fb76c291b00f |
comparison
equal
deleted
inserted
replaced
1316:732083928afb | 1317:cd7204a18f14 |
---|---|
47 #include <gdk/gdkkeysyms.h> /* for keyboard values */ | 47 #include <gdk/gdkkeysyms.h> /* for keyboard values */ |
48 | 48 |
49 | 49 |
50 #define MENU_EDIT_ACTION_OFFSET 16 | 50 #define MENU_EDIT_ACTION_OFFSET 16 |
51 | 51 |
52 static gboolean layout_bar_enabled(LayoutWindow *lw); | |
52 | 53 |
53 /* | 54 /* |
54 *----------------------------------------------------------------------------- | 55 *----------------------------------------------------------------------------- |
55 * keyboard handler | 56 * keyboard handler |
56 *----------------------------------------------------------------------------- | 57 *----------------------------------------------------------------------------- |
667 { | 668 { |
668 LayoutWindow *lw = data; | 669 LayoutWindow *lw = data; |
669 | 670 |
670 layout_exit_fullscreen(lw); | 671 layout_exit_fullscreen(lw); |
671 | 672 |
672 if (lw->options.panels.info.enabled == gtk_toggle_action_get_active(action)) return; | 673 if (layout_bar_enabled(lw) == gtk_toggle_action_get_active(action)) return; |
673 layout_bar_toggle(lw); | 674 layout_bar_toggle(lw); |
674 } | 675 } |
675 | 676 |
676 static void layout_menu_bar_exif_cb(GtkToggleAction *action, gpointer data) | 677 static void layout_menu_bar_exif_cb(GtkToggleAction *action, gpointer data) |
677 { | 678 { |
1860 | 1861 |
1861 action = gtk_action_group_get_action(lw->action_group, "FloatTools"); | 1862 action = gtk_action_group_get_action(lw->action_group, "FloatTools"); |
1862 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->options.tools_float); | 1863 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->options.tools_float); |
1863 | 1864 |
1864 action = gtk_action_group_get_action(lw->action_group, "SBar"); | 1865 action = gtk_action_group_get_action(lw->action_group, "SBar"); |
1865 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->options.panels.info.enabled); | 1866 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), layout_bar_enabled(lw)); |
1866 | 1867 |
1867 action = gtk_action_group_get_action(lw->action_group, "SBarSort"); | 1868 action = gtk_action_group_get_action(lw->action_group, "SBarSort"); |
1868 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->options.panels.sort.enabled); | 1869 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->options.panels.sort.enabled); |
1869 | 1870 |
1870 action = gtk_action_group_get_action(lw->action_group, "HideToolbar"); | 1871 action = gtk_action_group_get_action(lw->action_group, "HideToolbar"); |
1939 *----------------------------------------------------------------------------- | 1940 *----------------------------------------------------------------------------- |
1940 * sidebars | 1941 * sidebars |
1941 *----------------------------------------------------------------------------- | 1942 *----------------------------------------------------------------------------- |
1942 */ | 1943 */ |
1943 | 1944 |
1945 static gboolean layout_bar_enabled(LayoutWindow *lw) | |
1946 { | |
1947 return lw->bar && GTK_WIDGET_VISIBLE(lw->bar); | |
1948 } | |
1949 | |
1944 static void layout_bar_destroyed(GtkWidget *widget, gpointer data) | 1950 static void layout_bar_destroyed(GtkWidget *widget, gpointer data) |
1945 { | 1951 { |
1946 LayoutWindow *lw = data; | 1952 LayoutWindow *lw = data; |
1947 | 1953 |
1948 lw->bar = NULL; | 1954 lw->bar = NULL; |
1949 | 1955 /* |
1950 if (lw->utility_box) | 1956 do not call layout_util_sync_views(lw) here |
1951 { | 1957 this is called either when whole layout is destroyed - no need for update |
1952 /* destroyed from within itself */ | 1958 or when the bar is replaced - sync is called by upper function at the end of whole operation |
1953 lw->options.panels.info.enabled = FALSE; | 1959 |
1954 layout_util_sync_views(lw); | 1960 */ |
1955 } | |
1956 } | 1961 } |
1957 | 1962 |
1958 static GList *layout_bar_list_cb(gpointer data) | 1963 static GList *layout_bar_list_cb(gpointer data) |
1959 { | 1964 { |
1960 LayoutWindow *lw = data; | 1965 LayoutWindow *lw = data; |
1961 | 1966 |
1962 return layout_selection_list(lw); | 1967 return layout_selection_list(lw); |
1963 } | 1968 } |
1964 | 1969 |
1965 static void layout_bar_sized(GtkWidget *widget, GtkAllocation *allocation, gpointer data) | 1970 static void layout_bar_set_default(LayoutWindow *lw) |
1966 { | 1971 { |
1967 LayoutWindow *lw = data; | 1972 GtkWidget *bar; |
1968 | |
1969 if (!lw->bar) return; | |
1970 | 1973 |
1971 lw->options.panels.info.width = allocation->width; | |
1972 } | |
1973 | |
1974 void layout_bar_new(LayoutWindow *lw, gboolean populate) | |
1975 { | |
1976 if (!lw->utility_box) return; | 1974 if (!lw->utility_box) return; |
1977 | 1975 |
1978 if (!lw->bar) | 1976 bar = bar_new_default(lw->utility_box); |
1979 { | 1977 |
1980 lw->bar = bar_new(lw->utility_box); | 1978 layout_bar_set(lw, bar); |
1981 | 1979 } |
1982 if (populate) | 1980 |
1983 { | 1981 static void layout_bar_close(LayoutWindow *lw) |
1984 bar_populate_default(lw->bar); | |
1985 } | |
1986 | |
1987 bar_set_selection_func(lw->bar, layout_bar_list_cb, lw); | |
1988 g_signal_connect(G_OBJECT(lw->bar), "destroy", | |
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); | |
1999 bar_set_fd(lw->bar, layout_image_get_fd(lw)); | |
2000 gtk_widget_show(lw->bar); | |
2001 } | |
2002 | |
2003 void layout_bar_close(LayoutWindow *lw) | |
2004 { | 1982 { |
2005 if (lw->bar) | 1983 if (lw->bar) |
2006 { | 1984 { |
2007 bar_close(lw->bar); | 1985 bar_close(lw->bar); |
2008 lw->bar = NULL; | 1986 lw->bar = NULL; |
2009 } | 1987 } |
2010 lw->options.panels.info.enabled = FALSE; | 1988 } |
2011 } | 1989 |
2012 | 1990 |
2013 static void layout_bar_hide(LayoutWindow *lw) | 1991 void layout_bar_set(LayoutWindow *lw, GtkWidget *bar) |
2014 { | 1992 { |
2015 if (lw->bar) | 1993 if (!lw->utility_box) return; |
1994 | |
1995 layout_bar_close(lw); /* if any */ | |
1996 | |
1997 if (!bar) return; | |
1998 lw->bar = bar; | |
1999 | |
2000 bar_set_selection_func(lw->bar, layout_bar_list_cb, lw); | |
2001 g_signal_connect(G_OBJECT(lw->bar), "destroy", | |
2002 G_CALLBACK(layout_bar_destroyed), lw); | |
2003 | |
2004 | |
2005 gtk_box_pack_start(GTK_BOX(lw->utility_box), lw->bar, FALSE, FALSE, 0); | |
2006 | |
2007 bar_set_fd(lw->bar, layout_image_get_fd(lw)); | |
2008 } | |
2009 | |
2010 | |
2011 void layout_bar_toggle(LayoutWindow *lw) | |
2012 { | |
2013 if (layout_bar_enabled(lw)) | |
2016 { | 2014 { |
2017 gtk_widget_hide(lw->bar); | 2015 gtk_widget_hide(lw->bar); |
2018 } | 2016 } |
2019 lw->options.panels.info.enabled = FALSE; | |
2020 } | |
2021 | |
2022 void layout_bar_toggle(LayoutWindow *lw) | |
2023 { | |
2024 if (lw->options.panels.info.enabled) | |
2025 { | |
2026 layout_bar_hide(lw); | |
2027 } | |
2028 else | 2017 else |
2029 { | 2018 { |
2030 layout_bar_new(lw, TRUE); | 2019 if (!lw->bar) |
2031 } | 2020 { |
2021 layout_bar_set_default(lw); | |
2022 } | |
2023 gtk_widget_show(lw->bar); | |
2024 } | |
2025 layout_util_sync_views(lw); | |
2032 } | 2026 } |
2033 | 2027 |
2034 static void layout_bar_new_image(LayoutWindow *lw) | 2028 static void layout_bar_new_image(LayoutWindow *lw) |
2035 { | 2029 { |
2036 if (!lw->bar || !lw->options.panels.info.enabled) return; | 2030 if (!layout_bar_enabled(lw)) return; |
2037 | 2031 |
2038 bar_set_fd(lw->bar, layout_image_get_fd(lw)); | 2032 bar_set_fd(lw->bar, layout_image_get_fd(lw)); |
2039 } | 2033 } |
2040 | 2034 |
2041 static void layout_bar_new_selection(LayoutWindow *lw, gint count) | 2035 static void layout_bar_new_selection(LayoutWindow *lw, gint count) |
2042 { | 2036 { |
2043 if (!lw->bar || !lw->options.panels.info.enabled) return; | 2037 if (!layout_bar_enabled(lw)) return; |
2044 | 2038 |
2045 // bar_info_selection(lw->bar_info, count - 1); | 2039 // bar_info_selection(lw->bar_info, count - 1); |
2046 } | |
2047 | |
2048 static void layout_bar_maint_renamed(LayoutWindow *lw) | |
2049 { | |
2050 if (!lw->bar || !lw->options.panels.info.enabled) return; | |
2051 | |
2052 // bar_maint_renamed(lw->bar_info, layout_image_get_fd(lw)); | |
2053 } | 2040 } |
2054 | 2041 |
2055 static void layout_bar_sort_destroyed(GtkWidget *widget, gpointer data) | 2042 static void layout_bar_sort_destroyed(GtkWidget *widget, gpointer data) |
2056 { | 2043 { |
2057 LayoutWindow *lw = data; | 2044 LayoutWindow *lw = data; |
2127 if (lw->options.panels.sort.enabled) | 2114 if (lw->options.panels.sort.enabled) |
2128 { | 2115 { |
2129 layout_bar_sort_new(lw); | 2116 layout_bar_sort_new(lw); |
2130 } | 2117 } |
2131 | 2118 |
2132 if (lw->options.panels.info.enabled) | |
2133 { | |
2134 layout_bar_new(lw, TRUE); | |
2135 } | |
2136 | |
2137 return lw->utility_box; | 2119 return lw->utility_box; |
2138 } | 2120 } |
2139 | 2121 |
2140 void layout_bars_close(LayoutWindow *lw) | 2122 void layout_bars_close(LayoutWindow *lw) |
2141 { | 2123 { |
2142 layout_bar_sort_close(lw); | 2124 layout_bar_sort_close(lw); |
2143 layout_bar_close(lw); | 2125 layout_bar_close(lw); |
2144 } | |
2145 | |
2146 void layout_bars_maint_renamed(LayoutWindow *lw) | |
2147 { | |
2148 layout_bar_maint_renamed(lw); | |
2149 } | 2126 } |
2150 | 2127 |
2151 static void layout_exif_window_destroy(GtkWidget *widget, gpointer data) | 2128 static void layout_exif_window_destroy(GtkWidget *widget, gpointer data) |
2152 { | 2129 { |
2153 LayoutWindow *lw = data; | 2130 LayoutWindow *lw = data; |