From 7127a46033f3d49eb08561cd30040a51c1114d0d Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Fri, 30 Aug 2013 19:25:24 +0200 Subject: [PATCH] Fix deprecated gdk thread function calls Signed-off-by: Sebastian Ramacher --- callbacks.c | 13 +++++++++---- main.c | 8 +++++++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/callbacks.c b/callbacks.c index 31364ec..14a629b 100644 --- a/callbacks.c +++ b/callbacks.c @@ -107,7 +107,7 @@ cb_view_vadjustment_value_changed(GtkAdjustment* GIRARA_UNUSED(adjustment), gpoi } } else { zathura_page_set_visibility(page, false); - /* If a page becomes invisible, abort all render requests. */ + /* If a page becomes invisible, abort the render request. */ zathura_page_widget_abort_render_request(zathura_page_widget); /* if the page is not visible and not cached, but still has a surface, we * need to get rid of the surface */ @@ -370,6 +370,13 @@ cb_sc_display_link(GtkEntry* entry, girara_session_t* session) return handle_link(entry, session, ZATHURA_LINK_ACTION_DISPLAY); } +static gboolean +file_monitor_reload(void* data) +{ + sc_reload((girara_session_t*) data, NULL, NULL, 0); + return FALSE; +} + void cb_file_monitor(GFileMonitor* monitor, GFile* file, GFile* UNUSED(other_file), GFileMonitorEvent event, girara_session_t* session) { @@ -380,9 +387,7 @@ cb_file_monitor(GFileMonitor* monitor, GFile* file, GFile* UNUSED(other_file), G switch (event) { case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT: case G_FILE_MONITOR_EVENT_CREATED: - gdk_threads_enter(); - sc_reload(session, NULL, NULL, 0); - gdk_threads_leave(); + g_main_context_invoke(NULL, file_monitor_reload, session); break; default: return; diff --git a/main.c b/main.c index 26d561a..692aa67 100644 --- a/main.c +++ b/main.c @@ -25,7 +25,9 @@ main(int argc, char* argv[]) #if !GLIB_CHECK_VERSION(2, 31, 0) g_thread_init(NULL); #endif +#if !GTK_CHECK_VERSION(3, 6, 0) gdk_threads_init(); +#endif gtk_init(&argc, &argv); /* create zathura session */ @@ -46,7 +48,7 @@ main(int argc, char* argv[]) bool synctex = false; int page_number = ZATHURA_PAGE_NUMBER_UNSPECIFIED; -#if (GTK_MAJOR_VERSION == 3) +#if GTK_CHECK_VERSION(3, 0, 0) Window embed = 0; #else GdkNativeWindow embed = 0; @@ -148,9 +150,13 @@ main(int argc, char* argv[]) } /* run zathura */ +#if !GTK_CHECK_VERSION(3, 6, 0) gdk_threads_enter(); +#endif gtk_main(); +#if !GTK_CHECK_VERSION(3, 6, 0) gdk_threads_leave(); +#endif /* free zathura */ zathura_free(zathura);