[pygobject] pass in the demo app so demos can use utility methods like requesting file paths
- From: John Palmieri <johnp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] pass in the demo app so demos can use utility methods like requesting file paths
- Date: Thu, 8 Jul 2010 20:03:25 +0000 (UTC)
commit 27a417c71f8c122e46c7472663bb25c17413f103
Author: John (J5) Palmieri <johnp redhat com>
Date: Thu Jul 8 16:01:25 2010 -0400
pass in the demo app so demos can use utility methods like requesting file paths
demos/gtk-demo/demos/Entry/entry_buffer.py | 2 +-
demos/gtk-demo/demos/Entry/entry_completion.py | 2 +-
demos/gtk-demo/demos/appwindow.py | 13 +++++++++++--
demos/gtk-demo/demos/assistant.py | 2 +-
demos/gtk-demo/demos/builder.py | 14 ++++++++++----
demos/gtk-demo/demos/button_box.py | 2 +-
demos/gtk-demo/demos/clipboard.py | 8 +-------
demos/gtk-demo/demos/colorselector.py | 2 +-
demos/gtk-demo/demos/combobox.py | 8 +++++---
demos/gtk-demo/demos/drawingarea.py | 2 +-
demos/gtk-demo/demos/test.py | 2 +-
demos/gtk-demo/gtk-demo.py | 6 +++---
12 files changed, 37 insertions(+), 26 deletions(-)
---
diff --git a/demos/gtk-demo/demos/Entry/entry_buffer.py b/demos/gtk-demo/demos/Entry/entry_buffer.py
index 8578345..b5e884d 100644
--- a/demos/gtk-demo/demos/Entry/entry_buffer.py
+++ b/demos/gtk-demo/demos/Entry/entry_buffer.py
@@ -65,7 +65,7 @@ class EntryBufferApp:
self.window.destroy()
Gtk.main_quit()
-def main():
+def main(demoapp=None):
app = EntryBufferApp()
Gtk.main()
diff --git a/demos/gtk-demo/demos/Entry/entry_completion.py b/demos/gtk-demo/demos/Entry/entry_completion.py
index 3cac0dd..a1bde10 100644
--- a/demos/gtk-demo/demos/Entry/entry_completion.py
+++ b/demos/gtk-demo/demos/Entry/entry_completion.py
@@ -79,7 +79,7 @@ class EntryBufferApp:
self.window.destroy()
Gtk.main_quit()
-def main():
+def main(demoapp=None):
app = EntryBufferApp()
Gtk.main()
diff --git a/demos/gtk-demo/demos/appwindow.py b/demos/gtk-demo/demos/appwindow.py
index 27306a2..8b7c99c 100644
--- a/demos/gtk-demo/demos/appwindow.py
+++ b/demos/gtk-demo/demos/appwindow.py
@@ -33,6 +33,7 @@ import sys, os
global infobar
global window
global messagelabel
+global _demoapp
def widget_destroy(widget, button):
widget.destroy()
@@ -305,7 +306,12 @@ def register_stock_icons():
factory = Gtk.IconFactory()
factory.add_default()
- filename = os.path.join('data', 'gtk-logo-rgb.gif')
+
+ if _demoapp is None:
+ filename = os.path.join('data', 'gtk-logo-rgb.gif')
+ else:
+ filename = _demoapp.find_file('gtk-logo-rgb.gif')
+
pixbuf = GdkPixbuf.Pixbuf.new_from_file(filename)
transparent = pixbuf.add_alpha(True, 0xff, 0xff, 0xff)
icon_set = Gtk.IconSet.new_from_pixbuf(transparent)
@@ -317,10 +323,13 @@ class ToolMenuAction(Gtk.Action):
def do_create_tool_item(self):
return Gtk.MenuToolButton()
-def main():
+def main(demoapp=None):
global infobar
global window
global messagelabel
+ global _demoapp
+
+ _demoapp = demoapp
register_stock_icons()
diff --git a/demos/gtk-demo/demos/assistant.py b/demos/gtk-demo/demos/assistant.py
index 3d6f1bf..e1a7ecd 100644
--- a/demos/gtk-demo/demos/assistant.py
+++ b/demos/gtk-demo/demos/assistant.py
@@ -126,7 +126,7 @@ class AssistantApp:
None)
self.assistant.set_page_header_image(label, pixbuf)
-def main():
+def main(demoapp=None):
app = AssistantApp()
Gtk.main()
diff --git a/demos/gtk-demo/demos/builder.py b/demos/gtk-demo/demos/builder.py
index d72ce51..5ecf748 100644
--- a/demos/gtk-demo/demos/builder.py
+++ b/demos/gtk-demo/demos/builder.py
@@ -31,9 +31,15 @@ from gi.repository import Gtk, GdkPixbuf, Gdk
import os
class BuilderApp:
- def __init__(self):
+ def __init__(self, demoapp):
+ self.demoapp = demoapp
+
self.builder = Gtk.Builder()
- filename = os.path.join('data', 'demo.ui')
+ if demoapp is None:
+ filename = os.path.join('data', 'demo.ui')
+ else:
+ filename = demoapp.find_file('demo.ui')
+
self.builder.add_from_file(filename)
self.builder.connect_signals(self)
@@ -49,8 +55,8 @@ class BuilderApp:
def quit_activate(self, action):
Gtk.main_quit()
-def main():
- app = BuilderApp()
+def main(demoapp=None):
+ app = BuilderApp(demoapp)
Gtk.main()
if __name__ == '__main__':
diff --git a/demos/gtk-demo/demos/button_box.py b/demos/gtk-demo/demos/button_box.py
index dfbcf19..7cd8d52 100644
--- a/demos/gtk-demo/demos/button_box.py
+++ b/demos/gtk-demo/demos/button_box.py
@@ -113,7 +113,7 @@ class ButtonBoxApp:
return frame
-def main():
+def main(demoapp=None):
app = ButtonBoxApp()
Gtk.main()
diff --git a/demos/gtk-demo/demos/clipboard.py b/demos/gtk-demo/demos/clipboard.py
index fb129cd..fa8f2da 100644
--- a/demos/gtk-demo/demos/clipboard.py
+++ b/demos/gtk-demo/demos/clipboard.py
@@ -222,15 +222,9 @@ class ClipboardApp:
item.show()
menu.append(item)
- #FIXME: This doesn't work as we pass a None as a function
- # pointer. PyGI doesn't correctly check for
- # allow-none on callback parameters
- # Fix is waiting for approval -
- # https://bugzilla.gnome.org/show_bug.cgi?id=620906
-
menu.popup(None, None, None, None, 3, event.button.time)
-def main():
+def main(demoapp=None):
app = ClipboardApp()
Gtk.main()
diff --git a/demos/gtk-demo/demos/colorselector.py b/demos/gtk-demo/demos/colorselector.py
index ee94b64..514718b 100644
--- a/demos/gtk-demo/demos/colorselector.py
+++ b/demos/gtk-demo/demos/colorselector.py
@@ -113,7 +113,7 @@ class ColorSelectorApp:
dialog.destroy()
-def main():
+def main(demoapp=None):
app = ColorSelectorApp()
Gtk.main()
diff --git a/demos/gtk-demo/demos/combobox.py b/demos/gtk-demo/demos/combobox.py
index 906efd2..965457e 100644
--- a/demos/gtk-demo/demos/combobox.py
+++ b/demos/gtk-demo/demos/combobox.py
@@ -59,7 +59,9 @@ class MaskEntry(Gtk.Entry):
self.set_background()
class ComboboxApp:
- def __init__(self):
+ def __init__(self, demoapp):
+ self.demoapp = demoapp
+
self.window = Gtk.Window()
self.window.set_title('Combo boxes')
self.window.set_border_width(10)
@@ -274,8 +276,8 @@ class ComboboxApp:
entry.append_text('2\302\275')
entry.append_text('Three')
-def main():
- app = ComboboxApp()
+def main(demoapp=None):
+ app = ComboboxApp(demoapp)
Gtk.main()
if __name__ == '__main__':
diff --git a/demos/gtk-demo/demos/drawingarea.py b/demos/gtk-demo/demos/drawingarea.py
index 527b564..b5dc1db 100644
--- a/demos/gtk-demo/demos/drawingarea.py
+++ b/demos/gtk-demo/demos/drawingarea.py
@@ -241,7 +241,7 @@ class DrawingAreaApp:
return True
-def main():
+def main(demoapp=None):
app = DrawingAreaApp()
Gtk.main()
diff --git a/demos/gtk-demo/demos/test.py b/demos/gtk-demo/demos/test.py
index 4716ff7..9201bcb 100644
--- a/demos/gtk-demo/demos/test.py
+++ b/demos/gtk-demo/demos/test.py
@@ -7,7 +7,7 @@ from gi.repository import Gtk
def _quit(*args):
Gtk.main_quit()
-def main():
+def main(demoapp=None):
window = Gtk.Window()
window.connect_after('destroy', _quit)
window.show_all()
diff --git a/demos/gtk-demo/gtk-demo.py b/demos/gtk-demo/gtk-demo.py
index c0a0f86..15b00df 100755
--- a/demos/gtk-demo/gtk-demo.py
+++ b/demos/gtk-demo/gtk-demo.py
@@ -148,7 +148,7 @@ class GtkDemoApp(object):
self.load_demos_from_list(demo_file_list, demo_list)
- def demo_find_file(self, base=''):
+ def find_file(self, base=''):
dir = os.path.join('demos', 'data')
logo_file = os.path.join(dir, 'gtk-logo-rgb.gif')
base_file = os.path.join(dir, base)
@@ -165,7 +165,7 @@ class GtkDemoApp(object):
raise IOError('Cannot find demo data file "%s"' % base)
def setup_default_icon(self):
- filename = self.demo_find_file ('gtk-logo-rgb.gif')
+ filename = self.find_file ('gtk-logo-rgb.gif')
pixbuf = GdkPixbuf.Pixbuf.new_from_file(filename)
transparent = pixbuf.add_alpha(True, 0xff, 0xff, 0xff)
list = []
@@ -212,7 +212,7 @@ class GtkDemoApp(object):
def row_activated_cb(self, view, path, col, store):
(success, treeiter) = store.get_iter(path)
demo = store.get_value(treeiter, 1)
- demo.module.main()
+ demo.module.main(self)
def create_tree(self):
tree_store = Gtk.TreeStore(str, Demo, Pango.Style)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]