]> www.fi.muni.cz Git - evince.git/blobdiff - shell/ev-window.c
Plug some memory leaks
[evince.git] / shell / ev-window.c
index d860d74589186daff904a6cb20c4dae0bd6eeadd..be601901ab38d925f416f4bec5d92948255f58bf 100644 (file)
@@ -1102,7 +1102,7 @@ ev_window_cmd_file_open (GtkAction *action, EvWindow *window)
                                
                folder = gtk_file_chooser_get_current_folder_uri (GTK_FILE_CHOOSER (chooser));
 
-               ev_application_open_uri_list (EV_APP, uris);
+               ev_application_open_uri_list (EV_APP, uris, GDK_CURRENT_TIME);
        
                g_slist_foreach (uris, (GFunc)g_free, NULL);    
                g_slist_free (uris);
@@ -1126,7 +1126,7 @@ ev_window_cmd_recent_file_activate (GtkAction *action,
 
        uri = egg_recent_item_get_uri (item);
 
-       ev_application_open_uri (EV_APP, uri, NULL, NULL);      
+       ev_application_open_uri (EV_APP, uri, NULL, GDK_CURRENT_TIME, NULL);
        
        g_free (uri);
 }
@@ -1486,6 +1486,8 @@ ev_window_print_range (EvWindow *ev_window, int first_page, int last_page)
                break;
        }
 
+       g_object_unref (job);
+
        gtk_widget_destroy (print_dialog);
 
        if (print_job != NULL) {
@@ -2060,35 +2062,16 @@ ev_window_cmd_edit_toolbar_cb (GtkDialog *dialog, gint response, gpointer data)
         gtk_widget_destroy (GTK_WIDGET (dialog));
 }
 
-/* should these be hooked up to properties?? */
-static void
-save_rotation_to_file (EvWindow *window)
-{
-       int rotation;
-
-       if (window->priv->uri) {
-               rotation = ev_view_get_rotation (EV_VIEW (window->priv->view));
-               ev_metadata_manager_set_int (window->priv->uri, "rotation",
-                                            rotation);
-       }
-
-
-}
-
 static void
 ev_window_cmd_edit_rotate_left (GtkAction *action, EvWindow *ev_window)
 {
        ev_view_rotate_left (EV_VIEW (ev_window->priv->view));
-       ev_sidebar_thumbnails_refresh (EV_SIDEBAR_THUMBNAILS (ev_window->priv->sidebar_thumbs));
-       save_rotation_to_file (ev_window);
 }
 
 static void
 ev_window_cmd_edit_rotate_right (GtkAction *action, EvWindow *ev_window)
 {
        ev_view_rotate_right (EV_VIEW (ev_window->priv->view));
-       ev_sidebar_thumbnails_refresh (EV_SIDEBAR_THUMBNAILS (ev_window->priv->sidebar_thumbs));
-       save_rotation_to_file (ev_window);
 }
 
 static void
@@ -2420,6 +2403,22 @@ ev_window_continuous_changed_cb (EvView *view, GParamSpec *pspec, EvWindow *ev_w
                                         ev_view_get_continuous (EV_VIEW (ev_window->priv->view)));
 }
 
+static void     
+ev_window_rotation_changed_cb (EvView *view, GParamSpec *pspec, EvWindow *window)
+{
+       int rotation;
+
+       rotation = ev_view_get_rotation (EV_VIEW (window->priv->view));
+
+       if (window->priv->uri) {
+               ev_metadata_manager_set_int (window->priv->uri, "rotation",
+                                            rotation);
+       }
+
+       ev_sidebar_thumbnails_refresh (EV_SIDEBAR_THUMBNAILS (window->priv->sidebar_thumbs),
+                                      rotation);
+}
+
 static void     
 ev_window_dual_mode_changed_cb (EvView *view, GParamSpec *pspec, EvWindow *ev_window)
 {
@@ -2748,14 +2747,23 @@ zoom_control_changed_cb (EphyZoomAction *action,
 static void
 ev_window_finalize (GObject *object)
 {
-       GList *windows = gtk_window_list_toplevels ();
+       gboolean empty = TRUE;
+       GList *list, *windows;
 
-       if (windows == NULL) {
-               ev_application_shutdown (EV_APP);
-       } else {
-               g_list_free (windows);
-       }
 
+       windows = gtk_window_list_toplevels ();
+
+       for (list = windows; list; list = list->next) {
+               if (EV_IS_WINDOW (list->data)) {
+                       empty = FALSE;
+                       break;
+               }
+       }
+       
+       if (empty)
+               ev_application_shutdown (EV_APP);
+       
+       g_list_free (windows);
        G_OBJECT_CLASS (ev_window_parent_class)->finalize (object);
 }
 
@@ -2830,6 +2838,11 @@ ev_window_dispose (GObject *object)
                priv->find_bar = NULL;
        }
 
+       if (priv->uri) {
+               g_free (priv->uri);
+               priv->uri = NULL;
+       }
+
        if (window->priv->fullscreen_timeout_source) {
                g_source_destroy (window->priv->fullscreen_timeout_source);
                window->priv->fullscreen_timeout_source = NULL;
@@ -3045,7 +3058,7 @@ drag_data_received_cb (GtkWidget *widget, GdkDragContext *context,
 
                gnome_vfs_uri_list_free (uri_list);
                
-               ev_application_open_uri_list (EV_APP, uris);
+               ev_application_open_uri_list (EV_APP, uris, 0);
                
                g_slist_free (uris);
 
@@ -3513,6 +3526,10 @@ ev_window_init (EvWindow *ev_window)
                          "notify::continuous",
                          G_CALLBACK (ev_window_continuous_changed_cb),
                          ev_window);
+       g_signal_connect (ev_window->priv->view,
+                         "notify::rotation",
+                         G_CALLBACK (ev_window_rotation_changed_cb),
+                         ev_window);
 
        ev_window->priv->statusbar = ev_statusbar_new ();
        gtk_box_pack_end (GTK_BOX (ev_window->priv->main_box),