Commit cfa0e003 authored by Hib Eris's avatar Hib Eris

Allow compiling with glib < 2.31.0

parent cb4e0ccf
......@@ -123,7 +123,7 @@ AM_CONDITIONAL([PLATFORM_WIN32],[test "$with_platform" = "win32"])
dnl Specify required versions of dependencies
CAIRO_REQUIRED=1.10.0
GLIB_REQUIRED=2.31.0
GLIB_REQUIRED=2.25.11
KEYRING_REQUIRED=2.22.0
GTK_REQUIRED=3.0.2
NAUTILUS_REQUIRED=2.91.4
......
......@@ -69,8 +69,22 @@ static gchar *_ev_document_get_page_label (EvDocument *document,
static EvDocumentInfo *_ev_document_get_info (EvDocument *document);
static gboolean _ev_document_support_synctex (EvDocument *document);
#if (!GLIB_CHECK_VERSION(2,31,0))
/* Remove this once we bump dependencies to glib >= 2.31.0 */
GMutex *ev_doc_mutex = NULL;
GMutex *ev_fc_mutex = NULL;
#define p_ev_doc_mutex ((ev_doc_mutex == NULL) ? ev_doc_mutex = g_mutex_new () : ev_doc_mutex)
#define p_ev_fc_mutex ((ev_fc_mutex == NULL) ? ev_fc_mutex = g_mutex_new () : ev_fc_mutex)
#else
static GMutex ev_doc_mutex;
static GMutex ev_fc_mutex;
/* Remove these defines once we bump dependencies to glib >= 2.31.0
and replace occurences in this file of p_ev_{doc|fc}_mutex with
&ev_{doc|fc}_mutex.
*/
#define p_ev_doc_mutex (&ev_doc_mutex)
#define p_ev_fc_mutex (&ev_fc_mutex)
#endif
G_DEFINE_ABSTRACT_TYPE (EvDocument, ev_document, G_TYPE_OBJECT)
......@@ -161,37 +175,37 @@ ev_document_class_init (EvDocumentClass *klass)
void
ev_document_doc_mutex_lock (void)
{
g_mutex_lock (&ev_doc_mutex);
g_mutex_lock (p_ev_doc_mutex);
}
void
ev_document_doc_mutex_unlock (void)
{
g_mutex_unlock (&ev_doc_mutex);
g_mutex_unlock (p_ev_doc_mutex);
}
gboolean
ev_document_doc_mutex_trylock (void)
{
return g_mutex_trylock (&ev_doc_mutex);
return g_mutex_trylock (p_ev_doc_mutex);
}
void
ev_document_fc_mutex_lock (void)
{
g_mutex_lock (&ev_fc_mutex);
g_mutex_lock (p_ev_fc_mutex);
}
void
ev_document_fc_mutex_unlock (void)
{
g_mutex_unlock (&ev_fc_mutex);
g_mutex_unlock (p_ev_fc_mutex);
}
gboolean
ev_document_fc_mutex_trylock (void)
{
return g_mutex_trylock (&ev_fc_mutex);
return g_mutex_trylock (p_ev_fc_mutex);
}
/**
......
......@@ -42,8 +42,21 @@ static GQueue queue_high = G_QUEUE_INIT;
static GQueue queue_low = G_QUEUE_INIT;
static GQueue queue_none = G_QUEUE_INIT;
#if (!GLIB_CHECK_VERSION(2,31,0))
/* Remove this once we bump dependencies to glib >= 2.31.0 */
static GCond *p_job_queue_cond = NULL;
static GMutex *p_job_queue_mutex = NULL;
#else
static GCond job_queue_cond;
static GMutex job_queue_mutex;
/* Remove these defines once we bump dependencies to glib >= 2.31.0
and replace occurences in this file of p_job_queue_{cond|mutex} with
&job_queue_{cond|mutex}.
*/
#define p_job_queue_cond (&job_queue_cond)
#define p_job_queue_mutex (&job_queue_mutex)
#endif
static GQueue *job_queue[EV_JOB_N_PRIORITIES] = {
&queue_urgent,
&queue_high,
......@@ -57,12 +70,12 @@ ev_job_queue_push (EvSchedulerJob *job,
{
ev_debug_message (DEBUG_JOBS, "%s priority %d", EV_GET_TYPE_NAME (job->job), priority);
g_mutex_lock (&job_queue_mutex);
g_mutex_lock (p_job_queue_mutex);
g_queue_push_tail (job_queue[priority], job);
g_cond_broadcast (&job_queue_cond);
g_cond_broadcast (p_job_queue_cond);
g_mutex_unlock (&job_queue_mutex);
g_mutex_unlock (p_job_queue_mutex);
}
static EvSchedulerJob *
......@@ -85,7 +98,14 @@ ev_job_queue_get_next_unlocked (void)
static gpointer
ev_job_scheduler_init (gpointer data)
{
#if (!GLIB_CHECK_VERSION(2,31,0))
/* Remove this once we bump dependencies to glib >= 2.31.0 */
p_job_queue_cond = g_cond_new ();
p_job_queue_mutex = g_mutex_new ();
g_thread_create (ev_job_thread_proxy, NULL, FALSE, NULL);
#else
g_thread_new ("EvJobScheduler", ev_job_thread_proxy, NULL);
#endif
return NULL;
}
......@@ -152,7 +172,7 @@ ev_scheduler_thread_job_cancelled (EvSchedulerJob *job,
ev_debug_message (DEBUG_JOBS, "%s", EV_GET_TYPE_NAME (job->job));
g_mutex_lock (&job_queue_mutex);
g_mutex_lock (p_job_queue_mutex);
/* If the job is not still running,
* remove it from the job queue and job list.
......@@ -162,10 +182,10 @@ ev_scheduler_thread_job_cancelled (EvSchedulerJob *job,
list = g_queue_find (job_queue[job->priority], job);
if (list) {
g_queue_delete_link (job_queue[job->priority], list);
g_mutex_unlock (&job_queue_mutex);
g_mutex_unlock (p_job_queue_mutex);
ev_scheduler_job_destroy (job);
} else {
g_mutex_unlock (&job_queue_mutex);
g_mutex_unlock (p_job_queue_mutex);
}
}
......@@ -205,14 +225,14 @@ ev_job_thread_proxy (gpointer data)
while (TRUE) {
EvSchedulerJob *job;
g_mutex_lock (&job_queue_mutex);
g_mutex_lock (p_job_queue_mutex);
job = ev_job_queue_get_next_unlocked ();
if (!job) {
g_cond_wait (&job_queue_cond, &job_queue_mutex);
g_mutex_unlock (&job_queue_mutex);
g_cond_wait (p_job_queue_cond, p_job_queue_mutex);
g_mutex_unlock (p_job_queue_mutex);
continue;
}
g_mutex_unlock (&job_queue_mutex);
g_mutex_unlock (p_job_queue_mutex);
ev_job_thread (job->job);
ev_scheduler_job_destroy (job);
......@@ -292,7 +312,7 @@ ev_job_scheduler_update_job (EvJob *job,
if (need_resort) {
GList *list;
g_mutex_lock (&job_queue_mutex);
g_mutex_lock (p_job_queue_mutex);
list = g_queue_find (job_queue[s_job->priority], s_job);
if (list) {
......@@ -300,10 +320,10 @@ ev_job_scheduler_update_job (EvJob *job,
EV_GET_TYPE_NAME (job), s_job->priority, priority);
g_queue_delete_link (job_queue[s_job->priority], list);
g_queue_push_tail (job_queue[priority], s_job);
g_cond_broadcast (&job_queue_cond);
g_cond_broadcast (p_job_queue_cond);
}
g_mutex_unlock (&job_queue_mutex);
g_mutex_unlock (p_job_queue_mutex);
}
}
......
......@@ -130,6 +130,13 @@ main (gint argc, gchar **argv)
}
#endif
#if (!GLIB_CHECK_VERSION(2,31,0))
/* Remove this once we bump dependencies to glib >= 2.31.0 */
/* Init glib threads asap */
if (!g_thread_supported ())
g_thread_init (NULL);
#endif
#ifdef ENABLE_NLS
/* Initialize the i18n stuff */
bindtextdomain (GETTEXT_PACKAGE, ev_get_locale_dir());
......
......@@ -260,6 +260,13 @@ main (int argc, char *argv[])
}
#endif
#if (!GLIB_CHECK_VERSION(2,31,0))
/* Remove this once we bump dependencies to glib >= 2.31.0 */
/* Init glib threads asap */
if (!g_thread_supported ())
g_thread_init (NULL);
#endif
#ifdef ENABLE_NLS
/* Initialize the i18n stuff */
bindtextdomain (GETTEXT_PACKAGE, ev_get_locale_dir());
......
......@@ -83,7 +83,12 @@ static void
time_monitor_start (const char *input)
{
finished = FALSE;
g_thread_new ("EvThumbnailerTimer", time_monitor, (gpointer) input);
#if (!GLIB_CHECK_VERSION(2,31,0))
/* Remove this once we bump dependencies to glib >= 2.31.0 */
g_thread_create (time_monitor, (gpointer) input, FALSE, NULL);
#else
g_thread_new ("EvThumbnailerTimer", time_monitor, (gpointer) input);
#endif
}
static void
......@@ -294,6 +299,12 @@ main (int argc, char *argv[])
g_type_init ();
#if (!GLIB_CHECK_VERSION(2,31,0))
/* Remove this once we bump dependencies to glib >= 2.31.0 */
if (!g_thread_supported ())
g_thread_init (NULL);
#endif
if (!ev_init ())
return -1;
......@@ -318,9 +329,15 @@ main (int argc, char *argv[])
data.output = output;
data.size = size;
#if (!GLIB_CHECK_VERSION(2,31,0))
/* Remove this once we bump dependencies to glib >= 2.31.0 */
g_thread_create ((GThreadFunc) evince_thumbnail_pngenc_get_async,
&data, FALSE, NULL);
#else
g_thread_new ("EvThumbanilerAsyncRenderer",
(GThreadFunc) evince_thumbnail_pngenc_get_async,
&data);
(GThreadFunc) evince_thumbnail_pngenc_get_async,
&data);
#endif
gtk_main ();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment