aboutsummaryrefslogtreecommitdiff
path: root/src/glib.h
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2024-08-27 15:50:10 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2024-08-27 15:50:10 +0200
commit79853595a8e4adacddaeffd42f8e4cfdf5f9a5c5 (patch)
tree1a1e7ab8a8a4b703f3237d2ed77ed9f60a2d42fd /src/glib.h
parent4bfbd579171d9194956376c7153f378ff6eb9d4e (diff)
parent1398450b47460ae951f69e410311677cb8fc14a7 (diff)
downloadayatana-settings-79853595a8e4adacddaeffd42f8e4cfdf5f9a5c5.tar.gz
ayatana-settings-79853595a8e4adacddaeffd42f8e4cfdf5f9a5c5.tar.bz2
ayatana-settings-79853595a8e4adacddaeffd42f8e4cfdf5f9a5c5.zip
Merge branch 'pr/full-rewrite'
Attributes GH PR #25: https://github.com/AyatanaIndicators/ayatana-settings/pull/25
Diffstat (limited to 'src/glib.h')
-rw-r--r--src/glib.h61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/glib.h b/src/glib.h
new file mode 100644
index 0000000..be9cb06
--- /dev/null
+++ b/src/glib.h
@@ -0,0 +1,61 @@
+#ifndef __GLIB__
+#define __GLIB__
+
+#include <glib.h>
+#include <gio/gio.h>
+
+G_BEGIN_DECLS
+
+static inline void file_Copy (gchar *sPathIn, gchar *sPathOut)
+{
+ GError *pError = NULL;
+ GFile *pFileIn = g_file_new_for_path (sPathIn);
+ GFile *pFileOut = g_file_new_for_path (sPathOut);
+ g_file_copy (pFileIn, pFileOut, G_FILE_COPY_NONE, NULL, NULL, NULL, &pError);
+ g_object_unref (pFileIn);
+ g_object_unref (pFileOut);
+
+ if (pError)
+ {
+ g_error ("Panic: Failed copying file from %s to %s: %s", sPathIn, sPathOut, pError->message);
+ g_clear_error (&pError);
+
+ return;
+ }
+}
+
+static inline gboolean string_Equal (gchar *sText, gchar *sText2)
+{
+ gint nEquality = g_strcmp0 (sText, sText2);
+
+ return (nEquality == 0);
+}
+
+static inline guint string_Length (gchar *sText)
+{
+ glong nLength = g_utf8_strlen (sText, -1);
+
+ return nLength;
+}
+
+static inline gchar* string_Replace (gchar *sText, gchar *sFind, gchar *sReplace)
+{
+ GString *sString = g_string_new (sText);
+ g_string_replace (sString, sFind, sReplace, 0);
+ gchar *sNewText = g_string_free_and_steal (sString);
+
+ return sNewText;
+}
+
+static inline gchar* string_Remove (gchar *sText, gchar *sRemove)
+{
+ gchar *sNewText = string_Replace (sText, sRemove, "");
+
+ return sNewText;
+}
+
+#define string_ToInt atoi
+
+G_END_DECLS
+
+#endif