Subversion Repositories basico

Rev

Rev 370 | Rev 385 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 370 Rev 380
Line 7... Line 7...
7
# Description: Annotation Widget
7
# Description: Annotation Widget
8
"""
8
"""
9
9
10
import html
10
import html
11
import gi
11
import gi
12
gi.require_version('Gtk', '3.0')
-
 
-
 
12
gi.require_version('Gtk', '3.0')
13
gi.require_version('Gdk', '3.0')
13
gi.require_version('Gdk', '3.0')
14
gi.require_version('Pango', '1.0')
14
gi.require_version('Pango', '1.0')
15
gi.require_version('GdkPixbuf', '2.0')
15
gi.require_version('GdkPixbuf', '2.0')
16
gi.require_version('GtkSource', '3.0')
16
gi.require_version('GtkSource', '3.0')
17
from gi.repository import Gtk
17
from gi.repository import Gtk
Line 34... Line 34...
34
        # Toolbar
34
        # Toolbar
35
        self.tool_bar = Gtk.Toolbar()
35
        self.tool_bar = Gtk.Toolbar()
36
        self.pack_start(self.tool_bar, False, True, 0)
36
        self.pack_start(self.tool_bar, False, True, 0)
37
        self.tool_bar.get_style_context().add_class(Gtk.STYLE_CLASS_PRIMARY_TOOLBAR)
37
        self.tool_bar.get_style_context().add_class(Gtk.STYLE_CLASS_PRIMARY_TOOLBAR)
38
        self.tool_bar.set_property('margin-bottom', 0)
38
        self.tool_bar.set_property('margin-bottom', 0)
39
       
-
 
-
 
39
40
        # Task Category button
40
        # Task Category button
41
        tool = Gtk.ToolItem()
41
        tool = Gtk.ToolItem()
42
        a_category_model = Gtk.ListStore(Pixbuf, str)
42
        a_category_model = Gtk.ListStore(Pixbuf, str)
43
        a_category = Gtk.ComboBox.new_with_model(a_category_model)
43
        a_category = Gtk.ComboBox.new_with_model(a_category_model)
44
        a_category.set_tooltip_markup('<b>Choose a category</b>')
44
        a_category.set_tooltip_markup('<b>Choose a category</b>')
45
        self.srvgui.add_widget('gtk_combobox_annotation_category', a_category)
45
        self.srvgui.add_widget('gtk_combobox_annotation_category', a_category)
46
       
-
 
-
 
46
47
        renderer = Gtk.CellRendererPixbuf()
47
        renderer = Gtk.CellRendererPixbuf()
48
        a_category.pack_start(renderer, False)
48
        a_category.pack_start(renderer, False)
49
        a_category.add_attribute(renderer, "pixbuf", 0)
49
        a_category.add_attribute(renderer, "pixbuf", 0)
50
        renderer = Gtk.CellRendererText()
50
        renderer = Gtk.CellRendererText()
51
        a_category.pack_start(renderer, True)
51
        a_category.pack_start(renderer, True)
52
        a_category.add_attribute(renderer, "text", 1)
52
        a_category.add_attribute(renderer, "text", 1)
53
53
54
        icon = self.srvicm.get_pixbuf_icon('basico-inbox', 24, 24)
54
        icon = self.srvicm.get_pixbuf_icon('basico-inbox', 24, 24)
55
        active = self.srvgui.add_widget('annotation_category_Inbox', a_category_model.append([icon, 'Inbox']))
55
        active = self.srvgui.add_widget('annotation_category_Inbox', a_category_model.append([icon, 'Inbox']))
56
       
-
 
-
 
56
57
        icon = self.srvicm.get_pixbuf_icon('basico-drafts', 24, 24)
57
        icon = self.srvicm.get_pixbuf_icon('basico-drafts', 24, 24)
58
        self.srvgui.add_widget('annotation_category_Drafts', a_category_model.append([icon, 'Drafts']))
58
        self.srvgui.add_widget('annotation_category_Drafts', a_category_model.append([icon, 'Drafts']))
59
59
60
        icon = self.srvicm.get_pixbuf_icon('basico-archived', 24, 24)
60
        icon = self.srvicm.get_pixbuf_icon('basico-archived', 24, 24)
61
        self.srvgui.add_widget('annotation_category_Archived', a_category_model.append([icon, 'Archived']))
61
        self.srvgui.add_widget('annotation_category_Archived', a_category_model.append([icon, 'Archived']))
62
       
-
 
-
 
62
63
        a_category.set_active_iter(active)
63
        a_category.set_active_iter(active)
64
        hbox = Gtk.HBox()
64
        hbox = Gtk.HBox()
65
        hbox.pack_start(a_category, False, False, 0)
65
        hbox.pack_start(a_category, False, False, 0)
66
        tool.add(hbox)
66
        tool.add(hbox)
67
        self.tool_bar.insert(tool, -1)
67
        self.tool_bar.insert(tool, -1)
Line 99... Line 99...
99
        tool = Gtk.ToolItem()
99
        tool = Gtk.ToolItem()
100
        a_priority_model = Gtk.ListStore(Pixbuf, str)
100
        a_priority_model = Gtk.ListStore(Pixbuf, str)
101
        a_priority = Gtk.ComboBox.new_with_model(a_priority_model)
101
        a_priority = Gtk.ComboBox.new_with_model(a_priority_model)
102
        a_priority.set_tooltip_markup('<b>Choose a priority</b>')
102
        a_priority.set_tooltip_markup('<b>Choose a priority</b>')
103
        self.srvgui.add_widget('gtk_combobox_annotation_priority', a_priority)
103
        self.srvgui.add_widget('gtk_combobox_annotation_priority', a_priority)
104
       
-
 
-
 
104
105
        renderer = Gtk.CellRendererPixbuf()
105
        renderer = Gtk.CellRendererPixbuf()
106
        a_priority.pack_start(renderer, False)
106
        a_priority.pack_start(renderer, False)
107
        a_priority.add_attribute(renderer, "pixbuf", 0)
107
        a_priority.add_attribute(renderer, "pixbuf", 0)
108
       
-
 
-
 
108
109
        renderer = Gtk.CellRendererText()
109
        renderer = Gtk.CellRendererText()
110
        a_priority.pack_start(renderer, True)
110
        a_priority.pack_start(renderer, True)
111
        a_priority.add_attribute(renderer, "text", 1)
111
        a_priority.add_attribute(renderer, "text", 1)
112
112
113
        icon = self.srvicm.get_pixbuf_icon('basico-annotation-priority-high', 24, 24)
113
        icon = self.srvicm.get_pixbuf_icon('basico-annotation-priority-high', 24, 24)
Line 116... Line 116...
116
        icon = self.srvicm.get_pixbuf_icon('basico-annotation-priority-normal', 24, 24)
116
        icon = self.srvicm.get_pixbuf_icon('basico-annotation-priority-normal', 24, 24)
117
        active = self.srvgui.add_widget('annotation_priority_Normal', a_priority_model.append([icon, 'Normal']))
117
        active = self.srvgui.add_widget('annotation_priority_Normal', a_priority_model.append([icon, 'Normal']))
118
118
119
        icon = self.srvicm.get_pixbuf_icon('basico-annotation-priority-low', 24, 24)
119
        icon = self.srvicm.get_pixbuf_icon('basico-annotation-priority-low', 24, 24)
120
        self.srvgui.add_widget('annotation_priority_Low', a_priority_model.append([icon, 'Low']))
120
        self.srvgui.add_widget('annotation_priority_Low', a_priority_model.append([icon, 'Low']))
121
       
-
 
-
 
121
122
        a_priority.set_active_iter(active)
122
        a_priority.set_active_iter(active)
123
        hbox = Gtk.HBox()
123
        hbox = Gtk.HBox()
124
        hbox.pack_start(a_priority, False, False, 0)
124
        hbox.pack_start(a_priority, False, False, 0)
125
        tool.add(hbox)
125
        tool.add(hbox)
126
        self.tool_bar.insert(tool, -1)
126
        self.tool_bar.insert(tool, -1)
127
       
-
 
-
 
127
128
        # Separator
128
        # Separator
129
        tool = self.srvuif.get_toolbar_separator(False, False)
129
        tool = self.srvuif.get_toolbar_separator(False, False)
130
        self.tool_bar.insert(tool, -1)
130
        self.tool_bar.insert(tool, -1)
131
131
132
        # Attachment button
132
        # Attachment button
Line 138... Line 138...
138
        self.tool_bar.insert(tool, -1)
138
        self.tool_bar.insert(tool, -1)
139
139
140
        # Separator
140
        # Separator
141
        tool = self.srvuif.get_toolbar_separator(False, True)
141
        tool = self.srvuif.get_toolbar_separator(False, True)
142
        self.tool_bar.insert(tool, -1)
142
        self.tool_bar.insert(tool, -1)
143
       
-
 
-
 
143
144
        # Title
144
        # Title
145
        tool = Gtk.ToolItem()
145
        tool = Gtk.ToolItem()
146
        # ~ vbox = Gtk.VBox()
146
        # ~ vbox = Gtk.VBox()
147
        title = self.srvgui.add_widget('gtk_label_annotation_sid', Gtk.Label())
147
        title = self.srvgui.add_widget('gtk_label_annotation_sid', Gtk.Label())
148
        title.set_selectable(True)
148
        title.set_selectable(True)
Line 161... Line 161...
161
        a_wdg_timestamp_created.set_xalign(0.5)
161
        a_wdg_timestamp_created.set_xalign(0.5)
162
        tool.add(a_wdg_timestamp_created)
162
        tool.add(a_wdg_timestamp_created)
163
        tool.set_no_show_all(True)
163
        tool.set_no_show_all(True)
164
        tool.hide()
164
        tool.hide()
165
        self.tool_bar.insert(tool, -1)
165
        self.tool_bar.insert(tool, -1)
166
       
-
 
-
 
166
167
        # Timestamp updated
167
        # Timestamp updated
168
        tool = Gtk.ToolItem()
168
        tool = Gtk.ToolItem()
169
        tool.set_expand(False)
169
        tool.set_expand(False)
170
        a_wdg_human_timestamp = self.srvgui.add_widget('gtk_label_human_timestamp', Gtk.Label())
170
        a_wdg_human_timestamp = self.srvgui.add_widget('gtk_label_human_timestamp', Gtk.Label())
171
        a_wdg_human_timestamp.modify_font(Pango.FontDescription('Monospace 10'))
171
        a_wdg_human_timestamp.modify_font(Pango.FontDescription('Monospace 10'))
Line 203... Line 203...
203
        self.tool_bar.insert(tool, -1)
203
        self.tool_bar.insert(tool, -1)
204
204
205
        # Separator
205
        # Separator
206
        tool = self.srvuif.get_toolbar_separator(False, False)
206
        tool = self.srvuif.get_toolbar_separator(False, False)
207
        self.tool_bar.insert(tool, -1)
207
        self.tool_bar.insert(tool, -1)
208
       
-
 
-
 
208
209
        # Maximize toggle button
209
        # Maximize toggle button
210
        tool = Gtk.ToolItem()
210
        tool = Gtk.ToolItem()
211
        tool.set_expand(False)
211
        tool.set_expand(False)
212
        icon = self.srvicm.get_new_image_icon('basico-fullscreen', 24, 24)
212
        icon = self.srvicm.get_new_image_icon('basico-fullscreen', 24, 24)
213
        box = self.srvgui.add_widget('gtk_box_container_icon_maximize', Gtk.Box())
213
        box = self.srvgui.add_widget('gtk_box_container_icon_maximize', Gtk.Box())
Line 248... Line 248...
248
        self.sid = sid
248
        self.sid = sid
249
        self.get_services()
249
        self.get_services()
250
        self.__setup()
250
        self.__setup()
251
        # ~ self.stack_changed()
251
        # ~ self.stack_changed()
252
252
253
   
-
 
-
 
253
254
    def get_services(self):
254
    def get_services(self):
255
        """Load services to be used in this class
255
        """Load services to be used in this class
256
        """
256
        """
257
        self.srvgui = self.get_service("GUI")
257
        self.srvgui = self.get_service("GUI")
258
        self.srvicm = self.get_service("IM")
258
        self.srvicm = self.get_service("IM")
Line 260... Line 260...
260
        self.srvclt = self.get_service('Collections')
260
        self.srvclt = self.get_service('Collections')
261
        self.srvclb = self.get_service('Callbacks')
261
        self.srvclb = self.get_service('Callbacks')
262
        self.srvant = self.get_service('Annotation')
262
        self.srvant = self.get_service('Annotation')
263
        self.srvutl = self.get_service('Utils')
263
        self.srvutl = self.get_service('Utils')
264
        self.srvacd = self.get_service('Asciidoctor')
264
        self.srvacd = self.get_service('Asciidoctor')
265
       
-
 
-
 
265
266
266
267
    def __setup(self):
267
    def __setup(self):
268
        # Setup Widget properties
268
        # Setup Widget properties
269
        self.set_property('margin-left', 3)
269
        self.set_property('margin-left', 3)
270
        self.set_property('margin-right', 3)
270
        self.set_property('margin-right', 3)
Line 317... Line 317...
317
        self.container_body.add(stack_annotation)
317
        self.container_body.add(stack_annotation)
318
318
319
        # ~ hpaned = self.srvgui.get_widget('gtk_hpaned')
319
        # ~ hpaned = self.srvgui.get_widget('gtk_hpaned')
320
        # ~ hpaned.set_position(0)
320
        # ~ hpaned.set_position(0)
321
        # ~ self.log.debug("HPaned position: %d", hpaned.get_position())
321
        # ~ self.log.debug("HPaned position: %d", hpaned.get_position())
322
       
-
 
-
 
322
323
        # Add Annotation preview stack
323
        # Add Annotation preview stack
324
        preview = self.annotation_preview()
324
        preview = self.annotation_preview()
325
        stack_annotation.add_titled(preview, "preview", "Preview annotation")
325
        stack_annotation.add_titled(preview, "preview", "Preview annotation")
326
        stack_annotation.child_set_property (preview, "icon-name", "basico-preview")
326
        stack_annotation.child_set_property (preview, "icon-name", "basico-preview")
327
       
-
 
-
 
327
328
        # Add Annotation editor stack
328
        # Add Annotation editor stack
329
        editor = self.annotation_editor()
329
        editor = self.annotation_editor()
330
        stack_annotation.add_titled(editor, "editor", "Edit annotation")
330
        stack_annotation.add_titled(editor, "editor", "Edit annotation")
331
        stack_annotation.child_set_property (editor, "icon-name", "basico-drafts")
331
        stack_annotation.child_set_property (editor, "icon-name", "basico-drafts")
332
332
333
        # Add Annotation properties stack
333
        # Add Annotation properties stack
334
        properties = self.annotation_properties()
334
        properties = self.annotation_properties()
335
        stack_annotation.add_titled(properties, "properties", "Edit properties")
335
        stack_annotation.add_titled(properties, "properties", "Edit properties")
336
        stack_annotation.child_set_property (properties, "icon-name", "basico-tags")
336
        stack_annotation.child_set_property (properties, "icon-name", "basico-tags")
337
       
-
 
338
        stack_annotation.set_visible_child_name('editor')
-
 
-
 
337
-
 
338
        self.set_visible_stack('editor')
339
        # ~ stack_annotation.set_visible_child_full('editor', Gtk.StackTransitionType.CROSSFADE)
339
        # ~ stack_annotation.set_visible_child_full('editor', Gtk.StackTransitionType.CROSSFADE)
340
        # ~ stack_annotation.set_property('visible-child', editor)
340
        # ~ stack_annotation.set_property('visible-child', editor)
341
       
-
 
342
       
-
 
343
    def stack_changed(self, *args):
-
 
-
 
341
-
 
342
-
 
343
    def set_visible_stack(self, stack_name='preview'):
-
 
344
        self.srvuif.set_widget_visibility('stack_annotation', True)
344
        stack = self.srvgui.get_widget('stack_annotation')
345
        stack = self.srvgui.get_widget('stack_annotation')
345
        stack_name = stack.get_visible_child_name()
-
 
-
 
346
        stack.set_visible_child_name(stack_name)
346
        if stack_name == 'preview':
347
        if stack_name == 'preview':
347
            self.preview()
348
            self.preview()
348
            self.srvuif.set_widget_visibility('gtk_combobox_annotation_category', False)
349
            self.srvuif.set_widget_visibility('gtk_combobox_annotation_category', False)
349
            self.srvuif.set_widget_visibility('gtk_combobox_annotation_type', False)
350
            self.srvuif.set_widget_visibility('gtk_combobox_annotation_type', False)
350
            self.srvuif.set_widget_visibility('gtk_combobox_annotation_priority', False)
-
 
351
            self.srvuif.set_widget_visibility('gtk_button_annotation_toolbar_attachment', False)
-
 
-
 
351
            self.srvuif.set_widget_visibility('gtk_combobox_annotation_priority', False)
-
 
352
            self.srvuif.set_widget_visibility('gtk_button_annotation_toolbar_attachment', False)
352
        elif stack_name == 'properties':
353
        elif stack_name == 'properties':
353
            self.srvuif.set_widget_visibility('gtk_combobox_annotation_category', False)
354
            self.srvuif.set_widget_visibility('gtk_combobox_annotation_category', False)
354
            self.srvuif.set_widget_visibility('gtk_combobox_annotation_type', False)
355
            self.srvuif.set_widget_visibility('gtk_combobox_annotation_type', False)
355
            self.srvuif.set_widget_visibility('gtk_combobox_annotation_priority', False)
356
            self.srvuif.set_widget_visibility('gtk_combobox_annotation_priority', False)
356
            self.srvuif.set_widget_visibility('gtk_button_annotation_toolbar_attachment', False)
-
 
-
 
357
            self.srvuif.set_widget_visibility('gtk_button_annotation_toolbar_attachment', False)
357
        elif stack_name == 'editor':
358
        elif stack_name == 'editor':
358
            self.srvuif.set_widget_visibility('gtk_combobox_annotation_category', True)
359
            self.srvuif.set_widget_visibility('gtk_combobox_annotation_category', True)
359
            self.srvuif.set_widget_visibility('gtk_combobox_annotation_type', True)
360
            self.srvuif.set_widget_visibility('gtk_combobox_annotation_type', True)
360
            self.srvuif.set_widget_visibility('gtk_combobox_annotation_priority', True)
361
            self.srvuif.set_widget_visibility('gtk_combobox_annotation_priority', True)
361
            self.srvuif.set_widget_visibility('gtk_button_annotation_toolbar_attachment', True)
362
            self.srvuif.set_widget_visibility('gtk_button_annotation_toolbar_attachment', True)
362
             
-
 
-
 
363
363
364
364
    def annotation_preview(self):
365
    def annotation_preview(self):
365
        browser = self.srvgui.add_widget('annotation_browser', BasicoBrowser(self.app))
366
        browser = self.srvgui.add_widget('annotation_browser', BasicoBrowser(self.app))
366
        return browser
367
        return browser
367
368
368
    def annotation_properties(self):
369
    def annotation_properties(self):
369
        properties = self.srvgui.add_widget('annotation_properties', Gtk.Label('Properties'))
370
        properties = self.srvgui.add_widget('annotation_properties', Gtk.Label('Properties'))
370
        return properties
371
        return properties
371
372
372
       
-
 
-
 
373
373
    def annotation_editor(self):
374
    def annotation_editor(self):
374
        vbox = Gtk.VBox()
375
        vbox = Gtk.VBox()
375
376
376
        # Hidden metadata
377
        # Hidden metadata
377
        hhbox = Gtk.HBox()
378
        hhbox = Gtk.HBox()
Line 400... Line 401...
400
        # Text
401
        # Text
401
        scroller = Gtk.ScrolledWindow()
402
        scroller = Gtk.ScrolledWindow()
402
        scroller.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
403
        scroller.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
403
        scroller.set_shadow_type(Gtk.ShadowType.IN)
404
        scroller.set_shadow_type(Gtk.ShadowType.IN)
404
        scroller.set_hexpand(True)
405
        scroller.set_hexpand(True)
405
        scroller.set_vexpand(True)        
-
 
-
 
406
        scroller.set_vexpand(True)
406
        a_text = self.srvgui.add_widget('gtk_textview_annotation_text', GtkSource.View.new_with_buffer(GtkSource.Buffer()))
407
        a_text = self.srvgui.add_widget('gtk_textview_annotation_text', GtkSource.View.new_with_buffer(GtkSource.Buffer()))
407
        a_text.set_wrap_mode(Gtk.WrapMode.WORD)
408
        a_text.set_wrap_mode(Gtk.WrapMode.WORD)
408
        a_text.modify_font(Pango.FontDescription('Monospace 10'))
409
        a_text.modify_font(Pango.FontDescription('Monospace 10'))
409
        a_text.set_vexpand(True)
410
        a_text.set_vexpand(True)
410
        a_text.set_left_margin(6)
411
        a_text.set_left_margin(6)
Line 454... Line 455...
454
455
455
        mhbox.pack_start(vboxl, True, True, 6)
456
        mhbox.pack_start(vboxl, True, True, 6)
456
        mhbox.pack_start(vboxr, False, False, 0)
457
        mhbox.pack_start(vboxr, False, False, 0)
457
        vbox.pack_start(mhbox, True, True, 3)
458
        vbox.pack_start(mhbox, True, True, 3)
458
        return vbox
459
        return vbox
459
       
-
 
-
 
460
460
461
461
462
462
    def __setup_footer(self):
463
    def __setup_footer(self):
463
        # Buttons Accept/Cancel
464
        # Buttons Accept/Cancel
464
        hbox = Gtk.HBox()
465
        hbox = Gtk.HBox()
Line 528... Line 529...
528
                a_wdg_link_type = self.srvgui.get_widget('gtk_combobox_annotation_link_type')
529
                a_wdg_link_type = self.srvgui.get_widget('gtk_combobox_annotation_link_type')
529
530
530
                a_wdg_aid.set_text(annotation['AID'])
531
                a_wdg_aid.set_text(annotation['AID'])
531
                a_wdg_timestamp.set_text(annotation['Timestamp'])
532
                a_wdg_timestamp.set_text(annotation['Timestamp'])
532
                a_wdg_title.set_text(html.escape(annotation['Title']))
533
                a_wdg_title.set_text(html.escape(annotation['Title']))
533
               
-
 
-
 
534
534
                a_wdg_type.set_active_iter(self.srvgui.get_widget('annotation_type_%s' % annotation['Type']))
535
                a_wdg_type.set_active_iter(self.srvgui.get_widget('annotation_type_%s' % annotation['Type']))
535
               
-
 
-
 
536
536
                try:
537
                try:
537
                    a_wdg_category.set_active_iter(self.srvgui.get_widget('annotation_category_%s' % annotation['Category']))
538
                    a_wdg_category.set_active_iter(self.srvgui.get_widget('annotation_category_%s' % annotation['Category']))
538
                except:
539
                except:
539
                    a_wdg_category.set_active_iter(self.srvgui.get_widget('annotation_category_Inbox'))
540
                    a_wdg_category.set_active_iter(self.srvgui.get_widget('annotation_category_Inbox'))
540
541
541
                try:
542
                try:
542
                    a_wdg_priority.set_active_iter(self.srvgui.get_widget('annotation_priority_%s' % annotation['Priority']))
543
                    a_wdg_priority.set_active_iter(self.srvgui.get_widget('annotation_priority_%s' % annotation['Priority']))
543
                except:
544
                except:
544
                    a_wdg_priority.set_active_iter(self.srvgui.get_widget('annotation_priority_Normal'))
545
                    a_wdg_priority.set_active_iter(self.srvgui.get_widget('annotation_priority_Normal'))
545
                   
-
 
-
 
546
546
                self.srvuif.set_textview_text(a_wdg_text, open(ANNOTATION_FILE_CONTENT).read())
547
                self.srvuif.set_textview_text(a_wdg_text, open(ANNOTATION_FILE_CONTENT).read())
547
                a_wdg_link.set_text(annotation['Link'])
548
                a_wdg_link.set_text(annotation['Link'])
548
                a_wdg_link_button.set_uri(annotation['Link'])
549
                a_wdg_link_button.set_uri(annotation['Link'])
549
                a_wdg_link_type.set_active_iter(self.srvgui.get_widget('annotation_link_type_%s' % annotation['LinkType']))
550
                a_wdg_link_type.set_active_iter(self.srvgui.get_widget('annotation_link_type_%s' % annotation['LinkType']))
550
                human_timestamp = self.srvutl.get_human_date_from_timestamp(annotation['Timestamp'])
551
                human_timestamp = self.srvutl.get_human_date_from_timestamp(annotation['Timestamp'])
551
                a_wdg_human_timestamp.set_markup('<b>%s</b>' % human_timestamp)
552
                a_wdg_human_timestamp.set_markup('<b>%s</b>' % human_timestamp)
552
                a_wdg_timestamp_created.set_text(annotation['Created'])
553
                a_wdg_timestamp_created.set_text(annotation['Created'])
553
                self.stack_changed()
-
 
-
 
554
                # ~ self.stack_changed()
554
                # ~ self.preview()
555
                # ~ self.preview()
555
556
556
557
557
    def get_metadata_from_widget(self):
558
    def get_metadata_from_widget(self):
558
        """
559
        """
559
        C:237, 4: Missing method docstring (missing-docstring)
-
 
-
 
560
        C:237, 4: Missing method docstring (missing-docstring)
560
        """
561
        """
561
        annotation = {}
562
        annotation = {}
562
        a_wdg_aid = self.srvgui.get_widget('gtk_label_aid')
563
        a_wdg_aid = self.srvgui.get_widget('gtk_label_aid')
563
        a_wdg_timestamp = self.srvgui.get_widget('gtk_label_timestamp')
564
        a_wdg_timestamp = self.srvgui.get_widget('gtk_label_timestamp')
564
        a_wdg_timestamp_created = self.srvgui.get_widget('gtk_label_timestamp_created')
565
        a_wdg_timestamp_created = self.srvgui.get_widget('gtk_label_timestamp_created')
Line 581... Line 582...
581
        annotation['Content'] = self.srvuif.get_textview_text(a_wdg_text)
582
        annotation['Content'] = self.srvuif.get_textview_text(a_wdg_text)
582
        annotation['Link'] = a_wdg_link.get_text()
583
        annotation['Link'] = a_wdg_link.get_text()
583
        annotation['LinkType'] = self.srvuif.get_combobox_text(a_wdg_link_type, 0)
584
        annotation['LinkType'] = self.srvuif.get_combobox_text(a_wdg_link_type, 0)
584
585
585
        return annotation
586
        return annotation
-
 
587
-
 
588
-
 
589
    def stack_changed(self, stack, gparam):
-
 
590
        visible_stack_name = stack.get_visible_child_name()
-
 
591
        if visible_stack_name == 'preview':
-
 
592
            try:
-
 
593
                self.preview()
-
 
594
            except:
-
 
595
                pass
586
596
587
597
588
    def preview(self):
598
    def preview(self):
589
        aid = self.get_aid_from_widget()
599
        aid = self.get_aid_from_widget()
590
        atype = self.srvant.get_metadata_value(aid, 'Type')
600
        atype = self.srvant.get_metadata_value(aid, 'Type')
Line 599... Line 609...
599
                target = self.srvacd.generate_preview(aid)
609
                target = self.srvacd.generate_preview(aid)
600
                browser.load_url(html.escape(target))
610
                browser.load_url(html.escape(target))
601
        except:
611
        except:
602
            self.log.debug("Showing editor instead preview")
612
            self.log.debug("Showing editor instead preview")
603
            stack_annotation = self.srvgui.get_widget('stack_annotation')
613
            stack_annotation = self.srvgui.get_widget('stack_annotation')
604
            stack_annotation.set_visible_child_name('editor')
-
 
-
 
614
            self.set_visible_stack('editor')
605
        # ~ self.log.debug("Load preview from %s", target)
615
        # ~ self.log.debug("Load preview from %s", target)