forked from AuroraMiddleware/gtk
Avoid delays in starting applications
Only query file info once, and don't do it for non-native files, since that may cause sync network IO. Bug http://bugzilla.gnome.org/show_bug.cgi?id=635588
This commit is contained in:
parent
289ad41bd1
commit
b0bf2b5202
@ -36,23 +36,14 @@
|
||||
#include <unistd.h>
|
||||
|
||||
static char *
|
||||
get_display_name (GFile *file)
|
||||
get_display_name (GFile *file,
|
||||
GFileInfo *info)
|
||||
{
|
||||
GFileInfo *info;
|
||||
char *name, *tmp;
|
||||
|
||||
/* This does sync I/O, which isn't ideal.
|
||||
* It should probably use the NautilusFile machinery
|
||||
*/
|
||||
|
||||
name = NULL;
|
||||
info = g_file_query_info (file,
|
||||
G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME, 0, NULL, NULL);
|
||||
if (info)
|
||||
{
|
||||
name = g_strdup (g_file_info_get_display_name (info));
|
||||
g_object_unref (info);
|
||||
}
|
||||
|
||||
if (name == NULL)
|
||||
{
|
||||
@ -61,8 +52,7 @@ get_display_name (GFile *file)
|
||||
{
|
||||
tmp = name;
|
||||
name =
|
||||
g_uri_escape_string (name, G_URI_RESERVED_CHARS_ALLOWED_IN_PATH,
|
||||
TRUE);
|
||||
g_uri_escape_string (name, G_URI_RESERVED_CHARS_ALLOWED_IN_PATH, TRUE);
|
||||
g_free (tmp);
|
||||
}
|
||||
}
|
||||
@ -71,19 +61,18 @@ get_display_name (GFile *file)
|
||||
}
|
||||
|
||||
static GIcon *
|
||||
get_icon (GFile *file)
|
||||
get_icon (GFile *file,
|
||||
GFileInfo *info)
|
||||
{
|
||||
GFileInfo *info;
|
||||
GIcon *icon;
|
||||
|
||||
icon = NULL;
|
||||
info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_ICON, 0, NULL, NULL);
|
||||
|
||||
if (info)
|
||||
{
|
||||
icon = g_file_info_get_icon (info);
|
||||
if (icon)
|
||||
g_object_ref (icon);
|
||||
g_object_unref (info);
|
||||
}
|
||||
|
||||
return icon;
|
||||
@ -288,6 +277,7 @@ _gdk_windowing_get_startup_notify_id (GAppLaunchContext *context,
|
||||
GIcon *icon;
|
||||
guint32 timestamp;
|
||||
char *startup_id;
|
||||
GFileInfo *fileinfo;
|
||||
|
||||
priv = GDK_APP_LAUNCH_CONTEXT (context)->priv;
|
||||
|
||||
@ -307,12 +297,24 @@ _gdk_windowing_get_startup_notify_id (GAppLaunchContext *context,
|
||||
screen = gdk_display_get_default_screen (display);
|
||||
}
|
||||
|
||||
fileinfo = NULL;
|
||||
|
||||
files_count = g_list_length (files);
|
||||
if (files_count == 0)
|
||||
{
|
||||
description = g_strdup_printf (_("Starting %s"), g_app_info_get_name (info));
|
||||
}
|
||||
else if (files_count == 1)
|
||||
{
|
||||
gchar *display_name = get_display_name (files->data);
|
||||
gchar *display_name;
|
||||
|
||||
if (g_file_is_native (files->data))
|
||||
fileinfo = g_file_query_info (files->data,
|
||||
G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME ","
|
||||
G_FILE_ATTRIBUTE_STANDARD_ICON,
|
||||
0, NULL, NULL);
|
||||
|
||||
display_name = get_display_name (files->data, fileinfo);
|
||||
description = g_strdup_printf (_("Opening %s"), display_name);
|
||||
g_free (display_name);
|
||||
}
|
||||
@ -332,7 +334,7 @@ _gdk_windowing_get_startup_notify_id (GAppLaunchContext *context,
|
||||
if (priv->icon != NULL)
|
||||
icon = g_object_ref (priv->icon);
|
||||
else if (files_count == 1)
|
||||
icon = get_icon (files->data);
|
||||
icon = get_icon (files->data, fileinfo);
|
||||
|
||||
if (icon == NULL)
|
||||
{
|
||||
@ -371,7 +373,6 @@ _gdk_windowing_get_startup_notify_id (GAppLaunchContext *context,
|
||||
sequence++,
|
||||
(unsigned long)timestamp);
|
||||
|
||||
|
||||
gdk_x11_display_broadcast_startup_message (display, "new",
|
||||
"ID", startup_id,
|
||||
"NAME", g_app_info_get_name (info),
|
||||
@ -388,6 +389,8 @@ _gdk_windowing_get_startup_notify_id (GAppLaunchContext *context,
|
||||
g_free (screen_str);
|
||||
g_free (workspace_str);
|
||||
g_free (icon_name);
|
||||
if (fileinfo)
|
||||
g_object_unref (fileinfo);
|
||||
|
||||
add_startup_timeout (screen, startup_id);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user