[libdazzle] build: port to GLib-2.50
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libdazzle] build: port to GLib-2.50
- Date: Sun, 19 May 2019 03:19:35 +0000 (UTC)
commit b02bcf987a277d106f30b0e72525db43a75d6b9e
Author: Christian Hergert <chergert redhat com>
Date: Sat May 18 20:18:54 2019 -0700
build: port to GLib-2.50
src/dazzle.h | 4 ++--
src/meson.build | 2 +-
src/shortcuts/dzl-shortcut-controller.c | 6 +++---
src/suggestions/dzl-suggestion-popover.c | 6 +++---
src/util/dzl-macros.h | 11 +++++++++--
tests/test-recursive-monitor.c | 21 ++++++++++++++++++++-
6 files changed, 38 insertions(+), 12 deletions(-)
---
diff --git a/src/dazzle.h b/src/dazzle.h
index 60ec635..b206337 100644
--- a/src/dazzle.h
+++ b/src/dazzle.h
@@ -23,11 +23,11 @@
G_BEGIN_DECLS
-#if !GTK_CHECK_VERSION(3, 22, 15)
+#if !GTK_CHECK_VERSION(3, 22, 0)
# error "libdazzle requires gtk+-3.0 >= 3.22.15"
#endif
-#if !GLIB_CHECK_VERSION(2, 52, 0)
+#if !GLIB_CHECK_VERSION(2, 50, 0)
# error "libdazzle requires glib-2.0 >= 2.52.0"
#endif
diff --git a/src/meson.build b/src/meson.build
index 0f054f9..977dc74 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -84,7 +84,7 @@ libdazzle_sources = [
]
libdazzle_deps = [
- dependency('gio-2.0', version: '>=2.56.0'),
+ dependency('gio-2.0', version: '>=2.50.0'),
dependency('gmodule-2.0'),
dependency('gtk+-3.0', version: '>=3.22.0'),
cc.find_library('m', required: false),
diff --git a/src/shortcuts/dzl-shortcut-controller.c b/src/shortcuts/dzl-shortcut-controller.c
index 604bf8f..4d73f6a 100644
--- a/src/shortcuts/dzl-shortcut-controller.c
+++ b/src/shortcuts/dzl-shortcut-controller.c
@@ -259,7 +259,7 @@ dzl_shortcut_controller_widget_destroy (DzlShortcutController *self,
g_assert (GTK_IS_WIDGET (widget));
dzl_shortcut_controller_disconnect (self);
- g_clear_weak_pointer (&priv->widget);
+ dzl_clear_weak_pointer (&priv->widget);
if (priv->root != NULL)
{
@@ -380,12 +380,12 @@ dzl_shortcut_controller_set_widget (DzlShortcutController *self,
if (priv->widget != NULL)
{
dzl_shortcut_controller_disconnect (self);
- g_clear_weak_pointer (&priv->widget);
+ dzl_clear_weak_pointer (&priv->widget);
}
if (widget != NULL && widget != priv->widget)
{
- g_set_weak_pointer (&priv->widget, widget);
+ dzl_set_weak_pointer (&priv->widget, widget);
dzl_shortcut_controller_connect (self);
}
diff --git a/src/suggestions/dzl-suggestion-popover.c b/src/suggestions/dzl-suggestion-popover.c
index bce3c47..243d68c 100644
--- a/src/suggestions/dzl-suggestion-popover.c
+++ b/src/suggestions/dzl-suggestion-popover.c
@@ -598,7 +598,7 @@ dzl_suggestion_popover_destroy (GtkWidget *widget)
{
DzlSuggestionPopover *self = (DzlSuggestionPopover *)widget;
- g_clear_handle_id (&self->queued_popdown, g_source_remove);
+ dzl_clear_source (&self->queued_popdown);
g_clear_object (&self->grab_device);
dzl_suggestion_popover_set_transient_for (self, NULL);
@@ -924,7 +924,7 @@ dzl_suggestion_popover_queue_popdown (DzlSuggestionPopover *self)
{
g_assert (DZL_IS_SUGGESTION_POPOVER (self));
- g_clear_handle_id (&self->queued_popdown, g_source_remove);
+ dzl_clear_source (&self->queued_popdown);
self->queued_popdown = gdk_threads_add_timeout (DELAYED_POPDOWN_MSEC,
dzl_suggestion_popover_do_queued_popdown,
self);
@@ -955,7 +955,7 @@ dzl_suggestion_popover_items_changed (DzlSuggestionPopover *self,
DZL_EXIT;
}
- g_clear_handle_id (&self->queued_popdown, g_source_remove);
+ dzl_clear_source (&self->queued_popdown);
if (self->popup_requested)
{
diff --git a/src/util/dzl-macros.h b/src/util/dzl-macros.h
index 5d65deb..bb36c1c 100644
--- a/src/util/dzl-macros.h
+++ b/src/util/dzl-macros.h
@@ -39,8 +39,15 @@ G_BEGIN_DECLS
#endif
/* These were upstreamed into GLib, just use them */
-#define dzl_clear_weak_pointer(ptr) g_clear_weak_pointer(ptr)
-#define dzl_set_weak_pointer(ptr,obj) g_set_weak_pointer(ptr,obj)
+#if GLIB_CHECK_VERSION(2,56,0)
+# define dzl_clear_weak_pointer(ptr) g_clear_weak_pointer(ptr)
+# define dzl_set_weak_pointer(ptr,obj) g_set_weak_pointer(ptr,obj)
+#else
+# define dzl_clear_weak_pointer(ptr) \
+ (*(ptr) ? (g_object_remove_weak_pointer((GObject*)*(ptr), (gpointer*)ptr),*(ptr)=NULL,1) : 0)
+# define dzl_set_weak_pointer(ptr,obj) \
+
((obj!=*(ptr))?(dzl_clear_weak_pointer(ptr),*(ptr)=obj,((obj)?g_object_add_weak_pointer((GObject*)obj,(gpointer*)ptr),NULL:NULL),1):0)
+#endif
/* A more type-correct form of g_clear_pointer(), to help find bugs.
* GLib ended up with a similar feature which we can rely on now.
diff --git a/tests/test-recursive-monitor.c b/tests/test-recursive-monitor.c
index 1611901..fca3cd8 100644
--- a/tests/test-recursive-monitor.c
+++ b/tests/test-recursive-monitor.c
@@ -29,6 +29,25 @@ failed_timeout (gpointer state)
return G_SOURCE_REMOVE;
}
+G_GNUC_NULL_TERMINATED
+static GFile *
+file_new_build_filename (const gchar *first, ...)
+{
+ g_autoptr(GPtrArray) parts = g_ptr_array_new ();
+ g_autofree gchar *path = NULL;
+ va_list args;
+
+ va_start (args, first);
+ g_ptr_array_add (parts, (gchar *)first);
+ while ((first = va_arg (args, const gchar *)))
+ g_ptr_array_add (parts, (gchar *)first);
+ g_ptr_array_add (parts, NULL);
+
+ path = g_build_filenamev ((gchar **)(gpointer)parts->pdata);
+
+ return g_file_new_for_path (path);
+}
+
static gboolean
begin_test_basic (gpointer data)
{
@@ -170,7 +189,7 @@ test_basic (void)
/* Build our list of directories to create/test */
for (guint i = 0; layer1[i]; i++)
{
- g_autoptr(GFile) file1 = g_file_new_build_filename ("recursive-dir", layer1[i], NULL);
+ g_autoptr(GFile) file1 = file_new_build_filename ("recursive-dir", layer1[i], NULL);
g_queue_push_tail (&state.dirs, g_object_ref (file1));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]