Use g_timeout_add_seconds_full() for the timed poll of the storage file,
2007-06-19 Emmanuele Bassi <ebassi@gnome.org> * gtk/gtkrecentmanager.c: Use g_timeout_add_seconds_full() for the timed poll of the storage file, since we are using multiple seconds intervals and we don't actually care about millisecond precision. (threads_dispatch), (threads_free), (gtk_recent_manager_init), (gtk_recent_manager_set_filename): Roll our own version of gdk_threads_add_timeout() using g_timeout_add_seconds_full() while holding the GDK main lock. svn path=/trunk/; revision=18185
This commit is contained in:

committed by
Emmanuele Bassi

parent
232e79a6d7
commit
ca0ad88892
12
ChangeLog
12
ChangeLog
@ -1,3 +1,15 @@
|
|||||||
|
2007-06-19 Emmanuele Bassi <ebassi@gnome.org>
|
||||||
|
|
||||||
|
* gtk/gtkrecentmanager.c: Use g_timeout_add_seconds_full() for
|
||||||
|
the timed poll of the storage file, since we are using multiple
|
||||||
|
seconds intervals and we don't actually care about millisecond
|
||||||
|
precision.
|
||||||
|
|
||||||
|
(threads_dispatch), (threads_free), (gtk_recent_manager_init),
|
||||||
|
(gtk_recent_manager_set_filename): Roll our own version of
|
||||||
|
gdk_threads_add_timeout() using g_timeout_add_seconds_full()
|
||||||
|
while holding the GDK main lock.
|
||||||
|
|
||||||
2007-06-19 Emmanuele Bassi <ebassi@gnome.org>
|
2007-06-19 Emmanuele Bassi <ebassi@gnome.org>
|
||||||
|
|
||||||
* gtk/gtkrecentmanager.c: Use a static variable to hold the
|
* gtk/gtkrecentmanager.c: Use a static variable to hold the
|
||||||
|
@ -31,7 +31,7 @@ m4_define([gtk_api_version], [2.0])
|
|||||||
m4_define([gtk_binary_version], [2.10.0])
|
m4_define([gtk_binary_version], [2.10.0])
|
||||||
|
|
||||||
# required versions of other packages
|
# required versions of other packages
|
||||||
m4_define([glib_required_version], [2.13.3])
|
m4_define([glib_required_version], [2.13.5])
|
||||||
m4_define([pango_required_version], [1.15.3])
|
m4_define([pango_required_version], [1.15.3])
|
||||||
m4_define([atk_required_version], [1.9.0])
|
m4_define([atk_required_version], [1.9.0])
|
||||||
m4_define([cairo_required_version], [1.2.0])
|
m4_define([cairo_required_version], [1.2.0])
|
||||||
|
@ -48,8 +48,8 @@
|
|||||||
/* 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"
|
||||||
|
|
||||||
/* a poll every two seconds should be enough */
|
/* a poll approximately every five seconds */
|
||||||
#define POLL_DELTA 2000
|
#define POLL_DELTA 5
|
||||||
|
|
||||||
/* return all items by default */
|
/* return all items by default */
|
||||||
#define DEFAULT_LIMIT -1
|
#define DEFAULT_LIMIT -1
|
||||||
@ -57,6 +57,13 @@
|
|||||||
/* 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
|
||||||
|
{
|
||||||
|
GSourceFunc func;
|
||||||
|
gpointer data;
|
||||||
|
GDestroyNotify notify;
|
||||||
|
} ThreadsDispatch;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
gchar *name;
|
gchar *name;
|
||||||
@ -189,6 +196,32 @@ gtk_recent_manager_error_quark (void)
|
|||||||
return g_quark_from_static_string ("gtk-recent-manager-error-quark");
|
return g_quark_from_static_string ("gtk-recent-manager-error-quark");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
threads_dispatch (gpointer data)
|
||||||
|
{
|
||||||
|
ThreadsDispatch *dispatch = data;
|
||||||
|
gboolean res = FALSE;
|
||||||
|
|
||||||
|
GDK_THREADS_ENTER ();
|
||||||
|
|
||||||
|
if (!g_source_is_destroyed (g_main_current_source ()))
|
||||||
|
res = dispatch->func (dispatch->data);
|
||||||
|
|
||||||
|
GDK_THREADS_LEAVE ();
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
threads_free (gpointer data)
|
||||||
|
{
|
||||||
|
ThreadsDispatch *dispatch = data;
|
||||||
|
|
||||||
|
if (dispatch->notify)
|
||||||
|
dispatch->notify (dispatch->data);
|
||||||
|
|
||||||
|
g_slice_free (ThreadsDispatch, dispatch);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_recent_manager_class_init (GtkRecentManagerClass *klass)
|
gtk_recent_manager_class_init (GtkRecentManagerClass *klass)
|
||||||
@ -277,6 +310,7 @@ static void
|
|||||||
gtk_recent_manager_init (GtkRecentManager *manager)
|
gtk_recent_manager_init (GtkRecentManager *manager)
|
||||||
{
|
{
|
||||||
GtkRecentManagerPrivate *priv;
|
GtkRecentManagerPrivate *priv;
|
||||||
|
ThreadsDispatch *dispatch;
|
||||||
|
|
||||||
priv = g_type_instance_get_private ((GTypeInstance *) manager,
|
priv = g_type_instance_get_private ((GTypeInstance *) manager,
|
||||||
GTK_TYPE_RECENT_MANAGER);
|
GTK_TYPE_RECENT_MANAGER);
|
||||||
@ -292,9 +326,16 @@ gtk_recent_manager_init (GtkRecentManager *manager)
|
|||||||
priv->filename = g_build_filename (g_get_home_dir (),
|
priv->filename = g_build_filename (g_get_home_dir (),
|
||||||
GTK_RECENTLY_USED_FILE,
|
GTK_RECENTLY_USED_FILE,
|
||||||
NULL);
|
NULL);
|
||||||
priv->poll_timeout = gdk_threads_add_timeout (POLL_DELTA,
|
|
||||||
gtk_recent_manager_poll_timeout,
|
dispatch = g_slice_new (ThreadsDispatch);
|
||||||
manager);
|
dispatch->func = gtk_recent_manager_poll_timeout;
|
||||||
|
dispatch->data = manager;
|
||||||
|
dispatch->notify = NULL;
|
||||||
|
priv->poll_timeout = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT + 30,
|
||||||
|
POLL_DELTA,
|
||||||
|
threads_dispatch,
|
||||||
|
dispatch,
|
||||||
|
threads_free);
|
||||||
|
|
||||||
build_recent_items_list (manager);
|
build_recent_items_list (manager);
|
||||||
}
|
}
|
||||||
@ -487,6 +528,7 @@ gtk_recent_manager_set_filename (GtkRecentManager *manager,
|
|||||||
const gchar *filename)
|
const gchar *filename)
|
||||||
{
|
{
|
||||||
GtkRecentManagerPrivate *priv;
|
GtkRecentManagerPrivate *priv;
|
||||||
|
ThreadsDispatch *dispatch;
|
||||||
|
|
||||||
g_assert (GTK_IS_RECENT_MANAGER (manager));
|
g_assert (GTK_IS_RECENT_MANAGER (manager));
|
||||||
priv = manager->priv;
|
priv = manager->priv;
|
||||||
@ -503,9 +545,16 @@ gtk_recent_manager_set_filename (GtkRecentManager *manager,
|
|||||||
}
|
}
|
||||||
|
|
||||||
priv->filename = g_strdup (filename);
|
priv->filename = g_strdup (filename);
|
||||||
priv->poll_timeout = gdk_threads_add_timeout (POLL_DELTA,
|
|
||||||
gtk_recent_manager_poll_timeout,
|
dispatch = g_slice_new (ThreadsDispatch);
|
||||||
manager);
|
dispatch->func = gtk_recent_manager_poll_timeout;
|
||||||
|
dispatch->data = manager;
|
||||||
|
dispatch->notify = NULL;
|
||||||
|
priv->poll_timeout = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT + 30,
|
||||||
|
POLL_DELTA,
|
||||||
|
threads_dispatch,
|
||||||
|
dispatch,
|
||||||
|
threads_free);
|
||||||
|
|
||||||
/* mark us clean, so that we can re-read the list
|
/* mark us clean, so that we can re-read the list
|
||||||
* of recently used resources
|
* of recently used resources
|
||||||
|
Reference in New Issue
Block a user