Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksey Lim <alsroot@member.fsf.org>2010-02-01 01:22:53 (GMT)
committer Aleksey Lim <alsroot@member.fsf.org>2010-02-01 01:22:53 (GMT)
commit3c4c060ef6f4292630ffc94b132eb3ff3d385b4b (patch)
tree2a661b89da4c34b0aafb9b9de6612a123e093e53
parent994e49458b824d5da25d950a89b75895c6a315bf (diff)
Bunch of design related small fixes
-rw-r--r--src/jarabe/journal/fields.py38
-rw-r--r--src/jarabe/journal/homogeneview.py11
-rw-r--r--src/jarabe/journal/listview.py26
-rw-r--r--src/jarabe/journal/objectchooser.py10
-rw-r--r--src/jarabe/journal/sugarbin.py3
-rw-r--r--src/jarabe/journal/thumbsview.py86
6 files changed, 117 insertions, 57 deletions
diff --git a/src/jarabe/journal/fields.py b/src/jarabe/journal/fields.py
index a65a75d..ab08e26 100644
--- a/src/jarabe/journal/fields.py
+++ b/src/jarabe/journal/fields.py
@@ -48,8 +48,6 @@ class _Button(gtk.Alignment):
self.metadata = None
self.prelight = False
- self.set_size_request(style.GRID_CELL_SIZE, -1)
-
box = gtk.EventBox()
box.props.visible_window = False
box.show()
@@ -159,7 +157,7 @@ class KeepIcon(_Button):
class _JournalObject(gtk.EventBox):
- def __init__(self, detail, paint_box):
+ def __init__(self, detail, paint_border, paint_fill):
gtk.EventBox.__init__(self)
self.metadata = None
@@ -168,17 +166,22 @@ class _JournalObject(gtk.EventBox):
self._invoker = WidgetInvoker(self)
self._invoker._position_hint = Invoker.AT_CURSOR
- self.props.visible_window = False
-
self.modify_fg(gtk.STATE_NORMAL,
style.COLOR_PANEL_GREY.get_gdk_color())
self.connect_after('button-release-event',
self.__button_release_event_cb)
-
self.connect('destroy', self.__destroy_cb)
- if paint_box:
+
+ if paint_border:
self.connect_after('expose-event', self.__expose_event_cb)
+ paint_fill = True
+
+ if paint_fill:
+ self.modify_bg(gtk.STATE_NORMAL,
+ style.COLOR_WHITE.get_gdk_color())
+ else:
+ self.props.visible_window = False
# DND stuff
@@ -204,9 +207,9 @@ class _JournalObject(gtk.EventBox):
self._invoker.detach()
def __expose_event_cb(self, widget, event):
- x, y, width, height = self.allocation
+ __, __, width, height = self.allocation
fg = self.style.fg_gc[gtk.STATE_NORMAL]
- self.window.draw_rectangle(fg, False, x, y, width - 1, height - 1)
+ self.window.draw_rectangle(fg, False, 0, 0, width - 1, height - 1)
def __drag_begin_cb(self, widget, context):
self._drag = True
@@ -245,8 +248,8 @@ class _JournalObject(gtk.EventBox):
class ObjectIcon(_JournalObject):
- def __init__(self, detail=True, paint_box=True, **kwargs):
- _JournalObject.__init__(self, detail, paint_box)
+ def __init__(self, detail, paint_border, paint_fill, **kwargs):
+ _JournalObject.__init__(self, detail, paint_border, paint_fill)
self._icon = Icon(**kwargs)
self._icon.show()
@@ -260,8 +263,8 @@ class ObjectIcon(_JournalObject):
class Thumb(_JournalObject):
- def __init__(self, detail=True, paint_box=True):
- _JournalObject.__init__(self, detail, paint_box)
+ def __init__(self, detail, paint_border, paint_fill):
+ _JournalObject.__init__(self, detail, paint_border, paint_fill)
self._image = gtk.Image()
self._image.show()
@@ -340,7 +343,7 @@ class Buddies(gtk.Alignment):
for buddy in buddies:
icon = _BuddyIcon()
show(icon, buddy)
- self._buddies.add(icon)
+ self._buddies.pack_start(icon, expand=False)
if self.child is not child:
if self.child is not None:
@@ -352,8 +355,11 @@ class Buddies(gtk.Alignment):
class Timestamp(gtk.Label):
def __init__(self, **kwargs):
- gobject.GObject.__init__(self, **kwargs)
- self.props.selectable = True
+ gobject.GObject.__init__(self,
+ selectable=True,
+ ellipsize=True,
+ xalign=0.0,
+ **kwargs)
def fill_in(self, metadata):
self.props.label = misc.get_date(metadata)
diff --git a/src/jarabe/journal/homogeneview.py b/src/jarabe/journal/homogeneview.py
index c0a5f5c..2474228 100644
--- a/src/jarabe/journal/homogeneview.py
+++ b/src/jarabe/journal/homogeneview.py
@@ -21,12 +21,14 @@ import logging
from sugar.graphics import style
from jarabe.journal.homogenetable import HomogeneTable
+from jarabe.journal.sugarbin import SugarBin
-class Cell(gtk.EventBox):
+class Cell(SugarBin):
def __init__(self):
- gtk.EventBox.__init__(self)
+ SugarBin.__init__(self)
+
self._fields = []
self.fill_background(False)
@@ -45,7 +47,7 @@ class Cell(gtk.EventBox):
def fill_background(self, selected):
if selected:
- color = style.COLOR_SELECTION_GREY.get_gdk_color()
+ color = style.COLOR_HIGHLIGHT.get_gdk_color()
else:
color = style.COLOR_WHITE.get_gdk_color()
self.modify_bg(gtk.STATE_NORMAL, color)
@@ -65,10 +67,11 @@ class HomogeneView(HomogeneTable):
def __init__(self, selection, **kwargs):
HomogeneTable.__init__(self, **kwargs)
+ self._result_set = None
+
self.editable = not selection
self.cursor_visible = selection
self.hover_selection = selection
- self._result_set = None
def set_result_set(self, result_set):
if self._result_set is result_set:
diff --git a/src/jarabe/journal/listview.py b/src/jarabe/journal/listview.py
index 9d1e4c0..0bdbdd9 100644
--- a/src/jarabe/journal/listview.py
+++ b/src/jarabe/journal/listview.py
@@ -26,7 +26,7 @@ from jarabe.journal.fields import *
class _Cell(Cell):
- def __init__(self):
+ def __init__(self, use_details):
Cell.__init__(self)
row = gtk.HBox()
@@ -34,11 +34,14 @@ class _Cell(Cell):
self.add(row)
keep = KeepIcon()
+ keep.set_size_request(style.GRID_CELL_SIZE, -1)
row.pack_start(keep, expand=False)
self.add_field(keep)
icon = ObjectIcon(
- paint_box=False,
+ detail=use_details,
+ paint_border=False,
+ paint_fill=False,
pixel_size=style.STANDARD_ICON_SIZE)
row.pack_start(icon, expand=False)
self.add_field(icon)
@@ -50,16 +53,25 @@ class _Cell(Cell):
row.pack_start(title_alignment)
self.add_field(title)
- details = DetailsIcon()
- row.pack_end(details, expand=False)
- self.add_field(details)
+ if use_details:
+ details = DetailsIcon()
+ self.add_field(details)
+ details.set_size_request(style.GRID_CELL_SIZE, -1)
+ row.pack_end(details, expand=False)
+ else:
+ padding = gtk.EventBox()
+ padding.props.visible_window = False
+ padding.set_size_request(style.DEFAULT_SPACING, -1)
+ row.pack_end(padding, expand=False)
date = Timestamp()
+ date.set_size_request(style.GRID_CELL_SIZE * 3, -1)
row.pack_end(date, expand=False)
self.add_field(date)
- buddies = Buddies(buddies_max=3,
+ buddies = Buddies(buddies_max=4,
xalign=0, yalign=0.5, xscale=1, yscale=0.15)
+ buddies.set_size_request(style.GRID_CELL_SIZE * 3, -1)
row.pack_end(buddies, expand=False)
self.add_field(buddies)
@@ -74,4 +86,4 @@ class ListView(HomogeneView):
self.cell_size = (None, style.GRID_CELL_SIZE)
def do_cell_new(self):
- return _Cell()
+ return _Cell(not self.hover_selection)
diff --git a/src/jarabe/journal/objectchooser.py b/src/jarabe/journal/objectchooser.py
index 14c1930..189a4b2 100644
--- a/src/jarabe/journal/objectchooser.py
+++ b/src/jarabe/journal/objectchooser.py
@@ -27,6 +27,7 @@ from sugar.graphics.toolbutton import ToolButton
from jarabe.journal.view import View
from jarabe.journal.journaltoolbox import SearchToolbar
from jarabe.journal.volumestoolbar import VolumesToolbar
+from jarabe.journal.sugarbin import SugarBin
class ObjectChooser(gtk.Window):
@@ -81,9 +82,16 @@ class ObjectChooser(gtk.Window):
self._toolbar.connect('query-changed', self.__query_changed_cb)
self._toolbar.connect('view-changed', self.__view_changed_cb)
self._toolbar.set_size_request(-1, style.GRID_CELL_SIZE)
- vbox.pack_start(self._toolbar, expand=False)
self._toolbar.show()
+ toolbar_bin = SugarBin()
+ toolbar_bin.padding_left = style.DEFAULT_SPACING
+ toolbar_bin.modify_bg(gtk.STATE_NORMAL,
+ style.COLOR_TOOLBAR_GREY.get_gdk_color())
+ toolbar_bin.add(self._toolbar)
+ toolbar_bin.show()
+ vbox.pack_start(toolbar_bin, expand=False)
+
self._view = View(selection=True)
self._view.connect('entry-activated', self.__entry_activated_cb)
vbox.pack_start(self._view)
diff --git a/src/jarabe/journal/sugarbin.py b/src/jarabe/journal/sugarbin.py
index 5596c67..be64655 100644
--- a/src/jarabe/journal/sugarbin.py
+++ b/src/jarabe/journal/sugarbin.py
@@ -123,7 +123,8 @@ class SugarBin(gtk.EventBox):
x=self._padding_left, y=self._padding_top,
width=width - self._padding_left - self._padding_right,
height=height - self._padding_top - self._padding_bottom)
+ child_allocation.width = max(0, child_allocation.width)
+ child_allocation.height = max(0, child_allocation.height)
self.child.size_allocate(child_allocation)
-
gobject.type_register(SugarBin)
diff --git a/src/jarabe/journal/thumbsview.py b/src/jarabe/journal/thumbsview.py
index cf943ca..be518c1 100644
--- a/src/jarabe/journal/thumbsview.py
+++ b/src/jarabe/journal/thumbsview.py
@@ -27,56 +27,80 @@ from jarabe.journal import entry
class _Cell(Cell):
- def __init__(self):
+ def __init__(self, use_details):
Cell.__init__(self)
self._last_thumb_uid = None
self._last_thumb_offset = None
self._last_thumb_mtime = None
+ self.padding = style.DEFAULT_SPACING
+
cell = gtk.HBox()
- cell.props.border_width = style.DEFAULT_PADDING
self.add(cell)
# toolbar
toolbar = gtk.VBox()
+ toolbar.set_size_request(style.GRID_CELL_SIZE / 2, -1)
cell.pack_start(toolbar, expand=False)
keep = KeepIcon()
toolbar.pack_start(keep, expand=False)
self.add_field(keep)
- details = DetailsIcon()
- toolbar.pack_start(details, expand=False)
- self.add_field(details)
-
- # main
+ if use_details:
+ details = DetailsIcon()
+ toolbar.pack_start(details, expand=False)
+ self.add_field(details)
- main = gtk.VBox()
- main.props.spacing = style.DEFAULT_PADDING
- cell.pack_end(main)
+ # image widgets
- self._icon = ObjectIcon(pixel_size=style.MEDIUM_ICON_SIZE)
+ self._icon = ObjectIcon(
+ detail=use_details,
+ paint_border=True,
+ paint_fill=True,
+ pixel_size=style.MEDIUM_ICON_SIZE)
self._icon.set_size_request(preview.THUMB_WIDTH, preview.THUMB_HEIGHT)
self._icon.show()
self.add_field(self._icon)
- self._thumb = Thumb()
+ self._thumb = Thumb(
+ detail=use_details,
+ paint_border=False,
+ paint_fill=True)
self._thumb.set_size_request(preview.THUMB_WIDTH, preview.THUMB_HEIGHT)
self._thumb.show()
self.add_field(self._thumb)
- self._thumb_box = gtk.HBox()
- main.pack_start(self._thumb_box, expand=False)
+ # image box
+
+ table = gtk.Table(3, 4, False)
+ table.props.row_spacing = style.DEFAULT_PADDING
+ cell.pack_end(table)
+
+ left_padding = gtk.EventBox()
+ table.attach(left_padding, 0, 1, 0, 2, gtk.EXPAND, gtk.SHRINK, 0, 0)
+
+ self._image = gtk.EventBox()
+ table.attach(self._image, 1, 2, 0, 1, gtk.SHRINK, gtk.SHRINK, 0, 0)
+
+ right_padding = gtk.EventBox()
+ table.attach(right_padding, 2, 3, 0, 2, gtk.EXPAND, gtk.SHRINK, 0, 0)
+
+ padding = gtk.EventBox()
+ padding.props.visible_window = False
+ padding.set_size_request(style.GRID_CELL_SIZE / 2, -1)
+ table.attach(padding, 3, 4, 0, 1, gtk.SHRINK, gtk.SHRINK, 0, 0)
+
+ # text box
title = Title(max_line_count=2)
- main.pack_start(title, expand=False)
+ table.attach(title, 1, 4, 1, 2, gtk.EXPAND | gtk.FILL, gtk.SHRINK, 0, 0)
self.add_field(title)
- date = Timestamp(wrap=True, xalign=0.0)
- date.set_size_request(preview.THUMB_WIDTH, -1)
- main.pack_start(date, expand=False)
+ date = Timestamp()
+ table.attach(date, 1, 4, 2, 3, gtk.EXPAND | gtk.FILL, gtk.SHRINK, 0, 0)
self.add_field(date)
self.show_all()
@@ -99,10 +123,11 @@ class _Cell(Cell):
self._set_thumb_widget(self._thumb)
def _set_thumb_widget(self, widget):
- if widget not in self._thumb_box.get_children():
- for child in self._thumb_box.get_children():
- self._thumb_box.remove(child)
- self._thumb_box.pack_start(widget, expand=False)
+ if widget is self._image.child:
+ return
+ if self._image.child is not None:
+ self._image.remove(self._image.child)
+ self._image.add(widget)
class ThumbsView(HomogeneView):
@@ -110,14 +135,19 @@ class ThumbsView(HomogeneView):
def __init__(self, selection):
HomogeneView.__init__(self, selection)
- cell_width = style.DEFAULT_PADDING * 2 + \
- style.GRID_CELL_SIZE + \
- preview.THUMB_WIDTH
+ if not selection:
+ padding = style.GRID_CELL_SIZE / 2 - style.DEFAULT_PADDING
+ self.padding_left = padding
+ self.padding_right = padding
+
+ cell_width = style.DEFAULT_SPACING * 2 + \
+ style.GRID_CELL_SIZE + \
+ preview.THUMB_WIDTH
- cell_height = style.DEFAULT_PADDING * 2 + \
+ cell_height = style.DEFAULT_SPACING * 2 + \
preview.THUMB_HEIGHT + \
style.DEFAULT_PADDING * 2 + \
- entry.TEXT_HEIGHT * 4
+ entry.TEXT_HEIGHT * 3
self.cell_size = (cell_width, cell_height)
@@ -125,7 +155,7 @@ class ThumbsView(HomogeneView):
preview.fetched.connect(self.__preview_fetched_cb)
def do_cell_new(self):
- return _Cell()
+ return _Cell(not self.hover_selection)
def __frame_scrolled_cb(self, table):
preview.discard_queue(table.frame_range)