Commit 8416d166 authored by Cosimo Cecchi's avatar Cosimo Cecchi

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.
parent f2a3ef1d
......@@ -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 \
......
......@@ -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 ();
......
......@@ -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);
}
......@@ -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);
......
......@@ -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);
}
......@@ -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 */
......@@ -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);
}
......@@ -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 */
......@@ -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*
......
......@@ -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 */
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
nautilus-view-factory.c: register and create NautilusViews
Copyright (C) 2004 Red Hat Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public
License along with this program; if not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
Author: Alexander Larsson <alexl@redhat.com>
*/
#include "config.h"
#include "nautilus-view-factory.h"
static GList *registered_views;
void
nautilus_view_factory_register (NautilusViewInfo *view_info)
{
g_return_if_fail (view_info != NULL);
g_return_if_fail (view_info->id != NULL);
g_return_if_fail (nautilus_view_factory_lookup (view_info->id) == NULL);
registered_views = g_list_append (registered_views, view_info);
}
const NautilusViewInfo *
nautilus_view_factory_lookup (const char *id)
{
GList *l;
NautilusViewInfo *view_info;
g_return_val_if_fail (id != NULL, NULL);
for (l = registered_views; l != NULL; l = l->next) {
view_info = l->data;
if (strcmp (view_info->id, id) == 0) {
return view_info;
}
}
return NULL;
}
NautilusView *
nautilus_view_factory_create (const char *id,
NautilusWindowSlot *slot)
{
const NautilusViewInfo *view_info;
NautilusView *view;
view_info = nautilus_view_factory_lookup (id);
if (view_info == NULL) {
return NULL;
}
view = view_info->create (slot);
if (g_object_is_floating (view)) {
g_object_ref_sink (view);
}
return view;
}
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
nautilus-view-factory.h: register and create NautilusViews
Copyright (C) 2004 Red Hat Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public
License along with this program; if not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
Author: Alexander Larsson <alexl@redhat.com>
*/
#ifndef NAUTILUS_VIEW_FACTORY_H
#define NAUTILUS_VIEW_FACTORY_H
#include <string.h>
#include <gio/gio.h>
#include "nautilus-view.h"
#include "nautilus-window-slot.h"
G_BEGIN_DECLS
typedef struct _NautilusViewInfo NautilusViewInfo;
struct _NautilusViewInfo {
char *id;
char *view_combo_label; /* Foo View (used in preferences dialog and navigation combo) */
char *view_menu_label_with_mnemonic; /* View -> _Foo (this is the "_Foo" part) */
char *error_label; /* The foo view encountered an error. */
char *startup_error_label; /* The foo view encountered an error while starting up. */
char *display_location_label; /* Display this location with the foo view. */
NautilusView * (*create) (NautilusWindowSlot *slot);
};
void nautilus_view_factory_register (NautilusViewInfo *view_info);
const NautilusViewInfo *nautilus_view_factory_lookup (const char *id);
NautilusView * nautilus_view_factory_create (const char *id,
NautilusWindowSlot *slot);
G_END_DECLS
#endif /* NAUTILUS_VIEW_FACTORY_H */
......@@ -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;
}
......@@ -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);
......
......@@ -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);
......
......@@ -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"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment