Creating the desktop's menu bar takes 1 second
- From: Federico Mena Quintero <federico ximian com>
- To: nautilus-list gnome org
- Subject: Creating the desktop's menu bar takes 1 second
- Date: Tue, 14 Mar 2006 22:42:15 -0600
Hi,
I've been taking some more profiles of nautilus startup, and creating
the menu bar for the desktop window takes around 1 second at login time.
Of course, the desktop window has no visible menu bar :)
Digging deeper, the culprit is this:
nautilus_window_initialize_menus {
...
if (!have_burn_uri ()) { <---- see below
set_visible (NAUTILUS_ACTION_GO_TO_BURN_CD, FALSE);
}
have_burn_uri() takes between 0.5 and 1.0 seconds, depending on whether
we get preempted in the middle. have_burn_uri() is expensive the first
time, because it has to load libmapping.so in order to create a
"burn:///" URI. In addition, it has to spawn mapping-daemon due to the
module's initialization function. Given all the churn that happens
during login, this can become really expensive, even with readahead
files.
Ideally, the desktop window shouldn't get a menubar/statusbar created
for it at all. In the meantime, here's a simple patch to avoid calling
have_burn_uri() for the desktop window. Is this OK to commit?
Federico
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/nautilus/ChangeLog,v
retrieving revision 1.6828
diff -u -p -r1.6828 ChangeLog
--- ChangeLog 13 Mar 2006 10:51:17 -0000 1.6828
+++ ChangeLog 15 Mar 2006 04:41:20 -0000
@@ -1,3 +1,31 @@
+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.
+
2006-03-13 Alexander Larsson <alexl redhat com>
* configure.in:
Index: src/nautilus-window-menus.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-window-menus.c,v
retrieving revision 1.293
diff -u -p -r1.293 nautilus-window-menus.c
--- src/nautilus-window-menus.c 15 Dec 2005 14:25:58 -0000 1.293
+++ src/nautilus-window-menus.c 15 Mar 2006 04:41:21 -0000
@@ -744,12 +744,23 @@ 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 *
Index: src/nautilus-window-private.h
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-window-private.h,v
retrieving revision 1.112
diff -u -p -r1.112 nautilus-window-private.h
--- src/nautilus-window-private.h 3 Mar 2006 13:42:24 -0000 1.112
+++ src/nautilus-window-private.h 15 Mar 2006 04:41:21 -0000
@@ -176,6 +176,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,
Index: src/nautilus-window.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-window.c,v
retrieving revision 1.461
diff -u -p -r1.461 nautilus-window.c
--- src/nautilus-window.c 27 Feb 2006 15:51:47 -0000 1.461
+++ src/nautilus-window.c 15 Mar 2006 04:41:21 -0000
@@ -159,7 +159,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),
@@ -642,6 +641,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)
{
@@ -1532,8 +1550,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;
@@ -1602,4 +1621,20 @@ nautilus_window_class_init (NautilusWind
"\n"
" widget \"*.nautilus-extra-view-widget\" style:rc \"nautilus-extra-view-widgets-style-internal\" \n"
"\n");
+}
+
+/**
+ * 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);
}
Index: src/nautilus-window.h
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-window.h,v
retrieving revision 1.125
diff -u -p -r1.125 nautilus-window.h
--- src/nautilus-window.h 27 Feb 2006 15:51:47 -0000 1.125
+++ src/nautilus-window.h 15 Mar 2006 04:41:21 -0000
@@ -150,5 +150,6 @@ void nautilus_window_allow_b
GtkUIManager * nautilus_window_get_ui_manager (NautilusWindow *window);
void nautilus_window_add_extra_location_widget (NautilusWindow *window,
GtkWidget *widget);
+gboolean nautilus_window_has_menubar_and_statusbar (NautilusWindow *window);
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]