diff options
author | Stefano Karapetsas <[email protected]> | 2012-10-15 16:47:56 +0200 |
---|---|---|
committer | Stefano Karapetsas <[email protected]> | 2012-10-15 16:47:56 +0200 |
commit | 458154dbbfebdc3b7e17c903b63aba792a71a70f (patch) | |
tree | da2ff9a1abcde13490288a6e2506179c978cd66c | |
parent | 2011fb06c86d034a92c40904da4572c19fccf89f (diff) | |
download | mate-desktop-458154dbbfebdc3b7e17c903b63aba792a71a70f.tar.bz2 mate-desktop-458154dbbfebdc3b7e17c903b63aba792a71a70f.tar.xz |
add retro-compatibility for glib < 2.31
-rw-r--r-- | libmate-desktop/mate-desktop-thumbnail.c | 66 |
1 files changed, 65 insertions, 1 deletions
diff --git a/libmate-desktop/mate-desktop-thumbnail.c b/libmate-desktop/mate-desktop-thumbnail.c index 6d91882..6e3616c 100644 --- a/libmate-desktop/mate-desktop-thumbnail.c +++ b/libmate-desktop/mate-desktop-thumbnail.c @@ -50,7 +50,11 @@ struct _MateDesktopThumbnailFactoryPrivate { MateDesktopThumbnailSize size; +#if GLIB_CHECK_VERSION(2, 31, 0) GMutex lock; +#else + GMutex* lock; +#endif GList *thumbnailers; GHashTable *mime_types_map; @@ -495,7 +499,15 @@ mate_desktop_thumbnail_factory_finalize (GObject *object) priv->monitors = NULL; } +#if GLIB_CHECK_VERSION(2, 31, 0) g_mutex_clear (&priv->lock); +#else + if (priv->lock) + { + g_mutex_free (priv->lock); + priv->lock = NULL; + } +#endif if (priv->disabled_types) { @@ -580,7 +592,11 @@ update_or_create_thumbnailer (MateDesktopThumbnailFactory *factory, Thumbnailer *thumb; gboolean found = FALSE; +#if GLIB_CHECK_VERSION(2, 31, 0) g_mutex_lock (&priv->lock); +#else + g_mutex_lock (priv->lock); +#endif for (l = priv->thumbnailers; l && !found; l = g_list_next (l)) { @@ -608,7 +624,11 @@ update_or_create_thumbnailer (MateDesktopThumbnailFactory *factory, mate_desktop_thumbnail_factory_add_thumbnailer (factory, thumb); } +#if GLIB_CHECK_VERSION(2, 31, 0) g_mutex_unlock (&priv->lock); +#else + g_mutex_unlock (priv->lock); +#endif } static void @@ -619,7 +639,11 @@ remove_thumbnailer (MateDesktopThumbnailFactory *factory, GList *l; Thumbnailer *thumb; +#if GLIB_CHECK_VERSION(2, 31, 0) g_mutex_lock (&priv->lock); +#else + g_mutex_lock (priv->lock); +#endif for (l = priv->thumbnailers; l; l = g_list_next (l)) { @@ -637,7 +661,11 @@ remove_thumbnailer (MateDesktopThumbnailFactory *factory, } } +#if GLIB_CHECK_VERSION(2, 31, 0) g_mutex_unlock (&priv->lock); +#else + g_mutex_unlock (priv->lock); +#endif } static void @@ -739,7 +767,11 @@ external_thumbnailers_disabled_all_changed_cb (GSettings *set { MateDesktopThumbnailFactoryPrivate *priv = factory->priv; +#if GLIB_CHECK_VERSION(2, 31, 0) g_mutex_lock (&priv->lock); +#else + g_mutex_lock (priv->lock); +#endif priv->disabled = g_settings_get_boolean (priv->settings, "disable-all"); if (priv->disabled) @@ -753,7 +785,11 @@ external_thumbnailers_disabled_all_changed_cb (GSettings *set mate_desktop_thumbnail_factory_load_thumbnailers (factory); } +#if GLIB_CHECK_VERSION(2, 31, 0) g_mutex_unlock (&priv->lock); +#else + g_mutex_unlock (priv->lock); +#endif } static void @@ -763,14 +799,22 @@ external_thumbnailers_disabled_changed_cb (GSettings *setting { MateDesktopThumbnailFactoryPrivate *priv = factory->priv; +#if GLIB_CHECK_VERSION(2, 31, 0) g_mutex_lock (&priv->lock); +#else + g_mutex_lock (priv->lock); +#endif if (priv->disabled) return; g_strfreev (priv->disabled_types); priv->disabled_types = g_settings_get_strv (priv->settings, "disable"); +#if GLIB_CHECK_VERSION(2, 31, 0) g_mutex_unlock (&priv->lock); +#else + g_mutex_unlock (priv->lock); +#endif } static void @@ -788,8 +832,12 @@ mate_desktop_thumbnail_factory_init (MateDesktopThumbnailFactory *factory) g_str_equal, (GDestroyNotify)g_free, (GDestroyNotify)thumbnailer_unref); - + +#if GLIB_CHECK_VERSION(2, 31, 0) g_mutex_init (&priv->lock); +#else + priv->lock = g_mutex_new (); +#endif priv->settings = g_settings_new ("org.mate.thumbnailers"); priv->disabled = g_settings_get_boolean (priv->settings, "disable-all"); @@ -1050,7 +1098,11 @@ mate_desktop_thumbnail_factory_can_thumbnail (MateDesktopThumbnailFactory *facto if (!mime_type) return FALSE; +#if GLIB_CHECK_VERSION(2, 31, 0) g_mutex_lock (&factory->priv->lock); +#else + g_mutex_lock (factory->priv->lock); +#endif if (!mate_desktop_thumbnail_factory_is_disabled (factory, mime_type)) { Thumbnailer *thumb; @@ -1058,7 +1110,11 @@ mate_desktop_thumbnail_factory_can_thumbnail (MateDesktopThumbnailFactory *facto thumb = g_hash_table_lookup (factory->priv->mime_types_map, mime_type); have_script = thumbnailer_try_exec (thumb); } +#if GLIB_CHECK_VERSION(2, 31, 0) g_mutex_unlock (&factory->priv->lock); +#else + g_mutex_unlock (factory->priv->lock); +#endif if (have_script || mimetype_supported_by_gdk_pixbuf (mime_type)) { @@ -1181,7 +1237,11 @@ mate_desktop_thumbnail_factory_generate_thumbnail (MateDesktopThumbnailFactory * pixbuf = NULL; script = NULL; +#if GLIB_CHECK_VERSION(2, 31, 0) g_mutex_lock (&factory->priv->lock); +#else + g_mutex_lock (factory->priv->lock); +#endif if (!mate_desktop_thumbnail_factory_is_disabled (factory, mime_type)) { Thumbnailer *thumb; @@ -1190,7 +1250,11 @@ mate_desktop_thumbnail_factory_generate_thumbnail (MateDesktopThumbnailFactory * if (thumb) script = g_strdup (thumb->command); } +#if GLIB_CHECK_VERSION(2, 31, 0) g_mutex_unlock (&factory->priv->lock); +#else + g_mutex_unlock (factory->priv->lock); +#endif if (script) { |