Subversion Repositories basico

Rev

Rev 232 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 232 Rev 233
Line 14... Line 14...
14
from gi.repository import Gtk
14
from gi.repository import Gtk
15
15
16
16
17
from concurrent.futures import ThreadPoolExecutor as Executor
17
from concurrent.futures import ThreadPoolExecutor as Executor
18
18
19
from .service import Service
-
 
20
from .sapnoteviewvisor import SAPNoteViewVisor, SAPNoteViewVisorToolbar
-
 
21
from .widgets.collections import CollectionsMgtView
-
 
22
from .widgets.annotation import AnnotationWidget
-
 
23
from .widgets.settings import SettingsView
-
 
24
from .env import FILE, LPATH
-
 
-
 
19
from basico.core.service import Service
-
 
20
from basico.widgets.sapnoteviewvisor import SAPNoteViewVisor, SAPNoteViewVisorToolbar
-
 
21
from basico.widgets.collections import CollectionsMgtView
-
 
22
from basico.widgets.annotation import AnnotationWidget
-
 
23
from basico.widgets.settings import SettingsView
-
 
24
from basico.core.env import FILE, LPATH
25
25
26
26
27
# PROPKEYS = CSV headers. SAP Note metadata
27
# PROPKEYS = CSV headers. SAP Note metadata
28
PROPKEYS = ['id', 'title', 'type', 'componentkey',
28
PROPKEYS = ['id', 'title', 'type', 'componentkey',
29
            'componenttxt', 'category', 'priority', 'releaseon',
29
            'componenttxt', 'category', 'priority', 'releaseon',
Line 48... Line 48...
48
        self.annot = self.app.get_service('Annotation')
48
        self.annot = self.app.get_service('Annotation')
49
49
50
50
51
    def action_search(self, entry):
51
    def action_search(self, entry):
52
        visor = self.gui.get_widget('visor')
52
        visor = self.gui.get_widget('visor')
-
 
53
        viewmenu = self.gui.get_widget('viewmenu')
-
 
54
        view = viewmenu.get_view()
53
55
54
        term = entry.get_text()
-
 
55
        bag = self.db.search(term)
-
 
56
        visor.populate(bag)
-
 
-
 
56
        if view != 'annotation':
-
 
57
            term = entry.get_text()
-
 
58
            bag = self.db.search(term)
-
 
59
            visor.populate(bag)
57
60
58
61
59
    def sapnote_browse(self, button, sid):
62
    def sapnote_browse(self, button, sid):
60
        self.debug("Browsing SAP Note %d" % int(sid))
63
        self.debug("Browsing SAP Note %d" % int(sid))
61
        SAP_NOTE_URL = self.settings.get('SAP', 'SAP_NOTE_URL')
64
        SAP_NOTE_URL = self.settings.get('SAP', 'SAP_NOTE_URL')
Line 89... Line 92...
89
    def gui_show_about(self, *args):
92
    def gui_show_about(self, *args):
90
        stack = self.gui.get_widget('gtk_stack_main')
93
        stack = self.gui.get_widget('gtk_stack_main')
91
        stack.set_visible_child_name('about')
94
        stack.set_visible_child_name('about')
92
        self.gui_toggle_menu_view(False)
95
        self.gui_toggle_menu_view(False)
93
        self.gui_hide_popover(self.gui.get_widget('gtk_popover_button_menu_system'))
96
        self.gui_hide_popover(self.gui.get_widget('gtk_popover_button_menu_system'))
94
        button = self.gui.get_widget('gtk_button_total_notes')
-
 
95
        button.set_no_show_all(True)
-
 
96
        button.hide()
-
 
-
 
97
        self.uif.set_widget_visibility('gtk_button_total_notes', False)
97
        self.uif.set_widget_visibility('gtk_button_dashboard', True)
98
        self.uif.set_widget_visibility('gtk_button_dashboard', True)
98
99
99
100
100
    def gui_show_log(self, *args):
101
    def gui_show_log(self, *args):
101
        logviewer = self.gui.get_widget('widget_logviewer')
102
        logviewer = self.gui.get_widget('widget_logviewer')
Line 114... Line 115...
114
        stack = self.gui.get_widget('gtk_stack_main')
115
        stack = self.gui.get_widget('gtk_stack_main')
115
        stack.set_visible_child_name('settings')
116
        stack.set_visible_child_name('settings')
116
        view_settings = self.gui.get_widget('widget_settings')
117
        view_settings = self.gui.get_widget('widget_settings')
117
        view_settings.update()
118
        view_settings.update()
118
        self.gui_hide_popover(self.gui.get_widget('gtk_popover_button_menu_system'))
119
        self.gui_hide_popover(self.gui.get_widget('gtk_popover_button_menu_system'))
119
        button = self.gui.get_widget('gtk_button_total_notes')
-
 
120
        button.set_no_show_all(True)
-
 
121
        button.hide()
-
 
-
 
120
        self.uif.set_widget_visibility('gtk_button_total_notes', False)
122
        self.uif.set_widget_visibility('gtk_button_dashboard', True)
121
        self.uif.set_widget_visibility('gtk_button_dashboard', True)
123
122
124
123
125
    def gui_show_dashboard(self, *args):
124
    def gui_show_dashboard(self, *args):
126
        stack = self.gui.get_widget('gtk_stack_main')
125
        stack = self.gui.get_widget('gtk_stack_main')
127
        stack.set_visible_child_name('visor')
126
        stack.set_visible_child_name('visor')
128
        self.gui_hide_popover(self.gui.get_widget('gtk_popover_button_menu_system'))
127
        self.gui_hide_popover(self.gui.get_widget('gtk_popover_button_menu_system'))
129
        self.uif.set_widget_visibility('gtk_button_dashboard', False)
128
        self.uif.set_widget_visibility('gtk_button_dashboard', False)
130
        # ~ self.uif.set_widget_visibility(button_home, False)
-
 
131
        # ~ button = self.gui.get_widget('gtk_button_total_notes')
-
 
132
        # ~ button.set_no_show_all(True)
-
 
133
        # ~ button.hide()
-
 
-
 
129
        viewmenu = self.gui.get_widget('viewmenu')
-
 
130
        current_view = viewmenu.get_view()
-
 
131
        self.debug("SHOW-DASHBOARD::CURRENT-VIEW: %s" % current_view)
-
 
132
        if current_view == 'annotation':
-
 
133
            self.uif.set_widget_visibility('gtk_button_total_notes', False)
-
 
134
            self.debug("Hidding button")
-
 
135
        else:
-
 
136
            self.uif.set_widget_visibility('gtk_button_total_notes', True)
-
 
137
            self.debug("Showing button")
134
138
135
139
136
    def gui_annotation_widget_show(self, widget, sid='0000000000', action='create'):
140
    def gui_annotation_widget_show(self, widget, sid='0000000000', action='create'):
137
        widget_annotation = self.gui.get_widget('widget_annotation')
141
        widget_annotation = self.gui.get_widget('widget_annotation')
138
        widget = self.gui.get_widget('gtk_label_aid')
-
 
-
 
142
        widget = self.gui.get_widget('gtk_label_annotation_sid')
139
143
140
144
141
        if action == 'create':
145
        if action == 'create':
142
            self.gui_annotation_widget_clear()
146
            self.gui_annotation_widget_clear()
143
            aid = self.annot.gen_aid(sid)
147
            aid = self.annot.gen_aid(sid)
144
        elif action == 'edit':
148
        elif action == 'edit':
145
            aid = sid
149
            aid = sid
146
        widget_annotation.set_metadata(aid, action)
-
 
-
 
150
        widget_annotation.set_metadata_to_widget(aid, action)
147
        self.uif.set_widget_visibility('gtk_vbox_container_annotations', True)
151
        self.uif.set_widget_visibility('gtk_vbox_container_annotations', True)
148
        widget.grab_focus()
152
        widget.grab_focus()
149
153
150
154
151
    def gui_show_popover(self, button, popover):
155
    def gui_show_popover(self, button, popover):
Line 366... Line 370...
366
370
367
    def action_annotation_delete(self, *args):
371
    def action_annotation_delete(self, *args):
368
        statusbar = self.gui.get_widget('widget_statusbar')
372
        statusbar = self.gui.get_widget('widget_statusbar')
369
        visor = self.gui.get_widget('visor')
373
        visor = self.gui.get_widget('visor')
370
        widget_annotation = self.gui.get_widget('widget_annotation')
374
        widget_annotation = self.gui.get_widget('widget_annotation')
371
        aid = widget_annotation.get_aid()
-
 
-
 
375
        aid = widget_annotation.get_aid_from_widget()
372
        self.annot.delete(aid)
376
        self.annot.delete(aid)
373
        self.gui_annotation_widget_clear()
377
        self.gui_annotation_widget_clear()
374
        self.uif.set_widget_visibility('gtk_vbox_container_annotations', False)
378
        self.uif.set_widget_visibility('gtk_vbox_container_annotations', False)
375
        # ~ visor.refresh()
379
        # ~ visor.refresh()
376
        visor.populate_annotations()
380
        visor.populate_annotations()
Line 380... Line 384...
380
    def action_annotation_accept(self, button, sid):
384
    def action_annotation_accept(self, button, sid):
381
        statusbar = self.gui.get_widget('widget_statusbar')
385
        statusbar = self.gui.get_widget('widget_statusbar')
382
        widget_annotation = self.gui.get_widget('widget_annotation')
386
        widget_annotation = self.gui.get_widget('widget_annotation')
383
        visor = self.gui.get_widget('visor')
387
        visor = self.gui.get_widget('visor')
384
388
385
        aid = widget_annotation.get_aid()
-
 
-
 
389
        aid = widget_annotation.get_aid_from_widget()
386
390
387
        annotation = widget_annotation.get_metadata(aid)
-
 
-
 
391
        annotation = widget_annotation.get_metadata_from_widget(aid)
388
392
389
        if self.annot.is_valid(aid):
393
        if self.annot.is_valid(aid):
390
            self.annot.update(annotation)
394
            self.annot.update(annotation)
391
            statusbar.message('<b>Anotation edited</b>')
395
            statusbar.message('<b>Anotation edited</b>')
392
            self.debug("Updated annotation: %s" % aid)
396
            self.debug("Updated annotation: %s" % aid)
Line 413... Line 417...
413
        TARGET_FILE = TARGET_DIRECTORY + 'basico-' + TIMESTAMP
417
        TARGET_FILE = TARGET_DIRECTORY + 'basico-' + TIMESTAMP
414
        self.utils.zip(TARGET_FILE, SOURCE_DIRECTORY)
418
        self.utils.zip(TARGET_FILE, SOURCE_DIRECTORY)
415
419
416
420
417
    def gui_annotation_widget_clear(self):
421
    def gui_annotation_widget_clear(self):
-
 
422
        a_wdg_timestamp = self.gui.get_widget('gtk_label_human_timestamp')
418
        a_wdg_title = self.gui.get_widget('gtk_entry_annotation_title')
423
        a_wdg_title = self.gui.get_widget('gtk_entry_annotation_title')
419
        a_wdg_type = self.gui.get_widget('gtk_combobox_annotation_type')
424
        a_wdg_type = self.gui.get_widget('gtk_combobox_annotation_type')
420
        a_wdg_text = self.gui.get_widget('gtk_textview_annotation_text')
425
        a_wdg_text = self.gui.get_widget('gtk_textview_annotation_text')
421
        a_wdg_link = self.gui.get_widget('gtk_entry_annotation_link')
426
        a_wdg_link = self.gui.get_widget('gtk_entry_annotation_link')
422
        a_wdg_link_type = self.gui.get_widget('gtk_combobox_annotation_link_type')
427
        a_wdg_link_type = self.gui.get_widget('gtk_combobox_annotation_link_type')
423
428
-
 
429
        a_wdg_timestamp.set_text('')
424
        a_wdg_title.set_text('')
430
        a_wdg_title.set_text('')
425
        textbuffer = a_wdg_text.get_buffer()
431
        textbuffer = a_wdg_text.get_buffer()
426
        textbuffer.set_text('')
432
        textbuffer.set_text('')
427
        a_wdg_link.set_text('')
433
        a_wdg_link.set_text('')
428
        self.uif.set_widget_visibility('gtk_vbox_container_annotations', False)
434
        self.uif.set_widget_visibility('gtk_vbox_container_annotations', False)