]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkrecentmanager.c
Fix typos
[~andy/gtk] / gtk / gtkrecentmanager.c
index 918104d7a0e4f137550debbc8d826ecc2ae26e7d..aadeb60418647df16e6abf6daa2045769cfc5e22 100644 (file)
@@ -48,8 +48,8 @@
 /* the file where we store the recently used items */
 #define GTK_RECENTLY_USED_FILE ".recently-used.xbel"
 
-/* a poll per second should be enough */
-#define POLL_DELTA     1000
+/* a poll every two seconds should be enough */
+#define POLL_DELTA     2000
 
 /* return all items by default */
 #define DEFAULT_LIMIT  -1
@@ -150,7 +150,7 @@ static void           gtk_recent_info_free            (GtkRecentInfo         *re
 
 static guint signal_changed = 0;
 
-G_DEFINE_TYPE (GtkRecentManager, gtk_recent_manager, G_TYPE_OBJECT);
+G_DEFINE_TYPE (GtkRecentManager, gtk_recent_manager, G_TYPE_OBJECT)
 
 static void
 filename_warning (const gchar *format, 
@@ -283,10 +283,6 @@ gtk_recent_manager_init (GtkRecentManager *manager)
                                      GTK_TYPE_RECENT_MANAGER);
   manager->priv = priv;
   
-  priv->filename = g_build_filename (g_get_home_dir (),
-                                    GTK_RECENTLY_USED_FILE,
-                                    NULL);
-  
   priv->limit = DEFAULT_LIMIT;
   priv->size = 0;
   
@@ -297,6 +293,13 @@ gtk_recent_manager_init (GtkRecentManager *manager)
 
   priv->screen = NULL;
 
+  priv->filename = g_build_filename (g_get_home_dir (),
+                                    GTK_RECENTLY_USED_FILE,
+                                    NULL);
+  priv->poll_timeout = g_timeout_add (POLL_DELTA,
+                                     gtk_recent_manager_poll_timeout,
+                                     manager);
+
   build_recent_items_list (manager);
 }
 
@@ -399,6 +402,7 @@ gtk_recent_manager_real_changed (GtkRecentManager *manager)
       g_bookmark_file_to_file (priv->recent_items,
                               priv->filename,
                               &write_error);
+
       if (write_error)
         {
           filename_warning ("Attempting to store changes into `%s', "
@@ -408,6 +412,8 @@ gtk_recent_manager_real_changed (GtkRecentManager *manager)
          g_error_free (write_error);
        }
 
+      priv->write_in_progress = FALSE;
+         
       /* we have sync'ed our list with the storage file, so we
        * update the file mtime in order to skip the timed check
        * and spare us from a re-read.
@@ -419,8 +425,6 @@ gtk_recent_manager_real_changed (GtkRecentManager *manager)
                            priv->filename,
                            g_strerror (errno));
 
-         priv->write_in_progress = FALSE;
-         
          g_object_thaw_notify (G_OBJECT (manager));
 
          return;
@@ -812,7 +816,6 @@ gtk_recent_manager_get_limit (GtkRecentManager *manager)
  * gtk_recent_manager_add_item:
  * @manager: a #GtkRecentManager
  * @uri: a valid URI
- * @error: return location for a #GError, or %NULL
  *
  * Adds a new resource, pointed by @uri, into the recently used
  * resources list.
@@ -831,8 +834,7 @@ gtk_recent_manager_get_limit (GtkRecentManager *manager)
  */
 gboolean
 gtk_recent_manager_add_item (GtkRecentManager  *manager,
-                            const gchar       *uri,
-                            GError           **error)
+                            const gchar       *uri)
 {
   GtkRecentData *recent_data;
   GError *add_error;
@@ -873,7 +875,7 @@ gtk_recent_manager_add_item (GtkRecentManager  *manager,
   recent_data->is_private = FALSE;
   
   add_error = NULL;
-  retval = gtk_recent_manager_add_full (manager, uri, recent_data, &add_error);
+  retval = gtk_recent_manager_add_full (manager, uri, recent_data);
   
   g_free (recent_data->mime_type);
   g_free (recent_data->app_name);
@@ -881,13 +883,6 @@ gtk_recent_manager_add_item (GtkRecentManager  *manager,
 
   g_slice_free (GtkRecentData, recent_data);
   
-  if (!retval)
-    {
-      g_propagate_error (error, add_error);
-      
-      return FALSE;
-    }
-  
   return retval;
 }
 
@@ -896,7 +891,6 @@ gtk_recent_manager_add_item (GtkRecentManager  *manager,
  * @manager: a #GtkRecentManager
  * @uri: a valid URI
  * @recent_data: metadata of the resource
- * @error: return location for a #GError, or %NULL
  *
  * Adds a new resource, pointed by @uri, into the recently used
  * resources list, using the metadata specified inside the #GtkRecentData
@@ -926,8 +920,7 @@ gtk_recent_manager_add_item (GtkRecentManager  *manager,
 gboolean
 gtk_recent_manager_add_full (GtkRecentManager     *manager,
                             const gchar          *uri,
-                            const GtkRecentData  *data,
-                            GError              **error)
+                            const GtkRecentData  *data)
 {
   GtkRecentManagerPrivate *priv;
   
@@ -939,53 +932,47 @@ gtk_recent_manager_add_full (GtkRecentManager     *manager,
   if ((data->display_name) &&
       (!g_utf8_validate (data->display_name, -1, NULL)))
     {
-      g_set_error  (error, GTK_RECENT_MANAGER_ERROR,
-                   GTK_RECENT_MANAGER_ERROR_INVALID_ENCODING,
-                   _("The display name of the recently used resource "
-                     "must be a valid UTF-8 encoded string."));
+      g_warning ("Attempting to add `%s' to the list of recently used "
+                "resources, but the display name is not a valid UTF-8 "
+                "encoded string",
+                uri);
       return FALSE;
     }
   
   if ((data->description) &&
       (!g_utf8_validate (data->description, -1, NULL)))
     {
-      g_set_error (error, GTK_RECENT_MANAGER_ERROR,
-                  GTK_RECENT_MANAGER_ERROR_INVALID_ENCODING,
-                  _("The description of the recently used resource "
-                    "must by a valid UTF-8 encoded string."));
+      g_warning ("Attempting to add `%s' to the list of recently used "
+                "resources, but the description is not a valid UTF-8 "
+                "encoded string",
+                uri);
       return FALSE;
     }
 
  
   if (!data->mime_type)
     {
-      g_set_error (error, GTK_RECENT_MANAGER_ERROR,
-                   GTK_RECENT_MANAGER_ERROR_INVALID_MIME,
-                  _("You must specify the MIME type of the "
-                    "resource pointed by `%s'"),
-                  uri);
+      g_warning ("Attempting to add `%s' to the list of recently used "
+                "resources, but not MIME type was defined",
+                uri);
       return FALSE;
     }
   
   if (!data->app_name)
     {
-      g_set_error (error, GTK_RECENT_MANAGER_ERROR,
-                  GTK_RECENT_MANAGER_ERROR_NOT_REGISTERED,
-                  _("You must specify the name of the application "
-                    "that is registering the recently used resource "
-                    "pointed by `%s'"),
-                  uri);
+      g_warning ("Attempting to add `%s' to the list of recently used "
+                "resources, but no name of the application that is "
+                "registering it was defined",
+                uri);
       return FALSE;
     }
   
   if (!data->app_exec)
     {
-      g_set_error (error, GTK_RECENT_MANAGER_ERROR,
-                   GTK_RECENT_MANAGER_ERROR_BAD_EXEC_STRING,
-                  _("You must specify a command line to "
-                    "be used when launching the resource "
-                    "pointed by `%s'"),
-                  uri);
+      g_warning ("Attempting to add `%s' to the list of recently used "
+                "resources, but no command line for the application "
+                "that is registering it was defined",
+                uri);
       return FALSE;
     }
   
@@ -1195,7 +1182,9 @@ build_recent_info (GBookmarkFile  *bookmarks,
  *   about the resource pointed by @uri, or %NULL if the URI was
  *   not registered in the recently used resources list.  Free with
  *   gtk_recent_info_unref().
- **/
+ *
+ * Since: 2.10
+ */
 GtkRecentInfo *
 gtk_recent_manager_lookup_item (GtkRecentManager  *manager,
                                const gchar       *uri,
@@ -1760,7 +1749,7 @@ recent_app_info_free (RecentAppInfo *app_info)
  * @app_name: the name of the application that has registered this item
  * @app_exec: return location for the string containing the command line
  * @count: return location for the number of times this item was registered
- * @time: return location for the timestamp this item was last registered
+ * @time_: return location for the timestamp this item was last registered
  *    for this application
  *
  * Gets the data regarding the application that has registered the resource
@@ -1780,7 +1769,7 @@ gtk_recent_info_get_application_info (GtkRecentInfo  *info,
                                      const gchar    *app_name,
                                      gchar         **app_exec,
                                      guint          *count,
-                                     time_t         *time)
+                                     time_t         *time_)
 {
   RecentAppInfo *ai;
   
@@ -1804,8 +1793,8 @@ gtk_recent_info_get_application_info (GtkRecentInfo  *info,
   if (count)
     *count = ai->count;
   
-  if (time)
-    *time = ai->stamp;
+  if (time_)
+    *time_ = ai->stamp;
 
   return TRUE;
 }