[gthumb: 100/129] rotate tool: improved UI and fixed memory leak
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb: 100/129] rotate tool: improved UI and fixed memory leak
- Date: Wed, 27 Apr 2011 20:58:47 +0000 (UTC)
commit 44fecbf90877f1f8af4562d77af91c7115adc101
Author: Stefano Pettini <spettini users sourceforge net>
Date: Wed Apr 20 16:52:42 2011 +0100
rotate tool: improved UI and fixed memory leak
extensions/file_tools/data/ui/rotate-options.ui | 49 +++++++++++++++++++++++
extensions/file_tools/gdk-pixbuf-rotate.c | 3 +-
extensions/file_tools/gdk-pixbuf-rotate.h | 3 +-
extensions/file_tools/gth-file-tool-rotate.c | 19 +++++++--
4 files changed, 68 insertions(+), 6 deletions(-)
---
diff --git a/extensions/file_tools/data/ui/rotate-options.ui b/extensions/file_tools/data/ui/rotate-options.ui
index 9ad6c9a..03123e7 100644
--- a/extensions/file_tools/data/ui/rotate-options.ui
+++ b/extensions/file_tools/data/ui/rotate-options.ui
@@ -58,6 +58,55 @@
<property name="position">0</property>
</packing>
</child>
+ <child>
+ <object class="GtkFrame" id="frame1">
+ <property name="visible">True</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="alignment1">
+ <property name="visible">True</property>
+ <property name="top_padding">6</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkVBox" id="vbox3">
+ <property name="visible">True</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkCheckButton" id="auto_crop">
+ <property name="label" translatable="yes">A_uto-crop</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="tooltip_text" translatable="yes">Whether to crop automatically the image to avoid black areas after rotation</property>
+ <property name="use_underline">True</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Settings</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
diff --git a/extensions/file_tools/gdk-pixbuf-rotate.c b/extensions/file_tools/gdk-pixbuf-rotate.c
index 3b85c44..b90dcb9 100644
--- a/extensions/file_tools/gdk-pixbuf-rotate.c
+++ b/extensions/file_tools/gdk-pixbuf-rotate.c
@@ -25,7 +25,8 @@
GdkPixbuf*
_gdk_pixbuf_rotate (GdkPixbuf *src_pixbuf,
- double angle)
+ double angle,
+ gint auto_crop)
{
GdkPixbuf *new_pixbuf;
diff --git a/extensions/file_tools/gdk-pixbuf-rotate.h b/extensions/file_tools/gdk-pixbuf-rotate.h
index e0cc9c6..4566f5e 100644
--- a/extensions/file_tools/gdk-pixbuf-rotate.h
+++ b/extensions/file_tools/gdk-pixbuf-rotate.h
@@ -29,7 +29,8 @@
G_BEGIN_DECLS
GdkPixbuf* _gdk_pixbuf_rotate (GdkPixbuf *src_pixbuf,
- double angle);
+ double angle,
+ gint auto_crop);
G_END_DECLS
diff --git a/extensions/file_tools/gth-file-tool-rotate.c b/extensions/file_tools/gth-file-tool-rotate.c
index 52f18ca..c4db81b 100644
--- a/extensions/file_tools/gth-file-tool-rotate.c
+++ b/extensions/file_tools/gth-file-tool-rotate.c
@@ -43,6 +43,7 @@ struct _GthFileToolRotatePrivate {
int screen_width;
int screen_height;
GtkAdjustment *rotation_angle_adj;
+ GtkWidget *auto_crop;
guint apply_event;
};
@@ -106,6 +107,7 @@ apply_cb (gpointer user_data)
GtkWidget *window;
GtkWidget *viewer_page;
double rotation_angle;
+ gint auto_crop;
if (self->priv->apply_event != 0) {
g_source_remove (self->priv->apply_event);
@@ -116,11 +118,15 @@ apply_cb (gpointer user_data)
viewer_page = gth_browser_get_viewer_page (GTH_BROWSER (window));
rotation_angle = gtk_adjustment_get_value (self->priv->rotation_angle_adj);
+ auto_crop = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->priv->auto_crop));
+
+ if (rotation_angle != 0.0) {
+ _g_object_unref (self->priv->dest_pixbuf);
+ self->priv->dest_pixbuf = _gdk_pixbuf_rotate (self->priv->src_pixbuf, rotation_angle, auto_crop);
- self->priv->dest_pixbuf = _gdk_pixbuf_rotate (self->priv->src_pixbuf, rotation_angle);
-
- gth_image_viewer_page_set_pixbuf (GTH_IMAGE_VIEWER_PAGE (viewer_page), self->priv->dest_pixbuf, FALSE);
-
+ gth_image_viewer_page_set_pixbuf (GTH_IMAGE_VIEWER_PAGE (viewer_page), self->priv->dest_pixbuf, FALSE);
+ }
+
return FALSE;
}
@@ -173,6 +179,7 @@ gth_file_tool_rotate_get_options (GthFileTool *base)
options = _gtk_builder_get_widget (self->priv->builder, "options");
gtk_widget_show (options);
self->priv->rotation_angle_adj = (GtkAdjustment *) gtk_builder_get_object (self->priv->builder, "rotation_angle_adjustment");
+ self->priv->auto_crop = _gtk_builder_get_widget (self->priv->builder, "auto_crop");
g_signal_connect (GET_WIDGET ("apply_button"),
"clicked",
@@ -186,6 +193,10 @@ gth_file_tool_rotate_get_options (GthFileTool *base)
"value-changed",
G_CALLBACK (value_changed_cb),
self);
+ g_signal_connect (G_OBJECT (self->priv->auto_crop),
+ "toggled",
+ G_CALLBACK (value_changed_cb),
+ self);
return options;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]