summaryrefslogtreecommitdiff
path: root/demos
diff options
context:
space:
mode:
authorHavoc Pennington <hp@pobox.com>2001-08-29 02:20:02 +0000
committerHavoc Pennington <hp@src.gnome.org>2001-08-29 02:20:02 +0000
commit9df007468539fa9fe85612eedf0af44dd64f3c98 (patch)
tree7a3dda0769668d56159dc7e7090eac95a2843985 /demos
parent3921a791182eafccc8da74f63a69fddaed553227 (diff)
downloadgtk+-9df007468539fa9fe85612eedf0af44dd64f3c98.tar.gz
add default icon
2001-08-28 Havoc Pennington <hp@pobox.com> * demos/gtk-demo/main.c (setup_default_icon): add default icon * gtk/gtkradiobutton.c (gtk_radio_button_new_with_mnemonic): warning fix (gtk_radio_button_new_with_label): warning fix * gtk/gtkdnd.c: used some random GtkImage private structs, update to reflect GtkImage changes * gdk/x11/gdkwindow-x11.c (gdk_window_set_icon_list): don't check whether the hint is supported, just always set the icon. A task list might want to use it even if the WM doesn't, and the WM may change over time. Also, XDeleteProperty() if list == NULL. * gtk/gtkwindow.c (gtk_window_set_icon_list) (gtk_window_get_icon_list) (gtk_window_set_icon) (gtk_window_get_icon) (gtk_window_set_default_icon_list) (gtk_window_get_default_icon_list): new functions * gtk/gtk-boxed.defs (GtkIconSet): add GtkIconSet * gtk/gtkimage.c: Implement property support, bug #59408 * gtk/gtkcontainer.c (gtk_container_add): make the warning message on reparent-without-removing-first a bit more helpful. Let's just destroy this FAQ.
Diffstat (limited to 'demos')
-rw-r--r--demos/gtk-demo/main.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/demos/gtk-demo/main.c b/demos/gtk-demo/main.c
index bea2c29a76..954795e239 100644
--- a/demos/gtk-demo/main.c
+++ b/demos/gtk-demo/main.c
@@ -722,6 +722,58 @@ create_tree (void)
return tree_view;
}
+static void
+setup_default_icon (void)
+{
+ GdkPixbuf *pixbuf;
+
+ /* Try in current directory, in case we haven't yet been installed
+ * (would be wrong in a real app)
+ */
+ pixbuf = gdk_pixbuf_new_from_file ("./gtk-logo-rgb.gif", NULL);
+
+ if (pixbuf == NULL)
+ {
+ GError *err;
+
+ err = NULL;
+ pixbuf = gdk_pixbuf_new_from_file (DEMOCODEDIR"/gtk-logo-rgb.gif",
+ &err);
+
+ /* Ignoring this error (passing NULL instead of &err above)
+ * would probably be reasonable for most apps. We're just
+ * showing off.
+ */
+ if (err)
+ {
+ GtkWidget *dialog;
+
+ dialog = gtk_message_dialog_new (NULL, 0,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE,
+ "Failed to read icon file "DEMOCODEDIR"/gtk-logo-rgb.gif: %s",
+ err->message);
+ g_error_free (err);
+
+ gtk_signal_connect (GTK_OBJECT (dialog),
+ "response",
+ GTK_SIGNAL_FUNC (gtk_widget_destroy),
+ NULL);
+ }
+ }
+
+ if (pixbuf)
+ {
+ GList *list;
+
+ list = NULL;
+ list = g_list_append (list, pixbuf);
+ gtk_window_set_default_icon_list (list);
+ g_list_free (list);
+ g_object_unref (G_OBJECT (pixbuf));
+ }
+}
+
int
main (int argc, char **argv)
{
@@ -744,6 +796,8 @@ main (int argc, char **argv)
/* -- End of hack -- */
gtk_init (&argc, &argv);
+
+ setup_default_icon ();
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "GTK+ Code Demos");