[nautilus] view: remove NautilusViewFactory
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] view: remove NautilusViewFactory
- Date: Mon, 8 Apr 2013 23:10:01 +0000 (UTC)
commit 8416d16669c58b2c7c9517857aa6eefbf8c82fd1
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Mon Apr 8 19:03:47 2013 -0400
view: remove NautilusViewFactory
We stopped having pluggable views a long time ago; remove the factory
code completely in favor of a simple nautilus_view_new() that looks at
the specified view ID among the list of views we support.
src/Makefile.am | 2 -
src/nautilus-application.c | 17 --------
src/nautilus-canvas-view.c | 39 +-----------------
src/nautilus-canvas-view.h | 4 +-
src/nautilus-desktop-canvas-view.c | 29 +------------
src/nautilus-desktop-canvas-view.h | 4 +-
src/nautilus-empty-view.c | 35 +---------------
src/nautilus-empty-view.h | 4 +-
src/nautilus-list-view.c | 35 +---------------
src/nautilus-list-view.h | 4 +-
src/nautilus-view-factory.c | 77 ------------------------------------
src/nautilus-view-factory.h | 57 --------------------------
src/nautilus-view.c | 31 ++++++++++++++
src/nautilus-view.h | 13 ++++++-
src/nautilus-window-slot.c | 3 +-
src/nautilus-window.c | 1 -
16 files changed, 60 insertions(+), 295 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index c49ac20..61b1bd2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -195,8 +195,6 @@ nautilus_SOURCES = \
nautilus-view.h \
nautilus-view-dnd.c \
nautilus-view-dnd.h \
- nautilus-view-factory.c \
- nautilus-view-factory.h \
nautilus-window-menus.c \
nautilus-window-private.h \
nautilus-window-slot.c \
diff --git a/src/nautilus-application.c b/src/nautilus-application.c
index 6c8451e..dda7e04 100644
--- a/src/nautilus-application.c
+++ b/src/nautilus-application.c
@@ -30,19 +30,12 @@
#include "nautilus-application.h"
-#if ENABLE_EMPTY_VIEW
-#include "nautilus-empty-view.h"
-#endif /* ENABLE_EMPTY_VIEW */
-
#include "nautilus-bookmarks-window.h"
#include "nautilus-connect-server-dialog.h"
-#include "nautilus-desktop-canvas-view.h"
#include "nautilus-desktop-window.h"
#include "nautilus-file-management-properties.h"
#include "nautilus-freedesktop-dbus.h"
-#include "nautilus-canvas-view.h"
#include "nautilus-image-properties-page.h"
-#include "nautilus-list-view.h"
#include "nautilus-previewer.h"
#include "nautilus-progress-ui-handler.h"
#include "nautilus-self-check-functions.h"
@@ -1602,16 +1595,6 @@ nautilus_application_startup (GApplication *app)
/* initialize preferences and create the global GSettings objects */
nautilus_global_preferences_init ();
- /* register views */
- nautilus_profile_start ("Register views");
- nautilus_canvas_view_register ();
- nautilus_desktop_canvas_view_register ();
- nautilus_list_view_register ();
-#if ENABLE_EMPTY_VIEW
- nautilus_empty_view_register ();
-#endif
- nautilus_profile_end ("Register views");
-
/* register property pages */
nautilus_image_properties_page_register ();
diff --git a/src/nautilus-canvas-view.c b/src/nautilus-canvas-view.c
index 61ee1c2..c51bc9d 100644
--- a/src/nautilus-canvas-view.c
+++ b/src/nautilus-canvas-view.c
@@ -31,7 +31,6 @@
#include "nautilus-desktop-canvas-view.h"
#include "nautilus-error-reporting.h"
#include "nautilus-view-dnd.h"
-#include "nautilus-view-factory.h"
#include <stdlib.h>
#include <eel/eel-vfs-extensions.h>
@@ -2259,42 +2258,10 @@ nautilus_canvas_view_init (NautilusCanvasView *canvas_view)
G_CALLBACK (canvas_view_notify_clipboard_info), canvas_view);
}
-static NautilusView *
-nautilus_canvas_view_create (NautilusWindowSlot *slot)
+NautilusView *
+nautilus_canvas_view_new (NautilusWindowSlot *slot)
{
- NautilusCanvasView *view;
-
- view = g_object_new (NAUTILUS_TYPE_CANVAS_VIEW,
+ return g_object_new (NAUTILUS_TYPE_CANVAS_VIEW,
"window-slot", slot,
NULL);
- return NAUTILUS_VIEW (view);
-}
-
-#define TRANSLATE_VIEW_INFO(view_info) \
- view_info.view_combo_label = _(view_info.view_combo_label); \
- view_info.view_menu_label_with_mnemonic = _(view_info.view_menu_label_with_mnemonic); \
- view_info.error_label = _(view_info.error_label); \
- view_info.startup_error_label = _(view_info.startup_error_label); \
- view_info.display_location_label = _(view_info.display_location_label); \
-
-
-static NautilusViewInfo nautilus_canvas_view = {
- NAUTILUS_CANVAS_VIEW_ID,
- /* translators: this is used in the view selection dropdown
- * of navigation windows and in the preferences dialog */
- N_("Icon View"),
- /* translators: this is used in the view menu */
- N_("_Icons"),
- N_("The icon view encountered an error."),
- N_("The icon view encountered an error while starting up."),
- N_("Display this location with the icon view."),
- nautilus_canvas_view_create
-};
-
-void
-nautilus_canvas_view_register (void)
-{
- TRANSLATE_VIEW_INFO (nautilus_canvas_view)
- nautilus_view_factory_register (&nautilus_canvas_view);
}
-
diff --git a/src/nautilus-canvas-view.h b/src/nautilus-canvas-view.h
index 313e4e0..6325a99 100644
--- a/src/nautilus-canvas-view.h
+++ b/src/nautilus-canvas-view.h
@@ -44,8 +44,6 @@ typedef struct NautilusCanvasViewClass NautilusCanvasViewClass;
#define NAUTILUS_CANVAS_VIEW_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), NAUTILUS_TYPE_CANVAS_VIEW, NautilusCanvasViewClass))
-#define NAUTILUS_CANVAS_VIEW_ID "OAFIID:Nautilus_File_Manager_Canvas_View"
-
typedef struct NautilusCanvasViewDetails NautilusCanvasViewDetails;
struct NautilusCanvasView {
@@ -66,7 +64,7 @@ void nautilus_canvas_view_filter_by_screen (NautilusCanvasView *canvas_view,
gboolean filter);
void nautilus_canvas_view_clean_up_by_name (NautilusCanvasView *canvas_view);
-void nautilus_canvas_view_register (void);
+NautilusView * nautilus_canvas_view_new (NautilusWindowSlot *slot);
NautilusCanvasContainer * nautilus_canvas_view_get_canvas_container (NautilusCanvasView *view);
diff --git a/src/nautilus-desktop-canvas-view.c b/src/nautilus-desktop-canvas-view.c
index 5652db8..3f32926 100644
--- a/src/nautilus-desktop-canvas-view.c
+++ b/src/nautilus-desktop-canvas-view.c
@@ -30,7 +30,6 @@
#include "nautilus-actions.h"
#include "nautilus-canvas-view-container.h"
-#include "nautilus-view-factory.h"
#include "nautilus-view.h"
#include <X11/Xatom.h>
@@ -743,12 +742,10 @@ real_merge_menus (NautilusView *view)
g_free (control_center_path);
}
-static NautilusView *
-nautilus_desktop_canvas_view_create (NautilusWindowSlot *slot)
+NautilusView *
+nautilus_desktop_canvas_view_new (NautilusWindowSlot *slot)
{
- NautilusCanvasView *view;
-
- view = g_object_new (NAUTILUS_TYPE_DESKTOP_CANVAS_VIEW,
+ return g_object_new (NAUTILUS_TYPE_DESKTOP_CANVAS_VIEW,
"window-slot", slot,
"supports-zooming", FALSE,
"supports-auto-layout", FALSE,
@@ -756,24 +753,4 @@ nautilus_desktop_canvas_view_create (NautilusWindowSlot *slot)
"supports-scaling", TRUE,
"supports-keep-aligned", TRUE,
NULL);
- return NAUTILUS_VIEW (view);
-}
-
-static NautilusViewInfo nautilus_desktop_canvas_view = {
- NAUTILUS_DESKTOP_CANVAS_VIEW_ID,
- "Desktop View",
- "_Desktop",
- N_("The desktop view encountered an error."),
- N_("The desktop view encountered an error while starting up."),
- "Display this location with the desktop view.",
- nautilus_desktop_canvas_view_create
-};
-
-void
-nautilus_desktop_canvas_view_register (void)
-{
- nautilus_desktop_canvas_view.error_label = _(nautilus_desktop_canvas_view.error_label);
- nautilus_desktop_canvas_view.startup_error_label =
_(nautilus_desktop_canvas_view.startup_error_label);
-
- nautilus_view_factory_register (&nautilus_desktop_canvas_view);
}
diff --git a/src/nautilus-desktop-canvas-view.h b/src/nautilus-desktop-canvas-view.h
index 725851c..cd084a5 100644
--- a/src/nautilus-desktop-canvas-view.h
+++ b/src/nautilus-desktop-canvas-view.h
@@ -39,8 +39,6 @@
#define NAUTILUS_DESKTOP_CANVAS_VIEW_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), NAUTILUS_TYPE_DESKTOP_CANVAS_VIEW, NautilusDesktopCanvasViewClass))
-#define NAUTILUS_DESKTOP_CANVAS_VIEW_ID "OAFIID:Nautilus_File_Manager_Desktop_Canvas_View"
-
typedef struct NautilusDesktopCanvasViewDetails NautilusDesktopCanvasViewDetails;
typedef struct {
NautilusCanvasView parent;
@@ -53,6 +51,6 @@ typedef struct {
/* GObject support */
GType nautilus_desktop_canvas_view_get_type (void);
-void nautilus_desktop_canvas_view_register (void);
+NautilusView * nautilus_desktop_canvas_view_new (NautilusWindowSlot *slot);
#endif /* NAUTILUS_DESKTOP_CANVAS_VIEW_H */
diff --git a/src/nautilus-empty-view.c b/src/nautilus-empty-view.c
index 25e06fb..2037133 100644
--- a/src/nautilus-empty-view.c
+++ b/src/nautilus-empty-view.c
@@ -27,7 +27,6 @@
#include "nautilus-empty-view.h"
#include "nautilus-view.h"
-#include "nautilus-view-factory.h"
#include <string.h>
#include <libnautilus-private/nautilus-file-utilities.h>
@@ -292,38 +291,10 @@ nautilus_empty_view_init (NautilusEmptyView *empty_view)
NautilusEmptyViewDetails);
}
-static NautilusView *
-nautilus_empty_view_create (NautilusWindowSlot *slot)
+NautilusView *
+nautilus_empty_view_new (NautilusWindowSlot *slot)
{
- NautilusEmptyView *view;
-
- g_assert (NAUTILUS_IS_WINDOW_SLOT (slot));
-
- view = g_object_new (NAUTILUS_TYPE_EMPTY_VIEW,
+ return g_object_new (NAUTILUS_TYPE_EMPTY_VIEW,
"window-slot", slot,
NULL);
-
- return NAUTILUS_VIEW (view);
-}
-
-static NautilusViewInfo nautilus_empty_view = {
- NAUTILUS_EMPTY_VIEW_ID,
- "Empty",
- "Empty View",
- "_Empty View",
- "The empty view encountered an error.",
- "Display this location with the empty view.",
- nautilus_empty_view_create
-};
-
-void
-nautilus_empty_view_register (void)
-{
- nautilus_empty_view.id = nautilus_empty_view.id;
- nautilus_empty_view.view_combo_label = nautilus_empty_view.view_combo_label;
- nautilus_empty_view.view_menu_label_with_mnemonic = nautilus_empty_view.view_menu_label_with_mnemonic;
- nautilus_empty_view.error_label = nautilus_empty_view.error_label;
- nautilus_empty_view.display_location_label = nautilus_empty_view.display_location_label;
-
- nautilus_view_factory_register (&nautilus_empty_view);
}
diff --git a/src/nautilus-empty-view.h b/src/nautilus-empty-view.h
index 2f599a8..14ce14c 100644
--- a/src/nautilus-empty-view.h
+++ b/src/nautilus-empty-view.h
@@ -39,8 +39,6 @@
#define NAUTILUS_EMPTY_VIEW_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), NAUTILUS_TYPE_EMPTY_VIEW, NautilusEmptyViewClass))
-#define NAUTILUS_EMPTY_VIEW_ID "OAFIID:Nautilus_File_Manager_Empty_View"
-
typedef struct NautilusEmptyViewDetails NautilusEmptyViewDetails;
typedef struct {
@@ -53,6 +51,6 @@ typedef struct {
} NautilusEmptyViewClass;
GType nautilus_empty_view_get_type (void);
-void nautilus_empty_view_register (void);
+NautilusView * nautilus_empty_view_new (NautilusWindowSlot *slot);
#endif /* NAUTILUS_EMPTY_VIEW_H */
diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c
index b0b5517..04d4444 100644
--- a/src/nautilus-list-view.c
+++ b/src/nautilus-list-view.c
@@ -31,7 +31,6 @@
#include "nautilus-list-model.h"
#include "nautilus-error-reporting.h"
#include "nautilus-view-dnd.h"
-#include "nautilus-view-factory.h"
#include <string.h>
#include <eel/eel-vfs-extensions.h>
@@ -3286,40 +3285,12 @@ nautilus_list_view_init (NautilusListView *list_view)
G_CALLBACK (list_view_notify_clipboard_info), list_view);
}
-static NautilusView *
-nautilus_list_view_create (NautilusWindowSlot *slot)
+NautilusView *
+nautilus_list_view_new (NautilusWindowSlot *slot)
{
- NautilusListView *view;
-
- view = g_object_new (NAUTILUS_TYPE_LIST_VIEW,
+ return g_object_new (NAUTILUS_TYPE_LIST_VIEW,
"window-slot", slot,
NULL);
- return NAUTILUS_VIEW (view);
-}
-
-static NautilusViewInfo nautilus_list_view = {
- NAUTILUS_LIST_VIEW_ID,
- /* translators: this is used in the view selection dropdown
- * of navigation windows and in the preferences dialog */
- N_("List View"),
- /* translators: this is used in the view menu */
- N_("_List"),
- N_("The list view encountered an error."),
- N_("The list view encountered an error while starting up."),
- N_("Display this location with the list view."),
- nautilus_list_view_create
-};
-
-void
-nautilus_list_view_register (void)
-{
- nautilus_list_view.view_combo_label = _(nautilus_list_view.view_combo_label);
- nautilus_list_view.view_menu_label_with_mnemonic =
_(nautilus_list_view.view_menu_label_with_mnemonic);
- nautilus_list_view.error_label = _(nautilus_list_view.error_label);
- nautilus_list_view.startup_error_label = _(nautilus_list_view.startup_error_label);
- nautilus_list_view.display_location_label = _(nautilus_list_view.display_location_label);
-
- nautilus_view_factory_register (&nautilus_list_view);
}
GtkTreeView*
diff --git a/src/nautilus-list-view.h b/src/nautilus-list-view.h
index fc5d266..91a26dd 100644
--- a/src/nautilus-list-view.h
+++ b/src/nautilus-list-view.h
@@ -41,8 +41,6 @@
#define NAUTILUS_LIST_VIEW_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), NAUTILUS_TYPE_LIST_VIEW, NautilusListViewClass))
-#define NAUTILUS_LIST_VIEW_ID "OAFIID:Nautilus_File_Manager_List_View"
-
typedef struct NautilusListViewDetails NautilusListViewDetails;
typedef struct {
@@ -55,7 +53,7 @@ typedef struct {
} NautilusListViewClass;
GType nautilus_list_view_get_type (void);
-void nautilus_list_view_register (void);
+NautilusView * nautilus_list_view_new (NautilusWindowSlot *slot);
GtkTreeView* nautilus_list_view_get_tree_view (NautilusListView *list_view);
#endif /* NAUTILUS_LIST_VIEW_H */
diff --git a/src/nautilus-view.c b/src/nautilus-view.c
index 357da27..258f4fb 100644
--- a/src/nautilus-view.c
+++ b/src/nautilus-view.c
@@ -39,6 +39,10 @@
#include "nautilus-previewer.h"
#include "nautilus-properties-window.h"
+#if ENABLE_EMPTY_VIEW
+#include "nautilus-empty-view.h"
+#endif
+
#include <gdk/gdkx.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
@@ -9841,3 +9845,30 @@ nautilus_view_class_init (NautilusViewClass *klass)
"delete", 0);
}
+NautilusView *
+nautilus_view_new (const gchar *id,
+ NautilusWindowSlot *slot)
+{
+ NautilusView *view = NULL;
+
+ if (g_strcmp0 (id, NAUTILUS_CANVAS_VIEW_ID) == 0) {
+ view = nautilus_canvas_view_new (slot);
+ } else if (g_strcmp0 (id, NAUTILUS_LIST_VIEW_ID) == 0) {
+ view = nautilus_list_view_new (slot);
+ } else if (g_strcmp0 (id, NAUTILUS_DESKTOP_CANVAS_VIEW_ID) == 0) {
+ view = nautilus_desktop_canvas_view_new (slot);
+ }
+#if ENABLE_EMPTY_VIEW
+ else if (g_strcmp0 (id, NAUTILUS_EMPTY_VIEW_ID) == 0) {
+ view = nautilus_empty_view_new (slot);
+ }
+#endif
+
+ if (view == NULL) {
+ g_critical ("Unknown view type ID: %s", id);
+ } else if (g_object_is_floating (view)) {
+ g_object_ref_sink (view);
+ }
+
+ return view;
+}
diff --git a/src/nautilus-view.h b/src/nautilus-view.h
index 9e5c4fc..594101a 100644
--- a/src/nautilus-view.h
+++ b/src/nautilus-view.h
@@ -41,6 +41,14 @@ typedef struct NautilusViewClass NautilusViewClass;
#include "nautilus-window.h"
#include "nautilus-window-slot.h"
+#if ENABLE_EMPTY_VIEW
+#define NAUTILUS_EMPTY_VIEW_ID "OAFIID:Nautilus_File_Manager_Empty_View"
+#endif
+
+#define NAUTILUS_CANVAS_VIEW_ID "OAFIID:Nautilus_File_Manager_Canvas_View"
+#define NAUTILUS_DESKTOP_CANVAS_VIEW_ID "OAFIID:Nautilus_File_Manager_Desktop_Canvas_View"
+#define NAUTILUS_LIST_VIEW_ID "OAFIID:Nautilus_File_Manager_List_View"
+
#define NAUTILUS_TYPE_VIEW nautilus_view_get_type()
#define NAUTILUS_VIEW(obj)\
(G_TYPE_CHECK_INSTANCE_CAST ((obj), NAUTILUS_TYPE_VIEW, NautilusView))
@@ -294,8 +302,11 @@ struct NautilusViewClass {
/* GObject support */
GType nautilus_view_get_type (void);
+NautilusView * nautilus_view_new (const gchar *id,
+ NautilusWindowSlot *slot);
+
/* Functions callable from the user interface and elsewhere. */
-NautilusWindowSlot *nautilus_view_get_nautilus_window_slot (NautilusView *view);
+NautilusWindowSlot *nautilus_view_get_nautilus_window_slot (NautilusView *view);
char * nautilus_view_get_uri (NautilusView *view);
void nautilus_view_display_selection_info (NautilusView *view);
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
index 7b36872..48ba4d2 100644
--- a/src/nautilus-window-slot.c
+++ b/src/nautilus-window-slot.c
@@ -35,7 +35,6 @@
#include "nautilus-special-location-bar.h"
#include "nautilus-toolbar.h"
#include "nautilus-trash-bar.h"
-#include "nautilus-view-factory.h"
#include "nautilus-window-private.h"
#include "nautilus-x-content-bar.h"
@@ -1389,7 +1388,7 @@ create_content_view (NautilusWindowSlot *slot,
g_object_ref (view);
} else {
/* create a new content view */
- view = nautilus_view_factory_create (view_id, slot);
+ view = nautilus_view_new (view_id, slot);
slot->details->new_content_view = view;
nautilus_window_slot_connect_new_content_view (slot);
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index c1f6765..52ca70c 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -41,7 +41,6 @@
#include "nautilus-places-sidebar.h"
#include "nautilus-pathbar.h"
#include "nautilus-toolbar.h"
-#include "nautilus-view-factory.h"
#include "nautilus-window-slot.h"
#include "nautilus-list-view.h"
#include "nautilus-canvas-view.h"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]