[gthumb: 95/129] rotate tool: initial empty implementation
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb: 95/129] rotate tool: initial empty implementation
- Date: Wed, 27 Apr 2011 20:58:22 +0000 (UTC)
commit 140662eb9e8c87c8b09ed16606afd9709b7354fa
Author: Stefano Pettini <spettini users sourceforge net>
Date: Mon Apr 18 19:44:29 2011 +0100
rotate tool: initial empty implementation
extensions/file_tools/Makefile.am | 4 +
extensions/file_tools/data/ui/Makefile.am | 1 +
extensions/file_tools/data/ui/rotate-options.ui | 130 ++++++++++++
extensions/file_tools/gdk-pixbuf-rotate.c | 31 +++
extensions/file_tools/gdk-pixbuf-rotate.h | 36 ++++
extensions/file_tools/gth-file-tool-rotate.c | 247 +++++++++++++++++++++++
extensions/file_tools/gth-file-tool-rotate.h | 53 +++++
extensions/file_tools/main.c | 2 +
8 files changed, 504 insertions(+), 0 deletions(-)
---
diff --git a/extensions/file_tools/Makefile.am b/extensions/file_tools/Makefile.am
index c09df38..6e16db0 100644
--- a/extensions/file_tools/Makefile.am
+++ b/extensions/file_tools/Makefile.am
@@ -9,6 +9,7 @@ ENUM_TYPES = \
HEADER_FILES = \
gdk-pixbuf-blur.h \
+ gdk-pixbuf-rotate.h \
gth-file-tool-adjust-colors.h \
gth-file-tool-crop.h \
gth-file-tool-desaturate.h \
@@ -21,6 +22,7 @@ HEADER_FILES = \
gth-file-tool-resize.h \
gth-file-tool-rotate-left.h \
gth-file-tool-rotate-right.h \
+ gth-file-tool-rotate.h \
gth-file-tool-save.h \
gth-file-tool-save-as.h \
gth-file-tool-sharpen.h \
@@ -54,6 +56,7 @@ libfile_tools_la_SOURCES = \
callbacks.c \
callbacks.h \
gdk-pixbuf-blur.c \
+ gdk-pixbuf-rotate.c \
gth-file-tool-adjust-colors.c \
gth-file-tool-crop.c \
gth-file-tool-desaturate.c \
@@ -66,6 +69,7 @@ libfile_tools_la_SOURCES = \
gth-file-tool-resize.c \
gth-file-tool-rotate-left.c \
gth-file-tool-rotate-right.c \
+ gth-file-tool-rotate.c \
gth-file-tool-save.c \
gth-file-tool-save-as.c \
gth-file-tool-sharpen.c \
diff --git a/extensions/file_tools/data/ui/Makefile.am b/extensions/file_tools/data/ui/Makefile.am
index 1442bc2..cc7927b 100644
--- a/extensions/file_tools/data/ui/Makefile.am
+++ b/extensions/file_tools/data/ui/Makefile.am
@@ -3,6 +3,7 @@ ui_DATA = \
adjust-colors-options.ui \
crop-options.ui \
resize-options.ui \
+ rotate-options.ui \
sharpen-options.ui
EXTRA_DIST = $(ui_DATA)
diff --git a/extensions/file_tools/data/ui/rotate-options.ui b/extensions/file_tools/data/ui/rotate-options.ui
new file mode 100644
index 0000000..ef95870
--- /dev/null
+++ b/extensions/file_tools/data/ui/rotate-options.ui
@@ -0,0 +1,130 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <requires lib="gtk+" version="2.16"/>
+ <!-- interface-naming-policy project-wide -->
+ <object class="GtkAlignment" id="options">
+ <property name="visible">True</property>
+ <property name="top_padding">6</property>
+ <child>
+ <object class="GtkVBox" id="vbox2">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkVBox" id="vbox1">
+ <property name="visible">True</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkFrame" id="frame4">
+ <property name="visible">True</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="alignment12">
+ <property name="visible">True</property>
+ <property name="top_padding">6</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkVBox" id="vbox10">
+ <property name="visible">True</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkHScale" id="rotation_angle">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="adjustment">rotation_angle_adjustment</property>
+ <property name="restrict_to_fill_level">False</property>
+ <property name="fill_level">0</property>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label15">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Rotation angle</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">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHSeparator" id="hseparator1">
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="padding">6</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHButtonBox" id="hbuttonbox1">
+ <property name="visible">True</property>
+ <property name="spacing">12</property>
+ <property name="layout_style">center</property>
+ <child>
+ <object class="GtkButton" id="rotate_button">
+ <property name="label">gtk-ok</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_underline">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="cancel_button">
+ <property name="label">gtk-cancel</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ <property name="xalign">0.47999998927116394</property>
+ </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>
+ <property name="fill">False</property>
+ <property name="padding">6</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <object class="GtkAdjustment" id="rotation_angle_adjustment">
+ <property name="lower">-180</property>
+ <property name="upper">180</property>
+ <property name="step_increment">0.10000000000000001</property>
+ <property name="page_increment">1</property>
+ <property name="page_size">1</property>
+ </object>
+</interface>
diff --git a/extensions/file_tools/gdk-pixbuf-rotate.c b/extensions/file_tools/gdk-pixbuf-rotate.c
new file mode 100644
index 0000000..bd80807
--- /dev/null
+++ b/extensions/file_tools/gdk-pixbuf-rotate.c
@@ -0,0 +1,31 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * GThumb
+ *
+ * Copyright (C) 2011 The Free Software Foundation, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "gdk-pixbuf-rotate.h"
+
+
+
+void
+_gdk_pixbuf_rotate (GdkPixbuf *src,
+ double angle)
+{
+ // TODO: implemement all
+}
diff --git a/extensions/file_tools/gdk-pixbuf-rotate.h b/extensions/file_tools/gdk-pixbuf-rotate.h
new file mode 100644
index 0000000..6ecbedb
--- /dev/null
+++ b/extensions/file_tools/gdk-pixbuf-rotate.h
@@ -0,0 +1,36 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * GThumb
+ *
+ * Copyright (C) 2011 The Free Software Foundation, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GDK_PIXBUF_ROTATE_H
+#define GDK_PIXBUF_ROTATE_H
+
+#include <glib.h>
+#include <gdk/gdk.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
+
+G_BEGIN_DECLS
+
+void _gdk_pixbuf_rotate (GdkPixbuf *src,
+ double angle);
+
+G_END_DECLS
+
+#endif /* GDK_PIXBUF_ROTATE_H */
diff --git a/extensions/file_tools/gth-file-tool-rotate.c b/extensions/file_tools/gth-file-tool-rotate.c
new file mode 100644
index 0000000..870802b
--- /dev/null
+++ b/extensions/file_tools/gth-file-tool-rotate.c
@@ -0,0 +1,247 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * GThumb
+ *
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <gthumb.h>
+#include <extensions/image_viewer/gth-image-viewer-page.h>
+#include "enum-types.h"
+#include "gth-file-tool-rotate.h"
+
+
+#define GET_WIDGET(x) (_gtk_builder_get_widget (self->priv->builder, (x)))
+
+
+static gpointer parent_class = NULL;
+
+
+struct _GthFileToolRotatePrivate {
+ GdkPixbuf *src_pixbuf;
+ GtkBuilder *builder;
+ int pixbuf_width;
+ int pixbuf_height;
+ int screen_width;
+ int screen_height;
+ GtkWidget *rotation_angle;
+};
+
+
+static void
+gth_file_tool_rotate_update_sensitivity (GthFileTool *base)
+{
+/*
+ GtkWidget *window;
+ GtkWidget *viewer_page;
+
+ window = gth_file_tool_get_window (base);
+ viewer_page = gth_browser_get_viewer_page (GTH_BROWSER (window));
+ if (! GTH_IS_IMAGE_VIEWER_PAGE (viewer_page))
+ gtk_widget_set_sensitive (GTK_WIDGET (base), FALSE);
+ else
+ gtk_widget_set_sensitive (GTK_WIDGET (base), TRUE);
+*/
+}
+
+
+static void
+cancel_button_clicked_cb (GtkButton *button,
+ GthFileToolRotate *self)
+{
+ gth_file_tool_hide_options (GTH_FILE_TOOL (self));
+}
+
+
+static void
+rotate_button_clicked_cb (GtkButton *button,
+ GthFileToolRotate *self)
+{
+/*
+ GdkRectangle selection;
+ GdkPixbuf *new_pixbuf;
+
+ gth_image_selector_get_selection (self->priv->selector, &selection);
+ if ((selection.width == 0) || (selection.height == 0))
+ return;
+
+ new_pixbuf = gdk_pixbuf_new_subpixbuf (self->priv->src_pixbuf,
+ selection.x,
+ selection.y,
+ selection.width,
+ selection.height);
+ if (new_pixbuf != NULL) {
+ GtkWidget *window;
+ GtkWidget *viewer_page;
+
+ window = gth_file_tool_get_window (GTH_FILE_TOOL (self));
+ viewer_page = gth_browser_get_viewer_page (GTH_BROWSER (window));
+ gth_image_viewer_page_set_pixbuf (GTH_IMAGE_VIEWER_PAGE (viewer_page), new_pixbuf, TRUE);
+ gth_file_tool_hide_options (GTH_FILE_TOOL (self));
+
+ g_object_unref (new_pixbuf);
+ }
+*/
+}
+
+
+static GtkWidget *
+gth_file_tool_rotate_get_options (GthFileTool *base)
+{
+ GthFileToolRotate *self;
+ GtkWidget *window;
+ GtkWidget *viewer_page;
+ GtkWidget *viewer;
+ GtkWidget *options;
+
+ self = (GthFileToolRotate *) base;
+
+ window = gth_file_tool_get_window (base);
+ viewer_page = gth_browser_get_viewer_page (GTH_BROWSER (window));
+ if (! GTH_IS_IMAGE_VIEWER_PAGE (viewer_page))
+ return NULL;
+
+ _g_object_unref (self->priv->src_pixbuf);
+
+ viewer = gth_image_viewer_page_get_image_viewer (GTH_IMAGE_VIEWER_PAGE (viewer_page));
+ self->priv->src_pixbuf = gth_image_viewer_get_current_pixbuf (GTH_IMAGE_VIEWER (viewer));
+ if (self->priv->src_pixbuf == NULL)
+ return NULL;
+
+ g_object_ref (self->priv->src_pixbuf);
+
+ self->priv->pixbuf_width = gdk_pixbuf_get_width (self->priv->src_pixbuf);
+ self->priv->pixbuf_height = gdk_pixbuf_get_height (self->priv->src_pixbuf);
+ _gtk_widget_get_screen_size (window, &self->priv->screen_width, &self->priv->screen_height);
+
+ self->priv->builder = _gtk_builder_new_from_file ("rotate-options.ui", "file_tools");
+
+ options = _gtk_builder_get_widget (self->priv->builder, "options");
+ gtk_widget_show (options);
+ self->priv->rotation_angle = _gtk_builder_get_widget (self->priv->builder, "rotation_angle");
+
+ g_signal_connect (GET_WIDGET ("rotate_button"),
+ "clicked",
+ G_CALLBACK (rotate_button_clicked_cb),
+ self);
+ g_signal_connect (GET_WIDGET ("cancel_button"),
+ "clicked",
+ G_CALLBACK (cancel_button_clicked_cb),
+ self);
+
+ return options;
+}
+
+
+static void
+gth_file_tool_rotate_destroy_options (GthFileTool *base)
+{
+ GthFileToolRotate *self;
+ GtkWidget *window;
+ GtkWidget *viewer_page;
+ GtkWidget *viewer;
+
+ self = (GthFileToolRotate *) base;
+
+ if (self->priv->builder != NULL) {
+ _g_object_unref (self->priv->src_pixbuf);
+ _g_object_unref (self->priv->builder);
+ self->priv->src_pixbuf = NULL;
+ self->priv->builder = NULL;
+ }
+
+ window = gth_file_tool_get_window (GTH_FILE_TOOL (self));
+ viewer_page = gth_browser_get_viewer_page (GTH_BROWSER (window));
+ viewer = gth_image_viewer_page_get_image_viewer (GTH_IMAGE_VIEWER_PAGE (viewer_page));
+ gth_image_viewer_set_tool (GTH_IMAGE_VIEWER (viewer), NULL);
+}
+
+
+static void
+gth_file_tool_rotate_activate (GthFileTool *base)
+{
+ gth_file_tool_show_options (base);
+}
+
+
+static void
+gth_file_tool_rotate_instance_init (GthFileToolRotate *self)
+{
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GTH_TYPE_FILE_TOOL_ROTATE, GthFileToolRotatePrivate);
+ gth_file_tool_construct (GTH_FILE_TOOL (self), "tool-rotate", _("Rotate..."), _("Rotate"), FALSE);
+}
+
+
+static void
+gth_file_tool_rotate_finalize (GObject *object)
+{
+ GthFileToolRotate *self;
+
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GTH_IS_FILE_TOOL_ROTATE (object));
+
+ self = (GthFileToolRotate *) object;
+
+ _g_object_unref (self->priv->src_pixbuf);
+ _g_object_unref (self->priv->builder);
+
+ /* Chain up */
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+
+static void
+gth_file_tool_rotate_class_init (GthFileToolRotateClass *class)
+{
+ GObjectClass *gobject_class;
+ GthFileToolClass *file_tool_class;
+
+ parent_class = g_type_class_peek_parent (class);
+ g_type_class_add_private (class, sizeof (GthFileToolRotatePrivate));
+
+ gobject_class = (GObjectClass*) class;
+ gobject_class->finalize = gth_file_tool_rotate_finalize;
+
+ file_tool_class = (GthFileToolClass *) class;
+ file_tool_class->update_sensitivity = gth_file_tool_rotate_update_sensitivity;
+ file_tool_class->activate = gth_file_tool_rotate_activate;
+ file_tool_class->get_options = gth_file_tool_rotate_get_options;
+ file_tool_class->destroy_options = gth_file_tool_rotate_destroy_options;
+}
+
+
+GType
+gth_file_tool_rotate_get_type (void) {
+ static GType type_id = 0;
+ if (type_id == 0) {
+ static const GTypeInfo g_define_type_info = {
+ sizeof (GthFileToolRotateClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) gth_file_tool_rotate_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL,
+ sizeof (GthFileToolRotate),
+ 0,
+ (GInstanceInitFunc) gth_file_tool_rotate_instance_init,
+ NULL
+ };
+ type_id = g_type_register_static (GTH_TYPE_FILE_TOOL, "GthFileToolRotate", &g_define_type_info, 0);
+ }
+ return type_id;
+}
diff --git a/extensions/file_tools/gth-file-tool-rotate.h b/extensions/file_tools/gth-file-tool-rotate.h
new file mode 100644
index 0000000..894818c
--- /dev/null
+++ b/extensions/file_tools/gth-file-tool-rotate.h
@@ -0,0 +1,53 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * GThumb
+ *
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GTH_FILE_TOOL_ROTATE_H
+#define GTH_FILE_TOOL_ROTATE_H
+
+#include <gthumb.h>
+
+G_BEGIN_DECLS
+
+#define GTH_TYPE_FILE_TOOL_ROTATE (gth_file_tool_rotate_get_type ())
+#define GTH_FILE_TOOL_ROTATE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTH_TYPE_FILE_TOOL_ROTATE, GthFileToolRotate))
+#define GTH_FILE_TOOL_ROTATE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTH_TYPE_FILE_TOOL_ROTATE, GthFileToolRotateClass))
+#define GTH_IS_FILE_TOOL_ROTATE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTH_TYPE_FILE_TOOL_ROTATE))
+#define GTH_IS_FILE_TOOL_ROTATE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTH_TYPE_FILE_TOOL_ROTATE))
+#define GTH_FILE_TOOL_ROTATE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTH_TYPE_FILE_TOOL_ROTATE, GthFileToolRotateClass))
+
+typedef struct _GthFileToolRotate GthFileToolRotate;
+typedef struct _GthFileToolRotateClass GthFileToolRotateClass;
+typedef struct _GthFileToolRotatePrivate GthFileToolRotatePrivate;
+
+struct _GthFileToolRotate {
+ GthFileTool parent_instance;
+ GthFileToolRotatePrivate *priv;
+};
+
+struct _GthFileToolRotateClass {
+ GthFileToolClass parent_class;
+};
+
+GType gth_file_tool_rotate_get_type (void);
+
+G_END_DECLS
+
+#endif /* GTH_FILE_TOOL_ROTATE_H */
diff --git a/extensions/file_tools/main.c b/extensions/file_tools/main.c
index 6931e66..b2550fe 100644
--- a/extensions/file_tools/main.c
+++ b/extensions/file_tools/main.c
@@ -34,6 +34,7 @@
#include "gth-file-tool-negative.h"
#include "gth-file-tool-redo.h"
#include "gth-file-tool-resize.h"
+#include "gth-file-tool-rotate.h"
#include "gth-file-tool-rotate-left.h"
#include "gth-file-tool-rotate-right.h"
#include "gth-file-tool-save.h"
@@ -61,6 +62,7 @@ gthumb_extension_activate (void)
gth_main_register_type ("file-tools", GTH_TYPE_FILE_TOOL_FLIP);
gth_main_register_type ("file-tools", GTH_TYPE_FILE_TOOL_ROTATE_RIGHT);
gth_main_register_type ("file-tools", GTH_TYPE_FILE_TOOL_ROTATE_LEFT);
+ gth_main_register_type ("file-tools", GTH_TYPE_FILE_TOOL_ROTATE);
gth_main_register_type ("file-tools", GTH_TYPE_FILE_TOOL_RESIZE);
gth_main_register_type ("file-tools", GTH_TYPE_FILE_TOOL_CROP);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]