Commit 7f0dd7f6 authored by Paolo Bacchilega's avatar Paolo Bacchilega Committed by Paolo Bacchilega
Browse files

update keyboard shortcuts

2005-12-24  Paolo Bacchilega  <paobac@cvs.gnome.org>

        * doc/C/gthumb.xml: update keyboard shortcuts

        * src/rotation-utils.h:
        * src/rotation-utils.c:
        * src/dlg-photo-importer.c (adjust_orientation__step):
        * src/gth-fullscreen.c (monitor_update_files_cb):

        allow to rotate images in fullscreen mode.

2005-12-23  Paolo Bacchilega  <paobac@cvs.gnome.org>

        * src/gth-browser.c (key_press_cb):
        * src/gth-fullscreen.c (viewer_key_press_cb):
        * src/gth-viewer.c (viewer_key_press_cb): use [ ] to do lossless
        rotation. r e to rotate the image without saving.

        Fixes bug #319467  Add keyboard shortcut to Lossless JPEG rotation.

        * src/gth-browser.c (gth_browser_notify_files_created): check
        parent_dir before using it.
parent a46415d5
2005-12-24 Paolo Bacchilega <paobac@cvs.gnome.org>
* doc/C/gthumb.xml: update keyboard shortcuts
* src/rotation-utils.h:
* src/rotation-utils.c:
* src/dlg-photo-importer.c (adjust_orientation__step):
* src/gth-fullscreen.c (monitor_update_files_cb):
allow to rotate images in fullscreen mode.
2005-12-23 Paolo Bacchilega <paobac@cvs.gnome.org>
* src/gth-browser.c (key_press_cb):
* src/gth-fullscreen.c (viewer_key_press_cb):
* src/gth-viewer.c (viewer_key_press_cb): use [ ] to do lossless
rotation. r e to rotate the image without saving.
Fixes bug #319467 – Add keyboard shortcut to Lossless JPEG rotation.
* src/gth-browser.c (gth_browser_notify_files_created): check
parent_dir before using it.
......
......@@ -2403,24 +2403,6 @@
linkend="gthumb-TBL-keyword-shortcuts-fullscreen"/> provide a quick
reference for all of the &gthumb; keyword shortcuts. Look in the
menus for other shortcuts.</para>
<para>
<note>
<title>NOTE</title>
<para>
When the <guilabel>location</guilabel> entry is focused you
can use
<keycombo><keycap>Tab</keycap></keycombo>
to display a list of possible location completions.
</para>
</note>
<note>
<title>WARNING</title>
<para>
When the <guilabel>location</guilabel> entry is focused
keyword shortcuts are not available.
</para>
</note>
</para>
<para>
<table id="gthumb-TBL-keyword-shortcuts-browser" frame="topbot">
<title>Keyboard shortcuts to navigate folders</title>
......@@ -2830,12 +2812,38 @@
<row rowsep="0">
<entry>
<para>
<keycombo><keycap>r</keycap></keycombo> or
<keycombo><keycap>]</keycap></keycombo>
<keycombo><keycap>r</keycap></keycombo>
</para>
</entry>
<entry>
<para>Rotate the image clockwise of 90 degrees without saving.</para>
</entry>
<entry>
<para>yes</para>
</entry>
</row>
<row rowsep="0">
<entry>
<para>
<keycombo><keycap>e</keycap></keycombo>
</para>
</entry>
<entry>
<para>Rotate the image counter-clockwise of 90 degrees without saving.</para>
</entry>
<entry>
<para>yes</para>
</entry>
</row>
<row rowsep="0">
<entry>
<para>
<keycombo><keycap>]</keycap></keycombo>
</para>
</entry>
<entry>
<para>Rotate the image clockwise of 90 degrees.</para>
<para>Rotate and save the image clockwise of 90 degrees. The rotation is lossless for jpeg images.</para>
</entry>
<entry>
<para>yes</para>
......@@ -2848,12 +2856,13 @@
</para>
</entry>
<entry>
<para>Rotate the image counter-clockwise of 90 degrees.</para>
<para>Rotate and save the image counter-clockwise of 90 degrees. The rotation is lossless for jpeg images.</para>
</entry>
<entry>
<para>yes</para>
</entry>
</row>
<row rowsep="0">
<entry>
<para>
......
......@@ -41,7 +41,6 @@
#include "jpegutils/jpeg-data.h"
#endif /* HAVE_LIBEXIF */
#include "file-data.h"
#include "file-utils.h"
#include "gconf-utils.h"
#include "gth-window.h"
......@@ -94,7 +93,7 @@ dialog_data_free (DialogData *data)
all_windows_add_monitor ();
file_data_list_free (data->file_list);
path_list_free (data->file_list);
if (data->loader != NULL)
g_object_unref (data->loader);
if (data->gui != NULL)
......@@ -245,7 +244,7 @@ image_loader_error_cb (ImageLoader *il,
static void
load_current_image (DialogData *data)
{
FileData *fd;
char *path;
if (data->current_image == NULL) {
gtk_widget_destroy (data->dialog);
......@@ -255,8 +254,8 @@ load_current_image (DialogData *data)
gtk_widget_set_sensitive (data->j_button_vbox, FALSE);
gtk_widget_set_sensitive (data->j_revert_button, FALSE);
fd = data->current_image->data;
image_loader_set_path (data->loader, fd->path);
path = data->current_image->data;
image_loader_set_path (data->loader, path);
image_loader_start (data->loader);
data->rot_data->rot_type = GTH_TRANSFORM_ROTATE_0;
......@@ -302,14 +301,14 @@ apply_transformation (DialogData *data,
GList *current_image,
gboolean notify_soon)
{
FileData *fd = current_image->data;
char *path = current_image->data;
char *dir;
GnomeVFSFileInfo info;
GtkWindow *window = GTK_WINDOW (data->dialog);
/* Check directory permissions. */
dir = remove_level_from_path (fd->path);
dir = remove_level_from_path (path);
if (! check_permissions (dir, R_OK | W_OK | X_OK)) {
char *utf8_path = g_filename_display_name (dir);
_gtk_error_dialog_run (GTK_WINDOW (data->dialog),
......@@ -324,15 +323,15 @@ apply_transformation (DialogData *data,
/**/
if (data->from_exif_data)
update_rotation_from_exif_data (fd, data->rot_data);
gnome_vfs_get_file_info (fd->path, &info, GNOME_VFS_FILE_INFO_GET_ACCESS_RIGHTS|GNOME_VFS_FILE_INFO_FOLLOW_LINKS);
if (image_is_jpeg (fd->path))
apply_transformation_jpeg (window, fd, data->rot_data);
update_rotation_from_exif_data (path, data->rot_data);
gnome_vfs_get_file_info (path, &info, GNOME_VFS_FILE_INFO_GET_ACCESS_RIGHTS|GNOME_VFS_FILE_INFO_FOLLOW_LINKS);
if (image_is_jpeg (path))
apply_transformation_jpeg (window, path, data->rot_data);
else
apply_transformation_generic (window, fd, data->rot_data);
gnome_vfs_set_file_info (fd->path, &info, GNOME_VFS_SET_FILE_INFO_PERMISSIONS|GNOME_VFS_SET_FILE_INFO_OWNER);
apply_transformation_generic (window, path, data->rot_data);
gnome_vfs_set_file_info (path, &info, GNOME_VFS_SET_FILE_INFO_PERMISSIONS|GNOME_VFS_SET_FILE_INFO_OWNER);
notify_file_changed (data, fd->path, notify_soon);
notify_file_changed (data, path, notify_soon);
}
......@@ -372,9 +371,13 @@ apply_transformation_to_all (DialogData *data)
i = 0;
for (scan = data->current_image; scan; scan = scan->next) {
FileData *fd = scan->data;
_gtk_label_set_filename_text (GTK_LABEL (label), fd->name);
char *path = scan->data;
char *name;
name = g_filename_display_basename (path);
_gtk_label_set_filename_text (GTK_LABEL (label), name);
g_free (name);
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (bar),
(gdouble) (i + 0.5) / n);
......@@ -614,7 +617,7 @@ dlg_jpegtran (GthWindow *window)
GList *list;
list = gth_window_get_file_list_selection_as_fd (window);
list = gth_window_get_file_list_selection (window);
if (list == NULL) {
g_warning ("No file selected.");
return;
......@@ -633,7 +636,7 @@ dlg_jpegtran (GthWindow *window)
if (! data->gui) {
g_warning ("Could not find " ROTATE_GLADE_FILE "\n");
if (data->file_list != NULL)
g_list_free (data->file_list);
path_list_free (data->file_list);
g_free (data);
return;
}
......@@ -754,7 +757,7 @@ dlg_apply_jpegtran (GthWindow *window,
DialogData *data;
GList *list;
list = gth_window_get_file_list_selection_as_fd (window);
list = gth_window_get_file_list_selection (window);
if (list == NULL) {
g_warning ("No file selected.");
return;
......@@ -782,7 +785,7 @@ dlg_apply_jpegtran_from_exif (GthWindow *window)
DialogData *data;
GList *list;
list = gth_window_get_file_list_selection_as_fd (window);
list = gth_window_get_file_list_selection (window);
if (list == NULL) {
g_warning ("No file selected.");
return;
......
......@@ -1343,11 +1343,11 @@ adjust_orientation__step (AsyncOperationData *aodata,
FileData *fd = file_data_new (filepath, &info);
RotationData *rot_data = rotation_data_new ();
update_rotation_from_exif_data (fd, rot_data);
update_rotation_from_exif_data (fd->path, rot_data);
if (image_is_jpeg (filepath))
apply_transformation_jpeg (window, fd, rot_data);
apply_transformation_jpeg (window, fd->path, rot_data);
else
apply_transformation_generic (window, fd, rot_data);
apply_transformation_generic (window, fd->path, rot_data);
file_data_unref (fd);
g_free (rot_data);
......
......@@ -2969,6 +2969,7 @@ key_press_cb (GtkWidget *widget,
gpointer data)
{
GthBrowser *browser = data;
GthWindow *window = (GthWindow*) browser;
GthBrowserPrivateData *priv = browser->priv;
ImageViewer *viewer = IMAGE_VIEWER (priv->viewer);
gboolean sel_not_null;
......@@ -3112,27 +3113,36 @@ key_press_cb (GtkWidget *widget,
}
break;
/* Rotate image */
case GDK_bracketright:
/* Rotate clockwise without saving */
case GDK_r:
gth_window_activate_action_alter_image_rotate90 (NULL, browser);
gth_window_activate_action_alter_image_rotate90 (NULL, window);
return TRUE;
/* Rotate counter-clockwise without saving */
case GDK_e:
gth_window_activate_action_alter_image_rotate90cc (NULL, window);
return TRUE;
/* Lossless clockwise rotation. */
case GDK_bracketright:
gth_window_activate_action_tools_jpeg_rotate_right (NULL, window);
return TRUE;
/* Lossless counter-clockwise rotation */
case GDK_bracketleft:
gth_window_activate_action_tools_jpeg_rotate_left (NULL, window);
return TRUE;
/* Flip image */
case GDK_l:
gth_window_activate_action_alter_image_flip (NULL, browser);
gth_window_activate_action_alter_image_flip (NULL, window);
return TRUE;
/* Mirror image */
case GDK_m:
gth_window_activate_action_alter_image_mirror (NULL, browser);
gth_window_activate_action_alter_image_mirror (NULL, window);
return TRUE;
/* Rotate image counter-clockwise */
case GDK_bracketleft:
gth_window_activate_action_alter_image_rotate90cc (NULL, browser);
return TRUE;
/* Delete selection. */
case GDK_Delete:
case GDK_KP_Delete:
......
......@@ -1174,25 +1174,34 @@ viewer_key_press_cb (GtkWidget *widget,
}
break;
/* Rotate image */
case GDK_bracketright:
/* Rotate clockwise without saving */
case GDK_r:
gth_window_activate_action_alter_image_rotate90 (NULL, fullscreen);
gth_window_activate_action_alter_image_rotate90 (NULL, window);
return TRUE;
/* Rotate counter-clockwise without saving */
case GDK_e:
gth_window_activate_action_alter_image_rotate90cc (NULL, window);
return TRUE;
/* Lossless clockwise rotation. */
case GDK_bracketright:
gth_window_activate_action_tools_jpeg_rotate_right (NULL, window);
return TRUE;
/* Lossless counter-clockwise rotation */
case GDK_bracketleft:
gth_window_activate_action_tools_jpeg_rotate_left (NULL, window);
return TRUE;
/* Flip image */
case GDK_l:
gth_window_activate_action_alter_image_flip (NULL, fullscreen);
gth_window_activate_action_alter_image_flip (NULL, window);
return TRUE;
/* Mirror image */
case GDK_m:
gth_window_activate_action_alter_image_mirror (NULL, fullscreen);
return TRUE;
/* Rotate image counter-clockwise */
case GDK_bracketleft:
gth_window_activate_action_alter_image_rotate90cc (NULL, fullscreen);
gth_window_activate_action_alter_image_mirror (NULL, window);
return TRUE;
/* Delete selection. */
......@@ -1337,10 +1346,19 @@ monitor_update_files_cb (GthMonitor *monitor,
switch (event) {
case GTH_MONITOR_EVENT_CREATED:
case GTH_MONITOR_EVENT_CHANGED:
if ((fullscreen->priv->image_path != NULL)
&& (g_list_find_custom (list,
fullscreen->priv->image_path,
(GCompareFunc) strcmp) != NULL)) {
g_free (fullscreen->priv->image_path);
fullscreen->priv->image_path = NULL;
if (fullscreen->priv->image != NULL)
g_object_unref (fullscreen->priv->image);
}
if ((fullscreen->priv->current != NULL)
&& (g_list_find_custom (list,
fullscreen->priv->current->data,
(GCompareFunc) strcmp) == NULL))
(GCompareFunc) strcmp) != NULL))
load_current_image (fullscreen);
break;
......
......@@ -1139,6 +1139,7 @@ viewer_key_press_cb (GtkWidget *widget,
gpointer data)
{
GthViewer *viewer = data;
GthWindow *window = (GthWindow*) viewer;
ImageViewer *image_viewer = (ImageViewer*)viewer->priv->viewer;
gboolean retval = FALSE;
......@@ -1191,30 +1192,35 @@ viewer_key_press_cb (GtkWidget *widget,
retval = TRUE;
break;
/* Rotate image */
case GDK_bracketright:
/* Rotate clockwise without saving */
case GDK_r:
gth_window_activate_action_alter_image_rotate90 (NULL, viewer);
retval = TRUE;
break;
gth_window_activate_action_alter_image_rotate90 (NULL, window);
return TRUE;
/* Rotate counter-clockwise without saving */
case GDK_e:
gth_window_activate_action_alter_image_rotate90cc (NULL, window);
return TRUE;
/* Lossless clockwise rotation. */
case GDK_bracketright:
gth_window_activate_action_tools_jpeg_rotate_right (NULL, window);
return TRUE;
/* Lossless counter-clockwise rotation */
case GDK_bracketleft:
gth_window_activate_action_tools_jpeg_rotate_left (NULL, window);
return TRUE;
/* Flip image */
case GDK_l:
gth_window_activate_action_alter_image_flip (NULL, viewer);
retval = TRUE;
break;
gth_window_activate_action_alter_image_flip (NULL, window);
return TRUE;
/* Mirror image */
case GDK_m:
gth_window_activate_action_alter_image_mirror (NULL, viewer);
retval = TRUE;
break;
/* Rotate image counter-clockwise */
case GDK_bracketleft:
gth_window_activate_action_alter_image_rotate90cc (NULL, viewer);
retval = TRUE;
break;
gth_window_activate_action_alter_image_mirror (NULL, window);
return TRUE;
/* Full screen view. */
case GDK_v:
......
......@@ -21,11 +21,17 @@
*/
#include <config.h>
#include <unistd.h>
#include <sys/types.h>
#include "file-data.h"
#include <libgnomevfs/gnome-vfs-mime.h>
#include "file-utils.h"
#include "gtk-utils.h"
#include "pixbuf-utils.h"
#include "rotation-utils.h"
#include "jpegutils/jpeg-data.h"
#include "jpegutils/transupp.h"
#include "jpegutils/jpegtran.h"
RotationData*
......@@ -42,11 +48,11 @@ rotation_data_new ()
void
update_rotation_from_exif_data (FileData *fd,
update_rotation_from_exif_data (const char *path,
RotationData *rot_data)
{
#ifdef HAVE_LIBEXIF
GthExifOrientation orientation = get_exif_tag_short (fd->path, EXIF_TAG_ORIENTATION);
GthExifOrientation orientation = get_exif_tag_short (path, EXIF_TAG_ORIENTATION);
#endif /* HAVE_LIBEXIF */
rot_data->rot_type = GTH_TRANSFORM_ROTATE_0;
......@@ -97,7 +103,7 @@ update_rotation_from_exif_data (FileData *fd,
void
apply_transformation_jpeg (GtkWindow *win,
FileData *fd,
const char *path,
RotationData *rot_data)
{
int rot_type = rot_data->rot_type;
......@@ -118,7 +124,7 @@ apply_transformation_jpeg (GtkWindow *win,
return;
if (rot_type == GTH_TRANSFORM_ROTATE_0)
tmp1 = g_strdup (fd->path);
tmp1 = g_strdup (path);
else {
tmp1 = g_strdup_printf ("%s/gthumb.%d.%d",
g_get_tmp_dir (),
......@@ -141,7 +147,7 @@ apply_transformation_jpeg (GtkWindow *win,
break;
}
if (jpegtran (fd->path, tmp1, transf, &err) != 0) {
if (jpegtran (path, tmp1, transf, &err) != 0) {
g_free (tmp1);
if (err != NULL)
_gtk_error_dialog_from_gerror_run (win, &err);
......@@ -164,7 +170,7 @@ apply_transformation_jpeg (GtkWindow *win,
}
e1 = shell_escape (tmp1);
e2 = shell_escape (fd->path);
e2 = shell_escape (path);
line = g_strdup_printf ("jpegtran -copy all %s -outfile %s %s",
command, e1, e2);
......@@ -243,7 +249,7 @@ apply_transformation_jpeg (GtkWindow *win,
}
e1 = shell_escape (tmp2);
e2 = shell_escape (fd->path);
e2 = shell_escape (path);
line = g_strdup_printf ("mv -f %s %s", e1, e2);
g_spawn_command_line_sync (line, NULL, NULL, NULL, &err);
......@@ -254,8 +260,8 @@ apply_transformation_jpeg (GtkWindow *win,
} else {
#ifdef HAVE_LIBEXIF
if ((rot_type == GTH_TRANSFORM_ROTATE_90) || (rot_type == GTH_TRANSFORM_ROTATE_270))
swap_xy_exif_fields (fd->path);
/* update_orientation_field (fd, rot_data); see bug #318828 */
swap_xy_exif_fields (path);
/* update_orientation_field (path, rot_data); see bug #318828 */
#endif
}
......@@ -269,7 +275,7 @@ apply_transformation_jpeg (GtkWindow *win,
void
apply_transformation_generic (GtkWindow *win,
FileData *fd,
const char *path,
RotationData *rot_data)
{
int rot_type = rot_data->rot_type;
......@@ -280,7 +286,7 @@ apply_transformation_generic (GtkWindow *win,
if ((rot_type == GTH_TRANSFORM_ROTATE_0) && (tran_type == GTH_TRANSFORM_NONE))
return;
pixbuf1 = gdk_pixbuf_new_from_file (fd->path, NULL);
pixbuf1 = gdk_pixbuf_new_from_file (path, NULL);
if (pixbuf1 == NULL)
return;
......@@ -315,12 +321,12 @@ apply_transformation_generic (GtkWindow *win,
}
g_object_unref (pixbuf2);
mime_type = gnome_vfs_mime_type_from_name (fd->path);
mime_type = gnome_vfs_mime_type_from_name (path);
if ((mime_type != NULL) && is_mime_type_writable (mime_type)) {
GError *error = NULL;
const char *image_type = mime_type + 6;
if (! _gdk_pixbuf_save (pixbuf1,
fd->path,
path,
image_type,
&error,
NULL))
......@@ -357,7 +363,7 @@ get_next_value_flip (int value)
void
update_orientation_field (FileData *fd,
update_orientation_field (const char *path,
RotationData *rot_data)
{
JPEGData *jdata;
......@@ -365,7 +371,7 @@ update_orientation_field (FileData *fd,
unsigned int i;
gboolean orientation_changed = FALSE;
jdata = jpeg_data_new_from_file (fd->path);
jdata = jpeg_data_new_from_file (path);
if (jdata == NULL)
return;
......@@ -424,7 +430,7 @@ update_orientation_field (FileData *fd,
}
}
jpeg_data_save_file (jdata, fd->path);
jpeg_data_save_file (jdata, path);
exif_data_unref (edata);
jpeg_data_unref (jdata);
......
......@@ -26,7 +26,6 @@
#include <config.h>
#include <gtk/gtk.h>
#include "typedefs.h"
#include "file-data.h"
#ifdef HAVE_LIBEXIF
#include "gth-exif-utils.h"
......@@ -38,27 +37,27 @@ struct _RotationData {
GthTransform tran_type;
};
RotationData* rotation_data_new ();
RotationData* rotation_data_new ();
void update_rotation_from_exif_data (FileData *fd,
RotationData *rot_data);
void apply_transformation_jpeg (GtkWindow *win,
FileData *fd,
RotationData *rot_data);
void apply_transformation_generic (GtkWindow *win,
FileData *fd,
RotationData *rot_data);
void update_rotation_from_exif_data (const char *filename,
RotationData *rot_data);
void apply_transformation_jpeg (GtkWindow *win,
const char *filename,
RotationData *rot_data);
void apply_transformation_generic (GtkWindow *win,
const char *filename,
RotationData *rot_data);
#ifdef HAVE_LIBEXIF
ExifShort get_next_value_rotation_90 (int value);
ExifShort get_next_value_mirror (int value);
ExifShort get_next_value_flip (int value);
void update_orientation_field (FileData *fd,
RotationData *rot_data);
gboolean swap_fields (ExifContent *content,
ExifTag tag1,
ExifTag tag2);
void swap_xy_exif_fields (const char *filename);
ExifShort get_next_value_rotation_90 (int value);
ExifShort get_next_value_mirror (int value);
ExifShort get_next_value_flip (int value);
void update_orientation_field (const char *filename,
RotationData *rot_data);
gboolean swap_fields (ExifContent *content,
ExifTag tag1,
ExifTag tag2);
void swap_xy_exif_fields (const char *filename);
#endif /* HAVE_LIBEXIF */
#endif /* ROTATION_UTILS_H */