Commit 6685dd8a authored by Martin Pitt's avatar Martin Pitt Committed by Philippe Rouquier

Speed up nautilus extension startup

Do not call brasero_*_start() at nautilus startup, they are very expensive (on
my system it takes 3.1 seconds with a cold cache). Instead, call those lazily
when needed. Now it starts up in less than 0.3 seconds.

https://bugzilla.gnome.org/show_bug.cgi?id=604084
parent 6be10eec
......@@ -104,6 +104,29 @@ static GObjectClass *parent_class;
//#define DEBUG_PRINT(format_MACRO,...) g_print (format_MACRO, ##__VA_ARGS__);
#define DEBUG_PRINT(format_MACRO,...)
/* do not call brasero_*_start() at nautilus startup, they are very expensive;
* lazily initialize those instead */
static void
ensure_initialized()
{
static gboolean initialized = FALSE;
GConfClient *client;
if (!initialized) {
client = gconf_client_get_default ();
if (gconf_client_get_bool (client, "/apps/brasero/nautilus-extension-debug", NULL)) {
brasero_media_library_set_debug (TRUE);
brasero_burn_library_set_debug (TRUE);
}
g_object_unref (client);
brasero_media_library_start ();
brasero_burn_library_start (NULL, NULL);
DEBUG_PRINT ("Libbrasero-media started\n");
initialized = TRUE;
}
}
static void
launch_brasero_on_window_session (BraseroSessionCfg *session,
......@@ -313,6 +336,8 @@ write_iso_activate_cb (NautilusMenuItem *item,
NautilusFileInfo *file_info;
char *uri;
ensure_initialized();
file_info = g_object_get_data (G_OBJECT (item), "file_info");
uri = nautilus_file_info_get_uri (file_info);
......@@ -335,6 +360,8 @@ copy_disc_activate_cb (NautilusMenuItem *item,
BraseroTrackDisc *track;
BraseroDrive *drive;
ensure_initialized();
device_path = g_object_get_data (G_OBJECT (item), "drive_device_path");
monitor = brasero_medium_monitor_get_default ();
drive = brasero_medium_monitor_get_drive (monitor, device_path);
......@@ -392,6 +419,8 @@ blank_disc_activate_cb (NautilusMenuItem *item,
{
BraseroBlankDialog *dialog;
ensure_initialized();
dialog = brasero_blank_dialog_new ();
tool_dialog_run (BRASERO_TOOL_DIALOG (dialog),
GTK_WINDOW (user_data),
......@@ -591,6 +620,8 @@ nautilus_disc_burn_get_file_items (NautilusMenuProvider *provider,
BraseroMedia media;
BraseroTrackType *type;
ensure_initialized();
device_path = g_volume_get_identifier (volume, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
monitor = brasero_medium_monitor_get_default ();
bdrive = brasero_medium_monitor_get_drive (monitor, device_path);
......@@ -985,22 +1016,7 @@ nautilus_disc_burn_register_type (GTypeModule *module)
void
nautilus_module_initialize (GTypeModule *module)
{
GConfClient *client;
DEBUG_PRINT ("Initializing nautilus-disc-recorder\n");
client = gconf_client_get_default ();
if (gconf_client_get_bool (client, "/apps/brasero/nautilus-extension-debug", NULL)) {
brasero_media_library_set_debug (TRUE);
brasero_burn_library_set_debug (TRUE);
}
g_object_unref (client);
brasero_media_library_start ();
brasero_burn_library_start (NULL, NULL);
DEBUG_PRINT ("Libbrasero-media started\n");
nautilus_disc_burn_register_type (module);
}
......
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