Commit 17cb714c authored by John (J5) Palmieri's avatar John (J5) Palmieri
Browse files

Merge branch 'master' into invoke-rewrite

Conflicts:
	gi/Makefile.am
	gi/pygi-argument.c
	gi/pygi-foreign-cairo.c
	gi/pygi-foreign-gvariant.c
	gi/pygi-foreign-gvariant.h
	gi/pygi-foreign.c
	gi/pygi-foreign.h
	gi/pygi-private.h
	gi/pygi.h
parents 7332a1b9 01596a9b
# Autotools-generated files.
aclocal.m4
autom4te.cache
compile
config.guess
config.h.in
config.lt
config.sub
configure
depcomp
install-sh
ltmain.sh
m4
Makefile.in
missing
py-compile
# Configuration-generated files.
config.h
config.log
config.status
libtool
Makefile
PKG-INFO
stamp-h1
# Build-generated files.
*.la
*.lo
*.o
*.pc
*.pyc
*.so
.deps
.libs
build
dist
# Other generated files.
*~
*.orig
# Eclipse files.
.settings
.project
.pydevproject
ACLOCAL_AMFLAGS = -I m4
AUTOMAKE_OPTIONS = 1.7
SUBDIRS = docs codegen glib gobject gio examples
SUBDIRS = docs codegen glib gobject examples
if ENABLE_INTROSPECTION
SUBDIRS += gi
......@@ -27,6 +27,33 @@ EXTRA_DIST = \
m4/jhflags.m4 \
m4/python.m4
MAINTAINERCLEANFILES = \
$(srcdir)/INSTALL \
$(srcdir)/aclocal.m4 \
$(srcdir)/autoscan.log \
$(srcdir)/compile \
$(srcdir)/config.guess \
$(srcdir)/config.h.in \
$(srcdir)/config.sub \
$(srcdir)/configure.scan \
$(srcdir)/depcomp \
$(srcdir)/install-sh \
$(srcdir)/ltmain.sh \
$(srcdir)/missing \
$(srcdir)/mkinstalldirs \
$(srcdir)/omf.make \
$(srcdir)/xmldocs.make \
$(srcdir)/gtk-doc.make \
$(srcdir)/ChangeLog \
$(srcdir)/py-compile \
$(srcdir)/m4/libtool.m4 \
$(srcdir)/m4/ltoptions.m4 \
$(srcdir)/m4/ltsugar.m4 \
$(srcdir)/m4/ltversion.m4 \
$(srcdir)/m4/lt~obsolete.m4 \
`find "$(srcdir)" -type f -name Makefile.in -print` \
`find "$(srcdir)" -type f -name "*.pyc" -print`
BUILT_EXTRA_DIST = \
ChangeLog
......@@ -131,3 +158,5 @@ check.gdb:
check.valgrind:
cd tests && $(MAKE) check.valgrind
-include $(top_srcdir)/git.mk
This diff is collapsed.
......@@ -9,7 +9,7 @@ Maintainer: Johan Dahlin
Maintainer-email: johan@gnome.org
License: GNU LGPL
Download-url: ftp://ftp.gnome.org/pub/GNOME/sources/pygobject/@PYGOBJECT_MAJOR_VERSION@.@PYGOBJECT_MINOR_VERSION@/pygobject-@VERSION@.tar.gz
Description: Python bindings for GLib, GObject and GIO
Description: Python bindings for GLib and GObject
Platform: POSIX, Windows
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Linux
......
......@@ -8,7 +8,7 @@ Current maintainers: Gustavo J A M Carneiro <gjc@gnome.org>
Gian Mario Tagliaretti <gianmt@gnome.org>
Tomeu Vizoso <tomeu.vizoso@collabora.co.uk>
This archive contains bindings for the GLib, GObject and GIO,
This archive contains bindings for the GLib, and GObject,
to be used in Python. It is a fairly complete set of bindings,
it's already rather useful, and is usable to write moderately
complex programs. (see the examples directory for some examples
......@@ -45,7 +45,6 @@ Requirements
* Python 2.3.5 or higher
* Glib 2.22.4 or higher
* GIO 2.22.4 or higher
* GIO-unix 2.22.4 or higher
* libffi (optional)
Copyright Information
......
......@@ -22,6 +22,9 @@ if libtoolize --version < /dev/null > /dev/null 2>&1 ; then
2.2*)
have_libtool=true
;;
2.4*)
have_libtool=true
;;
esac
fi
if $have_libtool ; then : ; else
......
# Configuration-generated files.
pygobject-codegen-2.0
......@@ -29,3 +29,5 @@ codegen_PYTHON = \
reversewrapper.py
EXTRA_DIST = $(codegen_SCRIPTS) README.defs pygobject-codegen-$(PLATFORM_VERSION).in
-include $(top_srcdir)/git.mk
......@@ -79,14 +79,14 @@ class ArgType:
def write_param(self, ptype, pname, pdflt, pnull, info):
"""Add code to the WrapperInfo instance to handle
parameter."""
raise RuntimeError, "write_param not implemented for %s" % \
self.__class__.__name__
raise RuntimeError("write_param not implemented for %s"
% self.__class__.__name__)
def write_return(self, ptype, ownsreturn, info):
"""Adds a variable named ret of the return type to
info.varlist, and add any required code to info.codeafter to
convert the return value to a python object."""
raise RuntimeError, "write_return not implemented for %s" % \
self.__class__.__name__
raise RuntimeError("write_return not implemented for %s"
% self.__class__.__name__)
class NoneArg(ArgType):
def write_return(self, ptype, ownsreturn, info):
......
......@@ -71,15 +71,15 @@ class Definition(object):
def __init__(self, *args):
"""Create a new defs object of this type. The arguments are the
components of the definition"""
raise RuntimeError, "this is an abstract class"
raise RuntimeError("this is an abstract class")
def merge(self, old):
"""Merge in customisations from older version of definition"""
raise RuntimeError, "this is an abstract class"
raise RuntimeError("this is an abstract class")
def write_defs(self, fp=sys.stdout):
"""write out this definition in defs file format"""
raise RuntimeError, "this is an abstract class"
raise RuntimeError("this is an abstract class")
def guess_return_value_ownership(self):
"return 1 if caller owns return value"
......@@ -407,7 +407,7 @@ class MethodDef(MethodDefBase):
for item in ('c_name', 'of_object'):
if self.__dict__[item] == None:
self.write_defs(sys.stderr)
raise RuntimeError, "definition missing required %s" % (item,)
raise RuntimeError("definition missing required %s" % (item,))
def write_defs(self, fp=sys.stdout):
fp.write('(define-method ' + self.name + '\n')
......@@ -491,7 +491,7 @@ class FunctionDef(Definition):
for item in ('c_name',):
if self.__dict__[item] == None:
self.write_defs(sys.stderr)
raise RuntimeError, "definition missing required %s" % (item,)
raise RuntimeError("definition missing required %s" % (item,))
_method_write_defs = MethodDef.__dict__['write_defs']
......@@ -513,8 +513,8 @@ class FunctionDef(Definition):
else:
param.merge(old_param)
return param
raise RuntimeError, "could not find %s in old_parameters %r" % (
param.pname, [p.pname for p in old.params])
raise RuntimeError("could not find %s in old_parameters %r" % (
param.pname, [p.pname for p in old.params]))
try:
self.params = map(merge_param, self.params)
except RuntimeError:
......
......@@ -11,16 +11,15 @@ 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, 0)
m4_define(pygobject_minor_version, 90)
m4_define(pygobject_micro_version, 1)
m4_define(pygobject_version, pygobject_major_version.pygobject_minor_version.pygobject_micro_version)
dnl versions of packages we require ...
m4_define(introspection_required_version, 0.9.5)
m4_define(pycairo_required_version, 1.0.2)
m4_define(glib_required_version, 2.22.4)
m4_define(gio_required_version, 2.22.4)
m4_define(giounix_required_version, 2.22.4)
m4_define(introspection_required_version, 0.10.2)
m4_define(pycairo_required_version, 1.2.0)
m4_define(glib_required_version, 2.24.0)
m4_define(gio_required_version, 2.24.0)
AC_INIT(pygobject, pygobject_version,
[http://bugzilla.gnome.org/enter_bug.cgi?product=pygobject])
......@@ -101,15 +100,9 @@ if test $build_py3k = true ; then
[AC_MSG_ERROR(too old)])
fi
JD_CHECK_PYTHON_HEADERS(,[AC_MSG_ERROR(could not find Python headers)])
AM_CHECK_PYTHON_HEADERS(,[AC_MSG_ERROR(could not find Python headers)])
AC_MSG_CHECKING([for PySignal_SetWakeupFd in Python.h])
py_prefix=`$PYTHON -c "import sys; sys.stdout.write(sys.prefix)"`
if test -x "$PYTHON-config"; then
PYTHON_INCLUDES=`$PYTHON-config --includes 2>/dev/null`
else
PYTHON_INCLUDES="-I${py_prefix}/include/python${PYTHON_VERSION}"
fi
old_CPPFLAGS=$CPPFLAGS
CPPFLAGS="-Wall -Werror $PYTHON_INCLUDES"
AC_TRY_COMPILE([#include <Python.h>],
......@@ -152,7 +145,11 @@ fi
AM_CONDITIONAL(ENABLE_DOCS, test x$enable_docs != xno)
AM_CHECK_PYMOD(thread,,,enable_thread=no)
AM_CHECK_PYMOD(thread,,,enable_thread=check_for_py3_module)
if test "x$enable_thread" = xcheck_for_py3_module; then
dnl Python 3 uses the _thread module so check for that
AM_CHECK_PYMOD(_thread,,,enable_thread=no)
fi
AC_MSG_CHECKING(whether to enable threading in pygobject)
if test "x$enable_thread" != xno; then
......@@ -207,28 +204,7 @@ AC_SUBST(FFI_LIBS)
AC_SUBST(LIBFFI_PC)
dnl gio
PKG_CHECK_MODULES(GIO, gio-2.0 >= gio_required_version,
have_gio=true, have_gio=false)
AC_SUBST(GIO_CFLAGS)
AC_SUBST(GIO_LIBS)
# Do not build GIO if the python version >= 3.0
# We use GI to access GIO in python 3
AM_CONDITIONAL(BUILD_GIO, test $have_gio = true -a $build_py3k = false)
if test -n "$export_dynamic"; then
GIO_LIBS=`echo $GIO_LIBS | sed -e "s/$export_dynamic//"`
fi
dnl giounix
PKG_CHECK_MODULES(GIOUNIX, gio-unix-2.0 >= giounix_required_version,
have_giounix=true, have_giounix=false)
AC_SUBST(GIOUNIX_CFLAGS)
AC_SUBST(GIOUNIX_LIBS)
AM_CONDITIONAL(BUILD_GIOUNIX, test $have_giounix = true -a $build_py3k = false)
if test -n "$export_dynamic"; then
GIOUNIX_LIBS=`echo $GIOUNIX_LIBS | sed -e "s/$export_dynamic//"`
fi
PKG_CHECK_MODULES(GIO, gio-2.0 >= gio_required_version)
AC_ARG_ENABLE(cairo,
AC_HELP_STRING([--enable-cairo], [Enable Cairo bindings using introspection information]),
......@@ -293,7 +269,6 @@ AC_CONFIG_FILES(
gi/overrides/Makefile
glib/Makefile
gobject/Makefile
gio/Makefile
examples/Makefile
tests/Makefile
PKG-INFO)
......
#!/usr/bin/env python
# -*- Mode: Python; py-indent-offset: 4 -*-
# vim: tabstop=4 shiftwidth=4 expandtab
#
# Copyright (C) 2010 Red Hat, Inc., John (J5) Palmieri <johnp@redhat.com>
#
# 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 St, Fifth Floor, Boston, MA 02110-1301
# USA
title = "Search Entry"
description = """
GtkEntry allows to display icons and progress information. This demo shows how to use these features in a search entry.
"""
from gi.repository import Gtk, Gdk, GdkPixbuf, GLib, GObject
(PIXBUF_COL,
TEXT_COL) = range(2)
class SearchboxApp:
def __init__(self, demoapp):
self.demoapp = demoapp
self.window = Gtk.Dialog('Search Entry',
buttons=(Gtk.STOCK_CLOSE, Gtk.ResponseType.NONE))
self.window.connect('response', lambda x, y: self.window.destroy())
self.window.connect('destroy', Gtk.main_quit)
content_area = self.window.get_content_area()
vbox = Gtk.VBox(spacing=5)
content_area.pack_start(vbox, True, True, 0)
vbox.set_border_width(5)
label = Gtk.Label()
label.set_markup('Search entry demo')
vbox.pack_start(label, False, False, 0)
hbox = Gtk.HBox(homogeneous=False, spacing=10)
hbox.set_border_width(0)
vbox.pack_start(hbox, True, True, 0)
# Create our entry
entry = Gtk.Entry()
hbox.pack_start(entry, False, False, 0)
# Create the find and cancel buttons
notebook = Gtk.Notebook()
self.notebook = notebook
notebook.set_show_tabs(False)
notebook.set_show_border(False)
hbox.pack_start(notebook, False, False, 0)
find_button = Gtk.Button('Find')
find_button.connect('clicked', self.start_search, entry)
notebook.append_page(find_button, None)
find_button.show()
cancel_button = Gtk.Button('Cancel')
cancel_button.connect('clicked', self.stop_search, entry)
notebook.append_page(cancel_button, None)
cancel_button.show()
# Set up the search icon
self.search_by_name(None, entry)
# Set up the clear icon
entry.set_icon_from_stock(Gtk.EntryIconPosition.SECONDARY,
Gtk.STOCK_CLEAR)
self.text_changed_cb(entry, None, find_button)
entry.connect('notify::text', self.text_changed_cb, find_button)
entry.connect('activate', self.activate_cb)
# Create the menu
menu = self.create_search_menu(entry)
entry.connect('icon-press', self.icon_press_cb, menu)
# FIXME: this should take None for the detach callback
# but our callback implementation does not allow
# it yet, so we pass in a noop callback
menu.attach_to_widget(entry, self.detach)
# add accessible alternatives for icon functionality
entry.connect('populate-popup', self.entry_populate_popup)
self.window.show_all()
def detach(self, *args):
pass
def show_find_button(self):
self.notebook.set_current_page(0)
def show_cancel_button(self):
self.notebook.set_current_page(1)
def search_progress(self, entry):
entry.progress_pulse()
return True
def search_progress_done (self, entry):
entry.set_progress_fraction(0.0)
def finish_search(self, button, entry):
self.show_find_button()
GObject.source_remove(self.search_progress_id)
self.search_progress_done(entry)
self.search_progress_id = 0
return False
def start_search_feedback(self, entry):
self.search_progress_id = GObject.timeout_add(100,
self.search_progress,
entry)
return False
def start_search(self, button, entry):
self.show_cancel_button()
self.search_progress_id = GObject.timeout_add_seconds(1,
self.start_search_feedback,
entry)
self.finish_search_id = GObject.timeout_add_seconds(15,
self.finish_search,
button)
def stop_search(self, button, entry):
GObject.source_remove(self.finish_search_id)
self.finish_search(button, entry)
def clear_entry_swapped(self, widget, entry):
self.clear_entry(entry)
def clear_entry(self, entry):
entry.set_text('')
def search_by_name (self, item, entry):
entry.set_icon_from_stock(Gtk.EntryIconPosition.PRIMARY,
Gtk.STOCK_FIND)
entry.set_icon_tooltip_text(Gtk.EntryIconPosition.PRIMARY,
'Search by name\n' + \
'Click here to change the search type')
def search_by_description(self, item, entry):
entry.set_icon_from_stock (Gtk.EntryIconPosition.PRIMARY,
Gtk.STOCK_EDIT)
entry.set_icon_tooltip_text(Gtk.EntryIconPosition.PRIMARY,
'Search by description\n' + \
'Click here to change the search type')
def search_by_file(self, item, entry):
entry.set_icon_from_stock(Gtk.EntryIconPosition.PRIMARY,
Gtk.STOCK_OPEN)
entry.set_icon_tooltip_text(Gtk.EntryIconPosition.PRIMARY,
'Search by file name\n' + \
'Click here to change the search type')
def create_search_menu(self, entry):
menu = Gtk.Menu()
item = Gtk.ImageMenuItem.new_with_mnemonic('Search by _name')
image = Gtk.Image.new_from_stock(Gtk.STOCK_FIND, Gtk.IconSize.MENU)
item.set_image(image)
item.set_always_show_image(True)
item.connect('activate', self.search_by_name, entry)
menu.append(item)
item = Gtk.ImageMenuItem.new_with_mnemonic('Search by _description')
image = Gtk.Image.new_from_stock(Gtk.STOCK_EDIT, Gtk.IconSize.MENU)
item.set_image(image)
item.set_always_show_image(True)
item.connect('activate', self.search_by_description, entry)
menu.append(item)
item = Gtk.ImageMenuItem.new_with_mnemonic('Search by _file name')
image = Gtk.Image.new_from_stock(Gtk.STOCK_OPEN, Gtk.IconSize.MENU)
item.set_image(image)
item.set_always_show_image(True)
item.connect('activate', self.search_by_name, entry)
menu.append(item)
menu.show_all()
return menu
def icon_press_cb(self, entry, position, event, menu):
if position == Gtk.EntryIconPosition.PRIMARY:
menu.popup(None, None, None, None,
event.button, event.time)
else:
self.clear_entry(entry)
def text_changed_cb(self, entry, pspec, button):
has_text = entry.get_text_length() > 0
entry.set_icon_sensitive(Gtk.EntryIconPosition.SECONDARY, has_text)
button.set_sensitive(has_text)
def activate_cb (self, entry, button):
if self.search_progress_id != 0:
return
self.start_search(button, entry)
def search_entry_destroyed(self, widget):
if finish_search_id != 0:
GObject.source_remove(finish_search_id)
if search_progress_id != 0:
GObject.source_remove(search_progress_id)
self.window = None
def entry_populate_popup(self, entry, menu):
has_text = entry.get_text_length() > 0
item = Gtk.SeparatorMenuItem()
item.show()
menu.append(item)
item = Gtk.MenuItem.new_with_mnemonic("C_lear")
item.show()
item.connect('activate', self.clear_entry_swapped, entry)
menu.append(item)
item.set_sensitive(has_text)
search_menu = self.create_search_menu(entry)
item = Gtk.MenuItem.new_with_label('Search by')
item.show()
item.set_submenu(search_menu)
menu.append (item)
def main(demoapp=None):
app = SearchboxApp(demoapp)
Gtk.main()
if __name__ == '__main__':
main()
#!/usr/bin/env python
# -*- Mode: Python; py-indent-offset: 4 -*-
# vim: tabstop=4 shiftwidth=4 expandtab
#
# Copyright (C) 2010 Red Hat, Inc., John (J5) Palmieri <johnp@redhat.com>
#
# 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 St, Fifth Floor, Boston, MA 02110-1301
# USA
title = "Icon View Basics"
description = """
The GtkIconView widget is used to display and manipulate icons. It uses a GtkTreeModel for data storage, so the list store example might be helpful.
We also use the Gio.File API to get the icons for each file type.
"""
import os
from gi.repository import GLib, Gtk, Gio, GdkPixbuf
import glib
class IconViewApp:
(COL_PATH,
COL_DISPLAY_NAME,
COL_PIXBUF,
COL_IS_DIRECTORY,
NUM_COLS) = range(5)
def __init__(self, demoapp):
self.pixbuf_lookup = {}
self.demoapp = demoapp
self.window = Gtk.Window()
self.window.set_title('Gtk.IconView demo')
self.window.set_default_size(650, 400)
self.window.connect('destroy', Gtk.main_quit)
vbox = Gtk.VBox()
self.window.add(vbox)
tool_bar = Gtk.Toolbar()
vbox.pack_start(tool_bar, False, False, 0)
up_button = Gtk.ToolButton(stock_id=Gtk.STOCK_GO_UP)
up_button.set_is_important(True)
up_button.set_sensitive(False)
tool_bar.insert(up_button, -1)
home_button = Gtk.ToolButton(stock_id=Gtk.STOCK_HOME)
home_button.set_is_important(True)
tool_bar.insert(home_button, -1)
sw = Gtk.