Addl fix #299: File Compression and Archiving
[geeqie.git] / src / layout_image.c
index 8d49985..949b817 100644 (file)
@@ -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);
 
@@ -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
                {
@@ -1604,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);
@@ -1677,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);
@@ -1812,11 +1870,27 @@ static void layout_image_button_cb(ImageWindow *imd, GdkEventButton *event, gpoi
 {
        LayoutWindow *lw = data;
        GtkWidget *menu;
+       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);
                                }
@@ -2135,10 +2209,10 @@ void layout_image_activate(LayoutWindow *lw, gint i, gboolean force)
        layout_image_set_buttons(lw);
        image_set_drag_func(lw->image, layout_image_drag_cb, lw);
 
-       image_attach_window(lw->image, lw->window, NULL, g_strcmp0(lw->options.id, "main") == 0 ? GQ_APPNAME : GQ_APPNAME_LC, FALSE);
+       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);