[nautilus] icon-view: move background setting code to FMDesktopIconView



commit ab0616de55f6f817a745caac26fd2b38ae41b71b
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Tue Sep 28 14:45:38 2010 +0200

    icon-view: move background setting code to FMDesktopIconView
    
    So that we avoid setting backgrounds on regular nautilus windows.

 src/file-manager/fm-desktop-icon-view.c |   60 ++++++++++++++-----------------
 src/file-manager/fm-icon-view.c         |   21 -----------
 2 files changed, 27 insertions(+), 54 deletions(-)
---
diff --git a/src/file-manager/fm-desktop-icon-view.c b/src/file-manager/fm-desktop-icon-view.c
index 11181bb..b091067 100644
--- a/src/file-manager/fm-desktop-icon-view.c
+++ b/src/file-manager/fm-desktop-icon-view.c
@@ -31,13 +31,8 @@
 
 #include <X11/Xatom.h>
 #include <gtk/gtk.h>
-#include <dirent.h>
 #include <eel/eel-glib-extensions.h>
-#include <eel/eel-gnome-extensions.h>
 #include <eel/eel-gtk-extensions.h>
-#include <eel/eel-gtk-macros.h>
-#include <eel/eel-stock-dialogs.h>
-#include <eel/eel-string.h>
 #include <eel/eel-vfs-extensions.h>
 #include <fcntl.h>
 #include <gdk/gdkx.h>
@@ -80,8 +75,6 @@ struct FMDesktopIconViewDetails
 	gboolean pending_rescan;
 };
 
-static void     fm_desktop_icon_view_init                   (FMDesktopIconView      *desktop_icon_view);
-static void     fm_desktop_icon_view_class_init             (FMDesktopIconViewClass *klass);
 static void     default_zoom_level_changed                        (gpointer                user_data);
 static gboolean real_supports_auto_layout                         (FMIconView             *view);
 static gboolean real_supports_scaling	                          (FMIconView             *view);
@@ -93,10 +86,7 @@ static gboolean real_supports_zooming                             (FMDirectoryVi
 static void     fm_desktop_icon_view_update_icon_container_fonts  (FMDesktopIconView      *view);
 static void     font_changed_callback                             (gpointer                callback_data);
 
-
-EEL_CLASS_BOILERPLATE (FMDesktopIconView,
-		       fm_desktop_icon_view,
-		       FM_TYPE_ICON_VIEW)
+G_DEFINE_TYPE (FMDesktopIconView, fm_desktop_icon_view, FM_TYPE_ICON_VIEW)
 
 static char *desktop_directory;
 static time_t desktop_dir_modify_time;
@@ -257,7 +247,21 @@ desktop_icon_view_property_filter (GdkXEvent *gdk_xevent,
 }
 
 static void
-fm_desktop_icon_view_destroy (GtkObject *object)
+real_begin_loading (FMDirectoryView *object)
+{
+	NautilusIconContainer *icon_container;
+	FMDesktopIconView *view;
+
+	view = FM_DESKTOP_ICON_VIEW (object);
+
+	icon_container = get_icon_container (view);
+	nautilus_connect_desktop_background_to_file_metadata (icon_container);
+
+	FM_DIRECTORY_VIEW_CLASS (fm_desktop_icon_view_parent_class)->begin_loading (object);
+}
+
+static void
+fm_desktop_icon_view_dispose (GObject *object)
 {
 	FMDesktopIconView *icon_view;
 	GtkUIManager *ui_manager;
@@ -277,16 +281,6 @@ fm_desktop_icon_view_destroy (GtkObject *object)
 					&icon_view->details->desktop_action_group);
 	}
 
-	GTK_OBJECT_CLASS (parent_class)->destroy (object);
-}
-
-static void
-fm_desktop_icon_view_finalize (GObject *object)
-{
-	FMDesktopIconView *icon_view;
-
-	icon_view = FM_DESKTOP_ICON_VIEW (object);
-
 	g_signal_handlers_disconnect_by_func (nautilus_icon_view_preferences,
 					      default_zoom_level_changed,
 					      icon_view);
@@ -302,18 +296,15 @@ fm_desktop_icon_view_finalize (GObject *object)
 					      fm_directory_view_update_menus,
 					      icon_view);
 
-	g_free (icon_view->details);
-
-	G_OBJECT_CLASS (parent_class)->finalize (object);
+	G_OBJECT_CLASS (fm_desktop_icon_view_parent_class)->dispose (object);
 }
 
 static void
 fm_desktop_icon_view_class_init (FMDesktopIconViewClass *class)
 {
-	G_OBJECT_CLASS (class)->finalize = fm_desktop_icon_view_finalize;
-
-	GTK_OBJECT_CLASS (class)->destroy = fm_desktop_icon_view_destroy;
+	G_OBJECT_CLASS (class)->dispose = fm_desktop_icon_view_dispose;
 
+	FM_DIRECTORY_VIEW_CLASS (class)->begin_loading = real_begin_loading;
 	FM_DIRECTORY_VIEW_CLASS (class)->merge_menus = real_merge_menus;
 	FM_DIRECTORY_VIEW_CLASS (class)->update_menus = real_update_menus;
 	FM_DIRECTORY_VIEW_CLASS (class)->supports_zooming = real_supports_zooming;
@@ -322,6 +313,8 @@ fm_desktop_icon_view_class_init (FMDesktopIconViewClass *class)
 	FM_ICON_VIEW_CLASS (class)->supports_scaling = real_supports_scaling;
 	FM_ICON_VIEW_CLASS (class)->supports_keep_aligned = real_supports_keep_aligned;
 	FM_ICON_VIEW_CLASS (class)->supports_labels_beside_icons = real_supports_labels_beside_icons;
+
+	g_type_class_add_private (class, sizeof (FMDesktopIconViewDetails));
 }
 
 static void
@@ -536,6 +529,10 @@ fm_desktop_icon_view_init (FMDesktopIconView *desktop_icon_view)
 	GtkAllocation allocation;
 	GtkAdjustment *hadj, *vadj;
 
+	desktop_icon_view->details = G_TYPE_INSTANCE_GET_PRIVATE (desktop_icon_view,
+								  FM_TYPE_DESKTOP_ICON_VIEW,
+								  FMDesktopIconViewDetails);
+
 	if (desktop_directory == NULL) {
 		g_signal_connect_swapped (nautilus_preferences, "changed::" NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR,
 					  G_CALLBACK(desktop_directory_changed_callback),
@@ -548,9 +545,6 @@ fm_desktop_icon_view_init (FMDesktopIconView *desktop_icon_view)
 	nautilus_icon_container_set_use_drop_shadows (icon_container, TRUE);
 	fm_icon_container_set_sort_desktop (FM_ICON_CONTAINER (icon_container), TRUE);
 
-	/* Set up details */
-	desktop_icon_view->details = g_new0 (FMDesktopIconViewDetails, 1);	
-
 	/* Do a reload on the desktop if we don't have FAM, a smarter
 	 * way to keep track of the items on the desktop.
 	 */
@@ -699,7 +693,7 @@ real_update_menus (FMDirectoryView *view)
 
 	g_assert (FM_IS_DESKTOP_ICON_VIEW (view));
 
-	EEL_CALL_PARENT (FM_DIRECTORY_VIEW_CLASS, update_menus, (view));
+	FM_DIRECTORY_VIEW_CLASS (fm_desktop_icon_view_parent_class)->update_menus (view);
 
 	desktop_view = FM_DESKTOP_ICON_VIEW (view);
 
@@ -757,7 +751,7 @@ real_merge_menus (FMDirectoryView *view)
 	GtkActionGroup *action_group;
 	const char *ui;
 
-	EEL_CALL_PARENT (FM_DIRECTORY_VIEW_CLASS, merge_menus, (view));
+	FM_DIRECTORY_VIEW_CLASS (fm_desktop_icon_view_parent_class)->merge_menus (view);
 
 	desktop_view = FM_DESKTOP_ICON_VIEW (view);
 
diff --git a/src/file-manager/fm-icon-view.c b/src/file-manager/fm-icon-view.c
index 6e5cb3d..92e652a 100644
--- a/src/file-manager/fm-icon-view.c
+++ b/src/file-manager/fm-icon-view.c
@@ -1219,27 +1219,6 @@ fm_icon_view_begin_loading (FMDirectoryView *view)
 	/* kill any sound preview process that is ongoing */
 	preview_audio (icon_view, NULL, FALSE);
 
-	/* FIXME bugzilla.gnome.org 45060: Should use methods instead
-	 * of hardcoding desktop knowledge in here.
-	 */
-	if (FM_IS_DESKTOP_ICON_VIEW (view)) {
-		nautilus_connect_desktop_background_to_file_metadata (NAUTILUS_ICON_CONTAINER (icon_container), file);
-	} else {
-		GdkDragAction default_action;
-		
-		if (nautilus_window_info_get_window_type (fm_directory_view_get_nautilus_window (view)) == NAUTILUS_WINDOW_NAVIGATION) {
-			default_action = NAUTILUS_DND_ACTION_SET_AS_GLOBAL_BACKGROUND;
-		} else {
-			default_action = NAUTILUS_DND_ACTION_SET_AS_FOLDER_BACKGROUND;
-		}
-		
-		nautilus_connect_background_to_file_metadata 
-			(icon_container, 
-			 file, 
-			 default_action);
-	}
-
-	
 	/* Set up the zoom level from the metadata. */
 	if (fm_directory_view_supports_zooming (FM_DIRECTORY_VIEW (icon_view))) {
 		if (icon_view->details->compact) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]