mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-24 14:36:13 +01:00
Add g_app_info_supports_files() Remove desktop arg from
2008-01-04 Alexander Larsson <alexl@redhat.com> * gappinfo.[ch]: * gwin32appinfo.c: * gio.symbols: Add g_app_info_supports_files() Remove desktop arg from g_app_info_should_show(). * gdesktopappinfo.[ch]: Implement g_app_info_supports_files() and new should_show() Add g_desktop_app_info_set_desktop_env() to set the desktop for should_show(). (This will be set by gtk+ later) svn path=/trunk/; revision=6242
This commit is contained in:
parent
ce50248037
commit
8af463f939
@ -1,3 +1,16 @@
|
||||
2008-01-04 Alexander Larsson <alexl@redhat.com>
|
||||
|
||||
* gappinfo.[ch]:
|
||||
* gwin32appinfo.c:
|
||||
* gio.symbols:
|
||||
Add g_app_info_supports_files()
|
||||
Remove desktop arg from g_app_info_should_show().
|
||||
|
||||
* gdesktopappinfo.[ch]:
|
||||
Implement g_app_info_supports_files() and new should_show()
|
||||
Add g_desktop_app_info_set_desktop_env() to set the desktop
|
||||
for should_show(). (This will be set by gtk+ later)
|
||||
|
||||
2008-01-04 Alexander Larsson <alexl@redhat.com>
|
||||
|
||||
* gio.symbols:
|
||||
|
@ -445,6 +445,27 @@ g_app_info_supports_uris (GAppInfo *appinfo)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* g_app_info_supports_files:
|
||||
* @appinfo: a #GAppInfo.
|
||||
*
|
||||
* Checks if the application accepts files as arguments.
|
||||
*
|
||||
* Returns: %TRUE if the @appinfo supports files.
|
||||
**/
|
||||
gboolean
|
||||
g_app_info_supports_files (GAppInfo *appinfo)
|
||||
{
|
||||
GAppInfoIface *iface;
|
||||
|
||||
g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE);
|
||||
|
||||
iface = G_APP_INFO_GET_IFACE (appinfo);
|
||||
|
||||
return (* iface->supports_files) (appinfo);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* g_app_info_launch_uris:
|
||||
* @appinfo: a #GAppInfo.
|
||||
@ -484,20 +505,14 @@ g_app_info_launch_uris (GAppInfo *appinfo,
|
||||
/**
|
||||
* g_app_info_should_show:
|
||||
* @appinfo: a #GAppInfo.
|
||||
* @desktop_env: A string specifying what desktop this is, or %NULL.
|
||||
*
|
||||
* Checks if the application info should be shown when listing
|
||||
* applications available.
|
||||
*
|
||||
* @destkop_env is used to hide applications that are specified to
|
||||
* just show up in specific desktops. For instance, passing in "GNOME"
|
||||
* would show all applications specific to the Gnome desktop.
|
||||
* Checks if the application info should be shown in menus that
|
||||
* list available applications.
|
||||
*
|
||||
* Returns: %TRUE if the @appinfo should be shown, %FALSE otherwise.
|
||||
**/
|
||||
gboolean
|
||||
g_app_info_should_show (GAppInfo *appinfo,
|
||||
const char *desktop_env)
|
||||
g_app_info_should_show (GAppInfo *appinfo)
|
||||
{
|
||||
GAppInfoIface *iface;
|
||||
|
||||
@ -505,7 +520,7 @@ g_app_info_should_show (GAppInfo *appinfo,
|
||||
|
||||
iface = G_APP_INFO_GET_IFACE (appinfo);
|
||||
|
||||
return (* iface->should_show) (appinfo, desktop_env);
|
||||
return (* iface->should_show) (appinfo);
|
||||
}
|
||||
|
||||
G_DEFINE_TYPE (GAppLaunchContext, g_app_launch_context, G_TYPE_OBJECT);
|
||||
|
@ -80,6 +80,7 @@ typedef struct _GAppInfo GAppInfo; /* Dummy typedef */
|
||||
* @get_icon: Gets the #GIcon for the #GAppInfo.
|
||||
* @launch: Launches an application specified by the #GAppInfo.
|
||||
* @supports_uris: Indicates whether the application specified supports launching URIs.
|
||||
* @supports_files: Indicates whether the application specified accepts filename arguments.
|
||||
* @launch_uris: Launches an application with a list of URIs.
|
||||
* @should_show: Returns whether an application should be shown (e.g. when getting a list of installed applications).
|
||||
* <ulink url="http://standards.freedesktop.org/startup-notification-spec/startup-notification-latest.txt">
|
||||
@ -113,12 +114,12 @@ struct _GAppInfoIface
|
||||
GAppLaunchContext *launch_context,
|
||||
GError **error);
|
||||
gboolean (*supports_uris) (GAppInfo *appinfo);
|
||||
gboolean (*supports_files) (GAppInfo *appinfo);
|
||||
gboolean (*launch_uris) (GAppInfo *appinfo,
|
||||
GList *uris,
|
||||
GAppLaunchContext *launch_context,
|
||||
GError **error);
|
||||
gboolean (*should_show) (GAppInfo *appinfo,
|
||||
const char *desktop_env);
|
||||
gboolean (*should_show) (GAppInfo *appinfo);
|
||||
|
||||
/* For changing associations */
|
||||
gboolean (*set_as_default_for_type) (GAppInfo *appinfo,
|
||||
@ -156,12 +157,12 @@ gboolean g_app_info_launch (GAppInfo *appin
|
||||
GAppLaunchContext *launch_context,
|
||||
GError **error);
|
||||
gboolean g_app_info_supports_uris (GAppInfo *appinfo);
|
||||
gboolean g_app_info_supports_files (GAppInfo *appinfo);
|
||||
gboolean g_app_info_launch_uris (GAppInfo *appinfo,
|
||||
GList *uris,
|
||||
GAppLaunchContext *launch_context,
|
||||
GError **error);
|
||||
gboolean g_app_info_should_show (GAppInfo *appinfo,
|
||||
const char *desktop_env);
|
||||
gboolean g_app_info_should_show (GAppInfo *appinfo);
|
||||
|
||||
gboolean g_app_info_set_as_default_for_type (GAppInfo *appinfo,
|
||||
const char *content_type,
|
||||
|
@ -950,6 +950,16 @@ g_desktop_app_info_supports_uris (GAppInfo *appinfo)
|
||||
(strstr (info->exec, "%U") != NULL));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
g_desktop_app_info_supports_files (GAppInfo *appinfo)
|
||||
{
|
||||
GDesktopAppInfo *info = G_DESKTOP_APP_INFO (appinfo);
|
||||
|
||||
return info->exec &&
|
||||
((strstr (info->exec, "%f") != NULL) ||
|
||||
(strstr (info->exec, "%F") != NULL));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
g_desktop_app_info_launch_uris (GAppInfo *appinfo,
|
||||
GList *uris,
|
||||
@ -981,17 +991,54 @@ g_desktop_app_info_launch_uris (GAppInfo *appinfo,
|
||||
return res;
|
||||
}
|
||||
|
||||
G_LOCK_DEFINE_STATIC (g_desktop_env);
|
||||
static gchar *g_desktop_env = NULL;
|
||||
|
||||
/**
|
||||
* g_desktop_app_info_set_desktop_env:
|
||||
* @desktop_env: a string specifying what desktop this is
|
||||
*
|
||||
* Sets the name of the desktop that the application is running in.
|
||||
* This is used by g_app_info_should_show() to evaluate the
|
||||
* <literal>OnlyShowIn</literal> and <literal>NotShowIn</literal>
|
||||
* desktop entry fields.
|
||||
*
|
||||
* The <ulink url="http://standards.freedesktop.org/menu-spec/latest/">Desktop
|
||||
* Menu specification</ulink> recognizes the following:
|
||||
* <simplelist>
|
||||
* <member>GNOME</member>
|
||||
* <member>KDE</member>
|
||||
* <member>ROX</member>
|
||||
* <member>XFCE</member>
|
||||
* <member>Old</member>
|
||||
* </simplelist>
|
||||
*
|
||||
* Should be called only once; subsequent calls are ignored.
|
||||
*/
|
||||
void
|
||||
g_desktop_app_info_set_desktop_env (const gchar *desktop_env)
|
||||
{
|
||||
G_LOCK (g_desktop_env);
|
||||
if (!g_desktop_env)
|
||||
g_desktop_env = g_strdup (desktop_env);
|
||||
G_UNLOCK (g_desktop_env);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
g_desktop_app_info_should_show (GAppInfo *appinfo,
|
||||
const char *desktop_env)
|
||||
g_desktop_app_info_should_show (GAppInfo *appinfo)
|
||||
{
|
||||
GDesktopAppInfo *info = G_DESKTOP_APP_INFO (appinfo);
|
||||
gboolean found;
|
||||
const gchar *desktop_env;
|
||||
int i;
|
||||
|
||||
if (info->nodisplay)
|
||||
return FALSE;
|
||||
|
||||
G_LOCK (g_desktop_env);
|
||||
desktop_env = g_desktop_env;
|
||||
G_UNLOCK (g_desktop_env);
|
||||
|
||||
if (info->only_show_in)
|
||||
{
|
||||
if (desktop_env == NULL)
|
||||
@ -1495,6 +1542,7 @@ g_desktop_app_info_iface_init (GAppInfoIface *iface)
|
||||
iface->get_icon = g_desktop_app_info_get_icon;
|
||||
iface->launch = g_desktop_app_info_launch;
|
||||
iface->supports_uris = g_desktop_app_info_supports_uris;
|
||||
iface->supports_files = g_desktop_app_info_supports_files;
|
||||
iface->launch_uris = g_desktop_app_info_launch_uris;
|
||||
iface->should_show = g_desktop_app_info_should_show;
|
||||
iface->set_as_default_for_type = g_desktop_app_info_set_as_default_for_type;
|
||||
@ -1648,21 +1696,14 @@ get_apps_from_dir (GHashTable *apps,
|
||||
{
|
||||
appinfo = g_desktop_app_info_new_from_filename (filename);
|
||||
|
||||
/* Don't return apps that don't take arguments */
|
||||
if (appinfo &&
|
||||
(g_desktop_app_info_get_is_hidden (appinfo) ||
|
||||
(appinfo->exec &&
|
||||
strstr (appinfo->exec,"%U") == NULL &&
|
||||
strstr (appinfo->exec,"%u") == NULL &&
|
||||
strstr (appinfo->exec,"%f") == NULL &&
|
||||
strstr (appinfo->exec,"%F") == NULL)))
|
||||
if (appinfo && g_desktop_app_info_get_is_hidden (appinfo))
|
||||
{
|
||||
g_object_unref (appinfo);
|
||||
appinfo = NULL;
|
||||
hidden = TRUE;
|
||||
}
|
||||
|
||||
if (appinfo != NULL || hidden)
|
||||
if (appinfo || hidden)
|
||||
{
|
||||
g_hash_table_insert (apps, g_strdup (desktop_id), appinfo);
|
||||
|
||||
@ -1695,7 +1736,15 @@ get_apps_from_dir (GHashTable *apps,
|
||||
/**
|
||||
* g_app_info_get_all:
|
||||
*
|
||||
* Gets a list of all of the applications currently registered on this system.
|
||||
* Gets a list of all of the applications currently registered
|
||||
* on this system.
|
||||
*
|
||||
* For desktop files, this includes applications that have
|
||||
* <literal>NoDisplay=true</liberal> set or are excluded from
|
||||
* display by means of <literal>OnlyShowIn</literal> or
|
||||
* <literal>NotShowIn</literal>. See g_app_info_should_show().
|
||||
* The returned list does not include applications which have
|
||||
* the <literal>Hidden</literal> key set.
|
||||
*
|
||||
* Returns: a newly allocated #GList of references to #GAppInfo<!---->s.
|
||||
**/
|
||||
|
@ -48,6 +48,8 @@ GDesktopAppInfo *g_desktop_app_info_new_from_filename (const char *filename
|
||||
GDesktopAppInfo *g_desktop_app_info_new (const char *desktop_id);
|
||||
gboolean g_desktop_app_info_get_is_hidden (GDesktopAppInfo *info);
|
||||
|
||||
void g_desktop_app_info_set_desktop_env (const char *desktop_env);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
|
@ -38,6 +38,7 @@ g_app_info_get_executable
|
||||
g_app_info_get_icon
|
||||
g_app_info_launch
|
||||
g_app_info_supports_uris
|
||||
g_app_info_supports_files
|
||||
g_app_info_launch_uris
|
||||
g_app_info_should_show
|
||||
g_app_info_set_as_default_for_type
|
||||
|
@ -332,6 +332,12 @@ g_win32_app_info_supports_uris (GAppInfo *appinfo)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
g_win32_app_info_supports_files (GAppInfo *appinfo)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
g_win32_app_info_launch_uris (GAppInfo *appinfo,
|
||||
GList *uris,
|
||||
@ -345,8 +351,7 @@ g_win32_app_info_launch_uris (GAppInfo *appinfo,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
g_win32_app_info_should_show (GAppInfo *appinfo,
|
||||
const char *win32_env)
|
||||
g_win32_app_info_should_show (GAppInfo *appinfo)
|
||||
{
|
||||
GWin32AppInfo *info = G_WIN32_APP_INFO (appinfo);
|
||||
|
||||
@ -392,6 +397,7 @@ g_win32_app_info_iface_init (GAppInfoIface *iface)
|
||||
iface->get_icon = g_win32_app_info_get_icon;
|
||||
iface->launch = g_win32_app_info_launch;
|
||||
iface->supports_uris = g_win32_app_info_supports_uris;
|
||||
iface->supports_files = g_win32_app_info_supports_files;
|
||||
iface->launch_uris = g_win32_app_info_launch_uris;
|
||||
iface->should_show = g_win32_app_info_should_show;
|
||||
iface->set_as_default_for_type = g_win32_app_info_set_as_default_for_type;
|
||||
|
Loading…
Reference in New Issue
Block a user