r6924 - in bigboard/trunk/bigboard: . stocks/apps stocks/files
- From: commits mugshot org
- To: online-desktop-list gnome org
- Subject: r6924 - in bigboard/trunk/bigboard: . stocks/apps stocks/files
- Date: Fri, 16 Nov 2007 17:46:21 -0600 (CST)
Author: walters
Date: 2007-11-16 17:46:21 -0600 (Fri, 16 Nov 2007)
New Revision: 6924
Added:
bigboard/trunk/bigboard/apps_directory.py
Removed:
bigboard/trunk/bigboard/stocks/apps/apps_directory.py
Modified:
bigboard/trunk/bigboard/stocks/apps/AppsStock.py
bigboard/trunk/bigboard/stocks/apps/appbrowser.py
bigboard/trunk/bigboard/stocks/apps/apps.py
bigboard/trunk/bigboard/stocks/apps/apps_widgets.py
bigboard/trunk/bigboard/stocks/files/FilesStock.py
Log:
Move apps_directory into global area.
Change file stock slideout to be closer to mockup, include app
icons in buttons etc.
Copied: bigboard/trunk/bigboard/apps_directory.py (from rev 6923, bigboard/trunk/bigboard/stocks/apps/apps_directory.py)
Modified: bigboard/trunk/bigboard/stocks/apps/AppsStock.py
===================================================================
--- bigboard/trunk/bigboard/stocks/apps/AppsStock.py 2007-11-15 22:23:53 UTC (rev 6923)
+++ bigboard/trunk/bigboard/stocks/apps/AppsStock.py 2007-11-16 23:46:21 UTC (rev 6924)
@@ -9,10 +9,11 @@
import bigboard.global_mugshot as global_mugshot
import bigboard.libbig as libbig
from bigboard.libbig.gutil import *
+import bigboard.apps_directory as apps_directory
from bigboard.big_widgets import CanvasMugshotURLImage, PhotoContentItem, CanvasHBox, CanvasVBox, ActionLink
import bigboard.stock
-import apps, appbrowser, apps_widgets, apps_directory
+import apps, appbrowser, apps_widgets
from ddm import DataModel
Modified: bigboard/trunk/bigboard/stocks/apps/appbrowser.py
===================================================================
--- bigboard/trunk/bigboard/stocks/apps/appbrowser.py 2007-11-15 22:23:53 UTC (rev 6923)
+++ bigboard/trunk/bigboard/stocks/apps/appbrowser.py 2007-11-16 23:46:21 UTC (rev 6924)
@@ -7,13 +7,14 @@
import bigboard.globals as globals
import bigboard.libbig as libbig
+import bigboard.apps_directory as apps_directory
from bigboard.libbig.logutil import log_except
from bigboard.libbig.gutil import *
from bigboard.big_widgets import CanvasMugshotURLImage, CanvasHBox, CanvasVBox, CanvasTable, \
ActionLink, IconLink, PrelightingCanvasBox, CanvasSpinner, CanvasCheckbox, Button
from bigboard.overview_table import OverviewTable
-import apps_widgets, apps_directory
+import apps_widgets
_logger = logging.getLogger("bigboard.AppBrowser")
Modified: bigboard/trunk/bigboard/stocks/apps/apps.py
===================================================================
--- bigboard/trunk/bigboard/stocks/apps/apps.py 2007-11-15 22:23:53 UTC (rev 6923)
+++ bigboard/trunk/bigboard/stocks/apps/apps.py 2007-11-16 23:46:21 UTC (rev 6924)
@@ -10,7 +10,7 @@
import bigboard.global_mugshot as global_mugshot
import bigboard.libbig as libbig
from bigboard.libbig.gutil import *
-import apps_directory
+import bigboard.apps_directory as apps_directory
from bigboard.libbig.http import AsyncHTTPFetcher
from bigboard.libbig.xmlquery import query as xml_query, get_attrs as xml_get_attrs
import urlparse
Deleted: bigboard/trunk/bigboard/stocks/apps/apps_directory.py
===================================================================
--- bigboard/trunk/bigboard/stocks/apps/apps_directory.py 2007-11-15 22:23:53 UTC (rev 6923)
+++ bigboard/trunk/bigboard/stocks/apps/apps_directory.py 2007-11-16 23:46:21 UTC (rev 6924)
@@ -1,67 +0,0 @@
-import logging, time
-
-import gmenu, gobject, pango, gnomedesktop
-
-class AppDirectory(gobject.GObject):
- __gsignals__ = {
- "changed" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ())
- }
- def __init__(self):
- gobject.GObject.__init__(self)
- self._logger = logging.getLogger('bigboard.AppsDirectory')
- self._tree = gmenu.lookup_tree('applications.menu', gmenu.FLAGS_INCLUDE_EXCLUDED)
- self._apps = {}
- # with gnome-menus-2.16.0-2.fc6 omitting the user_data arg crashes the gmenu module
- self._tree.add_monitor(self._on_apps_changed, None)
- self.__last_local_app_update = 0.0
- self.__last_local_app_idle_id = 0
- self._on_apps_changed(None, None)
-
- def _append_directory(self, directory):
- for child in directory.contents:
- if isinstance(child, gmenu.Directory):
- self._append_directory(child)
- continue
-
- if not isinstance(child, gmenu.Entry):
- continue
-
- self._apps[child.desktop_file_id] = child
-
- def _on_apps_changed(self, tree, data):
- self._logger.debug("installed apps changed")
- self._apps = {}
- ## no root if no applications.menu was found, which would usually happen in a messed-up
- ## install to a separate prefix
- if self._tree.root:
- self._append_directory(self._tree.root)
- self._logger.debug("app read complete (%d apps)", len(self._apps.keys()))
- curtime = time.time()
- if self.__last_local_app_update < curtime-10:
- self.__last_local_app_update = curtime
- self._logger.debug("no changes before in last 10 secs, emitting changed now")
- self.emit('changed')
- elif self.__last_local_app_idle_id == 0:
- self._logger.debug("queuing idle change emit")
- self.__last_local_app_idle_id = gobject.timeout_add(7000, self.__idle_handle_local_apps_changed)
-
- def __idle_handle_local_apps_changed(self):
- self._logger.debug("doing idle local app change")
- self.__last_local_app_idle_id = 0
- self.__last_local_app_update = time.time()
- self.emit('changed')
-
- def get_apps(self):
- return self._apps.itervalues()
-
- def lookup(self, desktop_name):
- if not (desktop_name[-8:] == '.desktop'):
- desktop_name += '.desktop'
- return self._apps[desktop_name]
-
-_app_directory = None
-def get_app_directory():
- global _app_directory
- if _app_directory is None:
- _app_directory = AppDirectory()
- return _app_directory
Modified: bigboard/trunk/bigboard/stocks/apps/apps_widgets.py
===================================================================
--- bigboard/trunk/bigboard/stocks/apps/apps_widgets.py 2007-11-15 22:23:53 UTC (rev 6923)
+++ bigboard/trunk/bigboard/stocks/apps/apps_widgets.py 2007-11-16 23:46:21 UTC (rev 6924)
@@ -4,10 +4,9 @@
import hippo
import bigboard.globals as globals
+import bigboard.apps_directory as apps_directory
from bigboard.big_widgets import CanvasMugshotURLImage, PhotoContentItem, CanvasHBox, CanvasVBox, ActionLink
-import apps_directory
-
class AppLocation:
(STOCK, APP_BROWSER, DESCRIPTION_HEADER) = range(3)
Modified: bigboard/trunk/bigboard/stocks/files/FilesStock.py
===================================================================
--- bigboard/trunk/bigboard/stocks/files/FilesStock.py 2007-11-15 22:23:53 UTC (rev 6923)
+++ bigboard/trunk/bigboard/stocks/files/FilesStock.py 2007-11-16 23:46:21 UTC (rev 6924)
@@ -1,4 +1,4 @@
-import logging, os, sys, subprocess, urlparse, urllib, time, threading
+import logging, os, sys, re, subprocess, urlparse, urllib, time, threading
import xml.dom, xml.dom.minidom
import gobject, gtk, pango
@@ -19,6 +19,7 @@
import bigboard.google_stock as google_stock
from bigboard.big_widgets import IconLink, CanvasHBox, CanvasVBox, Button, GradientHeader
from bigboard.libbig.xmlquery import query as xml_query, get_attrs as xml_get_attrs
+import bigboard.apps_directory as apps_directory
import bigboard.search as search
import filebrowser
@@ -244,7 +245,16 @@
replaced_f = True
if not replaced_f:
exec_components.append(uri)
- subprocess.Popen(exec_components)
+ subprocess.Popen(exec_components)
+
+def get_menu_pixbuf(menuentry, size=48):
+ icon_name = re.sub(r'\.[a-z]+$','', menuentry.get_icon())
+ theme = gtk.icon_theme_get_default()
+ try:
+ pixbuf = theme.load_icon(icon_name, size, 0)
+ except gobject.GError, e:
+ return None
+ return pixbuf
class FileSlideout(CanvasVBox):
__gsignals__ = {
@@ -259,41 +269,60 @@
self.__header.append(text, hippo.PACK_EXPAND)
self.append(self.__header)
- hbox = CanvasHBox()
- img = hippo.CanvasImage(scale_width=80, scale_height=80, xalign=hippo.ALIGNMENT_CENTER, yalign=hippo.ALIGNMENT_CENTER)
+ 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 = CanvasVBox()
hbox.append(vbox)
+ attrs = pango.AttrList()
+ attrs.insert(pango.AttrForeground(0x6666, 0x6666, 0x6666, 0, 0xFFFF))
mime = fobj.get_mimetype()
if mime:
mimename = gnomevfs.mime_get_description(mime)
- text = hippo.CanvasText(text=mimename, font='12px')
+ text = hippo.CanvasText(text=mimename, font='12px', xalign=hippo.ALIGNMENT_START)
+ text.set_property("attributes", attrs)
vbox.append(text)
size = fobj.get_size()
if size is not None:
sizestr = format_file_size(size)
- text = hippo.CanvasText(text=sizestr, font='12px')
+ text = hippo.CanvasText(text=sizestr, font='12px', xalign=hippo.ALIGNMENT_START)
+ text.set_property("attributes", attrs)
vbox.append(text)
fname = os.path.dirname(fobj.get_full_name())
+ if fname.startswith('file://'):
+ fname = fname[7:]
home = os.path.expanduser('~')
if fname.startswith(home):
fname = fname[:len(home)]
- text = hippo.CanvasText(text=fname, font='12px')
+ fname = urllib.unquote(fname)
+ text = hippo.CanvasText(text=fname, font='12px', xalign=hippo.ALIGNMENT_START)
+ text.set_property("attributes", attrs)
vbox.append(text)
apps = gnomevfs.mime_get_all_applications(mime)
if apps:
- text = hippo.CanvasText(text='Open With: ', font='Bold 14px')
+ text = hippo.CanvasText(text='Open With: ', font='14px')
vbox.append(text)
def on_app_clicked(button, app):
self.emit('close')
_logger.debug("launching app %s", app)
- _launch_vfsmimeapp(app, fobj.get_url())
+ _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 = Button(label=app[1])
+ try:
+ menu = directory.lookup(app[0])
+ except KeyError, e:
+ _logger.debug("failed to find desktop file %s", app[0])
+ menu = None
+ if menu:
+ pixbuf = get_menu_pixbuf(menu, size=24)
+ img = gtk.Image()
+ img.set_from_pixbuf(pixbuf)
+ button.get_button().set_property('image', img)
button.get_button().connect('clicked', on_app_clicked, app)
vbox.append(button)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]