Thanks for the reviews so far!  While updating my jhbuild I came
accros a couple other related patches (attached).  I'm building again
as I write this, so I'll try to rebase all of my patches today.

The first is just visual, the second is a change to sugar-toolkit
which is required to support the highlighting of the tray on drag, and
the last just makes use of the go-up/go-down arrows which have been in
the them for some time, but never referenced in the tray code, which
was using left/right instead.

On Mon, Oct 20, 2008 at 6:05 AM, Tomeu Vizoso <[EMAIL PROTECTED]> wrote:
> On Fri, Oct 17, 2008 at 7:06 PM, Eben Eliason <[EMAIL PROTECTED]> wrote:
>> On Fri, Oct 17, 2008 at 12:48 PM, Tomeu Vizoso <[EMAIL PROTECTED]> wrote:
>>> On Fri, Oct 17, 2008 at 6:11 PM, Eben Eliason <[EMAIL PROTECTED]> wrote:
>>>> This is a set of patches I worked on recently, and need to rebase on
>>>> the latest jhbuild before I post them officially.  I wanted to expose
>>>> them for comments before I put in that effort, since there are no
>>>> doubt other things that will need to be changed upon review.
>>>>
>>>> Thanks!
>>>>
>>>> - Eben
>>>>
>>>> PS.  I just noticed upon attaching that the first isn't actually a
>>>> clipboard patch, but it was part of a sprint on clipboard and
>>>> drag'n'drop in general, so I include it.
>>>
>>> [PATCH] Lock cursor to center of icons in favorites view on drag (#7408)
>>>
>>> Looks good, you can as well calculate again the hot point from the
>>> pixbuf in the context, instead of adding two private members more to
>>> the class.
>>
>> Oh really?  I didn't see a way to pull that back out.  Could you give
>> me a pointer?
>
> You are right, I expected that gtk.DragContext would have an accesor
> as well as a setter.
>
>>> [PATCH] Add descriptions to clippings (#5751)
>>>
>>> Not sure if we should do the formatting in model/clipboardobject.py,
>>> that looks to me more like a presentation issue so should live in the
>>> view classes?
>>
>> I debated this back and forth.  My decision to put it in the model
>> meant that we could simple return a description easily in the correct
>> format given the clipping type. Otherwise, the view needs to special
>> case based on the type of the clipping.  It seemed to me (ignoring the
>> details of implementation) that I really just wanted "description" to
>> be "just a string" in the model, which the view could call up at any
>> point.  From this perspective, it's natural for the model to return an
>> appropriate string, and for the view to color, size, position, etc.
>> that string as it wants, right?
>
> I'm ok with the concept of a single-line description of a clipping
> living in the model, but the _MAX_DESCRIPTION_LENGTH value seems to me
> like a UI decision. What about moving it to be an argument of
> get_description()?

That sounds like a good idea.

> +            if key == 'STRING':
>
> I'm not sure all text clippings will have the STRING target, I would do 
> instead:
>
> +            if key in ['STRING', 'text/plain', ...]:
>
> (I'm not really sure which are the most common targets that contain
> text, I would check the logs after a paste, these are printed in
> there).

I'll take a look, thanks.  I was always unsure about the best way to
get that info; I just needed something that worked to get the rest up
and running.  I'll look at your previous patch to similar effect,
also.

- Eben

>>> [PATCH] Prevent duplicate clippings on drag within clipboard (#8606)
>>>
>>> Sounds good as a temporary measure, but I think that Gtk+ has support
>>> in its trays for reordering elements with DnD. Or it may be some
>>> extension to gtk+? Worth investigating.
>>
>> Yes, that's the long term solution.  I just wanted something to clean
>> up the behavior to prevent confusion in the meantime.  There is a TODO
>> somewhere in there where I mention we should be rearranging instead, I
>> think.  It might be the case that doing it right makes the rest of
>> this patch obsolete, but I'm not sure.
>
> Sure, I think that your solution is very good in the meantime.
>
> Thanks,
>
> Tomeu
>
From 7049b8ffc5adee08afa78033cd56e894996154b0 Mon Sep 17 00:00:00 2001
From: Eben Eliason <[EMAIL PROTECTED](none)>
Date: Tue, 23 Sep 2008 20:36:46 -0400
Subject: [PATCH] Size and position clippings correctly when dragged

---
 src/view/clipboardicon.py |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/src/view/clipboardicon.py b/src/view/clipboardicon.py
index c5b6ae7..43f7a6a 100644
--- a/src/view/clipboardicon.py
+++ b/src/view/clipboardicon.py
@@ -21,6 +21,7 @@ import gtk
 from sugar.graphics.radiotoolbutton import RadioToolButton
 from sugar.graphics.icon import Icon
 from sugar.graphics.xocolor import XoColor
+from sugar.graphics import style
 from sugar import profile
 
 from model import clipboard
@@ -106,10 +107,10 @@ class ClipboardIcon(RadioToolButton):
             self._icon.props.icon_name = 'application-octet-stream'
 
         child = self.get_child()
+        child.connect('drag-begin', self._drag_begin_cb)
         child.drag_source_set(gtk.gdk.BUTTON1_MASK,
                               self._get_targets(),
                               gtk.gdk.ACTION_COPY)
-        child.drag_source_set_icon_name(self._icon.props.icon_name)
 
         if cb_object.get_percent() == 100:
             self.props.sensitive = True
@@ -128,6 +129,14 @@ class ClipboardIcon(RadioToolButton):
                                    view.frame.frame.BOTTOM_LEFT)
         self._current_percent = cb_object.get_percent()
 
+    def _drag_begin_cb(self, widget, context):
+        # TODO: We should get the pixbuf from the icon, with colors, etc.
+        icon_theme = gtk.icon_theme_get_default()
+        pixbuf = icon_theme.load_icon(self._icon.props.icon_name,
+                                      style.STANDARD_ICON_SIZE, 0)
+        context.set_icon_pixbuf(pixbuf, pixbuf.props.width / 2,
+                                pixbuf.props.height / 2)
+
     def _notify_active_cb(self, widget, pspec):
         if self.props.active:
             self._put_in_clipboard()
-- 
1.5.4.3

From 90ebbfd57633468139c1e768516d8c075cf0caad Mon Sep 17 00:00:00 2001
From: Eben Eliason <[EMAIL PROTECTED](none)>
Date: Sun, 21 Sep 2008 17:40:13 -0400
Subject: [PATCH] Add drag-active property to tray control (#8604)

The drag-active property can be set to provide a highlight
when the tray control is accepting target of an ongoing drag.
---
 src/sugar/graphics/tray.py |   79 ++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 73 insertions(+), 6 deletions(-)

diff --git a/src/sugar/graphics/tray.py b/src/sugar/graphics/tray.py
index d5e9b39..678b235 100644
--- a/src/sugar/graphics/tray.py
+++ b/src/sugar/graphics/tray.py
@@ -211,7 +211,19 @@ ALIGN_TO_START = 0
 ALIGN_TO_END = 1
 
 class HTray(gtk.HBox):
+    __gtype_name__ = 'SugarHTray'
+
+    __gproperties__ = {
+        'align'         : (int, None, None, 0, 1, ALIGN_TO_START,
+                           gobject.PARAM_READWRITE |
+                           gobject.PARAM_CONSTRUCT_ONLY),
+        'drag-active'   : (bool, None, None, False,
+                           gobject.PARAM_READWRITE)
+    }
     def __init__(self, **kwargs):
+        self._drag_active = False
+        self.align = ALIGN_TO_START
+
         gobject.GObject.__init__(self, **kwargs)
 
         scroll_left = _TrayScrollButton('go-left', _PREVIOUS_PAGE)
@@ -235,9 +247,30 @@ class HTray(gtk.HBox):
             self._viewport.traybar.insert(spacer, 0)
             spacer.show()
 
-    align = gobject.property(
-            flags=gobject.PARAM_CONSTRUCT_ONLY | gobject.PARAM_READWRITE,
-            default=ALIGN_TO_START, type=int)
+    def do_set_property(self, pspec, value):
+        if pspec.name == 'align':
+            self.align = value
+        elif pspec.name == 'drag-active':
+            self._set_drag_active(value)
+        else:
+            raise AssertionError
+
+    def do_get_property(self, pspec):
+        if pspec.name == 'align':
+            return self.align
+        elif pspec.name == 'drag-active':
+            return self._drag_active
+        else:
+            raise AssertionError
+
+    def _set_drag_active(self, active):
+        if self._drag_active != active:
+            self._drag_active = active
+            if self._drag_active:
+                self._viewport.traybar.modify_bg(gtk.STATE_NORMAL,
+                        style.COLOR_BLACK.get_gdk_color())
+            else:
+                self._viewport.traybar.modify_bg(gtk.STATE_NORMAL, None)
 
     def get_children(self):
         children = self._viewport.traybar.get_children()[:]
@@ -263,7 +296,20 @@ class HTray(gtk.HBox):
         self._viewport.scroll_to_item(item)
 
 class VTray(gtk.VBox):
+    __gtype_name__ = 'SugarVTray'
+
+    __gproperties__ = {
+        'align'         : (int, None, None, 0, 1, ALIGN_TO_START,
+                           gobject.PARAM_READWRITE |
+                           gobject.PARAM_CONSTRUCT_ONLY),
+        'drag-active'   : (bool, None, None, False,
+                           gobject.PARAM_READWRITE)
+    }
+
     def __init__(self, **kwargs):
+        self._drag_active = False
+        self.align = ALIGN_TO_START
+
         gobject.GObject.__init__(self, **kwargs)
 
         # FIXME we need a go-up icon
@@ -289,9 +335,30 @@ class VTray(gtk.VBox):
             self._viewport.traybar.insert(spacer, 0)
             spacer.show()
 
-    align = gobject.property(
-            flags=gobject.PARAM_CONSTRUCT_ONLY | gobject.PARAM_READWRITE,
-            default=ALIGN_TO_START, type=int)
+    def do_set_property(self, pspec, value):
+        if pspec.name == 'align':
+            self.align = value
+        elif pspec.name == 'drag-active':
+            self._set_drag_active(value)
+        else:
+            raise AssertionError
+
+    def do_get_property(self, pspec):
+        if pspec.name == 'align':
+            return self.align
+        elif pspec.name == 'drag-active':
+            return self._drag_active
+        else:
+            raise AssertionError
+
+    def _set_drag_active(self, active):
+        if self._drag_active != active:
+            self._drag_active = active
+            if self._drag_active:
+                self._viewport.traybar.modify_bg(gtk.STATE_NORMAL,
+                        style.COLOR_BLACK.get_gdk_color())
+            else:
+                self._viewport.traybar.modify_bg(gtk.STATE_NORMAL, None)
 
     def get_children(self):
         children = self._viewport.traybar.get_children()[:]
-- 
1.5.4.3

From 83bd60f62bb90f4ade5039b46cb747bdb205563e Mon Sep 17 00:00:00 2001
From: Eben Eliason <[EMAIL PROTECTED](none)>
Date: Tue, 23 Sep 2008 11:39:07 -0400
Subject: [PATCH] Fix up/down arrows in VTrays (#8617)

---
 src/sugar/graphics/tray.py |   14 ++++++--------
 1 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/src/sugar/graphics/tray.py b/src/sugar/graphics/tray.py
index 678b235..21ecbb0 100644
--- a/src/sugar/graphics/tray.py
+++ b/src/sugar/graphics/tray.py
@@ -312,20 +312,18 @@ class VTray(gtk.VBox):
 
         gobject.GObject.__init__(self, **kwargs)
 
-        # FIXME we need a go-up icon
-        scroll_left = _TrayScrollButton('go-left', _PREVIOUS_PAGE)
-        self.pack_start(scroll_left, False)
+        scroll_up = _TrayScrollButton('go-up', _PREVIOUS_PAGE)
+        self.pack_start(scroll_up, False)
 
         self._viewport = _TrayViewport(gtk.ORIENTATION_VERTICAL)
         self.pack_start(self._viewport)
         self._viewport.show()
 
-        # FIXME we need a go-down icon
-        scroll_right = _TrayScrollButton('go-right', _NEXT_PAGE)
-        self.pack_start(scroll_right, False)
+        scroll_down = _TrayScrollButton('go-down', _NEXT_PAGE)
+        self.pack_start(scroll_down, False)
 
-        scroll_left.viewport = self._viewport
-        scroll_right.viewport = self._viewport
+        scroll_up.viewport = self._viewport
+        scroll_down.viewport = self._viewport
 
         if self.align == ALIGN_TO_END:
             spacer = gtk.SeparatorToolItem()
-- 
1.5.4.3

_______________________________________________
Sugar mailing list
[email protected]
http://lists.laptop.org/listinfo/sugar

Reply via email to