[gtk+/wip/baedert/gtkimageview: 97/139] Return early in set_scale/_set_angle
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/baedert/gtkimageview: 97/139] Return early in set_scale/_set_angle
- Date: Sat, 16 Apr 2016 16:48:06 +0000 (UTC)
commit 0b1d34111593f056b8d014022605d775ac125feb
Author: Timm Bäder <mail baedert org>
Date: Mon Feb 8 14:17:26 2016 +0100
Return early in set_scale/_set_angle
demos/gtk-demo/image_view.c | 48 ++++++++--------------------
demos/gtk-demo/image_view.ui | 72 +++++++++++++++++++++++++++++++++++-------
gtk/gtkimageview.c | 6 +++
3 files changed, 80 insertions(+), 46 deletions(-)
---
diff --git a/demos/gtk-demo/image_view.c b/demos/gtk-demo/image_view.c
index 5ee4205..9ef020b 100644
--- a/demos/gtk-demo/image_view.c
+++ b/demos/gtk-demo/image_view.c
@@ -103,7 +103,7 @@ rotate_right_clicked_cb ()
}
void
-scrolled_check_button_active_cb (GObject *source)
+scrolled_switch_active_cb (GObject *source)
{
GtkWidget *parent = gtk_widget_get_parent (image_view);
@@ -208,32 +208,6 @@ clear_button_clicked_cb ()
gtk_image_view_set_surface (GTK_IMAGE_VIEW (image_view), NULL);
}
-void
-prepare_image_cb (GtkImageView *image_view,
- cairo_surface_t *surface)
-{
- cairo_t *ct;
- int width;
- int height;
-
- g_assert (GTK_IS_IMAGE_VIEW (image_view));
-
- g_assert (surface != NULL);
- g_assert (cairo_surface_get_type (surface) == CAIRO_SURFACE_TYPE_IMAGE);
-
-
- ct = cairo_create (surface);
- width = cairo_image_surface_get_width (surface);
- height = cairo_image_surface_get_height (surface);
-
-
- cairo_set_source_rgba (ct, 0, 1, 0, 1);
- cairo_set_line_width (ct, 5.0);
- cairo_rectangle (ct, 0, 0, width, height);
- cairo_stroke (ct);
-}
-
-
GtkWidget *
do_image_view (GtkWidget *do_widget)
{
@@ -241,9 +215,9 @@ do_image_view (GtkWidget *do_widget)
GtkBuilder *builder = gtk_builder_new_from_resource ("/imageview/image_view.ui");
GtkWidget *box = GTK_WIDGET (gtk_builder_get_object (builder, "box"));
GtkWidget *snap_angle_button = GTK_WIDGET (gtk_builder_get_object (builder, "snap_angle_check_button"));
- GtkWidget *fit_allocation_button = GTK_WIDGET (gtk_builder_get_object (builder,
"fit_allocation_check_button"));
- GtkWidget *rotate_gesture_button = GTK_WIDGET (gtk_builder_get_object (builder,
"rotate_gesture_check_button"));
- GtkWidget *zoom_gesture_button = GTK_WIDGET (gtk_builder_get_object (builder,
"zoom_gesture_check_button"));
+ GtkWidget *fit_allocation_switch = GTK_WIDGET (gtk_builder_get_object (builder, "fit_allocation_switch"));
+ GtkWidget *rotate_gesture_switch = GTK_WIDGET (gtk_builder_get_object (builder, "rotate_gesture_switch"));
+ GtkWidget *zoom_gesture_switch = GTK_WIDGET (gtk_builder_get_object (builder, "zoom_gesture_switch"));
GtkAdjustment *scale_adjustment = GTK_ADJUSTMENT (gtk_builder_get_object (builder, "scale_adjustment"));
GtkAdjustment *angle_adjustment = GTK_ADJUSTMENT (gtk_builder_get_object (builder, "angle_adjustment"));
@@ -255,19 +229,25 @@ do_image_view (GtkWidget *do_widget)
g_object_bind_property (scale_adjustment, "value", image_view, "scale",
G_BINDING_BIDIRECTIONAL);
+
g_object_bind_property (angle_adjustment, "value", image_view, "angle",
- G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
+ /*G_BINDING_BIDIRECTIONAL | */G_BINDING_SYNC_CREATE);
+ g_object_bind_property (image_view, "angle", angle_adjustment, "value",
+ /*G_BINDING_BIDIRECTIONAL | */G_BINDING_SYNC_CREATE);
+
+
+
g_object_bind_property (image_view, "snap-angle", snap_angle_button, "active",
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
- g_object_bind_property (image_view, "fit-allocation", fit_allocation_button, "active",
+ g_object_bind_property (image_view, "fit-allocation", fit_allocation_switch, "active",
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
g_object_bind_property (image_view, "rotate-gesture-enabled",
- rotate_gesture_button, "active",
+ rotate_gesture_switch, "active",
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
g_object_bind_property (image_view, "zoom-gesture-enabled",
- zoom_gesture_button, "active",
+ zoom_gesture_switch, "active",
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
diff --git a/demos/gtk-demo/image_view.ui b/demos/gtk-demo/image_view.ui
index 1ea05f1..a22af29 100644
--- a/demos/gtk-demo/image_view.ui
+++ b/demos/gtk-demo/image_view.ui
@@ -124,59 +124,107 @@
</packing>
</child>
-
-
<child>
- <object class="GtkCheckButton" id="fit_allocation_check_button">
+ <object class="GtkLabel">
<property name="visible">true</property>
<property name="label" translatable="yes">Fit Allocation</property>
+ <property name="halign">start</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">6</property>
- <property name="width">2</property>
+ <property name="width">1</property>
</packing>
</child>
+ <child>
+ <object class="GtkSwitch" id="fit_allocation_switch">
+ <property name="visible">true</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">6</property>
+ </packing>
+ </child>
+
+
+
+
<child>
- <object class="GtkCheckButton" id="scrolled_check_button">
+ <object class="GtkLabel">
<property name="visible">true</property>
<property name="label">In ScrolledWindow</property>
- <property name="active">true</property>
- <signal name="toggled" handler="scrolled_check_button_active_cb" />
+ <property name="halign">start</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">7</property>
- <property name="width">2</property>
+ <property name="width">1</property>
</packing>
</child>
<child>
- <object class="GtkCheckButton" id="zoom_gesture_check_button">
+ <object class="GtkSwitch" id="scrolled_switch">
+ <property name="visible">true</property>
+ <property name="active">true</property>
+ <signal name="notify::active" handler="scrolled_switch_active_cb" />
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">7</property>
+ </packing>
+ </child>
+
+
+ <child>
+ <object class="GtkLabel">
<property name="visible">true</property>
<property name="label">Zoom Gesture Enabled</property>
+ <property name="halign">start</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">8</property>
- <property name="width">2</property>
+ <property name="width">1</property>
</packing>
</child>
<child>
- <object class="GtkCheckButton" id="rotate_gesture_check_button">
+ <object class="GtkSwitch" id="zoom_gesture_switch">
+ <property name="visible">true</property>
+ <property name="active">true</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">8</property>
+ </packing>
+ </child>
+
+
+ <child>
+ <object class="GtkLabel">
<property name="visible">true</property>
<property name="label">Rotate Gesture Enabled</property>
+ <property name="halign">start</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">9</property>
- <property name="width">2</property>
+ <property name="width">1</property>
</packing>
</child>
+ <child>
+ <object class="GtkSwitch" id="rotate_gesture_switch">
+ <property name="visible">true</property>
+ <property name="active">true</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">9</property>
+ </packing>
+ </child>
diff --git a/gtk/gtkimageview.c b/gtk/gtkimageview.c
index 0eddbf3..6d24230 100644
--- a/gtk/gtkimageview.c
+++ b/gtk/gtkimageview.c
@@ -1240,6 +1240,9 @@ gtk_image_view_set_scale (GtkImageView *image_view,
g_return_if_fail (GTK_IS_IMAGE_VIEW (image_view));
g_return_if_fail (scale > 0.0);
+ if (scale == priv->scale)
+ return;
+
gtk_image_view_get_current_state (image_view, &state);
if (gtk_image_view_transitions_enabled (image_view))
@@ -1310,6 +1313,9 @@ gtk_image_view_set_angle (GtkImageView *image_view,
g_return_if_fail (GTK_IS_IMAGE_VIEW (image_view));
+ if (angle == priv->angle)
+ return;
+
gtk_image_view_get_current_state (image_view, &state);
if (gtk_image_view_transitions_enabled (image_view) &&
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]