[gimp] app: code cleanup in the measure tool
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: code cleanup in the measure tool
- Date: Sun, 10 Jun 2018 05:26:39 +0000 (UTC)
commit 845a19b785b8c0f2aff51570933b4c5fa104a9e5
Author: Ell <ell_se yahoo com>
Date: Sun Jun 10 01:24:56 2018 -0400
app: code cleanup in the measure tool
app/tools/gimpmeasureoptions.c | 14 ++++++++------
app/tools/gimpmeasureoptions.h | 4 +++-
app/tools/gimpmeasuretool.c | 30 +++++++++++++++---------------
3 files changed, 26 insertions(+), 22 deletions(-)
---
diff --git a/app/tools/gimpmeasureoptions.c b/app/tools/gimpmeasureoptions.c
index cf115176fd..dcce305e5f 100644
--- a/app/tools/gimpmeasureoptions.c
+++ b/app/tools/gimpmeasureoptions.c
@@ -118,11 +118,12 @@ gimp_measure_options_get_property (GObject *object,
GtkWidget *
gimp_measure_options_gui (GimpToolOptions *tool_options)
{
- GObject *config = G_OBJECT (tool_options);
- GtkWidget *vbox = gimp_tool_options_gui (tool_options);
- GtkWidget *button;
- GtkWidget *frame;
- GtkWidget *vbox2;
+ GObject *config = G_OBJECT (tool_options);
+ GimpMeasureOptions *options = GIMP_MEASURE_OPTIONS (tool_options);
+ GtkWidget *vbox = gimp_tool_options_gui (tool_options);
+ GtkWidget *button;
+ GtkWidget *frame;
+ GtkWidget *vbox2;
/* the use_info_window toggle button */
button = gimp_prop_check_button_new (config, "use-info-window", NULL);
@@ -149,6 +150,7 @@ gimp_measure_options_gui (GimpToolOptions *tool_options)
NULL);
gtk_widget_show (button);
- GIMP_MEASURE_OPTIONS (tool_options)->straighten = button;
+ options->straighten_button = button;
+
return vbox;
}
diff --git a/app/tools/gimpmeasureoptions.h b/app/tools/gimpmeasureoptions.h
index 3e887197a3..6f3e1c6479 100644
--- a/app/tools/gimpmeasureoptions.h
+++ b/app/tools/gimpmeasureoptions.h
@@ -38,7 +38,9 @@ struct _GimpMeasureOptions
GimpTransformOptions parent_instance;
gboolean use_info_window;
- GtkWidget *straighten;
+
+ /* options gui */
+ GtkWidget *straighten_button;
};
struct _GimpMeasureOptionsClass
diff --git a/app/tools/gimpmeasuretool.c b/app/tools/gimpmeasuretool.c
index 0f7ab099a9..d6b2039eb1 100644
--- a/app/tools/gimpmeasuretool.c
+++ b/app/tools/gimpmeasuretool.c
@@ -108,7 +108,8 @@ static GimpToolGui * gimp_measure_tool_dialog_new (GimpMeasureTool *measur
static void gimp_measure_tool_dialog_update (GimpMeasureTool *measure,
GimpDisplay *display);
-static void gimp_measure_tool_straighten_clicked (GtkWidget *button,
+static void gimp_measure_tool_straighten_button_clicked
+ (GtkWidget *button,
GimpMeasureTool *measure);
G_DEFINE_TYPE (GimpMeasureTool, gimp_measure_tool, GIMP_TYPE_TRANSFORM_TOOL)
@@ -319,9 +320,6 @@ gimp_measure_tool_recalc_matrix (GimpTransformTool *tr_tool)
gimp_vector2_sub (&p1, &p1, &p0);
gimp_vector2_sub (&p2, &p2, &p0);
- gimp_vector2_normalize (&p1);
- gimp_vector2_normalize (&p2);
-
angle = atan2 (gimp_vector2_cross_product (&p1, &p2).x,
gimp_vector2_inner_product (&p1, &p2));
@@ -354,7 +352,7 @@ gimp_measure_tool_compass_changed (GimpToolWidget *widget,
"y3", &measure->y[2],
NULL);
- gtk_widget_set_sensitive (options->straighten, measure->n_points >= 2);
+ gtk_widget_set_sensitive (options->straighten_button, measure->n_points >= 2);
gimp_measure_tool_dialog_update (measure, GIMP_TOOL (measure)->display);
}
@@ -460,8 +458,8 @@ gimp_measure_tool_start (GimpMeasureTool *measure,
g_signal_connect (measure->widget, "create-guides",
G_CALLBACK (gimp_measure_tool_compass_create_guides),
measure);
- g_signal_connect (options->straighten, "clicked",
- G_CALLBACK (gimp_measure_tool_straighten_clicked),
+ g_signal_connect (options->straighten_button, "clicked",
+ G_CALLBACK (gimp_measure_tool_straighten_button_clicked),
measure);
tool->display = display;
@@ -475,7 +473,7 @@ gimp_measure_tool_halt (GimpMeasureTool *measure)
GimpMeasureOptions *options = GIMP_MEASURE_TOOL_GET_OPTIONS (measure);
GimpTool *tool = GIMP_TOOL (measure);
- gtk_widget_set_sensitive (options->straighten, FALSE);
+ gtk_widget_set_sensitive (options->straighten_button, FALSE);
if (tool->display)
gimp_tool_pop_status (tool, tool->display);
@@ -483,9 +481,10 @@ gimp_measure_tool_halt (GimpMeasureTool *measure)
if (gimp_draw_tool_is_active (GIMP_DRAW_TOOL (measure)))
gimp_draw_tool_stop (GIMP_DRAW_TOOL (measure));
- g_signal_handlers_disconnect_by_func (options->straighten,
- G_CALLBACK (gimp_measure_tool_straighten_clicked),
- measure);
+ g_signal_handlers_disconnect_by_func (
+ options->straighten_button,
+ G_CALLBACK (gimp_measure_tool_straighten_button_clicked),
+ measure);
gimp_draw_tool_set_widget (GIMP_DRAW_TOOL (tool), NULL);
g_clear_object (&measure->widget);
@@ -866,16 +865,17 @@ gimp_measure_tool_dialog_new (GimpMeasureTool *measure)
}
static void
-gimp_measure_tool_straighten_clicked (GtkWidget *button,
- GimpMeasureTool *measure)
+gimp_measure_tool_straighten_button_clicked (GtkWidget *button,
+ GimpMeasureTool *measure)
{
GimpTool *tool = GIMP_TOOL (measure);
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (measure);
- gdouble x0, y0;
- gdouble x1, y1;
if (gimp_transform_tool_transform (tr_tool, tool->display))
{
+ gdouble x0, y0;
+ gdouble x1, y1;
+
gimp_matrix3_transform_point (&tr_tool->transform,
measure->x[0],
measure->y[0],
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]