2001-04-18 18:09:18 +00:00
|
|
|
/* Images
|
|
|
|
*
|
|
|
|
* GtkImage is used to display an image; the image can be in a number of formats.
|
|
|
|
* Typically, you load an image into a GdkPixbuf, then display the pixbuf.
|
|
|
|
*
|
|
|
|
* This demo code shows some of the more obscure cases, in the simple
|
|
|
|
* case a call to gtk_image_new_from_file() is all you need.
|
|
|
|
*
|
|
|
|
* If you want to put image data in your program as a C variable,
|
|
|
|
* use the make-inline-pixbuf program that comes with GTK+.
|
2001-05-07 15:58:47 +00:00
|
|
|
* This way you won't need to depend on loading external files, your
|
|
|
|
* application binary can be self-contained.
|
2001-04-18 18:09:18 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
2004-12-05 12:47:42 +00:00
|
|
|
#include <glib/gstdio.h>
|
2001-04-18 18:09:18 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <errno.h>
|
2001-11-23 21:46:44 +00:00
|
|
|
#include "demo-common.h"
|
2001-04-18 18:09:18 +00:00
|
|
|
|
|
|
|
static GtkWidget *window = NULL;
|
|
|
|
static GdkPixbufLoader *pixbuf_loader = NULL;
|
|
|
|
static guint load_timeout = 0;
|
|
|
|
static FILE* image_stream = NULL;
|
|
|
|
|
|
|
|
static void
|
2001-05-18 16:28:30 +00:00
|
|
|
progressive_prepared_callback (GdkPixbufLoader *loader,
|
|
|
|
gpointer data)
|
2001-04-18 18:09:18 +00:00
|
|
|
{
|
2001-05-18 16:28:30 +00:00
|
|
|
GdkPixbuf *pixbuf;
|
|
|
|
GtkWidget *image;
|
2001-04-18 18:09:18 +00:00
|
|
|
|
|
|
|
image = GTK_WIDGET (data);
|
2008-08-11 19:12:58 +00:00
|
|
|
|
2001-04-18 18:09:18 +00:00
|
|
|
pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
|
|
|
|
|
|
|
|
/* Avoid displaying random memory contents, since the pixbuf
|
|
|
|
* isn't filled in yet.
|
|
|
|
*/
|
|
|
|
gdk_pixbuf_fill (pixbuf, 0xaaaaaaff);
|
2008-08-11 19:12:58 +00:00
|
|
|
|
2001-04-18 18:09:18 +00:00
|
|
|
gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf);
|
|
|
|
}
|
|
|
|
|
2002-01-29 23:59:21 +00:00
|
|
|
static void
|
|
|
|
progressive_updated_callback (GdkPixbufLoader *loader,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint width,
|
|
|
|
gint height,
|
|
|
|
gpointer data)
|
2001-04-18 18:09:18 +00:00
|
|
|
{
|
2001-05-18 16:28:30 +00:00
|
|
|
GtkWidget *image;
|
2008-08-11 19:12:58 +00:00
|
|
|
|
2001-04-18 18:09:18 +00:00
|
|
|
image = GTK_WIDGET (data);
|
|
|
|
|
2001-05-07 15:58:47 +00:00
|
|
|
/* We know the pixbuf inside the GtkImage has changed, but the image
|
2001-04-18 18:09:18 +00:00
|
|
|
* itself doesn't know this; so queue a redraw. If we wanted to be
|
|
|
|
* really efficient, we could use a drawing area or something
|
|
|
|
* instead of a GtkImage, so we could control the exact position of
|
|
|
|
* the pixbuf on the display, then we could queue a draw for only
|
|
|
|
* the updated area of the image.
|
|
|
|
*/
|
2008-08-11 19:12:58 +00:00
|
|
|
|
2001-04-18 18:09:18 +00:00
|
|
|
gtk_widget_queue_draw (image);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
progressive_timeout (gpointer data)
|
|
|
|
{
|
|
|
|
GtkWidget *image;
|
|
|
|
|
|
|
|
image = GTK_WIDGET (data);
|
2008-08-11 19:12:58 +00:00
|
|
|
|
2001-04-18 18:09:18 +00:00
|
|
|
/* This shows off fully-paranoid error handling, so looks scary.
|
|
|
|
* You could factor out the error handling code into a nice separate
|
|
|
|
* function to make things nicer.
|
|
|
|
*/
|
2008-08-11 19:12:58 +00:00
|
|
|
|
2001-04-18 18:09:18 +00:00
|
|
|
if (image_stream)
|
|
|
|
{
|
|
|
|
size_t bytes_read;
|
|
|
|
guchar buf[256];
|
|
|
|
GError *error = NULL;
|
2008-08-11 19:12:58 +00:00
|
|
|
|
2001-04-18 18:09:18 +00:00
|
|
|
bytes_read = fread (buf, 1, 256, image_stream);
|
|
|
|
|
|
|
|
if (ferror (image_stream))
|
2001-05-18 16:28:30 +00:00
|
|
|
{
|
|
|
|
GtkWidget *dialog;
|
2008-08-11 19:12:58 +00:00
|
|
|
|
2001-05-18 16:28:30 +00:00
|
|
|
dialog = gtk_message_dialog_new (GTK_WINDOW (window),
|
|
|
|
GTK_DIALOG_DESTROY_WITH_PARENT,
|
|
|
|
GTK_MESSAGE_ERROR,
|
|
|
|
GTK_BUTTONS_CLOSE,
|
|
|
|
"Failure reading image file 'alphatest.png': %s",
|
|
|
|
g_strerror (errno));
|
|
|
|
|
2001-10-20 23:39:32 +00:00
|
|
|
g_signal_connect (dialog, "response",
|
|
|
|
G_CALLBACK (gtk_widget_destroy), NULL);
|
2001-05-18 16:28:30 +00:00
|
|
|
|
|
|
|
fclose (image_stream);
|
|
|
|
image_stream = NULL;
|
|
|
|
|
|
|
|
gtk_widget_show (dialog);
|
2008-08-11 19:12:58 +00:00
|
|
|
|
2001-05-18 16:28:30 +00:00
|
|
|
load_timeout = 0;
|
|
|
|
|
|
|
|
return FALSE; /* uninstall the timeout */
|
|
|
|
}
|
2001-04-18 18:09:18 +00:00
|
|
|
|
|
|
|
if (!gdk_pixbuf_loader_write (pixbuf_loader,
|
2001-05-18 16:28:30 +00:00
|
|
|
buf, bytes_read,
|
|
|
|
&error))
|
|
|
|
{
|
|
|
|
GtkWidget *dialog;
|
2008-08-11 19:12:58 +00:00
|
|
|
|
2001-05-18 16:28:30 +00:00
|
|
|
dialog = gtk_message_dialog_new (GTK_WINDOW (window),
|
|
|
|
GTK_DIALOG_DESTROY_WITH_PARENT,
|
|
|
|
GTK_MESSAGE_ERROR,
|
|
|
|
GTK_BUTTONS_CLOSE,
|
|
|
|
"Failed to load image: %s",
|
|
|
|
error->message);
|
|
|
|
|
|
|
|
g_error_free (error);
|
2008-08-11 19:12:58 +00:00
|
|
|
|
2001-10-20 23:39:32 +00:00
|
|
|
g_signal_connect (dialog, "response",
|
|
|
|
G_CALLBACK (gtk_widget_destroy), NULL);
|
2001-05-18 16:28:30 +00:00
|
|
|
|
|
|
|
fclose (image_stream);
|
|
|
|
image_stream = NULL;
|
2008-08-11 19:12:58 +00:00
|
|
|
|
2001-05-18 16:28:30 +00:00
|
|
|
gtk_widget_show (dialog);
|
|
|
|
|
|
|
|
load_timeout = 0;
|
|
|
|
|
|
|
|
return FALSE; /* uninstall the timeout */
|
|
|
|
}
|
2001-04-18 18:09:18 +00:00
|
|
|
|
|
|
|
if (feof (image_stream))
|
2001-05-18 16:28:30 +00:00
|
|
|
{
|
|
|
|
fclose (image_stream);
|
|
|
|
image_stream = NULL;
|
|
|
|
|
|
|
|
/* Errors can happen on close, e.g. if the image
|
|
|
|
* file was truncated we'll know on close that
|
|
|
|
* it was incomplete.
|
|
|
|
*/
|
|
|
|
error = NULL;
|
|
|
|
if (!gdk_pixbuf_loader_close (pixbuf_loader,
|
|
|
|
&error))
|
|
|
|
{
|
|
|
|
GtkWidget *dialog;
|
2008-08-11 19:12:58 +00:00
|
|
|
|
2001-05-18 16:28:30 +00:00
|
|
|
dialog = gtk_message_dialog_new (GTK_WINDOW (window),
|
|
|
|
GTK_DIALOG_DESTROY_WITH_PARENT,
|
|
|
|
GTK_MESSAGE_ERROR,
|
|
|
|
GTK_BUTTONS_CLOSE,
|
|
|
|
"Failed to load image: %s",
|
|
|
|
error->message);
|
2008-08-11 19:12:58 +00:00
|
|
|
|
2001-05-18 16:28:30 +00:00
|
|
|
g_error_free (error);
|
2008-08-11 19:12:58 +00:00
|
|
|
|
2001-10-20 23:39:32 +00:00
|
|
|
g_signal_connect (dialog, "response",
|
|
|
|
G_CALLBACK (gtk_widget_destroy), NULL);
|
2008-08-11 19:12:58 +00:00
|
|
|
|
2001-05-18 16:28:30 +00:00
|
|
|
gtk_widget_show (dialog);
|
|
|
|
|
2002-09-29 21:24:24 +00:00
|
|
|
g_object_unref (pixbuf_loader);
|
2001-05-18 16:28:30 +00:00
|
|
|
pixbuf_loader = NULL;
|
2008-08-11 19:12:58 +00:00
|
|
|
|
2001-05-18 16:28:30 +00:00
|
|
|
load_timeout = 0;
|
2008-08-11 19:12:58 +00:00
|
|
|
|
2001-05-18 16:28:30 +00:00
|
|
|
return FALSE; /* uninstall the timeout */
|
|
|
|
}
|
2008-08-11 19:12:58 +00:00
|
|
|
|
2002-09-29 21:24:24 +00:00
|
|
|
g_object_unref (pixbuf_loader);
|
2001-05-18 16:28:30 +00:00
|
|
|
pixbuf_loader = NULL;
|
|
|
|
}
|
2001-04-18 18:09:18 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-11-23 21:46:44 +00:00
|
|
|
gchar *filename;
|
|
|
|
gchar *error_message = NULL;
|
2008-08-11 19:12:58 +00:00
|
|
|
GError *error = NULL;
|
2001-04-18 18:09:18 +00:00
|
|
|
|
2006-09-25 14:48:31 +00:00
|
|
|
/* demo_find_file() looks in the current directory first,
|
2001-11-23 21:46:44 +00:00
|
|
|
* so you can run gtk-demo without installing GTK, then looks
|
|
|
|
* in the location where the file is installed.
|
|
|
|
*/
|
|
|
|
filename = demo_find_file ("alphatest.png", &error);
|
|
|
|
if (error)
|
|
|
|
{
|
|
|
|
error_message = g_strdup (error->message);
|
|
|
|
g_error_free (error);
|
|
|
|
}
|
2001-04-18 18:09:18 +00:00
|
|
|
else
|
2001-11-23 21:46:44 +00:00
|
|
|
{
|
2004-12-05 12:47:42 +00:00
|
|
|
image_stream = g_fopen (filename, "rb");
|
2001-11-23 21:46:44 +00:00
|
|
|
g_free (filename);
|
|
|
|
|
|
|
|
if (!image_stream)
|
|
|
|
error_message = g_strdup_printf ("Unable to open image file 'alphatest.png': %s",
|
|
|
|
g_strerror (errno));
|
|
|
|
}
|
2001-04-18 18:09:18 +00:00
|
|
|
|
|
|
|
if (image_stream == NULL)
|
2001-05-18 16:28:30 +00:00
|
|
|
{
|
|
|
|
GtkWidget *dialog;
|
2008-08-11 19:12:58 +00:00
|
|
|
|
2001-05-18 16:28:30 +00:00
|
|
|
dialog = gtk_message_dialog_new (GTK_WINDOW (window),
|
|
|
|
GTK_DIALOG_DESTROY_WITH_PARENT,
|
|
|
|
GTK_MESSAGE_ERROR,
|
|
|
|
GTK_BUTTONS_CLOSE,
|
2001-11-23 21:46:44 +00:00
|
|
|
"%s", error_message);
|
|
|
|
g_free (error_message);
|
2001-05-18 16:28:30 +00:00
|
|
|
|
2001-10-20 23:39:32 +00:00
|
|
|
g_signal_connect (dialog, "response",
|
|
|
|
G_CALLBACK (gtk_widget_destroy), NULL);
|
2008-08-11 19:12:58 +00:00
|
|
|
|
2001-05-18 16:28:30 +00:00
|
|
|
gtk_widget_show (dialog);
|
|
|
|
|
|
|
|
load_timeout = 0;
|
|
|
|
|
|
|
|
return FALSE; /* uninstall the timeout */
|
|
|
|
}
|
2001-04-18 18:09:18 +00:00
|
|
|
|
|
|
|
if (pixbuf_loader)
|
2001-05-18 16:28:30 +00:00
|
|
|
{
|
|
|
|
gdk_pixbuf_loader_close (pixbuf_loader, NULL);
|
2002-09-29 21:24:24 +00:00
|
|
|
g_object_unref (pixbuf_loader);
|
2001-05-18 16:28:30 +00:00
|
|
|
pixbuf_loader = NULL;
|
|
|
|
}
|
2008-08-11 19:12:58 +00:00
|
|
|
|
2001-04-18 18:09:18 +00:00
|
|
|
pixbuf_loader = gdk_pixbuf_loader_new ();
|
2008-08-11 19:12:58 +00:00
|
|
|
|
|
|
|
g_signal_connect (pixbuf_loader, "area-prepared",
|
2001-10-20 23:39:32 +00:00
|
|
|
G_CALLBACK (progressive_prepared_callback), image);
|
2008-08-11 19:12:58 +00:00
|
|
|
|
|
|
|
g_signal_connect (pixbuf_loader, "area-updated",
|
2001-10-20 23:39:32 +00:00
|
|
|
G_CALLBACK (progressive_updated_callback), image);
|
2001-04-18 18:09:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* leave timeout installed */
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
start_progressive_loading (GtkWidget *image)
|
|
|
|
{
|
|
|
|
/* This is obviously totally contrived (we slow down loading
|
|
|
|
* on purpose to show how incremental loading works).
|
|
|
|
* The real purpose of incremental loading is the case where
|
|
|
|
* you are reading data from a slow source such as the network.
|
|
|
|
* The timeout simply simulates a slow data source by inserting
|
|
|
|
* pauses in the reading process.
|
|
|
|
*/
|
2006-12-22 19:10:43 +00:00
|
|
|
load_timeout = gdk_threads_add_timeout (150,
|
2001-05-18 16:28:30 +00:00
|
|
|
progressive_timeout,
|
|
|
|
image);
|
2001-04-18 18:09:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-09-27 06:10:50 +00:00
|
|
|
cleanup_callback (GObject *object,
|
2001-05-18 16:28:30 +00:00
|
|
|
gpointer data)
|
2001-04-18 18:09:18 +00:00
|
|
|
{
|
|
|
|
if (load_timeout)
|
|
|
|
{
|
|
|
|
g_source_remove (load_timeout);
|
|
|
|
load_timeout = 0;
|
|
|
|
}
|
2008-08-11 19:12:58 +00:00
|
|
|
|
2001-04-18 18:09:18 +00:00
|
|
|
if (pixbuf_loader)
|
|
|
|
{
|
|
|
|
gdk_pixbuf_loader_close (pixbuf_loader, NULL);
|
2002-09-29 21:24:24 +00:00
|
|
|
g_object_unref (pixbuf_loader);
|
2001-04-18 18:09:18 +00:00
|
|
|
pixbuf_loader = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (image_stream)
|
|
|
|
fclose (image_stream);
|
|
|
|
image_stream = NULL;
|
|
|
|
}
|
|
|
|
|
2002-01-29 23:59:21 +00:00
|
|
|
static void
|
|
|
|
toggle_sensitivity_callback (GtkWidget *togglebutton,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
GtkContainer *container = user_data;
|
|
|
|
GList *list;
|
|
|
|
GList *tmp;
|
2008-08-11 19:12:58 +00:00
|
|
|
|
2002-01-29 23:59:21 +00:00
|
|
|
list = gtk_container_get_children (container);
|
|
|
|
|
|
|
|
tmp = list;
|
|
|
|
while (tmp != NULL)
|
|
|
|
{
|
|
|
|
/* don't disable our toggle */
|
|
|
|
if (GTK_WIDGET (tmp->data) != togglebutton)
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (tmp->data),
|
|
|
|
!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (togglebutton)));
|
2008-08-11 19:12:58 +00:00
|
|
|
|
2002-01-29 23:59:21 +00:00
|
|
|
tmp = tmp->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_list_free (list);
|
|
|
|
}
|
2008-08-11 19:12:58 +00:00
|
|
|
|
2002-01-29 23:59:21 +00:00
|
|
|
|
2001-04-18 18:09:18 +00:00
|
|
|
GtkWidget *
|
2003-11-08 22:08:05 +00:00
|
|
|
do_images (GtkWidget *do_widget)
|
2001-04-18 18:09:18 +00:00
|
|
|
{
|
|
|
|
GtkWidget *frame;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *image;
|
|
|
|
GtkWidget *label;
|
|
|
|
GtkWidget *align;
|
2002-01-29 23:59:21 +00:00
|
|
|
GtkWidget *button;
|
2001-11-23 21:46:44 +00:00
|
|
|
GdkPixbuf *pixbuf;
|
2010-04-26 10:55:34 +00:00
|
|
|
GIcon *gicon;
|
2001-11-23 21:46:44 +00:00
|
|
|
GError *error = NULL;
|
|
|
|
char *filename;
|
2008-08-11 19:12:58 +00:00
|
|
|
|
2001-04-18 18:09:18 +00:00
|
|
|
if (!window)
|
|
|
|
{
|
|
|
|
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
2003-11-08 22:08:05 +00:00
|
|
|
gtk_window_set_screen (GTK_WINDOW (window),
|
|
|
|
gtk_widget_get_screen (do_widget));
|
2001-04-18 18:09:18 +00:00
|
|
|
gtk_window_set_title (GTK_WINDOW (window), "Images");
|
|
|
|
|
2001-10-20 23:39:32 +00:00
|
|
|
g_signal_connect (window, "destroy",
|
|
|
|
G_CALLBACK (gtk_widget_destroyed), &window);
|
|
|
|
g_signal_connect (window, "destroy",
|
|
|
|
G_CALLBACK (cleanup_callback), NULL);
|
2001-04-18 18:09:18 +00:00
|
|
|
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (window), 8);
|
|
|
|
|
2010-10-30 03:00:32 +00:00
|
|
|
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE, 8);
|
2001-04-18 18:09:18 +00:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 8);
|
|
|
|
gtk_container_add (GTK_CONTAINER (window), vbox);
|
|
|
|
|
|
|
|
label = gtk_label_new (NULL);
|
|
|
|
gtk_label_set_markup (GTK_LABEL (label),
|
2001-05-18 16:28:30 +00:00
|
|
|
"<u>Image loaded from a file</u>");
|
2001-04-18 18:09:18 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
|
2008-08-11 19:12:58 +00:00
|
|
|
|
2001-04-18 18:09:18 +00:00
|
|
|
frame = gtk_frame_new (NULL);
|
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
|
|
|
/* The alignment keeps the frame from growing when users resize
|
|
|
|
* the window
|
|
|
|
*/
|
|
|
|
align = gtk_alignment_new (0.5, 0.5, 0, 0);
|
|
|
|
gtk_container_add (GTK_CONTAINER (align), frame);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), align, FALSE, FALSE, 0);
|
|
|
|
|
2006-09-25 14:48:31 +00:00
|
|
|
/* demo_find_file() looks in the current directory first,
|
2001-11-23 21:46:44 +00:00
|
|
|
* so you can run gtk-demo without installing GTK, then looks
|
|
|
|
* in the location where the file is installed.
|
2001-04-18 18:09:18 +00:00
|
|
|
*/
|
2001-11-23 21:46:44 +00:00
|
|
|
pixbuf = NULL;
|
|
|
|
filename = demo_find_file ("gtk-logo-rgb.gif", &error);
|
|
|
|
if (filename)
|
|
|
|
{
|
|
|
|
pixbuf = gdk_pixbuf_new_from_file (filename, &error);
|
|
|
|
g_free (filename);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (error)
|
2001-05-18 16:28:30 +00:00
|
|
|
{
|
|
|
|
/* This code shows off error handling. You can just use
|
|
|
|
* gtk_image_new_from_file() instead if you don't want to report
|
|
|
|
* errors to the user. If the file doesn't load when using
|
|
|
|
* gtk_image_new_from_file(), a "missing image" icon will
|
|
|
|
* be displayed instead.
|
|
|
|
*/
|
2001-11-23 21:46:44 +00:00
|
|
|
GtkWidget *dialog;
|
2008-08-11 19:12:58 +00:00
|
|
|
|
2001-11-23 21:46:44 +00:00
|
|
|
dialog = gtk_message_dialog_new (GTK_WINDOW (window),
|
|
|
|
GTK_DIALOG_DESTROY_WITH_PARENT,
|
|
|
|
GTK_MESSAGE_ERROR,
|
|
|
|
GTK_BUTTONS_CLOSE,
|
|
|
|
"Unable to open image file 'gtk-logo-rgb.gif': %s",
|
|
|
|
error->message);
|
|
|
|
g_error_free (error);
|
2008-08-11 19:12:58 +00:00
|
|
|
|
2001-11-23 21:46:44 +00:00
|
|
|
g_signal_connect (dialog, "response",
|
|
|
|
G_CALLBACK (gtk_widget_destroy), NULL);
|
2008-08-11 19:12:58 +00:00
|
|
|
|
2001-11-23 21:46:44 +00:00
|
|
|
gtk_widget_show (dialog);
|
2001-05-18 16:28:30 +00:00
|
|
|
}
|
2008-08-11 19:12:58 +00:00
|
|
|
|
2001-11-23 21:46:44 +00:00
|
|
|
image = gtk_image_new_from_pixbuf (pixbuf);
|
2001-04-18 18:09:18 +00:00
|
|
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), image);
|
|
|
|
|
2001-05-07 15:58:47 +00:00
|
|
|
|
|
|
|
/* Animation */
|
|
|
|
|
|
|
|
label = gtk_label_new (NULL);
|
|
|
|
gtk_label_set_markup (GTK_LABEL (label),
|
2001-05-18 16:28:30 +00:00
|
|
|
"<u>Animation loaded from a file</u>");
|
2001-05-07 15:58:47 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
|
2008-08-11 19:12:58 +00:00
|
|
|
|
2001-05-07 15:58:47 +00:00
|
|
|
frame = gtk_frame_new (NULL);
|
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
|
|
|
/* The alignment keeps the frame from growing when users resize
|
|
|
|
* the window
|
|
|
|
*/
|
|
|
|
align = gtk_alignment_new (0.5, 0.5, 0, 0);
|
|
|
|
gtk_container_add (GTK_CONTAINER (align), frame);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), align, FALSE, FALSE, 0);
|
|
|
|
|
2001-11-23 21:46:44 +00:00
|
|
|
filename = demo_find_file ("floppybuddy.gif", NULL);
|
|
|
|
image = gtk_image_new_from_file (filename);
|
|
|
|
g_free (filename);
|
2001-05-07 15:58:47 +00:00
|
|
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), image);
|
2008-08-11 19:12:58 +00:00
|
|
|
|
2010-04-26 10:55:34 +00:00
|
|
|
/* Symbolic icon */
|
|
|
|
|
|
|
|
label = gtk_label_new (NULL);
|
|
|
|
gtk_label_set_markup (GTK_LABEL (label),
|
|
|
|
"<u>Symbolic themed icon</u>");
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
frame = gtk_frame_new (NULL);
|
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
|
|
|
/* The alignment keeps the frame from growing when users resize
|
|
|
|
* the window
|
|
|
|
*/
|
|
|
|
align = gtk_alignment_new (0.5, 0.5, 0, 0);
|
|
|
|
gtk_container_add (GTK_CONTAINER (align), frame);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), align, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
gicon = g_themed_icon_new_with_default_fallbacks ("battery-critical-charging-symbolic");
|
|
|
|
image = gtk_image_new_from_gicon (gicon, GTK_ICON_SIZE_DIALOG);
|
|
|
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), image);
|
2001-05-07 15:58:47 +00:00
|
|
|
|
|
|
|
/* Progressive */
|
2008-08-11 19:12:58 +00:00
|
|
|
|
|
|
|
|
2001-04-18 18:09:18 +00:00
|
|
|
label = gtk_label_new (NULL);
|
|
|
|
gtk_label_set_markup (GTK_LABEL (label),
|
2001-05-18 16:28:30 +00:00
|
|
|
"<u>Progressive image loading</u>");
|
2001-04-18 18:09:18 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
|
2008-08-11 19:12:58 +00:00
|
|
|
|
2001-04-18 18:09:18 +00:00
|
|
|
frame = gtk_frame_new (NULL);
|
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
|
|
|
/* The alignment keeps the frame from growing when users resize
|
|
|
|
* the window
|
|
|
|
*/
|
|
|
|
align = gtk_alignment_new (0.5, 0.5, 0, 0);
|
|
|
|
gtk_container_add (GTK_CONTAINER (align), frame);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), align, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
/* Create an empty image for now; the progressive loader
|
|
|
|
* will create the pixbuf and fill it in.
|
|
|
|
*/
|
|
|
|
image = gtk_image_new_from_pixbuf (NULL);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), image);
|
|
|
|
|
|
|
|
start_progressive_loading (image);
|
2002-01-29 23:59:21 +00:00
|
|
|
|
|
|
|
/* Sensitivity control */
|
|
|
|
button = gtk_toggle_button_new_with_mnemonic ("_Insensitive");
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
|
|
|
|
2002-09-29 21:24:24 +00:00
|
|
|
g_signal_connect (button, "toggled",
|
2002-01-29 23:59:21 +00:00
|
|
|
G_CALLBACK (toggle_sensitivity_callback),
|
|
|
|
vbox);
|
2001-04-18 18:09:18 +00:00
|
|
|
}
|
|
|
|
|
2010-03-01 06:47:38 +00:00
|
|
|
if (!gtk_widget_get_visible (window))
|
2001-04-18 18:09:18 +00:00
|
|
|
{
|
|
|
|
gtk_widget_show_all (window);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gtk_widget_destroy (window);
|
|
|
|
window = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return window;
|
|
|
|
}
|