Well, here's what I've got at present. It seems to be a worthwhile
cleanup patch even though it doesn't fix the problem I set out to fix.
It's true that the new Journal designs will eliminate the problem
once we get around to implementing them. I suppose we'll have to live
with the slow feedback on the favorite buttons in the interim.
- Eben
On Fri, Apr 25, 2008 at 10:55 AM, Tomeu Vizoso <[EMAIL PROTECTED]> wrote:
>
> On Thu, Apr 24, 2008 at 11:37 PM, Eben Eliason <[EMAIL PROTECTED]> wrote:
> > On Thu, Apr 24, 2008 at 5:25 PM, Bert Freudenberg <[EMAIL PROTECTED]>
> wrote:
> > >
> > >
> > > On 24.04.2008, at 22:56, Eben Eliason wrote:
> > >
> > >
> > > > On Thu, Apr 24, 2008 at 4:47 PM, Jameson Chema Quinn
> > > > <[EMAIL PROTECTED]> wrote:
> > > >
> > > > > you check the keep property before you set it, and do not touch it
> if
> > > you
> > > > > are not going to change it.
> > > > >
> > > >
> > > > That does in fact sound like a reasonable way to handle it. It
> > > > doesn't require an extra time around "the loop"....it simply stops it
> > > > directly at the signal handler for the KeepIcon change event by not
> > > > overwriting with the same value. Don't I feel stupid now....
> > > >
> > >
> > >
> > > I'd even consider it a bug if overwriting a property with the same
> value
> > > would emit a change event - but maybe this is how the framework works?
> >
> > Good point. That seems not to be the case.
> >
> > In other news, despite the much cleaner underlying code, my initial
> > treatment fails to alleviate the symptom! It appears that the redraw
> > doesn't happen until after all of the signal handling business has run
> > its course. This includes, as mentioned in my first message,
> > refreshing the entire view. I looked at this again, and there is no
> > check for the particular CollapsedEntry which changed at all.
> > Instead, it loops over each one, refreshing each by setting the
> > jobject property of each, which of course resets the keep icon, resets
> > the object icon, creates a brand new palette from scratch and attaches
> > it to the object icon, looks up and formats the date, reads the list
> > of buddies and creates their associated objects and palettes, and a
> > number of other smaller tasks. That's for /each/ entry shown, all
> > because one toggle button was clicked! This seems like serious
> > overkill, but I'm not sure if there's an obvious way to isolate the
> > changes. It does seem that, if anything, either the query.py or
> > listview.py code should be more intelligent about determining what
> > changes are worth doing such comprehensive updates for. This is not
> > one of them.
> >
> > Tomeu, you worked on the query and list code. Do you have any insight
> > into this?
>
> The lazy programmer that coded this (me) thought that the simple
> solution implemented was efficient enough and could be written in a
> simple way with many mainteinance advantages.
>
> Eben, your new designs will render this code totally obsolete, so
> what's the point in changing this right now?
>
> About the signal loop, it's my opinion that most property setting code
> should only do its thing if the new value is different to the current
> one. This can affect performance considerably, as well.
>
> Thanks,
>
> Tomeu
>
diff --git a/collapsedentry.py b/collapsedentry.py
index c99208a..d365dfa 100644
--- a/collapsedentry.py
+++ b/collapsedentry.py
@@ -118,8 +118,7 @@ class CollapsedEntry(hippo.CanvasBox):
def _create_keep_icon(self):
keep_icon = KeepIcon(False)
- keep_icon.connect('button-release-event',
- self._keep_icon_button_release_event_cb)
+ keep_icon.connect('notify::keep', self._keep_changed_cb)
return keep_icon
def _create_date(self):
@@ -223,25 +222,21 @@ class CollapsedEntry(hippo.CanvasBox):
return self._jobject.metadata.has_key('keep') and \
self._jobject.metadata['keep'] == 1
- def _keep_icon_button_release_event_cb(self, button, event):
- logging.debug('_keep_icon_button_release_event_cb')
+ def _keep_changed_cb(self, keep_icon, event):
jobject = datastore.get(self._jobject.object_id)
try:
- if self.get_keep():
- jobject.metadata['keep'] = 0
- else:
- jobject.metadata['keep'] = 1
- datastore.write(jobject, update_mtime=False)
+ if keep_icon.props.keep != jobject.metadata['keep']:
+ if keep_icon.props.keep:
+ jobject.metadata['keep'] = 1
+ else:
+ jobject.metadata['keep'] = 0
+ datastore.write(jobject, update_mtime=False)
finally:
jobject.destroy()
- self._keep_icon.props.keep = self.get_keep()
- self._update_color()
-
return True
def _icon_button_release_event_cb(self, button, event):
- logging.debug('_icon_button_release_event_cb')
self._jobject.resume()
return True
@@ -287,7 +282,6 @@ class CollapsedEntry(hippo.CanvasBox):
logging.error('CollapsedEntry._datastore_write_error_cb: %r' % error)
def _detail_button_release_event_cb(self, button, event):
- logging.debug('_detail_button_release_event_cb')
if not self._is_in_progress():
self.emit('entry-activated')
return True
@@ -299,7 +293,6 @@ class CollapsedEntry(hippo.CanvasBox):
button.props.fill_color = style.COLOR_BUTTON_GREY.get_svg()
def _cancel_button_release_event_cb(self, button, event):
- logging.debug('_cancel_button_release_event_cb')
datastore.delete(self._jobject.object_id)
return True
@@ -307,11 +300,6 @@ class CollapsedEntry(hippo.CanvasBox):
self._is_selected = is_selected
self._update_color()
- def _frame_button_release_event_cb(self, frame, event):
- logging.debug('_frame_button_release_event_cb')
- if not self._is_in_progress():
- self.emit('entry-activated')
-
def set_jobject(self, jobject):
self._jobject = jobject
self._is_selected = False
diff --git a/expandedentry.py b/expandedentry.py
index 693a41c..d7ca82d 100644
--- a/expandedentry.py
+++ b/expandedentry.py
@@ -377,16 +377,14 @@ class ExpandedEntry(hippo.CanvasBox):
self._jobject.metadata['keep'] == 1
def _keep_icon_activated_cb(self, keep_icon):
- if self.get_keep():
- self._jobject.metadata['keep'] = 0
- else:
- self._jobject.metadata['keep'] = 1
- datastore.write(self._jobject, update_mtime=False)
-
- keep_icon.props.keep = self.get_keep()
+ if keep_icon.props.keep != self._jobject.metadata['keep']:
+ if keep_icon.props.keep:
+ self._jobject.metadata['keep'] = 1
+ else:
+ self._jobject.metadata['keep'] = 0
+ datastore.write(self._jobject, update_mtime=False)
def _icon_button_release_event_cb(self, button, event):
- logging.debug('_icon_button_release_event_cb')
self._jobject.resume()
return True
diff --git a/keepicon.py b/keepicon.py
index ba0f180..202a27a 100644
--- a/keepicon.py
+++ b/keepicon.py
@@ -16,6 +16,7 @@
import gobject
import hippo
+import logging
from sugar.graphics.icon import CanvasIcon
from sugar.graphics import style
@@ -32,6 +33,7 @@ class KeepIcon(CanvasIcon):
box_width=style.GRID_CELL_SIZE * 3 / 5,
size=style.SMALL_ICON_SIZE)
self.connect('motion-notify-event', self.__motion_notify_event_cb)
+ self.connect('button-release-event', self.__button_release_event_cb)
self._keep = None
self._set_keep(keep)
@@ -66,3 +68,5 @@ class KeepIcon(CanvasIcon):
elif event.detail == hippo.MOTION_DETAIL_LEAVE:
icon.props.fill_color = style.COLOR_TRANSPARENT.get_svg()
+ def __button_release_event_cb(self, button, event):
+ self.props.keep = not self.props.keep
_______________________________________________
Sugar mailing list
[email protected]
http://lists.laptop.org/listinfo/sugar