summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog13
-rw-r--r--gio/gio-types.defs9
-rw-r--r--gio/gio.override124
3 files changed, 146 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 6909e12..309cfab 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2008-08-05 Paul Pogonyshev <pogonyshev@gmx.net>
+
+ Bug 546135 – GIcon and implementations improvements
+
+ * gio/gio-types.defs (FileIcon): New 'define-object'.
+
+ * gio/gio.override (pygio_do_icon_richcompare)
+ (_wrap_g_icon_tp_richcompare, _wrap_g_icon_tp_hash)
+ (_wrap_g_file_icon_tp_richcompare, _wrap_g_file_icon_tp_hash)
+ (_wrap_g_file_icon_tp_repr, _wrap_g_themed_icon_tp_richcompare)
+ (_wrap_g_themed_icon_tp_hash, _wrap_g_themed_icon_tp_repr): New
+ functions.
+
2008-08-03 Gian Mario Tagliaretti <gianmt@gnome.org>
Bug 546046 – Wrap GFile.replace_async and query_info_async
diff --git a/gio/gio-types.defs b/gio/gio-types.defs
index 00eeaa3..fe55b45 100644
--- a/gio/gio-types.defs
+++ b/gio/gio-types.defs
@@ -216,6 +216,15 @@
(gtype-id "G_TYPE_NATIVE_VOLUME_MONITOR")
)
+(define-object FileIcon
+ (in-module "gio")
+ (parent "GObject")
+ (c-name "GFileIcon")
+ (gtype-id "G_TYPE_FILE_ICON")
+ (implements "GIcon")
+ (implements "GLoadableIcon")
+)
+
(define-object ThemedIcon
(in-module "gio")
(parent "GObject")
diff --git a/gio/gio.override b/gio/gio.override
index 13a4950..6bde819 100644
--- a/gio/gio.override
+++ b/gio/gio.override
@@ -179,6 +179,86 @@ _wrap_g_app_info_get_all_for_type (PyGObject *self, PyObject *args)
return ret;
}
%%
+override-slot GIcon.tp_richcompare
+static PyObject *
+pygio_do_icon_richcompare(PyGObject *self, PyGObject *other, int op)
+{
+ PyObject *result;
+
+ if (PyObject_TypeCheck(self, &PyGIcon_Type)
+ && PyObject_TypeCheck(other, &PyGIcon_Type)) {
+ GIcon *icon1 = G_ICON(self->obj);
+ GIcon *icon2 = G_ICON(other->obj);
+
+ switch (op) {
+ case Py_EQ:
+ result = (g_icon_equal(icon1, icon2)
+ ? Py_True : Py_False);
+ break;
+ case Py_NE:
+ result = (!g_icon_equal(icon1, icon2)
+ ? Py_True : Py_False);
+ break;
+ default:
+ result = Py_NotImplemented;
+ }
+ }
+ else
+ result = Py_NotImplemented;
+
+ Py_INCREF(result);
+ return result;
+}
+static PyObject *
+_wrap_g_icon_tp_richcompare(PyGObject *self, PyGObject *other, int op)
+{
+ return pygio_do_icon_richcompare(self, other, op);
+}
+%%
+override-slot GIcon.tp_hash
+static long
+_wrap_g_icon_tp_hash(PyGObject *self)
+{
+ return g_icon_hash(G_ICON(self->obj));
+}
+%%
+override-slot GFileIcon.tp_richcompare
+/* We need to duplicate, because GIcon is an interface, not a class. */
+static PyObject *
+_wrap_g_file_icon_tp_richcompare(PyGObject *self, PyGObject *other, int op)
+{
+ return pygio_do_icon_richcompare(self, other, op);
+}
+%%
+override-slot GFileIcon.tp_hash
+/* We need to duplicate, because GIcon is an interface, not a class. */
+static long
+_wrap_g_file_icon_tp_hash(PyGObject *self)
+{
+ return g_icon_hash(G_ICON(self->obj));
+}
+%%
+override-slot GFileIcon.tp_repr
+static int
+_wrap_g_file_icon_tp_repr(PyGObject *self)
+{
+ GFile *file = g_file_icon_get_file(G_FILE_ICON(self->obj));
+ char *uri = (file ? g_file_get_uri(file) : NULL);
+ gchar *representation;
+ PyObject *result;
+
+ if (uri) {
+ representation = g_strdup_printf("<%s at %p: %s>", self->ob_type->tp_name, self, uri);
+ g_free(uri);
+ }
+ else
+ representation = g_strdup_printf("<%s at %p: UNKNOWN URI>", self->ob_type->tp_name, self);
+
+ result = PyString_FromString(representation);
+ g_free(representation);
+ return result;
+}
+%%
override g_themed_icon_get_names noargs
static PyObject *
_wrap_g_themed_icon_get_names(PyGObject *self)
@@ -200,6 +280,50 @@ _wrap_g_themed_icon_get_names(PyGObject *self)
return ret;
}
%%
+override-slot GThemedIcon.tp_richcompare
+/* We need to duplicate, because GIcon is an interface, not a class. */
+static PyObject *
+_wrap_g_themed_icon_tp_richcompare(PyGObject *self, PyGObject *other, int op)
+{
+ return pygio_do_icon_richcompare(self, other, op);
+}
+%%
+override-slot GThemedIcon.tp_hash
+/* We need to duplicate, because GIcon is an interface, not a class. */
+static long
+_wrap_g_themed_icon_tp_hash(PyGObject *self)
+{
+ return g_icon_hash(G_ICON(self->obj));
+}
+%%
+override-slot GThemedIcon.tp_repr
+static int
+_wrap_g_themed_icon_tp_repr(PyGObject *self)
+{
+ const char * const *names = g_themed_icon_get_names(G_THEMED_ICON(self->obj));
+ GString *representation = g_string_new(NULL);
+ PyObject *result;
+
+ g_string_append_printf(representation, "<%s at %p: ", self->ob_type->tp_name, self);
+
+ if (names) {
+ gboolean first_name = TRUE;
+ while (*names) {
+ if (!first_name)
+ g_string_append(representation, ", ");
+ else
+ first_name = FALSE;
+
+ g_string_append(representation, *names++);
+ }
+ }
+
+ g_string_append(representation, ">");
+ result = PyString_FromString(representation->str);
+ g_string_free(representation, TRUE);
+ return result;
+}
+%%
override g_content_type_guess kwargs
static PyObject *
_wrap_g_content_type_guess(PyGObject *self, PyObject *args, PyObject *kwargs)