about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-05-22 19:39:48 +0100
committerJames Booth <boothj5@gmail.com>2014-05-22 19:39:48 +0100
commitb1da6d1bc4591c92ae300d393b44505553e984be (patch)
tree41632cbc0d14689e7c654e811fc57e72d2bf448f
parent86c3dcc2e125b4b7974dac8b1871050a8ec6ccc4 (diff)
downloadprofani-tty-b1da6d1bc4591c92ae300d393b44505553e984be.tar.gz
Added glib g_hash_table_add for glib < 2.32
-rw-r--r--src/common.c7
-rw-r--r--src/common.h6
2 files changed, 12 insertions, 1 deletions
diff --git a/src/common.c b/src/common.c
index be2dd2bf..e54cee6c 100644
--- a/src/common.c
+++ b/src/common.c
@@ -64,7 +64,6 @@ p_utf8_substring(const gchar *str, glong start_pos, glong end_pos)
     return out;
 }
 
-// backwards compatibility for GLib version < 2.28
 void
 p_slist_free_full(GSList *items, GDestroyNotify free_func)
 {
@@ -80,6 +79,12 @@ p_list_free_full(GList *items, GDestroyNotify free_func)
 }
 
 gboolean
+p_hash_table_add(GHashTable *hash_table, gpointer key)
+{
+    return g_hash_table_replace(hash_table, key, key);
+}
+
+gboolean
 create_dir(char *name)
 {
     struct stat sb;
diff --git a/src/common.h b/src/common.h
index 48d6c97e..1c402319 100644
--- a/src/common.h
+++ b/src/common.h
@@ -36,6 +36,10 @@
 #define g_utf8_substring(str, start_pos, end_pos)   p_utf8_substring(str, start_pos, end_pos)
 #endif
 
+#if !GLIB_CHECK_VERSION(2,32,0)
+#define g_hash_table_add(hash_table, key)           p_hash_table_add(hash_table, key)
+#endif
+
 #ifndef NOTIFY_CHECK_VERSION
 #define notify_notification_new(summary, body, icon) notify_notification_new(summary, body, icon, NULL)
 #endif
@@ -74,6 +78,8 @@ typedef enum {
 gchar* p_utf8_substring(const gchar *str, glong start_pos, glong end_pos);
 void p_slist_free_full(GSList *items, GDestroyNotify free_func);
 void p_list_free_full(GList *items, GDestroyNotify free_func);
+gboolean p_hash_table_add(GHashTable *hash_table, gpointer key);
+
 gboolean create_dir(char *name);
 gboolean mkdir_recursive(const char *dir);
 char * str_replace(const char *string, const char *substr,