File nautilus-perf-no-burn-uri-for-desktop.diff of Package nautilus
2006-03-14 Federico Mena Quintero <federico@novell.com>
* src/nautilus-window-menus.c: (nautilus_window_initialize_menus):
Don't set the visibility of the "burn CD" action here.
(nautilus_window_initialize_menus_constructed): New public
function. Only disable NAUTILUS_ACTION_GO_TO_BURN_CD if we are in
a window which has a menubar. This prevents calling
have_burn_uri() unnecessarily for the desktop window, as this is
an expensive operation during login (up to 1 second!). The way
have_burn_uri() works is by creating a "burn:///" URI and seeing
if it is valid, but this makes gnome-vfs load libmapping.so from
nautilus-cd-burner; this takes a long time during login.
* src/nautilus-window-private.h: Added prototype for
nautilus_window_initialize_menus_constructed().
* src/nautilus-window.h: New prototype for
nautilus_window_has_menubar_and_statusbar().
* src/nautilus-window.c
(nautilus_window_has_menubar_and_statusbar): New function; returns
whether the window should have a menubar and statusbar. This
depends on the window_type from the class structure.
(nautilus_window_constructor): Call
nautilus_window_initialize_menus_constructed(). We do it here so
that its own call to nautilus_window_has_menubar_and_statusbar()
will already have the right value for class->window_type.
--- src/nautilus-window-menus.c.orig 2006-03-16 19:04:12.000000000 -0600
+++ src/nautilus-window-menus.c 2006-03-16 19:04:49.000000000 -0600
@@ -743,14 +743,25 @@ nautilus_window_initialize_menus (Nautil
ui = nautilus_ui_string_get ("nautilus-shell-ui.xml");
gtk_ui_manager_add_ui_from_string (ui_manager, ui, -1, NULL);
- if (!have_burn_uri ()) {
- action = gtk_action_group_get_action (action_group, NAUTILUS_ACTION_GO_TO_BURN_CD);
- gtk_action_set_visible (action, FALSE);
- }
-
nautilus_window_initialize_bookmarks_menu (window);
}
+void
+nautilus_window_initialize_menus_constructed (NautilusWindow *window)
+{
+ GtkAction *action;
+
+ /* Don't call have_burn_uri() for the desktop window, as this is a very
+ * expensive operation during login (around 1 second) ---
+ * have_burn_uri() has to create a "burn:///" URI, which causes
+ * gnome-vfs to link in libmapping.so from nautilus-cd-burner.
+ */
+ if (nautilus_window_has_menubar_and_statusbar (window) && !have_burn_uri ()) {
+ action = gtk_action_group_get_action (window->details->main_action_group, NAUTILUS_ACTION_GO_TO_BURN_CD);
+ gtk_action_set_visible (action, FALSE);
+ }
+}
+
static GList *
get_extension_menus (NautilusWindow *window)
{
--- src/nautilus-window-private.h.orig 2006-03-16 19:04:19.000000000 -0600
+++ src/nautilus-window-private.h 2006-03-16 19:04:58.000000000 -0600
@@ -172,6 +172,7 @@ void nautilus_window_set_s
void nautilus_window_load_view_as_menus (NautilusWindow *window);
void nautilus_window_load_extension_menus (NautilusWindow *window);
void nautilus_window_initialize_menus (NautilusWindow *window);
+void nautilus_window_initialize_menus_constructed (NautilusWindow *window);
void nautilus_menus_append_bookmark_to_menu (NautilusWindow *window,
NautilusBookmark *bookmark,
const char *parent_path,
--- src/nautilus-window.c.orig 2006-03-16 19:04:23.000000000 -0600
+++ src/nautilus-window.c 2006-03-16 19:05:59.000000000 -0600
@@ -157,7 +157,6 @@ nautilus_window_init (NautilusWindow *wi
gtk_widget_show (table);
gtk_container_add (GTK_CONTAINER (window), table);
-
statusbar = gtk_statusbar_new ();
window->details->statusbar = statusbar;
gtk_table_attach (GTK_TABLE (table),
@@ -629,6 +628,25 @@ nautilus_window_finalize (GObject *objec
G_OBJECT_CLASS (nautilus_window_parent_class)->finalize (object);
}
+static GObject *
+nautilus_window_constructor (GType type,
+ guint n_construct_properties,
+ GObjectConstructParam *construct_params)
+{
+ GObject *object;
+ NautilusWindow *window;
+
+ object = (* G_OBJECT_CLASS (nautilus_window_parent_class)->constructor) (type,
+ n_construct_properties,
+ construct_params);
+
+ window = NAUTILUS_WINDOW (object);
+
+ nautilus_window_initialize_menus_constructed (window);
+
+ return object;
+}
+
void
nautilus_window_show_window (NautilusWindow *window)
{
@@ -1509,8 +1527,9 @@ static void
nautilus_window_class_init (NautilusWindowClass *class)
{
GtkBindingSet *binding_set;
-
+
G_OBJECT_CLASS (class)->finalize = nautilus_window_finalize;
+ G_OBJECT_CLASS (class)->constructor = nautilus_window_constructor;
G_OBJECT_CLASS (class)->get_property = nautilus_window_get_property;
G_OBJECT_CLASS (class)->set_property = nautilus_window_set_property;
GTK_OBJECT_CLASS (class)->destroy = nautilus_window_destroy;
@@ -1569,3 +1588,19 @@ nautilus_window_class_init (NautilusWind
class->reload = nautilus_window_reload;
class->go_up = nautilus_window_go_up_signal;
}
+
+/**
+ * nautilus_window_has_menubar_and_statusbar:
+ * @window: A #NautilusWindow
+ *
+ * Queries whether the window should have a menubar and statusbar, based on the
+ * window_type from its class structure.
+ *
+ * Return value: TRUE if the window should have a menubar and statusbar; FALSE
+ * otherwise.
+ **/
+gboolean
+nautilus_window_has_menubar_and_statusbar (NautilusWindow *window)
+{
+ return (nautilus_window_get_window_type (window) != NAUTILUS_WINDOW_DESKTOP);
+}
--- src/nautilus-window.h.orig 2006-03-16 19:05:28.000000000 -0600
+++ src/nautilus-window.h 2006-03-16 19:06:10.000000000 -0600
@@ -146,4 +146,6 @@ void nautilus_window_allow_b
gboolean allow);
GtkUIManager * nautilus_window_get_ui_manager (NautilusWindow *window);
+gboolean nautilus_window_has_menubar_and_statusbar (NautilusWindow *window);
+
#endif