[Xfce4-commits] <ristretto:master> Remove 'wrong' statusbar-message Improve set_scale function

Stephan Arts noreply at xfce.org
Sat Aug 20 10:34:02 CEST 2011


Updating branch refs/heads/master
         to 36c19aa4494514018af763e6d67c4f1ca5a309fd (commit)
       from 1dcc36d4544a7c9b69c85b72d539973779e90637 (commit)

commit 36c19aa4494514018af763e6d67c4f1ca5a309fd
Author: Stephan Arts <stephan at xfce.org>
Date:   Tue Aug 16 00:42:59 2011 +0200

    Remove 'wrong' statusbar-message
    Improve set_scale function

 src/image_list.c   |    2 +-
 src/image_viewer.c |   25 +++++++++++++++++++++++++
 src/main_window.c  |   13 +++++++------
 3 files changed, 33 insertions(+), 7 deletions(-)

diff --git a/src/image_list.c b/src/image_list.c
index 1344f3c..3af1aa9 100644
--- a/src/image_list.c
+++ b/src/image_list.c
@@ -1,5 +1,5 @@
 /*
- *  Copyright (c) Stephan Arts 2009-2010 <stephan at xfce.org>
+ *  Copyright (c) Stephan Arts 2009-2011 <stephan at xfce.org>
  *
  *  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
diff --git a/src/image_viewer.c b/src/image_viewer.c
index ee0318b..4b0213a 100644
--- a/src/image_viewer.c
+++ b/src/image_viewer.c
@@ -1071,6 +1071,18 @@ rstto_image_viewer_set_scale (RsttoImageViewer *viewer, gdouble scale)
             pixbuf_x_offset = ((GTK_WIDGET(viewer)->allocation.width - pixbuf_width)/2);
             pixbuf_y_offset = ((GTK_WIDGET(viewer)->allocation.height - pixbuf_height)/2);
         }
+
+        /*
+         * Prevent the adjustments from emitting the 'changed' signal,
+         * this way both the upper-limit and value can be changed before the
+         * rest of the application is informed.
+         */
+        g_object_freeze_notify(G_OBJECT(viewer->hadjustment));
+        g_object_freeze_notify(G_OBJECT(viewer->vadjustment));
+
+
+        gtk_adjustment_set_upper (viewer->hadjustment, ((gdouble)viewer->priv->image_width)*scale);
+        gtk_adjustment_set_upper (viewer->vadjustment, ((gdouble)viewer->priv->image_height)*scale);
         
         /*
          * When zooming in or out, 
@@ -1085,6 +1097,19 @@ rstto_image_viewer_set_scale (RsttoImageViewer *viewer, gdouble scale)
                         (gtk_adjustment_get_page_size (viewer->hadjustment) / 2) - pixbuf_x_offset) / viewer->priv->scale;
         gtk_adjustment_set_value (viewer->hadjustment, (tmp_x*scale - (gtk_adjustment_get_page_size(viewer->hadjustment)/2)));
 
+        /*
+         * Enable signals on the adjustments.
+         */
+        g_object_thaw_notify(G_OBJECT(viewer->vadjustment));
+        g_object_thaw_notify(G_OBJECT(viewer->hadjustment));
+
+        /*
+         * Trigger the 'changed' signal, update the rest of
+         * the appliaction.
+         */
+        gtk_adjustment_changed(viewer->hadjustment);
+        gtk_adjustment_changed(viewer->vadjustment);
+
     }
 
     viewer->priv->scale = scale;
diff --git a/src/main_window.c b/src/main_window.c
index 81c4efa..b230d18 100644
--- a/src/main_window.c
+++ b/src/main_window.c
@@ -864,10 +864,6 @@ rstto_main_window_image_list_iter_changed (RsttoMainWindow *window)
             {
                 status = g_strdup_printf ("%d x %d", width, height);
             }
-            else
-            {
-                status = g_strdup_printf ("Loading '%s'", file_basename);
-            }
 
             g_free (file_basename);
         }
@@ -894,10 +890,15 @@ rstto_main_window_image_list_iter_changed (RsttoMainWindow *window)
         rstto_main_window_update_buttons (window);
         gtk_window_set_title (GTK_WINDOW (window), title);
         gtk_statusbar_pop (GTK_STATUSBAR (window->priv->statusbar), window->priv->statusbar_context_id);
-        gtk_statusbar_push (GTK_STATUSBAR (window->priv->statusbar), window->priv->statusbar_context_id, status);
+
+        if (status)
+        {
+            gtk_statusbar_push (GTK_STATUSBAR (window->priv->statusbar), window->priv->statusbar_context_id, status);
+            g_free (status);
+            status = NULL;
+        }
 
         g_free (title);
-        g_free (status);
     }
 
 }


More information about the Xfce4-commits mailing list