Remove compat code for pre-2.32 glib

Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
This commit is contained in:
Sebastian Ramacher 2015-10-08 21:41:24 +02:00
parent 359fc9a6f2
commit 083520cea6
5 changed files with 16 additions and 44 deletions

2
README
View file

@ -6,7 +6,7 @@ girara user interface library and several document libraries.
Requirements Requirements
------------ ------------
gtk3 gtk3
glib (>= 2.28) glib (>= 2.32)
girara (>= 0.2.4) girara (>= 0.2.4)
sqlite3 (optional, >= 3.5.9) sqlite3 (optional, >= 3.5.9)
check (for tests) check (for tests)

View file

@ -22,7 +22,7 @@ GIRARA_MIN_VERSION = 0.2.4
GIRARA_PKG_CONFIG_NAME = girara-gtk3 GIRARA_PKG_CONFIG_NAME = girara-gtk3
# glib # glib
GLIB_VERSION_CHECK ?= 1 GLIB_VERSION_CHECK ?= 1
GLIB_MIN_VERSION = 2.28 GLIB_MIN_VERSION = 2.32
GLIB_PKG_CONFIG_NAME = glib-2.0 GLIB_PKG_CONFIG_NAME = glib-2.0
# GTK # GTK
GTK_VERSION_CHECK ?= 1 GTK_VERSION_CHECK ?= 1

View file

@ -1,24 +0,0 @@
/* See LICENSE file for license and copyright information */
#ifndef GLIB_COMPAT_H
#define GLIB_COMPAT_H
#include <glib.h>
/* GStaticMutex is deprecated starting with glib 2.32 and got replaced with
* GMutex */
#if GLIB_CHECK_VERSION(2, 32, 0)
#define mutex GMutex
#define mutex_init(m) g_mutex_init((m))
#define mutex_lock(m) g_mutex_lock((m))
#define mutex_unlock(m) g_mutex_unlock((m))
#define mutex_free(m) g_mutex_clear((m))
#else
#define mutex GStaticMutex
#define mutex_init(m) g_static_mutex_init((m))
#define mutex_lock(m) g_static_mutex_lock((m))
#define mutex_unlock(m) g_static_mutex_unlock((m))
#define mutex_free(m) g_static_mutex_free((m))
#endif
#endif

View file

@ -28,9 +28,6 @@ main(int argc, char* argv[])
textdomain(GETTEXT_PACKAGE); textdomain(GETTEXT_PACKAGE);
/* init gtk */ /* init gtk */
#if !GLIB_CHECK_VERSION(2, 31, 0)
g_thread_init(NULL);
#endif
#if !GTK_CHECK_VERSION(3, 6, 0) #if !GTK_CHECK_VERSION(3, 6, 0)
gdk_threads_init(); gdk_threads_init();
#endif #endif

View file

@ -4,7 +4,6 @@
#include <string.h> #include <string.h>
#include <girara/datastructures.h> #include <girara/datastructures.h>
#include <girara/utils.h> #include <girara/utils.h>
#include "glib-compat.h"
#include "render.h" #include "render.h"
#include "adjustment.h" #include "adjustment.h"
@ -34,7 +33,7 @@ static bool page_cache_is_full(ZathuraRenderer* renderer, bool* result);
/* private data for ZathuraRenderer */ /* private data for ZathuraRenderer */
typedef struct private_s { typedef struct private_s {
GThreadPool* pool; /**< Pool of threads */ GThreadPool* pool; /**< Pool of threads */
mutex mutex; /**< Render lock */ GMutex mutex; /**< Render lock */
volatile bool about_to_close; /**< Render thread is to be freed */ volatile bool about_to_close; /**< Render thread is to be freed */
/** /**
@ -68,7 +67,7 @@ typedef struct request_private_s {
zathura_page_t* page; zathura_page_t* page;
gint64 last_view_time; gint64 last_view_time;
girara_list_t* active_jobs; girara_list_t* active_jobs;
mutex jobs_mutex; GMutex jobs_mutex;
} request_private_t; } request_private_t;
#define GET_PRIVATE(obj) \ #define GET_PRIVATE(obj) \
@ -103,7 +102,7 @@ zathura_renderer_init(ZathuraRenderer* renderer)
priv->pool = g_thread_pool_new(render_job, renderer, 1, TRUE, NULL); priv->pool = g_thread_pool_new(render_job, renderer, 1, TRUE, NULL);
priv->about_to_close = false; priv->about_to_close = false;
g_thread_pool_set_sort_function(priv->pool, render_thread_sort, NULL); g_thread_pool_set_sort_function(priv->pool, render_thread_sort, NULL);
mutex_init(&priv->mutex); g_mutex_init(&priv->mutex);
/* recolor */ /* recolor */
priv->recolor.enabled = false; priv->recolor.enabled = false;
@ -161,7 +160,7 @@ renderer_finalize(GObject* object)
if (priv->pool != NULL) { if (priv->pool != NULL) {
g_thread_pool_free(priv->pool, TRUE, TRUE); g_thread_pool_free(priv->pool, TRUE, TRUE);
} }
mutex_free(&(priv->mutex)); g_mutex_free(&(priv->mutex));
free(priv->page_cache.cache); free(priv->page_cache.cache);
girara_list_free(priv->requests); girara_list_free(priv->requests);
@ -265,7 +264,7 @@ zathura_render_request_new(ZathuraRenderer* renderer, zathura_page_t* page)
priv->renderer = g_object_ref(renderer); priv->renderer = g_object_ref(renderer);
priv->page = page; priv->page = page;
priv->active_jobs = girara_list_new(); priv->active_jobs = girara_list_new();
mutex_init(&priv->jobs_mutex); g_mutex_init(&priv->jobs_mutex);
/* register the request with the renderer */ /* register the request with the renderer */
renderer_register_request(renderer, request); renderer_register_request(renderer, request);
@ -299,7 +298,7 @@ render_request_finalize(GObject* object)
girara_error("This should not happen!"); girara_error("This should not happen!");
} }
girara_list_free(priv->active_jobs); girara_list_free(priv->active_jobs);
mutex_free(&priv->jobs_mutex); g_mutex_free(&priv->jobs_mutex);
G_OBJECT_CLASS(zathura_render_request_parent_class)->finalize(object); G_OBJECT_CLASS(zathura_render_request_parent_class)->finalize(object);
} }
@ -407,7 +406,7 @@ zathura_renderer_lock(ZathuraRenderer* renderer)
g_return_if_fail(ZATHURA_IS_RENDERER(renderer)); g_return_if_fail(ZATHURA_IS_RENDERER(renderer));
private_t* priv = GET_PRIVATE(renderer); private_t* priv = GET_PRIVATE(renderer);
mutex_lock(&priv->mutex); g_mutex_lock(&priv->mutex);
} }
void void
@ -416,7 +415,7 @@ zathura_renderer_unlock(ZathuraRenderer* renderer)
g_return_if_fail(ZATHURA_IS_RENDERER(renderer)); g_return_if_fail(ZATHURA_IS_RENDERER(renderer));
private_t* priv = GET_PRIVATE(renderer); private_t* priv = GET_PRIVATE(renderer);
mutex_unlock(&priv->mutex); g_mutex_unlock(&priv->mutex);
} }
void void
@ -435,7 +434,7 @@ zathura_render_request(ZathuraRenderRequest* request, gint64 last_view_time)
g_return_if_fail(ZATHURA_IS_RENDER_REQUEST(request)); g_return_if_fail(ZATHURA_IS_RENDER_REQUEST(request));
request_private_t* request_priv = REQUEST_GET_PRIVATE(request); request_private_t* request_priv = REQUEST_GET_PRIVATE(request);
mutex_lock(&request_priv->jobs_mutex); g_mutex_lock(&request_priv->jobs_mutex);
bool unfinished_jobs = false; bool unfinished_jobs = false;
/* check if there are any active jobs left */ /* check if there are any active jobs left */
@ -462,7 +461,7 @@ zathura_render_request(ZathuraRenderRequest* request, gint64 last_view_time)
g_thread_pool_push(priv->pool, job, NULL); g_thread_pool_push(priv->pool, job, NULL);
} }
mutex_unlock(&request_priv->jobs_mutex); g_mutex_unlock(&request_priv->jobs_mutex);
} }
void void
@ -471,11 +470,11 @@ zathura_render_request_abort(ZathuraRenderRequest* request)
g_return_if_fail(ZATHURA_IS_RENDER_REQUEST(request)); g_return_if_fail(ZATHURA_IS_RENDER_REQUEST(request));
request_private_t* request_priv = REQUEST_GET_PRIVATE(request); request_private_t* request_priv = REQUEST_GET_PRIVATE(request);
mutex_lock(&request_priv->jobs_mutex); g_mutex_lock(&request_priv->jobs_mutex);
GIRARA_LIST_FOREACH(request_priv->active_jobs, render_job_t*, iter, job) GIRARA_LIST_FOREACH(request_priv->active_jobs, render_job_t*, iter, job)
job->aborted = true; job->aborted = true;
GIRARA_LIST_FOREACH_END(request_priv->active_jobs, render_job_t*, iter, job); GIRARA_LIST_FOREACH_END(request_priv->active_jobs, render_job_t*, iter, job);
mutex_unlock(&request_priv->jobs_mutex); g_mutex_unlock(&request_priv->jobs_mutex);
} }
void void
@ -494,9 +493,9 @@ remove_job_and_free(render_job_t* job)
{ {
request_private_t* request_priv = REQUEST_GET_PRIVATE(job->request); request_private_t* request_priv = REQUEST_GET_PRIVATE(job->request);
mutex_lock(&request_priv->jobs_mutex); g_mutex_lock(&request_priv->jobs_mutex);
girara_list_remove(request_priv->active_jobs, job); girara_list_remove(request_priv->active_jobs, job);
mutex_unlock(&request_priv->jobs_mutex); g_mutex_unlock(&request_priv->jobs_mutex);
g_object_unref(job->request); g_object_unref(job->request);
g_free(job); g_free(job);