Subversion Repositories basico

Rev

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

Rev Author Line No. Line
340 t00mlabs 1
#!/usr/bin/python
2
# -*- coding: utf-8 -*-
3
"""
4
# File: wdg_annot.py
5
# Author: Tomás Vírseda
6
# License: GPL v3
7
# Description: Annotation Widget
8
"""
9
 
10
import html
11
import gi
343 t00mlabs 12
gi.require_version('Gtk', '3.0')
342 t00mlabs 13
gi.require_version('Gdk', '3.0')
14
gi.require_version('Pango', '1.0')
15
gi.require_version('GdkPixbuf', '2.0')
16
gi.require_version('GtkSource', '3.0')
340 t00mlabs 17
from gi.repository import Gtk
18
from gi.repository import Pango
19
from gi.repository.GdkPixbuf import Pixbuf
342 t00mlabs 20
from gi.repository import GtkSource
340 t00mlabs 21
from basico.core.mod_env import LPATH, ATYPES
22
from basico.core.mod_wdg import BasicoWidget
23
 
24
 
348 t00mlabs 25
class AnnotationToolbar(BasicoWidget, Gtk.HBox):
26
    def __init__(self, app, sid='0000000000'):
27
        super().__init__(app, __class__.__name__)
28
        Gtk.Box.__init__(self)
29
        self.sid = sid
30
        self.get_services()
31
        self.set_homogeneous(False)
352 t00mlabs 32
 
33
        # Toolbar
348 t00mlabs 34
        self.tool_bar = Gtk.Toolbar()
35
        self.pack_start(self.tool_bar, False, True, 0)
36
        self.tool_bar.get_style_context().add_class(Gtk.STYLE_CLASS_PRIMARY_TOOLBAR)
37
        self.tool_bar.set_property('margin-bottom', 0)
352 t00mlabs 38
 
348 t00mlabs 39
 
40
        # Task Category button
41
        tool = Gtk.ToolItem()
42
        a_category_model = Gtk.ListStore(Pixbuf, str)
43
        a_category = Gtk.ComboBox.new_with_model(a_category_model)
44
        self.srvgui.add_widget('gtk_combobox_annotation_category', a_category)
45
 
46
        renderer = Gtk.CellRendererPixbuf()
47
        a_category.pack_start(renderer, False)
48
        a_category.add_attribute(renderer, "pixbuf", 0)
49
        renderer = Gtk.CellRendererText()
50
        a_category.pack_start(renderer, True)
51
        a_category.add_attribute(renderer, "text", 1)
52
 
53
        icon = self.srvicm.get_pixbuf_icon('basico-inbox', 24, 24)
54
        active = self.srvgui.add_widget('annotation_category_Inbox', a_category_model.append([icon, 'Inbox']))
55
 
56
        icon = self.srvicm.get_pixbuf_icon('basico-drafts', 24, 24)
57
        self.srvgui.add_widget('annotation_category_Drafts', a_category_model.append([icon, 'Drafts']))
58
 
59
        icon = self.srvicm.get_pixbuf_icon('basico-archived', 24, 24)
60
        self.srvgui.add_widget('annotation_category_Archived', a_category_model.append([icon, 'Archived']))
61
 
62
        a_category.set_active_iter(active)
350 t00mlabs 63
        hbox = Gtk.HBox()
64
        label = Gtk.Label()
65
        label.set_xalign(0.0)
66
        label.set_markup('<b>Category</b>')
67
        hbox.pack_start(label, False, False, 3)
68
        hbox.pack_start(a_category, False, False, 0)
69
        tool.add(hbox)
348 t00mlabs 70
        self.tool_bar.insert(tool, -1)
71
 
350 t00mlabs 72
        # Separator
73
        tool = Gtk.SeparatorToolItem.new()
74
        tool.set_draw(False)
75
        tool.set_expand(False)
76
        self.tool_bar.insert(tool, -1)
77
 
348 t00mlabs 78
        # Task Type button
79
        tool = Gtk.ToolItem()
80
        a_type_model = Gtk.ListStore(Pixbuf, str)
81
        a_type = Gtk.ComboBox.new_with_model(a_type_model)
82
        self.srvgui.add_widget('gtk_combobox_annotation_type', a_type)
83
        renderer = Gtk.CellRendererPixbuf()
84
        a_type.pack_start(renderer, False)
85
        a_type.add_attribute(renderer, "pixbuf", 0)
86
        renderer = Gtk.CellRendererText()
87
        a_type.pack_start(renderer, True)
88
        a_type.add_attribute(renderer, "text", 1)
89
        for item in ATYPES:
90
            icon = self.srvicm.get_pixbuf_icon('basico-annotation-type-%s' % item.lower(), 24, 24)
91
            active = self.srvgui.add_widget('annotation_type_%s' % item.title(), a_type_model.append([icon, '%s' % item.title()]))
92
        a_type.set_active_iter(active)
350 t00mlabs 93
        hbox = Gtk.HBox()
94
        label = Gtk.Label()
95
        label.set_xalign(0.0)
96
        label.set_markup('<b>Type</b>')
97
        hbox.pack_start(label, False, False, 6)
98
        hbox.pack_start(a_type, False, False, 0)
99
        tool.add(hbox)
348 t00mlabs 100
        self.tool_bar.insert(tool, -1)
101
 
350 t00mlabs 102
        # Separator
103
        tool = Gtk.SeparatorToolItem.new()
104
        tool.set_draw(False)
105
        tool.set_expand(False)
106
        self.tool_bar.insert(tool, -1)
107
 
348 t00mlabs 108
        # Task Priority button
109
        tool = Gtk.ToolItem()
110
        a_priority_model = Gtk.ListStore(Pixbuf, str)
111
        a_priority = Gtk.ComboBox.new_with_model(a_priority_model)
112
        self.srvgui.add_widget('gtk_combobox_annotation_priority', a_priority)
113
 
114
        renderer = Gtk.CellRendererPixbuf()
115
        a_priority.pack_start(renderer, False)
116
        a_priority.add_attribute(renderer, "pixbuf", 0)
117
 
118
        renderer = Gtk.CellRendererText()
119
        a_priority.pack_start(renderer, True)
120
        a_priority.add_attribute(renderer, "text", 1)
121
 
122
        icon = self.srvicm.get_pixbuf_icon('basico-annotation-priority-high', 24, 24)
123
        self.srvgui.add_widget('annotation_priority_High', a_priority_model.append([icon, 'High']))
124
 
125
        icon = self.srvicm.get_pixbuf_icon('basico-annotation-priority-normal', 24, 24)
126
        active = self.srvgui.add_widget('annotation_priority_Normal', a_priority_model.append([icon, 'Normal']))
127
 
128
        icon = self.srvicm.get_pixbuf_icon('basico-annotation-priority-low', 24, 24)
129
        self.srvgui.add_widget('annotation_priority_Low', a_priority_model.append([icon, 'Low']))
130
 
131
        a_priority.set_active_iter(active)
350 t00mlabs 132
        hbox = Gtk.HBox()
133
        label = Gtk.Label()
134
        label.set_xalign(0.0)
135
        label.set_markup('<b>Priority</b>')
136
        hbox.pack_start(label, False, False, 6)
137
        hbox.pack_start(a_priority, False, False, 0)
138
        tool.add(hbox)
348 t00mlabs 139
        self.tool_bar.insert(tool, -1)
140
 
141
        # Separator
142
        tool = Gtk.SeparatorToolItem.new()
353 t00mlabs 143
        tool.set_draw(True)
144
        tool.set_expand(False)
145
        self.tool_bar.insert(tool, -1)
146
 
147
        # Attachment button
148
        tool = Gtk.ToolButton()
149
        tool.set_icon_name('basico-attachment')
150
        tool.set_tooltip_markup('<b>Attach any document to this annotation</b>')
151
        popover = self.srvgui.add_widget('gtk_button_annotation_toolbar_attachment', Gtk.Popover.new(tool))
356 t00mlabs 152
        tool.connect('clicked', self.srvclb.gui_attachment_add)
353 t00mlabs 153
        self.tool_bar.insert(tool, -1)
154
 
155
        # Separator
156
        tool = Gtk.SeparatorToolItem.new()
348 t00mlabs 157
        tool.set_draw(False)
158
        tool.set_expand(True)
159
        self.tool_bar.insert(tool, -1)
353 t00mlabs 160
 
348 t00mlabs 161
        # Title
162
        tool = Gtk.ToolItem()
163
        # ~ vbox = Gtk.VBox()
164
        title = self.srvgui.add_widget('gtk_label_annotation_sid', Gtk.Label())
165
        title.set_selectable(True)
166
        if self.sid == '0000000000':
167
            title.set_markup('<small><b>Annotation</b></small>')
168
        else:
169
            title.set_markup('<small><b>Annotation for SAP Note %s</b></small>' % str(int(self.sid)))
170
        title.set_xalign(0.5)
171
        # ~ vbox.pack_start(title, False, False, 3)
351 t00mlabs 172
 
173
        # Timestamp created
174
        tool = Gtk.ToolItem()
175
        tool.set_expand(False)
176
        a_wdg_timestamp_created = self.srvgui.add_widget('gtk_label_timestamp_created', Gtk.Label())
177
        a_wdg_timestamp_created.modify_font(Pango.FontDescription('Monospace 10'))
178
        a_wdg_timestamp_created.set_xalign(0.5)
179
        tool.add(a_wdg_timestamp_created)
180
        tool.set_no_show_all(True)
181
        tool.hide()
182
        self.tool_bar.insert(tool, -1)
348 t00mlabs 183
 
351 t00mlabs 184
        # Timestamp updated
185
        tool = Gtk.ToolItem()
186
        tool.set_expand(False)
348 t00mlabs 187
        a_wdg_human_timestamp = self.srvgui.add_widget('gtk_label_human_timestamp', Gtk.Label())
188
        a_wdg_human_timestamp.modify_font(Pango.FontDescription('Monospace 10'))
189
        a_wdg_human_timestamp.set_xalign(0.5)
190
        tool.add(a_wdg_human_timestamp)
191
        self.tool_bar.insert(tool, -1)
192
 
193
        # Maximize toggle button
194
        tool = Gtk.ToolItem()
195
        tool.set_expand(False)
196
        icon = self.srvicm.get_new_image_icon('basico-fullscreen', 24, 24)
197
        box = self.srvgui.add_widget('gtk_box_container_icon_maximize', Gtk.Box())
198
        box.pack_start(icon, False, False, 0)
199
        button = self.srvgui.add_widget('gtk_togglebutton_maximize_annotation_widget', Gtk.ToggleButton())
200
        button.set_relief(Gtk.ReliefStyle.NONE)
201
        button.connect('toggled', self.srvclb.gui_maximize_annotation_window)
202
        button.add(box)
203
        tool.add(button)
204
        tool.set_tooltip_markup('<b>Fullscreen/Window mode</b>')
205
        self.tool_bar.insert(tool, -1)
206
 
207
        # Toolbar initial settings
208
        self.set_visible(True)
209
        self.set_no_show_all(False)
210
        self.tool_bar.set_hexpand(True)
211
 
212
 
213
    def get_services(self):
214
        self.srvgui = self.get_service("GUI")
215
        self.srvclb = self.get_service('Callbacks')
216
        self.srvsap = self.get_service('SAP')
217
        self.srvicm = self.get_service('IM')
218
        self.srvstg = self.get_service('Settings')
219
        self.srvdtb = self.get_service('DB')
220
        self.srvuif = self.get_service("UIF")
221
 
222
 
223
 
340 t00mlabs 224
class AnnotationWidget(BasicoWidget, Gtk.VBox):
225
    """
226
    Annotation Widget
227
    """
228
    def __init__(self, app, sid='0000000000'):
229
        super().__init__(app, __class__.__name__)
230
        Gtk.VBox.__init__(self)
231
        self.app = app
232
        self.sid = sid
233
        self.get_services()
234
        self.__setup()
235
 
236
 
237
    def get_services(self):
238
        """Load services to be used in this class
239
        """
240
        self.srvgui = self.get_service("GUI")
241
        self.srvicm = self.get_service("IM")
242
        self.srvuif = self.get_service("UIF")
243
        self.srvclt = self.get_service('Collections')
244
        self.srvclb = self.get_service('Callbacks')
245
        self.srvant = self.get_service('Annotation')
246
        self.srvutl = self.get_service('Utils')
247
 
248
 
249
    def __setup(self):
250
        # Setup Widget properties
251
        self.set_property('margin-left', 3)
252
        self.set_property('margin-right', 3)
253
        self.set_hexpand(True)
254
        self.set_vexpand(True)
255
 
256
        # Annotation container (body)
257
        self.container_body = self.srvgui.add_widget('gtk_vbox_annotation_container', Gtk.VBox())
258
        self.container_body.set_border_width(3)
259
        self.pack_start(self.container_body, True, True, 3)
260
 
261
        self.__setup_header()
262
        self.__setup_body()
263
        self.__setup_footer()
264
 
265
 
266
    def __setup_header(self):
267
        # Annotation Header
268
        container = self.srvgui.get_widget('gtk_vbox_annotation_container')
269
        header = Gtk.VBox()
270
        separator = Gtk.Separator()
346 t00mlabs 271
        # ~ header.pack_start(separator, False, False, 0)
348 t00mlabs 272
        toolbar = AnnotationToolbar(self.app, self.sid)
273
        header.pack_start(toolbar, False, False, 0)
340 t00mlabs 274
        hbox = Gtk.HBox()
275
        a_lbl_aid = Gtk.Label()
276
        a_lbl_aid.set_property('xalign', 1.0)
277
        a_lbl_aid.modify_font(Pango.FontDescription('Monospace 10'))
278
        a_lbl_aid.set_markup('<b>Annotation Id:</b>')
279
        a_aid = self.srvgui.add_widget('gtk_label_aid', Gtk.Label())
280
        a_aid.set_property('xalign', 1.0)
281
        a_aid.set_selectable(True)
282
        a_aid.modify_font(Pango.FontDescription('Monospace 10'))
283
        separator = Gtk.Separator()
284
        hbox.pack_start(a_lbl_aid, False, False, 0)
285
        hbox.pack_start(a_aid, False, False, 0)
348 t00mlabs 286
        hbox.set_no_show_all(True)
287
        hbox.hide()
288
        # ~ header.pack_start(hbox, False, False, 0)
289
        # ~ header.pack_start(a_wdg_human_timestamp, True, True, 0)
346 t00mlabs 290
        # ~ header.pack_start(separator, False, False, 3)
340 t00mlabs 291
        header.show_all()
292
        container.pack_start(header, False, False, 0)
293
 
294
 
295
    def __setup_body(self):
296
        vbox = Gtk.VBox()
297
 
298
        # Hidden metadata
299
        hhbox = Gtk.HBox()
300
 
301
        a_timestamp = self.srvgui.add_widget('gtk_label_timestamp', Gtk.Label(self.srvutl.timestamp()))
302
        a_timestamp.set_sensitive(False)
303
        self.srvuif.set_widget_visibility('gtk_label_timestamp', False)
304
        hhbox.pack_start(a_timestamp, False, False, 0)
305
        vbox.pack_start(hhbox, False, False, 0)
306
 
307
 
308
        # Main hbox
309
        mhbox = Gtk.HBox()
310
 
311
        vboxl = Gtk.VBox()
312
        vboxl.set_vexpand(True)
313
        vboxr = Gtk.VBox()
314
        vboxr.set_vexpand(True)
315
 
316
        # Title
317
        a_title = self.srvgui.add_widget('gtk_entry_annotation_title', Gtk.Entry())
318
        a_title.set_placeholder_text("Type a title here...")
319
        a_title.modify_font(Pango.FontDescription('Monospace 10'))
320
        vboxl.pack_start(a_title, False, False, 0)
321
 
322
        # Text
323
        scroller = Gtk.ScrolledWindow()
324
        scroller.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
325
        scroller.set_shadow_type(Gtk.ShadowType.IN)
326
        scroller.set_hexpand(True)
342 t00mlabs 327
        scroller.set_vexpand(True)        
328
        a_text = self.srvgui.add_widget('gtk_textview_annotation_text', GtkSource.View.new_with_buffer(GtkSource.Buffer()))
340 t00mlabs 329
        a_text.set_wrap_mode(Gtk.WrapMode.WORD)
330
        a_text.modify_font(Pango.FontDescription('Monospace 10'))
331
        a_text.set_vexpand(True)
332
        a_text.set_left_margin(6)
333
        a_text.set_top_margin(6)
334
        a_text.set_right_margin(6)
335
        a_text.set_bottom_margin(6)
342 t00mlabs 336
        a_text.set_show_line_marks(True)
337
        a_text.set_show_line_numbers(True)
338
        a_text.set_highlight_current_line(True)
339
        a_textbuffer = a_text.get_buffer()
340 t00mlabs 340
        a_textbuffer.set_text('')
341
        scroller.add(a_text)
342
        vboxl.pack_start(scroller, True, True, 3)
343
 
344
        # Url
345
        hbox = Gtk.HBox()
346
 
347
        ## url entry
348
        a_link = self.srvgui.add_widget('gtk_entry_annotation_link', Gtk.Entry())
349
        a_link.set_placeholder_text("Type a url here...")
350
        hbox.pack_start(a_link, True, True, 3)
351
 
352
        ## url button
353
        a_link_button = self.srvgui.add_widget('gtk_link_button_annotation_link', Gtk.LinkButton())
354
        a_link_button.set_relief(Gtk.ReliefStyle.NORMAL)
355
        a_link_button.set_label('Visit')
356
        hbox.pack_start(a_link_button, False, False, 3)
357
 
358
        # url type
359
        a_link_type_model = Gtk.ListStore(str)
360
        self.srvgui.add_widget('annotation_link_type_Intranet', a_link_type_model.append(['Intranet']))
361
        self.srvgui.add_widget('annotation_link_type_SAP Blog', a_link_type_model.append(['SAP Blog']))
362
        self.srvgui.add_widget('annotation_link_type_SAP Document', a_link_type_model.append(['SAP Document']))
363
        self.srvgui.add_widget('annotation_link_type_SAP Help', a_link_type_model.append(['SAP Help']))
364
        self.srvgui.add_widget('annotation_link_type_SAP Incident', a_link_type_model.append(['SAP Incident']))
365
        self.srvgui.add_widget('annotation_link_type_SAP Questions and Answers', a_link_type_model.append(['SAP Questions and Answers']))
366
        self.srvgui.add_widget('annotation_link_type_SAP Wiki', a_link_type_model.append(['SAP Wiki']))
367
        active = self.srvgui.add_widget('annotation_link_type_Website', a_link_type_model.append(['Website']))
368
        a_link_type = Gtk.ComboBox.new_with_model(a_link_type_model)
369
        a_link_type.set_active_iter(active)
370
        self.srvgui.add_widget('gtk_combobox_annotation_link_type', a_link_type)
371
        renderer_text = Gtk.CellRendererText()
372
        a_link_type.pack_start(renderer_text, True)
373
        a_link_type.add_attribute(renderer_text, "text", 0)
374
        hbox.pack_start(a_link_type, False, False, 0)
375
        vboxl.pack_start(hbox, False, False, 3)
376
 
377
        mhbox.pack_start(vboxl, True, True, 6)
378
        mhbox.pack_start(vboxr, False, False, 0)
379
        vbox.pack_start(mhbox, True, True, 3)
380
        self.container_body.add(vbox)
381
 
382
 
383
    def __setup_footer(self):
384
        # Buttons Accept/Cancel
385
        hbox = Gtk.HBox()
386
        accept = self.srvgui.add_widget('gtk_button_accept_annotation', Gtk.Button('Accept'))
387
        accept.connect('clicked', self.srvclb.action_annotation_accept, self.sid)
388
        accept.set_property('always-show-image', True)
389
        icon = self.srvicm.get_new_image_icon('basico-check-accept', 24, 24)
390
        accept.set_image(icon)
391
        cancel = self.srvgui.add_widget('gtk_button_cancel_annotation', Gtk.Button('Cancel'))
392
        cancel.connect('clicked', self.srvclb.action_annotation_cancel)
393
        cancel.set_property('always-show-image', True)
394
        icon = self.srvicm.get_new_image_icon('basico-check-cancel', 24, 24)
395
        cancel.set_image(icon)
396
        hbox.pack_start(accept, True, False, 3)
397
        hbox.pack_start(cancel, True, False, 3)
398
        self.pack_start(hbox, False, False, 3)
399
 
400
 
401
    def set_aid_to_widget(self, aid):
402
        """
403
        C:237, 4: Missing method docstring (missing-docstring)
404
        """
405
        a_aid = self.srvgui.get_widget('gtk_label_aid')
406
        a_aid.set_text(aid)
407
 
408
 
409
    def get_aid_from_widget(self):
410
        """
411
        C:237, 4: Missing method docstring (missing-docstring)
412
        """
413
        a_aid = self.srvgui.get_widget('gtk_label_aid')
414
        return a_aid.get_text()
415
 
416
 
417
    def set_metadata_to_widget(self, aid, action):
418
        """
419
        C:237, 4: Missing method docstring (missing-docstring)
420
        """
421
        self.set_aid_to_widget(aid)
422
        sid = self.srvant.get_sid(aid)
423
        title = self.srvgui.get_widget('gtk_label_annotation_sid')
424
        if sid == '0000000000':
425
            title.set_markup('<big><b>Annotation</b></big>')
426
            self.srvuif.statusbar_msg("Creating new annotation")
427
        else:
428
            title.set_markup('<big><b>Annotation for SAP Note %s</b></big>' % str(int(sid)))
429
            self.srvuif.statusbar_msg("Creating/Editing new annotation for SAP Note %s" % str(int(sid)))
430
 
431
        if action == 'create':
432
            pass
433
        elif action == 'edit':
351 t00mlabs 434
            annotation = self.srvant.get_metadata_from_aid(aid)
340 t00mlabs 435
            if annotation is not None:
436
                ANNOTATION_FILE_CONTENT = LPATH['ANNOTATIONS'] + aid + '.adoc'
437
                a_wdg_aid = self.srvgui.get_widget('gtk_label_aid')
438
                a_wdg_timestamp = self.srvgui.get_widget('gtk_label_timestamp')
439
                a_wdg_title = self.srvgui.get_widget('gtk_entry_annotation_title')
440
                a_wdg_type = self.srvgui.get_widget('gtk_combobox_annotation_type')
441
                a_wdg_category = self.srvgui.get_widget('gtk_combobox_annotation_category')
442
                a_wdg_priority = self.srvgui.get_widget('gtk_combobox_annotation_priority')
443
                a_wdg_human_timestamp = self.srvgui.get_widget('gtk_label_human_timestamp')
351 t00mlabs 444
                a_wdg_timestamp_created = self.srvgui.get_widget('gtk_label_timestamp_created')
340 t00mlabs 445
                a_wdg_text = self.srvgui.get_widget('gtk_textview_annotation_text')
446
                a_wdg_link = self.srvgui.get_widget('gtk_entry_annotation_link')
447
                a_wdg_link_button = self.srvgui.get_widget('gtk_link_button_annotation_link')
448
                a_wdg_link_type = self.srvgui.get_widget('gtk_combobox_annotation_link_type')
449
 
450
                a_wdg_aid.set_text(annotation['AID'])
451
                a_wdg_timestamp.set_text(annotation['Timestamp'])
452
                a_wdg_title.set_text(html.escape(annotation['Title']))
453
 
454
                a_wdg_type.set_active_iter(self.srvgui.get_widget('annotation_type_%s' % annotation['Type']))
455
 
456
                try:
457
                    a_wdg_category.set_active_iter(self.srvgui.get_widget('annotation_category_%s' % annotation['Category']))
458
                except:
459
                    a_wdg_category.set_active_iter(self.srvgui.get_widget('annotation_category_Inbox'))
460
 
461
                try:
462
                    a_wdg_priority.set_active_iter(self.srvgui.get_widget('annotation_priority_%s' % annotation['Priority']))
463
                except:
464
                    a_wdg_priority.set_active_iter(self.srvgui.get_widget('annotation_priority_Normal'))
465
 
466
                self.srvuif.set_textview_text(a_wdg_text, open(ANNOTATION_FILE_CONTENT).read())
467
                a_wdg_link.set_text(annotation['Link'])
468
                a_wdg_link_button.set_uri(annotation['Link'])
469
                a_wdg_link_type.set_active_iter(self.srvgui.get_widget('annotation_link_type_%s' % annotation['LinkType']))
470
                human_timestamp = self.srvutl.get_human_date_from_timestamp(annotation['Timestamp'])
348 t00mlabs 471
                a_wdg_human_timestamp.set_markup('<b>%s</b>' % human_timestamp)
351 t00mlabs 472
                a_wdg_timestamp_created.set_text(annotation['Created'])
340 t00mlabs 473
 
474
 
475
    def get_metadata_from_widget(self):
476
        """
354 t00mlabs 477
        C:237, 4: Missing method docstring (missing-docstring)
340 t00mlabs 478
        """
479
        annotation = {}
480
        a_wdg_aid = self.srvgui.get_widget('gtk_label_aid')
481
        a_wdg_timestamp = self.srvgui.get_widget('gtk_label_timestamp')
351 t00mlabs 482
        a_wdg_timestamp_created = self.srvgui.get_widget('gtk_label_timestamp_created')
340 t00mlabs 483
        a_wdg_title = self.srvgui.get_widget('gtk_entry_annotation_title')
484
        a_wdg_type = self.srvgui.get_widget('gtk_combobox_annotation_type')
485
        a_wdg_category = self.srvgui.get_widget('gtk_combobox_annotation_category')
486
        a_wdg_priority = self.srvgui.get_widget('gtk_combobox_annotation_priority')
487
        a_wdg_text = self.srvgui.get_widget('gtk_textview_annotation_text')
488
        a_wdg_link = self.srvgui.get_widget('gtk_entry_annotation_link')
489
        a_wdg_link_type = self.srvgui.get_widget('gtk_combobox_annotation_link_type')
490
 
491
        annotation['AID'] = a_wdg_aid.get_text()
492
        annotation['Timestamp'] = a_wdg_timestamp.get_text()
351 t00mlabs 493
        annotation['Created'] = a_wdg_timestamp_created.get_text()
340 t00mlabs 494
        annotation['Title'] = a_wdg_title.get_text()
495
        annotation['Component'] = 'Annotation'
496
        annotation['Type'] = self.srvuif.get_combobox_text(a_wdg_type, 1)
497
        annotation['Category'] = self.srvuif.get_combobox_text(a_wdg_category, 1)
498
        annotation['Priority'] = self.srvuif.get_combobox_text(a_wdg_priority, 1)
499
        annotation['Content'] = self.srvuif.get_textview_text(a_wdg_text)
500
        annotation['Link'] = a_wdg_link.get_text()
501
        annotation['LinkType'] = self.srvuif.get_combobox_text(a_wdg_link_type, 0)
502
 
503
        return annotation