From 2760437b11308e17269b4ccd984cd788108fd240 Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Tue, 29 Jun 2010 19:46:19 +0200 Subject: [PATCH 1/1] Don't abort when icons are missing Due to the way hildon-status-menu loads the plugins as soon as the .desktop files appear, there is a race between the Tor applet trying to load its icons and the package manager still unpacking them. Instead of aborting, just retry until the icon appears. This fixes #10798: https://bugs.maemo.org/show_bug.cgi?id=10798 --- debian/status-area-applet-tor.postinst | 2 + src/status-area-applet-tor.vala | 70 ++++++++++++++++---------------- 2 files changed, 38 insertions(+), 34 deletions(-) diff --git a/debian/status-area-applet-tor.postinst b/debian/status-area-applet-tor.postinst index 3e78d9a..a417e12 100644 --- a/debian/status-area-applet-tor.postinst +++ b/debian/status-area-applet-tor.postinst @@ -1,3 +1,5 @@ #!/bin/sh #update the icon cache gtk-update-icon-cache -f /usr/share/icons/hicolor +#gtk_icon_theme_rescan_if_needed doesn't trigger without this +touch /usr/share/icons/hicolor diff --git a/src/status-area-applet-tor.vala b/src/status-area-applet-tor.vala index 083d465..d384053 100644 --- a/src/status-area-applet-tor.vala +++ b/src/status-area-applet-tor.vala @@ -80,42 +80,42 @@ class TorStatusMenuItem : HD.StatusMenuItem { /** * Update status area icon and status menu button value */ - private void update_status () { - if (tor_enabled && tor_connected && icon_connected == null) try { - var icon_theme = Gtk.IconTheme.get_default (); - var pixbuf = icon_theme.load_icon ("statusarea_tor_connected", - STATUS_AREA_ICON_SIZE, - Gtk.IconLookupFlags.NO_SVG); - icon_connected = pixbuf; + private bool update_status () { + try { + if (tor_enabled && tor_connected && icon_connected == null) { + var icon_theme = Gtk.IconTheme.get_default (); + var pixbuf = icon_theme.load_icon ("statusarea_tor_connected", + STATUS_AREA_ICON_SIZE, + Gtk.IconLookupFlags.NO_SVG); + icon_connected = pixbuf; + } + if (tor_enabled && !tor_connected && icon_connecting == null) { + var icon_theme = Gtk.IconTheme.get_default (); + var pixbuf = icon_theme.load_icon ("statusarea_tor_connecting", + STATUS_AREA_ICON_SIZE, + Gtk.IconLookupFlags.NO_SVG); + icon_connecting = pixbuf; + } + if (tor_enabled && icon_enabled == null) { + var icon_theme = Gtk.IconTheme.get_default(); + var pixbuf = icon_theme.load_icon ("statusarea_tor_enabled", + STATUS_MENU_ICON_SIZE, + Gtk.IconLookupFlags.NO_SVG); + icon_enabled = new Gtk.Image.from_pixbuf (pixbuf); + } + if (!tor_enabled && icon_disabled == null) { + var icon_theme = Gtk.IconTheme.get_default(); + var pixbuf = icon_theme.load_icon ("statusarea_tor_disabled", + STATUS_MENU_ICON_SIZE, + Gtk.IconLookupFlags.NO_SVG); + icon_disabled = new Gtk.Image.from_pixbuf (pixbuf); + } } catch (Error e) { - error (e.message); - } - if (tor_enabled && !tor_connected && icon_connecting == null) try { + critical (e.message); var icon_theme = Gtk.IconTheme.get_default (); - var pixbuf = icon_theme.load_icon ("statusarea_tor_connecting", - STATUS_AREA_ICON_SIZE, - Gtk.IconLookupFlags.NO_SVG); - icon_connecting = pixbuf; - } catch (Error e) { - error (e.message); - } - if (tor_enabled && icon_enabled == null) try { - var icon_theme = Gtk.IconTheme.get_default(); - var pixbuf = icon_theme.load_icon ("statusarea_tor_enabled", - STATUS_MENU_ICON_SIZE, - Gtk.IconLookupFlags.NO_SVG); - icon_enabled = new Gtk.Image.from_pixbuf (pixbuf); - } catch (Error e) { - error (e.message); - } - if (!tor_enabled && icon_disabled == null) try { - var icon_theme = Gtk.IconTheme.get_default(); - var pixbuf = icon_theme.load_icon ("statusarea_tor_disabled", - STATUS_MENU_ICON_SIZE, - Gtk.IconLookupFlags.NO_SVG); - icon_disabled = new Gtk.Image.from_pixbuf (pixbuf); - } catch (Error e) { - error (e.message); + icon_theme.rescan_if_needed (); + Timeout.add_seconds (1, update_status); + return false; } if (conic_connected && tor_enabled) { @@ -126,6 +126,8 @@ class TorStatusMenuItem : HD.StatusMenuItem { button.set_value (tor_enabled ? _("Disconnected") : _("Disabled")); } button.set_image (tor_enabled ? icon_enabled : icon_disabled); + + return false; } /** -- 1.7.9.5