[Goodies-commits] r2972 - ristretto/trunk/src
Stephan Arts
stephan at xfce.org
Wed Aug 8 17:46:46 CEST 2007
Author: stephan
Date: 2007-08-08 15:46:46 +0000 (Wed, 08 Aug 2007)
New Revision: 2972
Modified:
ristretto/trunk/src/main.c
ristretto/trunk/src/navigator.c
ristretto/trunk/src/navigator.h
Log:
Add rotation
Modified: ristretto/trunk/src/main.c
===================================================================
--- ristretto/trunk/src/main.c 2007-08-07 20:40:16 UTC (rev 2971)
+++ ristretto/trunk/src/main.c 2007-08-08 15:46:46 UTC (rev 2972)
@@ -68,6 +68,11 @@
cb_rstto_hide_tv(GtkWidget *widget, RsttoThumbnailViewer *viewer);
static void
+cb_rstto_rotate_cw(GtkWidget *widget, RsttoNavigator *navigator);
+static void
+cb_rstto_rotate_ccw(GtkWidget *widget, RsttoNavigator *navigator);
+
+static void
cb_rstto_key_press_event(GtkWidget *widget, GdkEventKey *event, RsttoNavigator *navigator);
static void
@@ -148,9 +153,13 @@
gtk_menu_shell_append(GTK_MENU_SHELL(menu_file), menu_item_quit);
GtkWidget *menu_item_edit = gtk_menu_item_new_with_mnemonic(_("_Edit"));
+ GtkWidget *menu_item_rotate_left = gtk_menu_item_new_with_mnemonic(_("Rotate _Left"));
+ GtkWidget *menu_item_rotate_right = gtk_menu_item_new_with_mnemonic(_("Rotate _Right"));
GtkWidget *menu_edit = gtk_menu_new();
gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item_edit), menu_edit);
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu_edit), menu_item_rotate_left);
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu_edit), menu_item_rotate_right);
GtkWidget *menu_item_view = gtk_menu_item_new_with_mnemonic(_("_View"));
GtkWidget *menu_item_tv = gtk_menu_item_new_with_mnemonic(_("Thumbnail Viewer"));
@@ -269,6 +278,9 @@
g_signal_connect(G_OBJECT(menu_item_first), "activate", G_CALLBACK(cb_rstto_first), navigator);
g_signal_connect(G_OBJECT(menu_item_last), "activate", G_CALLBACK(cb_rstto_last), navigator);
+ g_signal_connect(G_OBJECT(menu_item_rotate_left), "activate", G_CALLBACK(cb_rstto_rotate_ccw), navigator);
+ g_signal_connect(G_OBJECT(menu_item_rotate_right), "activate", G_CALLBACK(cb_rstto_rotate_cw), navigator);
+
g_signal_connect(G_OBJECT(menu_item_vtv), "activate", G_CALLBACK(cb_rstto_show_tv_v), thumbnail_viewer);
g_signal_connect(G_OBJECT(menu_item_htv), "activate", G_CALLBACK(cb_rstto_show_tv_h), thumbnail_viewer);
g_signal_connect(G_OBJECT(menu_item_ntv), "activate", G_CALLBACK(cb_rstto_hide_tv), thumbnail_viewer);
@@ -553,3 +565,51 @@
{
gtk_widget_hide(GTK_WIDGET(viewer));
}
+
+static void
+cb_rstto_rotate_cw(GtkWidget *widget, RsttoNavigator *navigator)
+{
+ RsttoNavigatorEntry *entry = rstto_navigator_get_file(navigator);
+ GdkPixbufRotation rotation = rstto_navigator_entry_get_rotation(entry);
+ switch (rotation)
+ {
+ case GDK_PIXBUF_ROTATE_NONE:
+ rotation = GDK_PIXBUF_ROTATE_CLOCKWISE;
+ break;
+ case GDK_PIXBUF_ROTATE_CLOCKWISE:
+ rotation = GDK_PIXBUF_ROTATE_UPSIDEDOWN;
+ break;
+ case GDK_PIXBUF_ROTATE_UPSIDEDOWN:
+ rotation = GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE;
+ break;
+ case GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE:
+ rotation = GDK_PIXBUF_ROTATE_NONE;
+ break;
+ }
+
+ rstto_navigator_set_entry_rotation(navigator, entry, rotation);
+}
+
+static void
+cb_rstto_rotate_ccw(GtkWidget *widget, RsttoNavigator *navigator)
+{
+ RsttoNavigatorEntry *entry = rstto_navigator_get_file(navigator);
+ GdkPixbufRotation rotation = rstto_navigator_entry_get_rotation(entry);
+ switch (rotation)
+ {
+ case GDK_PIXBUF_ROTATE_NONE:
+ rotation = GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE;
+ break;
+ case GDK_PIXBUF_ROTATE_CLOCKWISE:
+ rotation = GDK_PIXBUF_ROTATE_NONE;
+ break;
+ case GDK_PIXBUF_ROTATE_UPSIDEDOWN:
+ rotation = GDK_PIXBUF_ROTATE_CLOCKWISE;
+ break;
+ case GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE:
+ rotation = GDK_PIXBUF_ROTATE_UPSIDEDOWN;
+ break;
+ }
+
+ rstto_navigator_set_entry_rotation(navigator, entry, rotation);
+}
Modified: ristretto/trunk/src/navigator.c
===================================================================
--- ristretto/trunk/src/navigator.c 2007-08-07 20:40:16 UTC (rev 2971)
+++ ristretto/trunk/src/navigator.c 2007-08-08 15:46:46 UTC (rev 2972)
@@ -44,8 +44,9 @@
struct _RsttoNavigatorEntry
{
- ThunarVfsInfo *info;
- GdkPixbuf *pixbuf;
+ ThunarVfsInfo *info;
+ GdkPixbuf *pixbuf;
+ GdkPixbufRotation rotation;
};
RsttoNavigatorEntry *
@@ -221,6 +222,16 @@
{
gchar *filename = thunar_vfs_path_dup_string(((ThunarVfsInfo *)((RsttoNavigatorEntry *)navigator->file_iter->data)->info)->path);
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(filename , NULL);
+ if(pixbuf)
+ {
+ RsttoNavigatorEntry *entry = navigator->file_iter->data;
+ GdkPixbuf *new_pixbuf = gdk_pixbuf_rotate_simple(pixbuf, entry->rotation);
+ if(new_pixbuf)
+ {
+ g_object_unref(pixbuf);
+ pixbuf = new_pixbuf;
+ }
+ }
if(!pixbuf)
pixbuf = gtk_icon_theme_load_icon(navigator->icon_theme, GTK_STOCK_MISSING_IMAGE, 48, 0, NULL);
@@ -243,6 +254,16 @@
ThunarVfsInfo *info = rstto_navigator_entry_get_info(((RsttoNavigatorEntry *)navigator->file_iter->data));
gchar *filename = thunar_vfs_path_dup_string(info->path);
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(filename , NULL);
+ if(pixbuf)
+ {
+ RsttoNavigatorEntry *entry = navigator->file_iter->data;
+ GdkPixbuf *new_pixbuf = gdk_pixbuf_rotate_simple(pixbuf, entry->rotation);
+ if(new_pixbuf)
+ {
+ g_object_unref(pixbuf);
+ pixbuf = new_pixbuf;
+ }
+ }
if(!pixbuf)
{
pixbuf = gtk_icon_theme_load_icon(navigator->icon_theme, GTK_STOCK_MISSING_IMAGE, 48, 0, NULL);
@@ -272,6 +293,16 @@
ThunarVfsInfo *info = rstto_navigator_entry_get_info(((RsttoNavigatorEntry *)navigator->file_iter->data));
gchar *filename = thunar_vfs_path_dup_string(info->path);
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(filename , NULL);
+ if(pixbuf)
+ {
+ RsttoNavigatorEntry *entry = navigator->file_iter->data;
+ GdkPixbuf *new_pixbuf = gdk_pixbuf_rotate_simple(pixbuf, entry->rotation);
+ if(new_pixbuf)
+ {
+ g_object_unref(pixbuf);
+ pixbuf = new_pixbuf;
+ }
+ }
if(!pixbuf)
{
pixbuf = gtk_icon_theme_load_icon(navigator->icon_theme, GTK_STOCK_MISSING_IMAGE, 48, 0, NULL);
@@ -300,6 +331,16 @@
ThunarVfsInfo *info = rstto_navigator_entry_get_info(((RsttoNavigatorEntry *)navigator->file_iter->data));
gchar *filename = thunar_vfs_path_dup_string(info->path);
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(filename , NULL);
+ if(pixbuf)
+ {
+ RsttoNavigatorEntry *entry = navigator->file_iter->data;
+ GdkPixbuf *new_pixbuf = gdk_pixbuf_rotate_simple(pixbuf, entry->rotation);
+ if(new_pixbuf)
+ {
+ g_object_unref(pixbuf);
+ pixbuf = new_pixbuf;
+ }
+ }
if(!pixbuf)
{
pixbuf = gtk_icon_theme_load_icon(navigator->icon_theme, GTK_STOCK_MISSING_IMAGE, 48, 0, NULL);
@@ -325,6 +366,16 @@
ThunarVfsInfo *info = rstto_navigator_entry_get_info(((RsttoNavigatorEntry *)navigator->file_iter->data));
gchar *filename = thunar_vfs_path_dup_string(info->path);
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(filename , NULL);
+ if(pixbuf)
+ {
+ RsttoNavigatorEntry *entry = navigator->file_iter->data;
+ GdkPixbuf *new_pixbuf = gdk_pixbuf_rotate_simple(pixbuf, entry->rotation);
+ if(new_pixbuf)
+ {
+ g_object_unref(pixbuf);
+ pixbuf = new_pixbuf;
+ }
+ }
if(!pixbuf)
{
pixbuf = gtk_icon_theme_load_icon(navigator->icon_theme, GTK_STOCK_MISSING_IMAGE, 48, 0, NULL);
@@ -385,6 +436,16 @@
ThunarVfsInfo *info = rstto_navigator_entry_get_info(((RsttoNavigatorEntry *)navigator->file_iter->data));
gchar *filename = thunar_vfs_path_dup_string(info->path);
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(filename , NULL);
+ if(pixbuf)
+ {
+ RsttoNavigatorEntry *entry = navigator->file_iter->data;
+ GdkPixbuf *new_pixbuf = gdk_pixbuf_rotate_simple(pixbuf, entry->rotation);
+ if(new_pixbuf)
+ {
+ g_object_unref(pixbuf);
+ pixbuf = new_pixbuf;
+ }
+ }
if(!pixbuf)
{
pixbuf = gtk_icon_theme_load_icon(navigator->icon_theme, GTK_STOCK_MISSING_IMAGE, 48, 0, NULL);
@@ -429,6 +490,45 @@
return entry->pixbuf;
}
+GdkPixbufRotation
+rstto_navigator_entry_get_rotation (RsttoNavigatorEntry *entry)
+{
+ return entry->rotation;
+}
+
+void
+rstto_navigator_set_entry_rotation (RsttoNavigator *navigator, RsttoNavigatorEntry *entry, GdkPixbufRotation rotation)
+{
+ entry->rotation = rotation;
+ if(entry == navigator->file_iter->data)
+ {
+ ThunarVfsInfo *info = rstto_navigator_entry_get_info(((RsttoNavigatorEntry *)navigator->file_iter->data));
+ gchar *filename = thunar_vfs_path_dup_string(info->path);
+ GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(filename , NULL);
+ if(pixbuf)
+ {
+ GdkPixbuf *new_pixbuf = gdk_pixbuf_rotate_simple(pixbuf, entry->rotation);
+ if(new_pixbuf)
+ {
+ g_object_unref(pixbuf);
+ pixbuf = new_pixbuf;
+ }
+ }
+ if(!pixbuf)
+ {
+ pixbuf = gtk_icon_theme_load_icon(navigator->icon_theme, GTK_STOCK_MISSING_IMAGE, 48, 0, NULL);
+ rstto_picture_viewer_set_scale(navigator->viewer, 1);
+ }
+
+ rstto_picture_viewer_set_pixbuf(navigator->viewer, pixbuf);
+ if(pixbuf)
+ gdk_pixbuf_unref(pixbuf);
+
+ g_free(filename);
+ g_signal_emit(G_OBJECT(navigator), rstto_navigator_signals[RSTTO_NAVIGATOR_SIGNAL_FILE_CHANGED], 0, NULL);
+ }
+}
+
static void
_rstto_navigator_entry_free(RsttoNavigatorEntry *nav_entry)
{
Modified: ristretto/trunk/src/navigator.h
===================================================================
--- ristretto/trunk/src/navigator.h 2007-08-07 20:40:16 UTC (rev 2971)
+++ ristretto/trunk/src/navigator.h 2007-08-08 15:46:46 UTC (rev 2972)
@@ -94,6 +94,11 @@
ThunarVfsInfo *
rstto_navigator_entry_get_info (RsttoNavigatorEntry *entry);
+void
+rstto_navigator_set_entry_rotation (RsttoNavigator *navigator, RsttoNavigatorEntry *entry, GdkPixbufRotation rotation);
+GdkPixbufRotation
+rstto_navigator_entry_get_rotation (RsttoNavigatorEntry *entry);
+
G_END_DECLS
#endif /* __RISTRETTO_NAVIGATOR_H__ */
More information about the Goodies-commits
mailing list