Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorflavio <fdanesse@gmail.com>2012-12-09 15:27:05 (GMT)
committer flavio <fdanesse@gmail.com>2012-12-09 15:27:05 (GMT)
commitc97d9ea7dd2c6b250c2ea3659c78b9aa5bf087e2 (patch)
tree27cab497440765d589bae8e6e20601e6ffc071b0
parentb104cd55755ff9fe5bafe2bd735d0812e74e20ad (diff)
Remove HippoCanvas - New HTray.
-rw-r--r--record.py28
-rw-r--r--tray.py110
2 files changed, 84 insertions, 54 deletions
diff --git a/record.py b/record.py
index b1c09fd..d46d8c5 100644
--- a/record.py
+++ b/record.py
@@ -52,7 +52,7 @@ from button import RecdButton
import constants
from instance import Instance
import utils
-#from tray import HTray # FIXME: no more HIPPO
+from tray import HTray
from mediaview import MediaView
import hw
from iconcombobox import IconComboBox
@@ -238,11 +238,11 @@ class Record(activity.Activity):
self._record_container = RecordContainer(self._media_view, self._controls_hbox)
main_box.pack_start(self._record_container, True, True, 6)
self._record_container.show()
- # FIXME: no more Hippo
- #self._thumb_tray = HTray()
- #self._thumb_tray.set_size_request(-1, 150)
- #main_box.pack_end(self._thumb_tray, False, False, 0)
- #self._thumb_tray.show_all()
+
+ self._thumb_tray = HTray()
+ self._thumb_tray.set_size_request(-1, 150)
+ main_box.pack_end(self._thumb_tray, False, False, 0)
+ self._thumb_tray.show_all()
def serialize(self):
@@ -392,11 +392,11 @@ class Record(activity.Activity):
if not self._fullscreen:
self._toolbar_box.hide()
- #self._thumb_tray.hide()
+ self._thumb_tray.hide()
else:
self._toolbar_box.show()
- #self._thumb_tray.show()
+ self._thumb_tray.show()
self._fullscreen = not self._fullscreen
self._media_view.set_fullscreen(self._fullscreen)
@@ -474,10 +474,10 @@ class Record(activity.Activity):
remove_handler = button.connect("remove-requested", self._remove_recd)
clipboard_handler = button.connect("copy-clipboard-requested", self._thumbnail_copy_clipboard)
button.set_data('handler-ids', (clicked_handler, remove_handler, clipboard_handler))
- #self._thumb_tray.add_item(button)
+ self._thumb_tray.add_item(button)
button.show()
- #if scroll_to_end:
- #self._thumb_tray.scroll_to_end()
+ if scroll_to_end:
+ self._thumb_tray.scroll_to_end()
def _copy_to_clipboard(self, recd):
@@ -522,13 +522,13 @@ class Record(activity.Activity):
for handler in handlers:
recdbutton.disconnect(handler)
- #self._thumb_tray.remove_item(recdbutton)
+ self._thumb_tray.remove_item(recdbutton)
recdbutton.cleanup()
def remove_all_thumbnails(self):
- #for child in self._thumb_tray.get_children():
- # self._remove_thumbnail(child)
+ for child in self._thumb_tray.get_children():
+ self._remove_thumbnail(child)
pass
def show_still(self, pixbuf):
diff --git a/tray.py b/tray.py
index 49288fe..d054724 100644
--- a/tray.py
+++ b/tray.py
@@ -18,8 +18,6 @@
import gi
from gi.repository import GObject
from gi.repository import Gtk
-# FIXME: No more hippo
-#import hippo
import sugar3
from sugar3.graphics import style
@@ -29,17 +27,19 @@ _PREVIOUS_PAGE = 0
_NEXT_PAGE = 1
class _TrayViewport(Gtk.Viewport):
+
__gproperties__ = {
'can-scroll' : (bool, None, None, False,
GObject.PARAM_READABLE),
}
def __init__(self, orientation):
+
+ Gtk.Viewport.__init__(self)
+
self.orientation = orientation
self._can_scroll = False
-
- Gtk.Viewport.__init__(self)
-
+
self.set_shadow_type(Gtk.ShadowType.NONE)
self.traybar = Gtk.Toolbar()
@@ -51,136 +51,160 @@ class _TrayViewport(Gtk.Viewport):
self.connect('size_allocate', self._size_allocate_cb)
def scroll(self, direction):
+
if direction == _PREVIOUS_PAGE:
self._scroll_previous()
+
elif direction == _NEXT_PAGE:
self._scroll_next()
def _scroll_next(self):
+
if self.orientation == Gtk.Orientation.HORIZONTAL:
+
adj = self.get_hadjustment()
new_value = adj.get_value() + self.allocation.width
adj.value = min(new_value, adj.get_upper() - self.allocation.width)
+
else:
adj = self.get_vadjustment()
new_value = adj.get_value() + self.allocation.height
adj.value = min(new_value, adj.get_upper() - self.allocation.height)
def _scroll_to_end(self):
+
if self.orientation == Gtk.Orientation.HORIZONTAL:
adj = self.get_hadjustment()
adj.set_value(adj.get_upper()) # - self.allocation.width
+
else:
adj = self.get_vadjustment()
adj.set_value(adj.get_upper() - self.allocation.height)
def _scroll_previous(self):
+
if self.orientation == Gtk.Orientation.HORIZONTAL:
adj = self.get_hadjustment()
new_value = adj.get_value() - self.allocation.width
adj.set_value(max(adj.get_lower(), new_value))
+
else:
adj = self.get_vadjustment()
new_value = adj.get_value() - self.allocation.height
adj.set_value(max(adj.get_lower(), new_value))
- def do_size_request(self, requisition):
- child_requisition = self.child.size_request()
+ def _size_allocate_cb(self, widget, requisition):
+
+ child_requisition = self.get_child().size_request()
+
if self.orientation == Gtk.Orientation.HORIZONTAL:
- requisition[0] = 0
- requisition[1] = child_requisition[1]
+ requisition.width = 0
+ requisition.height = child_requisition.height
+
else:
- requisition[0] = child_requisition[0]
- requisition[1] = 0
+ requisition.width = child_requisition.width
+ requisition.height = 0
def do_get_property(self, pspec):
+
if pspec.name == 'can-scroll':
return self._can_scroll
- def _size_allocate_cb(self, viewport, allocation):
+ def do_size_allocate(self, allocation):
+
bar_requisition = self.traybar.get_child_requisition()
+
if self.orientation == Gtk.Orientation.HORIZONTAL:
- can_scroll = bar_requisition[0] > allocation.width
+ can_scroll = bar_requisition.width > allocation.width
+
else:
- can_scroll = bar_requisition[1] > allocation.height
+ can_scroll = bar_requisition.height > allocation.height
if can_scroll != self._can_scroll:
self._can_scroll = can_scroll
self.notify('can-scroll')
class _TrayScrollButton(Gtk.Button):
+
def __init__(self, icon_name, scroll_direction):
+
Gtk.Button.__init__(self)
self._viewport = None
self._scroll_direction = scroll_direction
-
- self.set_relief(Gtk.RELIEF_NONE)
+ self.set_relief(Gtk.ReliefStyle.NONE)
self.set_size_request(style.GRID_CELL_SIZE, style.GRID_CELL_SIZE)
icon = Icon(icon_name = icon_name,
- icon_size=Gtk.ICON_SIZE_SMALL_TOOLBAR)
+ icon_size=Gtk.IconSize.SMALL_TOOLBAR)
self.set_image(icon)
icon.show()
self.connect('clicked', self._clicked_cb)
def set_viewport(self, viewport):
+
self._viewport = viewport
self._viewport.connect('notify::can-scroll',
self._viewport_can_scroll_changed_cb)
def _viewport_can_scroll_changed_cb(self, viewport, pspec):
+
#self.props.visible = self._viewport.props.can_scroll
self.set_sensitive(self._viewport.props.can_scroll)
def _clicked_cb(self, button):
+
self._viewport.scroll(self._scroll_direction)
viewport = property(fset=set_viewport)
-# FIXME: No more hippo
-'''
-class HTray(Gtk.VBox):
- def __init__(self, **kwargs):
- GObject.GObject.__init__(self, **kwargs)
+class HTray(Gtk.Box):
+
+ def __init__(self):
+
+ Gtk.Box.__init__(self, orientation = Gtk.Orientation.VERTICAL)
- separator = hippo.Canvas()
- box = hippo.CanvasBox(
- border_color=0xffffffff,
- background_color=0xffffffff,
- box_height=1,
- border_bottom=1)
- separator.set_root(box)
- self.pack_start(separator, False)
+ #separator = hippo.Canvas()
+ #box = hippo.CanvasBox(
+ # border_color=0xffffffff,
+ # background_color=0xffffffff,
+ # box_height=1,
+ # border_bottom=1)
+ #separator.set_root(box)
+ #self.pack_start(separator, False)
- hbox = Gtk.HBox()
- self.pack_start(hbox)
+ hbox = Gtk.Box(orientation = Gtk.Orientation.HORIZONTAL)
+ self.pack_start(hbox, False, False, 0)
scroll_left = _TrayScrollButton('go-left', _PREVIOUS_PAGE)
scroll_left_event = Gtk.EventBox()
scroll_left_event.add(scroll_left)
scroll_left_event.set_size_request(55, -1)
- hbox.pack_start(scroll_left_event, False)
+ hbox.pack_start(scroll_left_event, False, False, 0)
self._viewport = _TrayViewport(Gtk.Orientation.HORIZONTAL)
- hbox.pack_start(self._viewport)
+ hbox.pack_start(self._viewport, False, False, 0)
self._viewport.show()
scroll_right = _TrayScrollButton('go-right', _NEXT_PAGE)
scroll_right_event = Gtk.EventBox()
scroll_right_event.add(scroll_right)
scroll_right_event.set_size_request(55, -1)
- hbox.pack_start(scroll_right_event, False)
+ hbox.pack_start(scroll_right_event, False, False, 0)
scroll_left.set_focus_on_click(False)
- scroll_left_event.modify_bg(Gtk.StateType.NORMAL, sugar3.graphics.style.COLOR_TOOLBAR_GREY.get_gdk_color())
- scroll_left.modify_bg(Gtk.StateType.ACTIVE, sugar3.graphics.style.COLOR_BUTTON_GREY.get_gdk_color())
+ scroll_left_event.modify_bg(Gtk.StateType.NORMAL,
+ sugar3.graphics.style.COLOR_TOOLBAR_GREY.get_gdk_color())
+ scroll_left.modify_bg(Gtk.StateType.ACTIVE,
+ sugar3.graphics.style.COLOR_BUTTON_GREY.get_gdk_color())
scroll_right.set_focus_on_click(False)
- scroll_right_event.modify_bg(Gtk.StateType.NORMAL, sugar3.graphics.style.COLOR_TOOLBAR_GREY.get_gdk_color())
- scroll_right.modify_bg(Gtk.StateType.ACTIVE, sugar3.graphics.style.COLOR_BUTTON_GREY.get_gdk_color())
+ scroll_right_event.modify_bg(Gtk.StateType.NORMAL,
+ sugar3.graphics.style.COLOR_TOOLBAR_GREY.get_gdk_color())
+ scroll_right.modify_bg(Gtk.StateType.ACTIVE,
+ sugar3.graphics.style.COLOR_BUTTON_GREY.get_gdk_color())
scroll_left.viewport = self._viewport
scroll_right.viewport = self._viewport
@@ -188,19 +212,25 @@ class HTray(Gtk.VBox):
self.connect_after("size-allocate", self._sizeAllocateCb)
def _sizeAllocateCb(self, widget, event ):
+
self._viewport.notify('can-scroll')
def get_children(self):
+
return self._viewport.traybar.get_children()
def add_item(self, item, index=-1):
+
self._viewport.traybar.insert(item, index)
def remove_item(self, item):
+
self._viewport.traybar.remove(item)
def get_item_index(self, item):
+
return self._viewport.traybar.get_item_index(item)
def scroll_to_end(self):
- self._viewport._scroll_to_end()'''
+
+ self._viewport._scroll_to_end()