/*
* Geeqie
* (C) 2006 John Ellis
- * Copyright (C) 2008 - 2009 The Geeqie Team
+ * Copyright (C) 2008 - 2012 The Geeqie Team
*
* Author: John Ellis
*
#define TOOLWINDOW_DEF_HEIGHT 450
#define PROGRESS_WIDTH 150
-#define PIXEL_LABEL_WIDTH 130
#define ZOOM_LABEL_WIDTH 64
#define PANE_DIVIDER_SIZE 10
GList *layout_window_list = NULL;
-
+LayoutWindow *current_lw = NULL;
static void layout_list_scroll_to_subpart(LayoutWindow *lw, const gchar *needle);
{
if (*lw == NULL)
{
- if (layout_window_list) *lw = layout_window_list->data;
+ if (current_lw) *lw = current_lw;
+ else if (layout_window_list) *lw = layout_window_list->data;
return (*lw != NULL);
}
-
return (g_list_find(layout_window_list, *lw) != NULL);
}
return NULL;
}
+LayoutWindow *layout_find_by_layout_id(const gchar *id)
+{
+ GList *work;
+
+ if (!id || !id[0]) return NULL;
+
+ if (strcmp(id, LAYOUT_ID_CURRENT) == 0)
+ {
+ if (current_lw) return current_lw;
+ if (layout_window_list) return layout_window_list->data;
+ return NULL;
+ }
+
+ work = layout_window_list;
+ while (work)
+ {
+ LayoutWindow *lw = work->data;
+ work = work->next;
+
+ if (lw->options.id && strcmp(id, lw->options.id) == 0)
+ return lw;
+ }
+
+ return NULL;
+}
+
+static void layout_set_unique_id(LayoutWindow *lw)
+{
+ char id[10];
+ gint i;
+ if (lw->options.id && lw->options.id[0]) return; /* id is already set */
+
+ g_free(lw->options.id);
+ lw->options.id = NULL;
+
+ if (!layout_find_by_layout_id("main"))
+ {
+ lw->options.id = g_strdup("main");
+ return;
+ }
+
+ i = 1;
+ while (TRUE)
+ {
+ g_snprintf(id, sizeof(id), "lw%d", i);
+ if (!layout_find_by_layout_id(id))
+ {
+ lw->options.id = g_strdup(id);
+ return;
+ }
+ i++;
+ }
+}
+
+static gboolean layout_set_current_cb(GtkWidget *widget, GdkEventFocus *event, gpointer data)
+{
+ LayoutWindow *lw = data;
+ current_lw = lw;
+ return FALSE;
+}
+
/*
*-----------------------------------------------------------------------------
* menu, toolbar, and dir view
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)
GtkWidget *box;
GtkWidget *menu_bar;
GtkWidget *tabcomp;
+ GtkWidget *toolbar;
box = gtk_vbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(box), menu_bar, FALSE, FALSE, 0);
gtk_widget_show(menu_bar);
- lw->toolbar = 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);
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);
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)
return button;
}
-/*
- *-----------------------------------------------------------------------------
- * color profile button (and menu)
- *-----------------------------------------------------------------------------
- */
-
-#ifdef HAVE_LCMS
-
-static void layout_color_menu_enable_cb(GtkWidget *widget, gpointer data)
-{
- LayoutWindow *lw = data;
-
- layout_image_color_profile_set_use(lw, (!layout_image_color_profile_get_use(lw)));
- layout_image_refresh(lw);
-}
-
-static void layout_color_menu_use_image_cb(GtkWidget *widget, gpointer data)
-{
- LayoutWindow *lw = data;
- gint input, screen;
- gboolean use_image;
-
- if (!layout_image_color_profile_get(lw, &input, &screen, &use_image)) return;
- layout_image_color_profile_set(lw, input, screen, !use_image);
- layout_image_refresh(lw);
-}
-
-#define COLOR_MENU_KEY "color_menu_key"
-
-static void layout_color_menu_input_cb(GtkWidget *widget, gpointer data)
-{
- LayoutWindow *lw = data;
- gint type;
- gint input, screen;
- gboolean use_image;
-
- if (!gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))) return;
-
- type = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), COLOR_MENU_KEY));
- if (type < 0 || type >= COLOR_PROFILE_FILE + COLOR_PROFILE_INPUTS) return;
-
- if (!layout_image_color_profile_get(lw, &input, &screen, &use_image)) return;
- if (type == input) return;
-
- layout_image_color_profile_set(lw, type, screen, use_image);
- layout_image_refresh(lw);
-}
-
-static void layout_color_menu_screen_cb(GtkWidget *widget, gpointer data)
-{
- LayoutWindow *lw = data;
- gint type;
- gint input, screen;
- gboolean use_image;
-
- if (!gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))) return;
-
- type = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), COLOR_MENU_KEY));
- if (type < 0 || type > 1) return;
-
- if (!layout_image_color_profile_get(lw, &input, &screen, &use_image)) return;
- if (type == screen) return;
-
- layout_image_color_profile_set(lw, input, type, use_image);
- layout_image_refresh(lw);
-}
-
-static gchar *layout_color_name_parse(const gchar *name)
-{
- if (!name || !*name) return g_strdup(_("Empty"));
- return g_strdelimit(g_strdup(name), "_", '-');
-}
-
-#endif /* HAVE_LCMS */
-
-static void layout_color_button_press_cb(GtkWidget *widget, gpointer data)
-{
-#ifndef HAVE_LCMS
- gchar *msg = g_strdup_printf(_("This installation of %s was not built with support for color profiles."), GQ_APPNAME);
- file_util_warning_dialog(_("Color profiles not supported"),
- msg,
- GTK_STOCK_DIALOG_INFO, widget);
- g_free(msg);
- return;
-#else
- LayoutWindow *lw = data;
- GtkWidget *menu;
- GtkWidget *item;
- gchar *buf;
- gboolean active;
- gint input = 0;
- gint screen = 0;
- gboolean use_image = FALSE;
- gboolean from_image;
- gint image_profile;
- gint i;
-
- if (!layout_image_color_profile_get(lw, &input, &screen, &use_image)) return;
-
- image_profile = layout_image_color_profile_get_from_image(lw);
- from_image = use_image && (image_profile != COLOR_PROFILE_NONE);
- menu = popup_menu_short_lived();
-
- active = layout_image_color_profile_get_use(lw);
- menu_item_add_check(menu, _("Use _color profiles"), active,
- G_CALLBACK(layout_color_menu_enable_cb), lw);
-
- menu_item_add_divider(menu);
-
- item = menu_item_add_check(menu, _("Use profile from _image"), use_image,
- G_CALLBACK(layout_color_menu_use_image_cb), lw);
- gtk_widget_set_sensitive(item, image_profile == COLOR_PROFILE_MEM || (image_profile > COLOR_PROFILE_NONE && image_profile < COLOR_PROFILE_FILE));
-
- for (i = COLOR_PROFILE_SRGB; i < COLOR_PROFILE_FILE; i++)
- {
- const gchar *label;
-
- switch (i)
- {
- case COLOR_PROFILE_SRGB: label = _("sRGB"); break;
- case COLOR_PROFILE_ADOBERGB: label = _("AdobeRGB compatible"); break;
- default: label = "fixme"; break;
- }
- buf = g_strdup_printf(_("Input _%d: %s%s"), i, label, (i == image_profile) ? " *" : "");
- item = menu_item_add_radio(menu, (i == COLOR_PROFILE_SRGB) ? NULL : item,
- buf, (input == i),
- G_CALLBACK(layout_color_menu_input_cb), lw);
- g_free(buf);
- g_object_set_data(G_OBJECT(item), COLOR_MENU_KEY, GINT_TO_POINTER(i));
- gtk_widget_set_sensitive(item, active && !from_image);
- }
-
- for (i = 0; i < COLOR_PROFILE_INPUTS; i++)
- {
- const gchar *name = options->color_profile.input_name[i];
- const gchar *file = options->color_profile.input_file[i];
- gchar *end;
-
- if (!name || !name[0]) name = filename_from_path(file);
-
- end = layout_color_name_parse(name);
- buf = g_strdup_printf(_("Input _%d: %s"), i + COLOR_PROFILE_FILE, end);
- g_free(end);
-
- item = menu_item_add_radio(menu, item,
- buf, (i + COLOR_PROFILE_FILE == input),
- G_CALLBACK(layout_color_menu_input_cb), lw);
- g_free(buf);
- g_object_set_data(G_OBJECT(item), COLOR_MENU_KEY, GINT_TO_POINTER(i + COLOR_PROFILE_FILE));
- gtk_widget_set_sensitive(item, active && !from_image && is_readable_file(file));
- }
-
- menu_item_add_divider(menu);
-
- item = menu_item_add_radio(menu, NULL,
- _("Screen sRGB"), (screen == 0),
- G_CALLBACK(layout_color_menu_screen_cb), lw);
-
- g_object_set_data(G_OBJECT(item), COLOR_MENU_KEY, GINT_TO_POINTER(0));
- gtk_widget_set_sensitive(item, active);
-
- item = menu_item_add_radio(menu, item,
- _("_Screen profile"), (screen == 1),
- G_CALLBACK(layout_color_menu_screen_cb), lw);
- g_object_set_data(G_OBJECT(item), COLOR_MENU_KEY, GINT_TO_POINTER(1));
- gtk_widget_set_sensitive(item, active && is_readable_file(options->color_profile.screen_file));
-
- gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 0, GDK_CURRENT_TIME);
-#endif /* HAVE_LCMS */
-}
-
-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;
-}
-
-/*
- *-----------------------------------------------------------------------------
- * 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)
{
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);
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)
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)
static void layout_status_setup(LayoutWindow *lw, GtkWidget *box, gboolean small_format)
{
GtkWidget *hbox;
+ GtkWidget *toolbar;
+ GtkWidget *toolbar_frame;
if (lw->info_box) return;
gtk_box_pack_start(GTK_BOX(hbox), lw->info_sort, FALSE, FALSE, 0);
gtk_widget_show(lw->info_sort);
- lw->info_color = layout_color_button(lw);
- gtk_widget_show(lw->info_color);
-
- 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_color, FALSE, FALSE, 0);
- 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)
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_color, FALSE, FALSE, 0);
- 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));
}
/*
layout_status_update_progress(lw, val, text);
}
+static void layout_list_sync_thumb(LayoutWindow *lw)
+{
+ if (lw->vf) vf_thumb_set(lw->vf, lw->options.show_thumbnails);
+}
+
static GtkWidget *layout_list_new(LayoutWindow *lw)
{
lw->vf = vf_new(lw->options.file_view_type, NULL);
vf_set_thumb_status_func(lw->vf, layout_list_thumb_cb, lw);
vf_marks_set(lw->vf, lw->options.show_marks);
-
- switch (lw->options.file_view_type)
- {
- case FILEVIEW_ICON:
- break;
- case FILEVIEW_LIST:
- vf_thumb_set(lw->vf, lw->options.show_thumbnails);
- break;
- }
+
+ layout_list_sync_thumb(lw);
return lw->vf->widget;
}
-static void layout_list_sync_thumb(LayoutWindow *lw)
-{
- if (lw->vf) vf_thumb_set(lw->vf, lw->options.show_thumbnails);
-}
-
static void layout_list_sync_marks(LayoutWindow *lw)
{
if (lw->vf) vf_marks_set(lw->vf, lw->options.show_marks);
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)
{
if (!layout_valid(&lw) || !fd) return -1;
- if (lw->vf) return vf_index_by_path(lw->vf, fd->path);
+ if (lw->vf) return vf_index_by_fd(lw->vf, fd);
return -1;
}
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
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;
gboolean layout_set_fd(LayoutWindow *lw, FileData *fd)
{
gboolean have_file = FALSE;
+ gboolean dir_changed = TRUE;
if (!layout_valid(&lw)) return FALSE;
if (lw->dir_fd && strcmp(lw->dir_fd->path, base) == 0)
{
g_free(base);
+ dir_changed = FALSE;
}
else if (isdir(base))
{
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);
}
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;
}
{
if (lw->vd) vd_refresh(lw->vd);
- if (lw->vf) vf_refresh(lw->vf);
+ if (lw->vf)
+ {
+ vf_refresh(lw->vf);
+ vf_thumb_update(lw->vf);
+ }
}
void layout_refresh(LayoutWindow *lw)
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);
}
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)
{
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) */
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;
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);
}
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);
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;
{
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);
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)
GtkWidget *files;
layout_actions_setup(lw);
- layout_actions_add_window(lw, lw->window);
lw->group_box = gtk_vbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(lw->main_box), lw->group_box, TRUE, TRUE, 0);
if (lw->utility_box)
{
+ layout_split_change(lw, lw->split_mode); /* this re-creates image frame for the new configuration */
image_sb = lw->utility_box;
}
else
layout_tools_setup(lw, tools, files);
- gtk_widget_grab_focus(lw->image->widget);
+ image_grab_focus(lw->image);
return;
}
gtk_paned_set_position(GTK_PANED(lw->h_pane), lw->options.main_window.hdivider_pos);
gtk_paned_set_position(GTK_PANED(lw->v_pane), lw->options.main_window.vdivider_pos);
- gtk_widget_grab_focus(lw->image->widget);
+ image_grab_focus(lw->image);
}
void layout_style_set(LayoutWindow *lw, gint style, const gchar *order)
{
FileData *dir_fd;
+ gint i;
if (!layout_valid(&lw)) return;
/* 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;
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 toolbars to be reused later in layout_grid_setup */
/* lw->image is preserved together with lw->utility_box */
- if (lw->utility_box)
- {
- /* preserve utility_box (image + sidebars) to be reused later in layout_grid_setup */
- gtk_widget_hide(lw->utility_box);
- g_object_ref(lw->utility_box);
- gtk_container_remove(GTK_CONTAINER(lw->utility_box->parent), lw->utility_box);
- }
+ 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 */
lw->h_pane = NULL;
lw->v_pane = NULL;
- lw->toolbar = NULL;
lw->path_entry = NULL;
lw->dir_view = NULL;
lw->vd = NULL;
lw->info_box = NULL;
lw->info_progress_bar = NULL;
lw->info_sort = NULL;
- lw->info_color = NULL;
lw->info_status = NULL;
lw->info_details = NULL;
lw->info_pixel = NULL;
lw->info_zoom = NULL;
+/*
if (lw->ui_manager) g_object_unref(lw->ui_manager);
lw->ui_manager = NULL;
lw->action_group = NULL;
- lw->action_group_external = NULL;
+ lw->action_group_editors = NULL;
+*/
gtk_container_remove(GTK_CONTAINER(lw->main_box), lw->group_box);
lw->group_box = NULL;
layout_util_sync(lw);
layout_status_update_all(lw);
+
+ // printf("%d %d %d \n", G_OBJECT(lw->utility_box)->ref_count, G_OBJECT(lw->menu_bar)->ref_count, G_OBJECT(lw->toolbar)->ref_count);
+
/* sync */
if (image_get_fd(lw->image))
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);
}
}
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");
}
/*
gtk_entry_set_text(GTK_ENTRY(lc->home_path_entry), layout_get_path(lc->lw));
}
+static void startup_path_set_current_cb(GtkWidget *widget, gpointer data)
+{
+ LayoutConfig *lc = data;
+ lc->options.startup_path = STARTUP_PATH_CURRENT;
+}
+
+static void startup_path_set_last_cb(GtkWidget *widget, gpointer data)
+{
+ LayoutConfig *lc = data;
+ lc->options.startup_path = STARTUP_PATH_LAST;
+}
+
+static void startup_path_set_home_cb(GtkWidget *widget, gpointer data)
+{
+ LayoutConfig *lc = data;
+ lc->options.startup_path = STARTUP_PATH_HOME;
+}
+
+
/*
static void layout_config_save_cb(GtkWidget *widget, gpointer data)
{
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);
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))
gtk_container_add(GTK_CONTAINER(frame), vbox);
gtk_widget_show(vbox);
+
group = pref_group_new(vbox, FALSE, _("General options"), GTK_ORIENTATION_VERTICAL);
- pref_label_new(group, _("Home button path (empty to use your home directory)"));
+ pref_label_new(group, _("Home path (empty to use your home directory)"));
hbox = pref_box_new(group, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_SPACE);
tabcomp = tab_completion_new(&lc->home_path_entry, lc->options.home_path, NULL, NULL);
button = pref_button_new(hbox, NULL, _("Use current"), FALSE,
G_CALLBACK(home_path_set_current_cb), lc);
- group = pref_group_new(vbox, FALSE, _("Behavior"), GTK_ORIENTATION_VERTICAL);
-
pref_checkbox_new_int(group, _("Show date in directories list view"),
lc->options.show_directory_date, &lc->options.show_directory_date);
+ pref_checkbox_new_int(group, _("Exit program when this window is closed"),
+ lc->options.exit_on_close, &lc->options.exit_on_close);
+
+ group = pref_group_new(vbox, FALSE, _("Start-up directory:"), GTK_ORIENTATION_VERTICAL);
+
+ button = pref_radiobutton_new(group, NULL, _("No change"),
+ (lc->options.startup_path == STARTUP_PATH_CURRENT),
+ G_CALLBACK(startup_path_set_current_cb), lc);
+ button = pref_radiobutton_new(group, button, _("Restore last path"),
+ (lc->options.startup_path == STARTUP_PATH_LAST),
+ G_CALLBACK(startup_path_set_last_cb), lc);
+ button = pref_radiobutton_new(group, button, _("Home path"),
+ (lc->options.startup_path == STARTUP_PATH_HOME),
+ G_CALLBACK(startup_path_set_home_cb), lc);
+
group = pref_group_new(vbox, FALSE, _("Layout"), GTK_ORIENTATION_VERTICAL);
lc->layout_widget = layout_config_new();
lw->options.image_overlay.histogram_channel = histogram->histogram_channel;
lw->options.image_overlay.histogram_mode = histogram->histogram_mode;
-// if (options->startup.restore_path && options->startup.use_last_path)
-// {
-// g_free(options->startup.path);
-// options->startup.path = g_strdup(layout_get_path(NULL));
-// }
+ g_free(lw->options.last_path);
+ lw->options.last_path = g_strdup(layout_get_path(lw));
}
void layout_apply_options(LayoutWindow *lw, LayoutOptions *lop)
void layout_close(LayoutWindow *lw)
{
- if (layout_window_list && layout_window_list->next)
+ if (!lw->options.exit_on_close && layout_window_list && layout_window_list->next)
{
layout_free(lw);
}
void layout_free(LayoutWindow *lw)
{
+ gint i;
if (!lw) return;
layout_window_list = g_list_remove(layout_window_list, lw);
+ if (current_lw == lw) current_lw = NULL;
if (lw->exif_window) g_signal_handlers_disconnect_matched(G_OBJECT(lw->exif_window), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, lw);
layout_bars_close(lw);
+ g_object_unref(lw->menu_bar);
+ 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);
if (lw->split_image_sizegroup) g_object_unref(lw->split_image_sizegroup);
file_data_unref(lw->dir_fd);
}
- string_list_free(lw->toolbar_actions);
free_layout_options_content(&lw->options);
g_free(lw);
}
GdkWindowHints hint_mask;
Histogram *histogram;
+ DEBUG_1("%s layout_new: start", get_exec_time());
lw = g_new0(LayoutWindow, 1);
if (lop)
lw->sort_method = SORT_NAME;
lw->sort_ascend = TRUE;
+ layout_set_unique_id(lw);
// lw->options.tools_float = popped;
// lw->options.tools_hidden = hidden;
// lw->bar_sort_enabled = options->panels.sort.enabled;
g_signal_connect(G_OBJECT(lw->window), "delete_event",
G_CALLBACK(layout_delete_cb), lw);
+ g_signal_connect(G_OBJECT(lw->window), "focus-in-event",
+ G_CALLBACK(layout_set_current_cb), lw);
+
layout_keyboard_init(lw, lw->window);
#ifdef HAVE_LIRC
file_data_register_notify_func(layout_image_notify_cb, lw, NOTIFY_PRIORITY_LOW);
+ DEBUG_1("%s layout_new: end", get_exec_time());
+
return lw;
}
void layout_write_attributes(LayoutOptions *layout, GString *outstr, gint indent)
{
- WRITE_INT(*layout, style);
- WRITE_CHAR(*layout, order);
- WRITE_UINT(*layout, dir_view_type);
- WRITE_UINT(*layout, file_view_type);
- WRITE_BOOL(*layout, show_marks);
- WRITE_BOOL(*layout, show_thumbnails);
- WRITE_BOOL(*layout, show_directory_date);
- WRITE_CHAR(*layout, home_path);
+ WRITE_NL(); WRITE_CHAR(*layout, id);
+
+ WRITE_NL(); WRITE_INT(*layout, style);
+ WRITE_NL(); WRITE_CHAR(*layout, order);
+ WRITE_NL(); WRITE_UINT(*layout, dir_view_type);
+ WRITE_NL(); WRITE_UINT(*layout, file_view_type);
+ WRITE_NL(); WRITE_BOOL(*layout, show_marks);
+ WRITE_NL(); WRITE_BOOL(*layout, show_thumbnails);
+ WRITE_NL(); WRITE_BOOL(*layout, show_directory_date);
+ WRITE_NL(); WRITE_CHAR(*layout, home_path);
+ WRITE_NL(); WRITE_CHAR(*layout, last_path);
+ WRITE_NL(); WRITE_UINT(*layout, startup_path);
+ WRITE_NL(); WRITE_BOOL(*layout, exit_on_close);
WRITE_SEPARATOR();
- WRITE_INT(*layout, main_window.x);
- WRITE_INT(*layout, main_window.y);
- WRITE_INT(*layout, main_window.w);
- WRITE_INT(*layout, main_window.h);
- WRITE_BOOL(*layout, main_window.maximized);
- WRITE_INT(*layout, main_window.hdivider_pos);
- WRITE_INT(*layout, main_window.vdivider_pos);
+ WRITE_NL(); WRITE_INT(*layout, main_window.x);
+ WRITE_NL(); WRITE_INT(*layout, main_window.y);
+ WRITE_NL(); WRITE_INT(*layout, main_window.w);
+ WRITE_NL(); WRITE_INT(*layout, main_window.h);
+ WRITE_NL(); WRITE_BOOL(*layout, main_window.maximized);
+ WRITE_NL(); WRITE_INT(*layout, main_window.hdivider_pos);
+ WRITE_NL(); WRITE_INT(*layout, main_window.vdivider_pos);
WRITE_SEPARATOR();
- WRITE_INT(*layout, float_window.x);
- WRITE_INT(*layout, float_window.y);
- WRITE_INT(*layout, float_window.w);
- WRITE_INT(*layout, float_window.h);
- WRITE_INT(*layout, float_window.vdivider_pos);
+ WRITE_NL(); WRITE_INT(*layout, float_window.x);
+ WRITE_NL(); WRITE_INT(*layout, float_window.y);
+ WRITE_NL(); WRITE_INT(*layout, float_window.w);
+ WRITE_NL(); WRITE_INT(*layout, float_window.h);
+ WRITE_NL(); WRITE_INT(*layout, float_window.vdivider_pos);
WRITE_SEPARATOR();
- WRITE_INT(*layout, properties_window.w);
- WRITE_INT(*layout, properties_window.h);
+ WRITE_NL(); WRITE_INT(*layout, properties_window.w);
+ WRITE_NL(); WRITE_INT(*layout, properties_window.h);
WRITE_SEPARATOR();
- WRITE_BOOL(*layout, tools_float);
- WRITE_BOOL(*layout, tools_hidden);
+ WRITE_NL(); WRITE_BOOL(*layout, tools_float);
+ WRITE_NL(); WRITE_BOOL(*layout, tools_hidden);
WRITE_SEPARATOR();
- WRITE_BOOL(*layout, toolbar_hidden);
- WRITE_BOOL(*layout, info_pixel_hidden);
+ WRITE_NL(); WRITE_BOOL(*layout, toolbar_hidden);
+ WRITE_NL(); WRITE_BOOL(*layout, show_info_pixel);
- WRITE_UINT(*layout, image_overlay.state);
- WRITE_INT(*layout, image_overlay.histogram_channel);
- WRITE_INT(*layout, image_overlay.histogram_mode);
+ WRITE_NL(); WRITE_UINT(*layout, image_overlay.state);
+ WRITE_NL(); WRITE_INT(*layout, image_overlay.histogram_channel);
+ WRITE_NL(); WRITE_INT(*layout, image_overlay.histogram_mode);
}
void layout_write_config(LayoutWindow *lw, GString *outstr, gint indent)
{
layout_sync_options_with_current_state(lw);
- WRITE_STRING("<layout\n");
+ WRITE_NL(); WRITE_STRING("<layout");
layout_write_attributes(&lw->options, outstr, indent + 1);
- WRITE_STRING(">\n");
+ WRITE_STRING(">");
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_STRING("</layout>\n");
+ WRITE_NL(); WRITE_STRING("</layout>");
}
void layout_load_attributes(LayoutOptions *layout, const gchar **attribute_names, const gchar **attribute_values)
{
+ gchar *id = NULL;
while (*attribute_names)
{
const gchar *value = *attribute_values++;
/* layout options */
+ if (READ_CHAR_FULL("id", id)) continue;
if (READ_INT(*layout, style)) continue;
if (READ_CHAR(*layout, order)) continue;
if (READ_BOOL(*layout, show_thumbnails)) continue;
if (READ_BOOL(*layout, show_directory_date)) continue;
if (READ_CHAR(*layout, home_path)) continue;
+ if (READ_CHAR(*layout, last_path)) continue;
+ if (READ_UINT_CLAMP(*layout, startup_path, 0, STARTUP_PATH_HOME)) continue;
+ if (READ_BOOL(*layout, exit_on_close)) continue;
/* window positions */
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;
if (READ_INT(*layout, image_overlay.histogram_mode)) continue;
- DEBUG_1("unknown attribute %s = %s", option, value);
+ log_printf("unknown attribute %s = %s\n", option, value);
+ }
+ if (id && strcmp(id, LAYOUT_ID_CURRENT) != 0)
+ {
+ g_free(layout->id);
+ layout->id = id;
+ }
+ else
+ {
+ g_free(id);
}
-
}
+static void layout_config_startup_path(LayoutOptions *lop, gchar **path)
+{
+ switch (lop->startup_path)
+ {
+ case STARTUP_PATH_LAST:
+ *path = (lop->last_path && isdir(lop->last_path)) ? g_strdup(lop->last_path) : get_current_dir();
+ break;
+ case STARTUP_PATH_HOME:
+ *path = (lop->home_path && isdir(lop->home_path)) ? g_strdup(lop->home_path) : g_strdup(homedir());
+ break;
+ default:
+ *path = get_current_dir();
+ break;
+ }
+}
+
+
static void layout_config_commandline(LayoutOptions *lop, gchar **path)
{
if (command_line->startup_blank)
{
*path = g_strdup(command_line->path);
}
- else if (options->startup.restore_path && options->startup.path && isdir(options->startup.path))
- {
- *path = g_strdup(options->startup.path);
- }
- else
- {
- *path = get_current_dir();
- }
+ else layout_config_startup_path(lop, path);
if (command_line->tools_show)
{
{
layout_config_commandline(&lop, &path);
}
- else if (options->startup.restore_path && options->startup.path && isdir(options->startup.path))
+ else
{
- path = g_strdup(options->startup.path);
- }
- else
- {
- path = get_current_dir();
+ layout_config_startup_path(&lop, &path);
}
lw = layout_new_with_geometry(NULL, &lop, use_commandline ? command_line->geometry : NULL);
return lw;
}
+void layout_update_from_config(LayoutWindow *lw, const gchar **attribute_names, const gchar **attribute_values)
+{
+ LayoutOptions lop;
+
+ init_layout_options(&lop);
+
+ if (attribute_names) layout_load_attributes(&lop, attribute_names, attribute_values);
+
+ layout_apply_options(lw, &lop);
+
+ free_layout_options_content(&lop);
+}
+
/* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */