#include "color-man.h"
#include "dnd.h"
#include "editors.h"
+#include "exif.h"
#include "filedata.h"
#include "fullscreen.h"
+#include "history_list.h"
#include "image.h"
#include "image-overlay.h"
#include "img-view.h"
#include "layout.h"
#include "layout_util.h"
#include "menu.h"
+#include "metadata.h"
#include "misc.h"
#include "pixbuf_util.h"
#include "pixbuf-renderer.h"
#include <gdk/gdkkeysyms.h> /* for keyboard values */
+#define FILE_COLUMN_POINTER 0
static GtkWidget *layout_image_pop_menu(LayoutWindow *lw);
static void layout_image_set_buttons(LayoutWindow *lw);
-static void layout_image_animate_stop(LayoutWindow *lw);
static gboolean layout_image_animate_new_file(LayoutWindow *lw);
static void layout_image_animate_update_image(LayoutWindow *lw);
static void image_animation_data_free(AnimationData *fd)
{
if(!fd) return;
- g_object_unref(fd->iter);
- g_object_unref(fd->gpa);
+ if(fd->iter) g_object_unref(fd->iter);
+ if(fd->gpa) g_object_unref(fd->gpa);
+ if(fd->cancellable) g_object_unref(fd->cancellable);
g_free(fd);
}
{
if (!layout_valid(&lw)) return FALSE;
- if(!lw->options.animate || lw->image->image_fd == NULL)
+ if(!lw->options.animate || lw->image->image_fd == NULL || lw->image->image_fd->extension == NULL || g_ascii_strcasecmp(lw->image->image_fd->extension,".GIF")!=0)
{
if(lw->animation)
{
lw->animation->valid = FALSE;
+ if (lw->animation->cancellable)
+ {
+ g_cancellable_cancel(lw->animation->cancellable);
+ }
lw->animation = NULL;
}
return FALSE;
return TRUE;
}
-static void layout_image_animate_stop(LayoutWindow *lw)
+static void layout_image_animate_update_image(LayoutWindow *lw)
{
if (!layout_valid(&lw)) return;
if(lw->options.animate && lw->animation)
{
- lw->animation->valid = FALSE;
- lw->animation = NULL;
+ if (lw->full_screen && lw->image != lw->full_screen->imd)
+ lw->animation->iw = lw->full_screen->imd;
+ else
+ lw->animation->iw = lw->image;
}
}
-static void layout_image_animate_update_image(LayoutWindow *lw)
+
+static void animation_async_ready_cb(GObject *source_object, GAsyncResult *res, gpointer data)
{
- if (!layout_valid(&lw)) return;
+ GError *error = NULL;
+ AnimationData *animation = data;
- if(lw->options.animate && lw->animation)
+ if (animation)
{
- if (lw->full_screen && lw->image != lw->full_screen->imd)
- lw->animation->iw = lw->full_screen->imd;
+ if (g_cancellable_is_cancelled(animation->cancellable))
+ {
+ gdk_pixbuf_animation_new_from_stream_finish(res, NULL);
+ g_object_unref(animation->in_file);
+ g_object_unref(animation->gfstream);
+ image_animation_data_free(animation);
+ return;
+ }
+
+ animation->gpa = gdk_pixbuf_animation_new_from_stream_finish(res, &error);
+ if (animation->gpa)
+ {
+ if (!gdk_pixbuf_animation_is_static_image(animation->gpa))
+ {
+ animation->iter = gdk_pixbuf_animation_get_iter(animation->gpa, NULL);
+ if (animation->iter)
+ {
+ animation->data_adr = animation->lw->image->image_fd;
+ animation->delay = gdk_pixbuf_animation_iter_get_delay_time(animation->iter);
+ animation->valid = TRUE;
+
+ layout_image_animate_update_image(animation->lw);
+
+ g_timeout_add(animation->delay, show_next_frame, animation);
+ }
+ }
+ }
else
- lw->animation->iw = lw->image;
+ {
+ log_printf("Error reading GIF file: %s\n", error->message);
+ }
+
+ g_object_unref(animation->in_file);
+ g_object_unref(animation->gfstream);
}
}
static gboolean layout_image_animate_new_file(LayoutWindow *lw)
{
- GError *err=NULL;
+ GFileInputStream *gfstream;
+ GError *error = NULL;
+ AnimationData *animation;
+ GFile *in_file;
if(!layout_image_animate_check(lw)) return FALSE;
if(lw->animation) lw->animation->valid = FALSE;
- lw->animation = g_malloc0(sizeof(AnimationData));
-
- if(!(lw->animation->gpa = gdk_pixbuf_animation_new_from_file(lw->image->image_fd->path,&err)) || err ||
- gdk_pixbuf_animation_is_static_image(lw->animation->gpa) ||
- !(lw->animation->iter = gdk_pixbuf_animation_get_iter(lw->animation->gpa,NULL)))
+ if (lw->animation)
{
- image_animation_data_free(lw->animation);
- return FALSE;
+ g_cancellable_cancel(lw->animation->cancellable);
}
- lw->animation->data_adr = lw->image->image_fd;
- lw->animation->delay = gdk_pixbuf_animation_iter_get_delay_time(lw->animation->iter);
- lw->animation->valid = TRUE;
+ animation = g_new0(AnimationData, 1);
+ lw->animation = animation;
+ animation->lw = lw;
+ animation->cancellable = g_cancellable_new();
- layout_image_animate_update_image(lw);
-
- g_timeout_add(lw->animation->delay, show_next_frame, lw->animation);
+ in_file = g_file_new_for_path(lw->image->image_fd->path);
+ animation->in_file = in_file;
+ gfstream = g_file_read(in_file, NULL, &error);
+ if (gfstream)
+ {
+ animation->gfstream = gfstream;
+ gdk_pixbuf_animation_new_from_stream_async((GInputStream*)gfstream, animation->cancellable, animation_async_ready_cb, animation);
+ }
+ else
+ {
+ log_printf("Error reading GIF file: %s\nError: %s\n", lw->image->image_fd->path, error->message);
+ }
return TRUE;
}
-static void layout_image_animate_toggle(LayoutWindow *lw)
+void layout_image_animate_toggle(LayoutWindow *lw)
{
+ GtkAction *action;
+
if (!lw) return;
lw->options.animate = !lw->options.animate;
+
+ action = gtk_action_group_get_action(lw->action_group, "Animate");
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->options.animate);
+
layout_image_animate_new_file(lw);
}
file_util_start_editor_from_file(key, layout_image_get_fd(lw), lw->window);
}
+#if !GTK_CHECK_VERSION(3,0,0)
static void li_pop_menu_wallpaper_cb(GtkWidget *widget, gpointer data)
{
LayoutWindow *lw = data;
layout_image_to_root(lw);
}
+#endif
static void li_pop_menu_alter_cb(GtkWidget *widget, gpointer data)
{
lw = submenu_item_get_data(widget);
type = (AlterType)GPOINTER_TO_INT(data);
- image_alter_orientation(lw->image, type);
+ image_alter_orientation(lw->image, lw->image->image_fd, type);
}
static void li_pop_menu_new_cb(GtkWidget *widget, gpointer data)
{
LayoutWindow *lw = data;
- file_util_copy_path_to_clipboard(layout_image_get_fd(lw));
+ file_util_copy_path_to_clipboard(layout_image_get_fd(lw), TRUE);
+}
+
+static void li_pop_menu_copy_path_unquoted_cb(GtkWidget *widget, gpointer data)
+{
+ LayoutWindow *lw = data;
+
+ file_util_copy_path_to_clipboard(layout_image_get_fd(lw), FALSE);
+}
+
+static void li_pop_menu_copy_image_cb(GtkWidget *widget, gpointer data)
+{
+ LayoutWindow *lw = data;
+ ImageWindow *imd = lw->image;
+
+ GdkPixbuf *pixbuf;
+ pixbuf = image_get_pixbuf(imd);
+ if (!pixbuf) return;
+ gtk_clipboard_set_image(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD), pixbuf);
}
static void li_pop_menu_move_cb(GtkWidget *widget, gpointer data)
{
LayoutWindow *lw = data;
+ options->file_ops.safe_delete_enable = FALSE;
+ file_util_delete(layout_image_get_fd(lw), NULL,
+ li_pop_menu_click_parent(widget, lw));
+}
+
+static void li_pop_menu_move_to_trash_cb(GtkWidget *widget, gpointer data)
+{
+ LayoutWindow *lw = data;
+
+ options->file_ops.safe_delete_enable = TRUE;
file_util_delete(layout_image_get_fd(lw), NULL,
li_pop_menu_click_parent(widget, lw));
}
if (fd) layout_set_fd(lw, fd);
}
+static void li_open_archive_cb(GtkWidget *widget, gpointer data)
+{
+ LayoutWindow *lw = data;
+ LayoutWindow *lw_new;
+ gchar *dest_dir;
+
+ if (!layout_valid(&lw)) return;
+
+ dest_dir = open_archive(layout_image_get_fd(lw));
+ if (dest_dir)
+ {
+ lw_new = layout_new_from_default();
+ layout_set_path(lw_new, dest_dir);
+ g_free(dest_dir);
+ }
+ else
+ {
+ warning_dialog(_("Cannot open archive file"), _("See the Log Window"), GTK_STOCK_DIALOG_WARNING, NULL);
+ }
+}
+
static gboolean li_check_if_current_path(LayoutWindow *lw, const gchar *path)
{
gchar *dirname;
return list;
}
+/**
+ * @brief Add file selection list to a collection
+ * @param[in] widget
+ * @param[in] data Index to the collection list menu item selected, or -1 for new collection
+ *
+ *
+ */
+static void layout_pop_menu_collections_cb(GtkWidget *widget, gpointer data)
+{
+ LayoutWindow *lw;
+ GList *selection_list = NULL;
+
+ lw = submenu_item_get_data(widget);
+ selection_list = g_list_append(selection_list, layout_image_get_fd(lw));
+ pop_menu_collections(selection_list, data);
+
+ filelist_free(selection_list);
+}
+
static GtkWidget *layout_image_pop_menu(LayoutWindow *lw)
{
GtkWidget *menu;
submenu = submenu_add_edit(menu, &item, G_CALLBACK(li_pop_menu_edit_cb), lw, editmenu_fd_list);
if (!path) gtk_widget_set_sensitive(item, FALSE);
menu_item_add_divider(submenu);
+#if !GTK_CHECK_VERSION(3,0,0)
menu_item_add(submenu, _("Set as _wallpaper"), G_CALLBACK(li_pop_menu_wallpaper_cb), lw);
-
+#endif
item = submenu_add_alter(menu, G_CALLBACK(li_pop_menu_alter_cb), lw);
item = menu_item_add_stock(menu, _("View in _new window"), GTK_STOCK_NEW, G_CALLBACK(li_pop_menu_new_cb), lw);
item = menu_item_add(menu, _("_Go to directory view"), G_CALLBACK(li_set_layout_path_cb), lw);
if (!path || li_check_if_current_path(lw, path)) gtk_widget_set_sensitive(item, FALSE);
+ item = menu_item_add_stock(menu, _("Open archive"), GTK_STOCK_OPEN, G_CALLBACK(li_open_archive_cb), lw);
+ if (!path || lw->image->image_fd->format_class != FORMAT_CLASS_ARCHIVE)
+ {
+ gtk_widget_set_sensitive(item, FALSE);
+ }
+
menu_item_add_divider(menu);
item = menu_item_add_stock(menu, _("_Copy..."), GTK_STOCK_COPY, G_CALLBACK(li_pop_menu_copy_cb), lw);
if (!path) gtk_widget_set_sensitive(item, FALSE);
item = menu_item_add(menu, _("_Rename..."), G_CALLBACK(li_pop_menu_rename_cb), lw);
if (!path) gtk_widget_set_sensitive(item, FALSE);
- item = menu_item_add_stock(menu, _("_Delete..."), GTK_STOCK_DELETE, G_CALLBACK(li_pop_menu_delete_cb), lw);
+ item = menu_item_add(menu, _("_Copy path"), G_CALLBACK(li_pop_menu_copy_path_cb), lw);
+ item = menu_item_add(menu, _("_Copy path unquoted"), G_CALLBACK(li_pop_menu_copy_path_unquoted_cb), lw);
+ item = menu_item_add(menu, _("Copy _image"), G_CALLBACK(li_pop_menu_copy_image_cb), lw);
if (!path) gtk_widget_set_sensitive(item, FALSE);
+ menu_item_add_divider(menu);
- item = menu_item_add(menu, _("_Copy path"), G_CALLBACK(li_pop_menu_copy_path_cb), lw);
+ item = menu_item_add_stock(menu,
+ options->file_ops.confirm_move_to_trash ? _("Move to Trash...") :
+ _("Move to Trash"), PIXBUF_INLINE_ICON_TRASH,
+ G_CALLBACK(li_pop_menu_move_to_trash_cb), lw);
+ if (!path) gtk_widget_set_sensitive(item, FALSE);
+ item = menu_item_add_stock(menu,
+ options->file_ops.confirm_delete ? _("_Delete...") :
+ _("_Delete"), GTK_STOCK_DELETE,
+ G_CALLBACK(li_pop_menu_delete_cb), lw);
if (!path) gtk_widget_set_sensitive(item, FALSE);
+ menu_item_add_divider(menu);
+ submenu = submenu_add_collections(menu, &item,
+ G_CALLBACK(layout_pop_menu_collections_cb), lw);
+ gtk_widget_set_sensitive(item, TRUE);
menu_item_add_divider(menu);
if (layout_image_slideshow_active(lw))
{
LayoutWindow *lw = data;
gint i;
+ gchar *url;
for (i = 0; i < MAX_SPLIT_IMAGES; i++)
layout_image_activate(lw, i, FALSE);
}
-
- if (info == TARGET_URI_LIST || info == TARGET_APP_COLLECTION_MEMBER)
+ if (info == TARGET_TEXT_PLAIN)
+ {
+ url = g_strdup((gchar *)gtk_selection_data_get_data(selection_data));
+ download_web_file(url, FALSE, lw);
+ g_free(url);
+ }
+ else if (info == TARGET_URI_LIST || info == TARGET_APP_COLLECTION_MEMBER)
{
CollectionData *source;
GList *list;
{
image_zoom_adjust_at_point(lw->full_screen->imd, increment, x, y);
}
-
- if (!connect_zoom) return;
+ if (!connect_zoom && !lw->split_mode) return;
for (i = 0; i < MAX_SPLIT_IMAGES; i++)
{
- if (lw->split_images[i] && lw->split_images[i] != lw->image)
+ if (lw->split_images[i] && lw->split_images[i] != lw->image &&
+ lw->split_images[i]->mouse_wheel_mode)
image_zoom_adjust_at_point(lw->split_images[i], increment, x, y);
}
}
{
if (!layout_valid(&lw)) return;
- image_alter_orientation(lw->image, type);
+ GtkTreeModel *store;
+ GList *work;
+ GtkTreeSelection *selection;
+ GtkTreePath *tpath;
+ FileData *fd_n;
+ GtkTreeIter iter;
+
+ if (!lw || !lw->vf) return;
+
+ if (lw->vf->type == FILEVIEW_ICON)
+ {
+ if (!VFICON(lw->vf)->selection) return;
+ work = VFICON(lw->vf)->selection;
+ }
+ else
+ {
+ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(lw->vf->listview));
+ work = gtk_tree_selection_get_selected_rows(selection, &store);
+ }
+
+ while (work)
+ {
+ if (lw->vf->type == FILEVIEW_ICON)
+ {
+ fd_n = work->data;
+ work = work->next;
+ }
+ else
+ {
+ tpath = work->data;
+ gtk_tree_model_get_iter(store, &iter, tpath);
+ gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd_n, -1);
+ work = work->next;
+ }
+
+ image_alter_orientation(lw->image, fd_n, type);
+ }
+}
+
+static void image_alter_rating(FileData *fd_n, const gchar *rating)
+{
+ metadata_write_string(fd_n, RATING_KEY, rating);
+ read_rating_data(fd_n);
+}
+
+void layout_image_rating(LayoutWindow *lw, const gchar *rating)
+{
+ if (!layout_valid(&lw)) return;
+
+ GtkTreeModel *store;
+ GList *work;
+ GtkTreeSelection *selection;
+ GtkTreePath *tpath;
+ FileData *fd_n;
+ GtkTreeIter iter;
+
+ if (!lw || !lw->vf) return;
+
+ if (lw->vf->type == FILEVIEW_ICON)
+ {
+ if (!VFICON(lw->vf)->selection) return;
+ work = VFICON(lw->vf)->selection;
+ }
+ else
+ {
+ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(lw->vf->listview));
+ work = gtk_tree_selection_get_selected_rows(selection, &store);
+ }
+
+ while (work)
+ {
+ if (lw->vf->type == FILEVIEW_ICON)
+ {
+ fd_n = work->data;
+ work = work->next;
+ }
+ else
+ {
+ tpath = work->data;
+ gtk_tree_model_get_iter(store, &iter, tpath);
+ gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd_n, -1);
+ work = work->next;
+ }
+
+ image_alter_rating(fd_n, rating);
+ }
+}
+
+void layout_image_reset_orientation(LayoutWindow *lw)
+{
+ ImageWindow *imd= lw->image;
+
+ if (!layout_valid(&lw)) return;
+ if (!imd || !imd->pr || !imd->image_fd) return;
+
+ if (imd->orientation < 1 || imd->orientation > 8) imd->orientation = 1;
+
+ if (options->image.exif_rotate_enable)
+ {
+ if (g_strcmp0(imd->image_fd->format_name, "heif") != 0)
+ {
+ imd->orientation = metadata_read_int(imd->image_fd, ORIENTATION_KEY, EXIF_ORIENTATION_TOP_LEFT);
+ }
+ else
+ {
+ imd->orientation = EXIF_ORIENTATION_TOP_LEFT;
+ }
+ }
+ else
+ {
+ imd->orientation = 1;
+ }
+
+ if (imd->image_fd->user_orientation != 0)
+ {
+ imd->orientation = imd->image_fd->user_orientation;
+ }
+
+ pixbuf_renderer_set_orientation((PixbufRenderer *)imd->pr, imd->orientation);
}
void layout_image_set_desaturate(LayoutWindow *lw, gboolean desaturate)
return image_get_desaturate(lw->image);
}
+void layout_image_set_overunderexposed(LayoutWindow *lw, gboolean overunderexposed)
+{
+ if (!layout_valid(&lw)) return;
+
+ image_set_overunderexposed(lw->image, overunderexposed);
+}
+
+gboolean layout_image_get_overunderexposed(LayoutWindow *lw)
+{
+ if (!layout_valid(&lw)) return FALSE;
+
+ return image_get_overunderexposed(lw->image);
+}
+
+void layout_image_set_ignore_alpha(LayoutWindow *lw, gboolean ignore_alpha)
+{
+ if (!layout_valid(&lw)) return;
+
+ lw->options.ignore_alpha = ignore_alpha;
+ image_set_ignore_alpha(lw->image, ignore_alpha);
+}
+
/* stereo */
/*
gint layout_image_stereo_get(LayoutWindow *lw)
layout_image_slideshow_continue_check(lw);
layout_bars_new_image(lw);
layout_image_animate_new_file(lw);
+
+ if (fd)
+ {
+ image_chain_append_end(fd->path);
+ }
}
void layout_image_set_with_ahead(LayoutWindow *lw, FileData *fd, FileData *read_ahead_fd)
if (y->next)
layout_image_set_index(lw, GPOINTER_TO_INT(y->next->data));
else
- layout_image_set_index(lw, GPOINTER_TO_INT(x->data));
+ {
+ if (options->circular_selection_lists)
+ {
+ layout_image_set_index(lw, GPOINTER_TO_INT(x->data));
+ }
+ }
}
while (x)
x = g_list_remove(x, x->data);
if (y->prev)
layout_image_set_index(lw, GPOINTER_TO_INT(y->prev->data));
else
- layout_image_set_index(lw, GPOINTER_TO_INT(last->data));
+ {
+ if (options->circular_selection_lists)
+ {
+ layout_image_set_index(lw, GPOINTER_TO_INT(last->data));
+ }
+ }
}
while (x)
x = g_list_remove(x, x->data);
{
LayoutWindow *lw = data;
GtkWidget *menu;
+ LayoutWindow *lw_new;
+ gchar *dest_dir;
switch (event->button)
{
case MOUSE_BUTTON_LEFT:
- if (options->image_lm_click_nav && lw->split_mode == SPLIT_NONE)
+ if (options->image_l_click_archive && imd-> image_fd && imd->image_fd->format_class == FORMAT_CLASS_ARCHIVE)
+ {
+ dest_dir = open_archive(imd->image_fd);
+ if (dest_dir)
+ {
+ lw_new = layout_new_from_default();
+ layout_set_path(lw_new, dest_dir);
+ g_free(dest_dir);
+ }
+ else
+ {
+ warning_dialog(_("Cannot open archive file"), _("See the Log Window"), GTK_STOCK_DIALOG_WARNING, NULL);
+ }
+ }
+ else if (options->image_l_click_video && options->image_l_click_video_editor && imd-> image_fd && imd->image_fd->format_class == FORMAT_CLASS_VIDEO)
+ {
+ start_editor_from_file(options->image_l_click_video_editor, imd->image_fd);
+ }
+ else if (options->image_lm_click_nav && lw->split_mode == SPLIT_NONE)
layout_image_next(lw);
break;
case MOUSE_BUTTON_MIDDLE:
}
- if (event->state & GDK_CONTROL_MASK)
+ if ((event->state & GDK_CONTROL_MASK) ||
+ (imd->mouse_wheel_mode && !options->image_lm_click_nav))
{
switch (event->direction)
{
}
}
-static void layout_image_drag_cb(ImageWindow *imd, GdkEventButton *event, gdouble dx, gdouble dy, gpointer data)
+static void layout_image_drag_cb(ImageWindow *imd, GdkEventMotion *event, gdouble dx, gdouble dy, gpointer data)
{
gint i;
LayoutWindow *lw = data;
}
-static void layout_image_drag_inactive_cb(ImageWindow *imd, GdkEventButton *event, gdouble dx, gdouble dy, gpointer data)
+static void layout_image_drag_inactive_cb(ImageWindow *imd, GdkEventMotion *event, gdouble dx, gdouble dy, gpointer data)
{
LayoutWindow *lw = data;
gint i = image_idx(lw, imd);
image_attach_window(lw->image, lw->window, NULL, GQ_APPNAME, FALSE);
- /* do not hilight selected image in SPLIT_NONE */
- /* maybe the image should be selected always and hilight should be controled by
+ /* do not highlight selected image in SPLIT_NONE */
+ /* maybe the image should be selected always and highlight should be controlled by
another image option */
if (lw->split_mode != SPLIT_NONE)
image_select(lw->split_images[i], TRUE);
GList *work = g_list_last(layout_selection_list(lw));
gint j = 0;
- if (work) work = work->prev;
-
while (work && j < i)
{
FileData *fd = work->data;
work = work->prev;
- j++;
- if (!fd || !*fd->path) continue;
+ if (!fd || !*fd->path || fd->parent ||
+ fd == lw->split_images[0]->image_fd)
+ {
+ continue;
+ }
img_fd = fd;
+
+ j++;
}
}
/* horizontal split means vpaned and vice versa */
if (horizontal)
+ {
paned = gtk_vpaned_new();
+ DEBUG_NAME(paned);
+ }
else
+ {
paned = gtk_hpaned_new();
+ DEBUG_NAME(paned);
+ }
gtk_paned_pack1(GTK_PANED(paned), lw->split_images[0]->widget, TRUE, TRUE);
gtk_paned_pack2(GTK_PANED(paned), lw->split_images[1]->widget, TRUE, TRUE);
layout_image_setup_split_common(lw, 4);
hpaned = gtk_hpaned_new();
+ DEBUG_NAME(hpaned);
vpaned1 = gtk_vpaned_new();
+ DEBUG_NAME(vpaned1);
vpaned2 = gtk_vpaned_new();
+ DEBUG_NAME(vpaned2);
gtk_paned_pack1(GTK_PANED(vpaned1), lw->split_images[0]->widget, TRUE, TRUE);
gtk_paned_pack2(GTK_PANED(vpaned1), lw->split_images[2]->widget, TRUE, TRUE);