Trim trailing white spaces.
[geeqie.git] / src / layout.c
index 8597802..08a8f69 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Geeqie
  * (C) 2006 John Ellis
- * Copyright (C) 2008 - 2009 The Geeqie Team
+ * Copyright (C) 2008 - 2012 The Geeqie Team
  *
  * Author: John Ellis
  *
@@ -52,7 +52,6 @@
 #define TOOLWINDOW_DEF_HEIGHT 450
 
 #define PROGRESS_WIDTH 150
-#define PIXEL_LABEL_WIDTH 130
 #define ZOOM_LABEL_WIDTH 64
 
 #define PANE_DIVIDER_SIZE 10
@@ -243,11 +242,11 @@ static void layout_path_entry_cb(const gchar *path, gpointer data)
        g_free(buf);
 }
 
-static void layout_vd_select_cb(ViewDir *vd, const gchar *path, gpointer data)
+static void layout_vd_select_cb(ViewDir *vd, FileData *fd, gpointer data)
 {
        LayoutWindow *lw = data;
 
-       layout_set_path(lw, path);
+       layout_set_fd(lw, fd);
 }
 
 static void layout_path_entry_tab_append_cb(const gchar *path, gpointer data, gint n)
@@ -266,6 +265,7 @@ static GtkWidget *layout_tool_setup(LayoutWindow *lw)
        GtkWidget *box;
        GtkWidget *menu_bar;
        GtkWidget *tabcomp;
+       GtkWidget *toolbar;
 
        box = gtk_vbox_new(FALSE, 0);
 
@@ -273,9 +273,9 @@ static GtkWidget *layout_tool_setup(LayoutWindow *lw)
        gtk_box_pack_start(GTK_BOX(box), menu_bar, FALSE, FALSE, 0);
        gtk_widget_show(menu_bar);
 
-       layout_actions_toolbar(lw);
-       gtk_box_pack_start(GTK_BOX(box), lw->toolbar, FALSE, FALSE, 0);
-       if (!lw->options.toolbar_hidden) gtk_widget_show(lw->toolbar);
+       toolbar = layout_actions_toolbar(lw, TOOLBAR_MAIN);
+       gtk_box_pack_start(GTK_BOX(box), toolbar, FALSE, FALSE, 0);
+       if (!lw->options.toolbar_hidden) gtk_widget_show(toolbar);
 
        tabcomp = tab_completion_new_with_history(&lw->path_entry, NULL, "path_list", -1,
                                                  layout_path_entry_cb, lw);
@@ -284,7 +284,7 @@ static GtkWidget *layout_tool_setup(LayoutWindow *lw)
        gtk_box_pack_start(GTK_BOX(box), tabcomp, FALSE, FALSE, 0);
        gtk_widget_show(tabcomp);
 
-       g_signal_connect(G_OBJECT(lw->path_entry->parent), "changed",
+       g_signal_connect(G_OBJECT(gtk_widget_get_parent(lw->path_entry)), "changed",
                         G_CALLBACK(layout_path_entry_changed_cb), lw);
 
        lw->vd = vd_new(lw->options.dir_view_type, lw->dir_fd);
@@ -332,11 +332,7 @@ static void layout_sort_menu_ascend_cb(GtkWidget *widget, gpointer data)
 static void layout_sort_menu_hide_cb(GtkWidget *widget, gpointer data)
 {
        /* destroy the menu */
-#if GTK_CHECK_VERSION(2,12,0)
        g_object_unref(widget);
-#else
-       gtk_widget_unref(GTK_WIDGET(widget));
-#endif
 }
 
 static void layout_sort_button_press_cb(GtkWidget *widget, gpointer data)
@@ -391,90 +387,12 @@ static GtkWidget *layout_sort_button(LayoutWindow *lw)
        return button;
 }
 
-#if 0
-static GtkWidget *layout_color_button(LayoutWindow *lw)
-{
-       GtkWidget *button;
-       GtkWidget *image;
-       gboolean enable;
-
-       button = gtk_button_new();
-       image = gtk_image_new_from_stock(GTK_STOCK_SELECT_COLOR, GTK_ICON_SIZE_MENU);
-       gtk_container_add(GTK_CONTAINER(button), image);
-       gtk_widget_show(image);
-       g_signal_connect(G_OBJECT(button), "clicked",
-                        G_CALLBACK(layout_color_button_press_cb), lw);
-       gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
-
-#ifdef HAVE_LCMS
-       enable = (lw->image) ? lw->image->color_profile_enable : FALSE;
-#else
-       enable = FALSE;
-#endif
-       gtk_widget_set_sensitive(image, enable);
-
-       return button;
-}
-#endif
-/*
- *-----------------------------------------------------------------------------
- * write button
- *-----------------------------------------------------------------------------
- */
-
-static void layout_write_button_press_cb(GtkWidget *widget, gpointer data)
-{
-       metadata_write_queue_confirm(NULL, NULL);
-}
-
-static GtkWidget *layout_write_button(LayoutWindow *lw)
-{
-       GtkWidget *button;
-       GtkWidget *image;
-
-       button = gtk_button_new();
-       image = gtk_image_new_from_stock(GTK_STOCK_SAVE, GTK_ICON_SIZE_MENU);
-       gtk_container_add(GTK_CONTAINER(button), image);
-       gtk_widget_show(image);
-       g_signal_connect(G_OBJECT(button), "clicked",
-                        G_CALLBACK(layout_write_button_press_cb), lw);
-       gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
-       
-       gtk_widget_set_sensitive(button, metadata_queue_length() > 0);
-       
-       return button;
-}
-
-
 /*
  *-----------------------------------------------------------------------------
  * status bar
  *-----------------------------------------------------------------------------
  */
 
-void layout_status_update_write(LayoutWindow *lw)
-{
-       if (!layout_valid(&lw)) return;
-       if (!lw->info_write) return;
-
-       gtk_widget_set_sensitive(lw->info_write, metadata_queue_length() > 0);
-       /* FIXME: maybe show also the number of files */
-}
-
-void layout_status_update_write_all(void)
-{
-       GList *work;
-
-       work = layout_window_list;
-       while (work)
-               {
-               LayoutWindow *lw = work->data;
-               work = work->next;
-
-               layout_status_update_write(lw);
-               }
-}
-
 
 void layout_status_update_progress(LayoutWindow *lw, gdouble val, const gchar *text)
 {
@@ -560,8 +478,9 @@ void layout_status_update_info(LayoutWindow *lw, const gchar *text)
 void layout_status_update_image(LayoutWindow *lw)
 {
        guint64 n;
-
+       
        if (!layout_valid(&lw) || !lw->image) return;
+       if (!lw->info_zoom || !lw->info_details) return; /*called from layout_style_set */
 
        n = layout_list_count(lw, NULL);
        
@@ -608,6 +527,7 @@ void layout_status_update_image(LayoutWindow *lw)
                gtk_label_set_text(GTK_LABEL(lw->info_details), text);
                g_free(text);
                }
+       layout_util_sync_color(lw); /* update color button */
 }
 
 void layout_status_update_all(LayoutWindow *lw)
@@ -615,7 +535,7 @@ void layout_status_update_all(LayoutWindow *lw)
        layout_status_update_progress(lw, 0.0, NULL);
        layout_status_update_info(lw, NULL);
        layout_status_update_image(lw);
-       layout_status_update_write(lw);
+       layout_util_status_update_write(lw);
 }
 
 static GtkWidget *layout_status_label(gchar *text, GtkWidget *box, gboolean start, gint size, gboolean expand)
@@ -646,6 +566,8 @@ static GtkWidget *layout_status_label(gchar *text, GtkWidget *box, gboolean star
 static void layout_status_setup(LayoutWindow *lw, GtkWidget *box, gboolean small_format)
 {
        GtkWidget *hbox;
+       GtkWidget *toolbar;
+       GtkWidget *toolbar_frame;
 
        if (lw->info_box) return;
 
@@ -679,11 +601,6 @@ static void layout_status_setup(LayoutWindow *lw, GtkWidget *box, gboolean small
        gtk_box_pack_start(GTK_BOX(hbox), lw->info_sort, FALSE, FALSE, 0);
        gtk_widget_show(lw->info_sort);
 
-       lw->info_write = layout_write_button(lw);
-       gtk_widget_show(lw->info_write);
-
-       if (small_format) gtk_box_pack_end(GTK_BOX(hbox), lw->info_write, FALSE, FALSE, 0);
-
        lw->info_status = layout_status_label(NULL, lw->info_box, TRUE, 0, (!small_format));
 
        if (small_format)
@@ -692,15 +609,24 @@ static void layout_status_setup(LayoutWindow *lw, GtkWidget *box, gboolean small
                gtk_box_pack_start(GTK_BOX(lw->info_box), hbox, FALSE, FALSE, 0);
                gtk_widget_show(hbox);
                }
-       else
-               {
-               hbox = lw->info_box;
-               }
        lw->info_details = layout_status_label(NULL, hbox, TRUE, 0, TRUE);
-       if (!small_format) gtk_box_pack_start(GTK_BOX(hbox), lw->info_write, FALSE, FALSE, 0);
-       lw->info_pixel = layout_status_label(NULL, hbox, FALSE, PIXEL_LABEL_WIDTH, TRUE);
-       if (lw->options.info_pixel_hidden) gtk_widget_hide(gtk_widget_get_parent(lw->info_pixel));
+       toolbar = layout_actions_toolbar(lw, TOOLBAR_STATUS);
+       
+       toolbar_frame = gtk_frame_new(NULL);
+       gtk_frame_set_shadow_type(GTK_FRAME(toolbar_frame), GTK_SHADOW_IN);
+       gtk_container_add(GTK_CONTAINER(toolbar_frame), toolbar);
+       gtk_widget_show(toolbar_frame);
+       gtk_widget_show(toolbar);
+       gtk_box_pack_end(GTK_BOX(hbox), toolbar_frame, FALSE, FALSE, 0);
        lw->info_zoom = layout_status_label(NULL, hbox, FALSE, ZOOM_LABEL_WIDTH, FALSE);
+       if (small_format)
+               {
+               hbox = gtk_hbox_new(FALSE, 0);
+               gtk_box_pack_start(GTK_BOX(lw->info_box), hbox, FALSE, FALSE, 0);
+               gtk_widget_show(hbox);
+               }
+       lw->info_pixel = layout_status_label(NULL, hbox, FALSE, 0, small_format); /* expand only in small format */
+       if (!lw->options.show_info_pixel) gtk_widget_hide(gtk_widget_get_parent(lw->info_pixel));
 }
 
 /*
@@ -757,9 +683,6 @@ static void layout_list_sync_marks(LayoutWindow *lw)
 static void layout_list_scroll_to_subpart(LayoutWindow *lw, const gchar *needle)
 {
        if (!lw) return;
-#if 0
-       if (lw->vf) vf_scroll_to_subpart(lw->vf, needle);
-#endif
 }
 
 GList *layout_list(LayoutWindow *lw)
@@ -885,6 +808,14 @@ void layout_selection_to_mark(LayoutWindow *lw, gint mark, SelectionToMarkMode m
        layout_status_update_info(lw, NULL); /* osd in fullscreen mode */
 }
 
+void layout_mark_filter_toggle(LayoutWindow *lw, gint mark)
+{
+       if (!layout_valid(&lw)) return;
+
+       if (lw->vf) vf_mark_filter_toggle(lw->vf, mark);
+}
+
+
 /*
  *-----------------------------------------------------------------------------
  * access
@@ -914,7 +845,7 @@ gboolean layout_set_path(LayoutWindow *lw, const gchar *path)
 
        if (!path) return FALSE;
        
-       fd = file_data_new_simple(path);
+       fd = file_data_new_group(path);
        ret = layout_set_fd(lw, fd);
        file_data_unref(fd);
        return ret;
@@ -924,6 +855,7 @@ gboolean layout_set_path(LayoutWindow *lw, const gchar *path)
 gboolean layout_set_fd(LayoutWindow *lw, FileData *fd)
 {
        gboolean have_file = FALSE;
+       gboolean dir_changed = TRUE;
 
        if (!layout_valid(&lw)) return FALSE;
 
@@ -951,6 +883,7 @@ gboolean layout_set_fd(LayoutWindow *lw, FileData *fd)
                if (lw->dir_fd && strcmp(lw->dir_fd->path, base) == 0)
                        {
                        g_free(base);
+                       dir_changed = FALSE;
                        }
                else if (isdir(base))
                        {
@@ -959,7 +892,7 @@ gboolean layout_set_fd(LayoutWindow *lw, FileData *fd)
                                file_data_unregister_real_time_monitor(lw->dir_fd);
                                file_data_unref(lw->dir_fd);
                                }
-                       lw->dir_fd = file_data_new_simple(base);
+                       lw->dir_fd = file_data_new_dir(base);
                        file_data_register_real_time_monitor(lw->dir_fd);
                        g_free(base);
                        }
@@ -994,8 +927,8 @@ gboolean layout_set_fd(LayoutWindow *lw, FileData *fd)
                layout_image_set_index(lw, 0);
                }
 
-       if (options->metadata.confirm_on_dir_change)
-               metadata_write_queue_confirm(NULL, NULL);
+       if (options->metadata.confirm_on_dir_change && dir_changed)
+               metadata_write_queue_confirm(FALSE, NULL, NULL);
 
        return TRUE;
 }
@@ -1068,7 +1001,7 @@ void layout_sort_set(LayoutWindow *lw, SortType type, gboolean ascend)
        lw->sort_method = type;
        lw->sort_ascend = ascend;
 
-       if (lw->info_sort) gtk_label_set_text(GTK_LABEL(GTK_BIN(lw->info_sort)->child),
+       if (lw->info_sort) gtk_label_set_text(GTK_LABEL(gtk_bin_get_child(GTK_BIN(lw->info_sort))),
                                              sort_type_get_text(type));
        layout_list_sync_sort(lw);
 }
@@ -1085,30 +1018,48 @@ gboolean layout_sort_get(LayoutWindow *lw, SortType *type, gboolean *ascend)
 
 gboolean layout_geometry_get(LayoutWindow *lw, gint *x, gint *y, gint *w, gint *h)
 {
+       GdkWindow *window;
        if (!layout_valid(&lw)) return FALSE;
-
-       gdk_window_get_root_origin(lw->window->window, x, y);
-       gdk_drawable_get_size(lw->window->window, w, h);
+       
+       window = gtk_widget_get_window(lw->window);
+       gdk_window_get_root_origin(window, x, y);
+       *w = gdk_window_get_width(window);
+       *h = gdk_window_get_height(window);
 
        return TRUE;
 }
 
 gboolean layout_geometry_get_dividers(LayoutWindow *lw, gint *h, gint *v)
 {
+       GtkAllocation h_allocation;
+       GtkAllocation v_allocation;
+       
        if (!layout_valid(&lw)) return FALSE;
+       
+       if (lw->h_pane)
+               {
+               GtkWidget *child = gtk_paned_get_child1(GTK_PANED(lw->h_pane));
+               gtk_widget_get_allocation(child, &h_allocation);
+               }
 
-       if (lw->h_pane && GTK_PANED(lw->h_pane)->child1->allocation.x >= 0)
+       if (lw->v_pane)
                {
-               *h = GTK_PANED(lw->h_pane)->child1->allocation.width;
+               GtkWidget *child = gtk_paned_get_child1(GTK_PANED(lw->v_pane));
+               gtk_widget_get_allocation(child, &v_allocation);
+               }
+
+       if (lw->h_pane && h_allocation.x >= 0)
+               {
+               *h = h_allocation.width;
                }
        else if (h != &lw->options.main_window.hdivider_pos)
                {
                *h = lw->options.main_window.hdivider_pos;
                }
 
-       if (lw->v_pane && GTK_PANED(lw->v_pane)->child1->allocation.x >= 0)
+       if (lw->v_pane && v_allocation.x >= 0)
                {
-               *v = GTK_PANED(lw->v_pane)->child1->allocation.height;
+               *v = v_allocation.height;
                }
        else if (v != &lw->options.main_window.vdivider_pos)
                {
@@ -1202,9 +1153,11 @@ static void layout_location_compute(LayoutLocation l1, LayoutLocation l2,
 
 gboolean layout_geometry_get_tools(LayoutWindow *lw, gint *x, gint *y, gint *w, gint *h, gint *divider_pos)
 {
+       GdkWindow *window;
+       GtkAllocation allocation;
        if (!layout_valid(&lw)) return FALSE;
 
-       if (!lw->tools || !GTK_WIDGET_VISIBLE(lw->tools))
+       if (!lw->tools || !gtk_widget_get_visible(lw->tools))
                {
                /* use the stored values (sort of breaks success return value) */
 
@@ -1213,16 +1166,19 @@ gboolean layout_geometry_get_tools(LayoutWindow *lw, gint *x, gint *y, gint *w,
                return FALSE;
                }
 
-       gdk_window_get_root_origin(lw->tools->window, x, y);
-       gdk_drawable_get_size(lw->tools->window, w, h);
+       window = gtk_widget_get_window(lw->window);
+       gdk_window_get_root_origin(window, x, y);
+       *w = gdk_window_get_width(window);
+       *h = gdk_window_get_height(window);
+       gtk_widget_get_allocation(gtk_paned_get_child1(GTK_PANED(lw->tools_pane)), &allocation);
 
        if (GTK_IS_VPANED(lw->tools_pane))
                {
-               *divider_pos = GTK_PANED(lw->tools_pane)->child1->allocation.height;
+               *divider_pos = allocation.height;
                }
        else
                {
-               *divider_pos = GTK_PANED(lw->tools_pane)->child1->allocation.width;
+               *divider_pos = allocation.width;
                }
 
        return TRUE;
@@ -1240,7 +1196,7 @@ static void layout_tools_hide(LayoutWindow *lw, gboolean hide)
 
        if (hide)
                {
-               if (GTK_WIDGET_VISIBLE(lw->tools))
+               if (gtk_widget_get_visible(lw->tools))
                        {
                        layout_tools_geometry_sync(lw);
                        gtk_widget_hide(lw->tools);
@@ -1248,7 +1204,7 @@ static void layout_tools_hide(LayoutWindow *lw, gboolean hide)
                }
        else
                {
-               if (!GTK_WIDGET_VISIBLE(lw->tools))
+               if (!gtk_widget_get_visible(lw->tools))
                        {
                        gtk_widget_show(lw->tools);
                        if (lw->vf) vf_refresh(lw->vf);
@@ -1276,10 +1232,6 @@ static void layout_tools_setup(LayoutWindow *lw, GtkWidget *tools, GtkWidget *fi
 
        vertical = (layout_location_single(lw->image_location) && !layout_location_vertical(lw->image_location)) ||
                   (!layout_location_single(lw->image_location) && layout_location_vertical(layout_grid_compass(lw)));
-#if 0
-       layout_location_compute(lw->dir_location, lw->file_location,
-                               tools, files, &w1, &w2);
-#endif
        /* for now, tools/dir are always first in order */
        w1 = tools;
        w2 = files;
@@ -1320,7 +1272,7 @@ static void layout_tools_setup(LayoutWindow *lw, GtkWidget *tools, GtkWidget *fi
                {
                layout_tools_geometry_sync(lw);
                /* dump the contents */
-               gtk_widget_destroy(GTK_BIN(lw->tools)->child);
+               gtk_widget_destroy(gtk_bin_get_child(GTK_BIN(lw->tools)));
                }
 
        layout_actions_add_window(lw, lw->tools);
@@ -1449,18 +1401,17 @@ void layout_split_change(LayoutWindow *lw, ImageSplitMode mode)
                if (lw->split_images[i])
                        {
                        gtk_widget_hide(lw->split_images[i]->widget);
-                       if (lw->split_images[i]->widget->parent != lw->utility_paned)
-                               gtk_container_remove(GTK_CONTAINER(lw->split_images[i]->widget->parent), lw->split_images[i]->widget);
+                       if (gtk_widget_get_parent(lw->split_images[i]->widget) != lw->utility_paned)
+                               gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(lw->split_images[i]->widget)), lw->split_images[i]->widget);
                        }
                }
        gtk_container_remove(GTK_CONTAINER(lw->utility_paned), lw->split_image_widget);
 
        image = layout_image_setup_split(lw, mode);
 
-//     gtk_box_pack_start(GTK_BOX(lw->utility_box), image, TRUE, TRUE, 0);
-//     gtk_box_reorder_child(GTK_BOX(lw->utility_box), image, 0);
        gtk_paned_pack1(GTK_PANED(lw->utility_paned), image, TRUE, FALSE);
        gtk_widget_show(image);
+       layout_util_sync(lw);
 }
 
 static void layout_grid_setup(LayoutWindow *lw)
@@ -1578,6 +1529,7 @@ static void layout_grid_setup(LayoutWindow *lw)
 void layout_style_set(LayoutWindow *lw, gint style, const gchar *order)
 {
        FileData *dir_fd;
+       gint i;
 
        if (!layout_valid(&lw)) return;
 
@@ -1598,7 +1550,7 @@ void layout_style_set(LayoutWindow *lw, gint style, const gchar *order)
 
        /* remember state */
 
-       layout_image_slideshow_stop(lw);
+       /* layout_image_slideshow_stop(lw); slideshow should survive */
        layout_image_full_screen_stop(lw);
 
        dir_fd = lw->dir_fd;
@@ -1607,11 +1559,12 @@ void layout_style_set(LayoutWindow *lw, gint style, const gchar *order)
 
        layout_geometry_get_dividers(lw, &lw->options.main_window.hdivider_pos, &lw->options.main_window.vdivider_pos);
 
-       /* preserve utility_box (image + sidebars), menu_bar and toolbar to be reused later in layout_grid_setup */
+       /* preserve utility_box (image + sidebars), menu_bar and toolbars to be reused later in layout_grid_setup */
        /* lw->image is preserved together with lw->utility_box */
-       if (lw->utility_box) gtk_container_remove(GTK_CONTAINER(lw->utility_box->parent), lw->utility_box);
-       if (lw->menu_bar) gtk_container_remove(GTK_CONTAINER(lw->menu_bar->parent), lw->menu_bar);
-       if (lw->toolbar) gtk_container_remove(GTK_CONTAINER(lw->toolbar->parent), lw->toolbar);
+       if (lw->utility_box) gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(lw->utility_box)), lw->utility_box);
+       if (lw->menu_bar) gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(lw->menu_bar)), lw->menu_bar);
+       for (i = 0; i < TOOLBAR_COUNT; i++)
+               if (lw->toolbar[i]) gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(lw->toolbar[i])), lw->toolbar[i]);
 
        /* clear it all */
 
@@ -1678,11 +1631,19 @@ void layout_colors_update(void)
        work = layout_window_list;
        while (work)
                {
+               gint i;
                LayoutWindow *lw = work->data;
                work = work->next;
-
+               
                if (!lw->image) continue;
-               image_background_set_color(lw->image, options->image.use_custom_border_color ? &options->image.border_color : NULL);
+
+               for (i = 0; i < MAX_SPLIT_IMAGES; i++)
+                       {
+                       if (!lw->split_images[i]) continue;
+                       image_background_set_color_from_options(lw->split_images[i], !!lw->full_screen);
+                       }
+               
+               image_background_set_color_from_options(lw->image, !!lw->full_screen);
                }
 }
 
@@ -1765,32 +1726,34 @@ void layout_toolbar_toggle(LayoutWindow *lw)
 
        if (lw->options.toolbar_hidden)
                {
-               if (GTK_WIDGET_VISIBLE(lw->toolbar)) gtk_widget_hide(lw->toolbar);
+               if (gtk_widget_get_visible(lw->toolbar[TOOLBAR_MAIN])) gtk_widget_hide(lw->toolbar[TOOLBAR_MAIN]);
                }
        else
                {
-               if (!GTK_WIDGET_VISIBLE(lw->toolbar)) gtk_widget_show(lw->toolbar);
+               if (!gtk_widget_get_visible(lw->toolbar[TOOLBAR_MAIN])) gtk_widget_show(lw->toolbar[TOOLBAR_MAIN]);
                }
 }
 
-void layout_info_pixel_toggle(LayoutWindow *lw)
+void layout_info_pixel_set(LayoutWindow *lw, gboolean show)
 {
        GtkWidget *frame;
        
        if (!layout_valid(&lw)) return;
        if (!lw->info_pixel) return;
 
-       lw->options.info_pixel_hidden = !lw->options.info_pixel_hidden;
+       lw->options.show_info_pixel = show;
 
        frame = gtk_widget_get_parent(lw->info_pixel);
-       if (lw->options.info_pixel_hidden)
+       if (!lw->options.show_info_pixel)
                {
-               if (GTK_WIDGET_VISIBLE(frame)) gtk_widget_hide(frame);
+               gtk_widget_hide(frame);
                }
        else
                {
-               if (!GTK_WIDGET_VISIBLE(frame)) gtk_widget_show(frame);
+               gtk_widget_show(frame);
                }
+       
+       g_signal_emit_by_name (lw->image->pr, "update-pixel");
 }
 
 /*
@@ -1923,7 +1886,7 @@ void layout_show_config_window(LayoutWindow *lw)
        button = pref_button_new(NULL, GTK_STOCK_OK, NULL, FALSE,
                                 G_CALLBACK(layout_config_ok_cb), lc);
        gtk_container_add(GTK_CONTAINER(hbox), button);
-       GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
+       gtk_widget_set_can_default(button, TRUE);
        gtk_widget_grab_default(button);
        gtk_widget_show(button);
 
@@ -1934,17 +1897,17 @@ void layout_show_config_window(LayoutWindow *lw)
        gtk_container_add(GTK_CONTAINER(hbox), button);
        GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
        gtk_widget_show(button);
-*/     
+*/
        button = pref_button_new(NULL, GTK_STOCK_APPLY, NULL, FALSE,
                                 G_CALLBACK(layout_config_apply_cb), lc);
        gtk_container_add(GTK_CONTAINER(hbox), button);
-       GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
+       gtk_widget_set_can_default(button, TRUE);
        gtk_widget_show(button);
 
        button = pref_button_new(NULL, GTK_STOCK_CANCEL, NULL, FALSE,
                                 G_CALLBACK(layout_config_close_cb), lc);
        gtk_container_add(GTK_CONTAINER(hbox), button);
-       GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
+       gtk_widget_set_can_default(button, TRUE);
        gtk_widget_show(button);
 
        if (!generic_dialog_get_alternative_button_order(lc->configwindow))
@@ -2067,6 +2030,7 @@ void layout_close(LayoutWindow *lw)
 
 void layout_free(LayoutWindow *lw)
 {
+       gint i;
        if (!lw) return;
 
        layout_window_list = g_list_remove(layout_window_list, lw);
@@ -2077,8 +2041,13 @@ void layout_free(LayoutWindow *lw)
        layout_bars_close(lw);
 
        g_object_unref(lw->menu_bar);
-       g_object_unref(lw->toolbar);
        g_object_unref(lw->utility_box);
+
+       for (i = 0; i < TOOLBAR_COUNT; i++)
+               {
+               if (lw->toolbar[i]) g_object_unref(lw->toolbar[i]);
+               string_list_free(lw->toolbar_actions[i]);
+               }
        
        gtk_widget_destroy(lw->window);
        
@@ -2092,7 +2061,6 @@ void layout_free(LayoutWindow *lw)
                file_data_unref(lw->dir_fd);
                }
 
-       string_list_free(lw->toolbar_actions);
        free_layout_options_content(&lw->options);
        g_free(lw);
 }
@@ -2118,6 +2086,7 @@ LayoutWindow *layout_new_with_geometry(FileData *dir_fd, LayoutOptions *lop,
        GdkWindowHints hint_mask;
        Histogram *histogram;
 
+       DEBUG_1("%s layout_new: start", get_exec_time());
        lw = g_new0(LayoutWindow, 1);
 
        if (lop)
@@ -2245,6 +2214,8 @@ LayoutWindow *layout_new_with_geometry(FileData *dir_fd, LayoutOptions *lop,
 
        file_data_register_notify_func(layout_image_notify_cb, lw, NOTIFY_PRIORITY_LOW);
 
+       DEBUG_1("%s layout_new: end", get_exec_time());
+
        return lw;
 }
 
@@ -2290,7 +2261,7 @@ void layout_write_attributes(LayoutOptions *layout, GString *outstr, gint indent
        WRITE_SEPARATOR();
 
        WRITE_NL(); WRITE_BOOL(*layout, toolbar_hidden);
-       WRITE_NL(); WRITE_BOOL(*layout, info_pixel_hidden);
+       WRITE_NL(); WRITE_BOOL(*layout, show_info_pixel);
 
        WRITE_NL(); WRITE_UINT(*layout, image_overlay.state);
        WRITE_NL(); WRITE_INT(*layout, image_overlay.histogram_channel);
@@ -2308,7 +2279,8 @@ void layout_write_config(LayoutWindow *lw, GString *outstr, gint indent)
        bar_sort_write_config(lw->bar_sort, outstr, indent + 1);
        bar_write_config(lw->bar, outstr, indent + 1);
        
-       layout_toolbar_write_config(lw, outstr, indent + 1);
+       layout_toolbar_write_config(lw, TOOLBAR_MAIN, outstr, indent + 1);
+       layout_toolbar_write_config(lw, TOOLBAR_STATUS, outstr, indent + 1);
 
        WRITE_NL(); WRITE_STRING("</layout>");
 }
@@ -2360,7 +2332,7 @@ void layout_load_attributes(LayoutOptions *layout, const gchar **attribute_names
                if (READ_BOOL(*layout, tools_float)) continue;
                if (READ_BOOL(*layout, tools_hidden)) continue;
                if (READ_BOOL(*layout, toolbar_hidden)) continue;
-               if (READ_BOOL(*layout, info_pixel_hidden)) continue;
+               if (READ_BOOL(*layout, show_info_pixel)) continue;
 
                if (READ_UINT(*layout, image_overlay.state)) continue;
                if (READ_INT(*layout, image_overlay.histogram_channel)) continue;
@@ -2393,7 +2365,7 @@ static void layout_config_startup_path(LayoutOptions *lop, gchar **path)
                        *path = get_current_dir();
                        break;
                }
-}      
+}
 
 
 static void layout_config_commandline(LayoutOptions *lop, gchar **path)
@@ -2437,7 +2409,7 @@ LayoutWindow *layout_new_from_config(const gchar **attribute_names, const gchar
                {
                layout_config_commandline(&lop, &path);
                }
-       else 
+       else
                {
                layout_config_startup_path(&lop, &path);
                }