home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.4)
-
- import os
- import cgi
- import re
- from os.path import *
- import deskbar
- import deskbar.gnomedesktop as deskbar
- import gtk
- import gtk.gdk as gtk
- import gnome.ui as gnome
- from htmlentitydefs import name2codepoint
- ICON_THEME = gtk.icon_theme_get_default()
- factory = gnome.ui.ThumbnailFactory(deskbar.ICON_HEIGHT)
- charrefpat = re.compile('&(#(\\d+|x[\\da-fA-F]+)|[\\w.:-]+);?')
-
- def htmldecode(text):
- '''Decode HTML entities in the given text.'''
- if type(text) is unicode:
- uchr = unichr
- else:
-
- uchr = lambda value: if not value > 255 or unichr(value):
- passchr(value)
-
- def entitydecode(match, uchr = uchr):
- entity = match.group(1)
- if entity.startswith('#x'):
- return uchr(int(entity[2:], 16))
- elif entity.startswith('#'):
- return uchr(int(entity[1:]))
- elif entity in name2codepoint:
- return uchr(name2codepoint[entity])
- else:
- return match.group(0)
-
- return charrefpat.sub(entitydecode, text)
-
-
- def strip_html(string):
- return re.sub('<.*?>|</.*?>', '', string)
-
-
- def more_information_dialog(parent, title, content):
- message_dialog = gtk.MessageDialog(parent = parent, buttons = gtk.BUTTONS_CLOSE)
- message_dialog.set_markup("<span size='larger' weight='bold'>%s</span>\n\n%s" % (cgi.escape(title), cgi.escape(content)))
- resp = message_dialog.run()
- if resp == gtk.RESPONSE_CLOSE:
- message_dialog.destroy()
-
-
-
- def get_xdg_data_dirs():
- dirs = os.getenv('XDG_DATA_HOME')
- if dirs == None:
- dirs = expanduser('~/.local/share')
-
- sysdirs = os.getenv('XDG_DATA_DIRS')
- if sysdirs == None:
- sysdirs = '/usr/local/share:/usr/share'
-
- dirs = '%s:%s' % (dirs, sysdirs)
- return _[1]
-
-
- def load_icon_for_file(f):
- (icon_name, flags) = gnome.ui.icon_lookup(ICON_THEME, factory, f, '', gnome.ui.ICON_LOOKUP_FLAGS_SHOW_SMALL_IMAGES_AS_THEMSELVES)
- return load_icon(icon_name)
-
-
- def load_icon_for_desktop_icon(icon):
- if icon != None:
- icon = deskbar.gnomedesktop.find_icon(ICON_THEME, icon, deskbar.ICON_HEIGHT, 0)
- if icon != None:
- return load_icon(icon)
-
-
-
-
- def load_icon(icon, width = deskbar.ICON_HEIGHT, height = deskbar.ICON_HEIGHT):
- pixbuf = None
- if icon != None and icon != '':
-
- try:
- our_icon = join(deskbar.ART_DATA_DIR, icon)
- if exists(our_icon):
- pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(our_icon, width, height)
- elif icon.startswith('/'):
- pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(icon, width, height)
- else:
- pixbuf = ICON_THEME.load_icon(splitext(icon)[0], width, gtk.ICON_LOOKUP_USE_BUILTIN)
- except Exception:
- msg1 = None
-
- try:
- pixbuf = ICON_THEME.load_icon(icon, width, gtk.ICON_LOOKUP_USE_BUILTIN)
- except Exception:
- msg2 = None
- print 'Error:load_icon:Icon Load Error:%s (or %s)' % (msg1, msg2)
- except:
- None<EXCEPTION MATCH>Exception
-
-
- None<EXCEPTION MATCH>Exception
-
-
- None<EXCEPTION MATCH>Exception
- if pixbuf != None and pixbuf.get_height() > height:
- pixbuf = pixbuf.scale_simple(width, height, gtk.gdk.INTERP_BILINEAR)
-
- return pixbuf
-
-