Don't abort when icons are missing
authorPhilipp Zabel <philipp.zabel@gmail.com>
Tue, 29 Jun 2010 17:46:19 +0000 (19:46 +0200)
committerPhilipp Zabel <philipp.zabel@gmail.com>
Tue, 29 Jun 2010 17:46:19 +0000 (19:46 +0200)
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
src/status-area-applet-tor.vala

index 3e78d9a..a417e12 100644 (file)
@@ -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
index 083d465..d384053 100644 (file)
@@ -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;
        }
 
        /**