[gthumb: 110/129] rotate tool: improving UI



commit 7601b4ce6be927d81ba458801c7467a3dfd6636b
Author: Stefano Pettini <spettini users sourceforge net>
Date:   Sat Apr 23 13:23:57 2011 +0100

    rotate tool: improving UI

 extensions/file_tools/data/ui/rotate-options.ui |  176 +++++++++++++++++++++--
 extensions/file_tools/gth-file-tool-rotate.c    |  143 ++++++++++++++++++-
 2 files changed, 303 insertions(+), 16 deletions(-)
---
diff --git a/extensions/file_tools/data/ui/rotate-options.ui b/extensions/file_tools/data/ui/rotate-options.ui
index 5ce5e50..019742b 100644
--- a/extensions/file_tools/data/ui/rotate-options.ui
+++ b/extensions/file_tools/data/ui/rotate-options.ui
@@ -23,29 +23,177 @@
                     <property name="top_padding">6</property>
                     <property name="left_padding">12</property>
                     <child>
-                      <object class="GtkVBox" id="vbox10">
+                      <object class="GtkHBox" id="rotation_angle_hbox">
                         <property name="visible">True</property>
                         <property name="spacing">6</property>
                         <child>
-                          <object class="GtkHScale" id="rotation_angle">
+                          <placeholder/>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+                <child type="label">
+                  <object class="GtkLabel" id="manual_rotation_label">
+                    <property name="visible">True</property>
+                    <property name="yalign">0.47999998927116394</property>
+                    <property name="label" translatable="yes">Manual rotation</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>
+            <child>
+              <object class="GtkFrame" id="frame2">
+                <property name="visible">True</property>
+                <property name="label_xalign">0</property>
+                <property name="shadow_type">none</property>
+                <child>
+                  <object class="GtkAlignment" id="alignment2">
+                    <property name="visible">True</property>
+                    <property name="top_padding">6</property>
+                    <property name="left_padding">12</property>
+                    <child>
+                      <object class="GtkVBox" id="vbox4">
+                        <property name="visible">True</property>
+                        <property name="spacing">6</property>
+                        <child>
+                          <object class="GtkHBox" id="hbox2">
                             <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>
+                            <property name="spacing">6</property>
+                            <child>
+                              <object class="GtkButton" id="get_1_button">
+                                <property name="label" translatable="yes">Get</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">True</property>
+                              </object>
+                              <packing>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkSpinButton" id="p1_x_spinbutton">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="invisible_char">â?¢</property>
+                              </object>
+                              <packing>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkLabel" id="label3">
+                                <property name="visible">True</property>
+                                <property name="label" translatable="yes">x</property>
+                              </object>
+                              <packing>
+                                <property name="position">2</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkSpinButton" id="p1_y_spinbutton">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="invisible_char">â?¢</property>
+                              </object>
+                              <packing>
+                                <property name="position">3</property>
+                              </packing>
+                            </child>
                           </object>
                           <packing>
                             <property name="position">0</property>
                           </packing>
                         </child>
+                        <child>
+                          <object class="GtkHBox" id="hbox1">
+                            <property name="visible">True</property>
+                            <property name="spacing">6</property>
+                            <child>
+                              <object class="GtkButton" id="get_2_button">
+                                <property name="label" translatable="yes">Get</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">True</property>
+                              </object>
+                              <packing>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkSpinButton" id="p2_x_spinbutton">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="invisible_char">â?¢</property>
+                              </object>
+                              <packing>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkLabel" id="label2">
+                                <property name="visible">True</property>
+                                <property name="label" translatable="yes">x</property>
+                              </object>
+                              <packing>
+                                <property name="position">2</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkSpinButton" id="p2_y_spinbutton">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="invisible_char">â?¢</property>
+                              </object>
+                              <packing>
+                                <property name="position">3</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkButton" id="align_h_button">
+                            <property name="label" translatable="yes">Align _horizontally</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">True</property>
+                            <property name="use_underline">True</property>
+                          </object>
+                          <packing>
+                            <property name="position">2</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkButton" id="align_v_button">
+                            <property name="label" translatable="yes">Align _vertically</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">True</property>
+                            <property name="use_underline">True</property>
+                          </object>
+                          <packing>
+                            <property name="position">3</property>
+                          </packing>
+                        </child>
                       </object>
                     </child>
                   </object>
                 </child>
                 <child type="label">
-                  <object class="GtkLabel" id="label15">
+                  <object class="GtkLabel" id="automatic_rotation_label">
                     <property name="visible">True</property>
-                    <property name="label" translatable="yes">Rotation angle</property>
+                    <property name="label" translatable="yes">Automatic rotation</property>
                     <attributes>
                       <attribute name="weight" value="bold"/>
                     </attributes>
@@ -55,7 +203,7 @@
               <packing>
                 <property name="expand">False</property>
                 <property name="fill">False</property>
-                <property name="position">0</property>
+                <property name="position">1</property>
               </packing>
             </child>
             <child>
@@ -74,7 +222,7 @@
                         <property name="spacing">6</property>
                         <child>
                           <object class="GtkCheckButton" id="high_quality">
-                            <property name="label" translatable="yes">_High quality</property>
+                            <property name="label" translatable="yes">High _quality</property>
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
                             <property name="receives_default">False</property>
@@ -118,7 +266,7 @@
               <packing>
                 <property name="expand">False</property>
                 <property name="fill">False</property>
-                <property name="position">1</property>
+                <property name="position">2</property>
               </packing>
             </child>
           </object>
@@ -190,4 +338,10 @@
     <property name="page_increment">1</property>
     <property name="page_size">1</property>
   </object>
+  <object class="GtkAdjustment" id="p1_x_adjustment">
+    <property name="upper">100</property>
+    <property name="step_increment">1</property>
+    <property name="page_increment">10</property>
+    <property name="page_size">10</property>
+  </object>
 </interface>
diff --git a/extensions/file_tools/gth-file-tool-rotate.c b/extensions/file_tools/gth-file-tool-rotate.c
index 31385a7..7bfb152 100644
--- a/extensions/file_tools/gth-file-tool-rotate.c
+++ b/extensions/file_tools/gth-file-tool-rotate.c
@@ -42,9 +42,11 @@ struct _GthFileToolRotatePrivate {
 	int               pixbuf_height;
 	int               screen_width;
 	int               screen_height;
-	GtkWidget        *rotation_angle;
+	GtkAdjustment    *rotation_angle_adj;
 	GtkWidget        *high_quality;
 	GtkWidget        *auto_crop;
+	GthImageSelector *selector;
+	guint             selector_point;
 	guint             apply_event;
 };
 
@@ -65,6 +67,58 @@ gth_file_tool_rotate_update_sensitivity (GthFileTool *base)
 
 
 static void
+get_1_button_clicked_cb (GtkButton         *button,
+			 GthFileToolRotate *self)
+{
+	GtkWidget *window;
+	GtkWidget *viewer_page;
+	GtkWidget *viewer;
+
+	self->priv->selector_point = 1;
+
+	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), (GthImageViewerTool *) self->priv->selector);
+}
+
+
+static void
+get_2_button_clicked_cb (GtkButton         *button,
+			 GthFileToolRotate *self)
+{
+	GtkWidget *window;
+	GtkWidget *viewer_page;
+	GtkWidget *viewer;
+
+	self->priv->selector_point = 2;
+	
+	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), (GthImageViewerTool *) self->priv->selector);
+}
+
+
+static void
+align_h_button_clicked_cb (GtkButton         *button,
+			   GthFileToolRotate *self)
+{
+
+}
+
+
+static void
+align_v_button_clicked_cb (GtkButton         *button,
+			   GthFileToolRotate *self)
+{
+
+}
+
+
+static void
 apply_button_clicked_cb (GtkButton         *button,
 			 GthFileToolRotate *self)
 {
@@ -119,7 +173,7 @@ apply_cb (gpointer user_data)
 	window = gth_file_tool_get_window (GTH_FILE_TOOL (self));
 	viewer_page = gth_browser_get_viewer_page (GTH_BROWSER (window));
 
-	rotation_angle = gtk_range_get_value (GTK_RANGE (self->priv->rotation_angle));
+	rotation_angle = gtk_adjustment_get_value (self->priv->rotation_angle_adj);
 	high_quality = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->priv->high_quality));
 	auto_crop = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->priv->auto_crop));
 	
@@ -144,6 +198,43 @@ value_changed_cb (GtkAdjustment     *adj,
 }
 
 
+static void
+selector_selected_cb (GthImageSelector  *selector,
+		      int                x,
+		      int                y,
+		      GthFileToolRotate *self)
+{
+	GtkWidget *window;
+	GtkWidget *viewer_page;
+	GtkWidget *viewer;
+
+	self->priv->selector_point = 0;
+	
+	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
+selector_motion_notify_cb (GthImageSelector  *selector,
+		           int                x,
+		           int                y,
+		           GthFileToolRotate *self)
+{
+	if (self->priv->selector_point == 1) {
+		gtk_spin_button_set_value (GTK_SPIN_BUTTON (GET_WIDGET ("p1_x_spinbutton")), (double) x);
+		gtk_spin_button_set_value (GTK_SPIN_BUTTON (GET_WIDGET ("p1_y_spinbutton")), (double) y);
+	}
+	else if (self->priv->selector_point == 2) {
+		gtk_spin_button_set_value (GTK_SPIN_BUTTON (GET_WIDGET ("p2_x_spinbutton")), (double) x);
+		gtk_spin_button_set_value (GTK_SPIN_BUTTON (GET_WIDGET ("p2_y_spinbutton")), (double) y);
+	}
+}
+
+
 static GtkWidget *
 gth_file_tool_rotate_get_options (GthFileTool *base)
 {
@@ -179,10 +270,18 @@ 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 = _gtk_builder_get_widget (self->priv->builder, "rotation_angle");
+	
+	self->priv->rotation_angle_adj = gimp_scale_entry_new (GET_WIDGET ("rotation_angle_hbox"),
+							       GTK_LABEL (GET_WIDGET ("manual_rotation_label")),
+							       0.0, -90.0, 90.0, 0.1, 1.0, 1);
+	
 	self->priv->high_quality = _gtk_builder_get_widget (self->priv->builder, "high_quality");
 	self->priv->auto_crop = _gtk_builder_get_widget (self->priv->builder, "auto_crop");
+	self->priv->selector = (GthImageSelector *) gth_image_selector_new (GTH_IMAGE_VIEWER (viewer), GTH_SELECTOR_TYPE_POINT);
 
+	gth_image_selector_set_mask_visible (self->priv->selector, TRUE);
+	self->priv->selector_point = 0;
+	
 	g_signal_connect (GET_WIDGET ("apply_button"),
 			  "clicked",
 			  G_CALLBACK (apply_button_clicked_cb),
@@ -191,7 +290,23 @@ gth_file_tool_rotate_get_options (GthFileTool *base)
 			  "clicked",
 			  G_CALLBACK (cancel_button_clicked_cb),
 			  self);
-	g_signal_connect (G_OBJECT (self->priv->rotation_angle),
+	g_signal_connect (GET_WIDGET ("get_1_button"),
+			  "clicked",
+			  G_CALLBACK (get_1_button_clicked_cb),
+			  self);
+	g_signal_connect (GET_WIDGET ("get_2_button"),
+			  "clicked",
+			  G_CALLBACK (get_2_button_clicked_cb),
+			  self);
+	g_signal_connect (GET_WIDGET ("align_h_button"),
+			  "clicked",
+			  G_CALLBACK (align_h_button_clicked_cb),
+			  self);
+	g_signal_connect (GET_WIDGET ("align_v_button"),
+			  "clicked",
+			  G_CALLBACK (align_v_button_clicked_cb),
+			  self);
+	g_signal_connect (G_OBJECT (self->priv->rotation_angle_adj),
 			  "value-changed",
 			  G_CALLBACK (value_changed_cb),
 			  self);
@@ -203,7 +318,14 @@ gth_file_tool_rotate_get_options (GthFileTool *base)
 			  "toggled",
 			  G_CALLBACK (value_changed_cb),
 			  self);
-
+	g_signal_connect (self->priv->selector,
+			  "selected",
+			  G_CALLBACK (selector_selected_cb),
+			  self);
+	g_signal_connect (self->priv->selector,
+			  "motion_notify",
+			  G_CALLBACK (selector_motion_notify_cb),
+			  self);
 	return options;
 }
 
@@ -212,6 +334,9 @@ static void
 gth_file_tool_rotate_destroy_options (GthFileTool *base)
 {
 	GthFileToolRotate *self;
+	GtkWidget         *window;
+	GtkWidget         *viewer_page;
+	GtkWidget         *viewer;
 
 	self = (GthFileToolRotate *) base;
 
@@ -220,12 +345,20 @@ gth_file_tool_rotate_destroy_options (GthFileTool *base)
 		self->priv->apply_event = 0;
 	}
 
+	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);
+
 	_g_object_unref (self->priv->src_pixbuf);
 	_g_object_unref (self->priv->dest_pixbuf);
 	_g_object_unref (self->priv->builder);
+	_g_object_unref (self->priv->selector);
 	self->priv->src_pixbuf = NULL;
 	self->priv->dest_pixbuf = NULL;
 	self->priv->builder = NULL;
+	self->priv->selector = NULL;
+	self->priv->selector_point = 0;
 }
 
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]