Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@localhost.localdomain>2007-06-01 18:38:30 (GMT)
committer Marco Pesenti Gritti <marco@localhost.localdomain>2007-06-01 18:38:30 (GMT)
commit5cc9a8c42437376ccef2fbe578a637f8ab3396b5 (patch)
treeb6494791f0382349b04d0605bd3da87469c233f4 /lib
parentd4bd7a5d05f251cdf90c0f656f0498df05b4e5b1 (diff)
Bindings to set activity_id and bundle_id hints
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile.am4
-rw-r--r--lib/sugar-x11-util.c88
-rw-r--r--lib/sugar-x11-util.h36
3 files changed, 127 insertions, 1 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am
index f709c58..cd0d457 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -11,4 +11,6 @@ libsugar_la_LIBADD = \
libsugar_la_SOURCES = \
sugar-address-entry.c \
- sugar-address-entry.h
+ sugar-address-entry.h \
+ sugar-x11-util.c \
+ sugar-x11-util.h
diff --git a/lib/sugar-x11-util.c b/lib/sugar-x11-util.c
new file mode 100644
index 0000000..bc0f693
--- /dev/null
+++ b/lib/sugar-x11-util.c
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2006, Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <gdk/gdkproperty.h>
+#include <X11/Xatom.h>
+#include <glib/gstrfuncs.h>
+#include <string.h>
+
+#include "sugar-x11-util.h"
+
+void
+sugar_x11_util_set_string_property(GdkWindow *window,
+ const char *property,
+ const char *value)
+{
+ Atom prop_atom;
+ Atom utf8_atom;
+ GdkDisplay *display;
+ char *prop_text;
+
+ display = gdk_drawable_get_display(window);
+ prop_atom = gdk_x11_get_xatom_by_name_for_display(display, property);
+ utf8_atom = gdk_x11_get_xatom_by_name_for_display(display, "UTF8_ATOM");
+ prop_text = gdk_utf8_to_string_target(value);
+
+ XChangeProperty(GDK_DISPLAY_XDISPLAY(display),
+ GDK_WINDOW_XID(window),
+ prop_atom,
+ utf8_atom, 8,
+ PropModeReplace, prop_text,
+ strlen(prop_text));
+
+ g_free(prop_text);
+}
+
+char *
+sugar_x11_util_get_string_property(GdkWindow *window,
+ const char *property)
+{
+ Atom type;
+ Atom prop_atom;
+ Atom utf8_atom;
+ int format;
+ int result;
+ unsigned long bytes_after, n_items;
+ unsigned char *str = NULL;
+ char *value = NULL;
+ GdkDisplay *display;
+
+ display = gdk_drawable_get_display(window);
+ prop_atom = gdk_x11_get_xatom_by_name_for_display(display, property);
+ utf8_atom = gdk_x11_get_xatom_by_name_for_display(display, "UTF8_ATOM");
+
+ result = XGetWindowProperty(GDK_DISPLAY_XDISPLAY(display),
+ GDK_WINDOW_XID(window),
+ prop_atom,
+ 0, 1024L,
+ False, utf8_atom,
+ &type, &format, &n_items,
+ &bytes_after, (unsigned char **)&str);
+
+ if (result == Success && str != NULL && type == utf8_atom &&
+ format == 8 && n_items > 0) {
+ value = g_strdup(str);
+ }
+
+ if (str) {
+ XFree(str);
+ }
+
+ return value;
+}
diff --git a/lib/sugar-x11-util.h b/lib/sugar-x11-util.h
new file mode 100644
index 0000000..aa61870
--- /dev/null
+++ b/lib/sugar-x11-util.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2006, Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __SUGAR_X11_UTIL_H__
+#define __SUGAR_X11_UTIL_H__
+
+#include <gdk/gdkx.h>
+
+G_BEGIN_DECLS
+
+void sugar_x11_util_set_string_property(GdkWindow *window,
+ const char *property,
+ const char *value);
+
+char *sugar_x11_util_get_string_property(GdkWindow *window,
+ const char *property);
+
+G_END_DECLS
+
+#endif /* __SUGAR_ADDRESS_ENTRY_H__ */