pygobject r924 - in trunk: . gio
- From: paulp svn gnome org
- To: svn-commits-list gnome org
- Subject: pygobject r924 - in trunk: . gio
- Date: Tue, 5 Aug 2008 20:39:27 +0000 (UTC)
Author: paulp
Date: Tue Aug 5 20:39:27 2008
New Revision: 924
URL: http://svn.gnome.org/viewvc/pygobject?rev=924&view=rev
Log:
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.
Modified:
trunk/ChangeLog
trunk/gio/gio-types.defs
trunk/gio/gio.override
Modified: trunk/gio/gio-types.defs
==============================================================================
--- trunk/gio/gio-types.defs (original)
+++ trunk/gio/gio-types.defs Tue Aug 5 20:39:27 2008
@@ -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")
Modified: trunk/gio/gio.override
==============================================================================
--- trunk/gio/gio.override (original)
+++ trunk/gio/gio.override Tue Aug 5 20:39:27 2008
@@ -179,6 +179,86 @@
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 @@
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)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]