gtk-demo: Port appwindow example to resources
This commit is contained in:
@ -117,6 +117,7 @@ RESOURCES= application.ui \
|
|||||||
theming.ui \
|
theming.ui \
|
||||||
gtk-logo-24.png \
|
gtk-logo-24.png \
|
||||||
gtk-logo-48.png \
|
gtk-logo-48.png \
|
||||||
|
gtk-logo-rgb.gif \
|
||||||
css_accordion.css \
|
css_accordion.css \
|
||||||
css_basics.css \
|
css_basics.css \
|
||||||
css_multiplebgs.css \
|
css_multiplebgs.css \
|
||||||
|
|||||||
@ -82,7 +82,6 @@ about_cb (GtkAction *action,
|
|||||||
GtkWidget *window)
|
GtkWidget *window)
|
||||||
{
|
{
|
||||||
GdkPixbuf *pixbuf, *transparent;
|
GdkPixbuf *pixbuf, *transparent;
|
||||||
gchar *filename;
|
|
||||||
|
|
||||||
const gchar *authors[] = {
|
const gchar *authors[] = {
|
||||||
"Peter Mattis",
|
"Peter Mattis",
|
||||||
@ -100,16 +99,11 @@ about_cb (GtkAction *action,
|
|||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
pixbuf = NULL;
|
pixbuf = gdk_pixbuf_new_from_resource ("/appwindow/gtk-logo-rgb.gif", NULL);
|
||||||
transparent = NULL;
|
/* We asser the existence of the pixbuf as we load it from a custom resource. */
|
||||||
filename = demo_find_file ("gtk-logo-rgb.gif", NULL);
|
g_assert (pixbuf);
|
||||||
if (filename)
|
|
||||||
{
|
|
||||||
pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
|
|
||||||
g_free (filename);
|
|
||||||
transparent = gdk_pixbuf_add_alpha (pixbuf, TRUE, 0xff, 0xff, 0xff);
|
transparent = gdk_pixbuf_add_alpha (pixbuf, TRUE, 0xff, 0xff, 0xff);
|
||||||
g_object_unref (pixbuf);
|
g_object_unref (pixbuf);
|
||||||
}
|
|
||||||
|
|
||||||
gtk_show_about_dialog (GTK_WINDOW (window),
|
gtk_show_about_dialog (GTK_WINDOW (window),
|
||||||
"program-name", "GTK+ Code Demos",
|
"program-name", "GTK+ Code Demos",
|
||||||
@ -309,7 +303,8 @@ register_stock_icons (void)
|
|||||||
{
|
{
|
||||||
GdkPixbuf *pixbuf;
|
GdkPixbuf *pixbuf;
|
||||||
GtkIconFactory *factory;
|
GtkIconFactory *factory;
|
||||||
char *filename;
|
GtkIconSet *icon_set;
|
||||||
|
GdkPixbuf *transparent;
|
||||||
|
|
||||||
static GtkStockItem items[] = {
|
static GtkStockItem items[] = {
|
||||||
{ "demo-gtk-logo",
|
{ "demo-gtk-logo",
|
||||||
@ -326,23 +321,9 @@ register_stock_icons (void)
|
|||||||
factory = gtk_icon_factory_new ();
|
factory = gtk_icon_factory_new ();
|
||||||
gtk_icon_factory_add_default (factory);
|
gtk_icon_factory_add_default (factory);
|
||||||
|
|
||||||
/* demo_find_file() looks in the current directory first,
|
pixbuf = gdk_pixbuf_new_from_resource ("/appwindow/gtk-logo-rgb.gif", NULL);
|
||||||
* so you can run gtk-demo without installing GTK, then looks
|
/* We assert the existence of the pixbuf as we load it from a custom resource. */
|
||||||
* in the location where the file is installed.
|
g_assert (pixbuf);
|
||||||
*/
|
|
||||||
pixbuf = NULL;
|
|
||||||
filename = demo_find_file ("gtk-logo-rgb.gif", NULL);
|
|
||||||
if (filename)
|
|
||||||
{
|
|
||||||
pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
|
|
||||||
g_free (filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Register icon to accompany stock item */
|
|
||||||
if (pixbuf != NULL)
|
|
||||||
{
|
|
||||||
GtkIconSet *icon_set;
|
|
||||||
GdkPixbuf *transparent;
|
|
||||||
|
|
||||||
/* The gtk-logo-rgb icon has a white background, make it transparent */
|
/* The gtk-logo-rgb icon has a white background, make it transparent */
|
||||||
transparent = gdk_pixbuf_add_alpha (pixbuf, TRUE, 0xff, 0xff, 0xff);
|
transparent = gdk_pixbuf_add_alpha (pixbuf, TRUE, 0xff, 0xff, 0xff);
|
||||||
@ -352,9 +333,6 @@ register_stock_icons (void)
|
|||||||
gtk_icon_set_unref (icon_set);
|
gtk_icon_set_unref (icon_set);
|
||||||
g_object_unref (pixbuf);
|
g_object_unref (pixbuf);
|
||||||
g_object_unref (transparent);
|
g_object_unref (transparent);
|
||||||
}
|
|
||||||
else
|
|
||||||
g_warning ("failed to load GTK logo for toolbar");
|
|
||||||
|
|
||||||
/* Drop our reference to the factory, GTK will hold a reference. */
|
/* Drop our reference to the factory, GTK will hold a reference. */
|
||||||
g_object_unref (factory);
|
g_object_unref (factory);
|
||||||
|
|||||||
@ -8,6 +8,9 @@
|
|||||||
<file preprocess="xml-stripblanks">application.ui</file>
|
<file preprocess="xml-stripblanks">application.ui</file>
|
||||||
<file preprocess="xml-stripblanks">menus.ui</file>
|
<file preprocess="xml-stripblanks">menus.ui</file>
|
||||||
</gresource>
|
</gresource>
|
||||||
|
<gresource prefix="/appwindow">
|
||||||
|
<file preprocess="to-pixdata">gtk-logo-rgb.gif</file>
|
||||||
|
</gresource>
|
||||||
<gresource prefix="/">
|
<gresource prefix="/">
|
||||||
<file>cssview.css</file>
|
<file>cssview.css</file>
|
||||||
<file>reset.css</file>
|
<file>reset.css</file>
|
||||||
|
|||||||
Reference in New Issue
Block a user