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

Stephan Arts stephan at xfce.org
Mon Oct 29 12:38:03 CET 2007


Author: stephan
Date: 2007-10-29 11:38:03 +0000 (Mon, 29 Oct 2007)
New Revision: 3473

Modified:
   ristretto/trunk/src/main.c
   ristretto/trunk/src/navigator.c
   ristretto/trunk/src/navigator.h
Log:
Fix fd issue



Modified: ristretto/trunk/src/main.c
===================================================================
--- ristretto/trunk/src/main.c	2007-10-29 09:41:56 UTC (rev 3472)
+++ ristretto/trunk/src/main.c	2007-10-29 11:38:03 UTC (rev 3473)
@@ -92,11 +92,17 @@
     gint window_width = xfce_rc_read_int_entry(xfce_rc, "LastWindowWidth", 400);
     gint window_height = xfce_rc_read_int_entry(xfce_rc, "LastWindowHeight", 300);
     gint slideshow_timeout = xfce_rc_read_int_entry(xfce_rc, "SlideShowTimeout", 5000);
+    gint max_cache = xfce_rc_read_int_entry(xfce_rc, "MaxImagesCacheSize", 1);
+    gint max_preload = xfce_rc_read_int_entry(xfce_rc, "MaxImagesPreload", 1);
     
     GtkWidget *window = rstto_main_window_new();
     gtk_widget_ref(window);
 
     RsttoNavigator *navigator = rstto_main_window_get_navigator(RSTTO_MAIN_WINDOW(window));
+
+    navigator->max_history = max_cache;
+    navigator->max_preload = max_preload;
+
     GtkRecentManager *recent_manager = rstto_main_window_get_recent_manager(RSTTO_MAIN_WINDOW(window));
     rstto_navigator_set_timeout(navigator, slideshow_timeout);
 
@@ -222,6 +228,7 @@
             xfce_rc_write_entry(xfce_rc, "ThumbnailViewerOrientation", "horizontal");
             break;
     }
+    xfce_rc_write_int_entry(xfce_rc, "MaxImagesCacheSize", rstto_navigator_get_cache_max_images(navigator));
     xfce_rc_flush(xfce_rc);
     xfce_rc_close(xfce_rc);
     gtk_widget_unref(window);

Modified: ristretto/trunk/src/navigator.c
===================================================================
--- ristretto/trunk/src/navigator.c	2007-10-29 09:41:56 UTC (rev 3472)
+++ ristretto/trunk/src/navigator.c	2007-10-29 11:38:03 UTC (rev 3473)
@@ -131,6 +131,8 @@
     navigator->old_position = -1;
     navigator->timeout = 5000;
     navigator->monitor = thunar_vfs_monitor_get_default();
+    navigator->max_history = 1;
+    navigator->max_preload = 0;
 
     navigator->factory = thunar_vfs_thumb_factory_new(THUNAR_VFS_THUMB_SIZE_NORMAL);
 }
@@ -236,6 +238,7 @@
     if(entry->io_channel)
     {
         g_source_remove(entry->io_source_id);
+        g_io_channel_unref(entry->io_channel);
         entry->io_channel = NULL;
         entry->io_source_id = 0;
         if(entry->loader)
@@ -262,7 +265,7 @@
     /* add image to the cache-history */
     navigator->history = g_list_prepend(navigator->history, entry);
 
-    if (g_list_length(navigator->history) > 5)
+    if (g_list_length(navigator->history) > navigator->max_history)
     {
         GList *last_entry = g_list_last(navigator->history);
         RsttoNavigatorEntry *nav_entry = last_entry->data;
@@ -279,6 +282,7 @@
             if(nav_entry->io_channel)
             {
                 g_source_remove(nav_entry->io_source_id);
+                g_io_channel_unref(nav_entry->io_channel);
                 nav_entry->io_channel = NULL;
                 nav_entry->io_source_id = 0;
             }
@@ -893,22 +897,24 @@
             case G_IO_STATUS_EOF:
                 gdk_pixbuf_loader_write(entry->loader, (const guchar *)buffer, bytes_read, NULL);
                 gdk_pixbuf_loader_close(entry->loader, NULL);
+                g_io_channel_unref(io_channel);
                 entry->io_channel = NULL;
+                entry->io_source_id = 0;
                 return FALSE;
                 break;
             case G_IO_STATUS_ERROR:
                 gdk_pixbuf_loader_close(entry->loader, NULL);
-                g_io_channel_shutdown(io_channel, FALSE, NULL);
+                g_io_channel_unref(io_channel);
                 entry->io_channel = NULL;
+                entry->io_source_id = 0;
                 return FALSE;
                 break;
             case G_IO_STATUS_AGAIN:
                 return TRUE;
                 break;
         }
-        g_io_channel_shutdown(io_channel, FALSE, NULL);
     }
-    g_io_channel_shutdown(io_channel, FALSE, NULL);
+    g_io_channel_unref(io_channel);
     return FALSE;
 }
 
@@ -1040,6 +1046,7 @@
     switch (event)
     {
         case THUNAR_VFS_MONITOR_EVENT_CHANGED:
+            rstto_navigator_entry_load_image (entry);
             break;
         case THUNAR_VFS_MONITOR_EVENT_CREATED:
             break;
@@ -1051,3 +1058,9 @@
             break;
     }
 }
+
+gint
+rstto_navigator_get_cache_max_images (RsttoNavigator *navigator)
+{
+    return navigator->max_history;
+}

Modified: ristretto/trunk/src/navigator.h
===================================================================
--- ristretto/trunk/src/navigator.h	2007-10-29 09:41:56 UTC (rev 3472)
+++ ristretto/trunk/src/navigator.h	2007-10-29 11:38:03 UTC (rev 3473)
@@ -54,6 +54,8 @@
     GList                 *file_list;
     GList                 *file_iter;
     GList                 *history;
+    gint                   max_history;
+    gint                   max_preload;
 
     gint                   old_position;
     gboolean               running;
@@ -139,6 +141,9 @@
 gboolean
 rstto_navigator_entry_load_image (RsttoNavigatorEntry *entry);
 
+gint
+rstto_navigator_get_cache_max_images (RsttoNavigator *navigator);
+
 G_END_DECLS
 
 #endif /* __RISTRETTO_NAVIGATOR_H__ */




More information about the Goodies-commits mailing list