Commit 2936c8e9 authored by Owen Taylor's avatar Owen Taylor Committed by Owen Taylor

Version 1.3.11 Require GLib-1.3.11, Pango-0.22, ATK-0.7. Restore to

Thu Nov 22 15:01:03 2001  Owen Taylor  <otaylor@redhat.com>
        * Version 1.3.11
        * configure.in (ATK_REQUIRED_VERSION): Require
        GLib-1.3.11, Pango-0.22, ATK-0.7.
        * tests/prop-editor.c (property_widget): Restore
        to working as well as it did before.
        * gtk/gtklistitem.h: Mark deprecated since it is
        an integral part of GtkList.
        * demos/gtk-demo/demo-common.h: New header file,
        for a common functions not important to the meat
        of the demos.

        * demos/gtk-demo/main.c (demo_ifind_file): Add a utility
        function to search for a file used by the demo.
        * demos/*.c: Use demo_find_file.
parent 393c4757
Thu Nov 22 15:01:03 2001 Owen Taylor <otaylor@redhat.com>
* Version 1.3.11
* configure.in (ATK_REQUIRED_VERSION): Require
GLib-1.3.11, Pango-0.22, ATK-0.7.
* tests/prop-editor.c (property_widget): Restore
to working as well as it did before.
* gtk/gtklistitem.h: Mark deprecated since it is
an integral part of GtkList.
* demos/gtk-demo/demo-common.h: New header file,
for a common functions not important to the meat
of the demos.
* demos/gtk-demo/main.c (demo_ifind_file): Add a utility
function to search for a file used by the demo.
* demos/*.c: Use demo_find_file.
2001-11-23 Matthias Clasen <matthiasc@poet.de>
* gtk/gtktextbuffer.c (gtk_text_buffer_create_tag),
......
Thu Nov 22 15:01:03 2001 Owen Taylor <otaylor@redhat.com>
* Version 1.3.11
* configure.in (ATK_REQUIRED_VERSION): Require
GLib-1.3.11, Pango-0.22, ATK-0.7.
* tests/prop-editor.c (property_widget): Restore
to working as well as it did before.
* gtk/gtklistitem.h: Mark deprecated since it is
an integral part of GtkList.
* demos/gtk-demo/demo-common.h: New header file,
for a common functions not important to the meat
of the demos.
* demos/gtk-demo/main.c (demo_ifind_file): Add a utility
function to search for a file used by the demo.
* demos/*.c: Use demo_find_file.
2001-11-23 Matthias Clasen <matthiasc@poet.de>
* gtk/gtktextbuffer.c (gtk_text_buffer_create_tag),
......
Thu Nov 22 15:01:03 2001 Owen Taylor <otaylor@redhat.com>
* Version 1.3.11
* configure.in (ATK_REQUIRED_VERSION): Require
GLib-1.3.11, Pango-0.22, ATK-0.7.
* tests/prop-editor.c (property_widget): Restore
to working as well as it did before.
* gtk/gtklistitem.h: Mark deprecated since it is
an integral part of GtkList.
* demos/gtk-demo/demo-common.h: New header file,
for a common functions not important to the meat
of the demos.
* demos/gtk-demo/main.c (demo_ifind_file): Add a utility
function to search for a file used by the demo.
* demos/*.c: Use demo_find_file.
2001-11-23 Matthias Clasen <matthiasc@poet.de>
* gtk/gtktextbuffer.c (gtk_text_buffer_create_tag),
......
Thu Nov 22 15:01:03 2001 Owen Taylor <otaylor@redhat.com>
* Version 1.3.11
* configure.in (ATK_REQUIRED_VERSION): Require
GLib-1.3.11, Pango-0.22, ATK-0.7.
* tests/prop-editor.c (property_widget): Restore
to working as well as it did before.
* gtk/gtklistitem.h: Mark deprecated since it is
an integral part of GtkList.
* demos/gtk-demo/demo-common.h: New header file,
for a common functions not important to the meat
of the demos.
* demos/gtk-demo/main.c (demo_ifind_file): Add a utility
function to search for a file used by the demo.
* demos/*.c: Use demo_find_file.
2001-11-23 Matthias Clasen <matthiasc@poet.de>
* gtk/gtktextbuffer.c (gtk_text_buffer_create_tag),
......
Thu Nov 22 15:01:03 2001 Owen Taylor <otaylor@redhat.com>
* Version 1.3.11
* configure.in (ATK_REQUIRED_VERSION): Require
GLib-1.3.11, Pango-0.22, ATK-0.7.
* tests/prop-editor.c (property_widget): Restore
to working as well as it did before.
* gtk/gtklistitem.h: Mark deprecated since it is
an integral part of GtkList.
* demos/gtk-demo/demo-common.h: New header file,
for a common functions not important to the meat
of the demos.
* demos/gtk-demo/main.c (demo_ifind_file): Add a utility
function to search for a file used by the demo.
* demos/*.c: Use demo_find_file.
2001-11-23 Matthias Clasen <matthiasc@poet.de>
* gtk/gtktextbuffer.c (gtk_text_buffer_create_tag),
......
Thu Nov 22 15:01:03 2001 Owen Taylor <otaylor@redhat.com>
* Version 1.3.11
* configure.in (ATK_REQUIRED_VERSION): Require
GLib-1.3.11, Pango-0.22, ATK-0.7.
* tests/prop-editor.c (property_widget): Restore
to working as well as it did before.
* gtk/gtklistitem.h: Mark deprecated since it is
an integral part of GtkList.
* demos/gtk-demo/demo-common.h: New header file,
for a common functions not important to the meat
of the demos.
* demos/gtk-demo/main.c (demo_ifind_file): Add a utility
function to search for a file used by the demo.
* demos/*.c: Use demo_find_file.
2001-11-23 Matthias Clasen <matthiasc@poet.de>
* gtk/gtktextbuffer.c (gtk_text_buffer_create_tag),
......
Thu Nov 22 15:01:03 2001 Owen Taylor <otaylor@redhat.com>
* Version 1.3.11
* configure.in (ATK_REQUIRED_VERSION): Require
GLib-1.3.11, Pango-0.22, ATK-0.7.
* tests/prop-editor.c (property_widget): Restore
to working as well as it did before.
* gtk/gtklistitem.h: Mark deprecated since it is
an integral part of GtkList.
* demos/gtk-demo/demo-common.h: New header file,
for a common functions not important to the meat
of the demos.
* demos/gtk-demo/main.c (demo_ifind_file): Add a utility
function to search for a file used by the demo.
* demos/*.c: Use demo_find_file.
2001-11-23 Matthias Clasen <matthiasc@poet.de>
* gtk/gtktextbuffer.c (gtk_text_buffer_create_tag),
......
......@@ -80,9 +80,9 @@ AC_SUBST(GDK_PIXBUF_MICRO)
AC_SUBST(GDK_PIXBUF_VERSION)
## Versions of dependencies
GLIB_REQUIRED_VERSION=1.3.10
PANGO_REQUIRED_VERSION=0.20
ATK_REQUIRED_VERSION=0.5
GLIB_REQUIRED_VERSION=1.3.11
PANGO_REQUIRED_VERSION=0.22
ATK_REQUIRED_VERSION=0.7
# For automake.
VERSION=$GTK_VERSION
......
......@@ -58,6 +58,7 @@ demos.h: $(demos) geninclude.pl
gtk_demo_SOURCES = \
$(demos) \
demo-common.h \
main.c \
demos.h
......
......@@ -4,6 +4,7 @@
*/
#include <gtk/gtk.h>
#include "demo-common.h"
static GtkWidget *window = NULL;
......@@ -95,6 +96,7 @@ register_stock_icons (void)
{
GdkPixbuf *pixbuf;
GtkIconFactory *factory;
char *filename;
static GtkStockItem items[] = {
{ "demo-gtk-logo",
......@@ -111,12 +113,17 @@ register_stock_icons (void)
factory = gtk_icon_factory_new ();
gtk_icon_factory_add_default (factory);
/* Try current directory */
pixbuf = gdk_pixbuf_new_from_file ("./gtk-logo-rgb.gif", NULL);
/* Try install directory */
if (pixbuf == NULL)
pixbuf = gdk_pixbuf_new_from_file (DEMOCODEDIR"/gtk-logo-rgb.gif", NULL);
/* demo_find_file() looks in the the current directory first,
* so you can run gtk-demo without installing GTK, then looks
* in the location where the file is installed.
*/
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)
......
#ifndef __DEMO_COMMON_H__
#define __DEMO_COMMON_H__
G_BEGIN_DECLS
gchar *demo_find_file (const gchar *base,
GError **err);
G_END_DECLS
#endif /* __DEMO_COMMON_H__ */
......@@ -15,6 +15,7 @@
#include <gtk/gtk.h>
#include <stdio.h>
#include <errno.h>
#include "demo-common.h"
static GtkWidget *window = NULL;
static GdkPixbufLoader *pixbuf_loader = NULL;
......@@ -177,14 +178,29 @@ progressive_timeout (gpointer data)
}
else
{
const gchar *filename;
gchar *filename;
gchar *error_message = NULL;
GError *error = NULL;
if (g_file_test ("./alphatest.png", G_FILE_TEST_EXISTS))
filename = "./alphatest.png";
/* demo_find_file() looks in the the current directory first,
* 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);
}
else
filename = DEMOCODEDIR"/alphatest.png";
image_stream = fopen (filename, "r");
{
image_stream = fopen (filename, "r");
g_free (filename);
if (!image_stream)
error_message = g_strdup_printf ("Unable to open image file 'alphatest.png': %s",
g_strerror (errno));
}
if (image_stream == NULL)
{
......@@ -194,8 +210,8 @@ progressive_timeout (gpointer data)
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
"Unable to open image file 'alphatest.png': %s",
g_strerror (errno));
"%s", error_message);
g_free (error_message);
g_signal_connect (dialog, "response",
G_CALLBACK (gtk_widget_destroy), NULL);
......@@ -272,6 +288,9 @@ do_images (void)
GtkWidget *image;
GtkWidget *label;
GtkWidget *align;
GdkPixbuf *pixbuf;
GError *error = NULL;
char *filename;
if (!window)
{
......@@ -303,10 +322,19 @@ do_images (void)
gtk_container_add (GTK_CONTAINER (align), frame);
gtk_box_pack_start (GTK_BOX (vbox), align, FALSE, FALSE, 0);
/* We look for the image in the current directory first,
* so you can run gtk-demo without installing GTK
/* demo_find_file() looks in the the current directory first,
* so you can run gtk-demo without installing GTK, then looks
* in the location where the file is installed.
*/
if (g_file_test ("./gtk-logo-rgb.gif", G_FILE_TEST_EXISTS))
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)
{
/* This code shows off error handling. You can just use
* gtk_image_new_from_file() instead if you don't want to report
......@@ -314,39 +342,23 @@ do_images (void)
* gtk_image_new_from_file(), a "missing image" icon will
* be displayed instead.
*/
GdkPixbuf *pixbuf;
GError *error = NULL;
GtkWidget *dialog;
pixbuf = gdk_pixbuf_new_from_file ("./gtk-logo-rgb.gif",
&error);
if (error)
{
GtkWidget *dialog;
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);
g_signal_connect (dialog, "response",
G_CALLBACK (gtk_widget_destroy), NULL);
gtk_widget_show (dialog);
}
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);
image = gtk_image_new_from_pixbuf (pixbuf);
}
else
{
/* This is the simpler code, with no error handling.
* Here we're loading the installed gtk-logo-rgb.gif instead
* of the one in the current directory.
*/
image = gtk_image_new_from_file (DEMOCODEDIR"/gtk-logo-rgb.gif");
g_signal_connect (dialog, "response",
G_CALLBACK (gtk_widget_destroy), NULL);
gtk_widget_show (dialog);
}
image = gtk_image_new_from_pixbuf (pixbuf);
gtk_container_add (GTK_CONTAINER (frame), image);
......@@ -367,13 +379,9 @@ do_images (void)
gtk_container_add (GTK_CONTAINER (align), frame);
gtk_box_pack_start (GTK_BOX (vbox), align, FALSE, FALSE, 0);
/* We look for the image in the current directory first,
* so you can run gtk-demo without installing GTK
*/
if (g_file_test ("./floppybuddy.gif", G_FILE_TEST_EXISTS))
image = gtk_image_new_from_file ("./floppybuddy.gif");
else
image = gtk_image_new_from_file (DEMOCODEDIR"/floppybuddy.gif");
filename = demo_find_file ("floppybuddy.gif", NULL);
image = gtk_image_new_from_file (filename);
g_free (filename);
gtk_container_add (GTK_CONTAINER (frame), image);
......
......@@ -13,6 +13,7 @@ static GtkTextBuffer *source_buffer;
static gchar *current_file = NULL;
enum {
TITLE_COLUMN,
FILENAME_COLUMN,
......@@ -28,6 +29,39 @@ struct _CallbackData
GtkTreePath *path;
};
/**
* demo_find_file:
* @base: base filename
* @err: location to store error, or %NULL.
*
* Looks for @base first in the current directory, then in the
* location GTK+ where it will be installed on make install,
* returns the first file found.
*
* Return value: the filename, if found or %NULL
**/
gchar *
demo_find_file (const char *base,
GError **err)
{
g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
if (g_file_test (base, G_FILE_TEST_EXISTS))
return g_strdup (base);
else
{
char *filename = g_build_filename (DEMOCODEDIR, base, NULL);
if (!g_file_test (filename, G_FILE_TEST_EXISTS))
{
g_set_error (err, G_FILE_ERROR, G_FILE_ERROR_NOENT,
"Cannot find demo data file \"%s\"", base);
g_free (filename);
return NULL;
}
return filename;
}
}
static void
window_closed_cb (GtkWidget *window, gpointer data)
{
......@@ -364,6 +398,8 @@ load_file (const gchar *filename)
{
FILE *file;
GtkTextIter start, end;
char *full_filename;
GError *err = NULL;
GString *buffer = g_string_new (NULL);
int state = 0;
gboolean in_para = 0;
......@@ -383,25 +419,23 @@ load_file (const gchar *filename)
gtk_text_buffer_get_bounds (source_buffer, &start, &end);
gtk_text_buffer_delete (source_buffer, &start, &end);
file = fopen (filename, "r");
full_filename = demo_find_file (filename, &err);
if (!full_filename)
{
g_warning ("%s", err->message);
g_error_free (err);
return;
}
file = fopen (full_filename, "r");
if (!file)
{
char *installed = g_strconcat (DEMOCODEDIR,
G_DIR_SEPARATOR_S,
filename,
NULL);
g_warning ("Cannot open %s: %s\n", full_filename, g_strerror (errno));
file = fopen (installed, "r");
g_free (full_filename);
g_free (installed);
}
if (!file)
{
g_warning ("Cannot open %s: %s\n", filename, g_strerror (errno));
return;
}
return;
gtk_text_buffer_get_iter_at_offset (info_buffer, &start, 0);
while (read_line (file, buffer))
......@@ -701,38 +735,36 @@ 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);
char *filename;
GError *err;
err = NULL;
if (pixbuf == NULL)
pixbuf = NULL;
filename = demo_find_file ("gtk-logo-rgb.gif", &err);
if (filename)
{
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);
g_signal_connect (dialog, "response",
G_CALLBACK (gtk_widget_destroy), NULL);
}
pixbuf = gdk_pixbuf_new_from_file (filename, &err);
g_free (filename);
}
/* 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: %s",
err->message);
g_error_free (err);
g_signal_connect (dialog, "response",
G_CALLBACK (gtk_widget_destroy), NULL);
}
if (pixbuf)
......
......@@ -17,12 +17,13 @@
#include <gtk/gtk.h>
#include <math.h>
#include "demo-common.h"
#define FRAME_DELAY 50
#define RELATIVE_BACKGROUND_NAME "background.jpg"
#define INSTALLED_BACKGROUND_NAME DEMOCODEDIR"/background.jpg"
#define BACKGROUND_NAME "background.jpg"
static const char *relative_image_names[] = {
static const char *image_names[] = {
"apple-red.png",
"gnome-applets.png",
"gnome-calendar.png",
......@@ -33,18 +34,7 @@ static const char *relative_image_names[] = {
"gnu-keys.png"
};
static const char *installed_image_names[] = {
DEMOCODEDIR"/apple-red.png",
DEMOCODEDIR"/gnome-applets.png",
DEMOCODEDIR"/gnome-calendar.png",
DEMOCODEDIR"/gnome-foot.png",
DEMOCODEDIR"/gnome-gmush.png",
DEMOCODEDIR"/gnome-gimp.png",
DEMOCODEDIR"/gnome-gsame.png",
DEMOCODEDIR"/gnu-keys.png"
};
#define N_IMAGES G_N_ELEMENTS (relative_image_names)
#define N_IMAGES G_N_ELEMENTS (image_names)
/* demo window */
static GtkWidget *window = NULL;
......@@ -67,30 +57,37 @@ static gboolean
load_pixbufs (GError **error)
{
gint i;
const gchar **image_names;
char *filename;
if (background)
return TRUE; /* already loaded earlier */
background = gdk_pixbuf_new_from_file (RELATIVE_BACKGROUND_NAME, NULL);
if (!background)
background = gdk_pixbuf_new_from_file (INSTALLED_BACKGROUND_NAME, error);
/* demo_find_file() looks in the the current directory first,
* so you can run gtk-demo without installing GTK, then looks
* in the location where the file is installed.
*/
filename = demo_find_file (BACKGROUND_NAME, error);
if (!filename)
return FALSE; /* note that "error" was filled in and returned */
background = gdk_pixbuf_new_from_file (filename, error);
g_free (filename);
if (!background)
return FALSE; /* note that "error" was filled in and returned */
return FALSE; /* Note that "error" was filled with a GError */
back_width = gdk_pixbuf_get_width (background);
back_height = gdk_pixbuf_get_height (background);
if (g_file_test (relative_image_names[0], G_FILE_TEST_EXISTS))
image_names = relative_image_names;
else
image_names = installed_image_names;
for (i = 0; i < N_IMAGES; i++)
{
images[i] = gdk_pixbuf_new_from_file (image_names[i], error);
filename = demo_find_file (image_names[i], error);
if (!filename)
return FALSE; /* Note that "error" was filled with a GError */
images[i] = gdk_pixbuf_new_from_file (filename, error);
g_free (filename);
if (!images[i])
return FALSE; /* Note that "error" was filled with a GError */
}
......
......@@ -10,6 +10,8 @@
#include <gtk/gtk.h>
#include <stdlib.h> /* for exit() */
#include "demo-common.h"
static void easter_egg_callback (GtkWidget *button, gpointer data);
#define gray50_width 2
......@@ -151,10 +153,19 @@ insert_text (GtkTextBuffer *buffer)
GdkPixbuf *pixbuf;
GdkPixbuf *scaled;
GtkTextChildAnchor *anchor;
char *filename;
pixbuf = gdk_pixbuf_new_from_file ("./gtk-logo-rgb.gif", NULL);
if (pixbuf == NULL)
gdk_pixbuf_new_from_file (DEMOCODEDIR"/gtk-logo-rgb.gif", NULL);
/* demo_find_file() looks in the the current directory first,
* so you can run gtk-demo without installing GTK, then looks
* in the location where the file is installed.
*/
pixbuf = NULL;
filename = demo_find_file ("gtk-logo-rgb.gif", NULL);
if (filename)
{
pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
g_free (filename);
}
if (pixbuf == NULL)
{
......@@ -412,10 +423,9 @@ attach_widgets (GtkTextView *text_view)
}
else if (i == 3)
{
if (g_file_test ("./floppybuddy.gif", G_FILE_TEST_EXISTS))
widget = gtk_image_new_from_file ("./floppybuddy.gif");
else
widget = gtk_image_new_from_file (DEMOCODEDIR"/floppybuddy.gif");
gchar *filename = demo_find_file ("floppybuddy.gif", NULL);
widget = gtk_image_new_from_file (filename);
g_free (filename);
}
else if (i == 4)
{
......
......@@ -24,6 +24,8 @@
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#ifndef GTK_DISABLE_DEPRECATED
#ifndef __GTK_LIST_ITEM_H__
#define __GTK_LIST_ITEM_H__
......@@ -92,3 +94,5 @@ void gtk_list_item_deselect (GtkListItem *list_item);
#endif /* __GTK_LIST_ITEM_H__ */
#endif /* GTK_DISABLE_DEPRECATED */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.