31
31
from gazpacho.widgetadaptor import WidgetAdaptor
32
from gazpacho.widget import Widget, load_child, load_widget_from_gtk_widget
32
from gazpacho.gadget import BaseGadget, load_gadget_from_widget
33
33
from gazpacho.context import Context
34
34
from gazpacho.placeholder import Placeholder
35
from gazpacho.uieditor import UIEditor, MenuBarUIEditor, AddMenuDialog, AddMenuitemDialog
35
from gazpacho.uieditor import UIEditor, AddMenuDialog, AddMenuitemDialog
36
36
from gazpacho.properties import prop_registry, TransparentProperty, StringType, IntType, CustomProperty, PropertyCustomEditor, ObjectType, PropertyError
37
from gazpacho.editor import PropertyCustomEditorWithDialog, EditorPropertyText, PropertyEditorDialog
38
from gazpacho.util import unselect_when_press_escape, xml_filter_nodes
37
from gazpacho.propertyeditor import PropertyCustomEditorWithDialog, EditorPropertyText, PropertyEditorDialog
38
#from gazpacho.util import unselect_when_press_escape, xml_filter_nodes
39
39
from gazpacho.widgetregistry import widget_registry
40
40
from gazpacho.loader.custom import adapter_registry
42
42
_ = gettext.gettext
45
class AppAdaptor(WidgetAdaptor):
46
def post_create (self, context, app, interactive=True):
47
# Resize the window to target size
48
app.set_size_request(672,396)
50
def fill_empty(self, context, widget):
51
widget.add(context.create_placeholder())
53
def replace_child(self, context, current, new, container):
54
if not isinstance(current, hildon.AppView):
55
container.remove(current)
58
class AppViewAdaptor(WidgetAdaptor):
59
def post_create (self, context, appview, interactive=True):
60
gwidget = Widget.from_widget(appview)
61
ui_string = "<popup name='HildonApp'></popup>"
62
self._setup_internal_children(gwidget)
64
project = gwidget.project
65
project.uim.create_default_actions()
67
project.uim.add_ui(gwidget, ui_string)
69
def fill_empty(self, context, appview):
70
appview.add(context.create_placeholder())
71
appview.vbox.add(context.create_placeholder())
73
def replace_child(self, context, current, new, container):
74
if current in container.get_children():
75
container.remove(current)
77
if current in container.vbox.get_children():
78
position = container.vbox.get_children().index(current)
79
container.vbox.remove(current)
80
container.vbox.add(new)
81
container.vbox.reorder_child(new, position)
83
def load(self, context, gtk_widget, blacklist):
84
project = context.get_project()
86
old_name = gtk_widget.name
87
gwidget = Widget.load(gtk_widget, project, blacklist)
88
gwidget._name = gwidget.gtk_widget.name
90
# change the gtk_widget for the one we get from the uimanager
91
project.uim.load_widget(gwidget, old_name)
94
if isinstance(gtk_widget, gtk.Container):
95
for child in gtk_widget.get_children():
96
load_child(gwidget, child, project, blacklist)
99
self._setup_internal_children(gwidget)
101
# create children for the vbox
102
for child in gtk_widget.vbox.get_children():
103
load_child(gwidget, child, project, blacklist)
105
gwidget.load_signals()
109
def _setup_internal_children(self, gwidget):
110
child_class = widget_registry.get_by_name('GtkVBox')
111
vbox_widget = Widget(child_class, gwidget.project)
112
vbox_widget.setup_internal_widget(gwidget.gtk_widget.vbox, 'vbox',
45
#class AppAdaptor(WidgetAdaptor):
46
# def post_create (self, context, app, interactive=True):
47
# # Resize the window to target size
48
# app.set_size_request(672,396)
50
# def fill_empty(self, context, widget):
51
# widget.add(context.create_placeholder())
53
# def replace_child(self, context, current, new, container):
54
# if not isinstance(current, hildon.AppView):
55
# container.remove(current)
58
#class AppViewAdaptor(WidgetAdaptor):
59
# def post_create (self, context, appview, interactive=True):
60
# gwidget = BaseCadget.from_widget(appview)
61
# ui_string = "<popup name='HildonApp'></popup>"
62
# self._setup_internal_children(gwidget)
64
# project = gwidget.project
65
# project.uim.create_default_actions()
67
# project.uim.add_ui(gwidget, ui_string)
69
# def fill_empty(self, context, appview):
70
# appview.add(context.create_placeholder())
71
# appview.vbox.add(context.create_placeholder())
73
# def replace_child(self, context, current, new, container):
74
# if current in container.get_children():
75
# container.remove(current)
77
# if current in container.vbox.get_children():
78
# position = container.vbox.get_children().index(current)
79
# container.vbox.remove(current)
80
# container.vbox.add(new)
81
# container.vbox.reorder_child(new, position)
83
# def load(self, context, gtk_widget, blacklist):
84
# project = context.get_project()
86
# old_name = gtk_widget.name
87
# gwidget = BaseGadget.load(gtk_widget, project, blacklist)
88
# gwidget._name = gwidget.gtk_widget.name
90
# # change the gtk_widget for the one we get from the uimanager
91
# project.uim.load_widget(gwidget, old_name)
93
# # create the children
94
# if isinstance(gtk_widget, gtk.Container):
95
# for child in gtk_widget.get_children():
96
# load_child(gwidget, child, project, blacklist)
99
# self._setup_internal_children(gwidget)
101
# # create children for the vbox
102
# for child in gtk_widget.vbox.get_children():
103
# load_child(gwidget, child, project, blacklist)
105
# gwidget.load_signals()
109
# def _setup_internal_children(self, gwidget):
110
# child_class = widget_registry.get_by_name('GtkVBox')
111
# vbox_widget = BaseGadget(child_class, gwidget.project)
112
# vbox_widget.setup_internal_widget(gwidget.gtk_widget.vbox, 'vbox',
113
# gwidget.name or '')
115
115
class ToolBarsProp(CustomProperty, IntType):