Ticket #1271: sugar-1271.patch

File sugar-1271.patch, 7.7 KB (added by alsroot, 12 years ago)
  • src/jarabe/journal/detailview.py

    From b1d437f93282c895d8219e6fac0e8c2fad4de078 Mon Sep 17 00:00:00 2001
    From: Aleksey Lim <alsroot@member.fsf.org>
    Date: Fri, 4 Sep 2009 14:10:50 +0000
    Subject: Details dialog blinks while requery #1271
    
    ---
     src/jarabe/journal/detailview.py    |    8 ++--
     src/jarabe/journal/expandedentry.py |   92 ++++++++++++++++++++++-------------
     2 files changed, 62 insertions(+), 38 deletions(-)
    
    diff --git a/src/jarabe/journal/detailview.py b/src/jarabe/journal/detailview.py
    index 47fdb1f..b4a2339 100644
    a b class DetailView(gtk.VBox): 
    6464        return False
    6565
    6666    def _update_view(self):
    67         if self._expanded_entry:
    68             self._root.remove(self._expanded_entry)
    69         self._expanded_entry = ExpandedEntry(self._metadata)
    70         self._root.append(self._expanded_entry, hippo.PACK_EXPAND)
     67        if self._expanded_entry is None:
     68            self._expanded_entry = ExpandedEntry()
     69            self._root.append(self._expanded_entry, hippo.PACK_EXPAND)
     70        self._expanded_entry.set_metadata(self._metadata)
    7171
    7272    def refresh(self):
    7373        logging.debug('DetailView.refresh')
  • src/jarabe/journal/expandedentry.py

    diff --git a/src/jarabe/journal/expandedentry.py b/src/jarabe/journal/expandedentry.py
    index ff830bf..fdf3478 100644
    a b class BuddyList(hippo.CanvasBox): 
    6363            self.append(hbox)
    6464
    6565class ExpandedEntry(hippo.CanvasBox):
    66     def __init__(self, metadata):
     66    def __init__(self):
    6767        hippo.CanvasBox.__init__(self)
    6868        self.props.orientation = hippo.ORIENTATION_VERTICAL
    6969        self.props.background_color = style.COLOR_WHITE.get_int()
    7070        self.props.padding_top = style.DEFAULT_SPACING * 3
    7171
    72         self._metadata = metadata
     72        self._metadata = None
    7373        self._update_title_sid = None
    7474
    7575        # Create header
    class ExpandedEntry(hippo.CanvasBox): 
    102102        self._keep_icon = self._create_keep_icon()
    103103        header.append(self._keep_icon)
    104104
    105         self._icon = self._create_icon()
    106         header.append(self._icon)
     105        self._icon = None
     106        self._icon_box = hippo.CanvasBox()
     107        header.append(self._icon_box)
    107108
    108109        self._title = self._create_title()
    109110        header.append(self._title, hippo.PACK_EXPAND)
    class ExpandedEntry(hippo.CanvasBox): 
    117118
    118119        # First column
    119120
    120         self._preview = self._create_preview()
    121         first_column.append(self._preview)
     121        self._preview_box = hippo.CanvasBox()
     122        first_column.append(self._preview_box)
    122123
    123         technical_box = self._create_technical()
    124         first_column.append(technical_box)
     124        self._technical_box = hippo.CanvasBox()
     125        first_column.append(self._technical_box)
    125126
    126127        # Second column
    127128
    class ExpandedEntry(hippo.CanvasBox): 
    131132        tags_box, self._tags = self._create_tags()
    132133        second_column.append(tags_box)
    133134
    134         self._buddy_list = self._create_buddy_list()
     135        self._buddy_list = hippo.CanvasBox()
    135136        second_column.append(self._buddy_list)
    136137
     138    def set_metadata(self, metadata):
     139        if self._metadata == metadata:
     140            return
     141        self._metadata = metadata
     142
     143        self._keep_icon.keep = (int(metadata.get('keep', 0)) == 1)
     144
     145        self._icon = self._create_icon()
     146        self._icon_box.clear()
     147        self._icon_box.append(self._icon)
     148
     149        self._date.props.text = misc.get_date(metadata)
     150
     151        title = self._title.props.widget
     152        title.props.text = metadata.get('title', _('Untitled'))
     153        title.props.editable = model.is_editable(metadata)
     154
     155        self._preview_box.clear()
     156        self._preview_box.append(self._create_preview())
     157
     158        self._technical_box.clear()
     159        self._technical_box.append(self._create_technical())
     160
     161        self._buddy_list.clear()
     162        self._buddy_list.append(self._create_buddy_list())
     163
     164        description = self._description.text_view_widget
     165        description.props.buffer.props.text = metadata.get('description', '')
     166        description.props.editable = model.is_editable(metadata)
     167
     168        tags = self._tags.text_view_widget
     169        tags.props.buffer.props.text = metadata.get('tags', '')
     170        tags.props.editable = model.is_editable(metadata)
     171
    137172    def _create_keep_icon(self):
    138         keep = int(self._metadata.get('keep', 0)) == 1
    139         keep_icon = KeepIcon(keep)
     173        keep_icon = KeepIcon(False)
    140174        keep_icon.connect('activated', self._keep_icon_activated_cb)
    141175        return keep_icon
    142176
    class ExpandedEntry(hippo.CanvasBox): 
    160194
    161195    def _create_title(self):
    162196        entry = gtk.Entry()
    163         entry.props.text = self._metadata.get('title', _('Untitled'))
     197        entry.connect('focus-out-event', self._title_focus_out_event_cb)
    164198
    165199        bg_color = style.COLOR_WHITE.get_gdk_color()
    166200        entry.modify_bg(gtk.STATE_INSENSITIVE, bg_color)
    167201        entry.modify_base(gtk.STATE_INSENSITIVE, bg_color)
    168202
    169         entry.props.editable = model.is_editable(self._metadata)
    170         if entry.props.editable:
    171             entry.connect('focus-out-event', self._title_focus_out_event_cb)
    172 
    173203        return hippo.CanvasWidget(widget=entry)
    174204
    175205    def _create_date(self):
    176206        date = hippo.CanvasText(xalign=hippo.ALIGNMENT_START,
    177                                 font_desc=style.FONT_NORMAL.get_pango_desc(),
    178                                 text = misc.get_date(self._metadata))
     207                                font_desc=style.FONT_NORMAL.get_pango_desc())
    179208        return date
    180209
    181210    def _create_preview(self):
    class ExpandedEntry(hippo.CanvasBox): 
    297326
    298327        vbox.append(text)
    299328
    300         description = self._metadata.get('description', '')
    301         text_view = CanvasTextView(description,
    302                                    box_height=style.GRID_CELL_SIZE * 2)
     329        text_view = CanvasTextView('',
     330                box_height=style.GRID_CELL_SIZE * 2)
    303331        vbox.append(text_view, hippo.PACK_EXPAND)
    304332
    305333        text_view.text_view_widget.props.accepts_tab = False
    306         editable = model.is_editable(self._metadata)
    307         if editable:
    308             text_view.text_view_widget.connect('focus-out-event',
    309                     self._description_focus_out_event_cb)
    310         text_view.text_view_widget.props.editable = editable
     334        text_view.text_view_widget.connect('focus-out-event',
     335                self._description_focus_out_event_cb)
    311336
    312337        return vbox, text_view
    313338
    class ExpandedEntry(hippo.CanvasBox): 
    326351
    327352        vbox.append(text)
    328353
    329         tags = self._metadata.get('tags', '')
    330         text_view = CanvasTextView(tags, box_height=style.GRID_CELL_SIZE * 2)
     354        text_view = CanvasTextView('',
     355                box_height=style.GRID_CELL_SIZE * 2)
    331356        vbox.append(text_view, hippo.PACK_EXPAND)
    332357
    333358        text_view.text_view_widget.props.accepts_tab = False
    334         editable = model.is_editable(self._metadata)
    335         if editable:
    336             text_view.text_view_widget.connect('focus-out-event',
    337                     self._tags_focus_out_event_cb)
    338         text_view.text_view_widget.props.editable = editable
     359        text_view.text_view_widget.connect('focus-out-event',
     360                self._tags_focus_out_event_cb)
    339361
    340362        return vbox, text_view
    341363
    class ExpandedEntry(hippo.CanvasBox): 
    354376        self._update_entry()
    355377
    356378    def _update_entry(self):
     379        if not model.is_editable(self._metadata):
     380            return
     381
    357382        needs_update = False
    358383
    359384        old_title = self._metadata.get('title', None)
    class ExpandedEntry(hippo.CanvasBox): 
    405430        logging.debug('_preview_box_button_release_event_cb')
    406431        misc.resume(self._metadata)
    407432        return True
    408