r7055 - in bigboard/trunk/bigboard: . stocks/files stocks/self
- From: commits mugshot org
- To: online-desktop-list gnome org
- Subject: r7055 - in bigboard/trunk/bigboard: . stocks/files stocks/self
- Date: Fri, 14 Dec 2007 11:12:10 -0600 (CST)
Author: walters
Date: 2007-12-14 11:12:09 -0600 (Fri, 14 Dec 2007)
New Revision: 7055
Modified:
bigboard/trunk/bigboard/slideout.py
bigboard/trunk/bigboard/stocks/files/FilesStock.py
bigboard/trunk/bigboard/stocks/self/SelfStock.py
Log:
Improvements to File stock and popouts (Philipp Kerling)
http://code.google.com/p/google-highly-open-participation-gnome/issues/detail?id=53
Modified: bigboard/trunk/bigboard/slideout.py
===================================================================
--- bigboard/trunk/bigboard/slideout.py 2007-12-14 16:35:41 UTC (rev 7054)
+++ bigboard/trunk/bigboard/slideout.py 2007-12-14 17:12:09 UTC (rev 7055)
@@ -1,13 +1,22 @@
+import logging
import hippo
import gtk
-
+import gobject
from bigboard.big_widgets import ThemedWidgetMixin
+logger = logging.getLogger('bigboard.Slideout')
+
class Slideout(hippo.CanvasWindow):
- def __init__(self, widget=None):
- super(Slideout, self).__init__(gtk.WINDOW_TOPLEVEL)
+ __gsignals__ = {
+ "button-press-event": "override",
+ "key-press-event": "override",
+ "close": (gobject.SIGNAL_RUN_LAST, None, (bool,))
+ }
+ def __init__(self, widget=None, modal=True):
+ super(Slideout, self).__init__(gtk.WINDOW_POPUP)
self.__widget = widget
+ self.__modal = modal
self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DOCK)
self.set_resizable(False)
@@ -40,7 +49,48 @@
y = y - offscreen_bottom
self.move(x, y)
self.present_with_time(gtk.get_current_event_time())
+ if self.__modal:
+ if not self.__do_grabs():
+ _logger.debug("grab failed")
+ return False
+ self.set_modal(True)
+ return True
+ def __do_grabs(self):
+ # owner_events=True says "only grab events going to other applications"; treat
+ # events going to this application normally; We need that because we want
+ # events to subwindows of ourwindow to be passed appropriately
+ if gtk.gdk.pointer_grab(self.window,
+ owner_events=True,
+ event_mask=gtk.gdk.BUTTON_PRESS_MASK,
+ time=gtk.get_current_event_time()) != gtk.gdk.GRAB_SUCCESS:
+ return False
+ # We don't need owner_events here since keyboard events are always delivered to the
+ # toplevel window anyways, and we aren't doing keyboard navigation in any case
+ if gtk.gdk.keyboard_grab(self.window,
+ owner_events=False,
+ time=gtk.get_current_event_time()) != gtk.gdk.GRAB_SUCCESS:
+ # Hiding the window removes the pointer grab
+ return False
+
+ return True
+
+ def do_button_press_event(self, event):
+ if event.window == self.window and event.x > 0 and event.x < self.allocation.width and event.y > 0 and event.y < self.allocation.height:
+ return hippo.CanvasWindow.do_button_press_event(self, event)
+ else:
+ self.popdown()
+ return True
+
+ def do_key_press_event(self, event):
+ if event.keyval == gtk.keysyms.Escape:
+ self.popdown()
+ return True
+ return False
+
+ def popdown(self):
+ self.emit('close', False)
+
class ThemedSlideout(Slideout, ThemedWidgetMixin):
def __init__(self, theme_hints=[], **kwargs):
Slideout.__init__(self, **kwargs)
@@ -49,4 +99,3 @@
def _on_theme_changed(self, theme):
self.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#%6X" % (theme.background >> 8,)))
self.queue_draw_area(0,0,-1,-1)
-
\ No newline at end of file
Modified: bigboard/trunk/bigboard/stocks/files/FilesStock.py
===================================================================
--- bigboard/trunk/bigboard/stocks/files/FilesStock.py 2007-12-14 16:35:41 UTC (rev 7054)
+++ bigboard/trunk/bigboard/stocks/files/FilesStock.py 2007-12-14 17:12:09 UTC (rev 7055)
@@ -14,7 +14,7 @@
from bigboard.libbig.gutil import *
from bigboard.workboard import WorkBoard
from bigboard.stock import Stock
-import bigboard.slideout
+from bigboard.slideout import Slideout
import bigboard.google as google
import bigboard.google_stock as google_stock
from bigboard.big_widgets import IconLink, CanvasHBox, CanvasVBox, Button, GradientHeader
@@ -129,9 +129,27 @@
except:
_logger.debug("Failed to get file info for target of '%s'", url, exc_info=True)
gobject.idle_add(cb, results)
- return
+ return
+ image_name = "image-missing"
try:
- (image_name, flags) = gnome.ui.icon_lookup(itheme, thumbnails, url, file_info=vfsstat, mime_type=vfsstat.mime_type)
+ if thumbnails.can_thumbnail(url, vfsstat.mime_type, vfsstat.mtime):
+ existing_thumbnail = thumbnails.lookup(url, vfsstat.mtime)
+ if existing_thumbnail is None:
+ _logger.debug("Trying to generate thumbnail for '%s' with mimetype '%s' and mtime %i", url, vfsstat.mime_type, vfsstat.mtime)
+ thumb = thumbnails.generate_thumbnail(url, vfsstat.mime_type)
+ if thumb is None:
+ _logger.debug("Thumbnail generation for '%s' failed", self._url, exc_info=True)
+ else:
+ thumbnails.save_thumbnail(thumb, url, vfsstat.mtime)
+ icon = thumbnails.lookup(url, vfsstat.mtime)
+ if icon is None:
+ _logger.debug("Failed to get generated thumbnail for '%s'", self._url, exc_info=True)
+ else:
+ image_name = icon
+ else:
+ image_name = existing_thumbnail
+ else:
+ (image_name, _) = gnome.ui.icon_lookup(itheme, thumbnails, url, file_info=vfsstat, mime_type=vfsstat.mime_type)
except gnomevfs.NotFoundError, e:
_logger.debug("Failed to get icon info for '%s'", self._url, exc_info=True)
gobject.idle_add(cb, results)
@@ -256,27 +274,24 @@
return None
return pixbuf
-class FileSlideout(CanvasVBox):
- __gsignals__ = {
- "close": (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ())
- }
+class FileSlideout(Slideout):
def __init__(self, fobj):
- super(FileSlideout, self).__init__(border=1, border_color=0x0000000ff,
- spacing=4, padding=4)
+ super(FileSlideout, self).__init__()
+ vbox = CanvasVBox(border=1, border_color=0x0000000ff, spacing=4, padding=4)
+ self.get_root().append(vbox)
self.__header = GradientHeader()
text = hippo.CanvasText(text=fobj.get_name(), font="14px", xalign=hippo.ALIGNMENT_START)
- text.connect("button-press-event", lambda text, event: self.__toggle_expanded())
self.__header.append(text, hippo.PACK_EXPAND)
- self.append(self.__header)
+ vbox.append(self.__header)
hbox = CanvasHBox(spacing=4)
img = hippo.CanvasImage(scale_width=60, scale_height=60, xalign=hippo.ALIGNMENT_START, yalign=hippo.ALIGNMENT_START)
img.set_property('image-name', fobj.get_image_name())
hbox.append(img)
- self.append(hbox)
+ vbox.append(hbox)
- vbox = CanvasVBox()
- hbox.append(vbox)
+ detailvbox = CanvasVBox(spacing=3)
+ hbox.append(detailvbox)
attrs = pango.AttrList()
attrs.insert(pango.AttrForeground(0x6666, 0x6666, 0x6666, 0, 0xFFFF))
mime = fobj.get_mimetype()
@@ -284,13 +299,13 @@
mimename = gnomevfs.mime_get_description(mime)
text = hippo.CanvasText(text=mimename, font='12px', xalign=hippo.ALIGNMENT_START)
text.set_property("attributes", attrs)
- vbox.append(text)
+ detailvbox.append(text)
size = fobj.get_size()
if size is not None:
sizestr = format_file_size(size)
text = hippo.CanvasText(text=sizestr, font='12px', xalign=hippo.ALIGNMENT_START)
text.set_property("attributes", attrs)
- vbox.append(text)
+ detailvbox.append(text)
fname = os.path.dirname(fobj.get_full_name())
if fname.startswith('file://'):
fname = fname[7:]
@@ -300,32 +315,48 @@
fname = urllib.unquote(fname)
text = hippo.CanvasText(text=fname, font='12px', xalign=hippo.ALIGNMENT_START)
text.set_property("attributes", attrs)
- vbox.append(text)
+ detailvbox.append(text)
apps = gnomevfs.mime_get_all_applications(mime)
if apps:
text = hippo.CanvasText(text='Open With: ', font='14px')
- vbox.append(text)
+ detailvbox.append(text)
def on_app_clicked(button, app):
- self.emit('close')
+ self.emit('close', True)
_logger.debug("launching app %s", app)
_launch_vfsmimeapp(app, fobj.get_url())
directory = apps_directory.get_app_directory()
for app in apps:
_logger.debug("mime type: %s got app %s", mime, app)
- button = Button(label=app[1])
+ button = hippo.CanvasButton()
+ labelhbox = gtk.HBox()
+ labelhbox.set_border_width(1)
+ labelhbox.set_spacing(2)
+
try:
menu = directory.lookup(app[0])
except KeyError, e:
_logger.debug("failed to find desktop file %s", app[0])
menu = None
+
+ img = gtk.Image()
+
if menu:
- pixbuf = get_menu_pixbuf(menu, size=24)
- img = gtk.Image()
+ pixbuf = get_menu_pixbuf(menu, size=16)
img.set_from_pixbuf(pixbuf)
- button.get_button().set_property('image', img)
- button.get_button().connect('clicked', on_app_clicked, app)
- vbox.append(button)
+ else:
+ img.set_size_request(16, 16)
+ labelhbox.pack_start(img, False, False)
+
+ textlabel = gtk.Label(app[1])
+ labelhbox.pack_start(textlabel, False)
+ labelhbox.show_all()
+
+ button.get_property('widget').add(labelhbox)
+ button.get_property('widget').connect('clicked', on_app_clicked, app)
+ button.get_property('widget').set_name('bigboard-nopad-button')
+ detailvbox.append(button)
+
class FilesStock(Stock, google_stock.GoogleStock):
"""Shows recent files."""
def __init__(self, *args, **kwargs):
@@ -387,17 +418,21 @@
self.__slideout_target = None
return
self.__slideout_target = fobj
- self.__slideout = bigboard.slideout.Slideout()
- file_slideout = FileSlideout(fobj)
- self.__slideout.get_root().append(file_slideout)
- def on_slideout_close(s):
- self._panel.action_taken()
+ self.__slideout = FileSlideout(fobj)
+ def on_slideout_close(s, action_taken):
+ if action_taken:
+ self._panel.action_taken()
s.destroy()
self.__slideout = None
- file_slideout.connect('close', on_slideout_close)
+ self.__slideout_target = None
+ self.__slideout.connect('close', on_slideout_close)
item = lnk.link
coords = item.get_context().translate_to_screen(item)
- self.__slideout.slideout_from(204, coords[1])
+ if not self.__slideout.slideout_from(204, coords[1]):
+ self.__slideout.destroy()
+ self.__slideout = None
+ self.__slideout_target = None
+ return
def __on_documents_load(self, document_entries, gobj):
self.__remove_files_for_key(gobj)
Modified: bigboard/trunk/bigboard/stocks/self/SelfStock.py
===================================================================
--- bigboard/trunk/bigboard/stocks/self/SelfStock.py 2007-12-14 16:35:41 UTC (rev 7054)
+++ bigboard/trunk/bigboard/stocks/self/SelfStock.py 2007-12-14 17:12:09 UTC (rev 7055)
@@ -9,7 +9,7 @@
from ddm import DataModel
import bigboard.globals as globals
-import bigboard.slideout
+from bigboard.slideout import ThemedSlideout
import bigboard.libbig as libbig
from bigboard.workboard import WorkBoard
from bigboard.stock import Stock, AbstractMugshotStock
@@ -87,23 +87,24 @@
self.displays = displays
-class SelfSlideout(CanvasVBox):
+class SelfSlideout(ThemedSlideout):
__gsignals__ = {
"account" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, []),
"logout" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, []),
"sidebar-controls" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, []),
- "close" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, [])
}
def __init__(self, stock, myself, fus=None, logger=None):
- super(SelfSlideout, self).__init__(border=1, border_color=0x0000000ff,
- spacing=4, padding=4)
+ super(SelfSlideout, self).__init__()
+
+ vbox = CanvasVBox(border=1, border_color=0x0000000ff, spacing=4, padding=4)
+ self.get_root().append(vbox)
self._logger = logger
self.__stock = stock
self.__personal_box = CanvasHBox(spacing=4)
- self.append(self.__personal_box)
+ vbox.append(self.__personal_box)
self.__photo = CanvasMugshotURLImage(scale_width=48, scale_height=48)
@@ -118,10 +119,10 @@
self.__personal_box_right.append(self.__name)
- self.append(Separator())
+ vbox.append(Separator())
self.__personalization_box = CanvasVBox(spacing=2)
- self.append(self.__personalization_box)
+ vbox.append(self.__personalization_box)
self.__personalization_box.append(ThemedText(text='Personalization',
font='12px Bold',
xalign=hippo.ALIGNMENT_START))
@@ -140,7 +141,7 @@
link.img.set_property('image-name', '/usr/share/icons/gnome/22x22/categories/preferences-desktop.png')
self.__personalization_box.append(link)
- self.append(Separator())
+ vbox.append(Separator())
if fus:
self.__fus = dbus.Interface(fus, 'org.gnome.FastUserSwitch')
@@ -149,7 +150,7 @@
self.__fus.RecheckDisplays()
self.__fus_box = CanvasVBox()
- self.append(self.__fus_box)
+ vbox.append(self.__fus_box)
self.__fus_users_box = CanvasVBox()
self.__fus_box.append(self.__fus_users_box)
@@ -162,7 +163,7 @@
self.__handle_fus_change()
self.__logout_controls_box = CanvasVBox()
- self.append(self.__logout_controls_box)
+ vbox.append(self.__logout_controls_box)
link = IconLink(text='Logout or Shutdown...', img_scale_width=22, img_scale_height=22, xalign=hippo.ALIGNMENT_START, themed=True)
link.link.connect("activated", self.__on_logout)
@@ -186,19 +187,19 @@
def __show_mugshot_link(self, l):
self.emit('account')
- self.emit('close')
+ self.emit('close', True)
def __on_sidebar_controls(self, l):
self.emit('sidebar-controls')
- self.emit('close')
+ self.emit('close', True)
def __on_system_preferences(self, l):
subprocess.Popen(['gnome-control-center'])
- self.emit('close')
+ self.emit('close', True)
def __on_logout(self, l):
self.emit('logout')
- self.emit('close')
+ self.emit('close', True)
def __on_dbus_error(self, err):
self._logger.exception("D-BUS error: %s", err)
@@ -236,7 +237,7 @@
def __do_fus_login_other_user(self, l):
self._logger.debug("Doing NewConsole")
self.__fus.NewConsole()
- self.emit('close')
+ self.emit('close', True)
class SelfStock(AbstractMugshotStock):
"""Shows a user's Mugshot personal information."""
@@ -287,7 +288,6 @@
self.info_loaded = False
self.__slideout = None
- self.__slideout_display = None
self.__portfolio_manager = None
@@ -360,17 +360,12 @@
self._box.set_child_visible(self._whereim_box, not not auth)
self._box.set_child_visible(self._signin, not auth)
- def __do_slideout(self, display, widget=None):
- slideout = bigboard.slideout.ThemedSlideout()
+ def __do_slideout(self, slideout, widget=None):
widget_src = widget or self._box
(box_x, box_y) = self._box.get_context().translate_to_screen(self._box)
(src_x, src_y) = widget_src.get_context().translate_to_screen(widget_src)
slideout.slideout_from(box_x + self._box.get_allocation()[0] + 4, src_y)
- if hasattr(display, 'focus'):
- display.focus()
- slideout.get_root().append(display)
slideout.set_size_request(200, -1)
- return slideout
def __do_logout(self):
self._panel.action_taken()
@@ -399,12 +394,12 @@
return
self.__create_fus_proxy()
- self.__slideout_display = SelfSlideout(self, self.__myself, fus=self.__fus_service, logger=_logger)
- self.__slideout_display.connect('account', lambda s: self.__do_account())
- self.__slideout_display.connect('sidebar-controls', lambda s: self.__do_sidebar_controls())
- self.__slideout_display.connect('logout', lambda s: self.__do_logout())
- self.__slideout_display.connect('close', lambda s: self.__on_activate())
- self.__slideout = self.__do_slideout(self.__slideout_display)
+ self.__slideout = SelfSlideout(self, self.__myself, fus=self.__fus_service, logger=_logger)
+ self.__slideout.connect('account', lambda s: self.__do_account())
+ self.__slideout.connect('sidebar-controls', lambda s: self.__do_sidebar_controls())
+ self.__slideout.connect('logout', lambda s: self.__do_logout())
+ self.__slideout.connect('close', lambda s, a: self.__on_activate())
+ self.__do_slideout(self.__slideout)
def get_authed_content(self, size):
return self._box
@@ -428,5 +423,5 @@
_logger.debug("appending external account %s", acct.accountType)
self._whereim_box.append(icon)
- if self.__slideout_display != None:
- self.__slideout_display.update_self(myself)
+ if self.__slideout != None:
+ self.__slideout.update_self(myself)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]