5757.1.6
by Michael Vogt
add a very (very) ((very!)) basic plugin view helper) |
1 |
#!/usr/bin/python3
|
2 |
||
5757.1.18
by Michael Vogt
setup UBIQUITY_PLUGIN_PATH,UBIQUITY_GLADE automatically |
3 |
import os |
4 |
import sys |
|
5 |
||
5757.1.6
by Michael Vogt
add a very (very) ((very!)) basic plugin view helper) |
6 |
from gi.repository import Gtk |
5757.1.53
by Michael McCracken
add connection watcher to test script to test online state handling |
7 |
from dbus.mainloop.glib import DBusGMainLoop |
8 |
DBusGMainLoop(set_as_default=True) |
|
5757.1.6
by Michael Vogt
add a very (very) ((very!)) basic plugin view helper) |
9 |
|
5757.1.7
by Michael Vogt
add small comment |
10 |
# we could use this as the base for the MockController as well
|
11 |
# from ubiquity.frontend.base import Controller
|
|
5757.1.6
by Michael Vogt
add a very (very) ((very!)) basic plugin view helper) |
12 |
|
5757.1.53
by Michael McCracken
add connection watcher to test script to test online state handling |
13 |
# for testing online status
|
14 |
from ubiquity.misc import add_connection_watch |
|
5757.1.11
by Michael Vogt
add some testing hints |
15 |
|
5757.1.6
by Michael Vogt
add a very (very) ((very!)) basic plugin view helper) |
16 |
class MockController(object): |
17 |
||
5757.1.15
by Michael Vogt
add entry field verification and refactor tests |
18 |
def __init__(self, parent): |
19 |
self.parent = parent |
|
5757.1.6
by Michael Vogt
add a very (very) ((very!)) basic plugin view helper) |
20 |
self.oem_user_config = None |
21 |
self.oem_config = None |
|
5757.1.8
by Michael Vogt
add some more README |
22 |
self.dbfilter = None |
23 |
self._allow_go_foward = True |
|
24 |
self._allow_go_backward = True |
|
5757.1.6
by Michael Vogt
add a very (very) ((very!)) basic plugin view helper) |
25 |
|
5757.1.34
by Michael Vogt
improve plugin viewer a bit and use plugin_translate() (now that I know what it does :) |
26 |
def go_forward(self): |
27 |
self.parent.button_next.clicked() |
|
28 |
||
29 |
def get_string(self, s, lang): |
|
30 |
return "get_string: %s (lang=%s)" % (s, lang) |
|
31 |
||
5757.1.6
by Michael Vogt
add a very (very) ((very!)) basic plugin view helper) |
32 |
def add_builder(self, builder): |
33 |
pass
|
|
34 |
||
5757.1.8
by Michael Vogt
add some more README |
35 |
def allow_go_forward(self, v): |
36 |
self._allow_go_forward = v |
|
5757.1.15
by Michael Vogt
add entry field verification and refactor tests |
37 |
self.parent.button_next.set_sensitive(v) |
5757.1.8
by Michael Vogt
add some more README |
38 |
|
39 |
def allow_go_backward(self, v): |
|
40 |
self._allow_go_backward = v |
|
5757.1.15
by Michael Vogt
add entry field verification and refactor tests |
41 |
self.parent.button_back.set_sensitive(v) |
5757.1.6
by Michael Vogt
add a very (very) ((very!)) basic plugin view helper) |
42 |
|
5757.1.34
by Michael Vogt
improve plugin viewer a bit and use plugin_translate() (now that I know what it does :) |
43 |
|
5757.1.6
by Michael Vogt
add a very (very) ((very!)) basic plugin view helper) |
44 |
if __name__ == "__main__": |
5757.1.18
by Michael Vogt
setup UBIQUITY_PLUGIN_PATH,UBIQUITY_GLADE automatically |
45 |
""" Run with:
|
6155
by Colin Watson
Remove lots of cruft relating to removed Ubuntu One, webcam, and |
46 |
./plugin-viewer-gtk.py ubi-timezone
|
5757.1.6
by Michael Vogt
add a very (very) ((very!)) basic plugin view helper) |
47 |
"""
|
5757.1.34
by Michael Vogt
improve plugin viewer a bit and use plugin_translate() (now that I know what it does :) |
48 |
def _on_button_next_clicked(button): |
49 |
stop = page_gtk.plugin_on_next_clicked() |
|
50 |
if not stop: |
|
51 |
Gtk.main_quit() |
|
52 |
||
5757.1.18
by Michael Vogt
setup UBIQUITY_PLUGIN_PATH,UBIQUITY_GLADE automatically |
53 |
# setup env
|
54 |
for envvar, path in ( |
|
55 |
("UBIQUITY_PLUGIN_PATH", "./ubiquity/plugins"), |
|
56 |
("UBIQUITY_GLADE", "./gui/gtk")): |
|
57 |
if os.path.exists(path): |
|
58 |
os.environ[envvar] = path |
|
59 |
# ... and then import the plugin_manager
|
|
60 |
from ubiquity.plugin_manager import load_plugin |
|
61 |
||
5757.1.6
by Michael Vogt
add a very (very) ((very!)) basic plugin view helper) |
62 |
plugin_name = sys.argv[1] |
63 |
plugin_module = load_plugin(plugin_name) |
|
5757.1.15
by Michael Vogt
add entry field verification and refactor tests |
64 |
|
65 |
win = Gtk.Window() |
|
66 |
win.button_next = Gtk.Button("next") |
|
67 |
win.button_back = Gtk.Button("back") |
|
68 |
||
69 |
mock_controller = MockController(win) |
|
5757.1.6
by Michael Vogt
add a very (very) ((very!)) basic plugin view helper) |
70 |
page_gtk = plugin_module.PageGtk(mock_controller) |
5757.1.34
by Michael Vogt
improve plugin viewer a bit and use plugin_translate() (now that I know what it does :) |
71 |
page_gtk.plugin_translate("en") |
5757.1.15
by Michael Vogt
add entry field verification and refactor tests |
72 |
|
73 |
win.button_next.connect( |
|
5757.1.34
by Michael Vogt
improve plugin viewer a bit and use plugin_translate() (now that I know what it does :) |
74 |
"clicked", _on_button_next_clicked) |
5757.1.15
by Michael Vogt
add entry field verification and refactor tests |
75 |
win.button_back.connect( |
5757.1.14
by Michael Vogt
some more logic and tests |
76 |
"clicked", lambda b: page_gtk.plugin_on_back_clicked()) |
5757.1.6
by Michael Vogt
add a very (very) ((very!)) basic plugin view helper) |
77 |
|
5757.1.53
by Michael McCracken
add connection watcher to test script to test online state handling |
78 |
add_connection_watch(page_gtk.plugin_set_online_state) |
79 |
||
5757.2.14
by Michael McCracken
- get hostname from debconf interface, and fake it in plugin-viewer-gtk.py |
80 |
# fake debconf interface:
|
81 |
page_gtk.db = {'netcfg/get_hostname': 'test hostname'} |
|
82 |
||
5757.1.6
by Michael Vogt
add a very (very) ((very!)) basic plugin view helper) |
83 |
button_box = Gtk.ButtonBox(spacing=12) |
84 |
button_box.set_layout(Gtk.ButtonBoxStyle.END) |
|
5757.1.15
by Michael Vogt
add entry field verification and refactor tests |
85 |
button_box.pack_start(win.button_back, True, True, 6) |
86 |
button_box.pack_start(win.button_next, True, True, 6) |
|
5757.1.6
by Michael Vogt
add a very (very) ((very!)) basic plugin view helper) |
87 |
|
88 |
box = Gtk.VBox() |
|
89 |
box.pack_start(page_gtk.page, True, True, 6) |
|
90 |
box.pack_start(button_box, True, True, 6) |
|
91 |
||
92 |
win.add(box) |
|
93 |
win.connect("destroy", Gtk.main_quit) |
|
94 |
win.show_all() |
|
95 |
||
96 |
Gtk.main() |