From cc1b1cd43078c19031c43875a3a1ac68e66316e2 Mon Sep 17 00:00:00 2001 From: Jordan Lee Date: Wed, 24 Jul 2013 00:13:31 +0000 Subject: [PATCH] since Transmission supports older versions of glib, add a portability wrapper for G_DEFINE_QUARK --- gtk/tr-icon.c | 2 +- gtk/tr-window.c | 2 +- gtk/util.c | 2 +- gtk/util.h | 17 +++++++++++++++++ 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/gtk/tr-icon.c b/gtk/tr-icon.c index 097ff9cfc..e0c324114 100644 --- a/gtk/tr-icon.c +++ b/gtk/tr-icon.c @@ -21,7 +21,7 @@ #include "tr-icon.h" #include "util.h" -static G_DEFINE_QUARK (tr_core, core) +static TR_DEFINE_QUARK (tr_core, core) #define ICON_NAME "transmission" diff --git a/gtk/tr-window.c b/gtk/tr-window.c index 80f83924b..94c1991d6 100644 --- a/gtk/tr-window.c +++ b/gtk/tr-window.c @@ -66,7 +66,7 @@ typedef struct } PrivateData; -static G_DEFINE_QUARK (private_data, private_data) +static TR_DEFINE_QUARK (private_data, private_data) static PrivateData* get_private_data (GtkWindow * w) diff --git a/gtk/util.c b/gtk/util.c index d31266cff..3f5180591 100644 --- a/gtk/util.c +++ b/gtk/util.c @@ -664,7 +664,7 @@ freespace_label_data_free (gpointer gdata) g_free (data); } -static G_DEFINE_QUARK (freespace_label_data, freespace_label_data) +static TR_DEFINE_QUARK (freespace_label_data, freespace_label_data) static void on_freespace_label_core_destroyed (gpointer gdata, GObject * dead_core G_GNUC_UNUSED) diff --git a/gtk/util.h b/gtk/util.h index caaf88845..0c5beaae1 100644 --- a/gtk/util.h +++ b/gtk/util.h @@ -37,6 +37,23 @@ extern const char * speed_M_str; extern const char * speed_G_str; extern const char * speed_T_str; +#if GLIB_CHECK_VERSION(2,33,12) + #define TR_DEFINE_QUARK G_DEFINE_QUARK +#else + #define TR_DEFINE_QUARK(QN, q_n) \ + GQuark \ + q_n##_quark (void) \ + { \ + static GQuark q; \ + \ + if G_UNLIKELY (q == 0) \ + q = g_quark_from_static_string (#QN); \ + \ + return q; \ + } +#endif + + /* macro to shut up "unused parameter" warnings */ #ifndef UNUSED #define UNUSED G_GNUC_UNUSED -- 2.40.0