Subversion Repositories basico

Rev

Rev 261 | Rev 264 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4 t00mlabs 1
#!/usr/bin/python
2
# -*- coding: utf-8 -*-
251 t00m 3
# File: mod_win.py
4 t00mlabs 4
# Author: Tomás Vírseda
5
# License: GPL v3
6
# Description: Gtk.ApplicationWindow implementation
7
 
8
import os
9
import stat
10
import time
11
import platform
12
 
13
import gi
14
gi.require_version('Gtk', '3.0')
15
 
16
from gi.repository import GLib
17
from gi.repository import GObject
18
from gi.repository import Gtk
19
from gi.repository import Gdk
20
from gi.repository import Gio
21
from gi.repository import Pango
22
from gi.repository.GdkPixbuf import Pixbuf
23
 
261 t00m 24
from basico.core.mod_env import APP, FILE
243 t00m 25
from basico.widgets.wdg_menuview import SAPNoteViewMenu
254 t00m 26
from basico.widgets.wdg_visor_sapnotes import SAPNotesVisor
27
from basico.widgets.wdg_visor_annotations import AnnotationsVisor
28
from basico.widgets.wdg_visor_toolbar import VisorToolbar
243 t00m 29
from basico.widgets.wdg_about import About
30
from basico.widgets.wdg_settingsview import SettingsView
31
from basico.widgets.wdg_logviewer import LogViewer
32
from basico.widgets.wdg_annot import AnnotationWidget
33
from basico.widgets.wdg_statusbar import Statusbar
4 t00mlabs 34
 
262 t00m 35
 
236 t00m 36
class GtkAppWindow(Gtk.ApplicationWindow):
4 t00mlabs 37
    def __init__(self, uiapp):
38
        self.setup_controller(uiapp)
39
        self.get_services()
247 t00m 40
        self.app = self.srvgui.get_app()
41
        self.srvgui.add_widget('uiapp', uiapp)
236 t00m 42
        self.setup_window(uiapp)
4 t00mlabs 43
        self.setup_widgets()
230 t00m 44
        self.run()
4 t00mlabs 45
 
106 t00mlabs 46
 
182 t00m 47
    def get_services(self):
247 t00m 48
        self.srvbnr = self.controller.get_service("BNR")
49
        self.srvgui = self.controller.get_service("GUI")
50
        self.srvdtb = self.controller.get_service("DB")
51
        self.srvuif = self.controller.get_service("UIF")
52
        self.srvicm = self.controller.get_service('IM')
53
        self.srvclb = self.controller.get_service('Callbacks')
255 t00m 54
        self.srvant = self.controller.get_service('Annotation')
4 t00mlabs 55
 
141 t00mlabs 56
 
4 t00mlabs 57
    def setup_controller(self, uiapp):
58
        self.controller = uiapp.get_controller()
59
 
60
 
236 t00m 61
    def setup_window(self, uiapp):
243 t00m 62
        Gtk.Window.__init__(self, title=APP['name'], application=uiapp)
247 t00m 63
        icon = self.srvicm.get_icon('basico-component', 48, 48)
4 t00mlabs 64
        self.set_icon(icon)
65
        # FIXME
66
        # From docs: Don’t use this function. It sets the X xlib.Window
67
        # System “class” and “name” hints for a window.
68
        # But I have to do it or it doesn't shows the right title. ???
243 t00m 69
        self.set_wmclass (APP['name'], APP['name'])
70
        self.set_role(APP['name'])
4 t00mlabs 71
        self.set_default_size(1024, 728)
72
        self.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
230 t00m 73
        self.maximize ()
93 t00mlabs 74
        self.setup_headerbar()
4 t00mlabs 75
        self.show_all()
76
 
77
 
77 t00mlabs 78
    def setup_headerbar(self):
247 t00m 79
        hb = self.srvgui.add_widget('gtk_headerbar_container', Gtk.HeaderBar())
77 t00mlabs 80
        hb.set_show_close_button(True)
81
        hb.props.title = "Basico"
79 t00mlabs 82
        hb.props.subtitle = "SAP Notes Manager for SAP Consultants"
231 t00m 83
        lhbox = self.setup_headerbar_left(hb)
84
        hb.pack_start(lhbox)
180 t00m 85
        rhbox = self.setup_headerbar_right(hb)
203 t00m 86
 
180 t00m 87
        hb.pack_end(rhbox)
88
        self.set_titlebar(hb)
89
        hb.show_all()
90
 
182 t00m 91
 
180 t00m 92
    def setup_headerbar_left(self, hb):
231 t00m 93
        # ~ '''Left headerbar side not used by now'''
94
        lhbox = Gtk.HBox()
185 t00m 95
 
231 t00m 96
        ### Dashboard / Visor
97
        hbox = Gtk.HBox()
247 t00m 98
        icon = self.srvicm.get_pixbuf_icon('basico-dashboard', 24, 24)
231 t00m 99
        image = Gtk.Image()
100
        image.set_from_pixbuf(icon)
101
        label = Gtk.Label()
102
        hbox.pack_start(image, False, False, 3)
103
        hbox.pack_start(label, False, False, 3)
247 t00m 104
        button = self.srvgui.add_widget('gtk_button_dashboard', Gtk.Button())
231 t00m 105
        button.add(hbox)
106
        button.set_relief(Gtk.ReliefStyle.NONE)
107
        lhbox.pack_start(button, False, False, 0)
247 t00m 108
        button.connect('clicked', self.srvclb.gui_show_dashboard)
77 t00mlabs 109
 
231 t00m 110
        return lhbox
111
 
112
 
180 t00m 113
    def setup_headerbar_right(self, hb):
185 t00m 114
        rhbox = Gtk.HBox()
180 t00m 115
 
257 t00m 116
        ## Help togglebutton
262 t00m 117
        if self.srvuif.webkit_support():
118
            button = self.srvgui.add_widget('gtk_togglebutton_help', Gtk.ToggleButton())
119
            icon = self.srvicm.get_pixbuf_icon('basico-help', 24, 24)
120
            image = Gtk.Image()
121
            image.set_from_pixbuf(icon)
122
            button.set_image(image)
123
            button.set_relief(Gtk.ReliefStyle.NONE)
124
            button.connect('toggled', self.srvclb.gui_toggle_help_visor)
125
        else:
126
            button = self.srvgui.add_widget('gtk_button_help', Gtk.Button())
127
            icon = self.srvicm.get_pixbuf_icon('basico-help', 24, 24)
128
            image = Gtk.Image()
129
            image.set_from_pixbuf(icon)
130
            button.set_image(image)
131
            button.set_relief(Gtk.ReliefStyle.NONE)
132
            button.connect('clicked', self.srvclb.gui_lauch_help_visor)
133
 
257 t00m 134
        rhbox.pack_end(button, False, False, 0)
135
 
153 t00m 136
        ## System Menu
77 t00mlabs 137
        button = Gtk.Button()
247 t00m 138
        icon = self.srvicm.get_pixbuf_icon('basico-menu-system', 24, 24)
81 t00mlabs 139
        image = Gtk.Image()
140
        image.set_from_pixbuf(icon)
141
        button.set_image(image)
77 t00mlabs 142
        button.set_relief(Gtk.ReliefStyle.NONE)
122 t00mlabs 143
        popover = Gtk.Popover.new(button)
247 t00m 144
        self.srvgui.add_widget('gtk_popover_button_menu_system', popover)
145
        button.connect('clicked', self.srvclb.gui_show_popover, popover)
77 t00mlabs 146
        rhbox.pack_end(button, False, False, 0)
79 t00mlabs 147
 
122 t00mlabs 148
        # Popover body
149
        box = Gtk.Box(spacing = 0, orientation="vertical")
237 t00m 150
        popover.add(box)
122 t00mlabs 151
 
153 t00m 152
        ### About
122 t00mlabs 153
        hbox = Gtk.Box(spacing = 0, orientation="horizontal")
247 t00m 154
        icon = self.srvicm.get_pixbuf_icon('basico-about', 48, 48)
122 t00mlabs 155
        image = Gtk.Image()
156
        image.set_from_pixbuf(icon)
157
        label = Gtk.Label("About")
158
        hbox.pack_start(image, False, False, 3)
159
        hbox.pack_start(label, False, False, 3)
160
        button = Gtk.Button()
161
        button.add(hbox)
162
        button.set_relief(Gtk.ReliefStyle.NONE)
247 t00m 163
        button.connect('clicked', self.srvclb.gui_show_about)
122 t00mlabs 164
        box.pack_end(button, False, False, 0)
165
 
216 t00m 166
        # ~ ### Help
167
        # ~ hbox = Gtk.Box(spacing = 0, orientation="horizontal")
247 t00m 168
        # ~ icon = self.srvicm.get_pixbuf_icon('basico-help', 48, 48)
216 t00m 169
        # ~ image = Gtk.Image()
170
        # ~ image.set_from_pixbuf(icon)
171
        # ~ label = Gtk.Label("Help")
172
        # ~ hbox.pack_start(image, False, False, 3)
173
        # ~ hbox.pack_start(label, False, False, 3)
174
        # ~ button = Gtk.Button()
175
        # ~ button.add(hbox)
176
        # ~ button.set_relief(Gtk.ReliefStyle.NONE)
247 t00m 177
        # ~ button.connect('clicked', self.srvclb.gui_show_help)
216 t00m 178
        # ~ box.pack_end(button, False, False, 0)
179
 
180
        ### Log viewer
181
        hbox = Gtk.Box(spacing = 0, orientation="horizontal")
247 t00m 182
        icon = self.srvicm.get_pixbuf_icon('basico-logviewer', 48, 48)
216 t00m 183
        image = Gtk.Image()
184
        image.set_from_pixbuf(icon)
185
        label = Gtk.Label("Log viewer")
186
        hbox.pack_start(image, False, False, 3)
187
        hbox.pack_start(label, False, False, 3)
188
        button = Gtk.Button()
189
        button.add(hbox)
190
        button.set_relief(Gtk.ReliefStyle.NONE)
247 t00m 191
        button.connect('clicked', self.srvclb.gui_show_log)
216 t00m 192
        box.pack_end(button, False, False, 0)
193
 
153 t00m 194
        ### Settings
195
        hbox = Gtk.Box(spacing = 0, orientation="horizontal")
247 t00m 196
        icon = self.srvicm.get_pixbuf_icon('basico-settings', 48, 48)
81 t00mlabs 197
        image = Gtk.Image()
198
        image.set_from_pixbuf(icon)
122 t00mlabs 199
        label = Gtk.Label("Settings")
200
        hbox.pack_start(image, False, False, 3)
201
        hbox.pack_start(label, False, False, 3)
202
        button = Gtk.Button()
203
        button.add(hbox)
79 t00mlabs 204
        button.set_relief(Gtk.ReliefStyle.NONE)
247 t00m 205
        button.connect('clicked', self.srvclb.gui_show_settings)
130 t00mlabs 206
        box.pack_start(button, False, False, 0)
217 t00m 207
 
227 t00m 208
        ### Backup
209
        hbox = Gtk.Box(spacing = 0, orientation="horizontal")
247 t00m 210
        icon = self.srvicm.get_pixbuf_icon('basico-backup-restore', 48, 48)
227 t00m 211
        image = Gtk.Image()
212
        image.set_from_pixbuf(icon)
238 t00m 213
        label = Gtk.Label("Backup/Restore")
227 t00m 214
        hbox.pack_start(image, False, False, 3)
215
        hbox.pack_start(label, False, False, 3)
216
        button = Gtk.Button()
217
        button.add(hbox)
218
        button.set_relief(Gtk.ReliefStyle.NONE)
247 t00m 219
        # ~ button.connect('clicked', self.srvbnr.backup)
227 t00m 220
        box.pack_start(button, False, False, 0)
221
 
237 t00m 222
        box_bnr = Gtk.VBox()
223
        popover_bnr = Gtk.Popover.new(button)
224
        popover_bnr.set_position(Gtk.PositionType.LEFT)
225
        popover_bnr.add(box_bnr)
247 t00m 226
        self.srvgui.add_widget('gtk_popover_button_menu_system', popover_bnr)
227
        button.connect('clicked', self.srvclb.gui_show_popover, popover_bnr)
227 t00m 228
 
247 t00m 229
        button_backup = self.srvuif.create_button('basico-backup', 48, 48, '<b>Backup database</b> ')
230
        button_restore = self.srvuif.create_button('basico-restore', 48, 48, '<b>Restore from backup</b>')
231
        button_restore.connect('clicked', self.srvclb.gui_show_filechooser_restore)
232
        button_cache = self.srvuif.create_button('basico-restore', 48, 48, '<b>Restore from cache</b>')
233
        button_cache.connect('clicked', self.srvbnr.restore_from_cache)
237 t00m 234
        box_bnr.pack_start(button_backup, False, False, 0)
235
        box_bnr.pack_start(button_restore, False, False, 0)
238 t00m 236
        box_bnr.pack_start(button_cache, False, False, 0)
237 t00m 237
 
180 t00m 238
        return rhbox
77 t00mlabs 239
 
240
 
240 t00m 241
    def reveal_filechooser_restore(self, *args):
247 t00m 242
        revealer = self.srvgui.get_widget('gtk_revealer_restore')
240 t00m 243
        revealer.set_reveal_child(True)
244
 
245
 
246
    def file_chooser_button_clicked(self, filechooser):
247
        def find_child_classes(container, cls):
248
            return [widget for widget in container.get_children() if isinstance(widget, cls)]
249
 
250
        widget = find_child_classes(filechooser, Gtk.Button)
251
        self.controller.debug(widget.get_name())
252
 
253
    def file_chooser_close(self, *args):
254
        self.debug(args)
255
 
4 t00mlabs 256
    def setup_widgets(self):
137 t00mlabs 257
        # Mainbox
247 t00m 258
        mainbox = self.srvgui.add_widget('gtk_vbox_container_main', Gtk.VBox())
137 t00mlabs 259
        mainbox.set_hexpand(True)
247 t00m 260
        paned = self.srvgui.add_widget('gtk_hpaned', Gtk.HPaned())
178 t00m 261
        paned.set_property('margin-bottom', 6)
262
        paned.set_wide_handle(False)
164 t00m 263
        paned.set_position(300)
82 t00mlabs 264
 
137 t00mlabs 265
        # Paned
266
        ## Left view
247 t00m 267
        box = self.srvgui.add_widget('gtk_vbox_container_menu_view', Gtk.VBox())
166 t00m 268
        box.set_property('margin-left', 6)
269
        box.set_property('margin-right', 6)
176 t00m 270
        box.set_property('margin-bottom', 0)
166 t00m 271
 
272
        ### Toolbar
273
        toolbar = Gtk.Toolbar()
274
        toolbar.get_style_context().add_class(Gtk.STYLE_CLASS_PRIMARY_TOOLBAR)
275
 
276
        #### Filter entry tool
277
        tool = Gtk.ToolItem.new()
278
 
279
        hbox = Gtk.HBox()
247 t00m 280
        viewfilter = self.srvgui.add_widget('gtk_entry_filter_view', Gtk.Entry())
281
        completion = self.srvgui.get_widget('gtk_entrycompletion_viewmenu')
242 t00m 282
        viewfilter.set_completion(completion)
247 t00m 283
        viewfilter.connect('activate', self.srvclb.gui_viewmenu_filter)
175 t00m 284
 
247 t00m 285
        icon = self.srvicm.get_pixbuf_icon('basico-refresh')
175 t00m 286
        viewfilter.set_icon_from_pixbuf(Gtk.EntryIconPosition.PRIMARY, icon)
287
        viewfilter.set_icon_sensitive(Gtk.EntryIconPosition.PRIMARY, True)
288
        viewfilter.set_icon_tooltip_markup (Gtk.EntryIconPosition.PRIMARY, "Refresh and collapse")
289
 
247 t00m 290
        icon = self.srvicm.get_pixbuf_icon('basico-filter')
175 t00m 291
        viewfilter.set_icon_from_pixbuf(Gtk.EntryIconPosition.SECONDARY, icon)
292
        viewfilter.set_icon_sensitive(Gtk.EntryIconPosition.SECONDARY, True)
293
        viewfilter.set_icon_tooltip_markup (Gtk.EntryIconPosition.SECONDARY, "Click here to expand the tree")
294
        viewfilter.set_placeholder_text("Filter this view...")
295
 
296
        def on_icon_pressed(entry, icon_pos, event):
297
            if icon_pos == Gtk.EntryIconPosition.PRIMARY:
247 t00m 298
                viewmenu = self.srvgui.get_widget('viewmenu')
175 t00m 299
                viewmenu.refresh()
300
            elif icon_pos == Gtk.EntryIconPosition.SECONDARY:
247 t00m 301
                self.srvclb.expand_menuview()
175 t00m 302
 
303
        viewfilter.connect("icon-press", on_icon_pressed)
304
 
166 t00m 305
        hbox.pack_start(viewfilter, True, True, 0)
306
        tool.add(hbox)
307
        tool.set_expand(True)
308
        toolbar.insert(tool, -1)
309
 
310
        box.pack_start(toolbar, False, False, 0)
311
 
185 t00m 312
        ### View treeview
137 t00mlabs 313
        scr = Gtk.ScrolledWindow()
314
        scr.set_hexpand(True)
315
        scr.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
164 t00m 316
        scr.set_shadow_type(Gtk.ShadowType.IN)
137 t00mlabs 317
        vwp = Gtk.Viewport()
318
        vwp.set_hexpand(True)
247 t00m 319
        viewsbox = self.srvgui.add_widget('gtk_box_container_views', Gtk.Box())
137 t00mlabs 320
        viewsbox.set_hexpand(True)
321
        vwp.add(viewsbox)
322
        scr.add(vwp)
166 t00m 323
        box.pack_start(scr, True, True, 0)
137 t00mlabs 324
        paned.add1(box)
82 t00mlabs 325
 
137 t00mlabs 326
        ## Right view
213 t00m 327
        box = Gtk.VBox()
137 t00mlabs 328
        box.set_hexpand(True)
247 t00m 329
        stack_main = self.srvgui.add_widget('gtk_stack_main', Gtk.Stack())
220 t00m 330
        stack_main.set_transition_type(Gtk.StackTransitionType.SLIDE_LEFT_RIGHT)
331
        stack_main.set_transition_duration(2500)
332
        box.pack_start(stack_main, True, True, 0)
168 t00m 333
 
216 t00m 334
        ### Visor stack
220 t00m 335
        stack_child = self.setup_stack_visor()
336
        stack_main.add_titled(stack_child, "visor", "SAP Notes Visor")
168 t00m 337
 
254 t00m 338
        ### SAP Note Visor tab
339
        # ~ tab_sapnote_visor = self.setup_tab_sapnote_visor()
340
        # ~ stack_main.add_titled(stack_child, "visor", "SAP Notes Visor")
341
 
342
        ### Annotation Visor tab
343
        # ~ tab_annotation_visor = self.setup_tab_annotations_visor()
344
        # ~ stack_main.add_titled(stack_child, "visor", "SAP Notes Visor")
345
 
215 t00m 346
        ### About stack
220 t00m 347
        stack_child = self.setup_stack_about()
348
        stack_main.add_titled(stack_child, "about", "About Basico")
207 t00m 349
 
220 t00m 350
        ### Log stack
351
        stack_child = self.setup_stack_log()
352
        stack_main.add_titled(stack_child, "log", "Log Viewer")
216 t00m 353
 
215 t00m 354
        ### Settings stack
220 t00m 355
        stack_child = self.setup_stack_settings()
356
        stack_main.add_titled(stack_child, "settings", "Basico Settings")
215 t00m 357
 
218 t00m 358
        ## Annotations
247 t00m 359
        boxannotations = self.srvgui.add_widget('gtk_vbox_container_annotations', Gtk.VBox())
220 t00m 360
 
247 t00m 361
        stack_annot = self.srvgui.add_widget('gtk_stack_annotation', Gtk.Stack())
220 t00m 362
        stack_annot.set_transition_type(Gtk.StackTransitionType.SLIDE_LEFT_RIGHT)
363
        stack_annot.set_transition_duration(2500)
364
 
365
        stack_child = self.setup_stack_annotation()
366
        stack_annot.add_titled(stack_child, "comment", "New comment")
367
        stack_annot.child_set_property (stack_child, "icon-name", "basico-comments")
368
 
369
        # ~ stack_child = self.setup_stack_annotation_link()
370
        # ~ stack_annot.add_titled(stack_child, "link", "New link")
371
        # ~ stack_annot.child_set_property (stack_child, "icon-name", "basico-browse")
372
 
247 t00m 373
        self.srvuif.set_widget_visibility('gtk_vbox_container_annotations', False)
220 t00m 374
        boxannotations.add(stack_annot)
375
 
376
 
218 t00m 377
        box.pack_start(boxannotations, True, True, 6)
137 t00mlabs 378
        paned.add2(box)
142 t00mlabs 379
        mainbox.pack_start(paned, True, True, 0)
82 t00mlabs 380
 
162 t00m 381
        # Statusbar
247 t00m 382
        statusbar = self.srvgui.add_widget('widget_statusbar', Statusbar(self.controller))
142 t00mlabs 383
        mainbox.pack_start(statusbar, False, False, 0)
384
 
203 t00m 385
        # Menu Views
386
        vbox = Gtk.VBox()
247 t00m 387
        viewsbox = self.srvgui.get_widget('gtk_box_container_views')
388
        viewmenu = self.srvgui.add_widget('viewmenu', SAPNoteViewMenu(self.controller))
203 t00m 389
        viewmenu.set_hexpand(True)
390
        viewmenu.set_vexpand(True)
391
        vbox.pack_start(viewmenu, True, True, 0)
247 t00m 392
        self.srvgui.swap_widget(viewsbox, vbox)
203 t00m 393
 
137 t00mlabs 394
        self.add(mainbox)
395
        self.show_all()
82 t00mlabs 396
 
397
 
214 t00m 398
    def setup_stack_visor(self):
399
        box = Gtk.VBox()
400
        box.set_hexpand(True)
401
 
402
        ### Toolbar
247 t00m 403
        boxtoolbar = self.srvgui.add_widget('gtk_hbox_container_toolbar', Gtk.HBox())
214 t00m 404
        box.pack_start(boxtoolbar, False, False, 0)
254 t00m 405
        visortoolbar = self.srvgui.add_widget('visortoolbar', VisorToolbar(self.controller))
247 t00m 406
        self.srvgui.swap_widget(boxtoolbar, visortoolbar)
214 t00m 407
 
408
        ### Visor
254 t00m 409
        notebook = self.srvgui.add_widget('gtk_notebook_visor', Gtk.Notebook())
255 t00m 410
        notebook.connect('switch-page', self.srvclb.gui_visor_switch_page)
411
        notebook.set_show_border(False)
412
        notebook.set_hexpand(True)
254 t00m 413
 
414
 
255 t00m 415
        visor_sapnotes_page = self.setup_tab_sapnote_visor()
416
        visor_sapnotes_page.set_hexpand(True)
417
        tab_widget = self.srvuif.create_notebook_tab_label('basico-sapnote', '<b>SAP Notes</b>')
418
        notebook.append_page(visor_sapnotes_page, tab_widget)
419
 
254 t00m 420
        visor_annotations_page = self.setup_tab_annotations_visor()
255 t00m 421
        tab_widget = self.srvuif.create_notebook_tab_label('basico-annotation', '<b>Annotations</b>')
422
        notebook.append_page(visor_annotations_page, tab_widget)
423
 
262 t00m 424
        if self.srvuif.webkit_support():
425
            visor_help_page = self.srvgui.add_widget('gtk_notebook_help_page', self.setup_tab_help_visor())
426
            visor_help_page.set_hexpand(True)
427
            tab_widget = self.srvuif.create_notebook_tab_label('basico-help', '<b>Help</b>')
428
            notebook.append_page(visor_help_page, tab_widget)
429
            self.srvuif.set_widget_visibility('gtk_notebook_help_page', False)
430
            notebook.child_set_property(visor_help_page, "tab-expand", True)
431
            notebook.child_set_property(visor_help_page, "tab-fill", False)
257 t00m 432
 
433
 
255 t00m 434
        notebook.child_set_property(visor_sapnotes_page, "tab-expand", True)
435
        notebook.child_set_property(visor_sapnotes_page, "tab-fill", False)
436
        notebook.child_set_property(visor_annotations_page, "tab-expand", True)
437
        notebook.child_set_property(visor_annotations_page, "tab-fill", False)
438
 
262 t00m 439
 
254 t00m 440
        box.pack_start(notebook, True, True, 0)
441
 
442
        return box
443
 
257 t00m 444
    def setup_tab_help_visor(self):
262 t00m 445
        from basico.widgets.wdg_browser import BasicoBrowser
257 t00m 446
        box = Gtk.VBox()
447
        box.set_hexpand(True)
448
 
449
        ### Help Visor
259 t00m 450
        browser = BasicoBrowser()
261 t00m 451
        self.controller.debug(FILE['HELP_INDEX'])
452
        browser.load_url("file://%s" % FILE['HELP_INDEX'])
259 t00m 453
        box.pack_start(browser, True, True, 0)
257 t00m 454
        box.show_all()
455
        return box
456
 
457
 
254 t00m 458
    def setup_tab_sapnote_visor(self):
459
        box = Gtk.VBox()
460
        box.set_hexpand(True)
461
 
462
        # ~ ### Toolbar
463
        # ~ boxtoolbar = self.srvgui.add_widget('gtk_hbox_container_toolbar', Gtk.HBox())
464
        # ~ box.pack_start(boxtoolbar, False, False, 0)
465
        # ~ visortoolbar = self.srvgui.add_widget('visortoolbar', SAPNoteViewVisorToolbar(self.controller))
466
        # ~ self.srvgui.swap_widget(boxtoolbar, visortoolbar)
467
 
468
        ### Visor
214 t00m 469
        scr = Gtk.ScrolledWindow()
470
        scr.set_hexpand(True)
471
        scr.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
255 t00m 472
        scr.set_shadow_type(Gtk.ShadowType.NONE)
214 t00m 473
        vwp = Gtk.Viewport()
474
        vwp.set_hexpand(True)
254 t00m 475
        visor = self.srvgui.add_widget('visor_sapnotes', SAPNotesVisor(self.controller))
214 t00m 476
        visor.set_hexpand(True)
477
        visor.set_vexpand(True)
478
        vwp.add(visor)
479
        scr.add(vwp)
480
        box.pack_start(scr, True, True, 0)
481
        visor.show_all()
482
        box.show_all()
483
        return box
215 t00m 484
 
485
 
254 t00m 486
    def setup_tab_annotations_visor(self):
487
        box = Gtk.VBox()
488
        box.set_hexpand(True)
489
 
490
        # ~ ### Toolbar
491
        # ~ boxtoolbar = self.srvgui.add_widget('gtk_hbox_container_toolbar', Gtk.HBox())
492
        # ~ box.pack_start(boxtoolbar, False, False, 0)
493
        # ~ visortoolbar = self.srvgui.add_widget('visortoolbar', SAPNoteViewVisorToolbar(self.controller))
494
        # ~ self.srvgui.swap_widget(boxtoolbar, visortoolbar)
495
 
496
        ### Visor
497
        scr = Gtk.ScrolledWindow()
498
        scr.set_hexpand(True)
499
        scr.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
255 t00m 500
        scr.set_shadow_type(Gtk.ShadowType.NONE)
254 t00m 501
        vwp = Gtk.Viewport()
502
        vwp.set_hexpand(True)
503
        visor = self.srvgui.add_widget('visor_annotations', AnnotationsVisor(self.controller))
504
        visor.set_hexpand(True)
505
        visor.set_vexpand(True)
506
        vwp.add(visor)
507
        scr.add(vwp)
508
        box.pack_start(scr, True, True, 0)
509
        visor.show_all()
510
        box.show_all()
511
        return box
512
 
215 t00m 513
    def setup_stack_about(self):
514
        box = Gtk.VBox()
515
        box.set_hexpand(True)
247 t00m 516
        about = self.srvgui.add_widget('widget_about', About())
216 t00m 517
        box.pack_start(about, True, True, 0)
215 t00m 518
        box.show_all()
519
        return box
520
 
521
 
522
    def setup_stack_settings(self):
523
        box = Gtk.VBox()
524
        box.set_hexpand(True)
247 t00m 525
        settings = self.srvgui.add_widget('widget_settings', SettingsView(self.controller))
215 t00m 526
        box.pack_start(settings, True, True, 0)
527
        box.show_all()
528
        return box
216 t00m 529
 
530
    def setup_stack_log(self):
531
        box = Gtk.VBox()
532
        box.set_hexpand(True)
247 t00m 533
        logviewer = self.srvgui.add_widget('widget_logviewer', LogViewer(self.controller))
216 t00m 534
        box.pack_start(logviewer, True, True, 0)
535
        box.show_all()
536
        return box
220 t00m 537
 
538
 
539
    def setup_stack_annotation(self):
247 t00m 540
        return self.srvgui.add_widget('widget_annotation', AnnotationWidget(self.controller))
230 t00m 541
 
542
 
543
    def run(self):
255 t00m 544
        visor_annotations = self.srvgui.get_widget('visor_annotations')
247 t00m 545
        viewmenu = self.srvgui.get_widget('viewmenu')
255 t00m 546
        viewmenu.set_view('collection')
247 t00m 547
        self.srvclb.gui_show_dashboard()
255 t00m 548
        annotations = self.srvant.search_term('')
549
        visor_annotations.populate_annotations(annotations)