From d2445459797fd34b2d78b389259c26dabbcbbfb9 Mon Sep 17 00:00:00 2001 From: Jordan Lee Date: Tue, 9 Jul 2013 22:44:24 +0000 Subject: [PATCH] use G_DEFINE_QUARK instead of rolling our own quark getters --- gtk/tr-icon.c | 17 ++++------------- gtk/tr-window.c | 15 +++------------ gtk/util.c | 11 +---------- 3 files changed, 8 insertions(+), 35 deletions(-) diff --git a/gtk/tr-icon.c b/gtk/tr-icon.c index 7750bceb8..6030242ec 100644 --- a/gtk/tr-icon.c +++ b/gtk/tr-icon.c @@ -21,16 +21,7 @@ #include "tr-icon.h" #include "util.h" -static GQuark -get_core_quark (void) -{ - static GQuark quark = 0; - - if (!quark) - quark = g_quark_from_static_string ("tr-core"); - - return quark; -} +static G_DEFINE_QUARK (tr-core, core) #define ICON_NAME "transmission" @@ -71,7 +62,7 @@ gtr_icon_refresh (gpointer vicon) char tip[1024]; const char * idle = _("Idle"); GtkStatusIcon * icon = GTK_STATUS_ICON (vicon); - tr_session * session = gtr_core_session (g_object_get_qdata (G_OBJECT (icon), get_core_quark ())); + tr_session * session = gtr_core_session (g_object_get_qdata (G_OBJECT (icon), core_quark ())); /* up */ KBps = tr_sessionGetRawSpeed_KBps (session, TR_UP); @@ -154,14 +145,14 @@ gtr_icon_new (TrCore * core) w = gtr_action_get_widget ("/icon-popup"); app_indicator_set_menu (indicator, GTK_MENU (w)); app_indicator_set_title (indicator, g_get_application_name ()); - g_object_set_qdata (G_OBJECT (indicator), get_core_quark (), core); + g_object_set_qdata (G_OBJECT (indicator), core_quark (), core); return indicator; #else const char * icon_name = getIconName (); GtkStatusIcon * icon = gtk_status_icon_new_from_icon_name (icon_name); g_signal_connect (icon, "activate", G_CALLBACK (activated), NULL); g_signal_connect (icon, "popup-menu", G_CALLBACK (popup), NULL); - g_object_set_qdata (G_OBJECT (icon), get_core_quark (), core); + g_object_set_qdata (G_OBJECT (icon), core_quark (), core); return icon; #endif } diff --git a/gtk/tr-window.c b/gtk/tr-window.c index c4e1232fb..1fdf0a118 100644 --- a/gtk/tr-window.c +++ b/gtk/tr-window.c @@ -66,21 +66,12 @@ typedef struct } PrivateData; -static GQuark -get_private_data_key (void) -{ - static GQuark q = 0; - - if (!q) - q = g_quark_from_static_string ("private-data"); - - return q; -} +static G_DEFINE_QUARK (private-data, private_data) static PrivateData* get_private_data (GtkWindow * w) { - return g_object_get_qdata (G_OBJECT (w), get_private_data_key ()); + return g_object_get_qdata (G_OBJECT (w), private_data_quark ()); } /*** @@ -620,7 +611,7 @@ gtr_window_new (GtkApplication * app, GtkUIManager * ui_mgr, TrCore * core) /* make the window */ self = gtk_application_window_new (app); - g_object_set_qdata_full (G_OBJECT (self), get_private_data_key (), p, privateFree); + g_object_set_qdata_full (G_OBJECT (self), private_data_quark (), p, privateFree); win = GTK_WINDOW (self); gtk_window_set_title (win, g_get_application_name ()); gtk_window_set_role (win, "tr-main"); diff --git a/gtk/util.c b/gtk/util.c index 6c89f717e..4f09330a4 100644 --- a/gtk/util.c +++ b/gtk/util.c @@ -664,16 +664,7 @@ freespace_label_data_free (gpointer gdata) g_free (data); } -static GQuark -freespace_label_data_quark (void) -{ - static GQuark q = 0; - - if (G_UNLIKELY(!q)) - q = g_quark_from_static_string ("data"); - - return q; -} +static G_DEFINE_QUARK (freespace-label-data, freespace_label_data) static void on_freespace_label_core_destroyed (gpointer gdata, GObject * dead_core G_GNUC_UNUSED) -- 2.40.0