Addl fix #299: File Compression and Archiving
[geeqie.git] / src / layout_image.c
index 74f609a..949b817 100644 (file)
@@ -395,9 +395,9 @@ static void animation_async_ready_cb(GObject *source_object, GAsyncResult *res,
                        {
                        if (!gdk_pixbuf_animation_is_static_image(animation->gpa))
                                {
-                               if (animation->iter = gdk_pixbuf_animation_get_iter(animation->gpa,NULL))
+                               animation->iter = gdk_pixbuf_animation_get_iter(animation->gpa, NULL);
+                               if (animation->iter)
                                        {
-                                       animation->iter = gdk_pixbuf_animation_get_iter(animation->gpa, NULL);
                                        animation->data_adr = animation->lw->image->image_fd;
                                        animation->delay = gdk_pixbuf_animation_iter_get_delay_time(animation->iter);
                                        animation->valid = TRUE;
@@ -516,12 +516,14 @@ static void li_pop_menu_edit_cb(GtkWidget *widget, gpointer data)
        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)
 {
@@ -581,6 +583,17 @@ static void li_pop_menu_copy_path_unquoted_cb(GtkWidget *widget, gpointer 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;
@@ -668,6 +681,27 @@ static void li_set_layout_path_cb(GtkWidget *widget, gpointer data)
        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;
@@ -761,6 +795,12 @@ static GtkWidget *layout_image_pop_menu(LayoutWindow *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);
@@ -771,6 +811,7 @@ static GtkWidget *layout_image_pop_menu(LayoutWindow *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);
        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);
 
@@ -878,7 +919,7 @@ static void layout_image_dnd_receive(GtkWidget *widget, GdkDragContext *context,
        if (info == TARGET_TEXT_PLAIN)
                {
                url = g_strdup((gchar *)gtk_selection_data_get_data(selection_data));
-               download_web_file(url, lw);
+               download_web_file(url, FALSE, lw);
                g_free(url);
                }
        else if (info == TARGET_URI_LIST || info == TARGET_APP_COLLECTION_MEMBER)
@@ -1265,7 +1306,14 @@ void layout_image_reset_orientation(LayoutWindow *lw)
 
        if (options->image.exif_rotate_enable)
                {
-               imd->orientation = metadata_read_int(imd->image_fd, ORIENTATION_KEY, EXIF_ORIENTATION_TOP_LEFT);
+               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
                {
@@ -1308,6 +1356,14 @@ gboolean layout_image_get_overunderexposed(LayoutWindow *lw)
        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)
@@ -1400,6 +1456,11 @@ void layout_image_set_fd(LayoutWindow *lw, FileData *fd)
        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)
@@ -1591,7 +1652,12 @@ void layout_image_next(LayoutWindow *lw)
                        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);
@@ -1664,7 +1730,12 @@ void layout_image_prev(LayoutWindow *lw)
                        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);
@@ -1799,12 +1870,27 @@ static void layout_image_button_cb(ImageWindow *imd, GdkEventButton *event, gpoi
 {
        LayoutWindow *lw = data;
        GtkWidget *menu;
-       FileData *dir_fd;
+       LayoutWindow *lw_new;
+       gchar *dest_dir;
 
        switch (event->button)
                {
                case MOUSE_BUTTON_LEFT:
-                       if (options->image_l_click_video && options->image_l_click_video_editor && imd->image_fd && imd->image_fd->format_class == FORMAT_CLASS_VIDEO)
+                       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);
                                }
@@ -2125,8 +2211,8 @@ void layout_image_activate(LayoutWindow *lw, gint i, gboolean force)
 
        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);