Subversion Repositories basico

Rev

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