Subversion Repositories basico

Rev

Rev 254 | Rev 257 | 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
 
243 t00m 24
from basico.core.mod_env import APP
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
 
243 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
 
153 t00m 116
        ## System Menu
77 t00mlabs 117
        button = Gtk.Button()
247 t00m 118
        icon = self.srvicm.get_pixbuf_icon('basico-menu-system', 24, 24)
81 t00mlabs 119
        image = Gtk.Image()
120
        image.set_from_pixbuf(icon)
121
        button.set_image(image)
77 t00mlabs 122
        button.set_relief(Gtk.ReliefStyle.NONE)
122 t00mlabs 123
        popover = Gtk.Popover.new(button)
247 t00m 124
        self.srvgui.add_widget('gtk_popover_button_menu_system', popover)
125
        button.connect('clicked', self.srvclb.gui_show_popover, popover)
77 t00mlabs 126
        rhbox.pack_end(button, False, False, 0)
79 t00mlabs 127
 
122 t00mlabs 128
        # Popover body
129
        box = Gtk.Box(spacing = 0, orientation="vertical")
237 t00m 130
        popover.add(box)
122 t00mlabs 131
 
153 t00m 132
        ### About
122 t00mlabs 133
        hbox = Gtk.Box(spacing = 0, orientation="horizontal")
247 t00m 134
        icon = self.srvicm.get_pixbuf_icon('basico-about', 48, 48)
122 t00mlabs 135
        image = Gtk.Image()
136
        image.set_from_pixbuf(icon)
137
        label = Gtk.Label("About")
138
        hbox.pack_start(image, False, False, 3)
139
        hbox.pack_start(label, False, False, 3)
140
        button = Gtk.Button()
141
        button.add(hbox)
142
        button.set_relief(Gtk.ReliefStyle.NONE)
247 t00m 143
        button.connect('clicked', self.srvclb.gui_show_about)
122 t00mlabs 144
        box.pack_end(button, False, False, 0)
145
 
216 t00m 146
        # ~ ### Help
147
        # ~ hbox = Gtk.Box(spacing = 0, orientation="horizontal")
247 t00m 148
        # ~ icon = self.srvicm.get_pixbuf_icon('basico-help', 48, 48)
216 t00m 149
        # ~ image = Gtk.Image()
150
        # ~ image.set_from_pixbuf(icon)
151
        # ~ label = Gtk.Label("Help")
152
        # ~ hbox.pack_start(image, False, False, 3)
153
        # ~ hbox.pack_start(label, False, False, 3)
154
        # ~ button = Gtk.Button()
155
        # ~ button.add(hbox)
156
        # ~ button.set_relief(Gtk.ReliefStyle.NONE)
247 t00m 157
        # ~ button.connect('clicked', self.srvclb.gui_show_help)
216 t00m 158
        # ~ box.pack_end(button, False, False, 0)
159
 
160
        ### Log viewer
161
        hbox = Gtk.Box(spacing = 0, orientation="horizontal")
247 t00m 162
        icon = self.srvicm.get_pixbuf_icon('basico-logviewer', 48, 48)
216 t00m 163
        image = Gtk.Image()
164
        image.set_from_pixbuf(icon)
165
        label = Gtk.Label("Log viewer")
166
        hbox.pack_start(image, False, False, 3)
167
        hbox.pack_start(label, False, False, 3)
168
        button = Gtk.Button()
169
        button.add(hbox)
170
        button.set_relief(Gtk.ReliefStyle.NONE)
247 t00m 171
        button.connect('clicked', self.srvclb.gui_show_log)
216 t00m 172
        box.pack_end(button, False, False, 0)
173
 
153 t00m 174
        ### Settings
175
        hbox = Gtk.Box(spacing = 0, orientation="horizontal")
247 t00m 176
        icon = self.srvicm.get_pixbuf_icon('basico-settings', 48, 48)
81 t00mlabs 177
        image = Gtk.Image()
178
        image.set_from_pixbuf(icon)
122 t00mlabs 179
        label = Gtk.Label("Settings")
180
        hbox.pack_start(image, False, False, 3)
181
        hbox.pack_start(label, False, False, 3)
182
        button = Gtk.Button()
183
        button.add(hbox)
79 t00mlabs 184
        button.set_relief(Gtk.ReliefStyle.NONE)
247 t00m 185
        button.connect('clicked', self.srvclb.gui_show_settings)
130 t00mlabs 186
        box.pack_start(button, False, False, 0)
217 t00m 187
 
227 t00m 188
        ### Backup
189
        hbox = Gtk.Box(spacing = 0, orientation="horizontal")
247 t00m 190
        icon = self.srvicm.get_pixbuf_icon('basico-backup-restore', 48, 48)
227 t00m 191
        image = Gtk.Image()
192
        image.set_from_pixbuf(icon)
238 t00m 193
        label = Gtk.Label("Backup/Restore")
227 t00m 194
        hbox.pack_start(image, False, False, 3)
195
        hbox.pack_start(label, False, False, 3)
196
        button = Gtk.Button()
197
        button.add(hbox)
198
        button.set_relief(Gtk.ReliefStyle.NONE)
247 t00m 199
        # ~ button.connect('clicked', self.srvbnr.backup)
227 t00m 200
        box.pack_start(button, False, False, 0)
201
 
237 t00m 202
        box_bnr = Gtk.VBox()
203
        popover_bnr = Gtk.Popover.new(button)
204
        popover_bnr.set_position(Gtk.PositionType.LEFT)
205
        popover_bnr.add(box_bnr)
247 t00m 206
        self.srvgui.add_widget('gtk_popover_button_menu_system', popover_bnr)
207
        button.connect('clicked', self.srvclb.gui_show_popover, popover_bnr)
227 t00m 208
 
247 t00m 209
        button_backup = self.srvuif.create_button('basico-backup', 48, 48, '<b>Backup database</b> ')
210
        button_restore = self.srvuif.create_button('basico-restore', 48, 48, '<b>Restore from backup</b>')
211
        button_restore.connect('clicked', self.srvclb.gui_show_filechooser_restore)
212
        button_cache = self.srvuif.create_button('basico-restore', 48, 48, '<b>Restore from cache</b>')
213
        button_cache.connect('clicked', self.srvbnr.restore_from_cache)
237 t00m 214
        box_bnr.pack_start(button_backup, False, False, 0)
215
        box_bnr.pack_start(button_restore, False, False, 0)
238 t00m 216
        box_bnr.pack_start(button_cache, False, False, 0)
237 t00m 217
 
180 t00m 218
        return rhbox
77 t00mlabs 219
 
220
 
240 t00m 221
    def reveal_filechooser_restore(self, *args):
247 t00m 222
        revealer = self.srvgui.get_widget('gtk_revealer_restore')
240 t00m 223
        revealer.set_reveal_child(True)
224
 
225
 
226
    def file_chooser_button_clicked(self, filechooser):
227
        def find_child_classes(container, cls):
228
            return [widget for widget in container.get_children() if isinstance(widget, cls)]
229
 
230
        widget = find_child_classes(filechooser, Gtk.Button)
231
        self.controller.debug(widget.get_name())
232
 
233
    def file_chooser_close(self, *args):
234
        self.debug(args)
235
 
4 t00mlabs 236
    def setup_widgets(self):
137 t00mlabs 237
        # Mainbox
247 t00m 238
        mainbox = self.srvgui.add_widget('gtk_vbox_container_main', Gtk.VBox())
137 t00mlabs 239
        mainbox.set_hexpand(True)
247 t00m 240
        paned = self.srvgui.add_widget('gtk_hpaned', Gtk.HPaned())
178 t00m 241
        paned.set_property('margin-bottom', 6)
242
        paned.set_wide_handle(False)
164 t00m 243
        paned.set_position(300)
82 t00mlabs 244
 
137 t00mlabs 245
        # Paned
246
        ## Left view
247 t00m 247
        box = self.srvgui.add_widget('gtk_vbox_container_menu_view', Gtk.VBox())
166 t00m 248
        box.set_property('margin-left', 6)
249
        box.set_property('margin-right', 6)
176 t00m 250
        box.set_property('margin-bottom', 0)
166 t00m 251
 
252
        ### Toolbar
253
        toolbar = Gtk.Toolbar()
254
        toolbar.get_style_context().add_class(Gtk.STYLE_CLASS_PRIMARY_TOOLBAR)
255
 
256
        #### Filter entry tool
257
        tool = Gtk.ToolItem.new()
258
 
259
        hbox = Gtk.HBox()
247 t00m 260
        viewfilter = self.srvgui.add_widget('gtk_entry_filter_view', Gtk.Entry())
261
        completion = self.srvgui.get_widget('gtk_entrycompletion_viewmenu')
242 t00m 262
        viewfilter.set_completion(completion)
247 t00m 263
        viewfilter.connect('activate', self.srvclb.gui_viewmenu_filter)
175 t00m 264
 
247 t00m 265
        icon = self.srvicm.get_pixbuf_icon('basico-refresh')
175 t00m 266
        viewfilter.set_icon_from_pixbuf(Gtk.EntryIconPosition.PRIMARY, icon)
267
        viewfilter.set_icon_sensitive(Gtk.EntryIconPosition.PRIMARY, True)
268
        viewfilter.set_icon_tooltip_markup (Gtk.EntryIconPosition.PRIMARY, "Refresh and collapse")
269
 
247 t00m 270
        icon = self.srvicm.get_pixbuf_icon('basico-filter')
175 t00m 271
        viewfilter.set_icon_from_pixbuf(Gtk.EntryIconPosition.SECONDARY, icon)
272
        viewfilter.set_icon_sensitive(Gtk.EntryIconPosition.SECONDARY, True)
273
        viewfilter.set_icon_tooltip_markup (Gtk.EntryIconPosition.SECONDARY, "Click here to expand the tree")
274
        viewfilter.set_placeholder_text("Filter this view...")
275
 
276
        def on_icon_pressed(entry, icon_pos, event):
277
            if icon_pos == Gtk.EntryIconPosition.PRIMARY:
247 t00m 278
                viewmenu = self.srvgui.get_widget('viewmenu')
175 t00m 279
                viewmenu.refresh()
280
            elif icon_pos == Gtk.EntryIconPosition.SECONDARY:
247 t00m 281
                self.srvclb.expand_menuview()
175 t00m 282
 
283
        viewfilter.connect("icon-press", on_icon_pressed)
284
 
166 t00m 285
        hbox.pack_start(viewfilter, True, True, 0)
286
        tool.add(hbox)
287
        tool.set_expand(True)
288
        toolbar.insert(tool, -1)
289
 
290
        box.pack_start(toolbar, False, False, 0)
291
 
185 t00m 292
        ### View treeview
137 t00mlabs 293
        scr = Gtk.ScrolledWindow()
294
        scr.set_hexpand(True)
295
        scr.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
164 t00m 296
        scr.set_shadow_type(Gtk.ShadowType.IN)
137 t00mlabs 297
        vwp = Gtk.Viewport()
298
        vwp.set_hexpand(True)
247 t00m 299
        viewsbox = self.srvgui.add_widget('gtk_box_container_views', Gtk.Box())
137 t00mlabs 300
        viewsbox.set_hexpand(True)
301
        vwp.add(viewsbox)
302
        scr.add(vwp)
166 t00m 303
        box.pack_start(scr, True, True, 0)
137 t00mlabs 304
        paned.add1(box)
82 t00mlabs 305
 
137 t00mlabs 306
        ## Right view
213 t00m 307
        box = Gtk.VBox()
137 t00mlabs 308
        box.set_hexpand(True)
247 t00m 309
        stack_main = self.srvgui.add_widget('gtk_stack_main', Gtk.Stack())
220 t00m 310
        stack_main.set_transition_type(Gtk.StackTransitionType.SLIDE_LEFT_RIGHT)
311
        stack_main.set_transition_duration(2500)
312
        box.pack_start(stack_main, True, True, 0)
168 t00m 313
 
216 t00m 314
        ### Visor stack
220 t00m 315
        stack_child = self.setup_stack_visor()
316
        stack_main.add_titled(stack_child, "visor", "SAP Notes Visor")
168 t00m 317
 
254 t00m 318
        ### SAP Note Visor tab
319
        # ~ tab_sapnote_visor = self.setup_tab_sapnote_visor()
320
        # ~ stack_main.add_titled(stack_child, "visor", "SAP Notes Visor")
321
 
322
        ### Annotation Visor tab
323
        # ~ tab_annotation_visor = self.setup_tab_annotations_visor()
324
        # ~ stack_main.add_titled(stack_child, "visor", "SAP Notes Visor")
325
 
215 t00m 326
        ### About stack
220 t00m 327
        stack_child = self.setup_stack_about()
328
        stack_main.add_titled(stack_child, "about", "About Basico")
207 t00m 329
 
220 t00m 330
        ### Log stack
331
        stack_child = self.setup_stack_log()
332
        stack_main.add_titled(stack_child, "log", "Log Viewer")
216 t00m 333
 
215 t00m 334
        ### Settings stack
220 t00m 335
        stack_child = self.setup_stack_settings()
336
        stack_main.add_titled(stack_child, "settings", "Basico Settings")
215 t00m 337
 
218 t00m 338
        ## Annotations
247 t00m 339
        boxannotations = self.srvgui.add_widget('gtk_vbox_container_annotations', Gtk.VBox())
220 t00m 340
 
247 t00m 341
        stack_annot = self.srvgui.add_widget('gtk_stack_annotation', Gtk.Stack())
220 t00m 342
        stack_annot.set_transition_type(Gtk.StackTransitionType.SLIDE_LEFT_RIGHT)
343
        stack_annot.set_transition_duration(2500)
344
 
345
        stack_child = self.setup_stack_annotation()
346
        stack_annot.add_titled(stack_child, "comment", "New comment")
347
        stack_annot.child_set_property (stack_child, "icon-name", "basico-comments")
348
 
349
        # ~ stack_child = self.setup_stack_annotation_link()
350
        # ~ stack_annot.add_titled(stack_child, "link", "New link")
351
        # ~ stack_annot.child_set_property (stack_child, "icon-name", "basico-browse")
352
 
247 t00m 353
        self.srvuif.set_widget_visibility('gtk_vbox_container_annotations', False)
220 t00m 354
        boxannotations.add(stack_annot)
355
 
356
 
218 t00m 357
        box.pack_start(boxannotations, True, True, 6)
137 t00mlabs 358
        paned.add2(box)
142 t00mlabs 359
        mainbox.pack_start(paned, True, True, 0)
82 t00mlabs 360
 
162 t00m 361
        # Statusbar
247 t00m 362
        statusbar = self.srvgui.add_widget('widget_statusbar', Statusbar(self.controller))
142 t00mlabs 363
        mainbox.pack_start(statusbar, False, False, 0)
364
 
203 t00m 365
        # Menu Views
366
        vbox = Gtk.VBox()
247 t00m 367
        viewsbox = self.srvgui.get_widget('gtk_box_container_views')
368
        viewmenu = self.srvgui.add_widget('viewmenu', SAPNoteViewMenu(self.controller))
203 t00m 369
        viewmenu.set_hexpand(True)
370
        viewmenu.set_vexpand(True)
371
        vbox.pack_start(viewmenu, True, True, 0)
247 t00m 372
        self.srvgui.swap_widget(viewsbox, vbox)
203 t00m 373
 
137 t00mlabs 374
        self.add(mainbox)
375
        self.show_all()
82 t00mlabs 376
 
377
 
214 t00m 378
    def setup_stack_visor(self):
379
        box = Gtk.VBox()
380
        box.set_hexpand(True)
381
 
382
        ### Toolbar
247 t00m 383
        boxtoolbar = self.srvgui.add_widget('gtk_hbox_container_toolbar', Gtk.HBox())
214 t00m 384
        box.pack_start(boxtoolbar, False, False, 0)
254 t00m 385
        visortoolbar = self.srvgui.add_widget('visortoolbar', VisorToolbar(self.controller))
247 t00m 386
        self.srvgui.swap_widget(boxtoolbar, visortoolbar)
214 t00m 387
 
388
        ### Visor
254 t00m 389
        notebook = self.srvgui.add_widget('gtk_notebook_visor', Gtk.Notebook())
255 t00m 390
        notebook.connect('switch-page', self.srvclb.gui_visor_switch_page)
391
        notebook.set_show_border(False)
392
        notebook.set_hexpand(True)
254 t00m 393
 
394
 
255 t00m 395
        visor_sapnotes_page = self.setup_tab_sapnote_visor()
396
        visor_sapnotes_page.set_hexpand(True)
397
        tab_widget = self.srvuif.create_notebook_tab_label('basico-sapnote', '<b>SAP Notes</b>')
398
        notebook.append_page(visor_sapnotes_page, tab_widget)
399
 
254 t00m 400
        visor_annotations_page = self.setup_tab_annotations_visor()
255 t00m 401
        tab_widget = self.srvuif.create_notebook_tab_label('basico-annotation', '<b>Annotations</b>')
402
        notebook.append_page(visor_annotations_page, tab_widget)
403
 
404
        notebook.child_set_property(visor_sapnotes_page, "tab-expand", True)
405
        notebook.child_set_property(visor_sapnotes_page, "tab-fill", False)
406
        notebook.child_set_property(visor_annotations_page, "tab-expand", True)
407
        notebook.child_set_property(visor_annotations_page, "tab-fill", False)
408
 
254 t00m 409
        box.pack_start(notebook, True, True, 0)
410
 
411
        return box
412
 
413
    def setup_tab_sapnote_visor(self):
414
        box = Gtk.VBox()
415
        box.set_hexpand(True)
416
 
417
        # ~ ### Toolbar
418
        # ~ boxtoolbar = self.srvgui.add_widget('gtk_hbox_container_toolbar', Gtk.HBox())
419
        # ~ box.pack_start(boxtoolbar, False, False, 0)
420
        # ~ visortoolbar = self.srvgui.add_widget('visortoolbar', SAPNoteViewVisorToolbar(self.controller))
421
        # ~ self.srvgui.swap_widget(boxtoolbar, visortoolbar)
422
 
423
        ### Visor
214 t00m 424
        scr = Gtk.ScrolledWindow()
425
        scr.set_hexpand(True)
426
        scr.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
255 t00m 427
        scr.set_shadow_type(Gtk.ShadowType.NONE)
214 t00m 428
        vwp = Gtk.Viewport()
429
        vwp.set_hexpand(True)
254 t00m 430
        visor = self.srvgui.add_widget('visor_sapnotes', SAPNotesVisor(self.controller))
214 t00m 431
        visor.set_hexpand(True)
432
        visor.set_vexpand(True)
433
        vwp.add(visor)
434
        scr.add(vwp)
435
        box.pack_start(scr, True, True, 0)
436
        visor.show_all()
437
        box.show_all()
438
        return box
215 t00m 439
 
440
 
254 t00m 441
    def setup_tab_annotations_visor(self):
442
        box = Gtk.VBox()
443
        box.set_hexpand(True)
444
 
445
        # ~ ### Toolbar
446
        # ~ boxtoolbar = self.srvgui.add_widget('gtk_hbox_container_toolbar', Gtk.HBox())
447
        # ~ box.pack_start(boxtoolbar, False, False, 0)
448
        # ~ visortoolbar = self.srvgui.add_widget('visortoolbar', SAPNoteViewVisorToolbar(self.controller))
449
        # ~ self.srvgui.swap_widget(boxtoolbar, visortoolbar)
450
 
451
        ### Visor
452
        scr = Gtk.ScrolledWindow()
453
        scr.set_hexpand(True)
454
        scr.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
255 t00m 455
        scr.set_shadow_type(Gtk.ShadowType.NONE)
254 t00m 456
        vwp = Gtk.Viewport()
457
        vwp.set_hexpand(True)
458
        visor = self.srvgui.add_widget('visor_annotations', AnnotationsVisor(self.controller))
459
        visor.set_hexpand(True)
460
        visor.set_vexpand(True)
461
        vwp.add(visor)
462
        scr.add(vwp)
463
        box.pack_start(scr, True, True, 0)
464
        visor.show_all()
465
        box.show_all()
466
        return box
467
 
215 t00m 468
    def setup_stack_about(self):
469
        box = Gtk.VBox()
470
        box.set_hexpand(True)
247 t00m 471
        about = self.srvgui.add_widget('widget_about', About())
216 t00m 472
        box.pack_start(about, True, True, 0)
215 t00m 473
        box.show_all()
474
        return box
475
 
476
 
477
    def setup_stack_settings(self):
478
        box = Gtk.VBox()
479
        box.set_hexpand(True)
247 t00m 480
        settings = self.srvgui.add_widget('widget_settings', SettingsView(self.controller))
215 t00m 481
        box.pack_start(settings, True, True, 0)
482
        box.show_all()
483
        return box
216 t00m 484
 
485
    def setup_stack_log(self):
486
        box = Gtk.VBox()
487
        box.set_hexpand(True)
247 t00m 488
        logviewer = self.srvgui.add_widget('widget_logviewer', LogViewer(self.controller))
216 t00m 489
        box.pack_start(logviewer, True, True, 0)
490
        box.show_all()
491
        return box
220 t00m 492
 
493
 
494
    def setup_stack_annotation(self):
247 t00m 495
        return self.srvgui.add_widget('widget_annotation', AnnotationWidget(self.controller))
230 t00m 496
 
497
 
498
    def run(self):
255 t00m 499
        visor_annotations = self.srvgui.get_widget('visor_annotations')
247 t00m 500
        viewmenu = self.srvgui.get_widget('viewmenu')
255 t00m 501
        viewmenu.set_view('collection')
247 t00m 502
        self.srvclb.gui_show_dashboard()
255 t00m 503
        annotations = self.srvant.search_term('')
504
        visor_annotations.populate_annotations(annotations)