/*
- * Geeqie
- * (C) 2006 John Ellis
- * Copyright (C) 2008 - 2010 The Geeqie Team
+ * Copyright (C) 2006 John Ellis
+ * Copyright (C) 2008 - 2016 The Geeqie Team
*
* Author: John Ellis
*
- * This software is released under the GNU General Public License (GNU GPL).
- * Please read the included file COPYING for more information.
- * This software comes with no warranty of any kind, use at your own risk!
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "main.h"
#include "color-man.h"
#include "dnd.h"
#include "editors.h"
+#include "exif.h"
#include "filedata.h"
#include "fullscreen.h"
#include "image.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);
/*
*----------------------------------------------------------------------------
LayoutWindow *lw = data;
/* restore image window */
- lw->image = fs->normal_imd;
+ if (lw->image == fs->imd)
+ lw->image = fs->normal_imd;
lw->full_screen = NULL;
}
layout_image_full_screen_stop_func, lw);
/* set to new image window */
- lw->image = lw->full_screen->imd;
+ if (lw->full_screen->same_region)
+ lw->image = lw->full_screen->imd;
layout_image_set_buttons(lw);
G_CALLBACK(layout_key_press_cb), lw);
layout_actions_add_window(lw, lw->full_screen->window);
-#if 0
- gtk_widget_set_sensitive(lw->window, FALSE);
- if (lw->tools) gtk_widget_set_sensitive(lw->tools, FALSE);
-#endif
image_osd_copy_status(lw->full_screen->normal_imd, lw->image);
+ layout_image_animate_update_image(lw);
}
void layout_image_full_screen_stop(LayoutWindow *lw)
if (!layout_valid(&lw)) return;
if (!lw->full_screen) return;
- image_osd_copy_status(lw->image, lw->full_screen->normal_imd);
+ if (lw->image == lw->full_screen->imd)
+ image_osd_copy_status(lw->image, lw->full_screen->normal_imd);
fullscreen_stop(lw->full_screen);
-#if 0
- gtk_widget_set_sensitive(lw->window, TRUE);
- if (lw->tools) gtk_widget_set_sensitive(lw->tools, TRUE);
-#endif
+ layout_image_animate_update_image(lw);
}
void layout_image_full_screen_toggle(LayoutWindow *lw)
return TRUE;
}
+/*
+ *----------------------------------------------------------------------------
+ * Animation
+ *----------------------------------------------------------------------------
+ */
+
+static void image_animation_data_free(AnimationData *fd)
+{
+ if(!fd) return;
+ if(fd->iter) g_object_unref(fd->iter);
+ if(fd->gpa) g_object_unref(fd->gpa);
+ g_free(fd);
+}
+
+static gboolean animation_should_continue(AnimationData *fd)
+{
+ if (!fd->valid)
+ return FALSE;
+
+ return TRUE;
+}
+
+static gboolean show_next_frame(gpointer data)
+{
+ AnimationData *fd = (AnimationData*)data;
+ int delay;
+ PixbufRenderer *pr;
+
+ if(animation_should_continue(fd)==FALSE)
+ {
+ image_animation_data_free(fd);
+ return FALSE;
+ }
+
+ pr = (PixbufRenderer*)fd->iw->pr;
+
+ if (gdk_pixbuf_animation_iter_advance(fd->iter,NULL)==FALSE)
+ {
+ /* This indicates the animation is complete.
+ Return FALSE here to disable looping. */
+ }
+
+ fd->gpb = gdk_pixbuf_animation_iter_get_pixbuf(fd->iter);
+ image_change_pixbuf(fd->iw,fd->gpb,pr->zoom,FALSE);
+
+ if (fd->iw->func_update)
+ fd->iw->func_update(fd->iw, fd->iw->data_update);
+
+ delay = gdk_pixbuf_animation_iter_get_delay_time(fd->iter);
+ if (delay!=fd->delay)
+ {
+ if (delay>0) /* Current frame not static. */
+ {
+ fd->delay=delay;
+ g_timeout_add(delay,show_next_frame,fd);
+ }
+ else
+ {
+ image_animation_data_free(fd);
+ }
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static gboolean layout_image_animate_check(LayoutWindow *lw)
+{
+ if (!layout_valid(&lw)) return FALSE;
+
+ if(!lw->options.animate || lw->image->image_fd == NULL)
+ {
+ if(lw->animation)
+ {
+ lw->animation->valid = FALSE;
+ lw->animation = NULL;
+ }
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static void layout_image_animate_stop(LayoutWindow *lw)
+{
+ if (!layout_valid(&lw)) return;
+
+ if(lw->options.animate && lw->animation)
+ {
+ lw->animation->valid = FALSE;
+ lw->animation = NULL;
+ }
+}
+
+static void layout_image_animate_update_image(LayoutWindow *lw)
+{
+ if (!layout_valid(&lw)) return;
+
+ if(lw->options.animate && lw->animation)
+ {
+ if (lw->full_screen && lw->image != lw->full_screen->imd)
+ lw->animation->iw = lw->full_screen->imd;
+ else
+ lw->animation->iw = lw->image;
+ }
+}
+
+static gboolean layout_image_animate_new_file(LayoutWindow *lw)
+{
+ GError *err=NULL;
+
+ 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)))
+ {
+ image_animation_data_free(lw->animation);
+ lw->animation = NULL;
+ return FALSE;
+ }
+
+ 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;
+
+ layout_image_animate_update_image(lw);
+
+ g_timeout_add(lw->animation->delay, show_next_frame, lw->animation);
+
+ return TRUE;
+}
+
+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);
+}
+
/*
*----------------------------------------------------------------------------
* pop-up menus
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)
layout_image_full_screen_toggle(lw);
}
+static void li_pop_menu_animate_cb(GtkWidget *widget, gpointer data)
+{
+ LayoutWindow *lw = data;
+
+ layout_image_animate_toggle(lw);
+}
+
static void li_pop_menu_hide_cb(GtkWidget *widget, gpointer data)
{
LayoutWindow *lw = data;
else
list = g_list_append(NULL, file_data_ref(fd));
}
-
+
return list;
}
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);
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);
if (!path) gtk_widget_set_sensitive(item, FALSE);
-
+
item = menu_item_add(menu, _("_Copy path"), G_CALLBACK(li_pop_menu_copy_path_cb), lw);
if (!path) gtk_widget_set_sensitive(item, FALSE);
menu_item_add(menu, _("Exit _full screen"), G_CALLBACK(li_pop_menu_full_screen_cb), lw);
}
+ menu_item_add_check(menu, _("_Animate"), lw->options.animate, G_CALLBACK(li_pop_menu_animate_cb), lw);
+
menu_item_add_divider(menu);
item = menu_item_add_check(menu, _("Hide file _list"), lw->options.tools_hidden,
{
LayoutWindow *lw = data;
- gdk_window_get_origin(lw->image->pr->window, x, y);
+ gdk_window_get_origin(gtk_widget_get_window(lw->image->pr), x, y);
popup_menu_position_clamp(menu, x, y, 0);
}
if (info == TARGET_URI_LIST)
{
- list = uri_filelist_from_text((gchar *)selection_data->data, TRUE);
+ list = uri_filelist_from_gtk_selection_data(selection_data);
source = NULL;
info_list = NULL;
}
else
{
- source = collection_from_dnd_data((gchar *)selection_data->data, &list, &info_list);
+ source = collection_from_dnd_data((gchar *)gtk_selection_data_get_data(selection_data), &list, &info_list);
}
if (list)
if (fd)
{
- gchar *text = NULL;
- gint len;
- gboolean plain_text;
GList *list;
- switch (info)
- {
- case TARGET_URI_LIST:
- plain_text = FALSE;
- break;
- case TARGET_TEXT_PLAIN:
- default:
- plain_text = TRUE;
- break;
- }
list = g_list_append(NULL, fd);
- text = uri_text_from_filelist(list, &len, plain_text);
+ uri_selection_data_set_uris_from_filelist(selection_data, list);
g_list_free(list);
- if (text)
- {
- gtk_selection_data_set(selection_data, selection_data->target,
- 8, (guchar *)text, len);
- g_free(text);
- }
}
else
{
- gtk_selection_data_set(selection_data, selection_data->target,
+ gtk_selection_data_set(selection_data, gtk_selection_data_get_target(selection_data),
8, NULL, 0);
}
}
static void layout_image_dnd_end(GtkWidget *widget, GdkDragContext *context, gpointer data)
{
LayoutWindow *lw = data;
- if (context->action == GDK_ACTION_MOVE)
+ if (gdk_drag_context_get_selected_action(context) == GDK_ACTION_MOVE)
{
FileData *fd;
gint row;
image_scroll(lw->image, x, y);
+ if (lw->full_screen && lw->image != lw->full_screen->imd)
+ {
+ image_scroll(lw->full_screen->imd, x, y);
+ }
+
if (!connect_scroll) return;
image_get_image_size(lw->image, &width, &height);
dx = (gdouble) x / width;
dy = (gdouble) y / height;
-
+
for (i = 0; i < MAX_SPLIT_IMAGES; i++)
{
if (lw->split_images[i] && lw->split_images[i] != lw->image)
image_zoom_adjust(lw->image, increment);
+ if (lw->full_screen && lw->image != lw->full_screen->imd)
+ {
+ image_zoom_adjust(lw->full_screen->imd, increment);
+ }
+
if (!connect_zoom) return;
for (i = 0; i < MAX_SPLIT_IMAGES; i++)
image_zoom_adjust_at_point(lw->image, increment, x, y);
- if (!connect_zoom) return;
+ if (lw->full_screen && lw->image != lw->full_screen->imd)
+ {
+ image_zoom_adjust_at_point(lw->full_screen->imd, increment, x, y);
+ }
+ 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);
}
}
image_zoom_set(lw->image, zoom);
+ if (lw->full_screen && lw->image != lw->full_screen->imd)
+ {
+ image_zoom_set(lw->full_screen->imd, zoom);
+ }
+
if (!connect_zoom) return;
for (i = 0; i < MAX_SPLIT_IMAGES; i++)
image_zoom_set_fill_geometry(lw->image, vertical);
+ if (lw->full_screen && lw->image != lw->full_screen->imd)
+ {
+ image_zoom_set_fill_geometry(lw->full_screen->imd, vertical);
+ }
+
if (!connect_zoom) return;
for (i = 0; i < MAX_SPLIT_IMAGES; i++)
{
if (!layout_valid(&lw)) return;
- image_alter_orientation(lw->image, type);
+ GtkTreeModel *store;
+ GList *work;
+ GtkTreeSelection *selection;
+ GtkTreePath *tpath;
+ FileData *fd_n;
+ GtkTreeIter iter;
+ IconData *id;
+
+ 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)
+ {
+ id = work->data;
+ fd_n = id->fd;
+ 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);
+}
+
+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;
+ IconData *id;
+
+ 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)
+ {
+ id = work->data;
+ fd_n = id->fd;
+ 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)
+ {
+ imd->orientation = metadata_read_int(imd->image_fd, ORIENTATION_KEY, 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)
image_change_fd(lw->image, fd, image_zoom_get_default(lw->image));
+ if (lw->full_screen && lw->image != lw->full_screen->imd)
+ {
+ image_change_fd(lw->full_screen->imd, fd, image_zoom_get_default(lw->full_screen->imd));
+ }
+
+
layout_list_sync_fd(lw, fd);
layout_image_slideshow_continue_check(lw);
layout_bars_new_image(lw);
+ layout_image_animate_new_file(lw);
}
void layout_image_set_with_ahead(LayoutWindow *lw, FileData *fd, FileData *read_ahead_fd)
switch (event->button)
{
case MOUSE_BUTTON_LEFT:
- if (lw->split_mode == SPLIT_NONE)
+ if (options->image_lm_click_nav && lw->split_mode == SPLIT_NONE)
layout_image_next(lw);
break;
case MOUSE_BUTTON_MIDDLE:
- if (lw->split_mode == SPLIT_NONE)
+ if (options->image_lm_click_nav && lw->split_mode == SPLIT_NONE)
layout_image_prev(lw);
break;
case MOUSE_BUTTON_RIGHT:
}
- 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;
+ gdouble sx, sy;
+
+ if (lw->full_screen && lw->image != lw->full_screen->imd &&
+ imd != lw->full_screen->imd)
+ {
+ if (event->state & GDK_CONTROL_MASK)
+ {
+ image_get_scroll_center(imd, &sx, &sy);
+ }
+ else
+ {
+ image_get_scroll_center(lw->full_screen->imd, &sx, &sy);
+ sx += dx;
+ sy += dy;
+ }
+ image_set_scroll_center(lw->full_screen->imd, sx, sy);
+ }
if (!(event->state & GDK_SHIFT_MASK)) return;
{
if (lw->split_images[i] && lw->split_images[i] != imd)
{
- gdouble sx, sy;
if (event->state & GDK_CONTROL_MASK)
{
}
-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);
if (width < 1 || height < 1) return;
pixbuf_renderer_get_mouse_position(pr, &x_pixel, &y_pixel);
-
+
if(x_pixel >= 0 && y_pixel >= 0)
{
gint r_mouse, g_mouse, b_mouse;
-
+
pixbuf_renderer_get_pixel_colors(pr, x_pixel, y_pixel,
- &r_mouse, &g_mouse, &b_mouse);
-
+ &r_mouse, &g_mouse, &b_mouse);
+
text = g_strdup_printf(_("[%*d,%*d]: RGB(%3d,%3d,%3d)"),
num_length(width - 1), x_pixel,
num_length(height - 1), y_pixel,
r_mouse, g_mouse, b_mouse);
-
+
}
else
{
{
lw->split_images[i] = image_new(TRUE);
-#if GTK_CHECK_VERSION(2,12,0)
g_object_ref(lw->split_images[i]->widget);
-#else
- gtk_widget_ref(lw->split_images[i]->widget);
-#endif
g_signal_connect(G_OBJECT(lw->split_images[i]->pr), "update-pixel",
G_CALLBACK(layout_status_update_pixel_cb), lw);
// layout_list_sync_path(lw, path);
layout_set_fd(lw, fd);
}
+ layout_status_update_image(lw);
}
layout_image_new(lw, i);
image_set_frame(lw->split_images[i], frame);
image_set_selectable(lw->split_images[i], (n > 1));
-
+
if (lw->image)
{
image_osd_copy_status(lw->image, lw->split_images[i]);
{
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++;
}
}
{
if (lw->split_images[i])
{
-#if GTK_CHECK_VERSION(2,12,0)
g_object_unref(lw->split_images[i]->widget);
-#else
- gtk_widget_unref(lw->split_images[i]->widget);
-#endif
lw->split_images[i] = NULL;
}
}
-
+
if (!lw->image || lw->active_split_image < 0 || lw->active_split_image >= n)
{
layout_image_activate(lw, 0, TRUE);
GtkWidget *layout_image_setup_split_none(LayoutWindow *lw)
{
lw->split_mode = SPLIT_NONE;
-
+
layout_image_setup_split_common(lw, 1);
lw->split_image_widget = lw->split_images[0]->widget;
GtkWidget *layout_image_setup_split_hv(LayoutWindow *lw, gboolean horizontal)
{
GtkWidget *paned;
-
+
lw->split_mode = horizontal ? SPLIT_HOR : SPLIT_VERT;
layout_image_setup_split_common(lw, 2);
}
layout_image_set_fd(lw, NULL);
}
-
- /* the image will be set to the next image from the list soon,
+
+ /* the image will be set to the next image from the list soon,
setting it to NULL here is not necessary*/
}
}
if (!(type & NOTIFY_CHANGE) || !fd->change) return;
DEBUG_1("Notify layout_image: %s %04x", fd->path, type);
-
+
switch (fd->change->type)
{
case FILEDATA_CHANGE_MOVE: