GtkRecentManager: Formatting fixes

This commit is contained in:
Matthias Clasen 2014-12-22 17:16:30 -05:00
parent ea9f5e2273
commit 0a54ad1187

View File

@ -108,13 +108,13 @@
#include "gtkmarshalers.h" #include "gtkmarshalers.h"
/* the file where we store the recently used items */ /* the file where we store the recently used items */
#define GTK_RECENTLY_USED_FILE "recently-used.xbel" #define GTK_RECENTLY_USED_FILE "recently-used.xbel"
/* return all items by default */ /* return all items by default */
#define DEFAULT_LIMIT -1 #define DEFAULT_LIMIT -1
/* keep in sync with xdgmime */ /* keep in sync with xdgmime */
#define GTK_RECENT_DEFAULT_MIME "application/octet-stream" #define GTK_RECENT_DEFAULT_MIME "application/octet-stream"
typedef struct typedef struct
{ {
@ -190,13 +190,13 @@ enum
static void gtk_recent_manager_dispose (GObject *object); static void gtk_recent_manager_dispose (GObject *object);
static void gtk_recent_manager_finalize (GObject *object); static void gtk_recent_manager_finalize (GObject *object);
static void gtk_recent_manager_set_property (GObject *object, static void gtk_recent_manager_set_property (GObject *object,
guint prop_id, guint prop_id,
const GValue *value, const GValue *value,
GParamSpec *pspec); GParamSpec *pspec);
static void gtk_recent_manager_get_property (GObject *object, static void gtk_recent_manager_get_property (GObject *object,
guint prop_id, guint prop_id,
GValue *value, GValue *value,
GParamSpec *pspec); GParamSpec *pspec);
static void gtk_recent_manager_add_item_query_info (GObject *source_object, static void gtk_recent_manager_add_item_query_info (GObject *source_object,
GAsyncResult *res, GAsyncResult *res,
gpointer user_data); gpointer user_data);
@ -214,9 +214,9 @@ static void gtk_recent_manager_clamp_to_age (GtkRecentManager *manag
static void gtk_recent_manager_enabled_changed (GtkRecentManager *manager); static void gtk_recent_manager_enabled_changed (GtkRecentManager *manager);
static void build_recent_items_list (GtkRecentManager *manager); static void build_recent_items_list (GtkRecentManager *manager);
static void purge_recent_items_list (GtkRecentManager *manager, static void purge_recent_items_list (GtkRecentManager *manager,
GError **error); GError **error);
static RecentAppInfo *recent_app_info_new (const gchar *app_name); static RecentAppInfo *recent_app_info_new (const gchar *app_name);
static void recent_app_info_free (RecentAppInfo *app_info); static void recent_app_info_free (RecentAppInfo *app_info);
@ -242,7 +242,8 @@ filename_warning (const gchar *format,
/* Test of haystack has the needle prefix, comparing case /* Test of haystack has the needle prefix, comparing case
* insensitive. haystack may be UTF-8, but needle must * insensitive. haystack may be UTF-8, but needle must
* contain only lowercase ascii. */ * contain only lowercase ascii.
*/
static gboolean static gboolean
has_case_prefix (const gchar *haystack, has_case_prefix (const gchar *haystack,
const gchar *needle) const gchar *needle)
@ -281,18 +282,18 @@ gtk_recent_manager_class_init (GtkRecentManagerClass *klass)
/** /**
* GtkRecentManager:filename: * GtkRecentManager:filename:
* *
* The full path to the file to be used to store and read the recently * The full path to the file to be used to store and read the
* used resources list * recently used resources list
* *
* Since: 2.10 * Since: 2.10
*/ */
g_object_class_install_property (gobject_class, g_object_class_install_property (gobject_class,
PROP_FILENAME, PROP_FILENAME,
g_param_spec_string ("filename", g_param_spec_string ("filename",
P_("Filename"), P_("Filename"),
P_("The full path to the file to be used to store and read the list"), P_("The full path to the file to be used to store and read the list"),
NULL, NULL,
(G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE))); (G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE)));
/** /**
* GtkRecentManager:size: * GtkRecentManager:size:
@ -302,33 +303,33 @@ gtk_recent_manager_class_init (GtkRecentManagerClass *klass)
* Since: 2.10 * Since: 2.10
*/ */
g_object_class_install_property (gobject_class, g_object_class_install_property (gobject_class,
PROP_SIZE, PROP_SIZE,
g_param_spec_int ("size", g_param_spec_int ("size",
P_("Size"), P_("Size"),
P_("The size of the recently used resources list"), P_("The size of the recently used resources list"),
-1, -1,
G_MAXINT, G_MAXINT,
0, 0,
G_PARAM_READABLE)); G_PARAM_READABLE));
/** /**
* GtkRecentManager::changed: * GtkRecentManager::changed:
* @recent_manager: the recent manager * @recent_manager: the recent manager
* *
* Emitted when the current recently used resources manager changes its * Emitted when the current recently used resources manager changes
* contents, either by calling gtk_recent_manager_add_item() or by another * its contents, either by calling gtk_recent_manager_add_item() or
* application. * by another application.
* *
* Since: 2.10 * Since: 2.10
*/ */
signal_changed = signal_changed =
g_signal_new (I_("changed"), g_signal_new (I_("changed"),
G_TYPE_FROM_CLASS (klass), G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST, G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkRecentManagerClass, changed), G_STRUCT_OFFSET (GtkRecentManagerClass, changed),
NULL, NULL, NULL, NULL,
g_cclosure_marshal_VOID__VOID, g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0); G_TYPE_NONE, 0);
klass->changed = gtk_recent_manager_real_changed; klass->changed = gtk_recent_manager_real_changed;
} }
@ -352,10 +353,10 @@ gtk_recent_manager_init (GtkRecentManager *manager)
} }
static void static void
gtk_recent_manager_set_property (GObject *object, gtk_recent_manager_set_property (GObject *object,
guint prop_id, guint prop_id,
const GValue *value, const GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
GtkRecentManager *recent_manager = GTK_RECENT_MANAGER (object); GtkRecentManager *recent_manager = GTK_RECENT_MANAGER (object);
@ -371,10 +372,10 @@ gtk_recent_manager_set_property (GObject *object,
} }
static void static void
gtk_recent_manager_get_property (GObject *object, gtk_recent_manager_get_property (GObject *object,
guint prop_id, guint prop_id,
GValue *value, GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
GtkRecentManager *recent_manager = GTK_RECENT_MANAGER (object); GtkRecentManager *recent_manager = GTK_RECENT_MANAGER (object);
@ -465,8 +466,8 @@ gtk_recent_manager_real_changed (GtkRecentManager *manager)
* empty container, and dump it * empty container, and dump it
*/ */
priv->recent_items = g_bookmark_file_new (); priv->recent_items = g_bookmark_file_new ();
priv->size = 0; priv->size = 0;
} }
else else
{ {
GtkSettings *settings; GtkSettings *settings;
@ -504,7 +505,7 @@ gtk_recent_manager_real_changed (GtkRecentManager *manager)
priv->filename, priv->filename,
write_error->message); write_error->message);
g_error_free (write_error); g_error_free (write_error);
} }
if (g_chmod (priv->filename, 0600) < 0) if (g_chmod (priv->filename, 0600) < 0)
{ {
@ -577,7 +578,7 @@ get_default_filename (void)
static void static void
gtk_recent_manager_set_filename (GtkRecentManager *manager, gtk_recent_manager_set_filename (GtkRecentManager *manager,
const gchar *filename) const gchar *filename)
{ {
GtkRecentManagerPrivate *priv; GtkRecentManagerPrivate *priv;
GFile *file; GFile *file;
@ -589,8 +590,8 @@ gtk_recent_manager_set_filename (GtkRecentManager *manager,
/* if a filename is already set and filename is not NULL, then copy /* if a filename is already set and filename is not NULL, then copy
* it and reset the monitor; otherwise, if it's NULL we're being * it and reset the monitor; otherwise, if it's NULL we're being
* called from the finalization sequence, so we simply disconnect the * called from the finalization sequence, so we simply disconnect
* monitoring and return. * the monitoring and return.
* *
* if no filename is set and filename is NULL, use the default. * if no filename is set and filename is NULL, use the default.
*/ */
@ -668,7 +669,8 @@ build_recent_items_list (GtkRecentManager *manager)
{ {
/* the file exists, and it's valid (we hope); if not, destroy the container /* the file exists, and it's valid (we hope); if not, destroy the container
* object and hope for a better result when the next "changed" signal is * object and hope for a better result when the next "changed" signal is
* fired. */ * fired.
*/
read_error = NULL; read_error = NULL;
g_bookmark_file_load_from_file (priv->recent_items, priv->filename, &read_error); g_bookmark_file_load_from_file (priv->recent_items, priv->filename, &read_error);
if (read_error) if (read_error)
@ -714,15 +716,15 @@ build_recent_items_list (GtkRecentManager *manager)
/** /**
* gtk_recent_manager_new: * gtk_recent_manager_new:
* *
* Creates a new recent manager object. Recent manager objects are used to * Creates a new recent manager object. Recent manager objects are used to
* handle the list of recently used resources. A #GtkRecentManager object * handle the list of recently used resources. A #GtkRecentManager object
* monitors the recently used resources list, and emits the changed signal * monitors the recently used resources list, and emits the changed signal
* each time something inside the list changes. * each time something inside the list changes.
* *
* #GtkRecentManager objects are expensive: be sure to create them only when * #GtkRecentManager objects are expensive: be sure to create them only when
* needed. You should use gtk_recent_manager_get_default() instead. * needed. You should use gtk_recent_manager_get_default() instead.
* *
* Returns: A newly created #GtkRecentManager object. * Returns: A newly created #GtkRecentManager object
* *
* Since: 2.10 * Since: 2.10
*/ */
@ -738,7 +740,8 @@ gtk_recent_manager_new (void)
* Gets a unique instance of #GtkRecentManager, that you can share * Gets a unique instance of #GtkRecentManager, that you can share
* in your application without caring about memory management. * in your application without caring about memory management.
* *
* Returns: (transfer none): A unique #GtkRecentManager. Do not ref or unref it. * Returns: (transfer none): A unique #GtkRecentManager. Do not ref or
* unref it.
* *
* Since: 2.10 * Since: 2.10
*/ */
@ -799,7 +802,8 @@ gtk_recent_manager_add_item_query_info (GObject *source_object,
gdk_threads_enter (); gdk_threads_enter ();
/* Ignore return value, this can't fail anyway since all required /* Ignore return value, this can't fail anyway since all required
* fields are set */ * fields are set
*/
gtk_recent_manager_add_full (manager, uri, &recent_data); gtk_recent_manager_add_full (manager, uri, &recent_data);
manager->priv->is_dirty = TRUE; manager->priv->is_dirty = TRUE;
@ -824,8 +828,8 @@ gtk_recent_manager_add_item_query_info (GObject *source_object,
* resources list. * resources list.
* *
* This function automatically retrieves some of the needed * This function automatically retrieves some of the needed
* metadata and setting other metadata to common default values; it * metadata and setting other metadata to common default values;
* then feeds the data to gtk_recent_manager_add_full(). * it then feeds the data to gtk_recent_manager_add_full().
* *
* See gtk_recent_manager_add_full() if you want to explicitly * See gtk_recent_manager_add_full() if you want to explicitly
* define the metadata for the resource pointed by @uri. * define the metadata for the resource pointed by @uri.
@ -836,8 +840,8 @@ gtk_recent_manager_add_item_query_info (GObject *source_object,
* Since: 2.10 * Since: 2.10
*/ */
gboolean gboolean
gtk_recent_manager_add_item (GtkRecentManager *manager, gtk_recent_manager_add_item (GtkRecentManager *manager,
const gchar *uri) const gchar *uri)
{ {
GFile* file; GFile* file;
@ -866,8 +870,8 @@ gtk_recent_manager_add_item (GtkRecentManager *manager,
* @recent_data: metadata of the resource * @recent_data: metadata of the resource
* *
* Adds a new resource, pointed by @uri, into the recently used * Adds a new resource, pointed by @uri, into the recently used
* resources list, using the metadata specified inside the #GtkRecentData-struct * resources list, using the metadata specified inside the
* passed in @recent_data. * #GtkRecentData-struct passed in @recent_data.
* *
* The passed URI will be used to identify this resource inside the * The passed URI will be used to identify this resource inside the
* list. * list.
@ -880,20 +884,20 @@ gtk_recent_manager_add_item (GtkRecentManager *manager,
* launching the item. * launching the item.
* *
* Optionally, a #GtkRecentData-struct might contain a UTF-8 string * Optionally, a #GtkRecentData-struct might contain a UTF-8 string
* to be used when viewing the item instead of the last component of the * to be used when viewing the item instead of the last component of
* URI; a short description of the item; whether the item should be * the URI; a short description of the item; whether the item should
* considered private - that is, should be displayed only by the * be considered private - that is, should be displayed only by the
* applications that have registered it. * applications that have registered it.
* *
* Returns: %TRUE if the new item was successfully added to the * Returns: %TRUE if the new item was successfully added to the
* recently used resources list, %FALSE otherwise. * recently used resources list, %FALSE otherwise
* *
* Since: 2.10 * Since: 2.10
*/ */
gboolean gboolean
gtk_recent_manager_add_full (GtkRecentManager *manager, gtk_recent_manager_add_full (GtkRecentManager *manager,
const gchar *uri, const gchar *uri,
const GtkRecentData *data) const GtkRecentData *data)
{ {
GtkRecentManagerPrivate *priv; GtkRecentManagerPrivate *priv;
GtkSettings *settings; GtkSettings *settings;
@ -908,9 +912,9 @@ gtk_recent_manager_add_full (GtkRecentManager *manager,
(!g_utf8_validate (data->display_name, -1, NULL))) (!g_utf8_validate (data->display_name, -1, NULL)))
{ {
g_warning ("Attempting to add `%s' to the list of recently used " g_warning ("Attempting to add `%s' to the list of recently used "
"resources, but the display name is not a valid UTF-8 " "resources, but the display name is not a valid UTF-8 "
"encoded string", "encoded string",
uri); uri);
return FALSE; return FALSE;
} }
@ -918,9 +922,9 @@ gtk_recent_manager_add_full (GtkRecentManager *manager,
(!g_utf8_validate (data->description, -1, NULL))) (!g_utf8_validate (data->description, -1, NULL)))
{ {
g_warning ("Attempting to add `%s' to the list of recently used " g_warning ("Attempting to add `%s' to the list of recently used "
"resources, but the description is not a valid UTF-8 " "resources, but the description is not a valid UTF-8 "
"encoded string", "encoded string",
uri); uri);
return FALSE; return FALSE;
} }
@ -928,26 +932,26 @@ gtk_recent_manager_add_full (GtkRecentManager *manager,
if (!data->mime_type) if (!data->mime_type)
{ {
g_warning ("Attempting to add `%s' to the list of recently used " g_warning ("Attempting to add `%s' to the list of recently used "
"resources, but no MIME type was defined", "resources, but no MIME type was defined",
uri); uri);
return FALSE; return FALSE;
} }
if (!data->app_name) if (!data->app_name)
{ {
g_warning ("Attempting to add `%s' to the list of recently used " g_warning ("Attempting to add `%s' to the list of recently used "
"resources, but no name of the application that is " "resources, but no name of the application that is "
"registering it was defined", "registering it was defined",
uri); uri);
return FALSE; return FALSE;
} }
if (!data->app_exec) if (!data->app_exec)
{ {
g_warning ("Attempting to add `%s' to the list of recently used " g_warning ("Attempting to add `%s' to the list of recently used "
"resources, but no command line for the application " "resources, but no command line for the application "
"that is registering it was defined", "that is registering it was defined",
uri); uri);
return FALSE; return FALSE;
} }
@ -985,11 +989,11 @@ gtk_recent_manager_add_full (GtkRecentManager *manager,
* already registered the same document inside the list * already registered the same document inside the list
*/ */
g_bookmark_file_add_application (priv->recent_items, uri, g_bookmark_file_add_application (priv->recent_items, uri,
data->app_name, data->app_name,
data->app_exec); data->app_exec);
g_bookmark_file_set_is_private (priv->recent_items, uri, g_bookmark_file_set_is_private (priv->recent_items, uri,
data->is_private); data->is_private);
/* mark us as dirty, so that when emitting the "changed" signal we /* mark us as dirty, so that when emitting the "changed" signal we
* will dump our changes * will dump our changes
@ -1010,14 +1014,14 @@ gtk_recent_manager_add_full (GtkRecentManager *manager,
* list handled by a recent manager. * list handled by a recent manager.
* *
* Returns: %TRUE if the item pointed by @uri has been successfully * Returns: %TRUE if the item pointed by @uri has been successfully
* removed by the recently used resources list, and %FALSE otherwise. * removed by the recently used resources list, and %FALSE otherwise
* *
* Since: 2.10 * Since: 2.10
*/ */
gboolean gboolean
gtk_recent_manager_remove_item (GtkRecentManager *manager, gtk_recent_manager_remove_item (GtkRecentManager *manager,
const gchar *uri, const gchar *uri,
GError **error) GError **error)
{ {
GtkRecentManagerPrivate *priv; GtkRecentManagerPrivate *priv;
GError *remove_error = NULL; GError *remove_error = NULL;
@ -1034,9 +1038,9 @@ gtk_recent_manager_remove_item (GtkRecentManager *manager,
priv->size = 0; priv->size = 0;
g_set_error (error, GTK_RECENT_MANAGER_ERROR, g_set_error (error, GTK_RECENT_MANAGER_ERROR,
GTK_RECENT_MANAGER_ERROR_NOT_FOUND, GTK_RECENT_MANAGER_ERROR_NOT_FOUND,
_("Unable to find an item with URI '%s'"), _("Unable to find an item with URI '%s'"),
uri); uri);
return FALSE; return FALSE;
} }
@ -1047,9 +1051,9 @@ gtk_recent_manager_remove_item (GtkRecentManager *manager,
g_error_free (remove_error); g_error_free (remove_error);
g_set_error (error, GTK_RECENT_MANAGER_ERROR, g_set_error (error, GTK_RECENT_MANAGER_ERROR,
GTK_RECENT_MANAGER_ERROR_NOT_FOUND, GTK_RECENT_MANAGER_ERROR_NOT_FOUND,
_("Unable to find an item with URI '%s'"), _("Unable to find an item with URI '%s'"),
uri); uri);
return FALSE; return FALSE;
} }
@ -1068,13 +1072,13 @@ gtk_recent_manager_remove_item (GtkRecentManager *manager,
* Checks whether there is a recently used resource registered * Checks whether there is a recently used resource registered
* with @uri inside the recent manager. * with @uri inside the recent manager.
* *
* Returns: %TRUE if the resource was found, %FALSE otherwise. * Returns: %TRUE if the resource was found, %FALSE otherwise
* *
* Since: 2.10 * Since: 2.10
*/ */
gboolean gboolean
gtk_recent_manager_has_item (GtkRecentManager *manager, gtk_recent_manager_has_item (GtkRecentManager *manager,
const gchar *uri) const gchar *uri)
{ {
GtkRecentManagerPrivate *priv; GtkRecentManagerPrivate *priv;
@ -1088,8 +1092,8 @@ gtk_recent_manager_has_item (GtkRecentManager *manager,
} }
static void static void
build_recent_info (GBookmarkFile *bookmarks, build_recent_info (GBookmarkFile *bookmarks,
GtkRecentInfo *info) GtkRecentInfo *info)
{ {
gchar **apps, **groups; gchar **apps, **groups;
gsize apps_len, groups_len, i; gsize apps_len, groups_len, i;
@ -1129,10 +1133,10 @@ build_recent_info (GBookmarkFile *bookmarks,
app_name = apps[i]; app_name = apps[i];
res = g_bookmark_file_get_app_info (bookmarks, info->uri, app_name, res = g_bookmark_file_get_app_info (bookmarks, info->uri, app_name,
&app_exec, &app_exec,
&count, &count,
&stamp, &stamp,
NULL); NULL);
if (!res) if (!res)
continue; continue;
@ -1160,15 +1164,15 @@ build_recent_info (GBookmarkFile *bookmarks,
* *
* Returns: a #GtkRecentInfo-struct containing information * Returns: a #GtkRecentInfo-struct containing information
* about the resource pointed by @uri, or %NULL if the URI was * about the resource pointed by @uri, or %NULL if the URI was
* not registered in the recently used resources list. Free with * not registered in the recently used resources list. Free with
* gtk_recent_info_unref(). * gtk_recent_info_unref().
* *
* Since: 2.10 * Since: 2.10
*/ */
GtkRecentInfo * GtkRecentInfo *
gtk_recent_manager_lookup_item (GtkRecentManager *manager, gtk_recent_manager_lookup_item (GtkRecentManager *manager,
const gchar *uri, const gchar *uri,
GError **error) GError **error)
{ {
GtkRecentManagerPrivate *priv; GtkRecentManagerPrivate *priv;
GtkRecentInfo *info = NULL; GtkRecentInfo *info = NULL;
@ -1184,9 +1188,9 @@ gtk_recent_manager_lookup_item (GtkRecentManager *manager,
priv->size = 0; priv->size = 0;
g_set_error (error, GTK_RECENT_MANAGER_ERROR, g_set_error (error, GTK_RECENT_MANAGER_ERROR,
GTK_RECENT_MANAGER_ERROR_NOT_FOUND, GTK_RECENT_MANAGER_ERROR_NOT_FOUND,
_("Unable to find an item with URI '%s'"), _("Unable to find an item with URI '%s'"),
uri); uri);
return NULL; return NULL;
} }
@ -1194,9 +1198,9 @@ gtk_recent_manager_lookup_item (GtkRecentManager *manager,
if (!g_bookmark_file_has_item (priv->recent_items, uri)) if (!g_bookmark_file_has_item (priv->recent_items, uri))
{ {
g_set_error (error, GTK_RECENT_MANAGER_ERROR, g_set_error (error, GTK_RECENT_MANAGER_ERROR,
GTK_RECENT_MANAGER_ERROR_NOT_FOUND, GTK_RECENT_MANAGER_ERROR_NOT_FOUND,
_("Unable to find an item with URI '%s'"), _("Unable to find an item with URI '%s'"),
uri); uri);
return NULL; return NULL;
} }
@ -1215,8 +1219,8 @@ gtk_recent_manager_lookup_item (GtkRecentManager *manager,
* gtk_recent_manager_move_item: * gtk_recent_manager_move_item:
* @manager: a #GtkRecentManager * @manager: a #GtkRecentManager
* @uri: the URI of a recently used resource * @uri: the URI of a recently used resource
* @new_uri: (allow-none): the new URI of the recently used resource, or %NULL to * @new_uri: (allow-none): the new URI of the recently used resource, or
* remove the item pointed by @uri in the list * %NULL to remove the item pointed by @uri in the list
* @error: (allow-none): a return location for a #GError, or %NULL * @error: (allow-none): a return location for a #GError, or %NULL
* *
* Changes the location of a recently used resource from @uri to @new_uri. * Changes the location of a recently used resource from @uri to @new_uri.
@ -1224,7 +1228,7 @@ gtk_recent_manager_lookup_item (GtkRecentManager *manager,
* Please note that this function will not affect the resource pointed * Please note that this function will not affect the resource pointed
* by the URIs, but only the URI used in the recently used resources list. * by the URIs, but only the URI used in the recently used resources list.
* *
* Returns: %TRUE on success. * Returns: %TRUE on success
* *
* Since: 2.10 * Since: 2.10
*/ */
@ -1288,7 +1292,7 @@ gtk_recent_manager_move_item (GtkRecentManager *recent_manager,
* *
* Gets the list of recently used resources. * Gets the list of recently used resources.
* *
* Returns: (element-type GtkRecentInfo) (transfer full): a list of * Returns: (element-type GtkRecentInfo) (transfer full): a list of
* newly allocated #GtkRecentInfo objects. Use * newly allocated #GtkRecentInfo objects. Use
* gtk_recent_info_unref() on each item inside the list, and then * gtk_recent_info_unref() on each item inside the list, and then
* free the list itself using g_list_free(). * free the list itself using g_list_free().
@ -1327,7 +1331,7 @@ gtk_recent_manager_get_items (GtkRecentManager *manager)
static void static void
purge_recent_items_list (GtkRecentManager *manager, purge_recent_items_list (GtkRecentManager *manager,
GError **error) GError **error)
{ {
GtkRecentManagerPrivate *priv = manager->priv; GtkRecentManagerPrivate *priv = manager->priv;
@ -1351,13 +1355,13 @@ purge_recent_items_list (GtkRecentManager *manager,
* Purges every item from the recently used resources list. * Purges every item from the recently used resources list.
* *
* Returns: the number of items that have been removed from the * Returns: the number of items that have been removed from the
* recently used resources list. * recently used resources list
* *
* Since: 2.10 * Since: 2.10
*/ */
gint gint
gtk_recent_manager_purge_items (GtkRecentManager *manager, gtk_recent_manager_purge_items (GtkRecentManager *manager,
GError **error) GError **error)
{ {
GtkRecentManagerPrivate *priv; GtkRecentManagerPrivate *priv;
gint count, purged; gint count, purged;
@ -1494,8 +1498,8 @@ gtk_recent_info_free (GtkRecentInfo *recent_info)
if (recent_info->applications) if (recent_info->applications)
{ {
g_slist_foreach (recent_info->applications, g_slist_foreach (recent_info->applications,
(GFunc) recent_app_info_free, (GFunc) recent_app_info_free,
NULL); NULL);
g_slist_free (recent_info->applications); g_slist_free (recent_info->applications);
recent_info->applications = NULL; recent_info->applications = NULL;
@ -1507,8 +1511,8 @@ gtk_recent_info_free (GtkRecentInfo *recent_info)
if (recent_info->groups) if (recent_info->groups)
{ {
g_slist_foreach (recent_info->groups, g_slist_foreach (recent_info->groups,
(GFunc) g_free, (GFunc) g_free,
NULL); NULL);
g_slist_free (recent_info->groups); g_slist_free (recent_info->groups);
recent_info->groups = NULL; recent_info->groups = NULL;
@ -1526,8 +1530,8 @@ gtk_recent_info_free (GtkRecentInfo *recent_info)
* *
* Increases the reference count of @recent_info by one. * Increases the reference count of @recent_info by one.
* *
* Returns: the recent info object with its reference count increased * Returns: the recent info object with its reference count
* by one. * increased by one
* *
* Since: 2.10 * Since: 2.10
*/ */
@ -1546,7 +1550,7 @@ gtk_recent_info_ref (GtkRecentInfo *info)
* gtk_recent_info_unref: * gtk_recent_info_unref:
* @info: a #GtkRecentInfo * @info: a #GtkRecentInfo
* *
* Decreases the reference count of @info by one. If the reference * Decreases the reference count of @info by one. If the reference
* count reaches zero, @info is deallocated, and the memory freed. * count reaches zero, @info is deallocated, and the memory freed.
* *
* Since: 2.10 * Since: 2.10
@ -1569,7 +1573,7 @@ gtk_recent_info_unref (GtkRecentInfo *info)
* *
* Gets the URI of the resource. * Gets the URI of the resource.
* *
* Returns: the URI of the resource. The returned string is * Returns: the URI of the resource. The returned string is
* owned by the recent manager, and should not be freed. * owned by the recent manager, and should not be freed.
* *
* Since: 2.10 * Since: 2.10
@ -1586,10 +1590,10 @@ gtk_recent_info_get_uri (GtkRecentInfo *info)
* gtk_recent_info_get_display_name: * gtk_recent_info_get_display_name:
* @info: a #GtkRecentInfo * @info: a #GtkRecentInfo
* *
* Gets the name of the resource. If none has been defined, the basename * Gets the name of the resource. If none has been defined, the basename
* of the resource is obtained. * of the resource is obtained.
* *
* Returns: the display name of the resource. The returned string * Returns: the display name of the resource. The returned string
* is owned by the recent manager, and should not be freed. * is owned by the recent manager, and should not be freed.
* *
* Since: 2.10 * Since: 2.10
@ -1611,7 +1615,7 @@ gtk_recent_info_get_display_name (GtkRecentInfo *info)
* *
* Gets the (short) description of the resource. * Gets the (short) description of the resource.
* *
* Returns: the description of the resource. The returned string * Returns: the description of the resource. The returned string
* is owned by the recent manager, and should not be freed. * is owned by the recent manager, and should not be freed.
* *
* Since: 2.10 * Since: 2.10
@ -1630,7 +1634,7 @@ gtk_recent_info_get_description (GtkRecentInfo *info)
* *
* Gets the MIME type of the resource. * Gets the MIME type of the resource.
* *
* Returns: the MIME type of the resource. The returned string * Returns: the MIME type of the resource. The returned string
* is owned by the recent manager, and should not be freed. * is owned by the recent manager, and should not be freed.
* *
* Since: 2.10 * Since: 2.10
@ -1710,11 +1714,11 @@ gtk_recent_info_get_visited (GtkRecentInfo *info)
* gtk_recent_info_get_private_hint: * gtk_recent_info_get_private_hint:
* @info: a #GtkRecentInfo * @info: a #GtkRecentInfo
* *
* Gets the value of the private flag. Resources in the recently used * Gets the value of the private flag. Resources in the recently used
* list that have this flag set to %TRUE should only be displayed by the * list that have this flag set to %TRUE should only be displayed by the
* applications that have registered them. * applications that have registered them.
* *
* Returns: %TRUE if the private flag was found, %FALSE otherwise. * Returns: %TRUE if the private flag was found, %FALSE otherwise
* *
* Since: 2.10 * Since: 2.10
*/ */
@ -1759,7 +1763,8 @@ recent_app_info_free (RecentAppInfo *app_info)
* gtk_recent_info_get_application_info: * gtk_recent_info_get_application_info:
* @info: a #GtkRecentInfo * @info: a #GtkRecentInfo
* @app_name: the name of the application that has registered this item * @app_name: the name of the application that has registered this item
* @app_exec: (transfer none) (out): return location for the string containing the command line * @app_exec: (transfer none) (out): return location for the string containing
* the command line
* @count: (out): return location for the number of times this item was registered * @count: (out): return location for the number of times this item was registered
* @time_: (out): return location for the timestamp this item was last registered * @time_: (out): return location for the timestamp this item was last registered
* for this application * for this application
@ -1779,10 +1784,10 @@ recent_app_info_free (RecentAppInfo *app_info)
*/ */
gboolean gboolean
gtk_recent_info_get_application_info (GtkRecentInfo *info, gtk_recent_info_get_application_info (GtkRecentInfo *info,
const gchar *app_name, const gchar *app_name,
const gchar **app_exec, const gchar **app_exec,
guint *count, guint *count,
time_t *time_) time_t *time_)
{ {
RecentAppInfo *ai; RecentAppInfo *ai;
@ -1790,7 +1795,7 @@ gtk_recent_info_get_application_info (GtkRecentInfo *info,
g_return_val_if_fail (app_name != NULL, FALSE); g_return_val_if_fail (app_name != NULL, FALSE);
ai = (RecentAppInfo *) g_hash_table_lookup (info->apps_lookup, ai = (RecentAppInfo *) g_hash_table_lookup (info->apps_lookup,
app_name); app_name);
if (!ai) if (!ai)
{ {
g_warning ("No registered application with name '%s' " g_warning ("No registered application with name '%s' "
@ -1827,7 +1832,7 @@ gtk_recent_info_get_application_info (GtkRecentInfo *info,
*/ */
gchar ** gchar **
gtk_recent_info_get_applications (GtkRecentInfo *info, gtk_recent_info_get_applications (GtkRecentInfo *info,
gsize *length) gsize *length)
{ {
GSList *l; GSList *l;
gchar **retval; gchar **retval;
@ -1873,13 +1878,13 @@ gtk_recent_info_get_applications (GtkRecentInfo *info,
* Checks whether an application registered this resource using @app_name. * Checks whether an application registered this resource using @app_name.
* *
* Returns: %TRUE if an application with name @app_name was found, * Returns: %TRUE if an application with name @app_name was found,
* %FALSE otherwise. * %FALSE otherwise
* *
* Since: 2.10 * Since: 2.10
*/ */
gboolean gboolean
gtk_recent_info_has_application (GtkRecentInfo *info, gtk_recent_info_has_application (GtkRecentInfo *info,
const gchar *app_name) const gchar *app_name)
{ {
g_return_val_if_fail (info != NULL, FALSE); g_return_val_if_fail (info != NULL, FALSE);
g_return_val_if_fail (app_name != NULL, FALSE); g_return_val_if_fail (app_name != NULL, FALSE);
@ -1894,12 +1899,12 @@ gtk_recent_info_has_application (GtkRecentInfo *info,
* Gets the name of the last application that have registered the * Gets the name of the last application that have registered the
* recently used resource represented by @info. * recently used resource represented by @info.
* *
* Returns: an application name. Use g_free() to free it. * Returns: an application name. Use g_free() to free it.
* *
* Since: 2.10 * Since: 2.10
*/ */
gchar * gchar *
gtk_recent_info_last_application (GtkRecentInfo *info) gtk_recent_info_last_application (GtkRecentInfo *info)
{ {
GSList *l; GSList *l;
time_t last_stamp = (time_t) -1; time_t last_stamp = (time_t) -1;
@ -1913,17 +1918,17 @@ gtk_recent_info_last_application (GtkRecentInfo *info)
if (ai->stamp > last_stamp) if (ai->stamp > last_stamp)
{ {
name = ai->name; name = ai->name;
last_stamp = ai->stamp; last_stamp = ai->stamp;
} }
} }
return g_strdup (name); return g_strdup (name);
} }
static GdkPixbuf * static GdkPixbuf *
get_icon_for_mime_type (const char *mime_type, get_icon_for_mime_type (const gchar *mime_type,
gint pixel_size) gint pixel_size)
{ {
GtkIconTheme *icon_theme; GtkIconTheme *icon_theme;
char *content_type; char *content_type;
@ -1957,7 +1962,7 @@ get_icon_for_mime_type (const char *mime_type,
static GdkPixbuf * static GdkPixbuf *
get_icon_fallback (const gchar *icon_name, get_icon_fallback (const gchar *icon_name,
gint size) gint size)
{ {
GtkIconTheme *icon_theme; GtkIconTheme *icon_theme;
GdkPixbuf *retval; GdkPixbuf *retval;
@ -1965,9 +1970,9 @@ get_icon_fallback (const gchar *icon_name,
icon_theme = gtk_icon_theme_get_default (); icon_theme = gtk_icon_theme_get_default ();
retval = gtk_icon_theme_load_icon (icon_theme, icon_name, retval = gtk_icon_theme_load_icon (icon_theme, icon_name,
size, size,
GTK_ICON_LOOKUP_USE_BUILTIN, GTK_ICON_LOOKUP_USE_BUILTIN,
NULL); NULL);
g_assert (retval != NULL); g_assert (retval != NULL);
return retval; return retval;
@ -1987,7 +1992,7 @@ get_icon_fallback (const gchar *icon_name,
*/ */
GdkPixbuf * GdkPixbuf *
gtk_recent_info_get_icon (GtkRecentInfo *info, gtk_recent_info_get_icon (GtkRecentInfo *info,
gint size) gint size)
{ {
GdkPixbuf *retval = NULL; GdkPixbuf *retval = NULL;
@ -2015,13 +2020,13 @@ gtk_recent_info_get_icon (GtkRecentInfo *info,
* *
* Retrieves the icon associated to the resource MIME type. * Retrieves the icon associated to the resource MIME type.
* *
* Returns: (transfer full): a #GIcon containing the icon, or %NULL. Use * Returns: (transfer full): a #GIcon containing the icon, or %NULL.
* g_object_unref() when finished using the icon * Use g_object_unref() when finished using the icon
* *
* Since: 2.22 * Since: 2.22
*/ */
GIcon * GIcon *
gtk_recent_info_get_gicon (GtkRecentInfo *info) gtk_recent_info_get_gicon (GtkRecentInfo *info)
{ {
GIcon *icon = NULL; GIcon *icon = NULL;
gchar *content_type; gchar *content_type;
@ -2045,7 +2050,7 @@ gtk_recent_info_get_gicon (GtkRecentInfo *info)
* Checks whether the resource is local or not by looking at the * Checks whether the resource is local or not by looking at the
* scheme of its URI. * scheme of its URI.
* *
* Returns: %TRUE if the resource is local. * Returns: %TRUE if the resource is local
* *
* Since: 2.10 * Since: 2.10
*/ */
@ -2061,8 +2066,9 @@ gtk_recent_info_is_local (GtkRecentInfo *info)
* gtk_recent_info_exists: * gtk_recent_info_exists:
* @info: a #GtkRecentInfo * @info: a #GtkRecentInfo
* *
* Checks whether the resource pointed by @info still exists. At * Checks whether the resource pointed by @info still exists.
* the moment this check is done only on resources pointing to local files. * At the moment this check is done only on resources pointing
* to local files.
* *
* Returns: %TRUE if the resource exists * Returns: %TRUE if the resource exists
* *
@ -2101,14 +2107,14 @@ gtk_recent_info_exists (GtkRecentInfo *info)
* Checks whether two #GtkRecentInfo-struct point to the same * Checks whether two #GtkRecentInfo-struct point to the same
* resource. * resource.
* *
* Returns: %TRUE if both #GtkRecentInfo-struct point to se same * Returns: %TRUE if both #GtkRecentInfo-struct point to the same
* resource, %FALSE otherwise. * resource, %FALSE otherwise
* *
* Since: 2.10 * Since: 2.10
*/ */
gboolean gboolean
gtk_recent_info_match (GtkRecentInfo *info_a, gtk_recent_info_match (GtkRecentInfo *info_a,
GtkRecentInfo *info_b) GtkRecentInfo *info_b)
{ {
g_return_val_if_fail (info_a != NULL, FALSE); g_return_val_if_fail (info_a != NULL, FALSE);
g_return_val_if_fail (info_b != NULL, FALSE); g_return_val_if_fail (info_b != NULL, FALSE);
@ -2119,7 +2125,7 @@ gtk_recent_info_match (GtkRecentInfo *info_a,
/* taken from gnome-vfs-uri.c */ /* taken from gnome-vfs-uri.c */
static const gchar * static const gchar *
get_method_string (const gchar *substring, get_method_string (const gchar *substring,
gchar **method_string) gchar **method_string)
{ {
const gchar *p; const gchar *p;
char *method; char *method;
@ -2134,7 +2140,7 @@ get_method_string (const gchar *substring,
&& &&
!(p == substring + 1 && g_ascii_isalpha (*substring)) !(p == substring + 1 && g_ascii_isalpha (*substring))
#endif #endif
) )
{ {
/* Found toplevel method specification. */ /* Found toplevel method specification. */
method = g_strndup (substring, p - substring); method = g_strndup (substring, p - substring);
@ -2244,12 +2250,13 @@ get_uri_shortname_for_display (const gchar *uri)
* gtk_recent_info_get_short_name: * gtk_recent_info_get_short_name:
* @info: an #GtkRecentInfo * @info: an #GtkRecentInfo
* *
* Computes a valid UTF-8 string that can be used as the name of the item in a * Computes a valid UTF-8 string that can be used as the
* menu or list. For example, calling this function on an item that refers to * name of the item in a menu or list. For example, calling
* this function on an item that refers to
* file:///foo/bar.txt” will yield “bar.txt”. * file:///foo/bar.txt” will yield “bar.txt”.
* *
* Returns: A newly-allocated string in UTF-8 encoding; free it with * Returns: A newly-allocated string in UTF-8 encoding
* g_free(). * free it with g_free()
* *
* Since: 2.10 * Since: 2.10
*/ */
@ -2272,7 +2279,7 @@ gtk_recent_info_get_short_name (GtkRecentInfo *info)
* gtk_recent_info_get_uri_display: * gtk_recent_info_get_uri_display:
* @info: a #GtkRecentInfo * @info: a #GtkRecentInfo
* *
* Gets a displayable version of the resources URI. If the resource * Gets a displayable version of the resources URI. If the resource
* is local, it returns a local path; if the resource is not local, * is local, it returns a local path; if the resource is not local,
* it returns the UTF-8 encoded content of gtk_recent_info_get_uri(). * it returns the UTF-8 encoded content of gtk_recent_info_get_uri().
* *
@ -2312,11 +2319,11 @@ gtk_recent_info_get_uri_display (GtkRecentInfo *info)
* gtk_recent_info_get_age: * gtk_recent_info_get_age:
* @info: a #GtkRecentInfo * @info: a #GtkRecentInfo
* *
* Gets the number of days elapsed since the last update of the resource * Gets the number of days elapsed since the last update
* pointed by @info. * of the resource pointed by @info.
* *
* Returns: a positive integer containing the number of days elapsed * Returns: a positive integer containing the number of days
* since the time this resource was last modified. * elapsed since the time this resource was last modified
* *
* Since: 2.10 * Since: 2.10
*/ */
@ -2342,19 +2349,19 @@ gtk_recent_info_get_age (GtkRecentInfo *info)
* @info: a #GtkRecentInfo * @info: a #GtkRecentInfo
* @length: (out) (allow-none): return location for the number of groups returned * @length: (out) (allow-none): return location for the number of groups returned
* *
* Returns all groups registered for the recently used item @info. The * Returns all groups registered for the recently used item @info.
* array of returned group names will be %NULL terminated, so length might * The array of returned group names will be %NULL terminated, so
* optionally be %NULL. * length might optionally be %NULL.
* *
* Returns: (array length=length zero-terminated=1) (transfer full): * Returns: (array length=length zero-terminated=1) (transfer full):
* a newly allocated %NULL terminated array of strings. * a newly allocated %NULL terminated array of strings.
* Use g_strfreev() to free it. * Use g_strfreev() to free it.
* *
* Since: 2.10 * Since: 2.10
*/ */
gchar ** gchar **
gtk_recent_info_get_groups (GtkRecentInfo *info, gtk_recent_info_get_groups (GtkRecentInfo *info,
gsize *length) gsize *length)
{ {
GSList *l; GSList *l;
gchar **retval; gchar **retval;
@ -2397,16 +2404,16 @@ gtk_recent_info_get_groups (GtkRecentInfo *info,
* @info: a #GtkRecentInfo * @info: a #GtkRecentInfo
* @group_name: name of a group * @group_name: name of a group
* *
* Checks whether @group_name appears inside the groups registered for the * Checks whether @group_name appears inside the groups
* recently used item @info. * registered for the recently used item @info.
* *
* Returns: %TRUE if the group was found. * Returns: %TRUE if the group was found
* *
* Since: 2.10 * Since: 2.10
*/ */
gboolean gboolean
gtk_recent_info_has_group (GtkRecentInfo *info, gtk_recent_info_has_group (GtkRecentInfo *info,
const gchar *group_name) const gchar *group_name)
{ {
GSList *l; GSList *l;