[Sugar-devel] How to have "CellRenderer.props" take effect, without a UI refresh?

Ajay Garg ajay at activitycentral.com
Wed Aug 1 04:03:09 EDT 2012


Thanks Sascha and Flavio.


a)
I modified the code to ::

####################################################################################
    def __favorite_set_data_cb(self, column, cell, tree_model, tree_iter):
        favorite = tree_model[tree_iter][ListModel.COLUMN_FAVORITE]

        if favorite:
            client = gconf.client_get_default()
            color = XoColor(client.get_string('/desktop/sugar/user/color'))
            cell.props.xo_color = color
        else:
            cell.props.xo_color = None


<VAR>.get_property('window').invalidate_rect(<VAR>.get_allocation(), False)
        <VAR>.get_property('window').process_updates(True)
####################################################################################

where I tried with values of <VAR> to ::

                          *  self
                          *  self.tree_view

However, it made no difference.




b)
I modified the code to ::

####################################################################################
    def __favorite_set_data_cb(self, column, cell, tree_model, tree_iter):
        favorite = tree_model[tree_iter][ListModel.COLUMN_FAVORITE]

        if favorite:
            client = gconf.client_get_default()
            color = XoColor(client.get_string('/desktop/sugar/user/color'))
            cell.props.xo_color = color
        else:
            cell.props.xo_color = None


<VAR>.get_property('window').invalidate_rect(<VAR>.get_allocation(), True)
        <VAR>.get_property('window').process_updates(True)
####################################################################################

where I tried with values of <VAR> to ::

                          *  self
                          *  self.tree_view

However, it caused an infinite recursive loop, and the journal never loaded.




c)
I modified the code to ::

####################################################################################
    def __favorite_set_data_cb(self, column, cell, tree_model, tree_iter):
        favorite = tree_model[tree_iter][ListModel.COLUMN_FAVORITE]

        if favorite:
            client = gconf.client_get_default()
            color = XoColor(client.get_string('/desktop/sugar/user/color'))
            cell.props.xo_color = color
        else:
            cell.props.xo_color = None


<VAR>.get_property('window').invalidate_rect(<VAR>.get_allocation(), False)
        <VAR>.get_property('window').process_updates(True)
####################################################################################

where I tried with values of <VAR> to ::

                          *  column
                          *  cell

However, it caused the following traceback ::

Traceback (most recent call last):
  File
"/home/ajay/sugar-jhbuild-dx3/install/lib/python2.7/site-packages/jarabe/journal/listview.py",
line 329, in __favorite_set_data_cb
    column.get_property('window').invalidate_rect(column.get_allocation(),
False)
TypeError: object of type `GtkTreeViewColumn' does not have property
`window'




d)
I modified the code to ::

####################################################################################
    def __favorite_set_data_cb(self, column, cell, tree_model, tree_iter):
        favorite = tree_model[tree_iter][ListModel.COLUMN_FAVORITE]

        if favorite:
            client = gconf.client_get_default()
            color = XoColor(client.get_string('/desktop/sugar/user/color'))
            cell.props.xo_color = color
        else:
            cell.props.xo_color = None


<VAR>.get_property('window').invalidate_rect(<VAR>.get_allocation(), True)
        <VAR>.get_property('window').process_updates(True)
####################################################################################

where I tried with values of <VAR> to ::

                          *  column
                          *  cell

Same as before - it caused the following traceback ::

Traceback (most recent call last):
  File
"/home/ajay/sugar-jhbuild-dx3/install/lib/python2.7/site-packages/jarabe/journal/listview.py",
line 329, in __favorite_set_data_cb
    column.get_property('window').invalidate_rect(column.get_allocation(),
False)
TypeError: object of type `GtkTreeViewColumn' does not have property
`window'



:-\



Regards,
Ajay




On Tue, Jul 31, 2012 at 7:07 AM, Flavio Danesse <fdanesse at gmail.com> wrote:

> self.get_property('window').invalidate_rect(self.get_allocation(), True)
> self.get_property('window').process_updates(True)
>
>
>
>
> 2012/7/30 Sascha Silbe <silbe at activitycentral.com>
>
>> Ajay Garg <ajay at activitycentral.com> writes:
>>
>> >> [adding short-circuit logic to
>> >> jarabe.journal.listview.BaseListView.refresh()]
>> [...]
>> >> What we should do is enhancing the logic to
>> >>
>> >> a) just redraw instead of querying the back-end again for changes we
>> >>    triggered ourselves and / or
>> >> b) update our model based on the change notifications rather than
>> >>    throwing away our state.
>> >>
>> >
>> > Well, that's exactly what I did, via the patch
>> >
>> http://git.sugarlabs.org/dextrose/mainline/commit/ad3897946e013f1ff4020aeab35375ccb122758b
>>
>> Not really AFAICT. You're still inhibiting the refresh completely,
>> without doing a redraw. You're also doing a gratuitous data store query
>> for each favourite star. I'm expecting that to have considerable impact
>> on performance.
>>
>>
>> > I guess, if we could somehow cause the mouse to PROGRAMMATICALLY
>> > hover-away/disappear-momentarily when the star/favorite-icon is
>> clicked, we
>> > could be done.
>> > However, I am not able to find a way to do this via pygtk.
>>
>> Fortunately. :-P
>>
>> As discussed on IRC, the way to _trigger_ _a_ _redraw_ (not: move the
>> pointer) is something like this:
>>
>>     x_, y_, width, height = self.allocation
>>     area = (0, 0, width, height)
>>     self.window.invalidate_rect(area, False)
>>
>>
>> Sascha
>> --
>> http://sascha.silbe.org/
>> http://www.infra-silbe.de/
>>
>> _______________________________________________
>> Sugar-devel mailing list
>> Sugar-devel at lists.sugarlabs.org
>> http://lists.sugarlabs.org/listinfo/sugar-devel
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20120801/29aab64a/attachment.html>


More information about the Sugar-devel mailing list