Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <mpg@redhat.com>2007-10-16 09:50:11 (GMT)
committer Marco Pesenti Gritti <mpg@redhat.com>2007-10-16 09:50:11 (GMT)
commit6d2828e54e3de7bdea720f0affec9166ef090a69 (patch)
treefc502e7af84857ea9c5a2ba37151e0e267168423
parentc999a3ca80feccc62c6652553b48f638966fb521 (diff)
Use gdk to get/set X11 properties
-rw-r--r--lib/sugar/Makefile.am4
-rw-r--r--lib/sugar/_sugarext.defs19
-rw-r--r--lib/sugar/_sugarext.override1
-rw-r--r--lib/sugar/sugar-x11-util.c88
-rw-r--r--lib/sugar/sugar-x11-util.h36
-rw-r--r--lib/sugar/wm.py24
6 files changed, 15 insertions, 157 deletions
diff --git a/lib/sugar/Makefile.am b/lib/sugar/Makefile.am
index 69ba27b..8c1946d 100644
--- a/lib/sugar/Makefile.am
+++ b/lib/sugar/Makefile.am
@@ -31,9 +31,7 @@ _sugarext_la_SOURCES = \
sugar-key-grabber.c \
sugar-key-grabber.h \
sugar-menu.h \
- sugar-menu.c \
- sugar-x11-util.c \
- sugar-x11-util.h
+ sugar-menu.c
BUILT_SOURCES = \
_sugarext.c \
diff --git a/lib/sugar/_sugarext.defs b/lib/sugar/_sugarext.defs
index 6a9129d..be5d185 100644
--- a/lib/sugar/_sugarext.defs
+++ b/lib/sugar/_sugarext.defs
@@ -92,25 +92,6 @@
'("guint" "state")
)
)
-; functions
-
-(define-function x11_set_string_property
- (c-name "sugar_x11_util_set_string_property")
- (parameters
- '("GdkWindow*" "window")
- '("const-char*" "property")
- '("const-char*" "value")
- )
-)
-
-(define-function x11_get_string_property
- (c-name "sugar_x11_util_get_string_property")
- (return-type "char*")
- (parameters
- '("GdkWindow*" "window")
- '("const-char*" "property")
- )
-)
;; From sexy-icon-entry.h
diff --git a/lib/sugar/_sugarext.override b/lib/sugar/_sugarext.override
index beeaad0..fbc859b 100644
--- a/lib/sugar/_sugarext.override
+++ b/lib/sugar/_sugarext.override
@@ -7,7 +7,6 @@ headers
#include "sugar-address-entry.h"
#include "sugar-key-grabber.h"
#include "sugar-menu.h"
-#include "sugar-x11-util.h"
#include "sexy-icon-entry.h"
#include <pygtk/pygtk.h>
diff --git a/lib/sugar/sugar-x11-util.c b/lib/sugar/sugar-x11-util.c
deleted file mode 100644
index b57d051..0000000
--- a/lib/sugar/sugar-x11-util.c
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (C) 2006-2007 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 string_atom;
- GdkDisplay *display;
- char *prop_text;
-
- display = gdk_drawable_get_display(window);
- prop_atom = gdk_x11_get_xatom_by_name_for_display(display, property);
- string_atom = gdk_x11_get_xatom_by_name_for_display(display, "STRING");
- prop_text = gdk_utf8_to_string_target(value);
-
- XChangeProperty(GDK_DISPLAY_XDISPLAY(display),
- GDK_WINDOW_XID(window),
- prop_atom,
- string_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 string_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);
- string_atom = gdk_x11_get_xatom_by_name_for_display(display, "STRING");
-
- result = XGetWindowProperty(GDK_DISPLAY_XDISPLAY(display),
- GDK_WINDOW_XID(window),
- prop_atom,
- 0, 1024L,
- False, string_atom,
- &type, &format, &n_items,
- &bytes_after, (unsigned char **)&str);
-
- if (result == Success && str != NULL && type == string_atom &&
- format == 8 && n_items > 0) {
- value = g_strdup(str);
- }
-
- if (str) {
- XFree(str);
- }
-
- return value;
-}
diff --git a/lib/sugar/sugar-x11-util.h b/lib/sugar/sugar-x11-util.h
deleted file mode 100644
index 54655a9..0000000
--- a/lib/sugar/sugar-x11-util.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2006-2007 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__ */
diff --git a/lib/sugar/wm.py b/lib/sugar/wm.py
index 6610889..47356a5 100644
--- a/lib/sugar/wm.py
+++ b/lib/sugar/wm.py
@@ -17,22 +17,26 @@
import gtk
-import _sugarext
-
def get_activity_id(wnck_window):
window = gtk.gdk.window_foreign_new(wnck_window.get_xid())
- return _sugarext.x11_get_string_property(
- window, '_SUGAR_ACTIVITY_ID')
+ prop_info = window.property_get('_SUGAR_ACTIVITY_ID', 'STRING')
+ if prop_info is None:
+ return None
+ else:
+ return prop_info[2]
def get_bundle_id(wnck_window):
window = gtk.gdk.window_foreign_new(wnck_window.get_xid())
- return _sugarext.x11_get_string_property(
- window, '_SUGAR_BUNDLE_ID')
+ prop_info = window.property_get('_SUGAR_BUNDLE_ID', 'STRING')
+ if prop_info is None:
+ return None
+ else:
+ return prop_info[2]
def set_activity_id(window, activity_id):
- _sugarext.x11_set_string_property(
- window, '_SUGAR_ACTIVITY_ID', activity_id)
+ window.property_change('_SUGAR_ACTIVITY_ID', 'STRING', 8,
+ gtk.gdk.PROP_MODE_REPLACE, activity_id)
def set_bundle_id(window, bundle_id):
- _sugarext.x11_set_string_property(
- window, '_SUGAR_BUNDLE_ID', bundle_id)
+ window.property_change('_SUGAR_BUNDLE_ID', 'STRING', 8,
+ gtk.gdk.PROP_MODE_REPLACE, bundle_id)