demo: use the installed named icon

This commit is contained in:
William Jon McCann 2013-11-05 15:29:54 -05:00
parent fc71414ada
commit cdc2f07a1e
11 changed files with 12 additions and 44 deletions

View File

@ -134,9 +134,6 @@ RESOURCES= $(demos) \
gnome-gmush.png \ gnome-gmush.png \
gnome-gsame.png \ gnome-gsame.png \
gnu-keys.png \ gnu-keys.png \
gtk-logo-24.png \
gtk-logo-48.png \
gtk-logo-old.png \
messages.txt \ messages.txt \
css_accordion.css \ css_accordion.css \
css_basics.css \ css_basics.css \

View File

@ -95,7 +95,6 @@ activate_about (GSimpleAction *action,
gpointer user_data) gpointer user_data)
{ {
GtkWidget *window = user_data; GtkWidget *window = user_data;
GdkPixbuf *pixbuf;
const gchar *authors[] = { const gchar *authors[] = {
"Peter Mattis", "Peter Mattis",
@ -113,8 +112,6 @@ activate_about (GSimpleAction *action,
NULL NULL
}; };
pixbuf = gdk_pixbuf_new_from_resource ("/application/gtk-logo-48.png", NULL);
gtk_show_about_dialog (GTK_WINDOW (window), gtk_show_about_dialog (GTK_WINDOW (window),
"program-name", "GTK+ Code Demos", "program-name", "GTK+ Code Demos",
"version", g_strdup_printf ("%s,\nRunning against GTK+ %d.%d.%d", "version", g_strdup_printf ("%s,\nRunning against GTK+ %d.%d.%d",
@ -128,10 +125,9 @@ activate_about (GSimpleAction *action,
"comments", "Program to demonstrate GTK+ functions.", "comments", "Program to demonstrate GTK+ functions.",
"authors", authors, "authors", authors,
"documenters", documentors, "documenters", documentors,
"logo", pixbuf, "logo-icon-name", "gtk3-demo",
"title", "About GTK+ Code Demos", "title", "About GTK+ Code Demos",
NULL); NULL);
g_object_unref (pixbuf);
} }
static void static void

View File

@ -1,8 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<gresources> <gresources>
<gresource prefix="/application"> <gresource prefix="/application">
<file preprocess="to-pixdata">gtk-logo-24.png</file>
<file preprocess="to-pixdata">gtk-logo-48.png</file>
<file>application.ui</file> <file>application.ui</file>
<file>menus.ui</file> <file>menus.ui</file>
</gresource> </gresource>
@ -59,7 +57,6 @@
<gresource prefix="/images"> <gresource prefix="/images">
<file>alphatest.png</file> <file>alphatest.png</file>
<file>floppybuddy.gif</file> <file>floppybuddy.gif</file>
<file>gtk-logo-old.png</file>
</gresource> </gresource>
<gresource prefix="/pixbufs"> <gresource prefix="/pixbufs">
<file>apple-red.png</file> <file>apple-red.png</file>
@ -125,12 +122,10 @@
</gresource> </gresource>
<gresource prefix="/textview"> <gresource prefix="/textview">
<file>floppybuddy.gif</file> <file>floppybuddy.gif</file>
<file>gtk-logo-old.png</file>
</gresource> </gresource>
<gresource prefix="/listbox"> <gresource prefix="/listbox">
<file>listbox.ui</file> <file>listbox.ui</file>
<file>messages.txt</file> <file>messages.txt</file>
<file>gtk-logo-48.png</file>
<file>apple-red.png</file> <file>apple-red.png</file>
</gresource> </gresource>
</gresources> </gresources>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 674 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

View File

@ -329,7 +329,6 @@ do_images (GtkWidget *do_widget)
GtkWidget *image; GtkWidget *image;
GtkWidget *label; GtkWidget *label;
GtkWidget *button; GtkWidget *button;
GdkPixbuf *pixbuf;
GIcon *gicon; GIcon *gicon;
if (!window) if (!window)
@ -361,11 +360,7 @@ do_images (GtkWidget *do_widget)
gtk_widget_set_valign (frame, GTK_ALIGN_CENTER); gtk_widget_set_valign (frame, GTK_ALIGN_CENTER);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
pixbuf = gdk_pixbuf_new_from_resource ("/images/gtk-logo-old.png", NULL); image = gtk_image_new_from_icon_name ("gtk3-demo", GTK_ICON_SIZE_DIALOG);
/* The image loading must work, we ensure that the resources are valid. */
g_assert (pixbuf);
image = gtk_image_new_from_pixbuf (pixbuf);
gtk_container_add (GTK_CONTAINER (frame), image); gtk_container_add (GTK_CONTAINER (frame), image);

View File

@ -9,7 +9,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
static GdkPixbuf *avatar_pixbuf_gtk;
static GdkPixbuf *avatar_pixbuf_other; static GdkPixbuf *avatar_pixbuf_other;
static GtkWidget *window = NULL; static GtkWidget *window = NULL;
@ -183,7 +182,7 @@ gtk_message_row_update (GtkMessageRow *row)
gtk_button_set_label (GTK_BUTTON (priv->resent_by_button), priv->message->resent_by); gtk_button_set_label (GTK_BUTTON (priv->resent_by_button), priv->message->resent_by);
if (strcmp (priv->message->sender_nick, "@GTKtoolkit") == 0) if (strcmp (priv->message->sender_nick, "@GTKtoolkit") == 0)
gtk_image_set_from_pixbuf (priv->avatar_image, avatar_pixbuf_gtk); gtk_image_set_from_icon_name (priv->avatar_image, "gtk3-demo", GTK_ICON_SIZE_DND);
else else
gtk_image_set_from_pixbuf (priv->avatar_image, avatar_pixbuf_other); gtk_image_set_from_pixbuf (priv->avatar_image, avatar_pixbuf_other);
@ -317,7 +316,6 @@ do_listbox (GtkWidget *do_widget)
if (!window) if (!window)
{ {
avatar_pixbuf_gtk = gdk_pixbuf_new_from_resource_at_scale ("/listbox/gtk-logo-48.png", 32, 32, FALSE, NULL);
avatar_pixbuf_other = gdk_pixbuf_new_from_resource_at_scale ("/listbox/apple-red.png", 32, 32, FALSE, NULL); avatar_pixbuf_other = gdk_pixbuf_new_from_resource_at_scale ("/listbox/apple-red.png", 32, 32, FALSE, NULL);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL); window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

View File

@ -882,20 +882,6 @@ create_tree (void)
return box; return box;
} }
static void
setup_default_icon (void)
{
GdkPixbuf *pixbuf;
pixbuf = gdk_pixbuf_new_from_resource ("/application/gtk-logo-48.png", NULL);
/* We load a resource, so we can guarantee that loading it is successful */
g_assert (pixbuf);
gtk_window_set_default_icon (pixbuf);
g_object_unref (pixbuf);
}
int int
main (int argc, char **argv) main (int argc, char **argv)
{ {
@ -915,7 +901,7 @@ main (int argc, char **argv)
gtk_init (&argc, &argv); gtk_init (&argc, &argv);
setup_default_icon (); gtk_window_set_default_icon_name ("gtk3-demo");
window = gtk_window_new (GTK_WINDOW_TOPLEVEL); window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "GTK+ Code Demos"); gtk_window_set_title (GTK_WINDOW (window), "GTK+ Code Demos");

View File

@ -32,7 +32,7 @@
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="margin-top">20</property> <property name="margin-top">20</property>
<property name="margin-bottom">20</property> <property name="margin-bottom">20</property>
<property name="resource">/application/gtk-logo-48.png</property> <property name="icon-name">gtk3-demo</property>
</object> </object>
<packing> <packing>
<property name="name">page1</property> <property name="name">page1</property>

View File

@ -129,15 +129,16 @@ insert_text (GtkTextBuffer *buffer)
GtkTextIter iter; GtkTextIter iter;
GtkTextIter start, end; GtkTextIter start, end;
GdkPixbuf *pixbuf; GdkPixbuf *pixbuf;
GdkPixbuf *scaled; GtkIconTheme *icon_theme;
pixbuf = gdk_pixbuf_new_from_resource ("/textview/gtk-logo-old.png", NULL); icon_theme = gtk_icon_theme_get_default ();
pixbuf = gtk_icon_theme_load_icon (icon_theme,
"gtk3-demo",
32,
GTK_ICON_LOOKUP_GENERIC_FALLBACK,
NULL);
g_assert (pixbuf); g_assert (pixbuf);
scaled = gdk_pixbuf_scale_simple (pixbuf, 32, 32, GDK_INTERP_BILINEAR);
g_object_unref (pixbuf);
pixbuf = scaled;
/* get start of buffer; each insertion will revalidate the /* get start of buffer; each insertion will revalidate the
* iterator to point to just after the inserted text. * iterator to point to just after the inserted text.
*/ */