Replace Layout icon_view field by more generic file_view_type.
authorLaurent Monin <geeqie@norz.org>
Sat, 3 May 2008 11:34:13 +0000 (11:34 +0000)
committerLaurent Monin <geeqie@norz.org>
Sat, 3 May 2008 11:34:13 +0000 (11:34 +0000)
Replace option layout.view_as_icons by layout.file_view_type.

src/layout.c
src/layout.h
src/layout_util.c
src/main.c
src/options.c
src/options.h
src/rcfile.c
src/typedefs.h
src/view_dir.c
src/view_file.h

index 581883c..43430e4 100644 (file)
@@ -26,6 +26,7 @@
 #include "pixbuf_util.h"
 #include "utilops.h"
 #include "view_dir.h"
+#include "view_file.h"
 #include "view_file_list.h"
 #include "view_file_icon.h"
 #include "ui_bookmark.h"
@@ -742,7 +743,11 @@ static void layout_icon_thumb_cb(ViewFileIcon *vfi, gdouble val, const gchar *te
 
 static GtkWidget *layout_list_new(LayoutWindow *lw)
 {
-       if (lw->icon_view)
+       GtkWidget *widget = NULL;
+
+       switch (lw->file_view_type)
+       {
+       case FILEVIEW_ICON:
                {
                lw->vfi = vficon_new(NULL);
                vficon_set_layout(lw->vfi, lw);
@@ -751,19 +756,26 @@ static GtkWidget *layout_list_new(LayoutWindow *lw)
                vficon_set_thumb_status_func(lw->vfi, layout_icon_thumb_cb, lw);
                /* FIXME vficon_marks_set(lw->vfi, lw->marks_enabled); */
 
-               return lw->vfi->widget;
+               widget = lw->vfi->widget;
                }
+               break;
+       case FILEVIEW_LIST:
+               {
+               lw->vfl = vflist_new(NULL);
+               vflist_set_layout(lw->vfl, lw);
 
-       lw->vfl = vflist_new(NULL);
-       vflist_set_layout(lw->vfl, lw);
+               vflist_set_status_func(lw->vfl, layout_list_status_cb, lw);
+               vflist_set_thumb_status_func(lw->vfl, layout_list_thumb_cb, lw);
 
-       vflist_set_status_func(lw->vfl, layout_list_status_cb, lw);
-       vflist_set_thumb_status_func(lw->vfl, layout_list_thumb_cb, lw);
+               vflist_marks_set(lw->vfl, lw->marks_enabled);
+               vflist_thumbs_set(lw->vfl, lw->thumbs_enabled);
 
-       vflist_marks_set(lw->vfl, lw->marks_enabled);
-       vflist_thumbs_set(lw->vfl, lw->thumbs_enabled);
+               widget = lw->vfl->widget;
+               }
+               break;
+       }
 
-       return lw->vfl->widget;
+       return widget;
 }
 
 static void layout_list_sync_thumb(LayoutWindow *lw)
@@ -1162,24 +1174,24 @@ gint layout_geometry_get_dividers(LayoutWindow *lw, gint *h, gint *v)
        return TRUE;
 }
 
-void layout_views_set(LayoutWindow *lw, DirViewType type, gint icons)
+void layout_views_set(LayoutWindow *lw, DirViewType dir_view_type, FileViewType file_view_type)
 {
        if (!layout_valid(&lw)) return;
 
-       if (lw->dir_view_type == type && lw->icon_view == icons) return;
+       if (lw->dir_view_type == dir_view_type && lw->file_view_type == file_view_type) return;
 
-       lw->dir_view_type = type;
-       lw->icon_view = icons;
+       lw->dir_view_type = dir_view_type;
+       lw->file_view_type = file_view_type;
 
        layout_style_set(lw, -1, NULL);
 }
 
-gint layout_views_get(LayoutWindow *lw, DirViewType *type, gint *icons)
+gint layout_views_get(LayoutWindow *lw, DirViewType *dir_view_type, FileViewType *file_view_type)
 {
        if (!layout_valid(&lw)) return FALSE;
 
-       *type = lw->dir_view_type;
-       *icons = lw->icon_view;
+       *dir_view_type = lw->dir_view_type;
+       *file_view_type = lw->file_view_type;
 
        return TRUE;
 }
@@ -1918,7 +1930,7 @@ LayoutWindow *layout_new_with_geometry(const gchar *path, gint popped, gint hidd
        layout_config_parse(options->layout.style, options->layout.order,
                            &lw->dir_location,  &lw->file_location, &lw->image_location);
        lw->dir_view_type = CLAMP(options->layout.dir_view_type, 0, VIEW_DIR_TYPES_COUNT - 1);
-       lw->icon_view = options->layout.view_as_icons;
+       lw->file_view_type = CLAMP(options->layout.file_view_type, 0, VIEW_FILE_TYPES_COUNT - 1);
 
        /* divider positions */
 
index cda289a..f16ef2c 100644 (file)
@@ -68,8 +68,8 @@ gint layout_sort_get(LayoutWindow *lw, SortType *type, gint *ascend);
 gint layout_geometry_get(LayoutWindow *lw, gint *x, gint *y, gint *w, gint *h);
 gint layout_geometry_get_dividers(LayoutWindow *lw, gint *h, gint *v);
 
-void layout_views_set(LayoutWindow *lw, DirViewType type, gint icons);
-gint layout_views_get(LayoutWindow *lw, DirViewType *type, gint *icons);
+void layout_views_set(LayoutWindow *lw, DirViewType dir_view_type, FileViewType file_view_type);
+gint layout_views_get(LayoutWindow *lw, DirViewType *dir_view_type, FileViewType *file_view_type);
 
 void layout_status_update(LayoutWindow *lw, const gchar *text);
 
index a7d09bc..32ea352 100644 (file)
@@ -514,7 +514,7 @@ static void layout_menu_list_cb(GtkRadioAction *action, GtkRadioAction *current,
        if (lw->full_screen)
                layout_image_full_screen_stop(lw);
 
-       layout_views_set(lw, lw->dir_view_type, (gtk_radio_action_get_current_value(action) == 1));
+       layout_views_set(lw, lw->dir_view_type, (gtk_radio_action_get_current_value(action) == 1) ? FILEVIEW_ICON : FILEVIEW_LIST);
 }
 
 static void layout_menu_view_dir_as_cb(GtkRadioAction *action, GtkRadioAction *current, gpointer data)
@@ -523,7 +523,7 @@ static void layout_menu_view_dir_as_cb(GtkRadioAction *action, GtkRadioAction *c
        if (lw->full_screen)
                layout_image_full_screen_stop(lw);
 
-       layout_views_set(lw, (DirViewType) gtk_radio_action_get_current_value(action), lw->icon_view);
+       layout_views_set(lw, (DirViewType) gtk_radio_action_get_current_value(action), lw->file_view_type);
 }
 
 static void layout_menu_view_in_new_window_cb(GtkAction *action, gpointer data)
@@ -1581,7 +1581,7 @@ static void layout_util_sync_views(LayoutWindow *lw)
        radio_action_set_current_value(GTK_RADIO_ACTION(action), lw->dir_view_type);
 
        action = gtk_action_group_get_action(lw->action_group, "ViewIcons");
-       gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->icon_view);
+       gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->file_view_type);
 
        action = gtk_action_group_get_action(lw->action_group, "FloatTools");
        gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->tools_float);
@@ -1613,10 +1613,10 @@ void layout_util_sync_thumb(LayoutWindow *lw)
 
        action = gtk_action_group_get_action(lw->action_group, "Thumbnails");
        gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->thumbs_enabled);
-       g_object_set(action, "sensitive", !lw->icon_view, NULL);
+       g_object_set(action, "sensitive", (lw->file_view_type == FILEVIEW_LIST), NULL);
 
        gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(lw->thumb_button), lw->thumbs_enabled);
-       gtk_widget_set_sensitive(lw->thumb_button, !lw->icon_view);
+       gtk_widget_set_sensitive(lw->thumb_button, (lw->file_view_type == FILEVIEW_LIST));
 }
 
 void layout_util_sync(LayoutWindow *lw)
index aa62fdb..38ce586 100644 (file)
@@ -1214,7 +1214,7 @@ static void exit_program_final(void)
 
        layout_geometry_get_dividers(NULL, &options->layout.main_window.hdivider_pos, &options->layout.main_window.vdivider_pos);
 
-       layout_views_get(NULL, &options->layout.dir_view_type, &options->layout.view_as_icons);
+       layout_views_get(NULL, &options->layout.dir_view_type, &options->layout.file_view_type);
 
        options->layout.show_thumbnails = layout_thumb_get(NULL);
        options->layout.show_marks = layout_marks_get(NULL);
index 84df49d..b680c9f 100644 (file)
@@ -73,6 +73,7 @@ ConfOptions *init_options(ConfOptions *options)
        options->image_overlay.common.template_string = NULL;
 
        options->layout.dir_view_type = DIRVIEW_LIST;
+       options->layout.file_view_type = FILEVIEW_LIST;
        options->layout.float_window.h = 450;
        options->layout.float_window.vdivider_pos = -1;
        options->layout.float_window.w = 260;
@@ -94,7 +95,6 @@ ConfOptions *init_options(ConfOptions *options)
        options->layout.tools_float = FALSE;
        options->layout.tools_hidden = FALSE;
        options->layout.tools_restore_state = FALSE;
-       options->layout.view_as_icons = FALSE;
 
        options->lazy_image_sync = FALSE;
        options->mousewheel_scrolls = FALSE;
index 7aff69a..ed9a2a2 100644 (file)
@@ -141,8 +141,8 @@ struct _ConfOptions
                gchar *order;
                gint style;
 
-               gint view_as_icons;
                DirViewType dir_view_type;
+               FileViewType file_view_type;
 
                gint show_thumbnails;
                gint show_marks;
index 4d382e9..b99d4e4 100644 (file)
@@ -338,8 +338,8 @@ void save_options(void)
 
        WRITE_INT(layout.style);
        WRITE_CHAR(layout.order);
-       WRITE_BOOL(layout.view_as_icons);
        WRITE_UINT(layout.dir_view_type);
+       WRITE_UINT(layout.file_view_type);
        WRITE_BOOL(layout.show_marks);
        WRITE_BOOL(layout.show_thumbnails);
        WRITE_SEPARATOR();
@@ -637,8 +637,11 @@ void load_options(void)
 
                READ_INT(layout.style);
                READ_CHAR(layout.order);
-               READ_BOOL(layout.view_as_icons);
+               
+               COMPAT_READ_UINT(layout.view_as_icons, layout.file_view_type); /* 2008/05/03 */
+
                READ_UINT(layout.dir_view_type);
+               READ_UINT(layout.file_view_type);
                READ_BOOL(layout.show_marks);
                READ_BOOL(layout.show_thumbnails);
 
index 0263558..51a8001 100644 (file)
@@ -507,7 +507,6 @@ struct _LayoutWindow
        ViewFileIcon *vfi;
        GtkWidget *file_view;
 
-       gint icon_view;
        SortType sort_method;
        gint sort_ascend;
 
index 2104579..7755d4b 100644 (file)
@@ -458,7 +458,7 @@ static void vd_pop_submenu_dir_view_as_cb(GtkWidget *widget, gpointer data)
        ViewDir *vd = data;
 
        DirViewType new_type = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), VIEW_DIR_AS_SUBMENU_KEY));
-       layout_views_set(vd->layout, new_type, vd->layout->icon_view);
+       layout_views_set(vd->layout, new_type, vd->layout->file_view_type);
 }
 
 static void vd_pop_menu_refresh_cb(GtkWidget *widget, gpointer data)
index b8110d0..f7fe02d 100644 (file)
@@ -12,4 +12,6 @@
 #ifndef VIEW_FILE_H
 #define VIEW_FILE_H
 
+#define VIEW_FILE_TYPES_COUNT 2
+
 #endif /* VIEW_FILE_H */