diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2017-07-12 08:45:23 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2017-07-12 08:45:27 +0900 |
commit | ee6939d73fd96606a92eee870014c58eafee5e63 (patch) | |
tree | 6a3526fab8e841879fbcab05749fcb4a91a4f580 /examples | |
parent | 0df45a72dc2a72275a5c49c38b87f73341987192 (diff) | |
download | pygobject2-ee6939d73fd96606a92eee870014c58eafee5e63.tar.gz pygobject2-ee6939d73fd96606a92eee870014c58eafee5e63.tar.bz2 pygobject2-ee6939d73fd96606a92eee870014c58eafee5e63.zip |
Imported Upstream version 3.20.0
Change-Id: I8106882e9a0d7a8fb554f9549e7c2cde111c104b
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/Makefile.am | 3 | ||||
-rw-r--r-- | examples/Makefile.in | 137 | ||||
-rwxr-xr-x | examples/cairo-demo.py | 59 | ||||
-rw-r--r-- | examples/option.py | 40 | ||||
-rw-r--r-- | examples/properties.py | 13 | ||||
-rw-r--r-- | examples/signal.py | 39 |
6 files changed, 184 insertions, 107 deletions
diff --git a/examples/Makefile.am b/examples/Makefile.am index b680b90..af9f3d7 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -1,4 +1 @@ EXTRA_DIST = properties.py signal.py option.py cairo-demo.py - - --include $(top_srcdir)/git.mk diff --git a/examples/Makefile.in b/examples/Makefile.in index 62c2a0e..dab6464 100644 --- a/examples/Makefile.in +++ b/examples/Makefile.in @@ -1,9 +1,8 @@ -# Makefile.in generated by automake 1.11.5 from Makefile.am. +# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software -# Foundation, Inc. +# Copyright (C) 1994-2014 Free Software Foundation, Inc. + # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -15,23 +14,61 @@ @SET_MAKE@ VPATH = @srcdir@ -am__make_dryrun = \ - { \ - am__dry=no; \ +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ - echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ - | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ - *) \ - for am__flg in $$MAKEFLAGS; do \ - case $$am__flg in \ - *=*|--*) ;; \ - *n*) am__dry=yes; break;; \ - esac; \ - done;; \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ esac; \ - test $$am__dry = yes; \ - } + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ @@ -51,7 +88,6 @@ POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = examples -DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/as-ac-expand.m4 \ $(top_srcdir)/m4/jhflags.m4 $(top_srcdir)/m4/libtool.m4 \ @@ -60,16 +96,23 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/as-ac-expand.m4 \ $(top_srcdir)/m4/python.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ +am__v_at_1 = SOURCES = DIST_SOURCES = am__can_run_installinfo = \ @@ -77,6 +120,8 @@ am__can_run_installinfo = \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +am__DIST_COMMON = $(srcdir)/Makefile.in DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@ @@ -88,9 +133,14 @@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ +CAIRO_CFLAGS = @CAIRO_CFLAGS@ +CAIRO_LIBS = @CAIRO_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ +CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ +CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ +CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ @@ -108,6 +158,7 @@ EXEEXT = @EXEEXT@ FFI_CFLAGS = @FFI_CFLAGS@ FFI_LIBS = @FFI_LIBS@ FGREP = @FGREP@ +GENHTML = @GENHTML@ GIO_CFLAGS = @GIO_CFLAGS@ GIO_LIBS = @GIO_LIBS@ GI_CFLAGS = @GI_CFLAGS@ @@ -127,6 +178,7 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ +LCOV = @LCOV@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBFFI_PC = @LIBFFI_PC@ @@ -136,7 +188,7 @@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ -MAINT = @MAINT@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ @@ -144,6 +196,7 @@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ +OS_EXT = @OS_EXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ @@ -171,6 +224,7 @@ PYTHON_LIBS = @PYTHON_LIBS@ PYTHON_LIB_LOC = @PYTHON_LIB_LOC@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ +PYTHON_SO = @PYTHON_SO@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ @@ -179,6 +233,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ THREADING_CFLAGS = @THREADING_CFLAGS@ VERSION = @VERSION@ +WARN_CFLAGS = @WARN_CFLAGS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ @@ -239,7 +294,7 @@ EXTRA_DIST = properties.py signal.py option.py cairo-demo.py all: all-am .SUFFIXES: -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ @@ -251,7 +306,6 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign examples/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign examples/Makefile -.PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ @@ -264,9 +318,9 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) +$(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) +$(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): @@ -275,11 +329,11 @@ mostlyclean-libtool: clean-libtool: -rm -rf .libs _libs -tags: TAGS -TAGS: +tags TAGS: + +ctags CTAGS: -ctags: CTAGS -CTAGS: +cscope cscopelist: distdir: $(DISTFILES) @@ -415,18 +469,19 @@ uninstall-am: .MAKE: install-am install-strip .PHONY: all all-am check check-am clean clean-generic clean-libtool \ - distclean distclean-generic distclean-libtool distdir dvi \ - dvi-am html html-am info info-am install install-am \ - install-data install-data-am install-dvi install-dvi-am \ - install-exec install-exec-am install-html install-html-am \ - install-info install-info-am install-man install-pdf \ - install-pdf-am install-ps install-ps-am install-strip \ - installcheck installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-generic \ - mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am - - --include $(top_srcdir)/git.mk + cscopelist-am ctags-am distclean distclean-generic \ + distclean-libtool distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags-am uninstall uninstall-am + +.PRECIOUS: Makefile + # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/examples/cairo-demo.py b/examples/cairo-demo.py index cec45d8..7b90ec3 100755 --- a/examples/cairo-demo.py +++ b/examples/cairo-demo.py @@ -4,43 +4,48 @@ Based on cairo-demo/X11/cairo-demo.c """ import cairo -from gi.repository import Gdk, Gtk +from gi.repository import Gtk SIZE = 30 + def triangle(ctx): ctx.move_to(SIZE, 0) - ctx.rel_line_to(SIZE, 2*SIZE) - ctx.rel_line_to(-2*SIZE, 0) + ctx.rel_line_to(SIZE, 2 * SIZE) + ctx.rel_line_to(-2 * SIZE, 0) ctx.close_path() + def square(ctx): ctx.move_to(0, 0) - ctx.rel_line_to(2*SIZE, 0) - ctx.rel_line_to(0, 2*SIZE) - ctx.rel_line_to(-2*SIZE, 0) + ctx.rel_line_to(2 * SIZE, 0) + ctx.rel_line_to(0, 2 * SIZE) + ctx.rel_line_to(-2 * SIZE, 0) ctx.close_path() + def bowtie(ctx): ctx.move_to(0, 0) - ctx.rel_line_to(2*SIZE, 2*SIZE) - ctx.rel_line_to(-2*SIZE, 0) - ctx.rel_line_to(2*SIZE, -2*SIZE) + ctx.rel_line_to(2 * SIZE, 2 * SIZE) + ctx.rel_line_to(-2 * SIZE, 0) + ctx.rel_line_to(2 * SIZE, -2 * SIZE) ctx.close_path() + def inf(ctx): ctx.move_to(0, SIZE) - ctx.rel_curve_to(0,SIZE, SIZE,SIZE, 2*SIZE,0) - ctx.rel_curve_to(SIZE,-SIZE, 2*SIZE,-SIZE, 2*SIZE,0) - ctx.rel_curve_to(0,SIZE, -SIZE,SIZE, -2*SIZE,0) - ctx.rel_curve_to(-SIZE,-SIZE, -2*SIZE,-SIZE, -2*SIZE,0) + ctx.rel_curve_to(0, SIZE, SIZE, SIZE, 2 * SIZE, 0) + ctx.rel_curve_to(SIZE, -SIZE, 2 * SIZE, -SIZE, 2 * SIZE, 0) + ctx.rel_curve_to(0, SIZE, -SIZE, SIZE, - 2 * SIZE, 0) + ctx.rel_curve_to(-SIZE, -SIZE, - 2 * SIZE, -SIZE, - 2 * SIZE, 0) ctx.close_path() + def draw_shapes(ctx, x, y, fill): ctx.save() ctx.new_path() - ctx.translate(x+SIZE, y+SIZE) + ctx.translate(x + SIZE, y + SIZE) bowtie(ctx) if fill: ctx.fill() @@ -48,7 +53,7 @@ def draw_shapes(ctx, x, y, fill): ctx.stroke() ctx.new_path() - ctx.translate(3*SIZE, 0) + ctx.translate(3 * SIZE, 0) square(ctx) if fill: ctx.fill() @@ -56,7 +61,7 @@ def draw_shapes(ctx, x, y, fill): ctx.stroke() ctx.new_path() - ctx.translate(3*SIZE, 0) + ctx.translate(3 * SIZE, 0) triangle(ctx) if fill: ctx.fill() @@ -64,7 +69,7 @@ def draw_shapes(ctx, x, y, fill): ctx.stroke() ctx.new_path() - ctx.translate(3*SIZE, 0) + ctx.translate(3 * SIZE, 0) inf(ctx) if fill: ctx.fill() @@ -73,12 +78,15 @@ def draw_shapes(ctx, x, y, fill): ctx.restore() + def fill_shapes(ctx, x, y): draw_shapes(ctx, x, y, True) + def stroke_shapes(ctx, x, y): draw_shapes(ctx, x, y, False) + def draw(da, ctx): ctx.set_source_rgb(0, 0, 0) @@ -86,24 +94,25 @@ def draw(da, ctx): ctx.set_tolerance(0.1) ctx.set_line_join(cairo.LINE_JOIN_ROUND) - ctx.set_dash([SIZE/4.0, SIZE/4.0], 0) + ctx.set_dash([SIZE / 4.0, SIZE / 4.0], 0) stroke_shapes(ctx, 0, 0) ctx.set_dash([], 0) - stroke_shapes(ctx, 0, 3*SIZE) + stroke_shapes(ctx, 0, 3 * SIZE) ctx.set_line_join(cairo.LINE_JOIN_BEVEL) - stroke_shapes(ctx, 0, 6*SIZE) + stroke_shapes(ctx, 0, 6 * SIZE) ctx.set_line_join(cairo.LINE_JOIN_MITER) - stroke_shapes(ctx, 0, 9*SIZE) + stroke_shapes(ctx, 0, 9 * SIZE) - fill_shapes(ctx, 0, 12*SIZE) + fill_shapes(ctx, 0, 12 * SIZE) ctx.set_line_join(cairo.LINE_JOIN_BEVEL) - fill_shapes(ctx, 0, 15*SIZE) - ctx.set_source_rgb(1,0,0) - stroke_shapes(ctx, 0, 15*SIZE) + fill_shapes(ctx, 0, 15 * SIZE) + ctx.set_source_rgb(1, 0, 0) + stroke_shapes(ctx, 0, 15 * SIZE) + def main(): win = Gtk.Window() diff --git a/examples/option.py b/examples/option.py index 345517e..73860f5 100644 --- a/examples/option.py +++ b/examples/option.py @@ -1,30 +1,28 @@ #!/usr/bin/env python -# gnome-python/pygobject/examples/option.py -from gobject.option import OptionGroup, OptionParser, make_option +from gi.repository import GLib -group = OptionGroup("example", "OptionGroup Example", "Shows all example options", - option_list = [ - make_option("--example", - action="store_true", - dest="example", - help="An example option."), - ]) +group = GLib.option.OptionGroup( + "example", "OptionGroup Example", "Shows all example options", + option_list=[GLib.option.make_option("--example", + action="store_true", + dest="example", + help="An example option."), + ]) -parser = OptionParser("NAMES ...", - description="A simple gobject.option example.", - option_list = [ - make_option("--file", "-f", - type="filename", - action="store", - dest="file", - help="A filename option"), - # ... - ]) +parser = GLib.option.OptionParser( + "NAMES ...", description="A simple gobject.option example.", + option_list=[GLib.option.make_option("--file", "-f", + type="filename", + action="store", + dest="file", + help="A filename option"), + # ... + ]) parser.add_option_group(group) parser.parse_args() -print "group: example ", group.values.example -print "parser: file", parser.values.file +print("group: example " + str(group.values.example)) +print("parser: file " + str(parser.values.file)) diff --git a/examples/properties.py b/examples/properties.py index eebfb16..4c8a20c 100644 --- a/examples/properties.py +++ b/examples/properties.py @@ -1,5 +1,6 @@ from gi.repository import GObject + class MyObject(GObject.GObject): foo = GObject.Property(type=str, default='bar') @@ -14,18 +15,18 @@ class MyObject(GObject.GObject): GObject.type_register(MyObject) -print "MyObject properties: ", list(MyObject.props) +print("MyObject properties: ", list(MyObject.props)) obj = MyObject() -print "obj.foo ==", obj.foo +print("obj.foo ==", obj.foo) obj.foo = 'spam' -print "obj.foo = spam" +print("obj.foo = spam") -print "obj.foo == ", obj.foo +print("obj.foo == ", obj.foo) -print "obj.boolprop == ", obj.boolprop +print("obj.boolprop == ", obj.boolprop) -print obj.readonly +print(obj.readonly) obj.readonly = 'does-not-work' diff --git a/examples/signal.py b/examples/signal.py index d1b7357..69c1d62 100644 --- a/examples/signal.py +++ b/examples/signal.py @@ -1,25 +1,42 @@ +from __future__ import print_function + from gi.repository import GObject + class C(GObject.GObject): - __gsignals__ = { - 'my_signal': (GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, - (GObject.TYPE_INT,)) - } - def do_my_signal(self, arg): - print "C: class closure for `my_signal' called with argument", arg + @GObject.Signal(arg_types=(int,)) + def my_signal(self, arg): + """Decorator style signal which uses the method name as signal name and + the method as the closure. + + Note that with python3 annotations can be used for argument types as follows: + @GObject.Signal + def my_signal(self, arg:int): + pass + """ + print("C: class closure for `my_signal' called with argument", arg) + + @GObject.Signal + def noarg_signal(self): + """Decoration of a signal using all defaults and no arguments.""" + print("C: class closure for `noarg_signal' called") + class D(C): def do_my_signal(self, arg): - print "D: class closure for `my_signal' called. Chaining up to C" - C.do_my_signal(self, arg) + print("D: class closure for `my_signal' called. Chaining up to C") + C.my_signal(self, arg) + + +def my_signal_handler(obj, arg, *extra): + print("handler for `my_signal' called with argument", arg, "and extra args", extra) -def my_signal_handler(object, arg, *extra): - print "handler for `my_signal' called with argument", arg, \ - "and extra args", extra inst = C() inst2 = D() inst.connect("my_signal", my_signal_handler, 1, 2, 3) +inst.connect("noarg_signal", my_signal_handler, 1, 2, 3) inst.emit("my_signal", 42) +inst.emit("noarg_signal") inst2.emit("my_signal", 42) |