~vcs-imports/gazpacho-hildon/trunk

« back to all changes in this revision

Viewing changes to hildonwidgets/lgpl.py

  • Committer: erikarls
  • Date: 2006-07-03 10:03:05 UTC
  • Revision ID: vcs-imports@canonical.com-20060703100305-173zy2oshnha01j7
fixed bugs

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
import hildon
30
30
 
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
41
41
 
42
42
_ = gettext.gettext
43
43
 
44
44
 
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)
49
 
 
50
 
    def fill_empty(self, context, widget):
51
 
        widget.add(context.create_placeholder())
52
 
 
53
 
    def replace_child(self, context, current, new, container):
54
 
        if not isinstance(current, hildon.AppView):
55
 
                    container.remove(current)
56
 
        container.add(new)
57
 
 
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)
63
 
 
64
 
        project = gwidget.project
65
 
        project.uim.create_default_actions()
66
 
 
67
 
        project.uim.add_ui(gwidget, ui_string)
68
 
 
69
 
    def fill_empty(self, context, appview):
70
 
        appview.add(context.create_placeholder())
71
 
        appview.vbox.add(context.create_placeholder())
72
 
 
73
 
    def replace_child(self, context, current, new, container):
74
 
        if current in container.get_children():
75
 
            container.remove(current)
76
 
            container.add(new)
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)
82
 
 
83
 
    def load(self, context, gtk_widget, blacklist):
84
 
        project = context.get_project()
85
 
 
86
 
        old_name = gtk_widget.name
87
 
        gwidget = Widget.load(gtk_widget, project, blacklist)
88
 
        gwidget._name = gwidget.gtk_widget.name
89
 
 
90
 
        # change the gtk_widget for the one we get from the uimanager
91
 
        project.uim.load_widget(gwidget, old_name)
92
 
 
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)
97
 
 
98
 
        # load the vbox
99
 
        self._setup_internal_children(gwidget)
100
 
 
101
 
        # create children for the vbox
102
 
        for child in gtk_widget.vbox.get_children():
103
 
            load_child(gwidget, child, project, blacklist)
104
 
 
105
 
        gwidget.load_signals()
106
 
 
107
 
        return gwidget
108
 
 
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',
113
 
                                          gwidget.name or '')
 
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)
 
49
#
 
50
#    def fill_empty(self, context, widget):
 
51
#        widget.add(context.create_placeholder())
 
52
#
 
53
#    def replace_child(self, context, current, new, container):
 
54
#        if not isinstance(current, hildon.AppView):
 
55
#                   container.remove(current)
 
56
#        container.add(new)
 
57
 
 
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)
 
63
#
 
64
#        project = gwidget.project
 
65
#        project.uim.create_default_actions()
 
66
#
 
67
#        project.uim.add_ui(gwidget, ui_string)
 
68
#
 
69
#    def fill_empty(self, context, appview):
 
70
#        appview.add(context.create_placeholder())
 
71
#        appview.vbox.add(context.create_placeholder())
 
72
#
 
73
#    def replace_child(self, context, current, new, container):
 
74
#        if current in container.get_children():
 
75
#            container.remove(current)
 
76
#            container.add(new)
 
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)
 
82
#
 
83
#    def load(self, context, gtk_widget, blacklist):
 
84
#        project = context.get_project()
 
85
#
 
86
#        old_name = gtk_widget.name
 
87
#        gwidget = BaseGadget.load(gtk_widget, project, blacklist)
 
88
#        gwidget._name = gwidget.gtk_widget.name
 
89
#
 
90
#        # change the gtk_widget for the one we get from the uimanager
 
91
#        project.uim.load_widget(gwidget, old_name)
 
92
#
 
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)
 
97
#
 
98
#        # load the vbox
 
99
#        self._setup_internal_children(gwidget)
 
100
#
 
101
#        # create children for the vbox
 
102
#        for child in gtk_widget.vbox.get_children():
 
103
#            load_child(gwidget, child, project, blacklist)
 
104
#
 
105
#        gwidget.load_signals()
 
106
#
 
107
#        return gwidget
 
108
#
 
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 '')
114
114
 
115
115
class ToolBarsProp(CustomProperty, IntType):
116
116
    minimum = 0
266
266
    context = False
267
267
    cdata = True
268
268
 
269
 
prop_registry.override_property('HildonAppView::menu-ui', AppViewMenuAdaptor)
 
269
#prop_registry.override_property('HildonAppView::menu-ui', AppViewMenuAdaptor)
270
270
 
271
 
prop_registry.override_simple('HildonAppView::fullscreen', disabled=True)
 
271
#prop_registry.override_simple('HildonAppView::fullscreen', disabled=True)
272
272
 
273
273
class  FileSelectEditor(PropertyCustomEditor, PropertyEditorDialog, EditorPropertyText):
274
274
    button_text = _('Select...')
373
373
        name = self._object.get_data("imagefilename")
374
374
        return name
375
375
 
376
 
prop_registry.override_property('HildonCaption::icon-setter', CaptionImageAdaptor)
 
376
#prop_registry.override_property('HildonCaption::icon-setter', CaptionImageAdaptor)
377
377
 
378
378
class CaptionAdaptor(WidgetAdaptor):
379
379
    internal_child = None