[Goodies-commits] r3677 - ristretto/trunk/src

Stephan Arts stephan at xfce.org
Sun Dec 9 00:11:08 CET 2007


Author: stephan
Date: 2007-12-08 23:11:08 +0000 (Sat, 08 Dec 2007)
New Revision: 3677

Modified:
   ristretto/trunk/src/main.c
   ristretto/trunk/src/main_window.c
   ristretto/trunk/src/picture_viewer.c
   ristretto/trunk/src/picture_viewer.h
Log:
Fix boxed-zoom



Modified: ristretto/trunk/src/main.c
===================================================================
--- ristretto/trunk/src/main.c	2007-12-07 22:54:31 UTC (rev 3676)
+++ ristretto/trunk/src/main.c	2007-12-08 23:11:08 UTC (rev 3677)
@@ -239,6 +239,7 @@
     gint max_cache = xfce_rc_read_int_entry(xfce_rc, "MaxImagesCacheSize", 1);
     gboolean preload_during_slideshow = xfce_rc_read_bool_entry (xfce_rc, "PreloadDuringSlideShow", FALSE);
     gboolean override_bg_color = xfce_rc_read_bool_entry (xfce_rc, "OverrideBgColor", FALSE);
+
     if (override_bg_color)
     {
         const gchar *color = xfce_rc_read_entry(xfce_rc, "BgColor", "#000000000000");
@@ -444,111 +445,7 @@
 
         }
     }
-    /*
-    for (n = 1; n < argc; ++n)
-    {
-        ThunarVfsPath *path;
-        if (g_path_is_absolute(argv[n]))
-            path = thunar_vfs_path_new(argv[n], NULL);
-        else
-        {
-            gchar *base_dir = g_get_current_dir();
 
-            path_dir = g_build_path("/", base_dir, argv[n], NULL);
-            path = thunar_vfs_path_new(path_dir, NULL);
-
-            g_free(base_dir);
-        }
-
-        if (path)
-        {
-
-            ThunarVfsInfo *info = thunar_vfs_info_new_for_path(path, NULL);
-            if(info)
-            {
-                if(strcmp(thunar_vfs_mime_info_get_name(info->mime_info), "inode/directory"))
-                {
-                    ThunarVfsPath *_path = thunar_vfs_path_get_parent(path);
-                    thunar_vfs_path_unref(path);
-                    path = _path;
-
-                    gchar *path_string = thunar_vfs_path_dup_string(path);
-                    
-                    GDir *dir = g_dir_open(path_string, 0, NULL);
-                    const gchar *filename = g_dir_read_name(dir);
-                    while (filename)
-                    {
-                        gchar *path_name = g_strconcat(path_string,  "/", filename, NULL);
-                        ThunarVfsPath *file_path = thunar_vfs_path_new(path_name, NULL);
-                        if (file_path)
-                        {
-                            ThunarVfsInfo *file_info = thunar_vfs_info_new_for_path(file_path, NULL);
-                            gchar *file_media = thunar_vfs_mime_info_get_media(file_info->mime_info);
-                            if(!strcmp(file_media, "image"))
-                            {
-                                RsttoNavigatorEntry *entry = rstto_navigator_entry_new(navigator, file_info);
-                                gint i = rstto_navigator_add (navigator, entry);
-                                if (path_dir == NULL)
-                                {
-                                    if (!strcmp(path_name, argv[n]))
-                                    {
-                                        rstto_navigator_set_file(navigator, i);
-                                    }
-                                }
-                                else
-                                {
-                                    if (!strcmp(path_name, path_dir))
-                                    {
-                                        rstto_navigator_set_file(navigator, i);
-                                    }
-
-                                }
-                            }
-                            g_free(file_media);
-                            thunar_vfs_path_unref(file_path);
-                        }
-                        g_free(path_name);
-                        filename = g_dir_read_name(dir);
-                    }
-                    g_dir_close(dir);
-                    g_free(path_string);
-                }
-                else
-                {
-                    GDir *dir = g_dir_open(argv[n], 0, NULL);
-                    const gchar *filename = g_dir_read_name(dir);
-                    while (filename)
-                    {
-                        gchar *path_name = g_strconcat(argv[n],  "/", filename, NULL);
-                        ThunarVfsPath *file_path = thunar_vfs_path_new(path_name, NULL);
-                        if (file_path)
-                        {
-                            ThunarVfsInfo *file_info = thunar_vfs_info_new_for_path(file_path, NULL);
-                            gchar *file_media = thunar_vfs_mime_info_get_media(file_info->mime_info);
-                            if(!strcmp(file_media, "image"))
-                            {
-                                RsttoNavigatorEntry *entry = rstto_navigator_entry_new(navigator, file_info);
-                                rstto_navigator_add (navigator, entry);
-                            }
-                            g_free(file_media);
-                            thunar_vfs_path_unref(file_path);
-                        }
-                        g_free(path_name);
-                        filename = g_dir_read_name(dir);
-                    }
-                    rstto_navigator_jump_first(navigator);
-                    g_dir_close(dir);
-                }
-                gchar *uri = thunar_vfs_path_dup_uri(info->path);
-                gtk_recent_manager_add_item(recent_manager, uri);
-                g_free(uri);
-            }
-            thunar_vfs_path_unref(path);
-        }
-    }
-*/
-
-
     g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL);
     g_signal_connect(G_OBJECT(window), "configure-event", G_CALLBACK(cb_rstto_main_window_configure_event), NULL);
 

Modified: ristretto/trunk/src/main_window.c
===================================================================
--- ristretto/trunk/src/main_window.c	2007-12-07 22:54:31 UTC (rev 3676)
+++ ristretto/trunk/src/main_window.c	2007-12-08 23:11:08 UTC (rev 3677)
@@ -1265,6 +1265,7 @@
             {
                 rstto_main_window_set_pv_bg_color(window, NULL);
             }
+            rstto_picture_viewer_redraw(RSTTO_PICTURE_VIEWER(window->priv->picture_viewer));
         default:
             break;
     }

Modified: ristretto/trunk/src/picture_viewer.c
===================================================================
--- ristretto/trunk/src/picture_viewer.c	2007-12-07 22:54:31 UTC (rev 3676)
+++ ristretto/trunk/src/picture_viewer.c	2007-12-08 23:11:08 UTC (rev 3677)
@@ -929,26 +929,34 @@
                     gdouble old_scale = scale;
                     gdouble width = (gdouble)gdk_pixbuf_get_width(viewer->priv->src_pixbuf);
                     gdouble height = (gdouble)gdk_pixbuf_get_height(viewer->priv->src_pixbuf);
+
+                    gdouble d_width = (gdouble)gdk_pixbuf_get_width(viewer->priv->dst_pixbuf);
+                    gdouble d_height = (gdouble)gdk_pixbuf_get_height(viewer->priv->dst_pixbuf);
+
                     gdouble box_width, box_height;
                     gdouble top_left_x, top_left_y;
                     if (viewer->priv->motion.x < viewer->priv->motion.current_x)
                     {
-                        top_left_x = viewer->priv->motion.x + viewer->hadjustment->value;
+                        gint x_offset = (widget->allocation.width - d_width)<=0?0:((widget->allocation.width - d_width)/2);
+                        top_left_x = viewer->priv->motion.x + viewer->hadjustment->value - x_offset;
                         box_width = viewer->priv->motion.current_x - viewer->priv->motion.x;
                     }
                     else
                     {
-                        top_left_x = viewer->priv->motion.current_x + viewer->hadjustment->value;
+                        gint x_offset = (widget->allocation.width - d_width)<=0?0:((widget->allocation.width - d_width)/2);
+                        top_left_x = viewer->priv->motion.current_x + viewer->hadjustment->value - x_offset;
                         box_width = viewer->priv->motion.x - viewer->priv->motion.current_x;
                     }
                     if (viewer->priv->motion.y < viewer->priv->motion.current_y)
                     {
-                        top_left_y = viewer->priv->motion.y + viewer->vadjustment->value;
+                        gint y_offset = (widget->allocation.height - d_height)<=0?0:((widget->allocation.height - d_height)/2);
+                        top_left_y = viewer->priv->motion.y + viewer->vadjustment->value - y_offset;
                         box_height = viewer->priv->motion.current_y - viewer->priv->motion.y;
                     }
                     else
                     {
-                        top_left_y = viewer->priv->motion.current_y + viewer->vadjustment->value;
+                        gint y_offset = (widget->allocation.height - d_height) <=0?0:((widget->allocation.height - d_height)/2);
+                        top_left_y = viewer->priv->motion.current_y + viewer->vadjustment->value - y_offset;
                         box_height = viewer->priv->motion.y - viewer->priv->motion.current_y;
                     }
 
@@ -976,7 +984,7 @@
                         viewer->hadjustment->lower = 0;
                         viewer->hadjustment->step_increment = 1;
                         viewer->hadjustment->page_increment = 100;
-                        viewer->hadjustment->value = top_left_x;
+                        viewer->hadjustment->value = top_left_x / old_scale * scale;
                         if((viewer->hadjustment->value + viewer->hadjustment->page_size) > viewer->hadjustment->upper)
                         {
                             viewer->hadjustment->value = viewer->hadjustment->upper - viewer->hadjustment->page_size;
@@ -995,7 +1003,7 @@
                         viewer->vadjustment->lower = 0;
                         viewer->vadjustment->step_increment = 1;
                         viewer->vadjustment->page_increment = 100;
-                        viewer->vadjustment->value = top_left_y;
+                        viewer->vadjustment->value = top_left_y / old_scale * scale;
                         if((viewer->vadjustment->value + viewer->vadjustment->page_size) > viewer->vadjustment->upper)
                         {
                             viewer->vadjustment->value = viewer->vadjustment->upper - viewer->vadjustment->page_size;
@@ -1076,3 +1084,11 @@
 {
     return viewer->priv->bg_color;
 }
+
+void
+rstto_picture_viewer_redraw(RsttoPictureViewer *viewer)
+{
+    rstto_picture_viewer_refresh(viewer);
+    rstto_picture_viewer_paint(GTK_WIDGET(viewer));
+}
+

Modified: ristretto/trunk/src/picture_viewer.h
===================================================================
--- ristretto/trunk/src/picture_viewer.h	2007-12-07 22:54:31 UTC (rev 3676)
+++ ristretto/trunk/src/picture_viewer.h	2007-12-08 23:11:08 UTC (rev 3677)
@@ -76,6 +76,8 @@
 const GdkColor *
 rstto_picture_viewer_get_bg_color (RsttoPictureViewer *viewer);
 
+void       rstto_picture_viewer_redraw (RsttoPictureViewer *viewer);
+
 G_END_DECLS
 
 #endif /* __RISTRETTO_PICTURE_VIEWER_H__ */




More information about the Goodies-commits mailing list