summaryrefslogtreecommitdiff
path: root/src/glib-utils.c
diff options
context:
space:
mode:
authorraveit <[email protected]>2012-11-05 17:14:51 +0100
committerraveit <[email protected]>2012-11-05 17:14:51 +0100
commite06e9b088a12dd098e11110f7d0d77ab8032e4eb (patch)
tree40a96b1b0e2ccd44771f5000e374e1920764ae59 /src/glib-utils.c
parent8f8784ba4ebcd8eb099c4e119a9a8d5a349efd61 (diff)
downloadengrampa-e06e9b088a12dd098e11110f7d0d77ab8032e4eb.tar.bz2
engrampa-e06e9b088a12dd098e11110f7d0d77ab8032e4eb.tar.xz
Port to gsettings
Diffstat (limited to 'src/glib-utils.c')
-rw-r--r--src/glib-utils.c68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/glib-utils.c b/src/glib-utils.c
index a484fcf..176370c 100644
--- a/src/glib-utils.c
+++ b/src/glib-utils.c
@@ -25,12 +25,36 @@
#include <glib.h>
#include <glib/gi18n.h>
#include <glib/gprintf.h>
+#include <glib-object.h>
#include "glib-utils.h"
#define MAX_PATTERNS 128
+/* gobject utils*/
+
+
+gpointer
+_g_object_ref (gpointer object)
+{
+ if (object != NULL)
+ return g_object_ref (object);
+ else
+ return NULL;
+}
+
+
+void
+_g_object_unref (gpointer object)
+{
+ if (object != NULL)
+ g_object_unref (object);
+}
+
+
+/* string utils */
+
gboolean
strchrs (const char *str,
const char *chars)
@@ -643,3 +667,47 @@ g_uri_display_basename (const char *uri)
return name;
}
+
+
+char **
+_g_strv_prepend (char **str_array,
+ const char *str)
+{
+ char **result;
+ int i;
+ int j;
+
+ result = g_new (char *, g_strv_length (str_array) + 1);
+ i = 0;
+ result[i++] = g_strdup (str);
+ for (j = 0; str_array[j] != NULL; j++)
+ result[i++] = g_strdup (str_array[j]);
+ result[i] = NULL;
+
+ return result;
+}
+
+
+gboolean
+_g_strv_remove (char **str_array,
+ const char *str)
+{
+ int i;
+ int j;
+
+ if (str == NULL)
+ return FALSE;
+
+ for (i = 0; str_array[i] != NULL; i++)
+ if (strcmp (str_array[i], str) == 0)
+ break;
+
+ if (str_array[i] == NULL)
+ return FALSE;
+
+ for (j = i; str_array[j] != NULL; j++)
+ str_array[j] = str_array[j + 1];
+
+ return TRUE;
+}
+