Exemple #1
0
def load_icon_from_func(plugin_name, icon_name, get_data_func, override=False):
    """
    Load icon from @icon_data into the name @icon_name

    @get_data_func: function to retrieve the data if needed
    @override: override the icon theme
    """
    if not override and icon_name in kupfer_locally_installed_names:
        pretty.print_debug(__name__, "Skipping existing", icon_name)
        return
    if not override and _default_theme.has_icon(icon_name):
        pretty.print_debug(__name__, "Skipping themed icon", icon_name)
        return
    try:
        icon_data = get_data_func()
    except:
        pretty.print_error(__name__, "Error loading icon %r for %r" %
                           (icon_name, plugin_name))
        pretty.print_exc(__name__)
        return
    for size in (SMALL_SZ, LARGE_SZ):
        pixbuf = get_pixbuf_from_data(icon_data, size, size)
        gtk.icon_theme_add_builtin_icon(icon_name, size, pixbuf)
        pretty.print_debug(__name__, "Loading icon", icon_name, "at", size,
                "for", plugin_name)
    kupfer_locally_installed_names.add(icon_name)
Exemple #2
0
    def get_scaled_icon(self, path, size):
        """Interpret a raw Icon value from a .desktop and return a good icon

        (Employs L{_ensure_good_upscales} to minimize blurrying tiny icons)

        @todo: Consider some kind of autocropping for things like Ultratron
               where they matted a perfectly good square icon on a rectangular
               white background.
        """
        if path is None:
            return None

        # Inject non-theme icon paths as builtins for consistent lookup
        if os.path.exists(path) and not self.icon_theme.has_icon(path):
            icon = gtk.gdk.pixbuf_new_from_file(path)
            w, h = icon.get_width(), icon.get_height()
            isize = max(w, h)

            gtk.icon_theme_add_builtin_icon(path, isize, icon)

        # TODO: Deduplicate this code as much as possible
        try:
            self._ensure_good_upscales(path, size)
            icon = self.icon_theme.load_icon(path, size, 0)
            if not (size == icon.get_width() == icon.get_height()):
                log.debug("%s: %s != %s != %s" %
                      (path, size, icon.get_width(), icon.get_height()))
            return self._ensure_dimensions(icon, size)
        except (AttributeError, glib.GError):
            log.error("BAD ICON: %s", path)
            try:
                return self._ensure_dimensions(
                    self.icon_theme.load_icon(FALLBACK_ICON, size, 0))
            except glib.GError, err:
                log.error("Error while loading fallback icon: %s", err)
Exemple #3
0
def load_icon_from_func(plugin_name, icon_name, get_data_func, override=False):
    """
	Load icon from @icon_data into the name @icon_name

	@get_data_func: function to retrieve the data if needed
	@override: override the icon theme
	"""
    if not override and icon_name in kupfer_locally_installed_names:
        pretty.print_debug(__name__, "Skipping existing", icon_name)
        return
    if not override and _default_theme.has_icon(icon_name):
        pretty.print_debug(__name__, "Skipping themed icon", icon_name)
        return
    try:
        icon_data = get_data_func()
    except:
        pretty.print_error(
            __name__,
            "Error loading icon %r for %r" % (icon_name, plugin_name))
        pretty.print_exc(__name__)
        return
    for size in (SMALL_SZ, LARGE_SZ):
        pixbuf = get_pixbuf_from_data(icon_data, size, size)
        gtk.icon_theme_add_builtin_icon(icon_name, size, pixbuf)
        pretty.print_debug(__name__, "Loading icon", icon_name, "at", size,
                           "for", plugin_name)
    kupfer_locally_installed_names.add(icon_name)
Exemple #4
0
    def _ensure_good_upscales(self, icon_name, target_size):
        """Mitigate scaling blur for icons smaller than 32px
        (By using pixel doubling/tripling to give them a more retro look)
        """
        iinfo = self.icon_theme.lookup_icon(icon_name, target_size,
                        gtk.ICON_LOOKUP_USE_BUILTIN)
        if iinfo is None:
            return None
        base_size = iinfo.get_base_size()

        # For icons smaller than 32px use pixel doubling to add some upscales
        # (Otherwise, 16px icons are unacceptably blurry)
        # Also, add some explicitly doubled versions for icons which refuse to
        # scale to force scaling.
        # TODO: I'll have to figure out how to workaround PlayOnLinux's
        #       crappy 16->32 upscaling
        icon = self.icon_theme.load_icon(icon_name, base_size, 0)
        w, h = icon.get_width(), icon.get_height()

        # Inject larger versions using INTERP_NEAREST at integer scales up to
        # but not including the target size (but at least once for any icons
        # below 32px). It provides a good compromise between the jagginess of
        # raw pixel doubling and the extreme blur of heavy interpolation.
        scale = 2
        while base_size * scale < max(target_size, 32 * 2):
            isize = max(w, h)
            log.debug("%s: %s -> %s", icon_name, isize, base_size * scale)

            gtk.icon_theme_add_builtin_icon(icon_name, isize * scale,
                icon.scale_simple(w * scale, h * scale,
                    gtk.gdk.INTERP_NEAREST))
            scale += 1
Exemple #5
0
def _register_icons():
    icondir = _get_icon_path()
    for filename in glob.glob(os.path.join(icondir, '*.png')):
        basename = os.path.basename(filename)
        name = basename[:-4]
        gtk.icon_theme_add_builtin_icon('widget-kiwi-%s' % (name, ), 22,
                                        gtk.gdk.pixbuf_new_from_file(filename))
Exemple #6
0
def set_stock_icons(st_req, st_path):
    import pkg_resources as pr
    icon_names = pr.resource_listdir(st_req, st_path)
    stock_ids = set(gtk.stock_list_ids())
    iconfactory = gtk.IconFactory()
    theme = gtk.icon_theme_get_default()
    listed = theme.list_icons()
    for icon in icon_names:
        if icon.startswith('.'):
            continue
        iconname = icon.split('.', 1)[0]
        if iconname not in listed:
            iconres = '/'.join(['data', 'icons', icon])
            iconpath = pr.resource_filename(st_req, iconres)
            try:
                pixbuf = gtk.gdk.pixbuf_new_from_file(iconpath)
                iconset = gtk.IconSet(pixbuf)
                iconfactory.add(iconname, iconset)
                gtk.icon_theme_add_builtin_icon(iconname, 128, pixbuf)
            except gobject.GError:
                # icon could not be loaded
                pass
            
    iconfactory.add_default()
    return theme, iconfactory
Exemple #7
0
def load_plugin_icon(plugin_name, icon_name, icon_data):
	"Load icon from @icon_data into the name @icon_name"
	for size in (24, 96):
		pixbuf = get_pixbuf_from_data(icon_data, size, size)
		gtk.icon_theme_add_builtin_icon(icon_name, size, pixbuf)
		pretty.print_debug(__name__, "Loading icon", icon_name, "at", size,
				"for", plugin_name)
Exemple #8
0
def _register_icons():
    icondir = _get_icon_path()
    for filename in glob.glob(os.path.join(icondir, '*.png')):
        basename = os.path.basename(filename)
        name = basename[:-4]
        gtk.icon_theme_add_builtin_icon(
            'widget-kiwi-%s' % (name,),
            22,
            gtk.gdk.pixbuf_new_from_file(filename))
Exemple #9
0
    def add_icon_name_from_pixbuf(self, icon_name, pixbuf, size=None):
        """
            Registers an icon name from a pixbuf
            
            :param icon_name: the name for the icon
            :type icon_name: string
            :param pixbuf: the pixbuf of an image
            :type pixbuf: :class:`gtk.gdk.Pixbuf`
            :param size: the size the icon shall be registered for
            :type size: int
        """
        if size is None:
            size = pixbuf.get_width()

        gtk.icon_theme_add_builtin_icon(icon_name, size, pixbuf)
Exemple #10
0
    def add_icon_name_from_pixbuf(self, icon_name, pixbuf, size=None):
        """
            Registers an icon name from a pixbuf
            
            :param icon_name: the name for the icon
            :type icon_name: string
            :param pixbuf: the pixbuf of an image
            :type pixbuf: :class:`gtk.gdk.Pixbuf`
            :param size: the size the icon shall be registered for
            :type size: int
        """
        if size is None:
            size = pixbuf.get_width()

        gtk.icon_theme_add_builtin_icon(icon_name, size, pixbuf)
Exemple #11
0
def load_kupfer_icons(scheduler):
    """Load in kupfer icons from installed files"""
    ilist = "art/icon-list"
    ilist_file_path = config.get_data_file(ilist)
    # parse icon list file
    ifile = open(ilist_file_path, "r")
    for line in ifile:
        # ignore '#'-comments
        if line.startswith("#"):
            continue
        icon_name, basename, size = (i.strip() for i in line.split("\t", 2))
        size = int(size)
        icon_path = config.get_data_file(os.path.join("art", basename))
        if not icon_path:
            pretty.print_info(__name__, "Icon", basename, icon_path, "not found")
            continue
        pixbuf = pixbuf_new_from_file_at_size(icon_path, size, size)
        gtk.icon_theme_add_builtin_icon(icon_name, size, pixbuf)
        pretty.print_debug(__name__, "Loading icon", icon_name, "at", size, "from", icon_path)
Exemple #12
0
 def __init__(self, icon_file=None):
     
     import pkg_resources as pr
     pidareq = pr.Requirement.parse('pida')
     icon_names = pr.resource_listdir(pidareq, 'icons')
     stock_ids = set(gtk.stock_list_ids())
     iconfactory = gtk.IconFactory()
     self.__theme = gtk.icon_theme_get_default()
     listed = self.__theme.list_icons()
     for icon in icon_names:
         iconname = icon.split('.', 1)[0]
         if iconname not in listed:
             iconres = '/'.join(['icons', icon])
             iconpath = pr.resource_filename(pidareq, iconres)
             pixbuf = gtk.gdk.pixbuf_new_from_file(iconpath)
             iconset = gtk.IconSet(pixbuf)
             iconfactory.add(iconname, iconset)
             gtk.icon_theme_add_builtin_icon(iconname, 128, pixbuf)
     iconfactory.add_default()
     self.__iconfactory = iconfactory
Exemple #13
0
    def __init__(self, icon_file=None):

        import pkg_resources as pr
        pidareq = pr.Requirement.parse('pida')
        icon_names = pr.resource_listdir(pidareq, 'icons')
        stock_ids = set(gtk.stock_list_ids())
        iconfactory = gtk.IconFactory()
        self.__theme = gtk.icon_theme_get_default()
        listed = self.__theme.list_icons()
        for icon in icon_names:
            iconname = icon.split('.', 1)[0]
            if iconname not in listed:
                iconres = '/'.join(['icons', icon])
                iconpath = pr.resource_filename(pidareq, iconres)
                pixbuf = gtk.gdk.pixbuf_new_from_file(iconpath)
                iconset = gtk.IconSet(pixbuf)
                iconfactory.add(iconname, iconset)
                gtk.icon_theme_add_builtin_icon(iconname, 128, pixbuf)
        iconfactory.add_default()
        self.__iconfactory = iconfactory
Exemple #14
0
def set_stock_icons(st_req, st_path):
    import pkg_resources as pr
    pidareq = pr.Requirement.parse(st_req)
    icon_names = pr.resource_listdir(pidareq, st_path)
    stock_ids = set(gtk.stock_list_ids())
    iconfactory = gtk.IconFactory()
    theme = gtk.icon_theme_get_default()
    listed = theme.list_icons()
    for icon in icon_names:
        if icon.startswith('.'):
            continue
        iconname = icon.split('.', 1)[0]
        if iconname not in listed:
            iconres = '/'.join(['icons', icon])
            iconpath = pr.resource_filename(pidareq, iconres)
            pixbuf = gtk.gdk.pixbuf_new_from_file(iconpath)
            iconset = gtk.IconSet(pixbuf)
            iconfactory.add(iconname, iconset)
            gtk.icon_theme_add_builtin_icon(iconname, 24, pixbuf)
    iconfactory.add_default()
    return theme, iconfactory
Exemple #15
0
 def __init__(self, icon_file=None):
     #icon_file = ('/home/ali/working/pida/pida/branches/'
     #             'pida-ali/pida/pidagtk/icons.dat')
     from pkg_resources import Requirement, resource_filename
     icon_file = resource_filename(Requirement.parse('pida'), 'images/icons.dat')
     #icon_file = "/usr/share/pida/icons.dat"
     self.d = shelve.open(icon_file, 'r')
     self.cs = gtk.gdk.COLORSPACE_RGB
     stock_ids = set(gtk.stock_list_ids())
     iconfactory = gtk.IconFactory()
     self.__theme = gtk.icon_theme_get_default()
     for k in self.d:
         stockname = 'gtk-%s' % k
         if stockname not in stock_ids:
             d, a = self.d[k]
             pixbuf = gtk.gdk.pixbuf_new_from_data(d, self.cs, *a)
             iconset = gtk.IconSet(pixbuf)
             iconfactory.add(stockname, iconset)
             gtk.icon_theme_add_builtin_icon(stockname, 12, pixbuf)
     iconfactory.add_default()
     self.__iconfactory = iconfactory
Exemple #16
0
def set_stock_icons(st_req, st_path):
    import pkg_resources as pr
    pidareq = pr.Requirement.parse(st_req)
    icon_names = pr.resource_listdir(pidareq, st_path)
    stock_ids = set(gtk.stock_list_ids())
    iconfactory = gtk.IconFactory()
    theme = gtk.icon_theme_get_default()
    listed = theme.list_icons()
    for icon in icon_names:
        if icon.startswith('.'):
            continue
        iconname = icon.split('.', 1)[0]
        if iconname not in listed:
            iconres = '/'.join(['icons', icon])
            iconpath = pr.resource_filename(pidareq, iconres)
            pixbuf = gtk.gdk.pixbuf_new_from_file(iconpath)
            iconset = gtk.IconSet(pixbuf)
            iconfactory.add(iconname, iconset)
            gtk.icon_theme_add_builtin_icon(iconname, 24, pixbuf)
    iconfactory.add_default()
    return theme, iconfactory
Exemple #17
0
 def __init__(self, icon_file=None):
     #icon_file = ('/home/ali/working/pida/pida/branches/'
     #             'pida-ali/pida/pidagtk/icons.dat')
     from pkg_resources import Requirement, resource_filename
     icon_file = resource_filename(Requirement.parse('pida'),
                                   'images/icons.dat')
     #icon_file = "/usr/share/pida/icons.dat"
     self.d = shelve.open(icon_file, 'r')
     self.cs = gtk.gdk.COLORSPACE_RGB
     stock_ids = set(gtk.stock_list_ids())
     iconfactory = gtk.IconFactory()
     self.__theme = gtk.icon_theme_get_default()
     for k in self.d:
         stockname = 'gtk-%s' % k
         if stockname not in stock_ids:
             d, a = self.d[k]
             pixbuf = gtk.gdk.pixbuf_new_from_data(d, self.cs, *a)
             iconset = gtk.IconSet(pixbuf)
             iconfactory.add(stockname, iconset)
             gtk.icon_theme_add_builtin_icon(stockname, 12, pixbuf)
     iconfactory.add_default()
     self.__iconfactory = iconfactory
Exemple #18
0
from __future__ import absolute_import


__all__ = ['DockLayout', 'DockFrame', 'DockPaned', 'DockGroup', 'DockItem', 'settings']
__version__ = '0.3'
__docformat__ = 'restructuredtext'


############################################################################
# Initialization
############################################################################
import os, gtk

# Register some custom icons into the default icon theme
path = os.path.abspath(os.path.join(os.path.dirname(__file__), 'icons', '16x16'))
gtk.icon_theme_add_builtin_icon('compact-close', 16, gtk.gdk.pixbuf_new_from_file(os.path.join(path, 'compact-close.png')))
gtk.icon_theme_add_builtin_icon('compact-close-prelight', 16, gtk.gdk.pixbuf_new_from_file(os.path.join(path, 'compact-close-prelight.png')))
gtk.icon_theme_add_builtin_icon('compact-list', 16, gtk.gdk.pixbuf_new_from_file(os.path.join(path, 'compact-list.png')))
gtk.icon_theme_add_builtin_icon('compact-minimize', 16, gtk.gdk.pixbuf_new_from_file(os.path.join(path, 'compact-minimize.png')))
gtk.icon_theme_add_builtin_icon('compact-maximize', 16, gtk.gdk.pixbuf_new_from_file(os.path.join(path, 'compact-maximize.png')))
gtk.icon_theme_add_builtin_icon('compact-restore', 16, gtk.gdk.pixbuf_new_from_file(os.path.join(path, 'compact-restore.png')))

# Check for elib, not required.
try:
    from elib.intl import install_module
except ImportError:
    def _(message): return message
else:
    localedir = os.path.abspath(os.path.join(os.path.dirname(__file__),
                                             '..', '..', 'share', 'locale'))
    _ = install_module('etk.docking', localedir)
Exemple #19
0
    def __init__(self):
        super(MainWindow, self).__init__()

        pynotify.init("Mailanie")
        self.set_title("Mailanie")

        self.pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
            os.path.join(os.path.dirname(__file__), "mailanie.svg"), 600, 600)
        self.connect_after("expose-event", self._expose)

        icon_theme = gtk.icon_theme_get_default()
        icon_factory = gtk.IconFactory()
        icon_factory.add_default()

        for icon in _icons:
            pixbuf = icon_theme.load_icon(_icons[icon][0], 128, 0)
            gtk.icon_theme_add_builtin_icon(icon, 128, pixbuf)
            gtk.stock_add([(icon, _icons[icon][1], 0, 0, None)])
            icon_factory.add(icon, gtk.IconSet(pixbuf))

        self.action_group = gtk.ActionGroup("actions")
        self.action_group.add_actions([
                ("New Mail", "mail-new",
                 None, None, _("Write a New Mail"),
                 lambda action: self.add_writemail_tab()),
                ("Refresh", "mail-send-receive",
                 None, None, _("Refresh the Mail Boxes"),
                 lambda action: self._update_mailbox()),
                ("Delete", "delete",
                 None, None, _("Delete Trash Mails"),
                 lambda action: self._delete_trash_mails()),
                ("Address Book", "address-book",
                 None, None, _("Open Address Book"),
                 lambda action: self._add_tab(mailanie.address_book)),
                ("Preferences", gtk.STOCK_PREFERENCES,
                 None, None, _("Choose Preferences"),
                 lambda action: self.preferences.show_all()),
                ("About", gtk.STOCK_ABOUT,
                 None, None, _("About Mailanie"),
                 lambda action: about.About()),
                ("Quit", gtk.STOCK_QUIT,
                 None, None, _("Quit Mailanie"),
                 lambda action: self.quit()),
                ])

        self.ui_manager = gtk.UIManager()
        self.ui_manager.add_ui_from_string(self._menu)
        self.ui_manager.insert_action_group(self.action_group)

        self.accel_group = self.ui_manager.get_accel_group()
        self.add_accel_group(self.accel_group)

        main_box = gtk.VBox()
        self.add(main_box)

        toolbar_box = gtk.HBox()
        main_box.pack_start(toolbar_box, expand=False)
        toolbar_box.pack_start(self.ui_manager.get_widget("/Toolbar"))

        toolbar = gtk.Toolbar()
        toolbar_box.pack_start(toolbar, expand=False)
        entry = gtk.Entry()
        entry.set_icon_from_stock(gtk.ENTRY_ICON_PRIMARY, "search")
        entry.set_icon_from_stock(gtk.ENTRY_ICON_SECONDARY, "clear")
        entry.connect("icon-release", self._search_icon)
        entry.connect("activate", lambda entry: self._search_icon(
                entry, gtk.ENTRY_ICON_PRIMARY, None))
        toolbar.add(entry)

        self.paned = gtk.HPaned()
        main_box.pack_start(self.paned)

        self._load_mailbox()
        self._load_address_book()

        self.preferences = preferences.Preferences()
        self.preferences.connect_after("response", self._preference_response)

        self.notebook = gtk.Notebook()
        self.notebook.set_scrollable(True)
        self.paned.add2(self.notebook)

        self.connect("destroy", lambda widget: self.quit())

        glib.timeout_add(60000, self._update_mailbox)

        gtk.window_set_default_icon_from_file(
            os.path.join(os.path.dirname(__file__), "mailanie.svg"))

        gtk.rc_parse_string ("""
            style "close-button-style"
            {
              GtkWidget::focus-padding = 0
              GtkWidget::focus-line-width = 0
              xthickness = 0
              ythickness = 0
            }
            widget "*.close-button" style "close-button-style"
            """)
Exemple #20
0
            try:
                pixbuf = icon_theme.load_icon(icon, width,
                                              gtk.ICON_LOOKUP_USE_BUILTIN)
            except Exception, msg2:
                print 'Error:load_icon:Icon Load Error:%s (or %s)' % (msg1,
                                                                      msg2)

    return pixbuf

# Register our icon with the icon theme if running from source
if utils.runned_from_source():
    for size in [16, 22, 24, 32]:
        icon_dir = "%sx%s" % (size, size)
        icon_file = os.path.join(icon_dir, "gget.png")
        pixbuf = load_icon(icon_file, size, size)
        gtk.icon_theme_add_builtin_icon(NAME.lower(), size, pixbuf)

def load_icon_from_mime_type(mime_type, size=48):
    """Loads an icon from a mime type string. This is ugly and error prone,
    there must be a better way to do this."""
    pixbuf = None
    l = mime_type.split("/")
    mime = "%s-%s" % (l[0], l[1])
    try:
        pixbuf = icon_theme.load_icon(mime, size, gtk.ICON_LOOKUP_USE_BUILTIN)
    except Exception, msg1:
        try:
            mime = "gnome-mime-%s" % mime
            pixbuf = icon_theme.load_icon(mime, size,
                    gtk.ICON_LOOKUP_USE_BUILTIN)
        except Exception, msg2:
Exemple #21
0
    def __init__(self):

        self.dbus = gintegration.DBusManager(self)

        gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
        self.set_title(_("Gwibber"))
        self.set_default_size(330, 500)
        config.GCONF.add_dir(config.GCONF_PREFERENCES_DIR,
                             config.gconf.CLIENT_PRELOAD_NONE)
        self.preferences = config.Preferences()
        self.last_update = None
        self.last_focus_time = None
        self.last_clear = None
        self._reply_acct = None
        self.indicator_items = {}
        layout = gtk.VBox()

        gtk.rc_parse_string("""
    style "tab-close-button-style" {
      GtkWidget::focus-padding = 0
      GtkWidget::focus-line-width = 0
      xthickness = 0
      ythickness = 0
     }
     widget "*.tab-close-button" style "tab-close-button-style"
     """)

        self.accounts = configui.AccountManager()
        self.client = microblog.Client(self.accounts)
        self.client.handle_error = self.handle_error
        self.client.post_process_message = self.post_process_message

        self.notification_bubbles = {}
        self.message_target = None

        self.errors = table.generate(
            [["date", lambda t: t.time.strftime("%x")],
             ["time", lambda t: t.time.strftime("%X")], ["username"],
             ["protocol"],
             [
                 "message",
                 (gtk.CellRendererText(), {
                     "markup": lambda t: t.message
                 })
             ]])

        self.connect("delete-event", self.on_window_close)
        self.connect("focus-out-event", self.on_focus_out)
        self.connect("focus-in-event", self.on_focus)

        for key, value in list(DEFAULT_PREFERENCES.items()):
            if self.preferences[key] == None: self.preferences[key] = value

        self.preferences["version"] = VERSION_NUMBER

        self.timer = gobject.timeout_add(
            60000 * int(self.preferences["refresh_interval"]), self.update)
        self.preferences.notify("refresh_interval",
                                self.on_refresh_interval_changed)
        self.preferences.notify("theme", self.on_theme_change)

        gtk.icon_theme_add_builtin_icon(
            "gwibber", 22,
            gtk.gdk.pixbuf_new_from_file_at_size(
                resources.get_ui_asset("gwibber.svg"), 24, 24))

        self.set_icon_name("gwibber")
        self.tray_icon = gtk.status_icon_new_from_icon_name("gwibber")
        self.tray_icon.connect("activate", self.on_toggle_window_visibility)

        self.tabs = gtk.Notebook()
        self.tabs.set_property("homogeneous", False)
        self.tabs.set_scrollable(True)
        self.messages_view = self.add_msg_tab(self.client.receive,
                                              _("Messages"),
                                              show_icon="go-home")
        self.add_msg_tab(self.client.responses,
                         _("Replies"),
                         show_icon="mail-reply-all",
                         add_indicator=True)

        saved_position = config.GCONF.get_list(
            "%s/%s" % (config.GCONF_PREFERENCES_DIR, "saved_position"),
            config.gconf.VALUE_INT)
        if saved_position:
            self.move(*saved_position)

        saved_size = config.GCONF.get_list(
            "%s/%s" % (config.GCONF_PREFERENCES_DIR, "saved_size"),
            config.gconf.VALUE_INT)
        if saved_size:
            self.resize(*saved_size)

        saved_queries = config.GCONF.get_list(
            "%s/%s" % (config.GCONF_PREFERENCES_DIR, "saved_searches"),
            config.gconf.VALUE_STRING)

        if saved_queries:
            for query in saved_queries:
                # XXX: suggest refactor of below code to avoid duplication of on_search code
                if query.startswith("#"):
                    self.add_msg_tab(functools.partial(self.client.tag, query),
                                     query.replace("#", ""), True,
                                     gtk.STOCK_INFO, False, query)
                elif microblog.support.LINK_PARSE.match(query):
                    self.add_msg_tab(
                        functools.partial(self.client.search_url, query),
                        urlparse.urlparse(query)[1], True, gtk.STOCK_FIND,
                        True, query)
                elif len(query) > 0:
                    title = _("Search") + " '" + query[:12] + "...'"
                    self.add_msg_tab(
                        functools.partial(self.client.search, query), title,
                        True, gtk.STOCK_FIND, False, query)

        #self.add_map_tab(self.client.friend_positions, "Location")

        if gintegration.SPELLCHECK_ENABLED:
            self.input = gintegration.sexy.SpellEntry()
            self.input.set_checked(self.preferences["spellcheck_enabled"])
        else:
            self.input = gtk.Entry()
        self.input.connect("insert-text", self.on_add_text)
        self.input.connect("populate-popup", self.on_input_context_menu)
        self.input.connect("activate", self.on_input_activate)
        self.input.connect("changed", self.on_input_change)
        self.input.set_max_length(MAX_MESSAGE_LENGTH)

        self.cancel_button = gtk.Button(_("Cancel"))
        self.cancel_button.connect("clicked", self.on_cancel_reply)

        self.editor = gtk.HBox()
        self.editor.pack_start(self.input)
        self.editor.pack_start(self.cancel_button, False)

        vb = gtk.VBox(spacing=5)
        vb.pack_start(self.tabs, True, True)
        vb.pack_start(self.editor, False, False)
        vb.set_border_width(5)

        warning_icon = gtk.image_new_from_stock(gtk.STOCK_DIALOG_WARNING,
                                                gtk.ICON_SIZE_MENU)
        self.status_icon = gtk.EventBox()
        self.status_icon.add(warning_icon)
        self.status_icon.connect("button-press-event", self.on_errors_show)

        self.statusbar = gtk.Statusbar()
        self.statusbar.pack_start(self.status_icon, False, False)

        layout.pack_start(self.setup_menus(), False)
        layout.pack_start(vb, True, True)
        layout.pack_start(self.statusbar, False)
        self.add(layout)

        if gintegration.can_notify:
            # FIXME: Move this to DBusManager
            import dbus

            # http://galago-project.org/specs/notification/0.9/x408.html#signal-notification-closed
            def on_notify_close(nId, reason=1):
                if nId in self.notification_bubbles:
                    del self.notification_bubbles[nId]

            def on_notify_action(nId, action):
                if action == "reply":
                    self.reply(self.notification_bubbles[nId])
                    self.window.show()
                    self.present()

            bus = dbus.SessionBus()
            bus.add_signal_receiver(
                on_notify_close,
                dbus_interface="org.freedesktop.Notifications",
                signal_name="NotificationClosed")

            bus.add_signal_receiver(
                on_notify_action,
                dbus_interface="org.freedesktop.Notifications",
                signal_name="ActionInvoked")

        if indicate:
            self.indicate = indicate.indicate_server_ref_default()
            self.indicate.set_type("message.gwibber")
            self.indicate.set_desktop_file(resources.get_desktop_file())
            self.indicate.connect("server-display",
                                  self.on_toggle_window_visibility)
            self.indicate.show()

        for i in list(CONFIGURABLE_UI_ELEMENTS.keys()):
            config.GCONF.notify_add(
                config.GCONF_PREFERENCES_DIR + "/show_%s" % i,
                lambda *a: self.apply_ui_element_settings())

        config.GCONF.notify_add("/apps/gwibber/accounts",
                                self.on_account_change)

        self.preferences.notify("hide_taskbar_entry",
                                lambda *a: self.apply_ui_element_settings())

        self.preferences.notify("spellcheck_enabled",
                                lambda *a: self.apply_ui_element_settings())

        #for i in CONFIGURABLE_UI_SETTINGS:
        #  config.GCONF.notify_add(config.GCONF_PREFERENCES_DIR + "/%s" % i,
        #    lambda *a: self.apply_ui_drawing_settings())

        def on_key_press(w, e):
            if e.keyval == gtk.keysyms.F5:
                self.update()
                return True
            if e.keyval == gtk.keysyms.Tab and e.state & gtk.gdk.CONTROL_MASK:
                if len(self.tabs) == self.tabs.get_current_page() + 1:
                    self.tabs.set_current_page(0)
                else:
                    self.tabs.next_page()
                return True
            elif e.keyval in [ord(str(x)) for x in range(10)
                              ] and e.state & gtk.gdk.MOD1_MASK:
                self.tabs.set_current_page(
                    int(gtk.gdk.keyval_name(e.keyval)) - 1)
                return True
            elif e.keyval == gtk.keysyms.T and e.state & gtk.gdk.CONTROL_MASK:
                self.on_theme_change()
                return True
            else:
                return False

            #else:
            #  if not self.input.is_focus():
            #    self.input.grab_focus()
            #    self.input.set_position(-1)
            #  return False

        self.connect("key_press_event", on_key_press)

        self.show_all()
        self.apply_ui_element_settings()
        self.cancel_button.hide()
        self.status_icon.hide()

        if not self.preferences["inhibit_startup_refresh"]:
            self.update()