Subversion Repositories basico

Rev

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