From: DongHun Kwak Date: Tue, 11 Jul 2017 23:35:52 +0000 (+0900) Subject: Imported Upstream version 2.27.91 X-Git-Tag: upstream/3.9.92~98 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c79482ebfe55da780fd2d733696f5107dc4d5cb8;p=platform%2Fupstream%2Fpygobject2.git Imported Upstream version 2.27.91 Change-Id: I3788dba2f5257cabaed71dd66932f46025d61a4e Signed-off-by: DongHun Kwak --- diff --git a/ChangeLog b/ChangeLog index b138b03..5ddfa44 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,727 @@ +commit 093334ee29b5846ff57b4e9f74380efc9ed591e7 +Author: John (J5) Palmieri +Date: Mon Feb 28 14:16:00 2011 -0500 + + prep for 2.27.91 release + + NEWS | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 files changed, 50 insertions(+), 0 deletions(-) + +commit 4b49a4f6123f0bbd5a36eba65b00142e3df7e595 +Author: John (J5) Palmieri +Date: Mon Feb 28 14:08:05 2011 -0500 + + [gi-tests] use Gdk.test_simulate_button instead of emitting event + ourselves + + * this function is available specifically so we can test events so + use this + instead of creating our own button press event + + tests/test_overrides.py | 9 +++++---- + 1 files changed, 5 insertions(+), 4 deletions(-) + +commit baa9865e6ff8b4eee4b16235b8dcc5dc48d2634d +Author: Laszlo Pandy +Date: Thu Feb 24 19:30:32 2011 +0100 + + [gi-tests] tests for EventButton override. + + * John (J5) Palmieri - fixed up original patch so that we actually + emit the event instead of just creating a Gdk.ButtonEvent object + + https://bugzilla.gnome.org/show_bug.cgi?id=642554 + + tests/test_overrides.py | 21 +++++++++++++++++++++ + 1 files changed, 21 insertions(+), 0 deletions(-) + +commit 6366307ba020a40f6dfa22e64fd6345b118fd2e5 +Author: Tomeu Vizoso +Date: Wed Feb 16 09:44:12 2011 +0100 + + Skip interfaces when checking for conflicts in the MRO + + https://bugzilla.gnome.org/show_bug.cgi?id=642437 + + gi/types.py | 40 ++++++++++++++++++++++++++++++++++++++++ + gobject/gobjectmodule.c | 9 +++++++-- + tests/test_gi.py | 16 ++++++++++++++++ + 3 files changed, 63 insertions(+), 2 deletions(-) + +commit 14c787541966be8f497905d33d554343dabf8b73 +Author: John (J5) Palmieri +Date: Wed Feb 23 18:43:27 2011 -0500 + + [gi-overrides] Add event methods to all event union members + + https://bugzilla.gnome.org/show_bug.cgi?id=642554 + + gi/overrides/Gdk.py | 70 + +++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 files changed, 70 insertions(+), 0 deletions(-) + +commit 7f013383063c1d1e5a95cf4c056ff152d4aa2645 +Author: John (J5) Palmieri +Date: Wed Feb 23 14:14:16 2011 -0500 + + [gi] check to see if object is a member of a union when validating + paramaters + + * union members are not subclasses of the union they belong to so + if an + inteface requires you pass a union but you pass one of its members + there will be a type error + * this patch checks to see if the type you are passing is a member + of the + union and passes the checks if it is + * this works in python 3 but in python 2 methods do their own + isinstance + check on the instance parameter (e.g. self) so we need to figure + out how to override that for union methods + (e.g. Gdk.Event.get_state) + + https://bugzilla.gnome.org/show_bug.cgi?id=642554 + + gi/pygi-argument.c | 38 ++++++++++++++++++++++++++++++++++++++ + 1 files changed, 38 insertions(+), 0 deletions(-) + +commit 284e775b6caa86ef6465d17c87ec77376e66931c +Author: Laszlo Pandy +Date: Thu Feb 24 18:46:15 2011 +0100 + + [gi] Remove DyanmicModule.load() to _load() to prevent overriding + GI attrs. + + gi/importer.py | 2 +- + gi/module.py | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit 6d6d4fcf4678b512558c2c0e44c0c2e235c810f4 +Author: Laszlo Pandy +Date: Wed Feb 23 12:05:03 2011 +0100 + + Test case with John's fix for crash with C arrays and a GError is set. + + I have added a test case, and made a few fixes to John's patch, + but the + solution is the same his. + + Workaround a bug when freeing C array types + + * This is a hack and there is really no way around it without + ripping out + the current array handling code which spans between pygi-invoke.c + and + pygi-argument.c and completely rewriting it. + * The is no time before our stable release + * This patch trades a segfault for a leak in the very unusual + case where + an error occures inside an interface that takes one or more C + arrays. Since + we wrap C arrays in GArrays internally but have to unwrap them + to send them + to the introspected C function, there is a period of time where + an error + can occure with the C array in an unknown state (some being true + C arrays + and others still wrapped in a GArray) + * This patch adds a c_arrays_are_wrapped state to signal that it + is safe to + free them. However since c_arrays_are_wrapped can only track + arrays + as a group, not individually, if it is set to FALSE we can + not assume + that every array is a pure C array, so instead we will simply + leak them + to avoid incorrectly freeing one and causing a segfault. + * This issue is fixed in the invoke rewrite branch as it treats + C arrays and + GArrays separately, however that branch is not yet ready to be + merged and + won't be until the next release. + + https://bugzilla.gnome.org/show_bug.cgi?id=642708 + + gi/pygi-invoke.c | 54 + ++++++++++++++++++++++++++++++++++++++++++++++++++---- + tests/test_gi.py | 9 +++++++++ + 2 files changed, 59 insertions(+), 4 deletions(-) + +commit 3534c1d4babefd4ee63e46119b279126058b7a71 +Author: John (J5) Palmieri +Date: Wed Feb 23 15:11:59 2011 -0500 + + [gi-overrides] fix setting rows in treeview to accept None as a value + + * as done in PyGTK None indicates the column should not be set + + gi/overrides/Gtk.py | 3 +++ + tests/test_overrides.py | 18 +++++++++++++----- + 2 files changed, 16 insertions(+), 5 deletions(-) + +commit ecbfaf60914a87f29ff0529614db9b6afca94c82 +Author: Laszlo Pandy +Date: Wed Feb 23 14:23:19 2011 +0100 + + [gi] Add value_name for enum and flags from introspection + "c:identifier" (if attr is available). + + gi/gimodule.c | 22 ++++++++++++++++++---- + tests/test_gi.py | 36 ++++++++++++++++++++++++++++++++++++ + 2 files changed, 54 insertions(+), 4 deletions(-) + +commit e5ae620ad772f62cb14ab7c049ba0ce00cc501f2 +Author: Laszlo Pandy +Date: Tue Feb 22 21:37:33 2011 +0100 + + Don't force loading of DynamicModule until set in sys.modules + + This fixes Tomeu's previous commit, which removed lazy loading. + Forcing the loading of a module before it is installed in sys.modules + prevents some overrides from being registered (namely Gtk.main_quit). + + https://bugzilla.gnome.org/show_bug.cgi?id=642305 + + gi/importer.py | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +commit 992c0c1096c77bc299a40a34ec30a2ac0c562ed4 +Author: Laszlo Pandy +Date: Wed Feb 23 11:40:55 2011 +0100 + + Fix flags with multiple names for the same value. + + Flags constructs a dict __flags_values__ and uses it to cache + instances. However some flags in Glib such as G_IO_FLAG_MASK and + G_IO_FLAG_GET_MASK are aliases for the same int value, and will + override each other's place in the dictionary. + + The dict length check is not necessary. It only reduces the number + of duplicate instances we keep, because if an instance is not + found in the dict, a new one is created anyway. + + gobject/pygflags.c | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +commit 8bf3f6ed075994eb3e29950670395bcf1b9dc2a0 +Author: John (J5) Palmieri +Date: Tue Feb 22 15:07:40 2011 -0500 + + [gi-demos] add liststore demo + + demos/gtk-demo/demos/Tree View/liststore.py | 205 + +++++++++++++++++++++++++++ + 1 files changed, 205 insertions(+), 0 deletions(-) + +commit 788fc96771046fc64cede392e748b2d1b6b3aa1c +Author: John (J5) Palmieri +Date: Tue Feb 22 14:35:44 2011 -0500 + + [gi-demos] run through the demos and remove the FIXMEs that have + been fixed + + demos/gtk-demo/demos/appwindow.py | 18 ++++++------------ + demos/gtk-demo/demos/assistant.py | 3 --- + demos/gtk-demo/demos/builder.py | 3 --- + demos/gtk-demo/demos/button_box.py | 10 +++------- + demos/gtk-demo/demos/clipboard.py | 8 ++------ + demos/gtk-demo/demos/colorselector.py | 2 -- + demos/gtk-demo/demos/combobox.py | 4 +--- + demos/gtk-demo/demos/drawingarea.py | 3 --- + 8 files changed, 12 insertions(+), 39 deletions(-) + +commit adf7aec853878681b450c3ef1f89bfe9ba85fec1 +Author: Tomeu Vizoso +Date: Wed Feb 16 11:53:18 2011 +0100 + + Load typelibs at import time, add gi.require_version() + + also adds Repository.get_loaded_namespaces() + + https://bugzilla.gnome.org/show_bug.cgi?id=642305 + + gi/__init__.py | 29 ++++++++++++++++++++++++++++- + gi/importer.py | 1 + + gi/module.py | 21 ++++----------------- + gi/pygi-repository.c | 23 +++++++++++++++++++++++ + 4 files changed, 56 insertions(+), 18 deletions(-) + +commit 6fe7783b96366f380f9168909932a87e35d994b3 +Author: John (J5) Palmieri +Date: Mon Feb 21 17:20:57 2011 -0500 + + use GValue support to marshal GtkTreeModel values correctly + + * needs patch from https://bugzilla.gnome.org/show_bug.cgi?id=642914 + + https://bugzilla.gnome.org/show_bug.cgi?id=642921 + + gi/overrides/Gtk.py | 37 ++++++++++++++++++-- + tests/test_overrides.py | 87 + ++++++++++++++++++++++++++++++++++++++++------- + 2 files changed, 107 insertions(+), 17 deletions(-) + +commit bc4a570bcc0a02029d746fbbcfdf4cc14c37f2ad +Author: John (J5) Palmieri +Date: Mon Feb 21 16:14:20 2011 -0500 + + [gi] pass raw GValues instead of trying to marshal them + + * Right now GValues are transparent to the user but this leave us no + way to describe fundimental types other than those supported + directly + by python (e.g. int, str, etc) + * If an interface is expecting a uint or other GValue type a user + can now use + the raw GValue interfaces and expect paramaters that take + GValues to + marshal them correctly e.g.: + value = GObject.Value() + value.int(GObject.TYPE_UINT) + value.set_uint(1234) + * The objective here is to not for users to use this API but for + overrides + to be able to utilize them. For instance in the TreeModel API + we can + get the expected type for a column and them create a GValue with + the correct + type so that he underlying python object is marshalled correctly. + + https://bugzilla.gnome.org/show_bug.cgi?id=642914 + + gi/pygi-argument.c | 24 ++++++++++++++++++------ + tests/test_gi.py | 9 ++++++++- + 2 files changed, 26 insertions(+), 7 deletions(-) + +commit 428fc90eb12f26ceb7c868879ad05788890d32a3 +Author: John (J5) Palmieri +Date: Sat Feb 19 19:42:41 2011 -0500 + + [gi-demos] add icon view edit and drag-and-drop demo + + demos/gtk-demo/demos/Icon View/iconviewedit.py | 101 + ++++++++++++++++++++++++ + 1 files changed, 101 insertions(+), 0 deletions(-) + +commit eb0e179bff167303db1c20412f4bc9c8baa94582 +Author: Laszlo Pandy +Date: Sat Feb 19 23:11:25 2011 +0100 + + [gi] Register GType for non-GType enums and flags at runtime. + + Note: rebuild of gobject-introspection is required for new tests. + + Previously non-GType enums used a separate type implemented in + Python, and non-GType flags had no implementation at all. This + removes the separate type for enums, and registers a new GType at + runtime if there isn't one. + + This allows non-GType enums and flags to use the same Python type + as GType enums and flags. This removes duplication of code, and + make both kinds behave identically. + + https://bugzilla.gnome.org/show_bug.cgi?id=642607 + + gi/gimodule.c | 117 + ++++++++++++++++++++++++++++++++++++++++++++++++++++ + gi/module.py | 24 +++++++---- + gi/pygi-info.c | 15 +++++++ + gi/types.py | 16 ------- + gobject/pygflags.c | 13 ++++-- + tests/test_gi.py | 35 +++++++++++++++ + 6 files changed, 191 insertions(+), 29 deletions(-) + +commit d5e67257361609036d2bbfa47ea85a6c759b332a +Author: John (J5) Palmieri +Date: Sat Feb 19 17:26:42 2011 -0500 + + [gi-demos] add info bars demo + + demos/gtk-demo/demos/infobars.py | 99 + ++++++++++++++++++++++++++++++++++++++ + 1 files changed, 99 insertions(+), 0 deletions(-) + +commit 372f480b078d1befb30532a0ebe0ad9c90e78df0 +Author: Martin Pitt +Date: Sat Feb 19 15:44:52 2011 +0100 + + tests/runtests.py: Add missing "import sys" + + master already has this. + + tests/runtests.py | 1 + + 1 files changed, 1 insertions(+), 0 deletions(-) + +commit c1b35fc49680ad25e996de57e3e020bd43d9186c +Author: Martin Pitt +Date: Tue Feb 8 15:38:21 2011 +0100 + + [gi] Add Pythonic gdbus method invocation + + Provide a wrapper for Gio.DBusProxy for calling D-Bus methods like + on a normal + Python object. This will handle the Python object <-> GVariant + conversion, and + optional keyword arguments for flags, timeout, and a result handler + for + asynchronous calls. + + Require specifying the input argument signature as the first argument + of each + method call. This ensures that the types of e. g. integers are + always correct, + and avoids having to do expensive D-Bus introspection for each call. + + https://bugzilla.gnome.org/show_bug.cgi?id=640181 + + gi/overrides/Gio.py | 99 + +++++++++++++++++++++++++++++++++++++++++++++++++ + tests/test_gdbus.py | 102 + ++++++++++++++++++++++++++++++++++++++++++++++++++- + 2 files changed, 199 insertions(+), 2 deletions(-) + +commit 2737e1c2c506cd324a0aa2abfdfeb3ad4f08e678 +Author: Laszlo Pandy +Date: Fri Feb 18 22:48:59 2011 +0100 + + Skip GError out parameters in Python closure. + + Python code should have never have to explicitely return a GError. + Once we are able to marshal exceptions the Python code should + throw an exception instead. Until then, set GError to NULL, and + don't complain if a Python function doesn't return an arg for it. + + https://bugzilla.gnome.org/show_bug.cgi?id=642715 + + gi/pygi-closure.c | 8 ++++++++ + 1 files changed, 8 insertions(+), 0 deletions(-) + +commit 93677502c12a3ee123dd565bf1b404ef47ec1c47 +Author: John (J5) Palmieri +Date: Thu Feb 17 19:46:49 2011 -0500 + + [gi-demos] added rotate text demo + + * needs some Pango Attr fixes to be 100% done, See FIXME + + demos/gtk-demo/demos/rotatedtext.py | 196 + +++++++++++++++++++++++++++++++++++ + 1 files changed, 196 insertions(+), 0 deletions(-) + +commit 8495ab57f49fb507a8004a9cf967d6fe91bb4ef0 +Author: John (J5) Palmieri +Date: Thu Feb 17 17:25:00 2011 -0500 + + [gi-demos] add images demo + + * needs annotation fix from GdkPixbuf for ImageLoader to work + + demos/gtk-demo/demos/images.py | 311 + ++++++++++++++++++++++++++++++++++++++++ + 1 files changed, 311 insertions(+), 0 deletions(-) + +commit 60b9dd8d021e550089f44dc489ffeb77af6976ee +Author: John (J5) Palmieri +Date: Thu Feb 17 14:48:24 2011 -0500 + + [gi-demos] add pixbuf demo + + demos/gtk-demo/demos/pixbuf.py | 183 + ++++++++++++++++++++++++++++++++++++++++ + 1 files changed, 183 insertions(+), 0 deletions(-) + +commit f57153dd6786858ff2ab79c28227cd021755d693 +Author: John (J5) Palmieri +Date: Thu Feb 17 14:47:12 2011 -0500 + + [gi-demos] remove fixmes from print demo, fixed in pango + + demos/gtk-demo/demos/printing.py | 10 +++------- + 1 files changed, 3 insertions(+), 7 deletions(-) + +commit b8345be15c7f65e97f6bc148ad6c35ff80ff3870 +Author: John (J5) Palmieri +Date: Wed Feb 16 19:39:30 2011 -0500 + + [gi-demos] add printing demo + + * needs some annotations for pango before it is 100% useful + + demos/gtk-demo/demos/printing.py | 177 + ++++++++++++++++++++++++++++++++++++++ + 1 files changed, 177 insertions(+), 0 deletions(-) + +commit 123877715145038a5877b8c538a48a1285f1ed54 +Author: John (J5) Palmieri +Date: Wed Feb 16 17:52:38 2011 -0500 + + [gi-overrides] add cursor overrides + + https://bugzilla.gnome.org/show_bug.cgi?id=635947 + + gi/overrides/Gdk.py | 41 +++++++++++++++++++++++++++++++++++++++++ + tests/test_overrides.py | 23 +++++++++++++++++++++++ + 2 files changed, 64 insertions(+), 0 deletions(-) + +commit 68d72e015997da8d5732527c7ab96dd8c61fa664 +Author: John (J5) Palmieri +Date: Wed Feb 16 16:18:24 2011 -0500 + + [gi-demos] add the links demo + + demos/gtk-demo/demos/links.py | 74 + +++++++++++++++++++++++++++++++++++++++++ + 1 files changed, 74 insertions(+), 0 deletions(-) + +commit 00505a9a5445b85a091650a777a47f632ddc9d6d +Author: John (J5) Palmieri +Date: Wed Feb 16 15:48:40 2011 -0500 + + [gi-demos] add expander demo + + demos/gtk-demo/demos/expander.py | 60 + ++++++++++++++++++++++++++++++++++++++ + 1 files changed, 60 insertions(+), 0 deletions(-) + +commit ed8710c7aa05cc0c919366536c94bf43955f1b71 +Author: John (J5) Palmieri +Date: Wed Feb 16 15:14:35 2011 -0500 + + [gi-overrides] use pop instead of del and add extra tests for + Gtk.Table kwargs + + gi/overrides/Gtk.py | 6 ++---- + tests/test_overrides.py | 8 ++++++++ + 2 files changed, 10 insertions(+), 4 deletions(-) + +commit 888675f85c895a60d4432b992961ec3067da6e20 +Author: Laszlo Pandy +Date: Tue Feb 15 20:07:42 2011 +0100 + + [tests] Separate processes for GI and static binding tests. + + Importing and using both static gobject bindings and + introspection GObject bindings in the same process can cause + conflicts with types which otherwise wouldn't be there. + + This patch changes "make check" to call runtests.py twice -- once + for each set of tests. + + In the case of a test failure, runtests.py now sets the exit code + so that make does not continue. Otherwise you might miss the + failures from the first batch of tests in the scrollback. + + tests/Makefile.am | 29 ++++++++++++----------------- + tests/runtests.py | 4 +++- + 2 files changed, 15 insertions(+), 18 deletions(-) + +commit 71b0dd93d524afce9f4a4b0b393c8a16a1f70e2f +Author: Laszlo Pandy +Date: Tue Feb 15 16:26:24 2011 +0100 + + [GI] Remove implicit loading of gi module preserve the code path + for static bindings. + + Previously type lookups (as well as property accesses and signal + connects would trigger an import of the gi module). Now we make + those paths fail, and fallback to the old static binding code + paths *unless* the gi module is already in sys.modules. + + So if Python code calls: + from gi.repository import Gtk + + or even just: + import gi + + then everything will work just like it did without this patch. If gi + is not explicitly imported, the code skips the introspection code + and acts like the old static bindings did. + + https://bugzilla.gnome.org/show_bug.cgi?id=642387 + + gi/pygi.h | 10 ++++++++-- + 1 files changed, 8 insertions(+), 2 deletions(-) + +commit 97e78181813f15f693e650df5a8901bd2fe71541 +Author: John (J5) Palmieri +Date: Tue Feb 15 14:47:10 2011 -0500 + + [gi-demos] add dialogs demo + + demos/gtk-demo/demos/dialogs.py | 153 + +++++++++++++++++++++++++++++++++++++++ + 1 files changed, 153 insertions(+), 0 deletions(-) + +commit a23a48edafb9d08fec5411b828d1e0c6763e84af +Author: John (J5) Palmieri +Date: Tue Feb 15 14:46:41 2011 -0500 + + [gi-overrides] fix typo in GtkTable constructor + + gi/overrides/Gtk.py | 8 ++++---- + 1 files changed, 4 insertions(+), 4 deletions(-) + +commit bcccff3b2ad9c8054a4d5462c62cde566587eba6 +Author: John (J5) Palmieri +Date: Tue Feb 15 13:26:38 2011 -0500 + + [gi-demos] keep popup menu from destroying itself by holding a ref + in app class + + demos/gtk-demo/demos/clipboard.py | 8 ++++---- + 1 files changed, 4 insertions(+), 4 deletions(-) + +commit 9dc0979ba7d35b6ff9bb219a21926c2fd88451c7 +Author: John (J5) Palmieri +Date: Tue Feb 15 13:25:13 2011 -0500 + + [gi-overrides] add a Gtk.Menu override for the popup method + + gi/overrides/Gtk.py | 7 +++++++ + 1 files changed, 7 insertions(+), 0 deletions(-) + +commit 317278a3ddf15f1f9da53051295a0b533b1b1a11 +Author: John (J5) Palmieri +Date: Tue Feb 15 13:24:33 2011 -0500 + + [gi-demos] fix the about dialog in appwindow demo + + demos/gtk-demo/demos/appwindow.py | 22 +++++++++------------- + 1 files changed, 9 insertions(+), 13 deletions(-) + +commit cb2d2aad023789991b20036e22cae5ad3eee9b36 +Author: John (J5) Palmieri +Date: Tue Feb 15 11:21:13 2011 -0500 + + [gi-demos] fix clipboard demo so DnD works + + * menu popups don't work because the API takes a callback without + a destroy + notify + + demos/gtk-demo/demos/clipboard.py | 20 ++++++++++---------- + 1 files changed, 10 insertions(+), 10 deletions(-) + +commit 5434b7aac323170ea9469afbda520b801462c246 +Author: John (J5) Palmieri +Date: Tue Feb 15 10:18:53 2011 -0500 + + [gi-demos] fix clipboard demo to reflect new API + + demos/gtk-demo/demos/clipboard.py | 6 +++--- + 1 files changed, 3 insertions(+), 3 deletions(-) + +commit b6c97de9680f3d5d629132415c1f7a9c42e558f8 +Author: John (J5) Palmieri +Date: Mon Feb 14 18:17:20 2011 -0500 + + [gi-demo] Fix color dialog demo to run with new draw, style and + color apis + + demos/gtk-demo/demos/colorselector.py | 44 + ++++++++++++-------------------- + 1 files changed, 17 insertions(+), 27 deletions(-) + +commit 7147bd635fb03439a5f9edbce56c5558d092428c +Author: John (J5) Palmieri +Date: Mon Feb 14 17:58:25 2011 -0500 + + [gi-demos] fix most of the combobox app + + * Still having some issues with filtering the ComboBoxText widget + + demos/gtk-demo/demos/combobox.py | 17 ++++++++--------- + 1 files changed, 8 insertions(+), 9 deletions(-) + +commit a64b8fe89492ae47172979f1900686455cd1f9a8 +Author: Laszlo Pandy +Date: Mon Feb 14 19:36:27 2011 +0100 + + Use PyGI type conversion (to fix foreign types) for signal callbacks. + + First attempt at patch to fix foreign types in signal callbacks. + Tests are not implemented yet. + + https://bugzilla.gnome.org/show_bug.cgi?id=637601 + + gi/Makefile.am | 2 + + gi/gimodule.c | 1 + + gi/pygi-argument.c | 91 +++++++++++++++++ + gi/pygi-argument.h | 2 + + gi/pygi-private.h | 1 + + gi/pygi-signal-closure.c | 245 + ++++++++++++++++++++++++++++++++++++++++++++++ + gi/pygi-signal-closure.h | 46 +++++++++ + gi/pygi.h | 28 +++++ + gobject/pygobject.c | 24 ++++- + 9 files changed, 436 insertions(+), 4 deletions(-) + +commit 36ddad6af4a579c070171fd0522d7ffd93d5d73e +Author: John (J5) Palmieri +Date: Mon Feb 14 16:47:03 2011 -0500 + + [gi-demos] fix drawingarea app to use the new draw api + + demos/gtk-demo/demos/drawingarea.py | 144 + ++++++++++++----------------------- + 1 files changed, 50 insertions(+), 94 deletions(-) + +commit ddde83ebd4dbb179aa5388057a14faf32ece26ae +Author: John (J5) Palmieri +Date: Mon Feb 14 16:43:35 2011 -0500 + + [gi-overrides] for Gtk 3 alias Gdk.Rectangle to cairo.RectangleInt + + * note this is the introspected gobject-cairo boxed type not the + static cairo + bindings + * we alias this so people do not get confused + + gi/overrides/Gdk.py | 5 +++++ + 1 files changed, 5 insertions(+), 0 deletions(-) + +commit 8617d0e2a63771eba04983c7319f18638aa6d81e +Author: John (J5) Palmieri +Date: Mon Feb 14 15:07:11 2011 -0500 + + [gi-overrides] let user set the proper property names in Gtk.Table + + * the old override added a columns and rows parameters to the Table + constuctor + to be in sync with PyGtk. + * The GTK properties are n_columns and n_rows + * support both + + gi/overrides/Gtk.py | 8 ++++++++ + 1 files changed, 8 insertions(+), 0 deletions(-) + +commit 09c0534e4ac673ffdbfb41bc0aa34353be3b88e2 +Author: John (J5) Palmieri +Date: Mon Feb 14 15:06:38 2011 -0500 + + [gi-demos] get appwindow demo working again + + demos/gtk-demo/demos/appwindow.py | 24 ++++-------------------- + 1 files changed, 4 insertions(+), 20 deletions(-) + +commit 1944349cc59ddaf4fd7308ffce10b521c885c88b +Author: John (J5) Palmieri +Date: Mon Feb 14 15:05:44 2011 -0500 + + [gi-demos] fixed use of tree_iter_get + + demos/gtk-demo/gtk-demo.py | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +commit 29efc5a31c2879cefcf31d1d9bdbab65052d3b24 +Author: John (J5) Palmieri +Date: Fri Feb 11 11:18:24 2011 -0500 + + pre-release version bump + + configure.ac | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + commit 5dae6386ef74b6334daa3d0baf7c2e43d93a7e40 Author: John (J5) Palmieri Date: Fri Feb 11 11:05:04 2011 -0500 diff --git a/NEWS b/NEWS index 1e46f04..def2b58 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,53 @@ +2.27.91 28-Feb-2011 (2.28 pre-release) + - [gi-tests] use Gdk.test_simulate_button instead of emitting event ourselves (John (J5) Palmieri) + - [gi-tests] tests for EventButton override. (Laszlo Pandy) + - Skip interfaces when checking for conflicts in the MRO (Tomeu Vizoso) + - [gi-overrides] Add event methods to all event union members (John (J5) Palmieri) + - [gi] check to see if object is a member of a union when validating paramaters (John (J5) Palmieri) + - [gi] Remove DyanmicModule.load() to _load() to prevent overriding GI attrs. (Laszlo Pandy) + - Test case with John's fix for crash with C arrays and a GError is set. (Laszlo Pandy) + - [gi-overrides] fix setting rows in treeview to accept None as a value (John (J5) Palmieri) + - [gi] Add value_name for enum and flags from introspection "c:identifier" (if attr is available). (Laszlo Pandy) + - Don't force loading of DynamicModule until set in sys.modules (Laszlo Pandy) + - Fix flags with multiple names for the same value. (Laszlo Pandy) + - [gi-demos] add liststore demo (John (J5) Palmieri) + - [gi-demos] run through the demos and remove the FIXMEs that have been fixed (John (J5) Palmieri) + - Load typelibs at import time, add gi.require_version() (Tomeu Vizoso) + - use GValue support to marshal GtkTreeModel values correctly (John (J5) Palmieri) + - [gi] pass raw GValues instead of trying to marshal them (John (J5) Palmieri) + - [gi-demos] add icon view edit and drag-and-drop demo (John (J5) Palmieri) + - [gi] Register GType for non-GType enums and flags at runtime. (Laszlo Pandy) + - [gi-demos] add info bars demo (John (J5) Palmieri) + - tests/runtests.py: Add missing "import sys" (Martin Pitt) + - [gi] Add Pythonic gdbus method invocation (Martin Pitt) + - Skip GError out parameters in Python closure. (Laszlo Pandy) + - [gi-demos] added rotate text demo (John (J5) Palmieri) + - [gi-demos] add images demo (John (J5) Palmieri) + - [gi-demos] add pixbuf demo (John (J5) Palmieri) + - [gi-demos] remove fixmes from print demo, fixed in pango (John (J5) Palmieri) + - [gi-demos] add printing demo (John (J5) Palmieri) + - [gi-overrides] add cursor overrides (John (J5) Palmieri) + - [gi-demos] add the links demo (John (J5) Palmieri) + - [gi-demos] add expander demo (John (J5) Palmieri) + - [gi-overrides] use pop instead of del and add extra tests for Gtk.Table kwargs (John (J5) Palmieri) + - [tests] Separate processes for GI and static binding tests. (Laszlo Pandy) + - [GI] Remove implicit loading of gi module preserve the code path for static bindings. (Laszlo Pandy) + - [gi-demos] add dialogs demo (John (J5) Palmieri) + - [gi-overrides] fix typo in GtkTable constructor (John (J5) Palmieri) + - [gi-demos] keep popup menu from destroying itself by holding a ref in app class (John (J5) Palmieri) + - [gi-overrides] add a Gtk.Menu override for the popup method (John (J5) Palmieri) + - [gi-demos] fix the about dialog in appwindow demo (John (J5) Palmieri) + - [gi-demos] fix clipboard demo so DnD works (John (J5) Palmieri) + - [gi-demos] fix clipboard demo to reflect new API (John (J5) Palmieri) + - [gi-demo] Fix color dialog demo to run with new draw, style and color apis (John (J5) Palmieri) + - [gi-demos] fix most of the combobox app (John (J5) Palmieri) + - Use PyGI type conversion (to fix foreign types) for signal callbacks. (Laszlo Pandy) + - [gi-demos] fix drawingarea app to use the new draw api (John (J5) Palmieri) + - [gi-overrides] for Gtk 3 alias Gdk.Rectangle to cairo.RectangleInt (John (J5) Palmieri) + - [gi-overrides] let user set the proper property names in Gtk.Table (John (J5) Palmieri) + - [gi-demos] get appwindow demo working again (John (J5) Palmieri) + - [gi-demos] fixed use of tree_iter_get (John (J5) Palmieri) + 2.27.90 11-Feb-2011 (2.28 pre-release) - fix build to correctly use python-config (John (J5) Palmieri) - Run gio tests separately when enabled (Martin Pitt) diff --git a/PKG-INFO b/PKG-INFO index 3c75ee1..9d0ba27 100644 --- a/PKG-INFO +++ b/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 1.0 Name: PyGObject -Version: 2.27.90 +Version: 2.27.91 Summary: Python bindings for GObject Home-page: http://www.pygtk.org/ Author: James Henstridge @@ -8,7 +8,7 @@ Author-email: james@daa.com.au Maintainer: Johan Dahlin Maintainer-email: johan@gnome.org License: GNU LGPL -Download-url: ftp://ftp.gnome.org/pub/GNOME/sources/pygobject/2.27/pygobject-2.27.90.tar.gz +Download-url: ftp://ftp.gnome.org/pub/GNOME/sources/pygobject/2.27/pygobject-2.27.91.tar.gz Description: Python bindings for GLib, GObject and GIO Platform: POSIX, Windows Classifier: Development Status :: 5 - Production/Stable diff --git a/configure b/configure index c7a71c0..5ef57dc 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.68 for pygobject 2.27.90. +# Generated by GNU Autoconf 2.68 for pygobject 2.27.91. # # Report bugs to . # @@ -571,8 +571,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='pygobject' PACKAGE_TARNAME='pygobject' -PACKAGE_VERSION='2.27.90' -PACKAGE_STRING='pygobject 2.27.90' +PACKAGE_VERSION='2.27.91' +PACKAGE_STRING='pygobject 2.27.91' PACKAGE_BUGREPORT='http://bugzilla.gnome.org/enter_bug.cgi?product=pygobject' PACKAGE_URL='' @@ -1381,7 +1381,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures pygobject 2.27.90 to adapt to many kinds of systems. +\`configure' configures pygobject 2.27.91 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1451,7 +1451,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of pygobject 2.27.90:";; + short | recursive ) echo "Configuration of pygobject 2.27.91:";; esac cat <<\_ACEOF @@ -1582,7 +1582,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -pygobject configure 2.27.90 +pygobject configure 2.27.91 generated by GNU Autoconf 2.68 Copyright (C) 2010 Free Software Foundation, Inc. @@ -1860,7 +1860,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by pygobject $as_me 2.27.90, which was +It was created by pygobject $as_me 2.27.91, which was generated by GNU Autoconf 2.68. Invocation command line was $ $0 $@ @@ -2224,9 +2224,9 @@ $as_echo "#define PYGOBJECT_MINOR_VERSION 27" >>confdefs.h PYGOBJECT_MINOR_VERSION=27 -$as_echo "#define PYGOBJECT_MICRO_VERSION 90" >>confdefs.h +$as_echo "#define PYGOBJECT_MICRO_VERSION 91" >>confdefs.h -PYGOBJECT_MICRO_VERSION=90 +PYGOBJECT_MICRO_VERSION=91 ac_config_headers="$ac_config_headers config.h" @@ -2710,7 +2710,7 @@ fi # Define the identity of the package. PACKAGE='pygobject' - VERSION='2.27.90' + VERSION='2.27.91' cat >>confdefs.h <<_ACEOF @@ -12046,7 +12046,7 @@ Usage: $0 [OPTIONS] Report bugs to ." lt_cl_version="\ -pygobject config.lt 2.27.90 +pygobject config.lt 2.27.91 configured by $0, generated by GNU Autoconf 2.68. Copyright (C) 2010 Free Software Foundation, Inc. @@ -16747,7 +16747,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by pygobject $as_me 2.27.90, which was +This file was extended by pygobject $as_me 2.27.91, which was generated by GNU Autoconf 2.68. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -16813,7 +16813,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -pygobject config.status 2.27.90 +pygobject config.status 2.27.91 configured by $0, generated by GNU Autoconf 2.68, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index 7b77401..cab7834 100644 --- a/configure.ac +++ b/configure.ac @@ -12,7 +12,7 @@ m4_define(python3_min_ver, 3.1) dnl the pygobject version number m4_define(pygobject_major_version, 2) m4_define(pygobject_minor_version, 27) -m4_define(pygobject_micro_version, 90) +m4_define(pygobject_micro_version, 91) m4_define(pygobject_version, pygobject_major_version.pygobject_minor_version.pygobject_micro_version) dnl versions of packages we require ... diff --git a/docs/html/class-gioappinfo.html b/docs/html/class-gioappinfo.html index aecd668..e7205ee 100644 --- a/docs/html/class-gioappinfo.html +++ b/docs/html/class-gioappinfo.html @@ -1,13 +1,13 @@ -gio.AppInfo

gio.AppInfo

gio.AppInfo — Information about an installed application and methods to launch it (with file arguments).

Synopsis

class gio.AppInfo(gobject.GInterface):
+gio.AppInfo

gio.AppInfo

gio.AppInfo — Information about an installed application and methods to launch it (with file arguments).

Synopsis

class gio.AppInfo(gobject.GInterface):
     gio.AppInfo(commandline, application_name=None, flags=gio.APP_INFO_CREATE_NONE)
def add_supports_type(content_type)
def can_delete()
def can_remove_supports_type()
def delete()
def dup()
def equal(appinfo2)
def get_commandline()
def get_description()
def get_executable()
def get_icon()
def get_id()
def get_name()
def launch(files, launch_context)
def launch_uris(uris, launch_context)
def remove_supports_type(content_type)
def set_as_default_for_extension(extension)
def set_as_default_for_type(content_type)
def should_show()
def supports_files()
def supports_uris()
 Functions
  
-    def gio.app_info_get_all()
def gio.app_info_get_all_for_type(content_type)
def gio.app_info_get_default_for_type(content_type, must_support_uris)
def gio.app_info_get_default_for_uri_scheme(uri_scheme)
def gio.app_info_reset_type_association(content_type)

Known Implementation

+

Known Implementation

gio.AppInfo is implemented by gio.DesktopAppInfo -

Description

+

Description

gio.AppInfo and gio.AppLaunchContext are used for describing and launching applications installed on the system. @@ -43,7 +43,7 @@

Creates a new gio.AppInfo from the given information. -

Methods

gio.AppInfo.add_supports_type

    def add_supports_type(content_type)

content_type :

A string.

+

Methods

gio.AppInfo.add_supports_type

    def add_supports_type(content_type)

content_type :

A string.

The add_supports_type() method adds a content type to the application information to indicate the application is capable of opening files with the given content type. @@ -166,7 +166,7 @@

The supports_uris() method checks if the application accepts uris as arguments. -

Functions

gio.app_info_get_all

    def app_info_get_all()

Returns :

A list of gio.AppInfos. +

Functions

gio.app_info_get_all

    def app_info_get_all()

Returns :

A list of gio.AppInfos.

The app_info_get_all() function gets a list of all of the applications currently registered on this system. diff --git a/docs/html/class-gioapplaunchcontext.html b/docs/html/class-gioapplaunchcontext.html index 3d93295..01b42b7 100644 --- a/docs/html/class-gioapplaunchcontext.html +++ b/docs/html/class-gioapplaunchcontext.html @@ -1,7 +1,7 @@ -gio.AppLaunchContext

gio.AppLaunchContext

gio.AppLaunchContext — Application launch context.

Synopsis

class gio.AppLaunchContext(gobject.GObject):
-    gio.AppLaunchContext()
def get_display(info, files)
def get_startup_notify_id(info, files)
def launch_failed(startup_notify_id)

Ancestry

+-- gobject.GObject
+gio.AppLaunchContext

gio.AppLaunchContext

gio.AppLaunchContext — Application launch context.

Synopsis

class gio.AppLaunchContext(gobject.GObject):
+    gio.AppLaunchContext()
def get_display(info, files)
def get_startup_notify_id(info, files)
def launch_failed(startup_notify_id)

Description

+

Description

The gio.AppLaunchContext is used for integrating the launch with the launching application. This is used to handle for instance startup notification and launching the new application on the same screen as the launching window. @@ -11,7 +11,7 @@ Creates a new application launch context. This is not normally used, instead you instantiate a subclass of this, such as gtk.gdk.AppLaunchContext. -

Methods

gio.AppLaunchContext.get_display

    def get_display(info, files)

info :

a +

Methods

gio.AppLaunchContext.get_display

    def get_display(info, files)

info :

a gio.AppInfo

files :

a list of gio.File diff --git a/docs/html/class-gioasyncresult.html b/docs/html/class-gioasyncresult.html index ddc75ac..1c877f6 100644 --- a/docs/html/class-gioasyncresult.html +++ b/docs/html/class-gioasyncresult.html @@ -1,13 +1,13 @@ -gio.AsyncResult

gio.AsyncResult

gio.AsyncResult — Asynchronous Function Results.

Synopsis

class gio.AsyncResult(gobject.GInterface):
-    def get_source_object()

Ancestry

+-- gobject.GInterface
+gio.AsyncResult

gio.AsyncResult

gio.AsyncResult — Asynchronous Function Results.

Synopsis

class gio.AsyncResult(gobject.GInterface):
+    def get_source_object()

Prerequisites

+

Prerequisites

gio.AsyncResult is required by gobject.GObject. -

Known Implementation

+

Known Implementation

gio.AsyncResult is implemented by gio.SimpleAsyncResult. -

Description

+

Description

gio.AsyncResult provides a base class for implementing asynchronous function results.

@@ -37,7 +37,7 @@ separate thread, if GThread has been initialized, but otherwise they are sent to the Main Event Loop and processed in an idle function. So, if you truly need asynchronous operations, make sure to initialize GThread. -

Methods

gio.AsyncResult.get_source_object

    def get_source_object()

Returns :

the source object for the res. +

Methods

gio.AsyncResult.get_source_object

    def get_source_object()

Returns :

the source object for the res.

The get_source_object() method gets the source object from a gio.AsyncResult diff --git a/docs/html/class-giobufferedinputstream.html b/docs/html/class-giobufferedinputstream.html index e6a334b..ca1d01e 100644 --- a/docs/html/class-giobufferedinputstream.html +++ b/docs/html/class-giobufferedinputstream.html @@ -1,12 +1,12 @@ -gio.BufferedInputStream

gio.BufferedInputStream

gio.BufferedInputStream — Buffered Input Stream

Synopsis

class gio.BufferedInputStream(gio.FilterInputStream):
+gio.BufferedInputStream

gio.BufferedInputStream

gio.BufferedInputStream — Buffered Input Stream

Synopsis

class gio.BufferedInputStream(gio.FilterInputStream):
     gio.BufferedInputStream(base_stream)
def fill(count, cancellable=None)
def fill_async(count, callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def fill_finish(result)
def get_available()
def get_buffer_size()
def read_byte(cancellable=None)
def set_buffer_size(size)
 Functions
  
-    def gio.buffered_input_stream_new_sized(size)

gio.BufferedInputStream Properties

"buffer-size"Read - Write - ConstructThe size of the backend buffer. Allowed values: >= 1. Default value: 4096.

Description

+

gio.BufferedInputStream Properties

"buffer-size"Read - Write - ConstructThe size of the backend buffer. Allowed values: >= 1. Default value: 4096.

Description

gio.BufferedInputStream implements gio.FilterInputStream and provides for buffered reads. @@ -33,7 +33,7 @@

Creates a new gio.InputStream from the given base_stream, with a buffer set to the default size (4 kilobytes). -

Methods

gio.BufferedInputStream.fill

    def fill(count, cancellable=None)

count :

the number of bytes that will be read from the stream. +

Methods

gio.BufferedInputStream.fill

    def fill(count, cancellable=None)

count :

the number of bytes that will be read from the stream.

cancellable :

optional gio.Cancellable object, None to ignore. @@ -123,7 +123,7 @@ The set_buffer_size() method sets the size of the internal buffer of stream to size, or to the size of the contents of the buffer. The buffer can never be resized smaller than its current contents. -

Functions

gio.buffered_input_stream_new_sized

    def buffered_input_stream_new_sized(size)

size :

the requested buffer size. +

Functions

gio.buffered_input_stream_new_sized

    def buffered_input_stream_new_sized(size)

size :

the requested buffer size.

Returns :

A new gio.InputStream.

diff --git a/docs/html/class-giobufferedoutputstream.html b/docs/html/class-giobufferedoutputstream.html index b2acf32..f1a0273 100644 --- a/docs/html/class-giobufferedoutputstream.html +++ b/docs/html/class-giobufferedoutputstream.html @@ -1,12 +1,12 @@ -gio.BufferedOutputStream

gio.BufferedOutputStream

gio.BufferedOutputStream — Buffered Output Stream

Synopsis

class gio.BufferedOutputStream(gio.FilterOutputStream):
+gio.BufferedOutputStream

gio.BufferedOutputStream

gio.BufferedOutputStream — Buffered Output Stream

Synopsis

class gio.BufferedOutputStream(gio.FilterOutputStream):
     gio.BufferedOutputStream(base_stream)
def get_auto_grow()
def get_buffer_size()
def set_auto_grow(auto_grow)
def set_buffer_size(size)
 Functions
  
-    def gio.buffered_output_stream_new_sized(size)

gio.BufferedOutputStream Properties

"auto-grow"Read - WriteWhether the buffer should automatically grow. Default value: False.
"buffer-size"Read - Write - ConstructThe size of the backend buffer. Allowed values: >= 1. Default value: 4096.

Description

+

gio.BufferedOutputStream Properties

"auto-grow"Read - WriteWhether the buffer should automatically grow. Default value: False.
"buffer-size"Read - Write - ConstructThe size of the backend buffer. Allowed values: >= 1. Default value: 4096.

Description

gio.BufferedOutputStream implements gio.FilterOutputStream and provides for buffered writes. @@ -32,7 +32,7 @@ for the given base_stream.

Creates a new buffered output stream for a base stream. -

Methods

gio.BufferedOutputStream.get_auto_grow

    def get_auto_grow()

Returns :

True if the stream's +

Methods

gio.BufferedOutputStream.get_auto_grow

    def get_auto_grow()

Returns :

True if the stream's buffer automatically grows, False otherwise.

The get_auto_grow() method checks if the @@ -51,7 +51,7 @@

The set_buffer_size() method sets the size of the internal buffer to size. -

Functions

gio.buffered_output_stream_new_sized

    def buffered_output_stream_new_sized(size)

size :

the requested buffer size. +

Functions

gio.buffered_output_stream_new_sized

    def buffered_output_stream_new_sized(size)

size :

the requested buffer size.

Returns :

A new gio.OutputStream with an internal buffer set to size.. diff --git a/docs/html/class-giocancellable.html b/docs/html/class-giocancellable.html index 2dd4e20..5178377 100644 --- a/docs/html/class-giocancellable.html +++ b/docs/html/class-giocancellable.html @@ -1,10 +1,10 @@ -gio.Cancellable

gio.Cancellable

gio.Cancellable — Thread-safe Operation Cancellation Stack.

Synopsis

class gio.Cancellable(gobject.GObject):
+gio.Cancellable

gio.Cancellable

gio.Cancellable — Thread-safe Operation Cancellation Stack.

Synopsis

class gio.Cancellable(gobject.GObject):
     gio.Cancellable()
def cancel()
def get_fd()
def is_cancelled()
def pop_current()
def push_current()
def reset()
def set_error_if_cancelled()
 Functions
  
-    def gio.cancellable_get_current()

Description

+

Description

The gio.Cancellable is a thread-safe operation cancellation stack used throughout GIO to allow for cancellation of synchronous and asynchronous operations. @@ -19,7 +19,7 @@

One gio.Cancellable can be used in multiple consecutive operations, but not in multiple concurrent operations. -

Methods

gio.Cancellable.cancel

    def cancel()

+

Methods

gio.Cancellable.cancel

    def cancel()

The cancel() method will set cancellable to cancelled, and will emit the "cancelled" signal. (However, see the warning about race conditions in the documentation for that signal if you are planning to connect to it.) @@ -55,7 +55,7 @@ False if it was not.

The set_error_if_cancelled() method, if the cancellable is cancelled, sets the error to notify that the operation was cancelled. -

Functions

gio.cancellable_get_current

    def cancellable_get_current()

Returns :

A gio.Cancellable +

Functions

gio.cancellable_get_current

    def cancellable_get_current()

Returns :

A gio.Cancellable from the top of the stack, or None if the stack is empty.

The cancellable_get_current() function gets the top cancellable from the stack.

diff --git a/docs/html/class-giodatainputstream.html b/docs/html/class-giodatainputstream.html index a5c99e6..3408ad5 100644 --- a/docs/html/class-giodatainputstream.html +++ b/docs/html/class-giodatainputstream.html @@ -1,10 +1,10 @@ -gio.DataInputStream

gio.DataInputStream

gio.DataInputStream — Data Input Stream

Synopsis

class gio.DataInputStream(gio.BufferedInputStream):
-    gio.DataInputStream(base_stream)
def get_byte_order()
def get_newline_type()
def read_byte(cancellable=None)
def read_int16(cancellable=None)
def read_int32(cancellable=None)
def read_int64(cancellable=None)
def read_line(cancellable=None)
def read_line_async(callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def read_line_finish(result)
def read_uint16(cancellable=None)
def read_uint32(cancellable=None)
def read_uint64(cancellable=None)
def read_until(stop_chars, cancellable=None)
def read_until_async(stop_chars, callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def read_until_finish(result)
def set_byte_order(order)
def set_newline_type(type)

Ancestry

+-- gobject.GObject
+gio.DataInputStream

gio.DataInputStream

gio.DataInputStream — Data Input Stream

Synopsis

class gio.DataInputStream(gio.BufferedInputStream):
+    gio.DataInputStream(base_stream)
def get_byte_order()
def get_newline_type()
def read_byte(cancellable=None)
def read_int16(cancellable=None)
def read_int32(cancellable=None)
def read_int64(cancellable=None)
def read_line(cancellable=None)
def read_line_async(callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def read_line_finish(result)
def read_uint16(cancellable=None)
def read_uint32(cancellable=None)
def read_uint64(cancellable=None)
def read_until(stop_chars, cancellable=None)
def read_until_async(stop_chars, callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def read_until_finish(result)
def set_byte_order(order)
def set_newline_type(type)

gio.DataInputStream Properties

"byte-order"Read - WriteThe byte order. Default value: gio.DATA_STREAM_BYTE_ORDER_BIG_ENDIAN.
"newline-type"Read - WriteThe accepted types of line ending. Default value: gio.DATA_STREAM_NEWLINE_TYPE_LF.

Description

+

gio.DataInputStream Properties

"byte-order"Read - WriteThe byte order. Default value: gio.DATA_STREAM_BYTE_ORDER_BIG_ENDIAN.
"newline-type"Read - WriteThe accepted types of line ending. Default value: gio.DATA_STREAM_NEWLINE_TYPE_LF.

Description

gio.DataInputStream implements gio.InputStream and includes functions for reading structured data directly from a binary input stream. @@ -15,7 +15,7 @@

Creates a new gio.DataInputStream from the given base_stream. -

Methods

gio.DataInputStream.get_byte_order

    def get_byte_order()

Returns :

the stream's current +

Methods

gio.DataInputStream.get_byte_order

    def get_byte_order()

Returns :

the stream's current Gio Data Stream Byte Order Constants.

The get_byte_order() method gets the byte diff --git a/docs/html/class-giodataoutputstream.html b/docs/html/class-giodataoutputstream.html index f95831d..265e300 100644 --- a/docs/html/class-giodataoutputstream.html +++ b/docs/html/class-giodataoutputstream.html @@ -1,12 +1,12 @@ -gio.DataOutputStream

gio.DataOutputStream

gio.DataOutputStream — Data Output Stream

Synopsis

class gio.DataOutputStream(gio.BufferedOutputStream):
-    gio.DataOutputStream(base_stream)
def get_byte_order()
def put_byte(cancellable=None)
def put_int16(cancellable=None)
def put_int32(cancellable=None)
def put_int64(cancellable=None)
def put_string(cancellable=None)
def put_uint16(cancellable=None)
def put_uint32(cancellable=None)
def put_uint64(cancellable=None)
def set_byte_order(order)

Ancestry

+-- gobject.GObject
+gio.DataOutputStream

gio.DataOutputStream

gio.DataOutputStream — Data Output Stream

Synopsis

class gio.DataOutputStream(gio.BufferedOutputStream):
+    gio.DataOutputStream(base_stream)
def get_byte_order()
def put_byte(cancellable=None)
def put_int16(cancellable=None)
def put_int32(cancellable=None)
def put_int64(cancellable=None)
def put_string(cancellable=None)
def put_uint16(cancellable=None)
def put_uint32(cancellable=None)
def put_uint64(cancellable=None)
def set_byte_order(order)

gio.DataOutputStream Properties

"byte-order"Read - WriteDetermines the byte ordering that is used when writing multi-byte entities (such as integers) to the stream. - Default value: gio.DATA_STREAM_BYTE_ORDER_BIG_ENDIAN.

Description

+ Default value: gio.DATA_STREAM_BYTE_ORDER_BIG_ENDIAN.

Description

gio.DataOutputStream implements gio.InputStream and includes functions for writing data directly to an output stream. @@ -17,7 +17,7 @@

Creates a new gio.DataOutputStream from the given base_stream. -

Methods

gio.DataOutputStream.get_byte_order

    def get_byte_order()

Returns :

the stream's current +

Methods

gio.DataOutputStream.get_byte_order

    def get_byte_order()

Returns :

the stream's current Gio Data Stream Byte Order Constants.

The get_byte_order() method gets the byte diff --git a/docs/html/class-giodrive.html b/docs/html/class-giodrive.html index e1680ad..098fe1e 100644 --- a/docs/html/class-giodrive.html +++ b/docs/html/class-giodrive.html @@ -1,10 +1,10 @@ -gio.Drive

gio.Drive

gio.Drive — Virtual File System drive management.

Synopsis

class gio.Drive(gobject.GInterface):
-    def can_eject()
def can_poll_for_media()
def eject(callback, flags=gio.MOUNT_UNMOUNT_NONE, cancellable=None, user_data=None)
def eject_finish(result)
def enumerate_identifiers()
def get_icon()
def get_identifier()
def get_name()
def get_volumes()
def has_media()
def has_volumes()
def is_media_check_automatic()
def is_media_removable()
def poll_for_media(callback, cancellable=None, user_data=None)
def poll_for_media_finish(result)

Ancestry

+-- gobject.GInterface
+gio.Drive

gio.Drive

gio.Drive — Virtual File System drive management.

Synopsis

class gio.Drive(gobject.GInterface):
+    def can_eject()
def can_poll_for_media()
def eject(callback, flags=gio.MOUNT_UNMOUNT_NONE, cancellable=None, user_data=None)
def eject_finish(result)
def enumerate_identifiers()
def get_icon()
def get_identifier()
def get_name()
def get_volumes()
def has_media()
def has_volumes()
def is_media_check_automatic()
def is_media_removable()
def poll_for_media(callback, cancellable=None, user_data=None)
def poll_for_media_finish(result)

Ancestry

+-- gobject.GInterface
   +-- gio.Drive
-

Prerequisites

+

Prerequisites

gio.Drive requires gobject.GObject -

Description

+

Description

gio.Drive - this represent a piece of hardware connected to the machine. Its generally only created for removable hardware or hardware with removable media. @@ -24,7 +24,7 @@ For porting from GnomeVFS note that there is no equivalent of gio.Drive in that API. -

Methods

gio.Drive.can_eject

    def can_eject()

Returns :

True if the drive can be ejected, +

Methods

gio.Drive.can_eject

    def can_eject()

Returns :

True if the drive can be ejected, False otherwise.

The can_eject() method checks if a drive can be ejected. diff --git a/docs/html/class-gioemblem.html b/docs/html/class-gioemblem.html index 1f47604..5fde4aa 100644 --- a/docs/html/class-gioemblem.html +++ b/docs/html/class-gioemblem.html @@ -1,14 +1,14 @@ -gio.Emblem

gio.Emblem

gio.Emblem — An object for emblems.

Synopsis

class gio.Emblem(gobject.GObject, gio.Icon):
+gio.Emblem

gio.Emblem

gio.Emblem — An object for emblems.

Synopsis

class gio.Emblem(gobject.GObject, gio.Icon):
     gio.Emblem(icon, origin=gio.EMBLEM_ORIGIN_UNKNOWN)
def get_icon()
def get_origin()
 Functions
  
-    def gio.emblem_new_with_origin(icon, origin)

Ancestry

+-- gobject.GObject
+    def gio.emblem_new_with_origin(icon, origin)

Ancestry

+-- gobject.GObject
   +-- gio.Emblem
-

Implemented Interfaces

+

Implemented Interfaces

gio.Emblem implements gio.Icon -

gio.Emblem Properties

"icon"Read - Write - Construct OnlyThe actual icon of the emblem.
"origin"Read - Write - Construct OnlyTells which origin the emblem is derived from.

Description

+

gio.Emblem Properties

"icon"Read - Write - Construct OnlyThe actual icon of the emblem.
"origin"Read - Write - Construct OnlyTells which origin the emblem is derived from.

Description

The gio.Emblem class is an implementation of gio.Icon that supports having an emblem, which is an icon with additional properties. @@ -27,14 +27,14 @@ Parameter origin is available since PyGObject 2.20.

Creates a new gio.Emblem for icon. -

Methods

gio.Emblem.get_icon

    def get_icon()

Returns :

a +

Methods

gio.Emblem.get_icon

    def get_icon()

Returns :

a gio.Icon.

The get_icon() method gives back the icon from emblem.

gio.Emblem.get_origin

    def get_origin()

Returns :

the origin of the emblem.

The get_origin() method gets the origin of the emblem. -

Functions

gio.emblem_new_with_origin

    def emblem_new_with_origin(icon, origin)

origin :

a Gio Emblem Origin Constants +

Functions

gio.emblem_new_with_origin

    def emblem_new_with_origin(icon, origin)

origin :

a Gio Emblem Origin Constants defining the emblem's origin.

Returns :

A gio.Emblem.

Note

diff --git a/docs/html/class-gioemblemedicon.html b/docs/html/class-gioemblemedicon.html index d4e4cfb..c92f9d8 100644 --- a/docs/html/class-gioemblemedicon.html +++ b/docs/html/class-gioemblemedicon.html @@ -1,11 +1,11 @@ -gio.EmblemedIcon

gio.EmblemedIcon

gio.EmblemedIcon — Icon with emblems.

Synopsis

class gio.EmblemedIcon(gobject.GObject, gio.Icon):
-    gio.EmblemedIcon(icon, emblem)
def add_emblem(emblem)
def get_icon()

Ancestry

+-- gobject.GObject
+gio.EmblemedIcon

gio.EmblemedIcon

gio.EmblemedIcon — Icon with emblems.

Synopsis

class gio.EmblemedIcon(gobject.GObject, gio.Icon):
+    gio.EmblemedIcon(icon, emblem)
def add_emblem(emblem)
def get_icon()

Implemented Interfaces

+

Implemented Interfaces

gio.EmblemedIcon implements gio.Icon -

Description

+

Description

The gio.EmblemedIcon class is an implementation of gio.Icon that supports adding an emblem to an icon. Adding multiple emblems to an icon is ensured via @@ -25,7 +25,7 @@

Creates a new gio.Icon for icon with the emblem emblem. -

Methods

gio.EmblemedIcon.add_emblem

    def add_emblem(emblem)

emblem :

a +

Methods

gio.EmblemedIcon.add_emblem

    def add_emblem(emblem)

emblem :

a gio.Emblem

The add_emblem() method adds emblem to the diff --git a/docs/html/class-giofile.html b/docs/html/class-giofile.html index 2c61524..e4aa905 100644 --- a/docs/html/class-giofile.html +++ b/docs/html/class-giofile.html @@ -1,12 +1,12 @@ -gio.File

gio.File

gio.File — File and Directory Handling.

Synopsis

class gio.File(gobject.GInterface):
+gio.File

gio.File

gio.File — File and Directory Handling.

Synopsis

class gio.File(gobject.GInterface):
     gio.File(commandline, path=None, uri=None)
def append_to(flags=gio.FILE_CREATE_NONE, cancellable=None)
def append_to_async(callback, flags=gio.FILE_CREATE_NONE, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def append_to_finish(result)
def copy(destination, progress_callback, flags=gio.FILE_COPY_NONE, cancellable=None, user_data=None)
def copy_async(destination, callback, progress_callback=None, flags=gio.FILE_CREATE_NONE, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None, progress_callback_data=None)
def copy_attributes(destination, flags=gio.FILE_COPY_NONE, cancellable=None)
def copy_finish(result)
def create(flags=gio.FILE_CREATE_NONE, cancellable=None)
def create_async(callback, flags=gio.FILE_CREATE_NONE, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def create_finish(result)
def delete(cancellable=None)
def dup()
def eject_mountable(callback, flags=gio.FILE_CREATE_NONE, cancellable=None, user_data=None)
def eject_mountable_finish(result)
def enumerate_children(attributes, flags=gio.FILE_QUERY_INFO_NONE, cancellable=None)
def enumerate_children_async(attributes, callback, flags=gio.FILE_QUERY_INFO_NONE, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def enumerate_children_finish(result)
def equal(file2)
def find_enclosing_mount(cancellable)
def find_enclosing_mount_async(callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def find_enclosing_mount_finish(result)
def get_basename()
def get_child(name)
def get_child_for_display_name(display_name)
def get_parent()
def get_parse_name()
def get_path()
def get_relative_path(descendant)
def get_uri()
def get_uri_scheme()
def has_prefix(prefix)
def has_uri_scheme(uri_scheme)
def is_native()
def load_contents(cancellable)
def load_contents_async(callback, cancellable=None, user_data=None)
def load_contents_finish(result)
def make_directory(cancellable=None)
def make_directory_with_parents(cancellable=None)
def make_symbolic_link(symlink_value, cancellable)
def monitor(flags=gio.FILE_MONITOR_NONE, cancellable=None)
def monitor_directory(flags, cancellable=None)
def monitor_file(flags, cancellable=None)
def mount_enclosing_volume(mount_operation, callback, flags=gio.MOUNT_MOUNT_NONE, cancellable=None, user_data=None)
def mount_enclosing_volume_finish(result)
def mount_mountable(mount_operation, callback, flags=gio.MOUNT_MOUNT_NONE, cancellable=None, user_data=None)
def mount_mountable_finish(result)
def move(destination, progress_callback, flags=gio.FILE_COPY_NONE, cancellable=None, user_data=None)
def query_default_handler(cancellable)
def query_exists(cancellable)
def query_file_type(flags, cancellable)
def query_filesystem_info(attributes, cancellable)
def query_filesystem_info_async(attributes, callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def query_filesystem_info_finish(result)
def query_info(attributes, flags, cancellable)
def query_info_async(attributes, callback, flags=gio.FILE_QUERY_INFO_NONE, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def query_info_finish(result)
def query_settable_attributes(cancellable=None)
def query_writable_namespace(cancellable=None)
def read(cancellable=None)
def read_async(callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def read_finish(result=None)
def replace(etag, make_backup, flags=gio.FILE_CREATE_NONE, cancellable=None)
def replace_async(callback, etag=None, make_backup=True, flags=gio.FILE_CREATE_NONE, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def replace_contents(contents, etag=None, make_backup=True, flags=gio.FILE_CREATE_NONE, cancellable=None)
def replace_contents_async(contents, callback, etag=None, make_backup=True, flags=gio.FILE_CREATE_NONE, cancellable=None, user_data=None)
def replace_contents_finish(result=None)
def replace_finish(result=None)
def resolve_relative_path(relative_path)
def set_attribute(attribute, type, value_p, flags=gio.FILE_QUERY_INFO_NONE, cancellable=None)
def set_attribute_byte_string(attribute, value, flags=gio.FILE_QUERY_INFO_NONE, cancellable=None)
def set_attribute_int32(attribute, value, flags=gio.FILE_QUERY_INFO_NONE, cancellable=None)
def set_attribute_int64(attribute, value, flags=gio.FILE_QUERY_INFO_NONE, cancellable=None)
def set_attribute_string(attribute, value, flags=gio.FILE_QUERY_INFO_NONE, cancellable=None)
def set_attribute_uint32(attribute, value, flags=gio.FILE_QUERY_INFO_NONE, cancellable=None)
def set_attribute_uint64(attribute, value, flags=gio.FILE_QUERY_INFO_NONE, cancellable=None)
def set_attributes_async(info, callback, flags=gio.FILE_QUERY_INFO_NONE, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def set_attributes_finish(result)
def set_attributes_from_info(info, flags=gio.FILE_QUERY_INFO_NONE, cancellable=None)
def set_dispay_name(display_name, cancellable=None)
def set_display_name_async(display_name, callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def set_display_name_finish(result)
def trash(cancellable=None)
def unmount_mountable(callback, flags=gio.MOUNT_UNMOUNT_NONE, cancellable=None, user_data=None)
def unmount_mountable_finish(cancellable=None)
 Functions
-    def gio.file_parse_name(parse_name)

Ancestry

+-- gobject.GInterface
+    def gio.file_parse_name(parse_name)

Ancestry

+-- gobject.GInterface
   +-- gio.File
-

Prerequisites

+

Prerequisites

gio.File is implemented by gobject.GObject -

Description

+

Description

gio.File is a high level abstraction for manipulating files on a virtual file system. gio.Files are lightweight, @@ -91,7 +91,7 @@

Creates a new gio.File either from a commandline, a path or an uri. -

Methods

gio.File.append_to

    def append_to(flags=gio.FILE_CREATE_NONE, cancellable=None)

flags :

a set of +

Methods

gio.File.append_to

    def append_to(flags=gio.FILE_CREATE_NONE, cancellable=None)

flags :

a set of Gio File Create Flags Constants

cancellable :

optional gio.Cancellable @@ -1425,7 +1425,7 @@ URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ] The unmount_mountable_finish() method finishes an asynchronous copy operation started with gio.File.unmount_mountable(). -

Functions

gio.file_parse_name

    def file_parse_name(parse_name)

parse_name :

a file name or path to be parsed. +

Functions

gio.file_parse_name

    def file_parse_name(parse_name)

parse_name :

a file name or path to be parsed.

Returns :

a new gio.File.

The parse_name() function constructs a diff --git a/docs/html/class-giofileattributeinfo.html b/docs/html/class-giofileattributeinfo.html index 00444a4..99fdcdf 100644 --- a/docs/html/class-giofileattributeinfo.html +++ b/docs/html/class-giofileattributeinfo.html @@ -1,7 +1,7 @@ -gio.FileAttributeInfo

gio.FileAttributeInfo

gio.FileAttributeInfo — Information about a specific attribute.

Synopsis

class gio.FileAttributeInfo(__builtin__.object):
-

Ancestry

+-- __builtin__.object
+gio.FileAttributeInfo

gio.FileAttributeInfo

gio.FileAttributeInfo — Information about a specific attribute.

Synopsis

class gio.FileAttributeInfo(__builtin__.object):
+

Ancestry

+-- __builtin__.object
   +-- gio.FileAttributeInfo
-

Description

+

Description

The gio.FileAttributeInfo contains information about a specific attribute.

gio.FileAttributeInfo Attributes

"name"ReadThe name of the attribute.
"type"Readthe diff --git a/docs/html/class-giofileenumerator.html b/docs/html/class-giofileenumerator.html index 117a94c..9d30ff3 100644 --- a/docs/html/class-giofileenumerator.html +++ b/docs/html/class-giofileenumerator.html @@ -1,7 +1,7 @@ -gio.FileEnumerator

gio.FileEnumerator

gio.FileEnumerator — Enumerated Files Routines.

Synopsis

class gio.FileEnumerator(gobject.GObject):
-    def close(cancellable=None)
def close_async(callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def close_finish(result)
def get_container()
def has_pending()
def is_closed()
def next_file(cancellable=None)
def next_files_async(num_files, callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def next_files_finish(result)
def set_pending(pending)

Ancestry

+-- gobject.GObject
+gio.FileEnumerator

gio.FileEnumerator

gio.FileEnumerator — Enumerated Files Routines.

Synopsis

class gio.FileEnumerator(gobject.GObject):
+    def close(cancellable=None)
def close_async(callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def close_finish(result)
def get_container()
def has_pending()
def is_closed()
def next_file(cancellable=None)
def next_files_async(num_files, callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def next_files_finish(result)
def set_pending(pending)

gio.FileEnumerator Properties

"container"Write - Construct onlyThe container that is being enumerated.

Description

+

gio.FileEnumerator Properties

"container"Write - Construct onlyThe container that is being enumerated.

Description

The gio.FileEnumerator allows you to operate on a set of gio.Files @@ -27,7 +27,7 @@ close_async. Once a gio.FileEnumerator is closed, no further actions may be performed on it. -

Methods

gio.FileEnumerator.close

    def close(cancellable=None)

cancellable :

Optional +

Methods

gio.FileEnumerator.close

    def close(cancellable=None)

cancellable :

Optional gio.Cancellable object, None to ignore.

Returns :

True on success or diff --git a/docs/html/class-giofileicon.html b/docs/html/class-giofileicon.html index b10772e..9ed697b 100644 --- a/docs/html/class-giofileicon.html +++ b/docs/html/class-giofileicon.html @@ -1,7 +1,7 @@ -gio.FileIcon

gio.FileIcon

gio.FileIcon — Icons pointing to an image file.

Synopsis

class gio.FileIcon(gobject.GObject, gio.Icon, gio.LoadableIcon):
-    gio.FileIcon(file)
def get_file()

Ancestry

+-- gobject.GObject
+gio.FileIcon

gio.FileIcon

gio.FileIcon — Icons pointing to an image file.

Synopsis

class gio.FileIcon(gobject.GObject, gio.Icon, gio.LoadableIcon):
+    gio.FileIcon(file)
def get_file()

Ancestry

+-- gobject.GObject
   +-- gio.FileIcon
-

Description

+

Description

The gio.FileIcon specifies an icon by pointing to an image file to be used as icon.

Constructor

    gio.FileIcon(file)

file :

a @@ -11,7 +11,7 @@ for the given file, or None on error.

Creates a new icon for a file. -

Methods

gio.FileIcon.get_file

    def get_file()

Returns :

a +

Methods

gio.FileIcon.get_file

    def get_file()

Returns :

a gio.File or None.

diff --git a/docs/html/class-giofileinfo.html b/docs/html/class-giofileinfo.html index bd01068..f44dbe0 100644 --- a/docs/html/class-giofileinfo.html +++ b/docs/html/class-giofileinfo.html @@ -1,7 +1,7 @@ -gio.FileInfo

gio.FileInfo

gio.FileInfo — File Information and Attributes

Synopsis

class gio.FileInfo(gobject.GObject):
-    gio.FileInfo()
def clear_status()
def copy_into()
def dup()
def get_attribute_as_string(attribute)
def get_attribute_boolean(attribute)
def get_attribute_byte_string(attribute)
def get_attribute_data(attribute)
def get_attribute_int32(attribute)
def get_attribute_int64(attribute)
def get_attribute_object(attribute)
def get_attribute_status(attribute)
def get_attribute_string(attribute)
def get_attribute_type(attribute)
def get_attribute_uint32(attribute)
def get_attribute_uint64(attribute)
def get_content_type()
def get_display_name()
def get_edit_name()
def get_etag()
def get_file_type()
def get_icon()
def get_is_backup()
def get_is_hidden()
def get_is_symlink()
def get_modification_time()
def get_name()
def get_size()
def get_sort_order()
def get_symlink_target()
def has_attribute(attribute)
def list_attributes(name_space)
def remove_attribute(attribute)
def set_attribute(attribute, type, value_p)
def set_attribute_boolean(attribute, attr_value)
def set_attribute_byte_string(attribute, attr_value)
def set_attribute_data(attribute, attr_value)
def set_attribute_int32(attribute, attr_value)
def set_attribute_int64(attribute, attr_value)
def set_attribute_mask(mask)
def set_attribute_object(attribute, attr_value)
def set_attribute_status(attribute, attr_value)
def set_attribute_string(attribute, attr_value)
def set_attribute_uint32(attribute)
def set_attribute_uint64(attribute)
def set_content_type(content_type)
def set_display_name(display_name)
def set_edit_name(edit_name)
def set_file_type(type)
def set_icon(icon)
def set_is_hidden(is_hidden)
def set_is_symlink(is_symlink)
def set_modification_time(mtime)
def set_name(name)
def set_size(size)
def set_sort_order(sort_order)
def set_symlink_tarset(symlink_target)
def unset_attribute_mask()

Ancestry

+-- gobject.GObject
+gio.FileInfo

gio.FileInfo

gio.FileInfo — File Information and Attributes

Synopsis

class gio.FileInfo(gobject.GObject):
+    gio.FileInfo()
def clear_status()
def copy_into()
def dup()
def get_attribute_as_string(attribute)
def get_attribute_boolean(attribute)
def get_attribute_byte_string(attribute)
def get_attribute_data(attribute)
def get_attribute_int32(attribute)
def get_attribute_int64(attribute)
def get_attribute_object(attribute)
def get_attribute_status(attribute)
def get_attribute_string(attribute)
def get_attribute_type(attribute)
def get_attribute_uint32(attribute)
def get_attribute_uint64(attribute)
def get_content_type()
def get_display_name()
def get_edit_name()
def get_etag()
def get_file_type()
def get_icon()
def get_is_backup()
def get_is_hidden()
def get_is_symlink()
def get_modification_time()
def get_name()
def get_size()
def get_sort_order()
def get_symlink_target()
def has_attribute(attribute)
def list_attributes(name_space)
def remove_attribute(attribute)
def set_attribute(attribute, type, value_p)
def set_attribute_boolean(attribute, attr_value)
def set_attribute_byte_string(attribute, attr_value)
def set_attribute_data(attribute, attr_value)
def set_attribute_int32(attribute, attr_value)
def set_attribute_int64(attribute, attr_value)
def set_attribute_mask(mask)
def set_attribute_object(attribute, attr_value)
def set_attribute_status(attribute, attr_value)
def set_attribute_string(attribute, attr_value)
def set_attribute_uint32(attribute)
def set_attribute_uint64(attribute)
def set_content_type(content_type)
def set_display_name(display_name)
def set_edit_name(edit_name)
def set_file_type(type)
def set_icon(icon)
def set_is_hidden(is_hidden)
def set_is_symlink(is_symlink)
def set_modification_time(mtime)
def set_name(name)
def set_size(size)
def set_sort_order(sort_order)
def set_symlink_tarset(symlink_target)
def unset_attribute_mask()

Ancestry

+-- gobject.GObject
   +-- gio.FileInfo
-

Description

+

Description

Functionality for manipulating basic metadata for files. gio.FileInfo implements methods for getting information that all files should contain, @@ -39,4 +39,4 @@ gio.FileInfo

Creates a new gio.FileInfo -

Methods

Unfinished section, you may want to see the relevant C API docs for methods descriptions.

+

Methods

Unfinished section, you may want to see the relevant C API docs for methods descriptions.

diff --git a/docs/html/class-giofileinputstream.html b/docs/html/class-giofileinputstream.html index cef8842..c259097 100644 --- a/docs/html/class-giofileinputstream.html +++ b/docs/html/class-giofileinputstream.html @@ -1,12 +1,12 @@ -gio.FileInputStream

gio.FileInputStream

gio.FileInputStream — Base class for implementing streaming input

Synopsis

class gio.FileInputStream(gio.InputStream):
-    def query_info(attributes, cancellable=None)
def query_info_async(attributes, callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def query_info_finish(result)

Ancestry

+-- gobject.GObject
+gio.FileInputStream

gio.FileInputStream

gio.FileInputStream — Base class for implementing streaming input

Synopsis

class gio.FileInputStream(gio.InputStream):
+    def query_info(attributes, cancellable=None)
def query_info_async(attributes, callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def query_info_finish(result)

Implemented Interfaces

+

Implemented Interfaces

gio.FileInputStream implements gio.Seekable -

Description

+

Description

gio.FileInputStream provides input streams that take their content from a file.

@@ -21,7 +21,7 @@ gio.Seekable.can_seek(). To position a file input stream, use gio.Seekable.seek(). -

Methods

gio.FileInputStream.query_info

    def query_info(attributes, cancellable=None)

attributes :

a file attribute query string. +

Methods

gio.FileInputStream.query_info

    def query_info(attributes, cancellable=None)

attributes :

a file attribute query string.

cancellable :

optional gio.Cancellable object, None to ignore. diff --git a/docs/html/class-giofilemonitor.html b/docs/html/class-giofilemonitor.html index 3fbd1f7..020267f 100644 --- a/docs/html/class-giofilemonitor.html +++ b/docs/html/class-giofilemonitor.html @@ -1,12 +1,12 @@ -gio.FileMonitor

gio.FileMonitor

gio.FileMonitor — File Monitor

Synopsis

class gio.FileMonitor(gobject.GObject):
-    def cancel()
def emit_event(child, other_file, event_type)
def is_cancelled()
def set_rate_limit(limit_msecs)

Ancestry

+-- gobject.GObject
+gio.FileMonitor

gio.FileMonitor

gio.FileMonitor — File Monitor

Synopsis

class gio.FileMonitor(gobject.GObject):
+    def cancel()
def emit_event(child, other_file, event_type)
def is_cancelled()
def set_rate_limit(limit_msecs)

gio.FileMonitor Properties

"cancelled"Read Whether the monitor has been cancelled. Default value: False.
"rate-limit"Read/Write The limit of the monitor to watch for changes, in milliseconds. Allowed values: >= 0. Default value: 800. -

gio.FileMonitor Signal Prototypes

gobject.GObject Signal Prototypes

"changed"

def callback(filemonitor, file, other_file, event_type, user_param1, ...)

Description

+

gio.FileMonitor Signal Prototypes

gobject.GObject Signal Prototypes

"changed"

def callback(filemonitor, file, other_file, event_type, user_param1, ...)

Description

The gio.FileMonitor monitors a file or directory for changes.

@@ -18,4 +18,4 @@

To get informed about changes to the file or directory you are monitoring, connect to the "changed" signal. -

Methods

Unfinished section, you may want to see the relevant C API docs for methods descriptions.

+

Methods

Unfinished section, you may want to see the relevant C API docs for methods descriptions.

diff --git a/docs/html/class-giofileoutputstream.html b/docs/html/class-giofileoutputstream.html index aaa529f..5f11267 100644 --- a/docs/html/class-giofileoutputstream.html +++ b/docs/html/class-giofileoutputstream.html @@ -1,12 +1,12 @@ -gio.FileOutputStream

gio.FileOutputStream

gio.FileOutputStream — Base class for implementing streaming input

Synopsis

class gio.FileOutputStream(gio.OutputStream):
-    def get_etag()
def query_info(attributes, cancellable=None)
def query_info_async(attributes, callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def query_info_finish(result)

Ancestry

+-- gobject.GObject
+gio.FileOutputStream

gio.FileOutputStream

gio.FileOutputStream — Base class for implementing streaming input

Synopsis

class gio.FileOutputStream(gio.OutputStream):
+    def get_etag()
def query_info(attributes, cancellable=None)
def query_info_async(attributes, callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def query_info_finish(result)

Implemented Interfaces

+

Implemented Interfaces

gio.FileOutputStream implements gio.Seekable -

Description

+

Description

gio.FileOutputStream provides output streams that write their content to a file.

@@ -26,7 +26,7 @@ gio.FileOutputStream.can_truncate(). To truncate a file output stream, use gio.Seekable.truncate(). -

Methods

gio.FileOutputStream.get_etag

    def get_etag()

Returns :

the entity tag for the stream. +

Methods

gio.FileOutputStream.get_etag

    def get_etag()

Returns :

the entity tag for the stream.

The get_etag() method gets the entity tag for the file when it has been written. This must be called after the diff --git a/docs/html/class-giofilterinputstream.html b/docs/html/class-giofilterinputstream.html index 52a66d4..124420f 100644 --- a/docs/html/class-giofilterinputstream.html +++ b/docs/html/class-giofilterinputstream.html @@ -1,11 +1,11 @@ -gio.FilterInputStream

gio.FilterInputStream

gio.FilterInputStream — Filter Input Stream

Synopsis

class gio.FilterInputStream(gio.InputStream):
-    def get_base_stream()
def get_close_base_stream()
def set_close_base_stream(close_base)

Ancestry

+-- gobject.GObject
+gio.FilterInputStream

gio.FilterInputStream

gio.FilterInputStream — Filter Input Stream

Synopsis

class gio.FilterInputStream(gio.InputStream):
+    def get_base_stream()
def get_close_base_stream()
def set_close_base_stream(close_base)

gio.FilterInputStream Properties

"base-stream"Read - Write - Construct onlyThe underlying base stream on which the io ops will be done.
"close-base-stream"Read - Write - Construct onlyIf the base stream should be closed when the filter stream is closed. - Default value: True.

Description

+ Default value: True.

Description

Filter Input Stream. -

Methods

gio.FilterInputStream.get_base_stream

    def get_base_stream()

Returns :

A +

Methods

gio.FilterInputStream.get_base_stream

    def get_base_stream()

Returns :

A gio.InputStream

The get_base_stream() method gets the base diff --git a/docs/html/class-giofilteroutputstream.html b/docs/html/class-giofilteroutputstream.html index 18bed0e..8f81914 100644 --- a/docs/html/class-giofilteroutputstream.html +++ b/docs/html/class-giofilteroutputstream.html @@ -1,11 +1,11 @@ -gio.FilterOutputStream

gio.FilterOutputStream

gio.FilterOutputStream — Filter Output Stream

Synopsis

class gio.FilterOutputStream(gio.OutputStream):
-    def get_base_stream()
def get_close_base_stream()
def set_close_base_stream(close_base)

Ancestry

+-- gobject.GObject
+gio.FilterOutputStream

gio.FilterOutputStream

gio.FilterOutputStream — Filter Output Stream

Synopsis

class gio.FilterOutputStream(gio.OutputStream):
+    def get_base_stream()
def get_close_base_stream()
def set_close_base_stream(close_base)

gio.FilterOutputStream Properties

"base-stream"Read - Write - Construct onlyThe underlying base stream on which the io ops will be done.
"close-base-stream"Read - Write - Construct onlyIf the base stream should be closed when the filter stream is closed. - Default value: True.

Description

+ Default value: True.

Description

Filter Output Stream. -

Methods

gio.FilterOutputStream.get_base_stream

    def get_base_stream()

Returns :

A +

Methods

gio.FilterOutputStream.get_base_stream

    def get_base_stream()

Returns :

A gio.OutputStream

The get_base_stream() method gets the base diff --git a/docs/html/class-gioicon.html b/docs/html/class-gioicon.html index c10c65d..0d2489b 100644 --- a/docs/html/class-gioicon.html +++ b/docs/html/class-gioicon.html @@ -1,19 +1,19 @@ -gio.Icon

gio.Icon

gio.Icon — Interface for icons.

Synopsis

class gio.Icon(gobject.GInterface):
+gio.Icon

gio.Icon

gio.Icon — Interface for icons.

Synopsis

class gio.Icon(gobject.GInterface):
     def equal(icon2)
def to_string()
 Functions
  
-    def gio.icon_new_from_string()

Ancestry

+-- gobject.GInterface
   +-- gio.Icon
-

Known Derived Interfaces

+

Known Derived Interfaces

gio.Icon is required by gio.LoadableIcon. -

Known Implementation

+

Known Implementation

gio.Icon is implemented by gio.ThemedIcon, gio.FileIcon, gio.Emblem, gio.EmblemedIcon. -

Description

+

Description

gio.Icon is a very minimal interface for icons. It provides functions for checking the equality of two icons, hashing of icons and serializing an icon to and from strings. @@ -39,7 +39,7 @@ implementations you need to ensure that each GType is registered with the type system prior to calling gio.icon_new_from_string(). -

Methods

gio.Icon.equal

    def equal(icon2)

icon2 :

the second +

Methods

gio.Icon.equal

    def equal(icon2)

icon2 :

the second gio.Icon

The equal() method checks if two icons are equal. @@ -63,7 +63,7 @@

If icon is a gio.ThemedIcon with exactly one name, the encoding is simply the name (such as network-server). -

Functions

gio.icon_new_from_string

    def icon_new_from_string(str)

str :

A string obtained via +

Functions

gio.icon_new_from_string

    def icon_new_from_string(str)

str :

A string obtained via gio.Icon.to_string().

Returns :

An object implementing the gio.Icon diff --git a/docs/html/class-gioinputstream.html b/docs/html/class-gioinputstream.html index fd9efa8..ab389da 100644 --- a/docs/html/class-gioinputstream.html +++ b/docs/html/class-gioinputstream.html @@ -1,7 +1,7 @@ -gio.InputStream

gio.InputStream

gio.InputStream — Base class for implementing streaming input

Synopsis

class gio.InputStream(gobject.GObject):
-    def clear_pending()
def close(cancellable=None)
def close_async(callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def close_finish(result)
def has_pending()
def is_closed()
def read(count=-1, cancellable=None)
def read_async(count, callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def read_finish(result)
def read_part(count=-1, cancellable=None)
def set_pending()
def skip(count, cancellable=None)
def skip_async(count, callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def skip_finish(result)

Ancestry

+-- gobject.GObject
+gio.InputStream

gio.InputStream

gio.InputStream — Base class for implementing streaming input

Synopsis

class gio.InputStream(gobject.GObject):
+    def clear_pending()
def close(cancellable=None)
def close_async(callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def close_finish(result)
def has_pending()
def is_closed()
def read(count=-1, cancellable=None)
def read_async(count, callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def read_finish(result)
def read_part(count=-1, cancellable=None)
def set_pending()
def skip(count, cancellable=None)
def skip_async(count, callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def skip_finish(result)

Description

+

Description

gio.InputStream has functions to read from a stream ( gio.InputStream.read() @@ -16,7 +16,7 @@ gio.OutputStream.splice().

All of these functions have async variants too. -

Methods

gio.InputStream.clear_pending

    def clear_pending()

+

Methods

gio.InputStream.clear_pending

    def clear_pending()

The clear_pending() method clears the pending flag on stream.

gio.InputStream.close

    def close(cancellable=None)

cancellable :

optional gio.Cancellable diff --git a/docs/html/class-gioloadableicon.html b/docs/html/class-gioloadableicon.html index f76c42c..e224147 100644 --- a/docs/html/class-gioloadableicon.html +++ b/docs/html/class-gioloadableicon.html @@ -1,18 +1,18 @@ -gio.LoadableIcon

gio.LoadableIcon

gio.LoadableIcon — Interface for icons.

Synopsis

class gio.LoadableIcon(gobject.GInterface):
-    def load(size=0, cancellable=None)
def load_async(callback, size=0, cancellable=None, user_data=None)
def load_finish(res)

Ancestry

+-- gobject.GInterface
+gio.LoadableIcon

gio.LoadableIcon

gio.LoadableIcon — Interface for icons.

Synopsis

class gio.LoadableIcon(gobject.GInterface):
+    def load(size=0, cancellable=None)
def load_async(callback, size=0, cancellable=None, user_data=None)
def load_finish(res)

Prerequisites

+

Prerequisites

gio.LoadableIcon requires gio.Icon. and gobject.GObject -

Known Implementation

+

Known Implementation

gio.LoadableIcon is implemented by gio.FileIcon -

Description

+

Description

gio.LoadableIcon extends the gio.Icon interface and adds the ability to load icons from streams. -

Methods

gio.LoadableIcon.load

    def load(size=0, cancellable=None)

size :

an integer +

Methods

gio.LoadableIcon.load

    def load(size=0, cancellable=None)

size :

an integer

cancellable :

optional gio.Cancellable object, None to ignore. diff --git a/docs/html/class-giomemoryinputstream.html b/docs/html/class-giomemoryinputstream.html index acee406..54fe461 100644 --- a/docs/html/class-giomemoryinputstream.html +++ b/docs/html/class-giomemoryinputstream.html @@ -1,15 +1,15 @@ -gio.MemoryInputStream

gio.MemoryInputStream

gio.MemoryInputStream — Base class for implementing streaming input

Synopsis

class gio.MemoryInputStream(gio.InputStream):
+gio.MemoryInputStream

gio.MemoryInputStream

gio.MemoryInputStream — Base class for implementing streaming input

Synopsis

class gio.MemoryInputStream(gio.InputStream):
     gio.MemoryInputStream()
def add_data(data)
 Functions
  
-    def gio.memory_input_stream_new_from_data(data)

Implemented Interfaces

+

Implemented Interfaces

gio.MemoryInputStream implements gio.Seekable -

Description

+

Description

gio.MemoryInputStream is a class for using arbitrary memory chunks as input for GIO streaming input operations.

Constructor

    gio.MemoryInputStream(icon)

Returns :

a new @@ -17,11 +17,11 @@

Creates an empty gio.MemoryInputStream. -

Methods

gio.MemoryInputStream.add_data

    def add_data(data)

data :

input data. +

Methods

gio.MemoryInputStream.add_data

    def add_data(data)

data :

input data.

The add_data() method appends data to data that can be read from the input stream -

Functions

gio.memory_input_stream_new_from_data

    def memory_input_stream_new_from_data(data)

data :

input data. +

Functions

gio.memory_input_stream_new_from_data

    def memory_input_stream_new_from_data(data)

data :

input data.

Returns :

A new gio.MemoryInputStream read from data diff --git a/docs/html/class-giomemoryoutputstream.html b/docs/html/class-giomemoryoutputstream.html index bc36c22..1d19e90 100644 --- a/docs/html/class-giomemoryoutputstream.html +++ b/docs/html/class-giomemoryoutputstream.html @@ -1,12 +1,12 @@ -gio.MemoryOutputStream

gio.MemoryOutputStream

gio.MemoryOutputStream — Streaming output operations on memory chunks

Synopsis

class gio.MemoryOutputStream(gio.OutputStream):
-    gio.MemoryOutputStream()
def get_contents()
def get_data_size()
def get_size()

Ancestry

+-- gobject.GObject
+gio.MemoryOutputStream

gio.MemoryOutputStream

gio.MemoryOutputStream — Streaming output operations on memory chunks

Synopsis

class gio.MemoryOutputStream(gio.OutputStream):
+    gio.MemoryOutputStream()
def get_contents()
def get_data_size()
def get_size()

Implemented Interfaces

+

Implemented Interfaces

gio.MemoryOutputStream implements gio.Seekable -

Description

+

Description

gio.MemoryOutputStream is a class for using arbitrary memory chunks as output for GIO streaming output operations.

Constructor

    gio.MemoryOutputStream()

Returns :

a new @@ -14,7 +14,7 @@

Creates a new gio.MemoryOutputStream. -

Methods

gio.MemoryOutputStream.get_contents

    def get_contents()

Returns :

the stream's data +

Methods

gio.MemoryOutputStream.get_contents

    def get_contents()

Returns :

the stream's data

The get_contents() method gets any loaded data from the ostream. diff --git a/docs/html/class-giomount.html b/docs/html/class-giomount.html index 04f9cd9..8a8a12b 100644 --- a/docs/html/class-giomount.html +++ b/docs/html/class-giomount.html @@ -1,10 +1,10 @@ -gio.Mount

gio.Mount

gio.Mount — Mount management

Synopsis

class gio.Mount(gobject.GInterface):
-    def can_eject()
def can_unmount()
def eject(callback, flags=gio.MOUNT_UNMOUNT_NONE, cancellable=None, user_data=None)
def eject_finish(result)
def get_drive()
def get_icon()
def get_name()
def get_root()
def get_uuid()
def get_volume()
def guess_content_type(callback, force_rescan, cancellable=None, user_data=None)
def guess_content_type_finish(result)
def guess_content_type_sync(force_rescan, cancellable=None)
def is_shadowed()
def remount(callback, flags=gio.MOUNT_UNMOUNT_NONE, mount_operation=None, cancellable=None, user_data=None)
def remount_finish(result)
def shadow()
def unmount(callback, flags=gio.MOUNT_UNMOUNT_NONE, cancellable=None, user_data=None)
def unmount_finish(result)
def unshadow()

Ancestry

+-- gobject.GInterface
+gio.Mount

gio.Mount

gio.Mount — Mount management

Synopsis

class gio.Mount(gobject.GInterface):
+    def can_eject()
def can_unmount()
def eject(callback, flags=gio.MOUNT_UNMOUNT_NONE, cancellable=None, user_data=None)
def eject_finish(result)
def get_drive()
def get_icon()
def get_name()
def get_root()
def get_uuid()
def get_volume()
def guess_content_type(callback, force_rescan, cancellable=None, user_data=None)
def guess_content_type_finish(result)
def guess_content_type_sync(force_rescan, cancellable=None)
def is_shadowed()
def remount(callback, flags=gio.MOUNT_UNMOUNT_NONE, mount_operation=None, cancellable=None, user_data=None)
def remount_finish(result)
def shadow()
def unmount(callback, flags=gio.MOUNT_UNMOUNT_NONE, cancellable=None, user_data=None)
def unmount_finish(result)
def unshadow()

Ancestry

+-- gobject.GInterface
   +-- gio.Mount
-

Prerequisites

+

Prerequisites

gio.Mount requires gobject.GObject -

gio.Mount Signal Prototypes

gobject.GObject Signal Prototypes

"aborted"

def callback(mount, user_param1, ...)

"changed"

def callback(mount, user_param1, ...)

"unmounted"

def callback(mount, user_param1, ...)

Description

+

gio.Mount Signal Prototypes

gobject.GObject Signal Prototypes

"aborted"

def callback(mount, user_param1, ...)

"changed"

def callback(mount, user_param1, ...)

"unmounted"

def callback(mount, user_param1, ...)

Description

The gio.Mount interface represents user-visible mounts. Note, when porting from GnomeVFS, gio.Mount @@ -28,7 +28,7 @@ with the GMount and the GAsyncReady data to see if the operation was completed successfully. If an error is present when g_mount_unmount_finish() is called, then it will be filled with any error information. -

Methods

gio.Mount.can_eject

    def can_eject()

Returns :

True if the mount can be ejected, +

Methods

gio.Mount.can_eject

    def can_eject()

Returns :

True if the mount can be ejected, False otherwise.

The can_eject() method checks if a mount can be ejected. @@ -221,7 +221,7 @@ gio.Mount.is_shadowed() for more information. The caller will need to emit the "changed" signal on mount manually. -

Signals

The "aborted" gio.Mount Signal

    def callback(mount, user_param1, ...)

mount :

the mount

user_param1 :

the first user parameter (if any) specified +

Signals

The "aborted" gio.Mount Signal

    def callback(mount, user_param1, ...)

mount :

the mount

user_param1 :

the first user parameter (if any) specified with the connect() method

... :

additional user parameters (if any)

Emitted by the backend when e.g. a device becomes unavailable while a diff --git a/docs/html/class-giomountoperation.html b/docs/html/class-giomountoperation.html index d71b469..2a64d88 100644 --- a/docs/html/class-giomountoperation.html +++ b/docs/html/class-giomountoperation.html @@ -1,5 +1,5 @@ -gio.MountOperation

gio.MountOperation

gio.MountOperation — Authentication methods for mountable locations.

Synopsis

class gio.MountOperation(gobject.GObject):
-    gio.MountOperation()
def get_anonymous()
def get_choice()
def get_domain()
def get_password()
def get_password_save()
def get_username()
def replay(result)
def set_anonymous(anonymous)
def set_choice(choice)
def set_domain(domain)
def set_password(password)
def set_password_save(save)
def set_username(username)

Ancestry

+-- gobject.GObject
+gio.MountOperation

gio.MountOperation

gio.MountOperation — Authentication methods for mountable locations.

Synopsis

class gio.MountOperation(gobject.GObject):
+    gio.MountOperation()
def get_anonymous()
def get_choice()
def get_domain()
def get_password()
def get_password_save()
def get_username()
def replay(result)
def set_anonymous(anonymous)
def set_choice(choice)
def set_domain(domain)
def set_password(password)
def set_password_save(save)
def set_username(username)

gio.MountOperation Properties

"anonymous"Read/Write Whether to use an anonymous user when authenticating. @@ -19,7 +19,7 @@
"username"Read/Write The user name that is used for authentication when carrying out the mount operation. Default value: None -

gio.MountOperation Signal Prototypes

gobject.GObject Signal Prototypes

"aborted"

def callback(mountoperation, user_param1, ...)

"ask-password"

def callback(mountoperation, message, default_user, default_domain, flags, user_param1, ...)

"ask-question"

def callback(mountoperation, message, choices, user_param1, ...)

"reply"

def callback(mountoperation, result, user_param1, ...)

Description

+

gio.MountOperation Signal Prototypes

gobject.GObject Signal Prototypes

"aborted"

def callback(mountoperation, user_param1, ...)

"ask-password"

def callback(mountoperation, message, default_user, default_domain, flags, user_param1, ...)

"ask-question"

def callback(mountoperation, message, choices, user_param1, ...)

"reply"

def callback(mountoperation, result, user_param1, ...)

Description

The gio.MountOperation provides a mechanism for authenticating mountable operations, such as loop mounting files, hard drive partitions or server locations. @@ -37,7 +37,7 @@ gio.MountOperation.

Creates a new mount operation. -

Methods

gio.MountOperation.get_anonymous

    def get_anonymous()

Returns :

True if mount operation is anonymous. +

Methods

gio.MountOperation.get_anonymous

    def get_anonymous()

Returns :

True if mount operation is anonymous.

The get_anonymous() method check to see whether the mount operation is being used for an anonymous user @@ -92,7 +92,7 @@

The set_anonymous() method sets the user name within op to username. -

Signals

The "aborted" gio.MountOperation Signal

    def callback(mountoperation, user_param1, ...)

mountoperation :

the mountoperation

user_param1 :

the first user parameter (if any) specified +

Signals

The "aborted" gio.MountOperation Signal

    def callback(mountoperation, user_param1, ...)

mountoperation :

the mountoperation

user_param1 :

the first user parameter (if any) specified with the connect() method

... :

additional user parameters (if any)

Emitted by the backend when e.g. a device becomes unavailable while a mount operation is in progress. diff --git a/docs/html/class-giooutputstream.html b/docs/html/class-giooutputstream.html index b1b2798..4f36724 100644 --- a/docs/html/class-giooutputstream.html +++ b/docs/html/class-giooutputstream.html @@ -1,7 +1,7 @@ -gio.OutputStream

gio.OutputStream

gio.OutputStream — Base class for implementing streaming input

Synopsis

class gio.OutputStream(gobject.GObject):
-    def clear_pending()
def close(cancellable=None)
def close_async(callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def close_finish(result)
def flush(cancellable=None)
def flush_async(callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def flush_finish(result)
def has_pending()
def is_closed()
def set_pending()
def splice(cancellable=None, flags=gio.OUTPUT_STREAM_SPLICE_NONE)
def splice_async(source, callback, flags=gio.OUTPUT_STREAM_SPLICE_NONE, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def splice_finish(result)
def write(buffer, cancellable=None)
def write_async(buffer, callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def write_finish(result)

Ancestry

+-- gobject.GObject
+gio.OutputStream

gio.OutputStream

gio.OutputStream — Base class for implementing streaming input

Synopsis

class gio.OutputStream(gobject.GObject):
+    def clear_pending()
def close(cancellable=None)
def close_async(callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def close_finish(result)
def flush(cancellable=None)
def flush_async(callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def flush_finish(result)
def has_pending()
def is_closed()
def set_pending()
def splice(cancellable=None, flags=gio.OUTPUT_STREAM_SPLICE_NONE)
def splice_async(source, callback, flags=gio.OUTPUT_STREAM_SPLICE_NONE, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def splice_finish(result)
def write(buffer, cancellable=None)
def write_async(buffer, callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def write_finish(result)

Description

+

Description

gio.OutputStream has functions to write from a stream ( gio.OutputStream.write() @@ -16,4 +16,4 @@ gio.OutputStream.splice().

All of these functions have async variants too. -

Methods

Unfinished section, you may want to see the relevant C API docs for methods descriptions.

+

Methods

Unfinished section, you may want to see the relevant C API docs for methods descriptions.

diff --git a/docs/html/class-gioseekable.html b/docs/html/class-gioseekable.html index 58c7533..98e717c 100644 --- a/docs/html/class-gioseekable.html +++ b/docs/html/class-gioseekable.html @@ -1,19 +1,19 @@ -gio.Seekable

gio.Seekable

gio.Seekable — Stream seeking interface.

Synopsis

class gio.Seekable(gobject.GInterface):
-    def tell()
def can_seek()
def seek(offset, type=0, cancellable=None)
def can_truncate()
def truncate(offset, cancellable=None)

Ancestry

+-- gobject.GInterface
+gio.Seekable

gio.Seekable

gio.Seekable — Stream seeking interface.

Synopsis

class gio.Seekable(gobject.GInterface):
+    def tell()
def can_seek()
def seek(offset, type=0, cancellable=None)
def can_truncate()
def truncate(offset, cancellable=None)

Known Implementation

+

Description

+

Description

gio.Seekable is implemented by streams (implementations of gio.InputStream or gio.OutputStream) that support seeking. -

Methods

gio.Seekable.tell

    def tell()

Returns :

+

Methods

gio.Seekable.tell

    def tell()

Returns :

the offset from the beginning of the buffer

Tells the current position within the stream. diff --git a/docs/html/class-giosimpleasyncresult.html b/docs/html/class-giosimpleasyncresult.html index b9eadb0..9da8dd2 100644 --- a/docs/html/class-giosimpleasyncresult.html +++ b/docs/html/class-giosimpleasyncresult.html @@ -1,10 +1,10 @@ -gio.SimpleAsyncResult

gio.SimpleAsyncResult

gio.SimpleAsyncResult — Simple asynchronous results implementation.

Synopsis

class gio.SimpleAsyncResult(gobject.GObject):
-    def complete()
def complete_in_idle()
def get_op_res_gboolean()
def get_op_res_gssize()
def propagate_error()
def set_handle_cancellation(handle_cancellation)
def set_op_res_gboolean(op_res)
def set_op_res_gssize(op_res)

Ancestry

+-- gobject.GObject
+gio.SimpleAsyncResult

gio.SimpleAsyncResult

gio.SimpleAsyncResult — Simple asynchronous results implementation.

Synopsis

class gio.SimpleAsyncResult(gobject.GObject):
+    def complete()
def complete_in_idle()
def get_op_res_gboolean()
def get_op_res_gssize()
def propagate_error()
def set_handle_cancellation(handle_cancellation)
def set_op_res_gboolean(op_res)
def set_op_res_gssize(op_res)

Implemented Interface

+

Implemented Interface

gio.SimpleAsyncResult implements gio.AsyncResult. -

Description

+

Description

Implements gio.AsyncResult for simple cases. Most of the time, this will be all an application needs, and will be used transparently Because of this, GSimpleAsyncResult is used throughout GIO for handling asynchronous functions. @@ -49,7 +49,7 @@ gio.SimpleAsyncResult.get_op_res_gboolean() and gio.SimpleAsyncResult.get_op_res_gssize() are provided, getting the operation's result as a gboolean and gssize, respectively. -

Methods

gio.SimpleAsyncResult.complete

    def complete()

+

Methods

gio.SimpleAsyncResult.complete

    def complete()

The complete() method completes an asynchronous I/O job. Must be called in the main thread, as it invokes the callback that should be called in the main thread. If you are in a different thread use diff --git a/docs/html/class-giothemedicon.html b/docs/html/class-giothemedicon.html index 3d81bd8..3f6e99d 100644 --- a/docs/html/class-giothemedicon.html +++ b/docs/html/class-giothemedicon.html @@ -1,5 +1,5 @@ -gio.ThemedIcon

gio.ThemedIcon

gio.ThemedIcon — Icon theming support.

Synopsis

class gio.ThemedIcon(gobject.GObject):
-    gio.ThemedIcon()
def append_name()
def get_names()
def prepend_name()

Ancestry

+-- gobject.GObject
+gio.ThemedIcon

gio.ThemedIcon

gio.ThemedIcon — Icon theming support.

Synopsis

class gio.ThemedIcon(gobject.GObject):
+    gio.ThemedIcon()
def append_name()
def get_names()
def prepend_name()

gio.ThemedIcon Properties

"name"Write/Contruct Only The icon name. Default value: None @@ -9,7 +9,7 @@ Whether to use the default fallbacks found by shortening the icon name at '-' characters. If the "names" array has more than one element, ignores any past the first. -

Description

+

Description

gio.ThemedIcon is an implementation of gio.Icon that supports icon themes. GThemedIcon contains a list of all of the icons present in an icon @@ -27,7 +27,7 @@ Creates a new themed icon from icon name, if instead of an icon name you provide a list of icon names, the gio.ThemedIcon will be constructed using the items in the list. -

Methods

gio.ThemedIcon.append_name

    def append_name()

name :

name of icon to append to list of icons from within icon. +

Methods

gio.ThemedIcon.append_name

    def append_name()

name :

name of icon to append to list of icons from within icon.

The append_name() method appends a name to the list of icons from within icon. diff --git a/docs/html/class-giounixinputstream.html b/docs/html/class-giounixinputstream.html index d7adeff..50b0e78 100644 --- a/docs/html/class-giounixinputstream.html +++ b/docs/html/class-giounixinputstream.html @@ -1,9 +1,9 @@ -gio.unix.InputStream

gio.unix.InputStream

gio.unix.InputStream — Streaming input operations for UNIX file descriptors.

Synopsis

class gio.unix.InputStream(gio.InputStream):
-    gio.unix.InputStream(fd, close_fd)
def get_close_fd()
def get_fd()
def set_close_fd(close_fd)

Ancestry

+-- gobject.GObject
+gio.unix.InputStream

gio.unix.InputStream

gio.unix.InputStream — Streaming input operations for UNIX file descriptors.

Synopsis

class gio.unix.InputStream(gio.InputStream):
+    gio.unix.InputStream(fd, close_fd)
def get_close_fd()
def get_fd()
def set_close_fd(close_fd)

gio.unix.InputStream Properties

"close-fd"Read - WriteWhether to close the file descriptor when the stream is closed. - Default value: True.
"fd"Read - Write - Construct onlyThe file descriptor that the stream reads from. Default value: -1.

Description

+ Default value: True.

"fd"Read - Write - Construct onlyThe file descriptor that the stream reads from. Default value: -1.

Description

gio.unix.InputStream implements gio.InputStream for reading from a UNIX file descriptor, including asynchronous operations. @@ -22,7 +22,7 @@ from the given fd.

If close_fd is True, the file descriptor will be closed when the stream is closed. -

Methods

gio.unix.InputStream.get_close_fd

    def get_close_fd()

Returns :

True if the file descriptor is closed when done. +

Methods

gio.unix.InputStream.get_close_fd

    def get_close_fd()

Returns :

True if the file descriptor is closed when done.

The get_close_fd() method returns whether the file descriptor of stream will be closed when the stream is closed. diff --git a/docs/html/class-giounixoutputstream.html b/docs/html/class-giounixoutputstream.html index f55bc49..80fa25e 100644 --- a/docs/html/class-giounixoutputstream.html +++ b/docs/html/class-giounixoutputstream.html @@ -1,9 +1,9 @@ -gio.unix.OutputStream

gio.unix.OutputStream

gio.unix.OutputStream — Streaming output operations for UNIX file descriptors.

Synopsis

class gio.unix.OutputStream(gio.OutputStream):
-    gio.unix.OutputStream(fd, close_fd)
def get_close_fd()
def get_fd()
def set_close_fd(close_fd)

Ancestry

+-- gobject.GObject
+gio.unix.OutputStream

gio.unix.OutputStream

gio.unix.OutputStream — Streaming output operations for UNIX file descriptors.

Synopsis

class gio.unix.OutputStream(gio.OutputStream):
+    gio.unix.OutputStream(fd, close_fd)
def get_close_fd()
def get_fd()
def set_close_fd(close_fd)

gio.unix.OutputStream Properties

"close-fd"Read - WriteWhether to close the file descriptor when the stream is closed. - Default value: True.
"fd"Read - Write - Construct onlyThe file descriptor that the stream writes to. Default value: -1.

Description

+ Default value: True.

"fd"Read - Write - Construct onlyThe file descriptor that the stream writes to. Default value: -1.

Description

gio.unix.OutputStream implements gio.OutputStream for writing to a UNIX file descriptor, including asynchronous operations. @@ -22,7 +22,7 @@ from the given fd.

If close_fd is True, the file descriptor will be closed when the stream is closed. -

Methods

gio.unix.OutputStream.get_close_fd

    def get_close_fd()

Returns :

True if the file descriptor is closed when done. +

Methods

gio.unix.OutputStream.get_close_fd

    def get_close_fd()

Returns :

True if the file descriptor is closed when done.

The get_close_fd() method returns whether the file descriptor of stream will be closed when the stream is closed. diff --git a/docs/html/class-giovolume.html b/docs/html/class-giovolume.html index b23af50..b594ded 100644 --- a/docs/html/class-giovolume.html +++ b/docs/html/class-giovolume.html @@ -1,10 +1,10 @@ -gio.Volume

gio.Volume

gio.Volume — Volume management.

Synopsis

class gio.Volume(gobject.GInterface):
-    def can_eject()
def can_mount()
def eject(callback, flags=gio.MOUNT_UNMOUNT_NONE, cancellable=None, user_data=None)
def eject_finish(result)
def enumerate_identifiers()
def get_activation_root()
def get_drive()
def get_icon()
def get_identifier()
def get_mount()
def get_name()
def get_uuid()
def mount(mount_operation, callback, flags=gio.MOUNT_MOUNT_NONE, cancellable=None, user_data=None)
def mount_finish(result)
def should_automount()

Ancestry

+-- gobject.GInterface
+gio.Volume

gio.Volume

gio.Volume — Volume management.

Synopsis

class gio.Volume(gobject.GInterface):
+    def can_eject()
def can_mount()
def eject(callback, flags=gio.MOUNT_UNMOUNT_NONE, cancellable=None, user_data=None)
def eject_finish(result)
def enumerate_identifiers()
def get_activation_root()
def get_drive()
def get_icon()
def get_identifier()
def get_mount()
def get_name()
def get_uuid()
def mount(mount_operation, callback, flags=gio.MOUNT_MOUNT_NONE, cancellable=None, user_data=None)
def mount_finish(result)
def should_automount()

Ancestry

+-- gobject.GInterface
   +-- gio.Volume
-

Prerequisites

+

Prerequisites

gio.Volume requires gobject.GObject -

gio.Volume Signal Prototypes

gobject.GObject Signal Prototypes

"changed"

def callback(volume, user_param1, ...)

"removed"

def callback(volume, user_param1, ...)

Description

+

gio.Volume Signal Prototypes

gobject.GObject Signal Prototypes

"changed"

def callback(volume, user_param1, ...)

"removed"

def callback(volume, user_param1, ...)

Description

The gio.Volume interface represents user-visible objects that can be mounted. Note, when porting from GnomeVFS, gio.Volume @@ -39,7 +39,7 @@ "hal-udi", "label", etc. Use gio.Volume.get_identifier() to obtain an identifier for a volume. -

Methods

gio.Volume.can_eject

    def can_eject()

Returns :

True if the volume can be ejected, +

Methods

gio.Volume.can_eject

    def can_eject()

Returns :

True if the volume can be ejected, False otherwise.

The can_eject() method checks if a volume can be ejected. @@ -162,7 +162,7 @@ volume_activation_root.has_prefix(mount_root) || volume_activation_root.equal(mo

The should_automount() method returns whether the volume should be automatically mounted. -

Signals

The "changed" gio.Volume Signal

    def callback(volume, user_param1, ...)

volume :

the volume

user_param1 :

the first user parameter (if any) specified +

Signals

The "changed" gio.Volume Signal

    def callback(volume, user_param1, ...)

volume :

the volume

user_param1 :

the first user parameter (if any) specified with the connect() method

... :

additional user parameters (if any)

Emitted when the volume has been changed. diff --git a/docs/html/class-giovolumemonitor.html b/docs/html/class-giovolumemonitor.html index 06f9500..930df0f 100644 --- a/docs/html/class-giovolumemonitor.html +++ b/docs/html/class-giovolumemonitor.html @@ -1,13 +1,13 @@ -gio.VolumeMonitor

gio.VolumeMonitor

gio.VolumeMonitor — Volume Monitor.

Synopsis

class gio.VolumeMonitor(gobject.GObject):
+gio.VolumeMonitor

gio.VolumeMonitor

gio.VolumeMonitor — Volume Monitor.

Synopsis

class gio.VolumeMonitor(gobject.GObject):
     def get_connected_drives()
def get_mount_for_uuid(uuid)
def get_mounts()
def get_volume_for_uuid(uuid)
def get_volumes()
 Functions
-    def gio.volume_monitor_adopt_orphan_mount()
def gio.volume_monitor_get()

gio.VolumeMonitor Signal Prototypes

gobject.GObject Signal Prototypes

"drive-changed"

def callback(volume_monitor, drive, user_param1, ...)

"drive-connected"

def callback(volume_monitor, drive, user_param1, ...)

"drive-disconnected"

def callback(volume_monitor, drive, user_param1, ...)

"drive-eject-button"

def callback(volume_monitor, drive, user_param1, ...)

"mount-added"

def callback(volume_monitor, mount, user_param1, ...)

"mount-changed"

def callback(volume_monitor, mount, user_param1, ...)

"mount-pre-unmount"

def callback(volume_monitor, mount, user_param1, ...)

"mount-removed"

def callback(volume_monitor, mount, user_param1, ...)

"volume-added"

def callback(volume_monitor, volume, user_param1, ...)

"volume-changed"

def callback(volume_monitor, volume, user_param1, ...)

"volume-removed"

def callback(volume_monitor, volume, user_param1, ...)

Description

+

gio.VolumeMonitor Signal Prototypes

gobject.GObject Signal Prototypes

"drive-changed"

def callback(volume_monitor, drive, user_param1, ...)

"drive-connected"

def callback(volume_monitor, drive, user_param1, ...)

"drive-disconnected"

def callback(volume_monitor, drive, user_param1, ...)

"drive-eject-button"

def callback(volume_monitor, drive, user_param1, ...)

"mount-added"

def callback(volume_monitor, mount, user_param1, ...)

"mount-changed"

def callback(volume_monitor, mount, user_param1, ...)

"mount-pre-unmount"

def callback(volume_monitor, mount, user_param1, ...)

"mount-removed"

def callback(volume_monitor, mount, user_param1, ...)

"volume-added"

def callback(volume_monitor, volume, user_param1, ...)

"volume-changed"

def callback(volume_monitor, volume, user_param1, ...)

"volume-removed"

def callback(volume_monitor, volume, user_param1, ...)

Description

The gio.VolumeMonitor is for listing the user interesting devices and volumes on the computer. In other words, what a file selector or file manager would show in a sidebar. -

Methods

gio.VolumeMonitor.get_connected_drives

    def get_connected_drives()

Returns :

a list of connected +

Methods

gio.VolumeMonitor.get_connected_drives

    def get_connected_drives()

Returns :

a list of connected gio.Drive objects.

The get_connected_drives() method gets a list @@ -40,7 +40,7 @@ objects.

The get_volumes() method gets a list of the volumes on the system. -

Functions

gio.volume_monitor_adopt_orphan_mount

    def volume_monitor_adopt_orphan_mount()

Returns :

The gio.Volume +

Functions

gio.volume_monitor_adopt_orphan_mount

    def volume_monitor_adopt_orphan_mount()

Returns :

The gio.Volume object that is the parent for mount or None if no wants to adopt the gio.Mount.

Warning

This method will be deprecated starting from GIO 2.20

@@ -88,7 +88,7 @@

The volume_monitor_get() function gets the volume monitor used by gio. -

Signals

The "drive-changed" gio.Volume Signal

    def callback(volume_monitor, drive, user_param1, ...)

volume_monitor :

the volume monitor

drive :

the drive that changed

user_param1 :

the first user parameter (if any) specified +

Signals

The "drive-changed" gio.Volume Signal

    def callback(volume_monitor, drive, user_param1, ...)

volume_monitor :

the volume monitor

drive :

the drive that changed

user_param1 :

the first user parameter (if any) specified with the connect() method

... :

additional user parameters (if any)

Emitted when a drive changes. diff --git a/docs/html/class-glibmaincontext.html b/docs/html/class-glibmaincontext.html index fee4a4e..6658e41 100644 --- a/docs/html/class-glibmaincontext.html +++ b/docs/html/class-glibmaincontext.html @@ -1,7 +1,7 @@ glib.MainContext

glib.MainContext

glib.MainContext — an object representing a set of event sources to be handled -in a glib.MainLoop.

Synopsis

class glib.MainContext:
-    glib.MainContext()
def iteration(may_block)
def pending()

Ancestry

+-- glib.MainContext
-

Description

A glib.MainContext +in a glib.MainLoop.

Synopsis

class glib.MainContext:
+    glib.MainContext()
def iteration(may_block)
def pending()

Ancestry

+-- glib.MainContext
+

Description

A glib.MainContext represents a set of event sources that can be run in a single thread. File descriptors (plain files, pipes or sockets) and timeouts are the standard event sources for GTK and PyGTK though @@ -13,7 +13,7 @@ events from lower priority sources. Single iterations of a iteration() method.

Constructor

    glib.MainContext()

Returns :

a new glib.MainContext object.

Creates a new glib.MainContext -object.

Methods

glib.MainContext.iteration

    def iteration()

may_block :

if True the call may block +object.

Methods

glib.MainContext.iteration

    def iteration()

may_block :

if True the call may block waiting for an event.

Returns :

True if events were dispatched.

The iteration() method runs a single iteration. This involves:

  • checking to see if any associated event sources are ready diff --git a/docs/html/class-glibmainloop.html b/docs/html/class-glibmainloop.html index ff1ad2d..9b53179 100644 --- a/docs/html/class-glibmainloop.html +++ b/docs/html/class-glibmainloop.html @@ -1,7 +1,7 @@ glib.MainLoop

    glib.MainLoop

    glib.MainLoop — an object representing the main event loop of a PyGTK - application.

    Synopsis

    class glib.MainLoop:
    -    glib.MainLoop(context=None, is_running=0)
    def get_context()
    def is_running()
    def quit()
    def run()

    Ancestry

    +-- glib.MainLoop
    -

    Description

    glib.MainLoop + application.

    Synopsis

    class glib.MainLoop:
    +    glib.MainLoop(context=None, is_running=0)
    def get_context()
    def is_running()
    def quit()
    def run()

    Ancestry

    +-- glib.MainLoop
    +

    Description

    glib.MainLoop represents a main event loop. A glib.MainLoop is created with the glib.MainLoop() constructor. After adding the initial event sources, the run() @@ -24,7 +24,7 @@ functions.

Returns :

a new glib.MainLoop object.

Creates a new glib.MainLoop -object.

Methods

glib.MainLoop.get_context

    def get_context()

Returns :

the glib.MainContext +object.

Methods

glib.MainLoop.get_context

    def get_context()

Returns :

the glib.MainContext the mainloop is associated with

The get_context() method returns the glib.MainContext that the mainloop was created with.

glib.MainLoop.is_running

    def is_running()

Returns :

True if the mainloop is diff --git a/docs/html/class-gobject.html b/docs/html/class-gobject.html index b59d6ff..c6b0b96 100644 --- a/docs/html/class-gobject.html +++ b/docs/html/class-gobject.html @@ -1,6 +1,6 @@ -gobject.GObject

gobject.GObject

gobject.GObject — the base class

Synopsis

class gobject.GObject:
-    def get_property(property_name)
def get_properties(first_property_name, ...)
def set_property(property_name, value)
def set_properties(property_name=value, ...)
def freeze_notify()
def notify(property_name)
def thaw_notify()
def get_data(key)
def set_data(key, data)
def connect(detailed_signal, handler)
def connect_after(detailed_signal, handler)
def connect_object(detailed_signal, handler)
def connect_object_after(detailed_signal, handler)
def disconnect(handler_id)
def handler_disconnect(handler_id)
def handler_is_connected(handler_id)
def handler_block(handler_id)
def handler_unblock(handler_id)
def handler_block_by_func(callable)
def handler_unblock_by_func(callable)
def emit(detailed_signal)
def stop_emission(detailed_signal)
def emit_stop_by_name(detailed_signal)
def chain()

Ancestry

+-- gobject.GObject
-

Attributes

"props"Read/Write +gobject.GObject

gobject.GObject

gobject.GObject — the base class

Synopsis

class gobject.GObject:
+    def get_property(property_name)
def get_properties(first_property_name, ...)
def set_property(property_name, value)
def set_properties(property_name=value, ...)
def freeze_notify()
def notify(property_name)
def thaw_notify()
def get_data(key)
def set_data(key, data)
def connect(detailed_signal, handler)
def connect_after(detailed_signal, handler)
def connect_object(detailed_signal, handler)
def connect_object_after(detailed_signal, handler)
def disconnect(handler_id)
def handler_disconnect(handler_id)
def handler_is_connected(handler_id)
def handler_block(handler_id)
def handler_unblock(handler_id)
def handler_block_by_func(callable)
def handler_unblock_by_func(callable)
def emit(detailed_signal)
def stop_emission(detailed_signal)
def emit_stop_by_name(detailed_signal)
def chain()

Ancestry

+-- gobject.GObject
+

Attributes

"props"Read/Write

This attribute gives full access to GObject properties as simple attributes. It can be used to iterate over all the object properties, and can be used both on class or instance objects.

@@ -17,12 +17,12 @@ button_label = button.get_property(label_pspec.name)
"__doc__"ReadThe documentation for the object type. Uses "__gdoc__" if no specific documentation set.
"__gdoc__"ReadThe generated documentation for the underlying GObject - type.
"__gtype__"ReadThe underlying GObject type.
"__grefcount__"ReadThe reference count for the underlying GObject.

gobject.GObject Signal Prototypes

"notify"

def callback(gobject, property_spec, user_param1, ...)

Description

The gobject.GObject + type.

"__gtype__"ReadThe underlying GObject type.
"__grefcount__"ReadThe reference count for the underlying GObject.

gobject.GObject Signal Prototypes

"notify"

def callback(gobject, property_spec, user_param1, ...)

Description

The gobject.GObject class is the base class providing the common attributes and methods for the PyGTK classes. The gobject.GObject class is not a user interface widget class.

The gobject.GObject class provides the signal management methods, the object property access - methods and the object data management methods.

Methods

gobject.GObject.get_property

    def get_property(property_name)

property_name :

a string containing the property name for the + methods and the object data management methods.

Methods

gobject.GObject.get_property

    def get_property(property_name)

property_name :

a string containing the property name for the GObject

Returns :

a Python object containing the value of the property

The get_property() method returns the value of the property specified by property_name or @@ -161,7 +161,7 @@ still to be run will not be invoked.

emit_stop_by_name() method stops the current emission of the signal specified by detailed_signal. Any signal handlers in the list -still to be run will not be invoked.

gobject.GObject.chain

    def chain(...)

... :

additional parameters

Returns :

a Python object

The chain() method does something.

Signals

The GObject "notify" Signal

    def callback(gobject, property_spec, user_param1, ...)

gobject :

the gobject that received the +still to be run will not be invoked.

gobject.GObject.chain

    def chain(...)

... :

additional parameters

Returns :

a Python object

The chain() method does something.

Signals

The GObject "notify" Signal

    def callback(gobject, property_spec, user_param1, ...)

gobject :

the gobject that received the signal

property_spec :

the gobject.GParamSpec of the property that was changed

user_param1 :

the first user parameter (if any) specified with the connect() diff --git a/docs/html/class-gobjectgboxed.html b/docs/html/class-gobjectgboxed.html index 1e29f4a..e67433b 100644 --- a/docs/html/class-gobjectgboxed.html +++ b/docs/html/class-gobjectgboxed.html @@ -1,9 +1,9 @@ -gobject.GBoxed

gobject.GBoxed

gobject.GBoxed — an object containing an opaque chunk of data

Synopsis

class gobject.GBoxed:
-    def copy()

Ancestry

+-- gobject.GBoxed
-

Description

gobject.GBoxed +gobject.GBoxed

gobject.GBoxed

gobject.GBoxed — an object containing an opaque chunk of data

Synopsis

class gobject.GBoxed:
+    def copy()

Ancestry

+-- gobject.GBoxed
+

Description

gobject.GBoxed is an abstract base class that encapsulates an opaque chunk of data to provide an object-oriented interface and a type that is registered with the GLIB type system. A boxed type is registered with functions that provide for the copying and freeing of the underlying data -structure - this allows PyGTK to encapsulate these as Python objects.

Methods

gobject.GBoxed.copy

    def copy()

Returns :

a copy of the gobject.GBoxed +structure - this allows PyGTK to encapsulate these as Python objects.

Methods

gobject.GBoxed.copy

    def copy()

Returns :

a copy of the gobject.GBoxed object

The copy() method makes and returns a copy of the boxed object.

diff --git a/docs/html/class-gobjectginterface.html b/docs/html/class-gobjectginterface.html index 9e9e66c..e746e03 100644 --- a/docs/html/class-gobjectginterface.html +++ b/docs/html/class-gobjectginterface.html @@ -1,4 +1,4 @@ -gobject.GInterface

gobject.GInterface

gobject.GInterface — an object representing a GInterface

Synopsis

class gobject.GInterface:
-

Ancestry

+-- gobject.GInterface
-

Description

gobject.GInterface +gobject.GInterface

gobject.GInterface

gobject.GInterface — an object representing a GInterface

Synopsis

class gobject.GInterface:
+

Ancestry

+-- gobject.GInterface
+

Description

gobject.GInterface is an abstract base class that encapsulates a GInterface.

diff --git a/docs/html/class-gobjectgpointer.html b/docs/html/class-gobjectgpointer.html index 2c0fb75..efbae31 100644 --- a/docs/html/class-gobjectgpointer.html +++ b/docs/html/class-gobjectgpointer.html @@ -1,7 +1,7 @@ gobject.GPointer

gobject.GPointer

gobject.GPointer — an object containing a completely opaque chunk of - data

Synopsis

class gobject.GPointer:
-

Ancestry

+-- gobject.GPointer
-

Description

gobject.GPointer + data

Synopsis

class gobject.GPointer:
+

Ancestry

+-- gobject.GPointer
+

Description

gobject.GPointer is an abstract base class that encapsulates an opaque chunk of data and registers it with the GLIB type system. A pointer type has no methods and generic ways of copying and freeing the data. It diff --git a/docs/html/gio-constants.html b/docs/html/gio-constants.html index 509b60c..683e900 100644 --- a/docs/html/gio-constants.html +++ b/docs/html/gio-constants.html @@ -1,4 +1,4 @@ -gio Constants

gio Constants

gio Constants — the built-in constants of the gio module

Synopsis

+gio Constants

gio Constants

gio Constants — the built-in constants of the gio module

Synopsis

 Gio AppInfo Create Flags Constants
 Gio Ask Password Flags Constants
 Gio Data Stream Byte Order Constants
diff --git a/docs/html/gio-functions.html b/docs/html/gio-functions.html
index f87918f..a5e81d8 100644
--- a/docs/html/gio-functions.html
+++ b/docs/html/gio-functions.html
@@ -1,7 +1,7 @@
-gio Functions

gio Functions

gio Functions

Description

+gio Functions

gio Functions

gio Functions

Description

These functions are part of the PyGObject gio module but are not directly associated with a specific class -

Functions

gio.content_type_can_be_executable

    def content_type_can_be_executable(type)

type :

a content type string. +

Functions

gio.content_type_can_be_executable

    def content_type_can_be_executable(type)

type :

a content type string.

Returns :

True if the file type corresponds to a type that can be executable, False otherwise.

diff --git a/docs/html/glib-constants.html b/docs/html/glib-constants.html index ecc7f1e..b9ddd32 100644 --- a/docs/html/glib-constants.html +++ b/docs/html/glib-constants.html @@ -1,4 +1,4 @@ -glib Constants

glib Constants

glib Constants — the built-in constants of the glib module

Synopsis

+glib Constants

glib Constants

glib Constants — the built-in constants of the glib module

Synopsis

 Glib IO Condition Constants
 Glib Priority Constants
 Glib Spawn Flag Constants
diff --git a/docs/html/glib-functions.html b/docs/html/glib-functions.html
index 0fa3bb2..4929177 100644
--- a/docs/html/glib-functions.html
+++ b/docs/html/glib-functions.html
@@ -1,6 +1,6 @@
-glib Functions

glib Functions

glib Functions — miscellaneous functions

Synopsis

-    def glib.idle_add(callback, ...)
def glib.timeout_add(interval, callback, ...)
def glib.timeout_add_seconds(interval, callback, ...)
def glib.io_add_watch(fd, condition, callback, ...)
def glib.source_remove(tag)
def glib.main_context_default()
def glib.markup_escape_text(text)
def glib.child_watch_add(pid, function, data=None, priority=glib.PRIORITY_DEFAULT)
def glib.spawn_async(argv, envp=None, working_directory=None, flags=0, child_setup=None, user_data=None, standard_input=None, standard_output=None, standard_error=None)
def glib.get_current_time()
def glib.get_user_cache_dir()
def glib.get_user_config_dir()
def glib.get_user_data_dir()
def glib.get_user_special_dir(directory)
def glib.main_depth()
def glib.threads_init()
def glib.filename_display_name(filename)
def glib.filename_display_basename(filename)
def glib.filename_from_utf8(utf8string)

Description

These functions are part of the PyGObject glib -module but are not directly associated with a specific class.

Functions

glib.idle_add

    def glib.idle_add(callback, ...)

callback :

a function to call when +glib Functions

glib Functions

glib Functions — miscellaneous functions

Synopsis

+    def glib.idle_add(callback, ...)
def glib.timeout_add(interval, callback, ...)
def glib.timeout_add_seconds(interval, callback, ...)
def glib.io_add_watch(fd, condition, callback, ...)
def glib.source_remove(tag)
def glib.main_context_default()
def glib.markup_escape_text(text)
def glib.child_watch_add(pid, function, data=None, priority=glib.PRIORITY_DEFAULT)
def glib.spawn_async(argv, envp=None, working_directory=None, flags=0, child_setup=None, user_data=None, standard_input=None, standard_output=None, standard_error=None)
def glib.get_current_time()
def glib.get_user_cache_dir()
def glib.get_user_config_dir()
def glib.get_user_data_dir()
def glib.get_user_special_dir(directory)
def glib.main_depth()
def glib.threads_init()
def glib.filename_display_name(filename)
def glib.filename_display_basename(filename)
def glib.filename_from_utf8(utf8string)

Description

These functions are part of the PyGObject glib +module but are not directly associated with a specific class.

Functions

glib.idle_add

    def glib.idle_add(callback, ...)

callback :

a function to call when PyGTK is idle

... :

optionals arguments to be passed to callback

Returns :

an integer ID

The glib.idle_add() function adds a function (specified by callback) to be called diff --git a/docs/html/gobject-constants.html b/docs/html/gobject-constants.html index 0775707..a6a00b4 100644 --- a/docs/html/gobject-constants.html +++ b/docs/html/gobject-constants.html @@ -1,4 +1,4 @@ -gobject Constants

gobject Constants

gobject Constants — the built-in constants of the gobject module

Synopsis

+gobject Constants

gobject Constants

gobject Constants — the built-in constants of the gobject module

Synopsis

 GObject Param Flag Constants
 GObject Signal Flag Constants
 GObject Built-in Type Constants
diff --git a/docs/html/gobject-functions.html b/docs/html/gobject-functions.html
index 5be478a..7b4e664 100644
--- a/docs/html/gobject-functions.html
+++ b/docs/html/gobject-functions.html
@@ -1,12 +1,12 @@
-gobject Functions

gobject Functions

gobject Functions — miscellaneous functions

Synopsis

+gobject Functions

gobject Functions

gobject Functions — miscellaneous functions

Synopsis

     def gobject.type_name(type)
def gobject.type_from_name(type_name)
def gobject.type_parent(type)
def gobject.type_is_a(type, parent_type)
def gobject.type_children(type)
def gobject.type_interfaces(type)
def gobject.type_register(class)
def gobject.signal_new(signal_name, type, flags, return_type, param_types)
def gobject.signal_list_names(type)
def gobject.signal_list_ids(type)
def gobject.signal_lookup(name, type)
def gobject.signal_name(signal_id)
def gobject.signal_query(name, type)
def gobject.signal_query(signal_id)
def gobject.list_properties(type)
def gobject.new(type, ...)
def gobject.signal_accumulator_true_handled()
def gobject.add_emission_hook(type, name, callback, ...)
def gobject.remove_emission_hook(type, name, hook_id)
def gobject._install_metaclass(metaclass) -

Description

These functions are part of the PyGTK gobject +

Description

These functions are part of the PyGTK gobject module but are not directly associated with a specific class.

Note

Many functions that previously were in this namespace got moved to glib namespace instead. They are still available in gobject for backward compatibility, but not documented here. If you miss documentation for some function, be sure to check glib first. -

Functions

gobject.type_name

    def gobject.type_name(type)

type :

a GObject type, type ID or +

Functions

gobject.type_name

    def gobject.type_name(type)

type :

a GObject type, type ID or instance

Returns :

The gobject.type_name() function returns the unique name that is assigned to the specified type. type can be a GObject diff --git a/docs/html/index.html b/docs/html/index.html index aade9e5..5b95ab5 100644 --- a/docs/html/index.html +++ b/docs/html/index.html @@ -1,4 +1,4 @@ -PyGObject Reference Manual

PyGObject Reference Manual

for PyGObject version 2.27.90

2011-02-11 +PyGObject Reference Manual

PyGObject Reference Manual

for PyGObject version 2.27.91

2011-02-11

Abstract

This reference describes the classes of the python gobject module.


Table of Contents

Introduction
Reference Page Format
PyGlibClass Reference
glib.MainContext — an object representing a set of event sources to be handled in a glib.MainLoop.
glib.MainLoop — an object representing the main event loop of a PyGTK diff --git a/gi/Makefile.am b/gi/Makefile.am index a98993b..28825ab 100644 --- a/gi/Makefile.am +++ b/gi/Makefile.am @@ -54,6 +54,8 @@ _gi_la_SOURCES = \ pygi-private.h \ pygi-property.c \ pygi-property.h \ + pygi-signal-closure.c \ + pygi-signal-closure.h \ pygobject-external.h \ gimodule.c diff --git a/gi/Makefile.in b/gi/Makefile.in index 173abf6..a5ccc12 100644 --- a/gi/Makefile.in +++ b/gi/Makefile.in @@ -81,7 +81,7 @@ am__gi_la_OBJECTS = _gi_la-pygi-repository.lo _gi_la-pygi-info.lo \ _gi_la-pygi-argument.lo _gi_la-pygi-type.lo \ _gi_la-pygi-boxed.lo _gi_la-pygi-closure.lo \ _gi_la-pygi-callbacks.lo _gi_la-pygi-property.lo \ - _gi_la-gimodule.lo + _gi_la-pygi-signal-closure.lo _gi_la-gimodule.lo _gi_la_OBJECTS = $(am__gi_la_OBJECTS) AM_V_lt = $(am__v_lt_$(V)) am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) @@ -381,6 +381,8 @@ _gi_la_SOURCES = \ pygi-private.h \ pygi-property.c \ pygi-property.h \ + pygi-signal-closure.c \ + pygi-signal-closure.h \ pygobject-external.h \ gimodule.c @@ -489,6 +491,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/_gi_la-pygi-invoke.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/_gi_la-pygi-property.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/_gi_la-pygi-repository.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/_gi_la-pygi-signal-closure.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/_gi_la-pygi-struct.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/_gi_la-pygi-type.Plo@am__quote@ @@ -612,6 +615,14 @@ _gi_la-pygi-property.lo: pygi-property.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(_gi_la_CFLAGS) $(CFLAGS) -c -o _gi_la-pygi-property.lo `test -f 'pygi-property.c' || echo '$(srcdir)/'`pygi-property.c +_gi_la-pygi-signal-closure.lo: pygi-signal-closure.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(_gi_la_CFLAGS) $(CFLAGS) -MT _gi_la-pygi-signal-closure.lo -MD -MP -MF $(DEPDIR)/_gi_la-pygi-signal-closure.Tpo -c -o _gi_la-pygi-signal-closure.lo `test -f 'pygi-signal-closure.c' || echo '$(srcdir)/'`pygi-signal-closure.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/_gi_la-pygi-signal-closure.Tpo $(DEPDIR)/_gi_la-pygi-signal-closure.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pygi-signal-closure.c' object='_gi_la-pygi-signal-closure.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(_gi_la_CFLAGS) $(CFLAGS) -c -o _gi_la-pygi-signal-closure.lo `test -f 'pygi-signal-closure.c' || echo '$(srcdir)/'`pygi-signal-closure.c + _gi_la-gimodule.lo: gimodule.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(_gi_la_CFLAGS) $(CFLAGS) -MT _gi_la-gimodule.lo -MD -MP -MF $(DEPDIR)/_gi_la-gimodule.Tpo -c -o _gi_la-gimodule.lo `test -f 'gimodule.c' || echo '$(srcdir)/'`gimodule.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/_gi_la-gimodule.Tpo $(DEPDIR)/_gi_la-gimodule.Plo diff --git a/gi/__init__.py b/gi/__init__.py index fb711c3..ed20606 100644 --- a/gi/__init__.py +++ b/gi/__init__.py @@ -20,8 +20,35 @@ from __future__ import absolute_import -from ._gi import _API +from ._gi import _API, Repository # Force loading the GObject typelib so we have available the wrappers for # base classes such as GInitiallyUnowned from gi.repository import GObject + +_versions = {} + +def require_version(namespace, version): + repository = Repository.get_default() + + if namespace in repository.get_loaded_namespaces(): + if repository.get_version(namespace) != version: + raise ValueError('Namespace %s is already loaded with version %s' % \ + (namespace, loaded_version)) + + if namespace in _versions and _versions[namespace] != version: + raise ValueError('Namespace %s already requires version %s' % \ + (namespace, _versions[namespace])) + + available_versions = repository.enumerate_versions(namespace) + if not available_versions: + raise ValueError('Namespace %s not available' % namespace) + + if version not in available_versions: + raise ValueError('Namespace %s not available for version %s' % \ + (namespace, version)) + + _versions[namespace] = version + +def get_required_version(namespace): + return _versions.get(namespace, None) diff --git a/gi/gimodule.c b/gi/gimodule.c index f70d0f2..2c4c335 100644 --- a/gi/gimodule.c +++ b/gi/gimodule.c @@ -50,6 +50,70 @@ _wrap_pyg_enum_add (PyObject *self, return pyg_enum_add (NULL, g_type_name (g_type), NULL, g_type); } +static PyObject * +_wrap_pyg_enum_register_new_gtype_and_add (PyObject *self, + PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "info", NULL }; + PyGIBaseInfo *py_info; + GIEnumInfo *info; + gint n_values; + GEnumValue *g_enum_values; + GType g_type; + const gchar *type_name; + + if (!PyArg_ParseTupleAndKeywords (args, kwargs, + "O:enum_add_make_new_gtype", + kwlist, (PyObject *)&py_info)) { + return NULL; + } + + if (!GI_IS_ENUM_INFO (py_info->info) || + g_base_info_get_type ((GIBaseInfo *) py_info->info) != GI_INFO_TYPE_ENUM) { + PyErr_SetString (PyExc_TypeError, "info must be an EnumInfo with info type GI_INFO_TYPE_ENUM"); + return NULL; + } + + info = (GIEnumInfo *)py_info->info; + n_values = g_enum_info_get_n_values (info); + g_enum_values = g_new0 (GEnumValue, n_values + 1); + + for (int i=0; i < n_values; i++) { + GIValueInfo *value_info; + GEnumValue *enum_value; + const gchar *name; + const gchar *c_identifier; + + value_info = g_enum_info_get_value (info, i); + name = g_base_info_get_name ((GIBaseInfo *) value_info); + c_identifier = g_base_info_get_attribute ((GIBaseInfo *) value_info, + "c:identifier"); + + enum_value = &g_enum_values[i]; + enum_value->value_nick = g_strdup (name); + enum_value->value = g_value_info_get_value (value_info); + + if (c_identifier == NULL) { + enum_value->value_name = enum_value->value_nick; + } else { + enum_value->value_name = g_strdup (c_identifier); + } + + g_base_info_unref ((GIBaseInfo *) value_info); + } + + g_enum_values[n_values].value = 0; + g_enum_values[n_values].value_nick = NULL; + g_enum_values[n_values].value_name = NULL; + + type_name = g_base_info_get_name ((GIBaseInfo *) info); + type_name = g_strdup (type_name); + g_type = g_enum_register_static (type_name, g_enum_values); + + return pyg_enum_add (NULL, g_type_name (g_type), NULL, g_type); +} + static PyObject * _wrap_pyg_flags_add (PyObject *self, PyObject *args, @@ -73,6 +137,71 @@ _wrap_pyg_flags_add (PyObject *self, return pyg_flags_add (NULL, g_type_name (g_type), NULL, g_type); } +static PyObject * +_wrap_pyg_flags_register_new_gtype_and_add (PyObject *self, + PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "info", NULL }; + PyGIBaseInfo *py_info; + GIEnumInfo *info; + gint n_values; + GFlagsValue *g_flags_values; + GType g_type; + const gchar *type_name; + + if (!PyArg_ParseTupleAndKeywords (args, kwargs, + "O:flags_add_make_new_gtype", + kwlist, (PyObject *)&py_info)) { + return NULL; + } + + if (!GI_IS_ENUM_INFO (py_info->info) || + g_base_info_get_type ((GIBaseInfo *) py_info->info) != GI_INFO_TYPE_FLAGS) { + PyErr_SetString (PyExc_TypeError, "info must be an EnumInfo with info type GI_INFO_TYPE_FLAGS"); + return NULL; + } + + info = (GIEnumInfo *)py_info->info; + n_values = g_enum_info_get_n_values (info); + g_flags_values = g_new0 (GFlagsValue, n_values + 1); + + for (int i=0; i < n_values; i++) { + GIValueInfo *value_info; + GFlagsValue *flags_value; + const gchar *name; + const gchar *c_identifier; + + value_info = g_enum_info_get_value (info, i); + name = g_base_info_get_name ((GIBaseInfo *) value_info); + c_identifier = g_base_info_get_attribute ((GIBaseInfo *) value_info, + "c:identifier"); + + flags_value = &g_flags_values[i]; + flags_value->value_nick = g_strdup (name); + flags_value->value = g_value_info_get_value (value_info); + + if (c_identifier == NULL) { + flags_value->value_name = flags_value->value_nick; + } else { + flags_value->value_name = g_strdup (c_identifier); + } + + g_base_info_unref ((GIBaseInfo *) value_info); + } + + g_flags_values[n_values].value = 0; + g_flags_values[n_values].value_nick = NULL; + g_flags_values[n_values].value_name = NULL; + + type_name = g_base_info_get_name ((GIBaseInfo *) info); + type_name = g_strdup (type_name); + g_type = g_flags_register_static (type_name, g_flags_values); + + return pyg_flags_add (NULL, g_type_name (g_type), NULL, g_type); +} + + static PyObject * _wrap_pyg_set_object_has_new_constructor (PyObject *self, PyObject *args, @@ -353,7 +482,9 @@ _wrap_pyg_variant_type_from_string (PyObject *self, PyObject *args) static PyMethodDef _gi_functions[] = { { "enum_add", (PyCFunction) _wrap_pyg_enum_add, METH_VARARGS | METH_KEYWORDS }, + { "enum_register_new_gtype_and_add", (PyCFunction) _wrap_pyg_enum_register_new_gtype_and_add, METH_VARARGS | METH_KEYWORDS }, { "flags_add", (PyCFunction) _wrap_pyg_flags_add, METH_VARARGS | METH_KEYWORDS }, + { "flags_register_new_gtype_and_add", (PyCFunction) _wrap_pyg_flags_register_new_gtype_and_add, METH_VARARGS | METH_KEYWORDS }, { "set_object_has_new_constructor", (PyCFunction) _wrap_pyg_set_object_has_new_constructor, METH_VARARGS | METH_KEYWORDS }, { "register_interface_info", (PyCFunction) _wrap_pyg_register_interface_info, METH_VARARGS }, @@ -367,6 +498,7 @@ static struct PyGI_API CAPI = { pygi_type_import_by_g_type_real, pygi_get_property_value_real, pygi_set_property_value_real, + pygi_signal_closure_new_real, pygi_register_foreign_struct_real, }; diff --git a/gi/importer.py b/gi/importer.py index 1cb9b92..df08274 100644 --- a/gi/importer.py +++ b/gi/importer.py @@ -73,6 +73,7 @@ class DynamicImporter(object): dynamic_module.__loader__ = self sys.modules[fullname] = dynamic_module + dynamic_module._load() return dynamic_module diff --git a/gi/module.py b/gi/module.py index 9b935ed..3e2b59e 100644 --- a/gi/module.py +++ b/gi/module.py @@ -25,6 +25,7 @@ from __future__ import absolute_import import os import gobject +import gi from .overrides import registry from ._gi import \ @@ -40,12 +41,13 @@ from ._gi import \ Struct, \ Boxed, \ enum_add, \ - flags_add + enum_register_new_gtype_and_add, \ + flags_add, \ + flags_register_new_gtype_and_add from .types import \ GObjectMeta, \ StructMeta, \ - Function, \ - Enum + Function repository = Repository.get_default() @@ -102,13 +104,18 @@ class IntrospectionModule(object): wrapper = g_type.pytype if wrapper is None: - if g_type.is_a(gobject.TYPE_ENUM): - wrapper = enum_add(g_type) - elif g_type.is_a(gobject.TYPE_NONE): - # An enum with a GType of None is an enum without GType - wrapper = type(info.get_name(), (Enum,), {}) + if info.is_flags(): + if g_type.is_a(gobject.TYPE_FLAGS): + wrapper = flags_add(g_type) + else: + assert g_type == gobject.TYPE_NONE + wrapper = flags_register_new_gtype_and_add(info) else: - wrapper = flags_add(g_type) + if g_type.is_a(gobject.TYPE_ENUM): + wrapper = enum_add(g_type) + else: + assert g_type == gobject.TYPE_NONE + wrapper = enum_register_new_gtype_and_add(info) wrapper.__info__ = info wrapper.__module__ = 'gi.repository.' + info.get_namespace() @@ -224,28 +231,19 @@ class DynamicModule(object): def __init__(self, namespace): self._namespace = namespace self._introspection_module = None - self._version = None self._overrides_module = None self.__path__ = None - def require_version(self, version): - if self._introspection_module is not None and \ - self._introspection_module._version != version: - raise RuntimeError('Module has been already loaded ') - self._version = version - - def _import(self): + def _load(self): + version = gi.get_required_version(self._namespace) self._introspection_module = IntrospectionModule(self._namespace, - self._version) + version) overrides_modules = __import__('gi.overrides', fromlist=[self._namespace]) self._overrides_module = getattr(overrides_modules, self._namespace, None) self.__path__ = repository.get_typelib_path(self._namespace) def __getattr__(self, name): - if self._introspection_module is None: - self._import() - if self._overrides_module is not None: override_exports = getattr(self._overrides_module, '__all__', ()) if name in override_exports: @@ -263,9 +261,6 @@ class DynamicModule(object): return getattr(self._introspection_module, name) def __dir__ (self): - if self._introspection_module is None: - self._import() - # Python's default dir() is just dir(self.__class__) + self.__dict__.keys() result = set(dir(self.__class__)) result.update(self.__dict__.keys()) @@ -276,8 +271,6 @@ class DynamicModule(object): return list(result) def __repr__(self): - repository.require(self._namespace, self._version) - path = repository.get_typelib_path(self._namespace) return "<%s.%s %r from %r>" % (self.__class__.__module__, self.__class__.__name__, diff --git a/gi/overrides/Gdk.py b/gi/overrides/Gdk.py index 4ed71a6..16a0548 100644 --- a/gi/overrides/Gdk.py +++ b/gi/overrides/Gdk.py @@ -22,6 +22,8 @@ from ..overrides import override from ..importer import modules +import sys + Gdk = modules['Gdk']._introspection_module __all__ = [] @@ -61,6 +63,11 @@ if Gdk._version == '2.0': Rectangle = override(Rectangle) __all__.append('Rectangle') +else: + from gi.repository import cairo as _cairo + Rectangle = _cairo.RectangleInt + + __all__.append('Rectangle') if Gdk._version == '2.0': class Drawable(Gdk.Drawable): @@ -136,6 +143,74 @@ class Event(Gdk.Event): Event = override(Event) __all__.append('Event') +# manually bind GdkEvent members to GdkEvent + +modname = globals()['__name__'] +module = sys.modules[modname] + +# right now we can't get the type_info from the +# field info so manually list the class names +event_member_classes = ['EventAny', + 'EventExpose', + 'EventVisibility', + 'EventMotion', + 'EventButton', + 'EventScroll', + 'EventKey', + 'EventCrossing', + 'EventFocus', + 'EventConfigure', + 'EventProperty', + 'EventSelection', + 'EventOwnerChange', + 'EventProximity', + 'EventDND', + 'EventWindowState', + 'EventSetting', + 'EventGrabBroken'] + +if Gdk._version == '2.0': + event_member_classes.append('EventNoExpose') + +# whitelist all methods that have a success return we want to mask +gsuccess_mask_funcs = ['get_state', + 'get_axis', + 'get_coords', + 'get_root_coords'] + +def _gsuccess_mask(func): + def cull_success(*args): + result = func(*args) + success = result[0] + if success == False: + return None + else: + if len(result) == 2: + return result[1] + else: + return result[1:] + return cull_success + +for event_class in event_member_classes: + override_class = type(event_class, (getattr(Gdk, event_class),), {}) + # add the event methods + for method_info in Gdk.Event.__info__.get_methods(): + name = method_info.get_name() + event_method = getattr(Gdk.Event, name) + # python2 we need to use the __func__ attr to avoid internal + # instance checks + event_method = getattr(event_method, '__func__', event_method) + + # use the _gsuccess_mask decorator if this method is whitelisted + if name in gsuccess_mask_funcs: + event_method = _gsuccess_mask(event_method) + setattr(override_class, name, event_method) + + setattr(module, event_class, override_class) + __all__.append(event_class) + +# end GdkEvent overrides + class DragContext(Gdk.DragContext): def finish(self, success, del_, time): Gtk = modules['Gtk']._introspection_module @@ -144,6 +219,47 @@ class DragContext(Gdk.DragContext): DragContext = override(DragContext) __all__.append('DragContext') +class Cursor(Gdk.Cursor): + def __new__(cls, *args, **kwds): + arg_len = len(args) + kwd_len = len(kwds) + total_len = arg_len + kwd_len + + def _new(cursor_type): + return cls.new(cursor_type) + + def _new_for_display(display, cursor_type): + return cls.new_for_display(display, cursor_type) + + def _new_from_pixbuf(display, pixbuf, x, y): + return cls.new_from_pixbuf(display, pixbuf, x, y) + + def _new_from_pixmap(source, mask, fg, bg, x, y): + return cls.new_from_pixmap(source, mask, fg, bg, x, y) + + _constructor = None + if total_len == 1: + _constructor = _new + elif total_len == 2: + _constructor = _new_for_display + elif total_len == 4: + _constructor = _new_from_pixbuf + elif total_len == 6: + if Gdk._version != '2.0': + # pixmaps don't exist in Gdk 3.0 + raise ValueError("Wrong number of parameters") + _constructor = _new_from_pixmap + else: + raise ValueError("Wrong number of parameters") + + return _constructor(*args, **kwds) + + def __init__(self, *args, **kwargs): + Gdk.Cursor.__init__(self) + +Cursor = override(Cursor) +__all__.append('Cursor') + import sys initialized, argv = Gdk.init_check(sys.argv) diff --git a/gi/overrides/Gio.py b/gi/overrides/Gio.py index 78affa2..20343a2 100644 --- a/gi/overrides/Gio.py +++ b/gi/overrides/Gio.py @@ -97,3 +97,102 @@ class Settings(Gio.Settings): Settings = override(Settings) __all__.append('Settings') + +class _DBusProxyMethodCall: + '''Helper class to implement DBusProxy method calls.''' + + def __init__(self, dbus_proxy, method_name): + self.dbus_proxy = dbus_proxy + self.method_name = method_name + + def __async_result_handler(self, obj, result, user_data): + (result_callback, error_callback, real_user_data) = user_data + try: + ret = obj.call_finish(result) + except Exception as e: + # return exception as value + if error_callback: + error_callback(obj, e, real_user_data) + else: + result_callback(obj, e, real_user_data) + return + + result_callback(obj, self._unpack_result(ret), real_user_data) + + def __call__(self, signature, *args, **kwargs): + arg_variant = GLib.Variant(signature, tuple(args)) + + if 'result_handler' in kwargs: + # asynchronous call + user_data = (kwargs['result_handler'], + kwargs.get('error_handler'), kwargs.get('user_data')) + self.dbus_proxy.call(self.method_name, arg_variant, + kwargs.get('flags', 0), kwargs.get('timeout', -1), None, + self.__async_result_handler, user_data) + else: + # synchronous call + result = self.dbus_proxy.call_sync(self.method_name, arg_variant, + kwargs.get('flags', 0), kwargs.get('timeout', -1), None) + return self._unpack_result(result) + + @classmethod + def _unpack_result(klass, result): + '''Convert a D-BUS return variant into an appropriate return value''' + + result = result.unpack() + + # to be compatible with standard Python behaviour, unbox + # single-element tuples and return None for empty result tuples + if len(result) == 1: + result = result[0] + elif len(result) == 0: + result = None + + return result + +class DBusProxy(Gio.DBusProxy): + '''Provide comfortable and pythonic method calls. + + This marshalls the method arguments into a GVariant, invokes the + call_sync() method on the DBusProxy object, and unmarshalls the result + GVariant back into a Python tuple. + + The first argument always needs to be the D-Bus signature tuple of the + method call. Example: + + proxy = Gio.DBusProxy.new_sync(...) + result = proxy.MyMethod('(is)', 42, 'hello') + + Optional keyword arguments: + + - timeout: timeout for the call in milliseconds (default to D-Bus timeout) + + - flags: Combination of Gio.DBusCallFlags.* + + - result_handler: Do an asynchronous method call and invoke + result_handler(proxy_object, result, user_data) when it finishes. + + - error_handler: If the asynchronous call raises an exception, + error_handler(proxy_object, exception, user_data) is called when it + finishes. If error_handler is not given, result_handler is called with + the exception object as result instead. + + - user_data: Optional user data to pass to result_handler for + asynchronous calls. + + Example for asynchronous calls: + + def mymethod_done(proxy, result, user_data): + if isinstance(result, Exception): + # handle error + else: + # do something with result + + proxy.MyMethod('(is)', 42, 'hello', + result_handler=mymethod_done, user_data='data') + ''' + def __getattr__(self, name): + return _DBusProxyMethodCall(self, name) + +DBusProxy = override(DBusProxy) +__all__.append('DBusProxy') diff --git a/gi/overrides/Gtk.py b/gi/overrides/Gtk.py index 6c22829..31d1362 100644 --- a/gi/overrides/Gtk.py +++ b/gi/overrides/Gtk.py @@ -720,6 +720,9 @@ class TreeModel(Gtk.TreeModel): for i in range(n_columns): value = row[i] + if value is None: + continue # None means skip this row + self.set_value(treeiter, i, value) def _convert_value(self, treeiter, column, value): @@ -728,9 +731,9 @@ class TreeModel(Gtk.TreeModel): # we may need to convert to a basic type type_ = self.get_column_type(column) - if type_ == gobject.TYPE_PYOBJECT: + if type_ == GObject.TYPE_PYOBJECT: pass # short-circut branching - elif type_ == gobject.TYPE_STRING: + elif type_ == GObject.TYPE_STRING: if isinstance(value, str): value = str(value) elif sys.version_info < (3, 0): @@ -740,12 +743,12 @@ class TreeModel(Gtk.TreeModel): raise ValueError('Expected string or unicode for column %i but got %s%s' % (column, value, type(value))) else: raise ValueError('Expected a string for column %i but got %s' % (column, type(value))) - elif type_ == gobject.TYPE_FLOAT or type_ == gobject.TYPE_DOUBLE: + elif type_ == GObject.TYPE_FLOAT or type_ == GObject.TYPE_DOUBLE: if isinstance(value, float): value = float(value) else: raise ValueError('Expected a float for column %i but got %s' % (column, type(value))) - elif type_ == gobject.TYPE_LONG or type_ == gobject.TYPE_INT: + elif type_ == GObject.TYPE_LONG or type_ == GObject.TYPE_INT: if isinstance(value, int): value = int(value) elif sys.version_info < (3, 0): @@ -755,6 +758,35 @@ class TreeModel(Gtk.TreeModel): raise ValueError('Expected an long for column %i but got %s' % (column, type(value))) else: raise ValueError('Expected an integer for column %i but got %s' % (column, type(value))) + elif type_ == GObject.TYPE_BOOLEAN: + if isinstance(value, (int, long)): + value = bool(value) + else: + raise ValueError('Expected a bool for column %i but got %s' % (column, type(value))) + else: + # use GValues directly to marshal to the correct type + # standard object checks should take care of validation + # so we don't have to do it here + value_container = GObject.Value() + value_container.init(type_) + if type_ == GObject.TYPE_CHAR: + value_container.set_char(value) + value = value_container + elif type_ == GObject.TYPE_UCHAR: + value_container.set_uchar(value) + value = value_container + elif type_ == GObject.TYPE_UINT: + value_container.set_uint(value) + value = value_container + elif type_ == GObject.TYPE_ULONG: + value_container.set_ulong(value) + value = value_container + elif type_ == GObject.TYPE_INT64: + value_container.set_int64(value) + value = value_container + elif type_ == GObject.TYPE_UINT64: + value_container.set_uint64(value) + value = value_container return value @@ -1143,6 +1175,12 @@ __all__.append('Adjustment') class Table(Gtk.Table, Container): def __init__(self, rows=1, columns=1, homogeneous=False, **kwds): + if 'n_rows' in kwds: + rows = kwds.pop('n_rows') + + if 'n_columns' in kwds: + columns = kwds.pop('n_columns') + Gtk.Table.__init__(self, n_rows=rows, n_columns=columns, homogeneous=homogeneous, **kwds) def attach(self, child, left_attach, right_attach, top_attach, bottom_attach, xoptions=Gtk.AttachOptions.EXPAND|Gtk.AttachOptions.FILL, yoptions=Gtk.AttachOptions.EXPAND|Gtk.AttachOptions.FILL, xpadding=0, ypadding=0): @@ -1168,6 +1206,13 @@ class Paned(Gtk.Paned): Paned = override(Paned) __all__.append('Paned') +if Gtk._version != '2.0': + class Menu(Gtk.Menu): + def popup(self, parent_menu_shell, parent_menu_item, func, data, button, activate_time): + self.popup_for_device(None, parent_menu_shell, parent_menu_item, func, data, button, activate_time) + Menu = override(Menu) + __all__.append('Menu') + _Gtk_main_quit = Gtk.main_quit @override(Gtk.main_quit) def main_quit(*args): diff --git a/gi/pygi-argument.c b/gi/pygi-argument.c index 8dd728d..bbbad00 100644 --- a/gi/pygi-argument.c +++ b/gi/pygi-argument.c @@ -241,8 +241,46 @@ _pygi_g_type_interface_check_object (GIBaseInfo *info, case GI_INFO_TYPE_BOXED: case GI_INFO_TYPE_INTERFACE: case GI_INFO_TYPE_OBJECT: + retval = _pygi_g_registered_type_info_check_object ( (GIRegisteredTypeInfo *) info, TRUE, object); + break; case GI_INFO_TYPE_UNION: + + retval = _pygi_g_registered_type_info_check_object ( (GIRegisteredTypeInfo *) info, TRUE, object); + + /* If not the same type then check to see if the object's type + * is the same as one of the union's members + */ + if (retval == 0) { + gint i; + gint n_fields; + + n_fields = g_union_info_get_n_fields ( (GIUnionInfo *) info); + + for (i = 0; i < n_fields; i++) { + gint member_retval; + GIFieldInfo *field_info; + GITypeInfo *field_type_info; + + field_info = + g_union_info_get_field ( (GIUnionInfo *) info, i); + field_type_info = g_field_info_get_type (field_info); + + member_retval = _pygi_g_type_info_check_object( + field_type_info, + object, + TRUE); + + g_base_info_unref ( ( GIBaseInfo *) field_type_info); + g_base_info_unref ( ( GIBaseInfo *) field_info); + + if (member_retval == 1) { + retval = member_retval; + break; + } + } + } + break; default: g_assert_not_reached(); @@ -1009,13 +1047,25 @@ array_success: g_warn_if_fail (transfer == GI_TRANSFER_NOTHING); value = g_slice_new0 (GValue); - g_value_init (value, object_type); - retval = pyg_value_from_pyobject (value, object); - if (retval < 0) { - g_slice_free (GValue, value); - PyErr_SetString (PyExc_RuntimeError, "PyObject conversion to GValue failed"); - break; + /* if already a gvalue, copy, else marshal into gvalue */ + if (object_type == G_TYPE_VALUE) { + /* src GValue's lifecycle is handled by Python + * so we have to copy it into the destination's + * GValue which is freed during the cleanup of + * invoke. + */ + GValue *src = (GValue *)((PyGObject *) object)->obj; + g_value_init (value, G_VALUE_TYPE (src)); + g_value_copy(src, value); + } else { + g_value_init (value, object_type); + retval = pyg_value_from_pyobject (value, object); + if (retval < 0) { + g_slice_free (GValue, value); + PyErr_SetString (PyExc_RuntimeError, "PyObject conversion to GValue failed"); + break; + } } arg.v_pointer = value; @@ -1719,6 +1769,97 @@ _pygi_argument_to_object (GIArgument *arg, return object; } + +GIArgument +_pygi_argument_from_g_value(const GValue *value, + GITypeInfo *type_info) +{ + GIArgument arg = { 0, }; + + GITypeTag type_tag = g_type_info_get_tag (type_info); + switch (type_tag) { + case GI_TYPE_TAG_BOOLEAN: + arg.v_boolean = g_value_get_boolean (value); + break; + case GI_TYPE_TAG_INT8: + case GI_TYPE_TAG_INT16: + case GI_TYPE_TAG_INT32: + case GI_TYPE_TAG_INT64: + arg.v_int = g_value_get_int (value); + break; + case GI_TYPE_TAG_UINT8: + case GI_TYPE_TAG_UINT16: + case GI_TYPE_TAG_UINT32: + case GI_TYPE_TAG_UINT64: + arg.v_uint = g_value_get_uint (value); + break; + case GI_TYPE_TAG_UNICHAR: + arg.v_uint32 = g_value_get_char (value); + break; + case GI_TYPE_TAG_FLOAT: + arg.v_float = g_value_get_float (value); + break; + case GI_TYPE_TAG_DOUBLE: + arg.v_double = g_value_get_double (value); + break; + case GI_TYPE_TAG_GTYPE: + arg.v_long = g_value_get_gtype (value); + break; + case GI_TYPE_TAG_UTF8: + case GI_TYPE_TAG_FILENAME: + arg.v_string = g_value_dup_string (value); + break; + case GI_TYPE_TAG_GLIST: + case GI_TYPE_TAG_GSLIST: + arg.v_pointer = g_value_get_pointer (value); + break; + case GI_TYPE_TAG_ARRAY: + case GI_TYPE_TAG_GHASH: + arg.v_pointer = g_value_get_boxed (value); + break; + case GI_TYPE_TAG_INTERFACE: + { + GIBaseInfo *info; + GIInfoType info_type; + + info = g_type_info_get_interface (type_info); + info_type = g_base_info_get_type (info); + + g_base_info_unref (info); + + switch (info_type) { + case GI_INFO_TYPE_FLAGS: + case GI_INFO_TYPE_ENUM: + arg.v_long = g_value_get_enum (value); + break; + case GI_INFO_TYPE_INTERFACE: + case GI_INFO_TYPE_OBJECT: + arg.v_pointer = g_value_get_object (value); + break; + case GI_INFO_TYPE_BOXED: + case GI_INFO_TYPE_STRUCT: + case GI_INFO_TYPE_UNION: + if (G_VALUE_HOLDS(value, G_TYPE_BOXED)) { + arg.v_pointer = g_value_get_boxed (value); + } else { + arg.v_pointer = g_value_get_pointer (value); + } + break; + default: + g_warning("Converting of type '%s' is not implemented", g_info_type_to_string(info_type)); + g_assert_not_reached(); + } + break; + } + case GI_TYPE_TAG_ERROR: + case GI_TYPE_TAG_VOID: + g_critical("Converting of type '%s' is not implemented", g_type_tag_to_string(type_tag)); + g_assert_not_reached(); + } + + return arg; +} + void _pygi_argument_release (GIArgument *arg, GITypeInfo *type_info, diff --git a/gi/pygi-argument.h b/gi/pygi-argument.h index d932e8f..7224c75 100644 --- a/gi/pygi-argument.h +++ b/gi/pygi-argument.h @@ -55,6 +55,8 @@ PyObject* _pygi_argument_to_object (GIArgument *arg, GITypeInfo *type_info, GITransfer transfer); +GIArgument _pygi_argument_from_g_value(const GValue *value, + GITypeInfo *type_info); void _pygi_argument_release (GIArgument *arg, GITypeInfo *type_info, diff --git a/gi/pygi-closure.c b/gi/pygi-closure.c index 33a8d81..56ddc8b 100644 --- a/gi/pygi-closure.c +++ b/gi/pygi-closure.c @@ -295,6 +295,14 @@ _pygi_closure_set_out_arguments (GICallableInfo *callable_info, if (direction == GI_DIRECTION_OUT || direction == GI_DIRECTION_INOUT) { GITransfer transfer = g_arg_info_get_ownership_transfer (arg_info); + + if (g_type_info_get_tag (type_info) == GI_TYPE_TAG_ERROR) { + /* TODO: check if an exception has been set and convert it to a GError */ + out_args[i_out_args].v_pointer = NULL; + i_out_args++; + continue; + } + if (PyTuple_Check (py_retval)) { PyObject *item = PyTuple_GET_ITEM (py_retval, i_py_retval); _pygi_closure_assign_pyobj_to_out_argument ( diff --git a/gi/pygi-info.c b/gi/pygi-info.c index f5dd69f..1bfd7d8 100644 --- a/gi/pygi-info.c +++ b/gi/pygi-info.c @@ -923,8 +923,23 @@ _wrap_g_enum_info_get_values (PyGIBaseInfo *self) return infos; } +static PyObject * +_wrap_g_enum_info_is_flags (PyGIBaseInfo *self) +{ + GIInfoType info_type = g_base_info_get_type ((GIBaseInfo *) self->info); + + if (info_type == GI_INFO_TYPE_ENUM) { + Py_RETURN_FALSE; + } else if (info_type == GI_INFO_TYPE_FLAGS) { + Py_RETURN_TRUE; + } else { + g_assert_not_reached(); + } +} + static PyMethodDef _PyGIEnumInfo_methods[] = { { "get_values", (PyCFunction) _wrap_g_enum_info_get_values, METH_NOARGS }, + { "is_flags", (PyCFunction) _wrap_g_enum_info_is_flags, METH_NOARGS }, { NULL, NULL, 0 } }; diff --git a/gi/pygi-invoke.c b/gi/pygi-invoke.c index c93442a..78984e5 100644 --- a/gi/pygi-invoke.c +++ b/gi/pygi-invoke.c @@ -62,6 +62,12 @@ struct invocation_state PyObject *return_value; GType implementor_gtype; + + /* hack to avoid treating C arrays as GArrays during free + * due to overly complicated array handling + * this will be removed when the new invoke branch is merged + */ + gboolean c_arrays_are_wrapped; }; static gboolean @@ -121,6 +127,11 @@ _initialize_invocation_state (struct invocation_state *state, state->out_values = NULL; state->backup_args = NULL; + /* HACK: this gets marked FALSE whenever a C array in the args is + * not wrapped by a GArray + */ + state->c_arrays_are_wrapped = TRUE; + return TRUE; } @@ -556,6 +567,20 @@ _prepare_invocation_state (struct invocation_state *state, (g_type_info_get_array_type (state->arg_type_infos[i]) == GI_ARRAY_TYPE_C)) { state->args[i]->v_pointer = array->data; + /* HACK: We have unwrapped a C array so + * set the state to reflect this. + * If there is an error between now + * and when we rewrap the array + * we will leak C arrays due to + * being in an inconsitant state. + * e.g. for interfaces with more + * than one C array argument, an + * error may occure when not all + * C arrays have been rewrapped. + * This will be removed once the invoke + * rewrite branch is merged. + */ + state->c_arrays_are_wrapped = FALSE; if (direction != GI_DIRECTION_INOUT || transfer != GI_TRANSFER_NOTHING) { /* The array hasn't been referenced anywhere, so free it to avoid losing memory. */ g_array_free (array, FALSE); @@ -851,6 +876,14 @@ _process_invocation_state (struct invocation_state *state, } + /* HACK: We rewrapped any C arrays above in a GArray so they are ok to + * free as GArrays. We will always leak C arrays if there is + * an error before we reach this state as there is no easy way + * to know which arrays were wrapped if there are more than one. + * This will be removed with better array handling once merge + * the invoke rewrite branch. + */ + state->c_arrays_are_wrapped = TRUE; g_assert (state->n_return_values <= 1 || return_values_pos == state->n_return_values); } @@ -900,13 +933,26 @@ _free_invocation_state (struct invocation_state *state) backup_args_pos += 1; } if (state->args != NULL && state->args[i] != NULL) { - _pygi_argument_release (state->args[i], state->arg_type_infos[i], - transfer, direction); - type_tag = g_type_info_get_tag (state->arg_type_infos[i]); + + if (type_tag == GI_TYPE_TAG_ARRAY && + (direction == GI_DIRECTION_IN || direction == GI_DIRECTION_INOUT) && + (g_type_info_get_array_type (state->arg_type_infos[i]) == GI_ARRAY_TYPE_C) && + !state->c_arrays_are_wrapped) { + /* HACK: Noop - we are in an inconsitant state due to + * complex array handler so leak any C arrays + * as we don't know if we can free them safely. + * This will be removed when we merge the + * invoke rewrite branch. + */ + } else { + _pygi_argument_release (state->args[i], state->arg_type_infos[i], + transfer, direction); + } + if (type_tag == GI_TYPE_TAG_ARRAY && (direction != GI_DIRECTION_IN && transfer == GI_TRANSFER_NOTHING)) { - /* We created a #GArray and it has not been released above, so free it. */ + /* We created an *out* #GArray and it has not been released above, so free it. */ state->args[i]->v_pointer = g_array_free (state->args[i]->v_pointer, FALSE); } } diff --git a/gi/pygi-private.h b/gi/pygi-private.h index 3a14bc3..efe62c8 100644 --- a/gi/pygi-private.h +++ b/gi/pygi-private.h @@ -29,6 +29,7 @@ #include "pygi-callbacks.h" #include "pygi-invoke.h" #include "pygi-property.h" +#include "pygi-signal-closure.h" G_BEGIN_DECLS #if PY_VERSION_HEX >= 0x03000000 diff --git a/gi/pygi-repository.c b/gi/pygi-repository.c index 9b22eae..c48d2ce 100644 --- a/gi/pygi-repository.c +++ b/gi/pygi-repository.c @@ -234,6 +234,28 @@ _wrap_g_irepository_get_version (PyGIRepository *self, return PYGLIB_PyUnicode_FromString (version); } +static PyObject * +_wrap_g_irepository_get_loaded_namespaces (PyGIRepository *self) +{ + char **namespaces; + PyObject *py_namespaces; + gssize i; + + namespaces = g_irepository_get_loaded_namespaces (self->repository); + + py_namespaces = PyList_New (0); + for (i = 0; namespaces[i] != NULL; i++) { + PyObject *py_namespace = PYGLIB_PyUnicode_FromString (namespaces[i]); + PyList_Append (py_namespaces, py_namespace); + Py_DECREF(py_namespace); + g_free (namespaces[i]); + } + + g_free (namespaces); + + return py_namespaces; +} + static PyMethodDef _PyGIRepository_methods[] = { { "enumerate_versions", (PyCFunction) _wrap_g_irepository_enumerate_versions, METH_VARARGS | METH_KEYWORDS }, { "get_default", (PyCFunction) _wrap_g_irepository_get_default, METH_STATIC | METH_NOARGS }, @@ -242,6 +264,7 @@ static PyMethodDef _PyGIRepository_methods[] = { { "find_by_name", (PyCFunction) _wrap_g_irepository_find_by_name, METH_VARARGS | METH_KEYWORDS }, { "get_typelib_path", (PyCFunction) _wrap_g_irepository_get_typelib_path, METH_VARARGS | METH_KEYWORDS }, { "get_version", (PyCFunction) _wrap_g_irepository_get_version, METH_VARARGS | METH_KEYWORDS }, + { "get_loaded_namespaces", (PyCFunction) _wrap_g_irepository_get_loaded_namespaces, METH_NOARGS }, { NULL, NULL, 0 } }; diff --git a/gi/pygi-signal-closure.c b/gi/pygi-signal-closure.c new file mode 100644 index 0000000..1482529 --- /dev/null +++ b/gi/pygi-signal-closure.c @@ -0,0 +1,245 @@ +/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */ +/* + * Copyright (c) 2011 Laszlo Pandy + * + * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + */ + +#include "pygi-private.h" + +/* Copied from glib */ +static void +canonicalize_key (gchar *key) +{ + gchar *p; + + for (p = key; *p != 0; p++) + { + gchar c = *p; + + if (c != '-' && + (c < '0' || c > '9') && + (c < 'A' || c > 'Z') && + (c < 'a' || c > 'z')) + *p = '-'; + } +} + +static GISignalInfo * +_pygi_lookup_signal_from_g_type (GType g_type, + const gchar *signal_name) +{ + GIRepository *repository; + GIBaseInfo *info; + gssize n_infos; + gssize i; + GType parent; + + repository = g_irepository_get_default(); + info = g_irepository_find_by_gtype (repository, g_type); + if (info != NULL) { + n_infos = g_object_info_get_n_signals ( (GIObjectInfo *) info); + for (i = 0; i < n_infos; i++) { + GISignalInfo *signal_info; + + signal_info = g_object_info_get_signal ( (GIObjectInfo *) info, i); + g_assert (info != NULL); + + if (strcmp (signal_name, g_base_info_get_name (signal_info)) == 0) { + g_base_info_unref (info); + return signal_info; + } + + g_base_info_unref (signal_info); + } + + g_base_info_unref (info); + } + + parent = g_type_parent (g_type); + if (parent > 0) + return _pygi_lookup_signal_from_g_type (parent, signal_name); + + return NULL; +} + +static void +pygi_signal_closure_invalidate(gpointer data, + GClosure *closure) +{ + PyGClosure *pc = (PyGClosure *)closure; + PyGILState_STATE state; + + state = PyGILState_Ensure(); + Py_XDECREF(pc->callback); + Py_XDECREF(pc->extra_args); + Py_XDECREF(pc->swap_data); + PyGILState_Release(state); + + pc->callback = NULL; + pc->extra_args = NULL; + pc->swap_data = NULL; + + g_base_info_unref (((PyGISignalClosure *) pc)->signal_info); + ((PyGISignalClosure *) pc)->signal_info = NULL; +} + +static void +pygi_signal_closure_marshal(GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data) +{ + PyGILState_STATE state; + PyGClosure *pc = (PyGClosure *)closure; + PyObject *params, *ret = NULL; + guint i; + GISignalInfo *signal_info; + gint n_sig_info_args; + gint sig_info_highest_arg; + + state = PyGILState_Ensure(); + + signal_info = ((PyGISignalClosure *)closure)->signal_info; + n_sig_info_args = g_callable_info_get_n_args(signal_info); + /* the first argument to a signal callback is instance, + but instance is not counted in the introspection data */ + sig_info_highest_arg = n_sig_info_args + 1; + g_assert_cmpint(sig_info_highest_arg, ==, n_param_values); + + /* construct Python tuple for the parameter values */ + params = PyTuple_New(n_param_values); + for (i = 0; i < n_param_values; i++) { + /* swap in a different initial data for connect_object() */ + if (i == 0 && G_CCLOSURE_SWAP_DATA(closure)) { + g_return_if_fail(pc->swap_data != NULL); + Py_INCREF(pc->swap_data); + PyTuple_SetItem(params, 0, pc->swap_data); + + } else if (i == 0) { + PyObject *item = pyg_value_as_pyobject(¶m_values[i], FALSE); + + if (!item) { + goto out; + } + PyTuple_SetItem(params, i, item); + + } else if (i < sig_info_highest_arg) { + GIArgInfo arg_info; + GITypeInfo type_info; + GITransfer transfer; + GIArgument arg = { 0, }; + PyObject *item = NULL; + + g_callable_info_load_arg(signal_info, i - 1, &arg_info); + g_arg_info_load_type(&arg_info, &type_info); + transfer = g_arg_info_get_ownership_transfer(&arg_info); + + arg = _pygi_argument_from_g_value(¶m_values[i], &type_info); + item = _pygi_argument_to_object(&arg, &type_info, transfer); + + if (item == NULL) { + goto out; + } + PyTuple_SetItem(params, i, item); + } + } + /* params passed to function may have extra arguments */ + if (pc->extra_args) { + PyObject *tuple = params; + params = PySequence_Concat(tuple, pc->extra_args); + Py_DECREF(tuple); + } + ret = PyObject_CallObject(pc->callback, params); + if (ret == NULL) { + if (pc->exception_handler) + pc->exception_handler(return_value, n_param_values, param_values); + else + PyErr_Print(); + goto out; + } + + if (return_value && pyg_value_from_pyobject(return_value, ret) != 0) { + PyErr_SetString(PyExc_TypeError, + "can't convert return value to desired type"); + + if (pc->exception_handler) + pc->exception_handler(return_value, n_param_values, param_values); + else + PyErr_Print(); + } + Py_DECREF(ret); + + out: + Py_DECREF(params); + PyGILState_Release(state); +} + +GClosure * +pygi_signal_closure_new_real (PyGObject *instance, + const gchar *sig_name, + PyObject *callback, + PyObject *extra_args, + PyObject *swap_data) +{ + GClosure *closure = NULL; + PyGISignalClosure *pygi_closure = NULL; + GType g_type; + GISignalInfo *signal_info = NULL; + char *signal_name = g_strdup (sig_name); + + g_return_val_if_fail(callback != NULL, NULL); + + canonicalize_key(signal_name); + + g_type = pyg_type_from_object ((PyObject *)instance); + signal_info = _pygi_lookup_signal_from_g_type (g_type, signal_name); + + if (signal_info == NULL) + goto out; + + closure = g_closure_new_simple(sizeof(PyGISignalClosure), NULL); + g_closure_add_invalidate_notifier(closure, NULL, pygi_signal_closure_invalidate); + g_closure_set_marshal(closure, pygi_signal_closure_marshal); + + pygi_closure = (PyGISignalClosure *)closure; + + pygi_closure->signal_info = signal_info; + Py_INCREF(callback); + pygi_closure->pyg_closure.callback = callback; + + if (extra_args != NULL && extra_args != Py_None) { + Py_INCREF(extra_args); + if (!PyTuple_Check(extra_args)) { + PyObject *tmp = PyTuple_New(1); + PyTuple_SetItem(tmp, 0, extra_args); + extra_args = tmp; + } + pygi_closure->pyg_closure.extra_args = extra_args; + } + if (swap_data) { + Py_INCREF(swap_data); + pygi_closure->pyg_closure.swap_data = swap_data; + closure->derivative_flag = TRUE; + } + +out: + g_free (signal_name); + + return closure; +} diff --git a/gi/pygi-signal-closure.h b/gi/pygi-signal-closure.h new file mode 100644 index 0000000..4687f3f --- /dev/null +++ b/gi/pygi-signal-closure.h @@ -0,0 +1,46 @@ +/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */ +/* + * Copyright (c) 2011 Laszlo Pandy + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef __PYGI_SIGNAL_CLOSURE_H__ +#define __PYGI_SIGNAL_CLOSURE_H__ + +#include "pygi.h" + +G_BEGIN_DECLS + +/* Private */ +typedef struct _PyGISignalClosure +{ + PyGClosure pyg_closure; + GISignalInfo *signal_info; +} PyGISignalClosure; + +GClosure * pygi_signal_closure_new_real (PyGObject *instance, + const gchar *sig_name, + PyObject *callback, + PyObject *extra_args, + PyObject *swap_data); + +G_END_DECLS + +#endif /* __PYGI_SIGNAL_CLOSURE_H__ */ diff --git a/gi/pygi.h b/gi/pygi.h index 2765b40..1c3bf5e 100644 --- a/gi/pygi.h +++ b/gi/pygi.h @@ -71,6 +71,11 @@ struct PyGI_API { gint (*set_property_value) (PyGObject *instance, const gchar *attr_name, PyObject *value); + GClosure * (*signal_closure_new) (PyGObject *instance, + const gchar *sig_name, + PyObject *callback, + PyObject *extra_args, + PyObject *swap_data); void (*register_foreign_struct) (const char* namespace_, const char* name, PyGIArgOverrideToGIArgumentFunc to_func, @@ -83,14 +88,20 @@ static struct PyGI_API *PyGI_API = NULL; static int _pygi_import (void) { + PyObject *modules_dict; + if (PyGI_API != NULL) { return 1; } + + modules_dict = PyImport_GetModuleDict(); /* borrowed reference -- don't unref */ + if (PyMapping_HasKeyString(modules_dict, "gi")) { #if PY_VERSION_HEX >= 0x03000000 - PyGI_API = (struct PyGI_API*) PyCapsule_Import("gi._API", FALSE); + PyGI_API = (struct PyGI_API*) PyCapsule_Import("gi._API", FALSE); #else - PyGI_API = (struct PyGI_API*) PyCObject_Import("gi", "_API"); + PyGI_API = (struct PyGI_API*) PyCObject_Import("gi", "_API"); #endif + } if (PyGI_API == NULL) { return -1; } @@ -128,6 +139,19 @@ pygi_set_property_value (PyGObject *instance, return PyGI_API->set_property_value(instance, attr_name, value); } +static inline GClosure * +pygi_signal_closure_new (PyGObject *instance, + const gchar *sig_name, + PyObject *callback, + PyObject *extra_args, + PyObject *swap_data) +{ + if (_pygi_import() < 0) { + return NULL; + } + return PyGI_API->signal_closure_new(instance, sig_name, callback, extra_args, swap_data); +} + static inline PyObject * pygi_register_foreign_struct (const char* namespace_, const char* name, @@ -169,6 +193,16 @@ pygi_set_property_value (PyGObject *instance, return -1; } +static inline GClosure * +pygi_signal_closure_new (PyGObject *instance, + const gchar *sig_name, + PyObject *callback, + PyObject *extra_args, + PyObject *swap_data) +{ + return NULL; +} + #endif /* ENABLE_INTROSPECTION */ #endif /* __PYGI_H__ */ diff --git a/gi/types.py b/gi/types.py index 37cf499..ed568d1 100644 --- a/gi/types.py +++ b/gi/types.py @@ -229,6 +229,46 @@ class GObjectMeta(gobject.GObjectMeta, MetaClassHelper): elif isinstance(cls.__info__, InterfaceInfo): register_interface_info(cls.__info__.get_g_type()) + def mro(cls): + return mro(cls) + + +def mro(C): + """Compute the class precedence list (mro) according to C3 + + Based on http://www.python.org/download/releases/2.3/mro/ + Modified to consider that interfaces don't create the diamond problem + """ + # TODO: If this turns out being too slow, consider using generators + bases = [] + bases_of_subclasses = [[C]] + + if C.__bases__: + bases_of_subclasses += map(mro, C.__bases__) + [list(C.__bases__)] + + while bases_of_subclasses: + for subclass_bases in bases_of_subclasses: + candidate = subclass_bases[0] + not_head = [s for s in bases_of_subclasses if candidate in s[1:]] + if not_head and gobject.GInterface not in candidate.__bases__: + candidate = None # conflict, reject candidate + else: + break + + if candidate is None: + raise TypeError('Cannot create a consistent method resolution ' + 'order (MRO)') + + bases.append(candidate) + + for subclass_bases in bases_of_subclasses[:]: # remove candidate + if subclass_bases and subclass_bases[0] == candidate: + del subclass_bases[0] + if not subclass_bases: + bases_of_subclasses.remove(subclass_bases) + + return bases + class StructMeta(type, MetaClassHelper): @@ -250,19 +290,3 @@ class StructMeta(type, MetaClassHelper): not method_info.get_arguments(): cls.__new__ = staticmethod(Constructor(method_info)) break - -class Enum(int): - # Only subclasses of this type should be instantiated. - # Each subclass requires an __info__ attribute, - # which is not declared here because enums do not share the same gi type. - def __init__(self, value): - int.__init__(value) - - def __repr__(self): - value_name = str(self) - for value_info in self.__info__.get_values(): - if self == value_info.get_value(): - value_name = value_info.get_name().upper() - return "" % (value_name, - self.__info__.get_namespace(), - self.__info__.get_name()) diff --git a/gobject/gobjectmodule.c b/gobject/gobjectmodule.c index acf94ce..2a84606 100644 --- a/gobject/gobjectmodule.c +++ b/gobject/gobjectmodule.c @@ -1176,16 +1176,21 @@ pyg_type_register(PyTypeObject *class, const char *type_name) /* create new typecode */ instance_type = g_type_register_static(parent_type, new_type_name, &type_info, 0); - if (type_name == NULL) - g_free(new_type_name); if (instance_type == 0) { PyErr_Format(PyExc_RuntimeError, "could not create new GType: %s (subclass of %s)", new_type_name, g_type_name(parent_type)); + + if (type_name == NULL) + g_free(new_type_name); + return -1; } + if (type_name == NULL) + g_free(new_type_name); + /* store pointer to the class with the GType */ Py_INCREF(class); g_type_set_qdata(instance_type, g_quark_from_string("PyGObject::class"), diff --git a/gobject/pygflags.c b/gobject/pygflags.c index 936f314..8c00f15 100644 --- a/gobject/pygflags.c +++ b/gobject/pygflags.c @@ -161,7 +161,7 @@ pyg_flags_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) return NULL; } - if (!PyDict_Check(values) || PyDict_Size(values) != eclass->n_values) { + if (!PyDict_Check(values)) { PyErr_SetString(PyExc_TypeError, "__flags_values__ badly formed"); Py_DECREF(values); g_type_class_unref(eclass); @@ -172,13 +172,18 @@ pyg_flags_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) pyint = PYGLIB_PyLong_FromLong(value); ret = PyDict_GetItem(values, pyint); + if (!ret) { + PyErr_Clear(); + + ret = pyg_flags_val_new((PyObject *)type, gtype, pyint); + g_assert(ret != NULL); + } else { + Py_INCREF(ret); + } + Py_DECREF(pyint); Py_DECREF(values); - if (ret) - Py_INCREF(ret); - else - PyErr_Format(PyExc_ValueError, "invalid flag value: %ld", value); return ret; } diff --git a/gobject/pygobject.c b/gobject/pygobject.c index a7b4505..3e77f99 100644 --- a/gobject/pygobject.c +++ b/gobject/pygobject.c @@ -1528,7 +1528,11 @@ pygobject_connect(PyGObject *self, PyObject *args) extra_args = PySequence_GetSlice(args, 2, len); if (extra_args == NULL) return NULL; - closure = pyg_closure_new(callback, extra_args, NULL); + + closure = pygi_signal_closure_new(self, name, callback, extra_args, NULL); + if (closure == NULL) + closure = pyg_closure_new(callback, extra_args, NULL); + pygobject_watch_closure((PyObject *)self, closure); handlerid = g_signal_connect_closure_by_id(self->obj, sigid, detail, closure, FALSE); @@ -1577,7 +1581,11 @@ pygobject_connect_after(PyGObject *self, PyObject *args) extra_args = PySequence_GetSlice(args, 2, len); if (extra_args == NULL) return NULL; - closure = pyg_closure_new(callback, extra_args, NULL); + + closure = pygi_signal_closure_new(self, name, callback, extra_args, NULL); + if (closure == NULL) + closure = pyg_closure_new(callback, extra_args, NULL); + pygobject_watch_closure((PyObject *)self, closure); handlerid = g_signal_connect_closure_by_id(self->obj, sigid, detail, closure, TRUE); @@ -1626,7 +1634,11 @@ pygobject_connect_object(PyGObject *self, PyObject *args) extra_args = PySequence_GetSlice(args, 3, len); if (extra_args == NULL) return NULL; - closure = pyg_closure_new(callback, extra_args, object); + + closure = pygi_signal_closure_new(self, name, callback, extra_args, object); + if (closure == NULL) + closure = pyg_closure_new(callback, extra_args, object); + pygobject_watch_closure((PyObject *)self, closure); handlerid = g_signal_connect_closure_by_id(self->obj, sigid, detail, closure, FALSE); @@ -1675,7 +1687,11 @@ pygobject_connect_object_after(PyGObject *self, PyObject *args) extra_args = PySequence_GetSlice(args, 3, len); if (extra_args == NULL) return NULL; - closure = pyg_closure_new(callback, extra_args, object); + + closure = pygi_signal_closure_new(self, name, callback, extra_args, object); + if (closure == NULL) + closure = pyg_closure_new(callback, extra_args, object); + pygobject_watch_closure((PyObject *)self, closure); handlerid = g_signal_connect_closure_by_id(self->obj, sigid, detail, closure, TRUE); diff --git a/tests/Makefile.am b/tests/Makefile.am index fb3d8e7..e5c2a68 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -68,7 +68,7 @@ testhelper.la: $(testhelper_la_OBJECTS) $(testhelper_la_DEPENDENCIES) all: $(LTLIBRARIES:.la=.so) -TEST_FILES = \ +TEST_FILES_STATIC = \ test_gobject.py \ test_interface.py \ test_mainloop.py \ @@ -81,7 +81,7 @@ TEST_FILES = \ test_uris.py if BUILD_GIO -GIO_TEST_FILES = \ +TEST_FILES_GIO = \ test_gio.py \ test_gresolver.py \ test_gsocket.py \ @@ -90,7 +90,7 @@ GIO_TEST_FILES = \ endif if ENABLE_INTROSPECTION -TEST_FILES += \ +TEST_FILES_GI = \ test_everything.py \ test_gi.py \ test_gdbus.py \ @@ -106,30 +106,25 @@ EXTRA_DIST = \ test-unknown.h \ org.gnome.test.gschema.xml -EXTRA_DIST += $(TEST_FILES) +EXTRA_DIST += $(TEST_FILES_STATIC) $(TEST_FILES_GI) $(TEST_FILES_GIO) clean-local: rm -f $(LTLIBRARIES:.la=.so) file.txt~ DBUS_LAUNCH=$(shell which dbus-launch) - -# need to run the gio tests separately to avoid loading gi.repository.Gio and -# gio at the same time -check-local: $(LTLIBRARIES:.la=.so) Regress-1.0.typelib GIMarshallingTests-1.0.typelib gschemas.compiled - TEST_FILES="$(TEST_FILES)" \ +RUN_TESTS_ENV_VARS= \ PYTHONPATH=$(top_builddir):$(top_builddir)/tests:$${PYTHONPATH:+:$$PYTHONPATH} \ LD_LIBRARY_PATH=$(builddir)/.libs:$$LD_LIBRARY_PATH \ GI_TYPELIB_PATH=$(builddir):$$GI_TYPELIB_PATH \ - XDG_DATA_DIRS=$$XDG_DATA_DIRS:/usr/share \ - $(DBUS_LAUNCH) $(EXEC_NAME) $(PYTHON) $(srcdir)/runtests.py + XDG_DATA_DIRS=$$XDG_DATA_DIRS:/usr/share +RUN_TESTS_LAUNCH=$(RUN_TESTS_ENV_VARS) $(DBUS_LAUNCH) $(EXEC_NAME) $(PYTHON) $(srcdir)/runtests.py +# run tests in separately to avoid loading static and introspection bindings in the same process +check-local: $(LTLIBRARIES:.la=.so) Regress-1.0.typelib GIMarshallingTests-1.0.typelib gschemas.compiled + TEST_FILES="$(TEST_FILES_STATIC)" $(RUN_TESTS_LAUNCH) + TEST_FILES="$(TEST_FILES_GI)" $(RUN_TESTS_LAUNCH) if BUILD_GIO - TEST_FILES="$(GIO_TEST_FILES)" \ - PYTHONPATH=$(top_builddir):$(top_builddir)/tests:$${PYTHONPATH:+:$$PYTHONPATH} \ - LD_LIBRARY_PATH=$(builddir)/.libs:$$LD_LIBRARY_PATH \ - GI_TYPELIB_PATH=$(builddir):$$GI_TYPELIB_PATH \ - XDG_DATA_DIRS=$$XDG_DATA_DIRS:/usr/share \ - $(EXEC_NAME) $(PYTHON) $(srcdir)/runtests.py + TEST_FILES="$(TEST_FILES_GIO)" $(RUN_TESTS_LAUNCH) endif check.gdb: diff --git a/tests/Makefile.in b/tests/Makefile.in index 355b0bf..3084f8d 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -36,12 +36,6 @@ build_triplet = @build@ host_triplet = @host@ @ENABLE_INTROSPECTION_TRUE@am__append_1 = libregress.la libgimarshallingtests.la @ENABLE_INTROSPECTION_TRUE@am__append_2 = Regress-1.0.gir Regress-1.0.typelib GIMarshallingTests-1.0.gir GIMarshallingTests-1.0.typelib gschemas.compiled -@ENABLE_INTROSPECTION_TRUE@am__append_3 = \ -@ENABLE_INTROSPECTION_TRUE@ test_everything.py \ -@ENABLE_INTROSPECTION_TRUE@ test_gi.py \ -@ENABLE_INTROSPECTION_TRUE@ test_gdbus.py \ -@ENABLE_INTROSPECTION_TRUE@ test_overrides.py - subdir = tests DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 @@ -295,21 +289,42 @@ testhelper_la_SOURCES = \ test-thread.c \ test-unknown.c -TEST_FILES = test_gobject.py test_interface.py test_mainloop.py \ - test_option.py test_properties.py test_signal.py \ - test_source.py test_subprocess.py test_thread.py test_uris.py \ - $(am__append_3) -@BUILD_GIO_TRUE@GIO_TEST_FILES = \ +TEST_FILES_STATIC = \ + test_gobject.py \ + test_interface.py \ + test_mainloop.py \ + test_option.py \ + test_properties.py \ + test_signal.py \ + test_source.py \ + test_subprocess.py \ + test_thread.py \ + test_uris.py + +@BUILD_GIO_TRUE@TEST_FILES_GIO = \ @BUILD_GIO_TRUE@ test_gio.py \ @BUILD_GIO_TRUE@ test_gresolver.py \ @BUILD_GIO_TRUE@ test_gsocket.py \ @BUILD_GIO_TRUE@ test_gicon.py \ @BUILD_GIO_TRUE@ test_gcancellable.py +@ENABLE_INTROSPECTION_TRUE@TEST_FILES_GI = \ +@ENABLE_INTROSPECTION_TRUE@ test_everything.py \ +@ENABLE_INTROSPECTION_TRUE@ test_gi.py \ +@ENABLE_INTROSPECTION_TRUE@ test_gdbus.py \ +@ENABLE_INTROSPECTION_TRUE@ test_overrides.py + EXTRA_DIST = compathelper.py runtests.py testmodule.py test-floating.h \ test-thread.h test-unknown.h org.gnome.test.gschema.xml \ - $(TEST_FILES) + $(TEST_FILES_STATIC) $(TEST_FILES_GI) $(TEST_FILES_GIO) DBUS_LAUNCH = $(shell which dbus-launch) +RUN_TESTS_ENV_VARS = \ + PYTHONPATH=$(top_builddir):$(top_builddir)/tests:$${PYTHONPATH:+:$$PYTHONPATH} \ + LD_LIBRARY_PATH=$(builddir)/.libs:$$LD_LIBRARY_PATH \ + GI_TYPELIB_PATH=$(builddir):$$GI_TYPELIB_PATH \ + XDG_DATA_DIRS=$$XDG_DATA_DIRS:/usr/share + +RUN_TESTS_LAUNCH = $(RUN_TESTS_ENV_VARS) $(DBUS_LAUNCH) $(EXEC_NAME) $(PYTHON) $(srcdir)/runtests.py all: all-am .SUFFIXES: @@ -695,22 +710,11 @@ all: $(LTLIBRARIES:.la=.so) clean-local: rm -f $(LTLIBRARIES:.la=.so) file.txt~ -# need to run the gio tests separately to avoid loading gi.repository.Gio and -# gio at the same time +# run tests in separately to avoid loading static and introspection bindings in the same process check-local: $(LTLIBRARIES:.la=.so) Regress-1.0.typelib GIMarshallingTests-1.0.typelib gschemas.compiled - TEST_FILES="$(TEST_FILES)" \ - PYTHONPATH=$(top_builddir):$(top_builddir)/tests:$${PYTHONPATH:+:$$PYTHONPATH} \ - LD_LIBRARY_PATH=$(builddir)/.libs:$$LD_LIBRARY_PATH \ - GI_TYPELIB_PATH=$(builddir):$$GI_TYPELIB_PATH \ - XDG_DATA_DIRS=$$XDG_DATA_DIRS:/usr/share \ - $(DBUS_LAUNCH) $(EXEC_NAME) $(PYTHON) $(srcdir)/runtests.py - -@BUILD_GIO_TRUE@ TEST_FILES="$(GIO_TEST_FILES)" \ -@BUILD_GIO_TRUE@ PYTHONPATH=$(top_builddir):$(top_builddir)/tests:$${PYTHONPATH:+:$$PYTHONPATH} \ -@BUILD_GIO_TRUE@ LD_LIBRARY_PATH=$(builddir)/.libs:$$LD_LIBRARY_PATH \ -@BUILD_GIO_TRUE@ GI_TYPELIB_PATH=$(builddir):$$GI_TYPELIB_PATH \ -@BUILD_GIO_TRUE@ XDG_DATA_DIRS=$$XDG_DATA_DIRS:/usr/share \ -@BUILD_GIO_TRUE@ $(EXEC_NAME) $(PYTHON) $(srcdir)/runtests.py + TEST_FILES="$(TEST_FILES_STATIC)" $(RUN_TESTS_LAUNCH) + TEST_FILES="$(TEST_FILES_GI)" $(RUN_TESTS_LAUNCH) +@BUILD_GIO_TRUE@ TEST_FILES="$(TEST_FILES_GIO)" $(RUN_TESTS_LAUNCH) check.gdb: EXEC_NAME="gdb --args" $(MAKE) check diff --git a/tests/runtests.py b/tests/runtests.py index 54c65aa..a912414 100644 --- a/tests/runtests.py +++ b/tests/runtests.py @@ -2,6 +2,7 @@ import os import glob +import sys import unittest @@ -25,5 +26,7 @@ suite = loader.loadTestsFromNames(names) # Run tests. runner = unittest.TextTestRunner(verbosity=2) -runner.run(suite) +result = runner.run(suite) +if not result.wasSuccessful(): + sys.exit(1) # exit code so "make check" reports error diff --git a/tests/test_gcancellable.py b/tests/test_gcancellable.py new file mode 100644 index 0000000..f911572 --- /dev/null +++ b/tests/test_gcancellable.py @@ -0,0 +1,15 @@ +# -*- Mode: Python -*- + +import unittest + +import glib +import gio + + +class TestResolver(unittest.TestCase): + def setUp(self): + self.cancellable = gio.Cancellable() + + def test_make_poll_fd(self): + poll = self.cancellable.make_pollfd() + self.failUnless(isinstance(poll, glib.PollFD)) diff --git a/tests/test_gdbus.py b/tests/test_gdbus.py index 567433c..ade62d1 100644 --- a/tests/test_gdbus.py +++ b/tests/test_gdbus.py @@ -62,7 +62,7 @@ class TestGDBusClient(unittest.TestCase): def test_native_calls_async(self): def call_done(obj, result, user_data): - user_data['result'] = self.dbus_proxy.call_finish(result) + user_data['result'] = obj.call_finish(result) user_data['main_loop'].quit() main_loop = gobject.MainLoop() @@ -80,7 +80,7 @@ class TestGDBusClient(unittest.TestCase): def test_native_calls_async_errors(self): def call_done(obj, result, user_data): try: - self.dbus_proxy.call_finish(result) + obj.call_finish(result) self.fail('call_finish() for unknown method should raise an exception') except Exception as e: self.assertTrue('UnknownMethod' in str(e)) @@ -92,3 +92,101 @@ class TestGDBusClient(unittest.TestCase): self.dbus_proxy.call('UnknownMethod', None, Gio.DBusCallFlags.NO_AUTO_START, 500, None, call_done, data) main_loop.run() + + def test_python_calls_sync(self): + # single value return tuples get unboxed to the one element + result = self.dbus_proxy.ListNames('()') + self.assertTrue(isinstance(result, list)) + self.assertTrue(len(result) > 1) + self.assertTrue('org.freedesktop.DBus' in result) + + result = self.dbus_proxy.GetNameOwner('(s)', 'org.freedesktop.DBus') + self.assertEqual(type(result), type('')) + + # empty return tuples get unboxed to None + self.assertEqual(self.dbus_proxy.ReloadConfig('()'), None) + + # multiple return values remain a tuple; unfortunately D-BUS itself + # does not have any method returning multiple results, so try talking + # to notification-daemon (and don't fail the test if it does not exist) + try: + notification_daemon = Gio.DBusProxy.new_sync(self.bus, + Gio.DBusProxyFlags.NONE, None, + 'org.freedesktop.Notifications', + '/org/freedesktop/Notifications', + 'org.freedesktop.Notifications', None) + result = notification_daemon.GetServerInformation('()') + self.assertTrue(isinstance(result, tuple)) + self.assertEqual(len(result), 4) + for i in result: + self.assertEqual(type(i), type('')) + except Exception as e: + if 'Error.ServiceUnknown' not in str(e): + raise + + # test keyword argument; timeout=0 will fail immediately + try: + self.dbus_proxy.GetConnectionUnixProcessID('()', timeout=0) + self.fail('call with timeout=0 should raise an exception') + except Exception as e: + self.assertTrue('Timeout' in str(e), str(e)) + + def test_python_calls_sync_errors(self): + # error case: invalid argument types + try: + self.dbus_proxy.GetConnectionUnixProcessID('()') + self.fail('call with invalid arguments should raise an exception') + except Exception as e: + self.assertTrue('InvalidArgs' in str(e), str(e)) + + def test_python_calls_async(self): + def call_done(obj, result, user_data): + user_data['result'] = result + user_data['main_loop'].quit() + + main_loop = gobject.MainLoop() + data = {'main_loop': main_loop} + self.dbus_proxy.ListNames('()', result_handler=call_done, + user_data=data) + main_loop.run() + + result = data['result'] + self.assertEqual(type(result), type([])) + self.assertTrue(len(result) > 1) + self.assertTrue('org.freedesktop.DBus' in result) + + def test_python_calls_async_error_result(self): + # when only specifying a result handler, this will get the error + def call_done(obj, result, user_data): + user_data['result'] = result + user_data['main_loop'].quit() + + main_loop = gobject.MainLoop() + data = {'main_loop': main_loop} + self.dbus_proxy.ListNames('(s)', 'invalid_argument', + result_handler=call_done, user_data=data) + main_loop.run() + + self.assertTrue(isinstance(data['result'], Exception)) + self.assertTrue('InvalidArgs' in str(data['result']), str(data['result'])) + + def test_python_calls_async_error(self): + # when specifying an explicit error handler, this will get the error + def call_done(obj, result, user_data): + user_data['main_loop'].quit() + self.fail('result handler should not be called') + + def call_error(obj, error, user_data): + user_data['error'] = error + user_data['main_loop'].quit() + + main_loop = gobject.MainLoop() + data = {'main_loop': main_loop} + self.dbus_proxy.ListNames('(s)', 'invalid_argument', + result_handler=call_done, error_handler=call_error, + user_data=data) + main_loop.run() + + self.assertTrue(isinstance(data['error'], Exception)) + self.assertTrue('InvalidArgs' in str(data['error']), str(data['error'])) + diff --git a/tests/test_gi.py b/tests/test_gi.py index 22ff2c4..73eb6fc 100644 --- a/tests/test_gi.py +++ b/tests/test_gi.py @@ -925,13 +925,20 @@ class TestGValue(unittest.TestCase): def test_gvalue_in(self): GIMarshallingTests.gvalue_in(42) + value = GObject.Value() + value.init(GObject.TYPE_INT) + value.set_int(42) + GIMarshallingTests.gvalue_in(value) def test_gvalue_out(self): self.assertEquals(42, GIMarshallingTests.gvalue_out()) def test_gvalue_inout(self): self.assertEquals('42', GIMarshallingTests.gvalue_inout(42)) - + value = GObject.Value() + value.init(GObject.TYPE_INT) + value.set_int(42) + self.assertEquals('42', GIMarshallingTests.gvalue_inout(value)) class TestGClosure(unittest.TestCase): @@ -956,6 +963,15 @@ class TestEnum(unittest.TestCase): self.assertTrue(isinstance(GIMarshallingTests.Enum.VALUE3, GIMarshallingTests.Enum)) self.assertEquals(42, GIMarshallingTests.Enum.VALUE3) + def test_value_nick_and_name(self): + self.assertEqual(GIMarshallingTests.Enum.VALUE1.value_nick, 'value1') + self.assertEqual(GIMarshallingTests.Enum.VALUE2.value_nick, 'value2') + self.assertEqual(GIMarshallingTests.Enum.VALUE3.value_nick, 'value3') + + self.assertEqual(GIMarshallingTests.Enum.VALUE1.value_name, 'GI_MARSHALLING_TESTS_ENUM_VALUE1') + self.assertEqual(GIMarshallingTests.Enum.VALUE2.value_name, 'GI_MARSHALLING_TESTS_ENUM_VALUE2') + self.assertEqual(GIMarshallingTests.Enum.VALUE3.value_name, 'GI_MARSHALLING_TESTS_ENUM_VALUE3') + def test_enum_in(self): GIMarshallingTests.enum_in(GIMarshallingTests.Enum.VALUE3) GIMarshallingTests.enum_in(42) @@ -993,6 +1009,15 @@ class TestGEnum(unittest.TestCase): self.assertTrue(isinstance(GIMarshallingTests.GEnum.VALUE3, GIMarshallingTests.GEnum)) self.assertEquals(42, GIMarshallingTests.GEnum.VALUE3) + def test_value_nick_and_name(self): + self.assertEqual(GIMarshallingTests.GEnum.VALUE1.value_nick, 'value1') + self.assertEqual(GIMarshallingTests.GEnum.VALUE2.value_nick, 'value2') + self.assertEqual(GIMarshallingTests.GEnum.VALUE3.value_nick, 'value3') + + self.assertEqual(GIMarshallingTests.GEnum.VALUE1.value_name, 'GI_MARSHALLING_TESTS_GENUM_VALUE1') + self.assertEqual(GIMarshallingTests.GEnum.VALUE2.value_name, 'GI_MARSHALLING_TESTS_GENUM_VALUE2') + self.assertEqual(GIMarshallingTests.GEnum.VALUE3.value_name, 'GI_MARSHALLING_TESTS_GENUM_VALUE3') + def test_genum_in(self): GIMarshallingTests.genum_in(GIMarshallingTests.GEnum.VALUE3) GIMarshallingTests.genum_in(42) @@ -1018,10 +1043,24 @@ class TestGFlags(unittest.TestCase): self.assertTrue(isinstance(GIMarshallingTests.Flags.VALUE1, GIMarshallingTests.Flags)) self.assertTrue(isinstance(GIMarshallingTests.Flags.VALUE2, GIMarshallingTests.Flags)) self.assertTrue(isinstance(GIMarshallingTests.Flags.VALUE3, GIMarshallingTests.Flags)) + # __or__() operation should still return an instance, not an int. + self.assertTrue(isinstance(GIMarshallingTests.Flags.VALUE1 | GIMarshallingTests.Flags.VALUE2, + GIMarshallingTests.Flags)) self.assertEquals(1 << 1, GIMarshallingTests.Flags.VALUE2) + def test_value_nick_and_name(self): + self.assertEqual(GIMarshallingTests.Flags.VALUE1.first_value_nick, 'value1') + self.assertEqual(GIMarshallingTests.Flags.VALUE2.first_value_nick, 'value2') + self.assertEqual(GIMarshallingTests.Flags.VALUE3.first_value_nick, 'value3') + + self.assertEqual(GIMarshallingTests.Flags.VALUE1.first_value_name, 'GI_MARSHALLING_TESTS_FLAGS_VALUE1') + self.assertEqual(GIMarshallingTests.Flags.VALUE2.first_value_name, 'GI_MARSHALLING_TESTS_FLAGS_VALUE2') + self.assertEqual(GIMarshallingTests.Flags.VALUE3.first_value_name, 'GI_MARSHALLING_TESTS_FLAGS_VALUE3') + def test_flags_in(self): GIMarshallingTests.flags_in(GIMarshallingTests.Flags.VALUE2) + # result of __or__() operation should still be valid instance, not an int. + GIMarshallingTests.flags_in(GIMarshallingTests.Flags.VALUE2 | GIMarshallingTests.Flags.VALUE2) GIMarshallingTests.flags_in_zero(Number(0)) self.assertRaises(TypeError, GIMarshallingTests.flags_in, 1 << 1) @@ -1037,6 +1076,45 @@ class TestGFlags(unittest.TestCase): self.assertTrue(isinstance(flags, GIMarshallingTests.Flags)) self.assertEquals(flags, GIMarshallingTests.Flags.VALUE1) +class TestNoTypeFlags(unittest.TestCase): + + def test_flags(self): + self.assertTrue(issubclass(GIMarshallingTests.NoTypeFlags, GObject.GFlags)) + self.assertTrue(isinstance(GIMarshallingTests.NoTypeFlags.VALUE1, GIMarshallingTests.NoTypeFlags)) + self.assertTrue(isinstance(GIMarshallingTests.NoTypeFlags.VALUE2, GIMarshallingTests.NoTypeFlags)) + self.assertTrue(isinstance(GIMarshallingTests.NoTypeFlags.VALUE3, GIMarshallingTests.NoTypeFlags)) + # __or__() operation should still return an instance, not an int. + self.assertTrue(isinstance(GIMarshallingTests.NoTypeFlags.VALUE1 | GIMarshallingTests.NoTypeFlags.VALUE2, + GIMarshallingTests.NoTypeFlags)) + self.assertEquals(1 << 1, GIMarshallingTests.NoTypeFlags.VALUE2) + + def test_value_nick_and_name(self): + self.assertEqual(GIMarshallingTests.NoTypeFlags.VALUE1.first_value_nick, 'value1') + self.assertEqual(GIMarshallingTests.NoTypeFlags.VALUE2.first_value_nick, 'value2') + self.assertEqual(GIMarshallingTests.NoTypeFlags.VALUE3.first_value_nick, 'value3') + + self.assertEqual(GIMarshallingTests.NoTypeFlags.VALUE1.first_value_name, 'GI_MARSHALLING_TESTS_NO_TYPE_FLAGS_VALUE1') + self.assertEqual(GIMarshallingTests.NoTypeFlags.VALUE2.first_value_name, 'GI_MARSHALLING_TESTS_NO_TYPE_FLAGS_VALUE2') + self.assertEqual(GIMarshallingTests.NoTypeFlags.VALUE3.first_value_name, 'GI_MARSHALLING_TESTS_NO_TYPE_FLAGS_VALUE3') + + def test_flags_in(self): + GIMarshallingTests.no_type_flags_in(GIMarshallingTests.NoTypeFlags.VALUE2) + GIMarshallingTests.no_type_flags_in(GIMarshallingTests.NoTypeFlags.VALUE2 | GIMarshallingTests.NoTypeFlags.VALUE2) + GIMarshallingTests.no_type_flags_in_zero(Number(0)) + + self.assertRaises(TypeError, GIMarshallingTests.no_type_flags_in, 1 << 1) + self.assertRaises(TypeError, GIMarshallingTests.no_type_flags_in, 'GIMarshallingTests.NoTypeFlags.VALUE2') + + def test_flags_out(self): + flags = GIMarshallingTests.no_type_flags_out() + self.assertTrue(isinstance(flags, GIMarshallingTests.NoTypeFlags)) + self.assertEquals(flags, GIMarshallingTests.NoTypeFlags.VALUE2) + + def test_flags_inout(self): + flags = GIMarshallingTests.no_type_flags_inout(GIMarshallingTests.NoTypeFlags.VALUE2) + self.assertTrue(isinstance(flags, GIMarshallingTests.NoTypeFlags)) + self.assertEquals(flags, GIMarshallingTests.NoTypeFlags.VALUE1) + class TestStructure(unittest.TestCase): @@ -1531,6 +1609,22 @@ class TestInterfaces(unittest.TestCase): GIMarshallingTests.test_interface_test_int8_in(instance, 42) self.assertEquals(instance.val, 42) + def test_mro(self): + # there was a problem with Python bailing out because of + # http://en.wikipedia.org/wiki/Diamond_problem with interfaces, + # which shouldn't really be a problem. + + class TestInterfaceImpl(GObject.GObject, GIMarshallingTests.Interface): + pass + + class TestInterfaceImpl2(GIMarshallingTests.Interface, + TestInterfaceImpl): + pass + + class TestInterfaceImpl3(TestInterfaceImpl, + GIMarshallingTests.Interface2): + pass + class TestInterfaceClash(unittest.TestCase): @@ -1613,3 +1707,12 @@ class TestDir(unittest.TestCase): # in the list: # # self.assertTrue('DoNotImportDummyTests' in list) + +class TestGErrorArrayInCrash(unittest.TestCase): + # Previously there was a bug in invoke, in which C arrays were unwrapped + # from inside GArrays to be passed to the C function. But when a GError was + # set, invoke would attempt to free the C array as if it were a GArray. + # This crash is only for C arrays. It does not happen for C functions which + # take in GArrays. See https://bugzilla.gnome.org/show_bug.cgi?id=642708 + def test_gerror_array_in_crash(self): + self.assertRaises(GObject.GError, GIMarshallingTests.gerror_array_in, [1, 2, 3]) diff --git a/tests/test_gicon.py b/tests/test_gicon.py new file mode 100644 index 0000000..b9af6ff --- /dev/null +++ b/tests/test_gicon.py @@ -0,0 +1,112 @@ +# -*- Mode: Python -*- + +import os +import unittest + +import glib +import gio + + +class TestIcon(unittest.TestCase): + def test_eq(self): + self.assertEquals(gio.FileIcon(gio.File('foo.png')), + gio.FileIcon(gio.File('foo.png'))) + self.assertEquals(gio.ThemedIcon('foo'), + gio.ThemedIcon('foo')) + + self.assertNotEqual(gio.FileIcon(gio.File('foo.png')), + gio.FileIcon(gio.File('bar.png'))) + self.assertNotEquals(gio.ThemedIcon('foo'), + gio.ThemedIcon('bar')) + self.assertNotEquals(gio.FileIcon(gio.File('foo.png')), + gio.ThemedIcon('foo')) + + def test_hash(self): + self.assertEquals(hash(gio.FileIcon(gio.File('foo.png'))), + hash(gio.FileIcon(gio.File('foo.png')))) + self.assertEquals(hash(gio.ThemedIcon('foo')), + hash(gio.ThemedIcon('foo'))) + +class TestLoadableIcon(unittest.TestCase): + def setUp(self): + self.file = open('temp.svg', 'w') + self.svg = ('' + '' + '') + self.file.write(self.svg) + self.file.close() + self.icon = gio.FileIcon(gio.File('temp.svg')) + + def tearDown(self): + if os.path.exists('temp.svg'): + os.unlink('temp.svg') + + def test_load(self): + stream, type = self.icon.load() + try: + self.assert_(isinstance(stream, gio.InputStream)) + self.assertEquals(self.svg, stream.read()) + finally: + stream.close() + + def test_load_async(self): + def callback(icon, result): + try: + stream, type = icon.load_finish(result) + self.assert_(isinstance(stream, gio.InputStream)) + self.assertEquals(self.svg, stream.read()) + finally: + loop.quit() + stream.close() + + self.icon.load_async(callback) + + loop = glib.MainLoop() + loop.run() + +class TestFileIcon(unittest.TestCase): + def test_constructor(self): + file = gio.File('foo.png') + self.assert_(file is gio.FileIcon(file).get_file()) + +class TestThemedIcon(unittest.TestCase): + def setUp(self): + self.icon = gio.ThemedIcon("open") + + def test_constructor(self): + have_use_default_fallbacks = ('use_default_fallbacks' + in gio.ThemedIcon.props.__members__) + icon = gio.ThemedIcon('foo') + self.assertEquals(['foo'], icon.props.names) + self.assert_(not have_use_default_fallbacks + or not icon.props.use_default_fallbacks) + + icon = gio.ThemedIcon(['foo', 'bar', 'baz']) + self.assertEquals(['foo', 'bar', 'baz'], icon.props.names) + self.assert_(not have_use_default_fallbacks + or not icon.props.use_default_fallbacks) + + icon = gio.ThemedIcon('xxx-yyy-zzz', True) + self.assertEquals(['xxx-yyy-zzz', 'xxx-yyy', 'xxx'], icon.props.names) + self.assert_(not have_use_default_fallbacks + or icon.props.use_default_fallbacks) + + def test_constructor_illegals(self): + self.assertRaises(TypeError, lambda: gio.ThemedIcon(42)) + self.assertRaises(TypeError, lambda: gio.ThemedIcon(['foo', 42, 'bar'])) + + def test_get_names(self): + self.assertEquals(self.icon.get_names(), ['open']) + + def test_append_name(self): + self.assertEquals(self.icon.get_names(), ['open']) + self.icon.append_name('close') + self.assertEquals(self.icon.get_names(), ['open', 'close']) + +class TestEmblemedIcon(unittest.TestCase): + def test_emblemed_icon(self): + icon = gio.FileIcon(gio.File('foo.png')) + emblem = gio.Emblem(icon) + emblemed = gio.EmblemedIcon(icon, emblem) + self.assertEquals(emblemed.get_emblems()[0], emblem) diff --git a/tests/test_gio.py b/tests/test_gio.py new file mode 100644 index 0000000..7c8251e --- /dev/null +++ b/tests/test_gio.py @@ -0,0 +1,1138 @@ +# -*- Mode: Python -*- + +import os +import unittest + +import glib +import gio + + +class TestFile(unittest.TestCase): + def setUp(self): + self._f = open("file.txt", "w+") + self.file = gio.File("file.txt") + + def tearDown(self): + self._f.close() + if os.path.exists('file.txt'): + os.unlink("file.txt") + + def testReadAsync(self): + self._f.write("testing") + self._f.seek(0) + + def callback(file, result): + try: + stream = file.read_finish(result) + self.failUnless(isinstance(stream, gio.InputStream)) + self.assertEquals(stream.read(), "testing") + finally: + loop.quit() + + self.file.read_async(callback) + + loop = glib.MainLoop() + loop.run() + + def testAppendToAsync(self): + self._f.write("append_to ") + self._f.close() + + def callback(file, result): + try: + stream = file.append_to_finish(result) + self.failUnless(isinstance(stream, gio.OutputStream)) + w = stream.write("testing") + cont, leng, etag = self.file.load_contents() + self.assertEqual(cont, "append_to testing") + finally: + loop.quit() + + self.file.append_to_async(callback, gio.FILE_CREATE_NONE, + glib.PRIORITY_HIGH) + + loop = glib.MainLoop() + loop.run() + + def testAppendToAsyncNoargs(self): + self._f.write("append_to ") + self._f.close() + + def callback(file, result): + try: + stream = file.append_to_finish(result) + self.failUnless(isinstance(stream, gio.OutputStream)) + w = stream.write("testing") + cont, leng, etag = self.file.load_contents() + self.assertEqual(cont, "append_to testing") + finally: + loop.quit() + + self.file.append_to_async(callback) + + loop = glib.MainLoop() + loop.run() + + def testCreateAsync(self): + def callback(file, result): + try: + stream = file.create_finish(result) + self.failUnless(isinstance(stream, gio.OutputStream)) + w = stream.write("testing") + cont, leng, etag = file.load_contents() + self.assertEqual(cont, "testing") + finally: + if os.path.exists('temp.txt'): + os.unlink("temp.txt") + loop.quit() + + gfile = gio.File("temp.txt") + gfile.create_async(callback, gio.FILE_CREATE_NONE, + glib.PRIORITY_HIGH) + + loop = glib.MainLoop() + loop.run() + + def testCreateReadWriteAsync(self): + def callback(file, result): + try: + iostream = file.create_readwrite_finish(result) + self.failUnless(isinstance(iostream, gio.FileIOStream)) + + ostream = iostream.get_output_stream() + self.failUnless(isinstance(ostream, gio.OutputStream)) + + w = ostream.write("testing") + cont, leng, etag = file.load_contents() + self.assertEqual(cont, "testing") + finally: + if os.path.exists('temp.txt'): + os.unlink("temp.txt") + loop.quit() + + gfile = gio.File("temp.txt") + gfile.create_readwrite_async(callback, gio.FILE_CREATE_NONE, + glib.PRIORITY_HIGH) + + loop = glib.MainLoop() + loop.run() + + def testCreateAsyncNoargs(self): + def callback(file, result): + try: + stream = file.create_finish(result) + self.failUnless(isinstance(stream, gio.OutputStream)) + w = stream.write("testing") + cont, leng, etag = file.load_contents() + self.assertEqual(cont, "testing") + finally: + if os.path.exists('temp.txt'): + os.unlink("temp.txt") + loop.quit() + + gfile = gio.File("temp.txt") + gfile.create_async(callback) + + loop = glib.MainLoop() + loop.run() + + def testReplaceAsync(self): + self._f.write("testing") + self._f.close() + + def callback(file, result): + try: + stream = file.replace_finish(result) + self.failUnless(isinstance(stream, gio.OutputStream)) + stream.write("some new string") + stream.close() + cont, leng, etag = file.load_contents() + self.assertEqual(cont, "some new string") + finally: + loop.quit() + + + self.file.replace_async(callback, None, True, gio.FILE_CREATE_NONE, + glib.PRIORITY_HIGH) + + loop = glib.MainLoop() + loop.run() + + def testReplaceAsyncNoargs(self): + self._f.write("testing") + self._f.close() + + def callback(file, result): + try: + stream = file.replace_finish(result) + self.failUnless(isinstance(stream, gio.OutputStream)) + stream.write("some new string") + stream.close() + cont, leng, etag = file.load_contents() + self.assertEqual(cont, "some new string") + finally: + loop.quit() + + + self.file.replace_async(callback) + + loop = glib.MainLoop() + loop.run() + + def testReadAsyncError(self): + self.assertRaises(TypeError, self.file.read_async) + self.assertRaises(TypeError, self.file.read_async, "foo", "bar") + self.assertRaises(TypeError, self.file.read_async, "foo", + priority="bar") + self.assertRaises(TypeError, self.file.read_async, "foo", + priority="bar") + self.assertRaises(TypeError, self.file.read_async, "foo", + priority=1, cancellable="bar") + self.assertRaises(TypeError, self.file.read_async, "foo", 1, "bar") + + def testConstructor(self): + for gfile in [gio.File("/"), + gio.File("file:///"), + gio.File(uri="file:///"), + gio.File(path="/"), + gio.File(u"/"), + gio.File(path=u"/")]: + self.failUnless(isinstance(gfile, gio.File)) + self.assertEquals(gfile.get_path(), "/") + self.assertEquals(gfile.get_uri(), "file:///") + + def testConstructorError(self): + self.assertRaises(TypeError, gio.File) + self.assertRaises(TypeError, gio.File, 1) + self.assertRaises(TypeError, gio.File, "foo", "bar") + self.assertRaises(TypeError, gio.File, foo="bar") + self.assertRaises(TypeError, gio.File, uri=1) + self.assertRaises(TypeError, gio.File, path=1) + + def testLoadContents(self): + self._f.write("testing load_contents") + self._f.seek(0) + c = gio.Cancellable() + cont, leng, etag = self.file.load_contents(cancellable=c) + self.assertEqual(cont, "testing load_contents") + self.assertEqual(leng, 21) + self.assertNotEqual(etag, '') + + def testLoadContentsAsync(self): + self._f.write("testing load_contents_async") + self._f.seek(0) + + def callback(contents, result): + try: + cont, leng, etag = contents.load_contents_finish(result) + self.assertEqual(cont, "testing load_contents_async") + self.assertEqual(leng, 27) + self.assertNotEqual(etag, '') + finally: + loop.quit() + + canc = gio.Cancellable() + self.file.load_contents_async(callback, cancellable=canc) + + loop = glib.MainLoop() + loop.run() + + def testQueryInfoAsync(self): + def callback(file, result): + try: + info = file.query_info_finish(result) + self.failUnless(isinstance(info, gio.FileInfo)) + self.failUnless(info.get_name(), "file.txt") + finally: + loop.quit() + + self.file.query_info_async("standard", callback) + + loop = glib.MainLoop() + loop.run() + + def testMountMountable(self): + gfile = gio.File('localtest:') + def unmount_done(mount, result): + try: + retval = mount.unmount_finish(result) + self.failUnless(retval) + finally: + loop.quit() + + def mount_enclosing_volume_done(gfile, result): + try: + try: + retval = gfile.mount_enclosing_volume_finish(result) + except gio.Error, e: + # If we run the tests too fast + if e.code == gio.ERROR_ALREADY_MOUNTED: + print ('WARNING: testfile is already mounted, ' + 'skipping test') + loop.quit() + return + raise + self.failUnless(retval) + finally: + try: + mount = gfile.find_enclosing_mount() + except gio.Error: + loop.quit() + return + mount.unmount(unmount_done) + + mount_operation = gio.MountOperation() + gfile.mount_enclosing_volume(mount_operation, + mount_enclosing_volume_done) + + loop = glib.MainLoop() + loop.run() + + def testCopy(self): + if os.path.exists('copy.txt'): + os.unlink("copy.txt") + + source = gio.File('file.txt') + destination = gio.File('copy.txt') + try: + retval = source.copy(destination) + self.failUnless(retval) + + self.failUnless(os.path.exists('copy.txt')) + self.assertEqual(open('file.txt').read(), + open('copy.txt').read()) + finally: + os.unlink("copy.txt") + + self.called = False + def callback(current, total): + self.called = True + source = gio.File('file.txt') + destination = gio.File('copy.txt') + try: + retval = source.copy(destination, callback) + self.failUnless(retval) + + self.failUnless(os.path.exists('copy.txt')) + self.assertEqual(open('file.txt').read(), + open('copy.txt').read()) + self.failUnless(self.called) + finally: + os.unlink("copy.txt") + + def test_copy_async(self): + if os.path.exists('copy.txt'): + os.unlink("copy.txt") + + source = gio.File('file.txt') + destination = gio.File('copy.txt') + + def copied(source_, result): + try: + self.assert_(source_ is source) + self.failUnless(source_.copy_finish(result)) + finally: + loop.quit() + + def progress(current, total): + self.assert_(isinstance(current, long)) + self.assert_(isinstance(total, long)) + self.assert_(0 <= current <= total) + + try: + loop = glib.MainLoop() + source.copy_async(destination, copied, progress_callback = progress) + loop.run() + + self.failUnless(os.path.exists('copy.txt')) + self.assertEqual(open('file.txt').read(), + open('copy.txt').read()) + finally: + os.unlink("copy.txt") + + # See bug 546591. + def test_copy_progress(self): + source = gio.File('file.txt') + destination = gio.File('copy.txt') + + def progress(current, total): + self.assert_(isinstance(current, long)) + self.assert_(isinstance(total, long)) + self.assert_(0 <= current <= total) + + try: + retval = source.copy(destination, + flags=gio.FILE_COPY_OVERWRITE, + progress_callback=progress) + self.failUnless(retval) + + self.failUnless(os.path.exists('copy.txt')) + self.assertEqual(open('file.txt').read(), + open('copy.txt').read()) + finally: + os.unlink("copy.txt") + + def testMove(self): + if os.path.exists('move.txt'): + os.unlink("move.txt") + + source = gio.File('file.txt') + destination = gio.File('move.txt') + retval = source.move(destination) + self.failUnless(retval) + + self.failIf(os.path.exists('file.txt')) + self.failUnless(os.path.exists('move.txt')) + + self.called = False + def callback(current, total): + self.called = True + source = gio.File('move.txt') + destination = gio.File('move-2.txt') + try: + retval = source.move(destination, callback) + self.failUnless(retval) + + self.failIf(os.path.exists('move.txt')) + self.failUnless(os.path.exists('move-2.txt')) + self.failUnless(self.called) + finally: + os.unlink("move-2.txt") + + def testInfoList(self): + infolist = self.file.query_settable_attributes() + for info in infolist: + if info.name == "time::modified": + self.assertEqual(info.type, gio.FILE_ATTRIBUTE_TYPE_UINT64) + self.assertEqual(info.name, "time::modified") + self.assertEqual(info.flags, + gio.FILE_ATTRIBUTE_INFO_COPY_WHEN_MOVED | + gio.FILE_ATTRIBUTE_INFO_COPY_WITH_FILE) + + def testQueryWritableNamespaces(self): + infolist = self.file.query_writable_namespaces() + for info in infolist: + if info.name == "xattr": + self.assertEqual(info.type, gio.FILE_ATTRIBUTE_TYPE_STRING) + + def testSetAttribute(self): + self._f.write("testing attributes") + self._f.seek(0) + infolist = self.file.query_settable_attributes() + + self.assertNotEqual(len(infolist), 0) + + for info in infolist: + if info.name == "time::modified-usec": + ret = self.file.set_attribute("time::modified-usec", + gio.FILE_ATTRIBUTE_TYPE_UINT32, + 10, gio.FILE_QUERY_INFO_NONE) + self.assertEqual(ret, True) + + def testSetAttributesAsync(self): + def callback(gfile, result): + try: + info = gfile.set_attributes_finish(result) + usec = info.get_attribute_uint32("time::modified-usec") + self.assertEqual(usec, 10) + finally: + loop.quit() + + info = gio.FileInfo() + info.set_attribute_uint32("time::modified-usec", 10) + + canc = gio.Cancellable() + self.file.set_attributes_async(info, callback) + + loop = glib.MainLoop() + loop.run() + + def testReplaceContents(self): + self.file.replace_contents("testing replace_contents") + cont, leng, etag = self.file.load_contents() + self.assertEqual(cont, "testing replace_contents") + + caught = False + try: + self.file.replace_contents("this won't work", etag="wrong") + except gio.Error, e: + self.assertEqual(e.code, gio.ERROR_WRONG_ETAG) + caught = True + self.failUnless(caught) + + self.file.replace_contents("testing replace_contents again", etag=etag) + cont, leng, etag = self.file.load_contents() + self.assertEqual(cont, "testing replace_contents again") + + self.file.replace_contents("testing replace_contents yet again", etag=None) + cont, leng, etag = self.file.load_contents() + self.assertEqual(cont, "testing replace_contents yet again") + + def testReplaceContentsAsync(self): + + def callback(contents, result): + try: + newetag = contents.replace_contents_finish(result) + cont, leng, etag = self.file.load_contents() + self.assertEqual(cont, "testing replace_contents_async") + self.assertEqual(leng, 30) + self.assertEqual(etag, newetag) + self.assertNotEqual(newetag, '') + finally: + loop.quit() + + canc = gio.Cancellable() + self.file.replace_contents_async("testing replace_contents_async", callback, cancellable=canc) + + loop = glib.MainLoop() + loop.run() + + def test_eq(self): + self.assertEqual(gio.File('foo'), + gio.File('foo')) + self.assertNotEqual(gio.File('foo'), + gio.File('bar')) + + def test_hash(self): + self.assertEquals(hash(gio.File('foo')), + hash(gio.File('foo'))) + + def testSetDisplayNameAsync(self): + def callback(gfile, result): + try: + new_gfile = gfile.set_display_name_finish(result) + new_name = new_gfile.get_basename() + self.assertEqual(new_name, "new.txt") + deleted = new_gfile.delete() + self.assertEqual(deleted, True) + finally: + loop.quit() + + canc = gio.Cancellable() + self.file.set_display_name_async("new.txt", callback, cancellable=canc) + + loop = glib.MainLoop() + loop.run() + +class TestGFileEnumerator(unittest.TestCase): + def setUp(self): + self.file = gio.File(".") + + def testEnumerateChildren(self): + enumerator = self.file.enumerate_children( + "standard::*", gio.FILE_QUERY_INFO_NOFOLLOW_SYMLINKS) + for file_info in enumerator: + if file_info.get_name() == 'test_gio.py': + break + else: + raise AssertionError + + def testEnumerateChildrenAsync(self): + def callback(gfile, result): + try: + for file_info in gfile.enumerate_children_finish(result): + if file_info.get_name() == 'test_gio.py': + break + else: + raise AssertionError + finally: + loop.quit() + + self.file.enumerate_children_async( + "standard::*", callback) + loop = glib.MainLoop() + loop.run() + + def testNextFilesAsync(self): + def callback(enumerator, result): + try: + for file_info in enumerator.next_files_finish(result): + if file_info.get_name() == 'test_gio.py': + break + else: + raise AssertionError + finally: + loop.quit() + + enumerator = self.file.enumerate_children( + "standard::*", gio.FILE_QUERY_INFO_NOFOLLOW_SYMLINKS) + enumerator.next_files_async(1000, callback) + loop = glib.MainLoop() + loop.run() + + def testCloseFilesAsync(self): + def callback(enumerator, result): + try: + enumerator.close_finish(result) + finally: + loop.quit() + + enumerator = self.file.enumerate_children( + "standard::*", gio.FILE_QUERY_INFO_NOFOLLOW_SYMLINKS) + + enumerator.close_async(callback) + + loop = glib.MainLoop() + loop.run() + + +class TestInputStream(unittest.TestCase): + def setUp(self): + self._f = open("inputstream.txt", "w+") + self._f.write("testing") + self._f.seek(0) + self.stream = gio.unix.InputStream(self._f.fileno(), False) + + def tearDown(self): + self._f.close() + os.unlink("inputstream.txt") + + def testRead(self): + self.assertEquals(self.stream.read(), "testing") + + self.stream = gio.MemoryInputStream() + self.assertEquals(self.stream.read(), '') + + self.stream = gio.MemoryInputStream() + some_data = open("test_gio.py", "rb").read() + self.stream.add_data(some_data) + self.assertEquals(self.stream.read(), some_data) + + stream = gio.MemoryInputStream() + stream.add_data(some_data) + self.assertEquals(self._read_in_loop(stream, + lambda: stream.read(50), + 50), + some_data) + + def testSkip(self): + self.stream.skip(2) + res = self.stream.read() + self.assertEqual(res, "sting") + + def testSkipAsync(self): + def callback(stream, result): + try: + size = stream.skip_finish(result) + self.assertEqual(size, 2) + res = stream.read() + self.assertEqual(res, "sting") + finally: + loop.quit() + + self.stream.skip_async(2, callback) + + loop = glib.MainLoop() + loop.run() + + def test_read_part(self): + self.assertEquals(self._read_in_loop(self.stream, + lambda: self.stream.read_part()), + 'testing') + + stream = gio.MemoryInputStream() + some_data = open('test_gio.py', 'rb').read() + stream.add_data(some_data) + self.assertEquals(self._read_in_loop(stream, + lambda: stream.read_part(50), + 50), + some_data) + + def _read_in_loop(self, stream, reader, size_limit=0): + read_data = '' + while True: + read_part = reader() + if read_part: + read_data += read_part + if size_limit > 0: + self.assert_(len(read_part) <= size_limit, + '%d <= %d' % (len(read_part), size_limit)) + else: + return read_data + + def testReadAsync(self): + def callback(stream, result): + self.assertEquals(result.get_op_res_gssize(), 7) + try: + data = stream.read_finish(result) + self.assertEquals(data, "testing") + stream.close() + finally: + loop.quit() + + self.stream.read_async(7, callback) + + loop = glib.MainLoop() + loop.run() + + def testReadAsyncError(self): + self.count = 0 + def callback(stream, result): + try: + self.count += 1 + if self.count == 1: + return + self.assertRaises(gio.Error, stream.read_finish, result) + finally: + loop.quit() + + self.stream.read_async(10240, callback) + self.stream.read_async(10240, callback) + + loop = glib.MainLoop() + loop.run() + + self.assertEquals(self.count, 2) + + self.assertRaises(TypeError, self.stream.read_async) + self.assertRaises(TypeError, self.stream.read_async, "foo") + self.assertRaises(TypeError, self.stream.read_async, 1024, "bar") + self.assertRaises(TypeError, self.stream.read_async, 1024, + priority="bar") + self.assertRaises(TypeError, self.stream.read_async, 1024, + priority="bar") + self.assertRaises(TypeError, self.stream.read_async, 1024, + priority=1, cancellable="bar") + self.assertRaises(TypeError, self.stream.read_async, 1024, 1, "bar") + + + # FIXME: this makes 'make check' freeze + def _testCloseAsync(self): + def callback(stream, result): + try: + self.failUnless(stream.close_finish(result)) + finally: + loop.quit() + + self.stream.close_async(callback) + + loop = glib.MainLoop() + loop.run() + + +class TestDataInputStream(unittest.TestCase): + def setUp(self): + self.base_stream = gio.MemoryInputStream() + self.data_stream = gio.DataInputStream(self.base_stream) + + def test_read_line(self): + self.base_stream.add_data('foo\nbar\n\nbaz') + self.assertEquals('foo', self.data_stream.read_line()) + self.assertEquals('bar', self.data_stream.read_line()) + self.assertEquals('', self.data_stream.read_line()) + self.assertEquals('baz', self.data_stream.read_line()) + + def test_read_line_async(self): + def do_read_line_async(): + loop = glib.MainLoop() + line = [] + + def callback(stream, result): + try: + line.append(stream.read_line_finish(result)) + finally: + loop.quit() + + self.data_stream.read_line_async(callback) + loop.run() + return line[0] + + self.base_stream.add_data('foo\nbar\n\nbaz') + self.assertEquals('foo', do_read_line_async()) + self.assertEquals('bar', do_read_line_async()) + self.assertEquals('', do_read_line_async()) + self.assertEquals('baz', do_read_line_async()) + + def test_read_until(self): + self.base_stream.add_data('sentence.end of line\nthe rest') + self.assertEquals('sentence', self.data_stream.read_until('.!?')) + self.assertEquals('end of line', self.data_stream.read_until('\n\r')) + self.assertEquals('the rest', self.data_stream.read_until('#$%^&')) + + def test_read_until_async(self): + def do_read_until_async(stop_chars): + loop = glib.MainLoop() + data = [] + + def callback(stream, result): + try: + data.append(stream.read_until_finish(result)) + finally: + loop.quit() + + self.data_stream.read_until_async(stop_chars, callback) + loop.run() + return data[0] + + # Note the weird difference between synchronous and + # asynchronous version. See bug #584284. + self.base_stream.add_data('sentence.end of line\nthe rest') + self.assertEquals('sentence', do_read_until_async('.!?')) + self.assertEquals('.end of line', do_read_until_async('\n\r')) + self.assertEquals('\nthe rest', do_read_until_async('#$%^&')) + + +class TestMemoryInputStream(unittest.TestCase): + def setUp(self): + self.stream = gio.MemoryInputStream() + + def test_add_data(self): + self.stream.add_data('foobar') + self.assertEquals('foobar', self.stream.read()) + + self.stream.add_data('ham ') + self.stream.add_data(None) + self.stream.add_data('spam') + self.assertEquals('ham spam', self.stream.read()) + + def test_new_from_data(self): + stream = gio.memory_input_stream_new_from_data('spam') + self.assertEquals('spam', stream.read()) + + +class TestOutputStream(unittest.TestCase): + def setUp(self): + self._f = open("outputstream.txt", "w") + self.stream = gio.unix.OutputStream(self._f.fileno(), False) + + def tearDown(self): + self._f.close() + os.unlink("outputstream.txt") + + def testWrite(self): + self.stream.write("testing") + self.stream.close() + self.failUnless(os.path.exists("outputstream.txt")) + self.assertEquals(open("outputstream.txt").read(), "testing") + + def test_write_part(self): + stream = gio.MemoryOutputStream() + some_data = open('test_gio.py', 'rb').read() + buffer = some_data + + # In fact this makes only one looping (memory stream is fast, + # write_part behaves just like write), but let's still be + # complete. + while buffer: + written = stream.write_part(buffer) + if written == len(buffer): + break + else: + buffer = buffer[written:] + + self.assertEquals(stream.get_contents(), some_data) + + def testWriteAsync(self): + def callback(stream, result): + self.assertEquals(result.get_op_res_gssize(), 7) + try: + self.assertEquals(stream.write_finish(result), 7) + self.failUnless(os.path.exists("outputstream.txt")) + self.assertEquals(open("outputstream.txt").read(), "testing") + finally: + loop.quit() + + self.stream.write_async("testing", callback) + + loop = glib.MainLoop() + loop.run() + + def testWriteAsyncError(self): + def callback(stream, result): + self.assertEquals(result.get_op_res_gssize(), 0) + try: + self.assertRaises(gio.Error, stream.write_finish, result) + finally: + loop.quit() + + self.stream.close() + self.stream.write_async("testing", callback) + + loop = glib.MainLoop() + loop.run() + + self.assertRaises(TypeError, self.stream.write_async) + self.assertRaises(TypeError, self.stream.write_async, 1138) + self.assertRaises(TypeError, self.stream.write_async, "foo", "bar") + self.assertRaises(TypeError, self.stream.write_async, "foo", + priority="bar") + self.assertRaises(TypeError, self.stream.write_async, "foo", + priority="bar") + self.assertRaises(TypeError, self.stream.write_async, "foo", + priority=1, cancellable="bar") + self.assertRaises(TypeError, self.stream.write_async, "foo", 1, "bar") + + # FIXME: this makes 'make check' freeze + def _testCloseAsync(self): + def callback(stream, result): + try: + self.failUnless(stream.close_finish(result)) + finally: + loop.quit() + + self.stream.close_async(callback) + + loop = glib.MainLoop() + loop.run() + + def testFlushAsync(self): + def callback(stream, result): + try: + self.failUnless(stream.flush_finish(result)) + finally: + loop.quit() + + self.stream.flush_async(callback) + + loop = glib.MainLoop() + loop.run() + + def testSpliceAsync(self): + _f = open("stream.txt", "w+") + _f.write("testing") + _f.seek(0) + instream = gio.unix.InputStream(_f.fileno(), False) + + def callback(stream, result): + try: + size = stream.splice_finish(result) + self.assertEqual(size, 7) + + finally: + os.unlink("stream.txt") + loop.quit() + + self.stream.splice_async(instream, callback) + + loop = glib.MainLoop() + loop.run() + +class TestMemoryOutputStream(unittest.TestCase): + def setUp(self): + self.stream = gio.MemoryOutputStream() + + def test_get_contents(self): + self.stream.write('foobar') + self.assertEquals('foobar', self.stream.get_contents()) + + self.stream.write('baz') + self.assertEquals('foobarbaz', self.stream.get_contents()) + + +class TestVolumeMonitor(unittest.TestCase): + def setUp(self): + self.monitor = gio.volume_monitor_get() + + def testGetConnectedDrives(self): + drives = self.monitor.get_connected_drives() + self.failUnless(isinstance(drives, list)) + + def testGetVolumes(self): + volumes = self.monitor.get_volumes() + self.failUnless(isinstance(volumes, list)) + + def testGetMounts(self): + mounts = self.monitor.get_mounts() + self.failUnless(isinstance(mounts, list)) + if not mounts: + return + + self.failUnless(isinstance(mounts[0], gio.Mount)) + # Bug 538601 + icon = mounts[0].get_icon() + if not icon: + return + self.failUnless(isinstance(icon, gio.Icon)) + + +class TestContentTypeGuess(unittest.TestCase): + def testFromName(self): + mime_type = gio.content_type_guess('diagram.svg') + self.assertEquals('image/svg+xml', mime_type) + + def testFromContents(self): + mime_type = gio.content_type_guess(data='') + self.assertEquals('text/html', mime_type) + + def testFromContentsUncertain(self): + mime_type, result_uncertain = gio.content_type_guess( + data='', want_uncertain=True) + self.assertEquals('text/html', mime_type) + self.assertEquals(bool, type(result_uncertain)) + + +class TestFileInfo(unittest.TestCase): + def setUp(self): + self.fileinfo = gio.File("test_gio.py").query_info("*") + + def testListAttributes(self): + attributes = self.fileinfo.list_attributes("standard") + self.failUnless(attributes) + self.failUnless('standard::name' in attributes) + + def testGetModificationTime(self): + mtime = self.fileinfo.get_modification_time() + self.assertEqual(type(mtime), float) + + def testSetModificationTime(self): + self.fileinfo.set_modification_time(1000) + mtime = self.fileinfo.get_modification_time() + self.assertEqual(mtime, 1000) + + +class TestAppInfo(unittest.TestCase): + def setUp(self): + self.appinfo = gio.AppInfo("does-not-exist") + + def testSimple(self): + self.assertEquals(self.appinfo.get_description(), + "Custom definition for does-not-exist") + + def test_eq(self): + info1 = gio.app_info_get_all()[0] + info2 = info1.dup() + self.assert_(info1 is not info2) + self.assertEquals(info1, info2) + + self.assertNotEqual(gio.app_info_get_all()[0], gio.app_info_get_all()[1]) + +class TestVfs(unittest.TestCase): + def setUp(self): + self.vfs = gio.vfs_get_default() + + def testGetSupportedURISchemes(self): + result = self.vfs.get_supported_uri_schemes() + self.failUnless(type(result), []) + +class TestVolume(unittest.TestCase): + def setUp(self): + self.monitor = gio.volume_monitor_get() + + def testVolumeEnumerate(self): + volumes = self.monitor.get_volumes() + self.failUnless(isinstance(volumes, list)) + for v in volumes: + if v is not None: + ids = v.enumerate_identifiers() + self.failUnless(isinstance(ids, list)) + for id in ids: + if id is not None: + self.failUnless(isinstance(id, str)) + +class TestFileInputStream(unittest.TestCase): + def setUp(self): + self._f = open("file.txt", "w+") + self._f.write("testing") + self._f.seek(0) + self.file = gio.File("file.txt") + + def tearDown(self): + self._f.close() + if os.path.exists('file.txt'): + os.unlink("file.txt") + + def testQueryInfoAsync(self): + def callback(stream, result): + try: + info = stream.query_info_finish(result) + self.failUnless(isinstance(info, gio.FileInfo)) + self.failUnless(info.get_attribute_uint64("standard::size"), 7) + finally: + loop.quit() + + inputstream = self.file.read() + inputstream.query_info_async("standard", callback) + + loop = glib.MainLoop() + loop.run() + +class TestFileOutputStream(unittest.TestCase): + def setUp(self): + self._f = open("file.txt", "w+") + self._f.write("testing") + self._f.seek(0) + self.file = gio.File("file.txt") + + def tearDown(self): + self._f.close() + if os.path.exists('file.txt'): + os.unlink("file.txt") + + def testQueryInfoAsync(self): + def callback(stream, result): + try: + info = stream.query_info_finish(result) + self.failUnless(isinstance(info, gio.FileInfo)) + self.failUnless(info.get_attribute_uint64("standard::size"), 7) + finally: + loop.quit() + + outputstream = self.file.append_to() + outputstream.query_info_async("standard", callback) + + loop = glib.MainLoop() + loop.run() + +class TestBufferedInputStream(unittest.TestCase): + def setUp(self): + self._f = open("buffer.txt", "w+") + self._f.write("testing") + self._f.seek(0) + stream = gio.unix.InputStream(self._f.fileno(), False) + self.buffered = gio.BufferedInputStream(stream) + + def tearDown(self): + self._f.close() + os.unlink("buffer.txt") + + def test_fill_async(self): + def callback(stream, result): + try: + size = stream.fill_finish(result) + self.failUnlessEqual(size, 4) + finally: + loop.quit() + + self.buffered.fill_async(4, callback) + + loop = glib.MainLoop() + loop.run() + +class TestIOStream(unittest.TestCase): + def setUp(self): + self.file = gio.File("file.txt") + self.iofile = self.file.create_readwrite(gio.FILE_CREATE_NONE) + + def tearDown(self): + if os.path.exists('file.txt'): + os.unlink("file.txt") + + def testIOStreamCloseAsync(self): + def callback(stream, result): + try: + self.failUnless(stream.close_finish(result)) + finally: + loop.quit() + + self.iofile.close_async(callback) + + loop = glib.MainLoop() + loop.run() + + + def testQueryInfoAsync(self): + def callback(stream, result): + try: + info = stream.query_info_finish(result) + self.failUnless(isinstance(info, gio.FileInfo)) + self.failUnless(info.get_attribute_uint64("standard::size"), 7) + finally: + loop.quit() + + ostream = self.iofile.get_output_stream() + ostream.write("testing") + + self.iofile.query_info_async("standard", callback) + + loop = glib.MainLoop() + loop.run() diff --git a/tests/test_gresolver.py b/tests/test_gresolver.py new file mode 100644 index 0000000..4238df7 --- /dev/null +++ b/tests/test_gresolver.py @@ -0,0 +1,68 @@ +# -*- Mode: Python -*- + +import unittest + +import glib +import gio + + +class TestResolver(unittest.TestCase): + def setUp(self): + self.resolver = gio.resolver_get_default() + + def test_resolver_lookup_by_name(self): + addresses = self.resolver.lookup_by_name("pygtk.org", cancellable=None) + self.failUnless(isinstance(addresses[0], gio.InetAddress)) + + def test_resolver_lookup_by_address(self): + address = gio.inet_address_new_from_string("8.8.8.8") + dns = self.resolver.lookup_by_address(address, cancellable=None) + self.failUnlessEqual(dns, "google-public-dns-a.google.com") + + def test_resolver_lookup_by_name_async(self): + def callback(resolver, result): + try: + addresses = resolver.lookup_by_name_finish(result) + self.failUnless(isinstance(addresses[0], gio.InetAddress)) + finally: + loop.quit() + + self.resolver.lookup_by_name_async(callback, "pygtk.org") + + loop = glib.MainLoop() + loop.run() + + def test_resolver_lookup_by_address_async(self): + def callback(resolver, result): + try: + dns = resolver.lookup_by_address_finish(result) + self.failUnlessEqual(dns, "google-public-dns-b.google.com") + finally: + loop.quit() + + address = gio.inet_address_new_from_string("8.8.4.4") + self.resolver.lookup_by_address_async(callback, address) + + loop = glib.MainLoop() + loop.run() + +""" Commented out because this requires an active internet connection and a + router that supports SRV lookups + + def test_resolver_lookup_service(self): + targets = self.resolver.lookup_service("xmpp-client", "tcp", "google.com") + self.failUnless(isinstance(targets[0], gio.SrvTarget)) + + def test_resolver_lookup_service_async(self): + def callback(resolver, result): + try: + targets = resolver.lookup_service_finish(result) + self.failUnless(isinstance(targets[0], gio.SrvTarget)) + finally: + loop.quit() + + self.resolver.lookup_service_async(callback, "xmpp-client", "tcp", "google.com") + + loop = glib.MainLoop() + loop.run() +""" diff --git a/tests/test_gsocket.py b/tests/test_gsocket.py new file mode 100644 index 0000000..627f6fd --- /dev/null +++ b/tests/test_gsocket.py @@ -0,0 +1,126 @@ +# -*- Mode: Python -*- + +import os +import unittest + +import glib +import gobject +import gio + + +class TestSocket(unittest.TestCase): + def setUp(self): + self.sock = gio.Socket(gio.SOCKET_FAMILY_IPV4, + gio.SOCKET_TYPE_STREAM, + gio.SOCKET_PROTOCOL_TCP) + + def test_socket_condition_check(self): + check = self.sock.condition_check(glib.IO_OUT) + self.failUnless(isinstance(check, gobject.GFlags)) + self.failUnlessEqual(check, glib.IO_OUT | glib.IO_HUP) + + def test_socket_condition_wait(self): + res = self.sock.condition_wait(glib.IO_OUT) + self.failUnless(res) + + def tearDown(self): + self.sock.close() + +class TestSocketAddress(unittest.TestCase): + def test_socket_address_enumerator_next_async(self): + def callback(enumerator, result): + try: + address = enumerator.next_finish(result) + self.failUnless(isinstance(address, gio.SocketAddress)) + finally: + loop.quit() + + socket = gio.NetworkAddress("www.pygtk.org", 80) + enumerator = socket.enumerate() + enumerator.next_async(callback) + + loop = glib.MainLoop() + loop.run() + +class TestSocketListener(unittest.TestCase): + def test_socket_listener_add_address(self): + address = gio.inet_address_new_from_string("127.0.0.1") + inetsock = gio.InetSocketAddress(address, 1024) + + listener = gio.SocketListener() + effective = listener.add_address(inetsock, gio.SOCKET_TYPE_STREAM, gio.SOCKET_PROTOCOL_TCP) + self.failUnless(isinstance(effective, gio.InetSocketAddress)) + + def test_socket_listener_accept(self): + address = gio.inet_address_new_from_string("127.0.0.1") + inetsock = gio.InetSocketAddress(address, 1024) + + listener = gio.SocketListener() + listener.add_address(inetsock, gio.SOCKET_TYPE_STREAM, gio.SOCKET_PROTOCOL_TCP) + + client = gio.SocketClient() + client.connect_to_host("127.0.0.1:1024", 1024) + + connection, source = listener.accept(cancellable=None) + self.failUnless(isinstance(connection, gio.TcpConnection)) + + def test_socket_listener_accept_socket(self): + address = gio.inet_address_new_from_string("127.0.0.1") + inetsock = gio.InetSocketAddress(address, 1024) + + listener = gio.SocketListener() + listener.add_address(inetsock, gio.SOCKET_TYPE_STREAM, gio.SOCKET_PROTOCOL_TCP) + + client = gio.SocketClient() + client.connect_to_host("127.0.0.1:1024", 1024) + + socket, source = listener.accept_socket(cancellable=None) + self.failUnless(isinstance(socket, gio.Socket)) + + def test_socket_listener_accept_async(self): + def callback(listener, result): + try: + connection, source = listener.accept_finish(result) + self.failUnless(isinstance(connection, gio.TcpConnection)) + finally: + loop.quit() + + address = gio.inet_address_new_from_string("127.0.0.1") + inetsock = gio.InetSocketAddress(address, 1024) + + listener = gio.SocketListener() + listener.add_address(inetsock, + gio.SOCKET_TYPE_STREAM, + gio.SOCKET_PROTOCOL_TCP) + + client = gio.SocketClient() + client.connect_to_host("127.0.0.1:1024", 1024) + + listener.accept_async(callback) + + loop = glib.MainLoop() + loop.run() + + def test_socket_listener_accept_socket_async(self): + def callback(listener, result): + try: + socket, source = listener.accept_socket_finish(result) + self.failUnless(isinstance(socket, gio.Socket)) + finally: + loop.quit() + + address = gio.inet_address_new_from_string("127.0.0.1") + inetsock = gio.InetSocketAddress(address, 1024) + + listener = gio.SocketListener() + listener.add_address(inetsock, + gio.SOCKET_TYPE_STREAM, + gio.SOCKET_PROTOCOL_TCP) + + client = gio.SocketClient() + client.connect_to_host("127.0.0.1:1024", 1024) + + listener.accept_socket_async(callback) + + loop = glib.MainLoop() + loop.run() diff --git a/tests/test_overrides.py b/tests/test_overrides.py index 766beaf..e2333b1 100644 --- a/tests/test_overrides.py +++ b/tests/test_overrides.py @@ -359,6 +359,51 @@ class TestGdk(unittest.TestCase): event.type = Gdk.EventType.SCROLL self.assertRaises(AttributeError, lambda: getattr(event, 'foo_bar')) + def test_event_structures(self): + def button_press_cb(button, event): + self.assertTrue(isinstance(event, Gdk.EventButton)) + self.assertTrue(event.type == Gdk.EventType.BUTTON_PRESS) + self.assertEquals(event.send_event, 0) + self.assertEquals(event.get_state(), Gdk.ModifierType.CONTROL_MASK) + self.assertEquals(event.get_root_coords(), (2, 5)) + + event.time = 12345 + self.assertEquals(event.get_time(), 12345) + + w = Gtk.Window() + b = Gtk.Button() + b.connect('button-press-event', button_press_cb) + w.add(b) + w.show_all() + Gdk.test_simulate_button(b.get_window(), + 2, 5, + 0, + Gdk.ModifierType.CONTROL_MASK, + Gdk.EventType.BUTTON_PRESS) + + def test_cursor(self): + self.assertEquals(Gdk.Cursor, overrides.Gdk.Cursor) + c = Gdk.Cursor(Gdk.CursorType.WATCH) + self.assertNotEqual(c, None) + c = Gdk.Cursor(cursor_type = Gdk.CursorType.WATCH) + self.assertNotEqual(c, None) + + display_manager = Gdk.DisplayManager.get() + display = display_manager.get_default_display() + + test_pixbuf = GdkPixbuf.Pixbuf.new(GdkPixbuf.Colorspace.RGB, + False, + 8, + 5, + 10) + + c = Gdk.Cursor(display, + test_pixbuf, + y=0, x=0) + + self.assertNotEqual(c, None) + self.assertRaises(ValueError, Gdk.Cursor, 1, 2, 3) + class TestGtk(unittest.TestCase): def test_container(self): @@ -632,7 +677,20 @@ class TestGtk(unittest.TestCase): test_pyobj = TestPyObject() test_pydict = {1:1, "2":2, "3":"3"} test_pylist = [1,"2", "3"] - tree_store = Gtk.TreeStore(int, 'gchararray', TestGtk.TestClass, object, object, object) + tree_store = Gtk.TreeStore(int, + 'gchararray', + TestGtk.TestClass, + object, + object, + object, + bool, + bool, + GObject.TYPE_UINT, + GObject.TYPE_ULONG, + GObject.TYPE_INT64, + GObject.TYPE_UINT64, + GObject.TYPE_UCHAR, + GObject.TYPE_CHAR) parent = None for i in range(100): @@ -643,7 +701,16 @@ class TestGtk(unittest.TestCase): testobj, test_pyobj, test_pydict, - test_pylist)) + test_pylist, + i % 2, + bool(i % 2), + i, + sys.maxint + 1, + -9223372036854775808, + 0xffffffffffffffff, + 254, + 'a' + )) # len gets the number of children in the root node # since we kept appending to the previous node @@ -656,9 +723,6 @@ class TestGtk(unittest.TestCase): treeiter = tree_store.iter_children(parent) while treeiter: - i = tree_store.get_value(treeiter, 0) - s = tree_store.get_value(treeiter, 1) - obj = tree_store.get_value(treeiter, 2) i = tree_store.get_value(treeiter, 0) s = tree_store.get_value(treeiter, 1) obj = tree_store.get_value(treeiter, 2) @@ -671,6 +735,25 @@ class TestGtk(unittest.TestCase): pylist = tree_store.get_value(treeiter, 5) self.assertEquals(pylist, test_pylist) + bool_1 = tree_store.get_value(treeiter, 6) + bool_2 = tree_store.get_value(treeiter, 7) + self.assertEquals(bool_1, bool_2) + self.assertTrue(isinstance(bool_1, bool)) + self.assertTrue(isinstance(bool_2, bool)) + + uint_ = tree_store.get_value(treeiter, 8) + self.assertEquals(uint_, i) + ulong_ = tree_store.get_value(treeiter, 9) + self.assertEquals(ulong_, sys.maxint + 1) + int64_ = tree_store.get_value(treeiter, 10) + self.assertEquals(int64_, -9223372036854775808) + uint64_ = tree_store.get_value(treeiter, 11) + self.assertEquals(uint64_, 0xffffffffffffffff) + uchar_ = tree_store.get_value(treeiter, 12) + self.assertEquals(ord(uchar_), 254) + char_ = tree_store.get_value(treeiter, 13) + self.assertEquals(char_, 'a') + parent = treeiter treeiter = tree_store.iter_children(parent) @@ -684,7 +767,7 @@ class TestGtk(unittest.TestCase): test_pydict = {1:1, "2":2, "3":"3"} test_pylist = [1,"2", "3"] - list_store = Gtk.ListStore(int, str, 'GIOverrideTreeAPITest', object, object, object) + list_store = Gtk.ListStore(int, str, 'GIOverrideTreeAPITest', object, object, object, bool, bool) for i in range(93): label = 'this is row #%d' % i testobj = TestGtk.TestClass(self, i, label) @@ -693,7 +776,9 @@ class TestGtk(unittest.TestCase): testobj, test_pyobj, test_pydict, - test_pylist)) + test_pylist, + i % 2, + bool(i % 2))) i = 93 label = _unicode('this is row #93') @@ -704,6 +789,8 @@ class TestGtk(unittest.TestCase): list_store.set_value(treeiter, 3, test_pyobj) list_store.set_value(treeiter, 4, test_pydict) list_store.set_value(treeiter, 5, test_pylist) + list_store.set_value(treeiter, 6, 1) + list_store.set_value(treeiter, 7, True) # test automatic unicode->str conversion i = 94 @@ -713,17 +800,29 @@ class TestGtk(unittest.TestCase): TestGtk.TestClass(self, i, label), test_pyobj, test_pydict, - test_pylist)) + test_pylist, + 0, + False)) # add sorted items out of order to test insert* apis + # also test sending in None to not set a column i = 97 label = 'this is row #97' - treeiter = list_store.append((i, - label, - TestGtk.TestClass(self, i, label), + treeiter = list_store.append((None, + None, + None, test_pyobj, - test_pydict, - test_pylist)) + None, + test_pylist, + 1, + None)) + + list_store.set_value(treeiter, 0, i) + list_store.set_value(treeiter, 1, label) + list_store.set_value(treeiter, 2, TestGtk.TestClass(self, i, label)) + list_store.set_value(treeiter, 4, test_pydict) + list_store.set_value(treeiter, 7, True) + # this should append i = 99 label = 'this is row #99' @@ -732,7 +831,9 @@ class TestGtk(unittest.TestCase): TestGtk.TestClass(self, i, label), test_pyobj, test_pydict, - test_pylist)) + test_pylist, + 1, + True)) i = 96 label = 'this is row #96' @@ -741,7 +842,9 @@ class TestGtk(unittest.TestCase): TestGtk.TestClass(self, i, label), test_pyobj, test_pydict, - test_pylist)) + test_pylist, + 0, + False)) i = 98 label = 'this is row #98' @@ -750,7 +853,9 @@ class TestGtk(unittest.TestCase): TestGtk.TestClass(self, i, label), test_pyobj, test_pydict, - test_pylist)) + test_pylist, + 0, + False)) i = 95 @@ -760,7 +865,9 @@ class TestGtk(unittest.TestCase): TestGtk.TestClass(self, i, label), test_pyobj, test_pydict, - test_pylist)) + test_pylist, + 1, + True)) self.assertEquals(len(list_store), 100) @@ -782,6 +889,13 @@ class TestGtk(unittest.TestCase): self.assertEquals(pydict, test_pydict) pylist = list_store.get_value(treeiter, 5) self.assertEquals(pylist, test_pylist) + + bool_1 = list_store.get_value(treeiter, 6) + bool_2 = list_store.get_value(treeiter, 7) + self.assertEquals(bool_1, bool_2) + self.assertTrue(isinstance(bool_1, bool)) + self.assertTrue(isinstance(bool_2, bool)) + treeiter = list_store.iter_next(treeiter) counter += 1 @@ -1180,6 +1294,14 @@ class TestGtk(unittest.TestCase): self.assertEquals(table.get_size(), (2,3)) self.assertEquals(table.get_homogeneous(), True) + # Test PyGTK interface + table = Gtk.Table(rows=3, columns=2) + self.assertEquals(table.get_size(), (3,2)) + # Test using the actual property names + table = Gtk.Table(n_rows=2, n_columns=3, homogeneous=True) + self.assertEquals(table.get_size(), (2,3)) + self.assertEquals(table.get_homogeneous(), True) + label = Gtk.Label('Hello') table.attach(label, 0, 1, 0, 1) self.assertEquals(label, table.get_children()[0])