]> Pileus Git - ~andy/gtk/blobdiff - tests/testicontheme.c
gdk/win32/gdkevents-win32.c: Fix build
[~andy/gtk] / tests / testicontheme.c
index 92a68aab32cdf95d53d9ebdab2735141dac5e2b7..d294a47b343b3b100baac8213e2910d72d44c60c 100644 (file)
@@ -13,9 +13,7 @@
  * Library General Public License for more details.
  *
  * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  */
 
 #include <gtk/gtk.h>
@@ -36,6 +34,28 @@ usage (void)
           );
 }
 
+static void
+icon_loaded_cb (GObject *source_object,
+               GAsyncResult *res,
+               gpointer user_data)
+{
+  GdkPixbuf *pixbuf;
+  GError *error;
+
+  error = NULL;
+  pixbuf = gtk_icon_info_load_icon_finish (GTK_ICON_INFO (source_object),
+                                          res, &error);
+
+  if (pixbuf == NULL)
+    {
+      g_print ("%s\n", error->message);
+      exit (1);
+    }
+
+  gtk_image_set_from_pixbuf (GTK_IMAGE (user_data), pixbuf);
+  g_object_unref (pixbuf);
+}
+
 
 int
 main (int argc, char *argv[])
@@ -103,6 +123,45 @@ main (int argc, char *argv[])
                         G_CALLBACK (gtk_main_quit), window);
       gtk_widget_show_all (window);
       
+      gtk_main ();
+    }
+  else if (strcmp (argv[1], "display-async") == 0)
+    {
+      GtkWidget *window, *image;
+      GtkIconSize size;
+      GtkIconInfo *info;
+
+      if (argc < 4)
+       {
+         g_object_unref (icon_theme);
+         usage ();
+         return 1;
+       }
+
+      if (argc >= 5)
+       size = atoi (argv[4]);
+      else
+       size = GTK_ICON_SIZE_BUTTON;
+
+      window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+      image = gtk_image_new ();
+      gtk_container_add (GTK_CONTAINER (window), image);
+      g_signal_connect (window, "delete-event",
+                        G_CALLBACK (gtk_main_quit), window);
+      gtk_widget_show_all (window);
+
+      info = gtk_icon_theme_lookup_icon (icon_theme, argv[3], size,
+                                         GTK_ICON_LOOKUP_USE_BUILTIN);
+
+      if (info == NULL)
+       {
+          g_print ("Icon not found\n");
+          return 1;
+       }
+
+      gtk_icon_info_load_icon_async (info,
+                                    NULL, icon_loaded_cb, image);
+
       gtk_main ();
     }
   else if (strcmp (argv[1], "list") == 0)
@@ -172,7 +231,7 @@ main (int argc, char *argv[])
          if (display_name)
            g_print ("Display name: %s\n", display_name);
          
-         gtk_icon_info_free (icon_info);
+         g_object_unref (icon_info);
        }
     }
   else