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-gsame.png \
gnu-keys.png \
gtk-logo-24.png \
gtk-logo-48.png \
gtk-logo-old.png \
messages.txt \
css_accordion.css \
css_basics.css \

View File

@ -95,7 +95,6 @@ activate_about (GSimpleAction *action,
gpointer user_data)
{
GtkWidget *window = user_data;
GdkPixbuf *pixbuf;
const gchar *authors[] = {
"Peter Mattis",
@ -113,8 +112,6 @@ activate_about (GSimpleAction *action,
NULL
};
pixbuf = gdk_pixbuf_new_from_resource ("/application/gtk-logo-48.png", NULL);
gtk_show_about_dialog (GTK_WINDOW (window),
"program-name", "GTK+ Code Demos",
"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.",
"authors", authors,
"documenters", documentors,
"logo", pixbuf,
"logo-icon-name", "gtk3-demo",
"title", "About GTK+ Code Demos",
NULL);
g_object_unref (pixbuf);
}
static void

View File

@ -1,8 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<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>menus.ui</file>
</gresource>
@ -59,7 +57,6 @@
<gresource prefix="/images">
<file>alphatest.png</file>
<file>floppybuddy.gif</file>
<file>gtk-logo-old.png</file>
</gresource>
<gresource prefix="/pixbufs">
<file>apple-red.png</file>
@ -125,12 +122,10 @@
</gresource>
<gresource prefix="/textview">
<file>floppybuddy.gif</file>
<file>gtk-logo-old.png</file>
</gresource>
<gresource prefix="/listbox">
<file>listbox.ui</file>
<file>messages.txt</file>
<file>gtk-logo-48.png</file>
<file>apple-red.png</file>
</gresource>
</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 *label;
GtkWidget *button;
GdkPixbuf *pixbuf;
GIcon *gicon;
if (!window)
@ -361,11 +360,7 @@ do_images (GtkWidget *do_widget)
gtk_widget_set_valign (frame, GTK_ALIGN_CENTER);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
pixbuf = gdk_pixbuf_new_from_resource ("/images/gtk-logo-old.png", NULL);
/* The image loading must work, we ensure that the resources are valid. */
g_assert (pixbuf);
image = gtk_image_new_from_pixbuf (pixbuf);
image = gtk_image_new_from_icon_name ("gtk3-demo", GTK_ICON_SIZE_DIALOG);
gtk_container_add (GTK_CONTAINER (frame), image);

View File

@ -9,7 +9,6 @@
#include <stdlib.h>
#include <string.h>
static GdkPixbuf *avatar_pixbuf_gtk;
static GdkPixbuf *avatar_pixbuf_other;
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);
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
gtk_image_set_from_pixbuf (priv->avatar_image, avatar_pixbuf_other);
@ -317,7 +316,6 @@ do_listbox (GtkWidget *do_widget)
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);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

View File

@ -882,20 +882,6 @@ create_tree (void)
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
main (int argc, char **argv)
{
@ -915,7 +901,7 @@ main (int argc, char **argv)
gtk_init (&argc, &argv);
setup_default_icon ();
gtk_window_set_default_icon_name ("gtk3-demo");
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "GTK+ Code Demos");

View File

@ -32,7 +32,7 @@
<property name="can_focus">False</property>
<property name="margin-top">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>
<packing>
<property name="name">page1</property>

View File

@ -129,15 +129,16 @@ insert_text (GtkTextBuffer *buffer)
GtkTextIter iter;
GtkTextIter start, end;
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);
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
* iterator to point to just after the inserted text.
*/