Compare commits
96 Commits
tooltip_wi
...
gtk-multih
Author | SHA1 | Date | |
---|---|---|---|
|
75c92d9e3e | ||
|
9b6ddad17e | ||
|
dcd3ef4055 | ||
|
85bfb30534 | ||
|
1773bb92b5 | ||
|
3fc9d614f1 | ||
|
9f685de755 | ||
|
3851491d9a | ||
|
77972d13e9 | ||
|
d01a255508 | ||
|
6ab8b0bd94 | ||
|
caa10a8453 | ||
|
1f59549db6 | ||
|
3bf0667168 | ||
|
5558fb5ceb | ||
|
7c55cfdfd1 | ||
|
75a8bd5fa2 | ||
|
c7d1a2e836 | ||
|
bb18a4abd0 | ||
|
8baf9adaa0 | ||
|
a99d8aa2ae | ||
|
0fcfca698d | ||
|
f4425feb4c | ||
|
e338e7d304 | ||
|
b40f48e86e | ||
|
9bc498eb52 | ||
|
951dd5dce8 | ||
|
7182f8e51a | ||
|
e7eb55d954 | ||
|
b5a3e20cc7 | ||
|
9e14846cd6 | ||
|
3d41b6dc9b | ||
|
7064f497e1 | ||
|
6352ace501 | ||
|
40df0aeb9b | ||
|
4cbeb803b3 | ||
|
f99cca8b87 | ||
|
165583bfda | ||
|
3aca27e818 | ||
|
68cb350f9d | ||
|
b2b9cc6783 | ||
|
d9395c7ef9 | ||
|
9886d3abfa | ||
|
5940e5f836 | ||
|
e5c6f92bf6 | ||
|
7f7b6e30c4 | ||
|
9dd35b1f0e | ||
|
2ef7ef1b16 | ||
|
08b0b80362 | ||
|
061c766e2b | ||
|
bd92619e9d | ||
|
fcc780f378 | ||
|
a1525ddf07 | ||
|
9cde6f277f | ||
|
6fa05332de | ||
|
996e355971 | ||
|
024eb4a6e4 | ||
|
a880dd2679 | ||
|
4f43fcd1a6 | ||
|
70af5e16a1 | ||
|
5ca448422a | ||
|
873bdc26a6 | ||
|
5e8e3f407e | ||
|
8ce4276208 | ||
|
e47807fbe1 | ||
|
255695f76f | ||
|
21c08e6440 | ||
|
8320e60ebd | ||
|
d4497ca21e | ||
|
97f7b5c9b3 | ||
|
f6ce455ecf | ||
|
a6d425470a | ||
|
5be19317ae | ||
|
3f23a87d82 | ||
|
be4d275bed | ||
|
e2b1a43f10 | ||
|
041053cb97 | ||
|
84902b6fd8 | ||
|
d66df2f988 | ||
|
845b1f3211 | ||
|
8ba19314c6 | ||
|
c5faaf2132 | ||
|
a9cec4e3d0 | ||
|
cbdedb210d | ||
|
4e71d42920 | ||
|
7ef95bf051 | ||
|
73f340ea73 | ||
|
bb0b5342c9 | ||
|
24b845f8f6 | ||
|
f7d0a21a2b | ||
|
86f52bfd26 | ||
|
63f140c9c8 | ||
|
d47c6f30ff | ||
|
565b8c42d4 | ||
|
6768cfdf2f | ||
|
28314a4bf1 |
@@ -5,6 +5,7 @@ config.h.in
|
||||
libtool
|
||||
config.status
|
||||
stamp-h
|
||||
stamp-h1
|
||||
Makefile
|
||||
Makefile.in
|
||||
aclocal.m4
|
||||
@@ -17,14 +18,20 @@ intl
|
||||
stamp-h.in
|
||||
gtk+.spec
|
||||
gtk+-2.0.pc
|
||||
gtk+-2.0-uninstalled.pc
|
||||
gtk+-linux-fb-2.0.pc
|
||||
gtk+-nanox-2.0.pc
|
||||
gtk+-x11-2.0.pc
|
||||
gdk-2.0.pc
|
||||
gdk-2.0-uninstalled.pc
|
||||
gdk-linux-fb-2.0.pc
|
||||
gdk-nanox-2.0.pc
|
||||
gdk-x11-2.0.pc
|
||||
gdk-pixbuf-2.0.pc
|
||||
gdk-pixbuf-2.0-uninstalled.pc
|
||||
gtk-zip.sh
|
||||
missing
|
||||
install-sh
|
||||
mkinstalldirs
|
||||
sgml
|
||||
autom4te.cache
|
||||
|
12512
ChangeLog.pre-2-0
12512
ChangeLog.pre-2-0
File diff suppressed because it is too large
Load Diff
16803
ChangeLog.pre-2-10
16803
ChangeLog.pre-2-10
File diff suppressed because it is too large
Load Diff
16803
ChangeLog.pre-2-2
16803
ChangeLog.pre-2-2
File diff suppressed because it is too large
Load Diff
16803
ChangeLog.pre-2-4
16803
ChangeLog.pre-2-4
File diff suppressed because it is too large
Load Diff
16803
ChangeLog.pre-2-6
16803
ChangeLog.pre-2-6
File diff suppressed because it is too large
Load Diff
16803
ChangeLog.pre-2-8
16803
ChangeLog.pre-2-8
File diff suppressed because it is too large
Load Diff
12
HACKING
12
HACKING
@@ -1,13 +1,11 @@
|
||||
If you want to hack on the Gtk+ project, it will make you life easier
|
||||
to have the following packages installed:
|
||||
If you want to hack on the GTK+ project, you'll need to have
|
||||
the following packages installed:
|
||||
|
||||
- GNU autoconf 2.13
|
||||
- GNU autoconf 2.52
|
||||
- GNU automake 1.4
|
||||
(Beta releases are at ftp://ftp.cygnus.com/pub/tromey)
|
||||
- GNU libtool 1.2d
|
||||
- GNU libtool 1.4
|
||||
- indent (GNU indent 1.9.1 is known good)
|
||||
- GNU gettext 10.35
|
||||
Available in ftp://alpha.gnu.org/gnu
|
||||
- GNU gettext 10.40
|
||||
|
||||
These should be available by ftp from ftp.gnu.org or any of the
|
||||
fine GNU mirrors. Beta software can be found at alpha.gnu.org.
|
||||
|
165
INSTALL
165
INSTALL
@@ -3,7 +3,7 @@ Prerequisites
|
||||
|
||||
GTK+ requires the following packages:
|
||||
|
||||
- The GLIB, Pango, and Atk libraries, available at the same location as GTK+
|
||||
- The GLib, Pango, and Atk libraries, available at the same location as GTK+
|
||||
|
||||
- The TIFF, PNG, and JPEG image loading libraries. You most
|
||||
likely have these installed on your system already. If not
|
||||
@@ -20,167 +20,22 @@ GTK+ requires the following packages:
|
||||
Simple install procedure
|
||||
========================
|
||||
|
||||
% gzip -cd gtk+-1.3.5.tar.gz | tar xvf - # unpack the sources
|
||||
% cd gtk+-1.3.5 # change to the toplevel directory
|
||||
% gzip -cd gtk+-2.0.2.tar.gz | tar xvf - # unpack the sources
|
||||
% cd gtk+-2.0.2 # change to the toplevel directory
|
||||
% ./configure # run the `configure' script
|
||||
% make # build GTK
|
||||
[ Become root if necessary ]
|
||||
% make install # install GTK
|
||||
|
||||
The Nitty-Gritty
|
||||
================
|
||||
The Details
|
||||
===========
|
||||
|
||||
The 'configure' script can be given a number of options to enable
|
||||
and disable various features. For a complete list, type:
|
||||
Complete information about installing GTK+ and related libraries can be found
|
||||
in the file:
|
||||
|
||||
./configure --help
|
||||
docs/reference/gtk/docs/reference/gtk/html/gtk-building.html
|
||||
|
||||
A few of the more important ones:
|
||||
|
||||
* --prefix=PREFIX install architecture-independent files in PREFIX
|
||||
[ Defaults to /usr/local ]
|
||||
|
||||
* --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
|
||||
[ Defaults to the value given to --prefix ]
|
||||
|
||||
* --with-xinput=[no/gxi/xfree] support XInput [default=no]
|
||||
|
||||
The --with-xinput flag specifies whether to compile with support
|
||||
for the XInput extension (mainly used for graphics tablets), and
|
||||
which form of support to use:
|
||||
|
||||
no : no support
|
||||
xfree : Use special features in the Wacom drivers in XFree86 3.3.1
|
||||
and later.
|
||||
gxi : Use generic XInput support (not recommended)
|
||||
|
||||
The XInput support is not known to work with any other XServer than
|
||||
XFree86. For more information about XInput, see:
|
||||
|
||||
http://www.gtk.org/~otaylor/xinput/howto/index.html
|
||||
http://www.lepied.com/xfree86/
|
||||
|
||||
* --disable-nls do not use Native Language Support
|
||||
|
||||
If this flag is not specified, GTK+ will try to find
|
||||
and use the gettext() set of functions to provide translations
|
||||
of the strings in the standard dialogs into the
|
||||
user's native language.
|
||||
|
||||
* --enable-xim support XIM [default=yes]
|
||||
|
||||
Specifying --disable-xim will disable support for entering
|
||||
internationalized text using X Input Methods. This will give some
|
||||
slight savings in speed and memory use and might be necessary
|
||||
with older versions of X.
|
||||
|
||||
* --with-locale=LOCALE locale name you want to use
|
||||
|
||||
The --with-locale options is used to determine if your operating
|
||||
system has support for the locale you will be using. If not, X's
|
||||
built in locale support will be used.
|
||||
|
||||
Because of bugs in autoconf, it is necessary to specify this
|
||||
option even if your LANG environment variable is correctly set.
|
||||
|
||||
This option does not determine which locale GTK will use at
|
||||
runtime. That will be determined from the usual environment
|
||||
variables. If you will be using multiple locales with GTK,
|
||||
specify the one for which your operating system has the worst
|
||||
support for the --with-locale option.
|
||||
|
||||
|
||||
Options can be given to the compiler and linker by setting
|
||||
environment variables before running configure. A few of the more
|
||||
important ones:
|
||||
|
||||
CC : The C compiler to use
|
||||
CPPFLAGS : Flags for the C preprocesser such as -I and -D
|
||||
CFLAGS : C compiler flags
|
||||
|
||||
The most important use of this is to set the
|
||||
optimization/debugging flags. For instance, to compile with no
|
||||
debugging information at all, run configure as:
|
||||
|
||||
CFLAGS=-O2 ./configure # Bourne compatible shells (sh/bash/zsh)
|
||||
|
||||
or,
|
||||
|
||||
setenv CFLAGS -O2 ; ./configure # csh and variants
|
||||
|
||||
Native-Language Support and gettext()
|
||||
=====================================
|
||||
|
||||
To provide native-language support (NLS) GTK+ uses the
|
||||
gettext() set of functions. These functions are found
|
||||
in the C library on many systems, such as the Solaris
|
||||
C library and the GNU C Library, version 2.
|
||||
|
||||
If your C library does not provide the necessary functionality,
|
||||
you may wish to install the GNU gettext package. You'll
|
||||
need version 0.10.35 or better. Version 0.10.35 is
|
||||
available from ftp://alpha.gnu.org/pub/gnu
|
||||
|
||||
Generally, GTK+ will properly detect what is installed
|
||||
on your system and enable or disable NLS as appropriate.
|
||||
However, in rare cases, it may be necessary to disable
|
||||
NLS manually to get GTK+ to compile. You can do this
|
||||
by specifying the --disable-nls flag when configuring
|
||||
GTK+.
|
||||
|
||||
Installation directories
|
||||
========================
|
||||
|
||||
The location of the installed files is determined by the --prefix
|
||||
and --exec-prefix options given to configure. There are also more
|
||||
detailed flags to control individual directories. However, the
|
||||
use of these flags is not tested.
|
||||
|
||||
One particular detail to note, is that the architecture-dependent
|
||||
include file glibconfig.h is installed in:
|
||||
|
||||
$exec_pref/lib/glib/include/
|
||||
|
||||
if you have a version in $prefix/include, this is out of date
|
||||
and should be deleted.
|
||||
|
||||
A shell script gtk-config is created during the configure
|
||||
process, and installed in the bin/ directory
|
||||
($exec_prefix/bin). This is used to determine the location of GTK
|
||||
when building applications. If you move GTK after installation,
|
||||
it will be necessary to edit this file.
|
||||
|
||||
For complete details, see the file docs/gtk-config.txt
|
||||
|
||||
|
||||
Notes for using XIM support for Japanese input
|
||||
==============================================
|
||||
|
||||
* There is a bug in older versions of kinput2 that will cause GTK+
|
||||
to hang when destroying a text entry. The latest versions of
|
||||
kinput is available from:
|
||||
|
||||
ftp://ftp.sra.co.jp/pub/x11/kinput2
|
||||
|
||||
* The locale information file for the ja_JP EUC locale
|
||||
distributed with some recent versions of X11 specifies to use the
|
||||
C library multibyte functions. Unless your C library has support
|
||||
for Japanese locales, this is incorrect, and will cause problems
|
||||
for GTK's internationalization.
|
||||
|
||||
(In particular, this occurs with GNU libc 2.0 in which
|
||||
the multibyte functions always translate to and from UTF-8; but
|
||||
the problem may occur for other C libraries, and other operating
|
||||
systems as well.)
|
||||
|
||||
To fix this, change the line:
|
||||
|
||||
use_stdc_env True
|
||||
|
||||
to
|
||||
|
||||
use_stdc_env False
|
||||
|
||||
in the file /usr/X11R6/lib/X11/locale/ja_JP/XLC_LOCALE.
|
||||
Or online at:
|
||||
|
||||
http://developer.gnome.org/doc/API/2.0/gtk/gtk-building.html
|
||||
|
||||
|
161
INSTALL.in
161
INSTALL.in
@@ -3,7 +3,7 @@ Prerequisites
|
||||
|
||||
GTK+ requires the following packages:
|
||||
|
||||
- The GLIB, Pango, and Atk libraries, available at the same location as GTK+
|
||||
- The GLib, Pango, and Atk libraries, available at the same location as GTK+
|
||||
|
||||
- The TIFF, PNG, and JPEG image loading libraries. You most
|
||||
likely have these installed on your system already. If not
|
||||
@@ -27,160 +27,15 @@ Simple install procedure
|
||||
[ Become root if necessary ]
|
||||
% make install # install GTK
|
||||
|
||||
The Nitty-Gritty
|
||||
================
|
||||
The Details
|
||||
===========
|
||||
|
||||
The 'configure' script can be given a number of options to enable
|
||||
and disable various features. For a complete list, type:
|
||||
Complete information about installing GTK+ and related libraries can be found
|
||||
in the file:
|
||||
|
||||
./configure --help
|
||||
docs/reference/gtk/docs/reference/gtk/html/gtk-building.html
|
||||
|
||||
A few of the more important ones:
|
||||
|
||||
* --prefix=PREFIX install architecture-independent files in PREFIX
|
||||
[ Defaults to /usr/local ]
|
||||
|
||||
* --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
|
||||
[ Defaults to the value given to --prefix ]
|
||||
|
||||
* --with-xinput=[no/gxi/xfree] support XInput [default=no]
|
||||
|
||||
The --with-xinput flag specifies whether to compile with support
|
||||
for the XInput extension (mainly used for graphics tablets), and
|
||||
which form of support to use:
|
||||
|
||||
no : no support
|
||||
xfree : Use special features in the Wacom drivers in XFree86 3.3.1
|
||||
and later.
|
||||
gxi : Use generic XInput support (not recommended)
|
||||
|
||||
The XInput support is not known to work with any other XServer than
|
||||
XFree86. For more information about XInput, see:
|
||||
|
||||
http://www.gtk.org/~otaylor/xinput/howto/index.html
|
||||
http://www.lepied.com/xfree86/
|
||||
|
||||
* --disable-nls do not use Native Language Support
|
||||
|
||||
If this flag is not specified, GTK+ will try to find
|
||||
and use the gettext() set of functions to provide translations
|
||||
of the strings in the standard dialogs into the
|
||||
user's native language.
|
||||
|
||||
* --enable-xim support XIM [default=yes]
|
||||
|
||||
Specifying --disable-xim will disable support for entering
|
||||
internationalized text using X Input Methods. This will give some
|
||||
slight savings in speed and memory use and might be necessary
|
||||
with older versions of X.
|
||||
|
||||
* --with-locale=LOCALE locale name you want to use
|
||||
|
||||
The --with-locale options is used to determine if your operating
|
||||
system has support for the locale you will be using. If not, X's
|
||||
built in locale support will be used.
|
||||
|
||||
Because of bugs in autoconf, it is necessary to specify this
|
||||
option even if your LANG environment variable is correctly set.
|
||||
|
||||
This option does not determine which locale GTK will use at
|
||||
runtime. That will be determined from the usual environment
|
||||
variables. If you will be using multiple locales with GTK,
|
||||
specify the one for which your operating system has the worst
|
||||
support for the --with-locale option.
|
||||
|
||||
|
||||
Options can be given to the compiler and linker by setting
|
||||
environment variables before running configure. A few of the more
|
||||
important ones:
|
||||
|
||||
CC : The C compiler to use
|
||||
CPPFLAGS : Flags for the C preprocesser such as -I and -D
|
||||
CFLAGS : C compiler flags
|
||||
|
||||
The most important use of this is to set the
|
||||
optimization/debugging flags. For instance, to compile with no
|
||||
debugging information at all, run configure as:
|
||||
|
||||
CFLAGS=-O2 ./configure # Bourne compatible shells (sh/bash/zsh)
|
||||
|
||||
or,
|
||||
|
||||
setenv CFLAGS -O2 ; ./configure # csh and variants
|
||||
|
||||
Native-Language Support and gettext()
|
||||
=====================================
|
||||
|
||||
To provide native-language support (NLS) GTK+ uses the
|
||||
gettext() set of functions. These functions are found
|
||||
in the C library on many systems, such as the Solaris
|
||||
C library and the GNU C Library, version 2.
|
||||
|
||||
If your C library does not provide the necessary functionality,
|
||||
you may wish to install the GNU gettext package. You'll
|
||||
need version 0.10.35 or better. Version 0.10.35 is
|
||||
available from ftp://alpha.gnu.org/pub/gnu
|
||||
|
||||
Generally, GTK+ will properly detect what is installed
|
||||
on your system and enable or disable NLS as appropriate.
|
||||
However, in rare cases, it may be necessary to disable
|
||||
NLS manually to get GTK+ to compile. You can do this
|
||||
by specifying the --disable-nls flag when configuring
|
||||
GTK+.
|
||||
|
||||
Installation directories
|
||||
========================
|
||||
|
||||
The location of the installed files is determined by the --prefix
|
||||
and --exec-prefix options given to configure. There are also more
|
||||
detailed flags to control individual directories. However, the
|
||||
use of these flags is not tested.
|
||||
|
||||
One particular detail to note, is that the architecture-dependent
|
||||
include file glibconfig.h is installed in:
|
||||
|
||||
$exec_pref/lib/glib/include/
|
||||
|
||||
if you have a version in $prefix/include, this is out of date
|
||||
and should be deleted.
|
||||
|
||||
A shell script gtk-config is created during the configure
|
||||
process, and installed in the bin/ directory
|
||||
($exec_prefix/bin). This is used to determine the location of GTK
|
||||
when building applications. If you move GTK after installation,
|
||||
it will be necessary to edit this file.
|
||||
|
||||
For complete details, see the file docs/gtk-config.txt
|
||||
|
||||
|
||||
Notes for using XIM support for Japanese input
|
||||
==============================================
|
||||
|
||||
* There is a bug in older versions of kinput2 that will cause GTK+
|
||||
to hang when destroying a text entry. The latest versions of
|
||||
kinput is available from:
|
||||
|
||||
ftp://ftp.sra.co.jp/pub/x11/kinput2
|
||||
|
||||
* The locale information file for the ja_JP EUC locale
|
||||
distributed with some recent versions of X11 specifies to use the
|
||||
C library multibyte functions. Unless your C library has support
|
||||
for Japanese locales, this is incorrect, and will cause problems
|
||||
for GTK's internationalization.
|
||||
|
||||
(In particular, this occurs with GNU libc 2.0 in which
|
||||
the multibyte functions always translate to and from UTF-8; but
|
||||
the problem may occur for other C libraries, and other operating
|
||||
systems as well.)
|
||||
|
||||
To fix this, change the line:
|
||||
|
||||
use_stdc_env True
|
||||
|
||||
to
|
||||
|
||||
use_stdc_env False
|
||||
|
||||
in the file /usr/X11R6/lib/X11/locale/ja_JP/XLC_LOCALE.
|
||||
Or online at:
|
||||
|
||||
http://developer.gnome.org/doc/API/2.0/gtk/gtk-building.html
|
||||
|
||||
|
72
Makefile.am
72
Makefile.am
@@ -1,7 +1,7 @@
|
||||
## Makefile.am for GTK+
|
||||
|
||||
SRC_SUBDIRS = gdk-pixbuf gdk gtk modules demos tests contrib
|
||||
SUBDIRS = po $(SRC_SUBDIRS) docs build
|
||||
SUBDIRS = po $(SRC_SUBDIRS) docs build m4macros
|
||||
|
||||
# require automake 1.4
|
||||
AUTOMAKE_OPTIONS = 1.4
|
||||
@@ -9,10 +9,7 @@ AUTOMAKE_OPTIONS = 1.4
|
||||
EXTRA_DIST = \
|
||||
HACKING \
|
||||
gtk+.spec.in \
|
||||
gtk-2.0.m4 \
|
||||
makecopyright \
|
||||
TODO \
|
||||
TODO.xml \
|
||||
NEWS.pre-1-0 \
|
||||
ChangeLog.pre-1-0 \
|
||||
ChangeLog.pre-1-2 \
|
||||
@@ -20,13 +17,14 @@ EXTRA_DIST = \
|
||||
README.win32 \
|
||||
README.nanox \
|
||||
config.h.win32 \
|
||||
intl/libgettext.h \
|
||||
intl/po2tbl.sed.in \
|
||||
gtk-zip.sh \
|
||||
sanitize-la.sh \
|
||||
po/README.tools \
|
||||
po/README.translators \
|
||||
po/desk.pl \
|
||||
po/makefile.mingw \
|
||||
po/update.pl \
|
||||
po/po2tbl.sed.in \
|
||||
examples/aspectframe/Makefile \
|
||||
examples/aspectframe/aspectframe.c \
|
||||
examples/Makefile \
|
||||
@@ -71,8 +69,6 @@ EXTRA_DIST = \
|
||||
examples/notebook/notebook.c \
|
||||
examples/packbox/Makefile \
|
||||
examples/packbox/packbox.c \
|
||||
examples/packer/Makefile \
|
||||
examples/packer/pack.c \
|
||||
examples/paned/Makefile \
|
||||
examples/paned/paned.c \
|
||||
examples/pixmap/Makefile \
|
||||
@@ -127,23 +123,37 @@ gdk-$(GDKTARGET)-2.0.pc: gdk-2.0.pc
|
||||
rm -f gdk-$(GDKTARGET)-2.0.pc && \
|
||||
cp gdk-2.0.pc gdk-$(GDKTARGET)-2.0.pc
|
||||
|
||||
gtk+-$(GDKTARGET)-2.0-uninstalled.pc: gtk+-2.0-uninstalled.pc
|
||||
rm -f gtk+-$(GDKTARGET)-2.0-uninstalled.pc && \
|
||||
cp gtk+-2.0-uninstalled.pc gtk+-$(GDKTARGET)-2.0-uninstalled.pc
|
||||
|
||||
gdk-$(GDKTARGET)-2.0-uninstalled.pc: gdk-2.0-uninstalled.pc
|
||||
rm -f gdk-$(GDKTARGET)-2.0-uninstalled.pc && \
|
||||
cp gdk-2.0-uninstalled.pc gdk-$(GDKTARGET)-2.0-uninstalled.pc
|
||||
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA= gdk-pixbuf-2.0.pc gdk-$(GDKTARGET)-2.0.pc gtk+-$(GDKTARGET)-2.0.pc
|
||||
|
||||
## symlink gdk-2.0.pc and gtk+-2.0.pc to default target for the platform
|
||||
DISTCLEANFILES = \
|
||||
gtk+-$(GDKTARGET)-2.0.pc \
|
||||
gdk-$(GDKTARGET)-2.0.pc \
|
||||
gtk+-$(GDKTARGET)-2.0-uninstalled.pc \
|
||||
gdk-$(GDKTARGET)-2.0-uninstalled.pc
|
||||
|
||||
## copy the default target for this platform to gdk-2.0.pc and gtk+-2.0.pc
|
||||
DEFAULT_GDKTARGET=x11
|
||||
install-data-local:
|
||||
install-data-hook:
|
||||
(cd $(DESTDIR)$(pkgconfigdir) && \
|
||||
test -e gdk-$(DEFAULT_GDKTARGET)-2.0.pc && \
|
||||
test -e gtk+-$(DEFAULT_GDKTARGET)-2.0.pc && \
|
||||
$(LN_S) -f gdk-$(DEFAULT_GDKTARGET)-2.0.pc gdk-2.0.pc && \
|
||||
$(LN_S) -f gtk+-$(DEFAULT_GDKTARGET)-2.0.pc gtk+-2.0.pc) || \
|
||||
test -f gdk-$(DEFAULT_GDKTARGET)-2.0.pc && \
|
||||
test -f gtk+-$(DEFAULT_GDKTARGET)-2.0.pc && \
|
||||
rm -f gdk-2.0.pc && cp -f gdk-$(DEFAULT_GDKTARGET)-2.0.pc gdk-2.0.pc && \
|
||||
rm -f gtk+-2.0.pc && cp -f gtk+-$(DEFAULT_GDKTARGET)-2.0.pc gtk+-2.0.pc) || \
|
||||
(cd $(DESTDIR)$(pkgconfigdir) && \
|
||||
$(LN_S) -f gdk-$(GDKTARGET)-2.0.pc gdk-2.0.pc && \
|
||||
$(LN_S) -f gtk+-$(GDKTARGET)-2.0.pc gtk+-2.0.pc)
|
||||
rm -f gdk-2.0.pc && cp -f gdk-$(GDKTARGET)-2.0.pc gdk-2.0.pc && \
|
||||
rm -f gtk+-2.0.pc && cp -f gtk+-$(GDKTARGET)-2.0.pc gtk+-2.0.pc)
|
||||
|
||||
dist-hook: gtk+.spec
|
||||
if test -e $(srcdir)/INSTALL.in && test -e $(srcdir)/README.in ; then \
|
||||
if test -f $(srcdir)/INSTALL.in && test -f $(srcdir)/README.in ; then \
|
||||
CONFIG_FILES="INSTALL:$(srcdir)/INSTALL.in README:$(srcdir)/README.in" \
|
||||
CONFIG_HEADERS= \
|
||||
$(SHELL) config.status \
|
||||
@@ -151,9 +161,6 @@ dist-hook: gtk+.spec
|
||||
fi \
|
||||
&& cp gtk+.spec $(distdir)
|
||||
|
||||
m4datadir = $(datadir)/aclocal
|
||||
m4data_DATA = gtk-2.0.m4
|
||||
|
||||
.PHONY: files release sanity snapshot
|
||||
|
||||
files:
|
||||
@@ -177,3 +184,28 @@ sanity:
|
||||
|
||||
snapshot:
|
||||
$(MAKE) dist distdir=$(PACKAGE)-snap`date +"%Y%m%d"`
|
||||
|
||||
|
||||
# This is a version of the automake-1.4 distcheck rule modified
|
||||
# to pass --enable-gtk-doc to ./configure
|
||||
#
|
||||
mydistcheck: dist
|
||||
-rm -rf $(distdir)
|
||||
GZIP=$(GZIP_ENV) $(TAR) zxf $(distdir).tar.gz
|
||||
mkdir $(distdir)/=build
|
||||
mkdir $(distdir)/=inst
|
||||
dc_install_base=`cd $(distdir)/=inst && pwd`; \
|
||||
cd $(distdir)/=build \
|
||||
&& ../configure --srcdir=.. --prefix=$$dc_install_base --enable-gtk-doc \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) check \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) install \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) installcheck \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) dist
|
||||
-rm -rf $(distdir)
|
||||
@banner="$(distdir).tar.gz is ready for distribution"; \
|
||||
dashes=`echo "$$banner" | sed s/./=/g`; \
|
||||
echo "$$dashes"; \
|
||||
echo "$$banner"; \
|
||||
echo "$$dashes"
|
||||
|
375
NEWS
375
NEWS
@@ -1,3 +1,378 @@
|
||||
Overview of Changes in GTK+ 2.0.2
|
||||
=================================
|
||||
|
||||
* GtkTreeView cursor movement fixes [Kristian Rietveld]
|
||||
* GtkTreeModelSort iterator stamp fixes [Kristian Rietveld]
|
||||
|
||||
Overview of Changes in GTK+ 2.0.1
|
||||
=================================
|
||||
|
||||
* GtkTreeView fixes and performance improvements
|
||||
[Kristian Rietveld, Jonathan Blandford, Mike Piepe, Dave Camp]
|
||||
* GtkTextView fixes [Havoc Pennington]
|
||||
* Fix problems with accelerators on Solaris [Padraig O'Briain]
|
||||
* Some fixes for key bindings on keypad keys [Owen Taylor]
|
||||
* Fix problem with RENDER use on big endian machines
|
||||
[Owen Taylor, with help from Tuomas Kuosmanen]
|
||||
* Win32 fixes, especially dashed line drawing
|
||||
[Tor Lillqvist, Hans Breuer]
|
||||
* Compile with -D_REENTRANT when appropriate [Sven Numann]
|
||||
* Compiler warning cleanups [Erwann Chenede]
|
||||
* Fix handling of font-name XSETTING [Richard Hestilow]
|
||||
* Make linux-fb backend compile again [Carlo E. Prelz, Alex Larsson]
|
||||
* Fix problems with inappropriate menu scroll arrows [Owen]
|
||||
* Stock icon improvements [Jakub Steiner, Tuomas]
|
||||
* Much work on pixbuf loader robustness [Matthias Clasen]
|
||||
* Documentation improvements [Matthias, Vitaly Tiskkov]
|
||||
* Fix some crashes in GtkWindow accelerator handling code
|
||||
[Dave Camp, Matt Wilson]
|
||||
* Misc bug fixes
|
||||
|
||||
Other contributors: Jacob Berkman, Dennis Björklund, Seth Burgess,
|
||||
Murray Cumming, Johan Dahlin, John Ellis, Kang Jeong-He,
|
||||
James Henstridge, Richard Hult, Thomas Leonard, LEE Sau Dan,
|
||||
Alexey A. Malyshev, Mark McLoughlin, Michael Meeks, Sven Neumann,
|
||||
Andras Salamon, Soeren Sandmann, Dan Winship, Yao Zhang
|
||||
|
||||
Overview of Changes in GTK+ 2.0.0
|
||||
=================================
|
||||
|
||||
* GtkTreeView fixes [Jonathan Blandford, Kristian Rietveld, Darin Adler]
|
||||
* Build fixes [Anders Carlsson, Tor Lillqvist, Manish Singh]
|
||||
* Bug fixes. [Thomas Leonard, Owen Taylor]
|
||||
|
||||
Overview of Changes in GTK+ 2.0.0 rc1
|
||||
=====================================
|
||||
|
||||
* GtkTreeView fixes [Kristian Rietveld, Jonathan Blandford, Richard Hult]
|
||||
* Text widget fixes [Havoc Pennington]
|
||||
* Efficiency fixes when using Xft [Owen Taylor]
|
||||
* Key handling fixes and other fixes for Win32 [Hans Breuer, Tor Lillqvist]
|
||||
* Try to fix key handling without XKEYBOARD extension [Owen]
|
||||
* Documentation fixes and improvements
|
||||
[Matthias Clasen, Alexey Malyshev, Akira Tagoh, Vitaly Tishkov]
|
||||
* Widget drawing improvments [Soeren Sandmann]
|
||||
* Allow cycling between multiple menu bars with <Control>Tab [Owen]
|
||||
* Try to build libraries with only shared library dependencies on Xft to
|
||||
deal with transition to Xft2 [Owen]
|
||||
* Portability fixes [Owen, Miroslaw Dobrzanski-Neumann]
|
||||
* Don't use red as the default cursor color [Owen]
|
||||
* Bug fixes, bug fixes, bug fixes.
|
||||
|
||||
Other contributors: Darin Adler, Jacob Berkman, Kevin Breit, Hans Breuer,
|
||||
Anders Carlsson, Damon Chaplin, Finlay Dobbie, Jody Goldberg,
|
||||
Andreas J. Guelzow, Scott Guilbeaux, Vlad Harchev, James Henstridge,
|
||||
Tim Janik, Satyajit Kanungo, Charles Kerr, Sergey Kuzminov, Miles Lane,
|
||||
Alexander Larsson, Paolo Maggi, Skip Montaro, Jan Mynarik, Sven Neumann,
|
||||
Padraig O'Briain, Narayani Pattipati, Mark Patton, Havoc Pennington,
|
||||
Ettore Perazzoli, Guillermo S. Romero, Manish Singh, Morten Welinder
|
||||
|
||||
Overview of Changes in GTK+ 1.3.15
|
||||
==================================
|
||||
|
||||
* New stock and improved icon images
|
||||
[Tuomas Kuosmanen, Jakub Steiner, Anders Carlsson]
|
||||
* Widget drawing improvements for check and radio buttons,
|
||||
spinbuttons [Soeren Sandmann]
|
||||
* Clean up module search path algorithm, use GTK_PATH [Owen Taylor]
|
||||
* Add GtkSetting for font name. [Richard Hestilow]
|
||||
* Much improved key matching code, accelerators work independent
|
||||
of group [Owen]
|
||||
* Make mnemonics work for embedded GtkPlug widgets [Owen]
|
||||
* Keynav improvements for GtkTreeView [Kristian Rietveld]
|
||||
* Fix gtk_tree_view_scroll_to_cell() [Jonathan Blandford]
|
||||
* Rename gtk_tree_view_get_iter_root() and gtk_tree_path_new_root()
|
||||
to gtk_tree_view_get_iter_first() and gtk_tree_path_new_first(),
|
||||
add compatibility macros.
|
||||
* GtkTreeView bug fixes [Kristian, Anders, Damon Chaplin]
|
||||
* GtkTextView bug fixes [Havoc Pennington]
|
||||
* Pad class structures for future binary compatibility [Owen]
|
||||
* Tutorial improvements [Sven Neumann, Matthias Clasen]
|
||||
* Fixes for MULTIPLE selection target [Gregory Merchan, Owen]
|
||||
* Fix problems with initial widget size [Owen]
|
||||
* AIX compilation fixes [Miroslaw Dobrzanski-Neumann]
|
||||
* Win32 fixes [Hans Breuer, Tor Lillqvist]
|
||||
* Miscellaneous bug fixes
|
||||
|
||||
Other contributors: David L. Cooper, Eric Fischer, Jody Goldberg,
|
||||
Satajyit Kanungo, Thomas Leonard, Mark Patton, Manish Singh,
|
||||
Nicolas Setton
|
||||
|
||||
Overview of Changes in GTK+ 1.3.14
|
||||
==================================
|
||||
|
||||
* Keyboard focus improvements [Owen Taylor]
|
||||
* Code cleanup [Matthias Clasen, Manish Singh, Darin Adler]
|
||||
* Fix accidentally exported variables [Mark McLoughlin]
|
||||
* GtkTreeView fixes [Jonathan Blandford, Kristian Rietveld, John Harper, Darin]
|
||||
* Default to yellow tooltips [Owen]
|
||||
* RC file fixes for reloading, priorities [Owen, Matthias]
|
||||
* GtkMenu behavior improvements and bug fixes [Owen, Arnaud Charlet]
|
||||
* GtkTextView fixes [Havoc Pennington, Daniel Elstner, Dennis Bjorklund]
|
||||
* Improve keynav for paned widgets, tooltips, spin buttons, notebooks,
|
||||
scrolled windows [Soeren Sandmann, Padraig, Owen]
|
||||
* Add Emacs/Default key themes [Owen]
|
||||
* Win32 fixes [Hans Breuer, Tor Lillqvist]
|
||||
* Ethiopic input methods [Daniel Yacob]
|
||||
* Opaque paned window resizing [Soeren]
|
||||
* Tweak table expansion behavior [Tim Janik]
|
||||
* Fix GtkCalendar focus drawing [Bill Haneman]
|
||||
* Allow themeable cursor thickness [Bill]
|
||||
* Start of fixing of tutorial for GTK+-2.0 [Matthias]
|
||||
* Add a ::adjust-bounds signal to GtkRange to allow spreadsheat style
|
||||
scrollbars. [Jody Goldberg]
|
||||
* Add the ability to turn on multiple selection for GtkFileSel [Manish]
|
||||
* Bug fixes
|
||||
|
||||
Other contributors: Jacob Berkman, Padraig O'Briain, Anders Carlsson,
|
||||
Johan Dahlin, Richard Hult, Stefan Kost, Alex Larsson, Thomas Leonard,
|
||||
Paolo Maggi, Alexey Malyshev, Federico Mena Quintero, Skip Montaro,
|
||||
Sven Neumann, Havoc Pennington, Laszlo Peter, Christian Rose, Joe Shaw,
|
||||
Kevin Vandersloot, Morten Welinder, Peter Williams
|
||||
|
||||
Overview of Changes in GTK+ 1.3.13
|
||||
==================================
|
||||
|
||||
* Tree view fixes. [Kristian Rietveld, Jonathan Blandford, Anders Carlsson]
|
||||
* Tree view support for low-vision themes [Bill Haneman]
|
||||
* Text view bug fixes. [Havoc Pennington]
|
||||
* Win32 fixes and improvements. [Tor Lillqvist, Hans Breuer,
|
||||
Archaeopteryx Software]
|
||||
* Documentation improvements [Matthias Clasen, Havoc Pennington]
|
||||
* Accelerate alpha compositing using RENDER extension if present,
|
||||
and optimize the non-RENDER case a lot. [Owen Taylor]
|
||||
* Add support for "optional keybindings" (action signal returns FALSE) [Owen]
|
||||
* Fixed the infamous changing directory deletes filename bug
|
||||
[Owen and a cast of thousands]
|
||||
* Add mouse cursor hiding for text widgets [Anders Carlsson]
|
||||
* Simple Hangul input module [Yusuke Tabata]
|
||||
* Removed the scary startup warning.
|
||||
* GdkPixbuf pixel handling fixes [Owen, Michael Hore, Jim Cape]
|
||||
* Converted GtkFileSelection and GtkFontSelection to use GtKTreeView widgets
|
||||
instead of the deprecated GtkCList [Owen]
|
||||
* gtkhsv.h was installed by mistake, fixed that. [reported by Ross Burton]
|
||||
* gdk_pixbuf_render_to_drawable() now also handles alpha pixbufs.
|
||||
* Made Gtkimage draw GtkPixmap, GtkImage, GdkPixbuf insensitive, prelighted,
|
||||
etc. [Havoc, Owen]
|
||||
* Marked gtk_item_factory_path_from_widget() G_CONST_RETURN. [Matt Wilson]
|
||||
* gtk_image_menu_item_new_from_stock() now falls back to
|
||||
new_with_mnemonic, for consistency with gtk_button_new_from_stock()
|
||||
[Havoc Pennington]
|
||||
* GdkModifierType is now consistently used for modifier mask parameters
|
||||
[Mark Patton]
|
||||
* gtk_widget_set_accel_path() is now publically exported.
|
||||
|
||||
Other contributors: Darin Adler, Jeffrey Baker, Damon Chaplin, Brian Cameron,
|
||||
Murray Cumming, James Henstridge, Jacob Berkman, Arnaud Charlet, Jeff Franks,
|
||||
Jeff Garzik, Jody Goldberg, Diego Gonzalez, Melvin Hadasht, Raja Harinath,
|
||||
Tim Janik, Mike Kestner, Mathieu Lacage, Alex Larsson, Ryan Lovett,
|
||||
Mark McLoughlin, Sven Neumann, Padraig O'Briain, Xavier Ordoquy, Chris Phelps,
|
||||
Detlef Reichl, Guillermo S. Romero, Federico Mena Quintero, Manish Singh,
|
||||
HideToshi Tajima, Vitaly Tishkov, Jon Trowbridge, Sergey Vlasov.
|
||||
|
||||
Overview of Changes in GTK+ 1.3.12
|
||||
==================================
|
||||
|
||||
* Fix problems with PNG saving [Michael Natterer]
|
||||
* Cleanups of deprecated usages [Sebastian Wilhelmi]
|
||||
* Win32 fixes [Tor Lillqvist]
|
||||
* Documentation improvements [Matthias Clasen, Havoc Pennington,
|
||||
Vitaly Tishkov]
|
||||
* Frame buffer port fixes [Manish Singh]
|
||||
* GtkTextView bug fixes [Havoc Pennington, Chris Phelps]
|
||||
* Menu behavior improvements [Kristian Rietveld]
|
||||
* Make focus line width configurable, focus color work on
|
||||
dark themes. [Bill Haneman, Owen Taylor]
|
||||
* Add state argument to gtk_paint_focus() [Bill]
|
||||
* Added incremental revalidation to tree view, for better apparent speed
|
||||
[Jonathan Blandford]
|
||||
* Remove useless gtk_tree_view_column_cell_event() [Jonathan]
|
||||
* Display XIM status in a separate window [HideToshi Tajima]
|
||||
* Add GDK_DEBUG=nograbs to disable pointer, keyboard grabs [Jacob Berkman]
|
||||
* Add menu of Unicode control characters to GtkEntry, GtkTextView
|
||||
[Dov Grobgeld, Havoc]
|
||||
* Pass key releases along to input methods [Owen]
|
||||
* Many bug fixes
|
||||
|
||||
Other contributors: Darin Adler, Fabrice Bellet, Chris Blizzard,
|
||||
Hans Breuer, Anders Carlsson, Damon Chaplin, Murray Cumming, Jeff Franks,
|
||||
James Henstridge, Tim Janik, Alex Larsson, George Lebl, Kjartan, Maraas,
|
||||
Sven Neumann, Seth Nickell, Padraig O'Briain, Soeren Sandmann, Manish Singh,
|
||||
Matt Wilson
|
||||
|
||||
Overview of Changes in GTK+ 1.3.11
|
||||
==================================
|
||||
|
||||
* Massive rework of accelerator API and implementation (Tim Janik)
|
||||
* Major fixes to resizing and redrawing to eliminate hysteresis
|
||||
and optimize. (Owen Taylor, Soeren Sandmann)
|
||||
* Make many widgets NO_WINDOW to improve appearance and reduce
|
||||
drawing overhead (Owen)
|
||||
* Text view fixes (Havoc Pennington)
|
||||
* Make child widgets in GtkTextView work (Havoc)
|
||||
* GtkTreeModelSort fixage (Jonathan Blandford, Kristian Rietveld)
|
||||
* Clean up GtkTreeView drag and drop support (Owen)
|
||||
* Misc tree view fixes and improvements (Jonathan, Kristian, Anders, Matt Wilson)
|
||||
* Add gtk_window_get/set_focus(), gtk_window_set_default() as public
|
||||
functions (Owen, Damian Ivereigh)
|
||||
* Fixes to GtkPlug/GtkSocket (Michael Meeks, Owen)
|
||||
* Change button ordering in standard dialogs to correspond to
|
||||
GNOME useability project proposal (Gregory Merchan)
|
||||
* Add support for context sensitivity in input methods (Owen)
|
||||
* Hook up gtk_im_context_set_use_preedit() (Hidetoshi Tajima)
|
||||
* Fix gdk_window_scroll() and other aspects of big windows (Owen)
|
||||
* Remove need for X connection for class initialization (Jacob Berkman)
|
||||
* Propagate key events to parents of focused widget (Owen)
|
||||
* Don't export normal GTK+ marshalers, export deprecated compat marshalers (Owen)
|
||||
* Many Win32 Fixes and improvements (Hans Breuer, Tor Lillqvist)
|
||||
* Bug and documentation fixing (Matthias Clasen, Anders Carlsson,
|
||||
Jacob Berkman, others.)
|
||||
|
||||
Other Contributors:
|
||||
Darin Adler, Marius Andreiana, Erwann Chenede, Murray Cumming, Janet Davis,
|
||||
Daniel Egger, Daniel Elstner, Jeff Franks, Alex Larsson, George Lebl,
|
||||
Sergey Kuzminov, Eric Lemings, Arkadiusz Miskiewicz, Padraig O'Briain, Sven Neumann,
|
||||
Kristian Rietveld, Nicolas Setton, Manish Singh, Vitaly Tishkov, Sebastian Wilhelmi,
|
||||
Michael Natterer
|
||||
|
||||
Overview of Changes in GTK+ 1.3.10
|
||||
==================================
|
||||
|
||||
* GtkTextView fixes [Havoc Pennington]
|
||||
* GtkTreeView fixes and improvements [Jonathan Blandford, Kristian,
|
||||
Manish Singh, Joshua Pritikin, Oleg Maiboroda, James Henstridge]
|
||||
* gtkdemo improvements [Kristian Rietveld]
|
||||
* Drag and drop fixes to generic code and widgets
|
||||
[Owen Taylor, Damian Ivereigh]
|
||||
* Documentation improvement [Havoc Pennington, Matthias Clasen]
|
||||
* Spelling fixes [Jacob Berkman]
|
||||
* Move signals to the GtkEditable interface [Kristian]
|
||||
* Further stock image improvements [Jakub Steiner]
|
||||
* Support text chunks for the PGN loader, add gdk_pixbuf_get_option()
|
||||
[Sven Neumann]
|
||||
* Rename gdk_pixbuf_new_from_stream back to new_from_inline [Owen]
|
||||
* Automatically call setlocale(), unless explictely disabled [Owen]
|
||||
* Property addition to various widgets [Michael Meeks, Owen]
|
||||
* Support building with automake-1.4 [James]
|
||||
* Make GtkRadioButton groups act as a single focus point [Owen]
|
||||
* Move gdk_window_lookup etc. to be cross-platform [Matthias]
|
||||
* Draw spinbuttons variably sized [Kristian]
|
||||
* Separate GdkAtom out from X atoms for compatibility with future
|
||||
multihead changes [Owen]
|
||||
* Require gdk_threads_init() to be explicitly called instead
|
||||
of piggybacking off of g_thread_init(). [Owen]
|
||||
* Improvements to text-view/label/entry popup menus [Damian, Jacob, Owen]
|
||||
* Bug fixes and cleanup [Matthias, others]
|
||||
|
||||
Other Contributors:
|
||||
Mark McLoughin, Mikael Hermansson, Soeren Sandmann, Anders Carlsson,
|
||||
Tim Janik, Murray Cumming, Hidetoshi Tajima, Padraig O'Briain,
|
||||
Hans Breuer, Vitaly Tishkov, Dov Grobgeld
|
||||
|
||||
|
||||
Overview of Changes in GTK+ 1.3.9
|
||||
=================================
|
||||
|
||||
* Add editable text cells to GtkTreeView.
|
||||
Keynav, drawing fixes in GtkTreeView [Jonathan Blandford]
|
||||
* Text widget no longer always has a \n in it. [Havoc Pennington]
|
||||
* Text widget bug fixes [Havoc, Dov Grobgeld, Hidetoshi Tajima]
|
||||
* Allow -1 for width/height in gdk_pixbuf_render_*(). [Matthias Clasen]
|
||||
* Minor fix for major resizing problems in recent releases [Owen Taylor]
|
||||
* Restore ability to set _set properties to TRUE for
|
||||
GtkCellRendererText, GtkTextTag [Owen]
|
||||
* Cursor drawing improvements [Owen]
|
||||
* Win32 fixes [Hans Breuer]
|
||||
* Mark various functions as deprecated or private.
|
||||
* Misc bug fixes, portability fixes, and cleanups.
|
||||
|
||||
Other Contributors:
|
||||
Vitaly Tishkov, Christian Rose, Frank Belew, Jeff Franks, Sven Neumann,
|
||||
Kristian Rietveld, Vitaly Tishkov, Joshua N. Pritikin, Matt Wilson,
|
||||
James Henstridge, Detlef Reichl
|
||||
|
||||
Overview of Changes in GTK+ 1.3.8
|
||||
=================================
|
||||
|
||||
* GtkTreeView and GtkTreeModel API cleanups/improvements [Jrb]
|
||||
* GtkOptionMenu scrollwheel support [Alex]
|
||||
* GtkModule search paths [Owen]
|
||||
* Documenatation updates [Havoc,Jrb]
|
||||
* Major Gdk cleanup [Owen]
|
||||
* Miscellaneous other fixes/cleanups
|
||||
|
||||
Other Contributors:
|
||||
Joshua N Pritikin, Padraig O'Briain, Jakub Steiner, Matthias Clasen,
|
||||
Matt Wilson, James Henstridge
|
||||
|
||||
Overview of Changes in GTK+ 1.3.7
|
||||
=================================
|
||||
|
||||
* Many Pixbuf (loader) improvements [Matthias Clasen, Soeren Sandmann]
|
||||
* Added publically installed utility gdk-pixbuf-csource to generate
|
||||
inlined pixbufs in C source code [Tim Janik]
|
||||
* Optional movement of button children on press [Soeren, Owen Taylor]
|
||||
* Interactive searching in GtkTreeView [Kristian Rietveld]
|
||||
* Sorting/ordering improvements for GtkTreeView [Kris, Jonathan Blandford]
|
||||
* Animation of expander motion for GtkTreeView [Anders Carlsson]
|
||||
* Lots of misc GtkTreeView fixes and improvements [Jonathan]
|
||||
* New/improved stock icons [Jakub Steiner]
|
||||
* Code and API rework for window resizing [Havoc Pennington]
|
||||
* Converted accel groups to GObject [James Henstridge]
|
||||
* More property support improvements
|
||||
* Add facility for "secondary" buttons in
|
||||
GtkButtonBox/GtkDialog [Gregory Merchan]
|
||||
* Disentangled child visability from MAPPED state [Owen]
|
||||
* Plug/Socket improvements and port to the XEMBED protocol [Owen]
|
||||
* Added priorities for styles in RC files,
|
||||
support multiple parse contents [Owen]
|
||||
* Made GdkVisual and GdkDevice GObjects [Alexander Larsson]
|
||||
* Key binding improvements [Havoc]
|
||||
* Added GtkWidget::event-after signal since normal event handling
|
||||
is now aborted as soon as a handler returned TRUE [Tim]
|
||||
* Dnd fixes and improved icon support [Owen]
|
||||
* Removed GtkPacker widget
|
||||
* Fixing missing paired getters/setters [Kris]
|
||||
* Nuked remaining GtkArg cruft, implemented container/child properties [Tim]
|
||||
* Added window grab groups [Owen]
|
||||
* Many frame buffer improvements [Alex]
|
||||
* Win32 fixes and improvements [Hans Breuer]
|
||||
* Warning fixes [Darin Adler]
|
||||
* Miscellaneous bug and API fixes [Matthias et. al]
|
||||
|
||||
Other Contributors:
|
||||
Joshua N Pritikin, Hidetoshi Tajima, Manish Singh, ERDI Gergo, Jens Finke,
|
||||
Chema Celorio, Lee Mallabone, Vitaly Tishkov, Sebastian Wilhelmi,
|
||||
Nicola Girardi, Sven Neumann, Padraig O'Briain, Michael Natterer,
|
||||
Suresh Chandrasekharan, Jonas Borgström, Jay Cox, Michael Meeks,
|
||||
Mathias Hasselmann, Peter Williams, Thomas Broyer, Kjartan Maraas,
|
||||
Joel Becker, Jeff Franks, Brian Cameron, Skip Montanaro
|
||||
|
||||
Overview of Changes in GTK+ 1.3.6
|
||||
=================================
|
||||
|
||||
* Properly renders strikethrough text
|
||||
* win32 fixes
|
||||
* Added "scale" property to GtkTextTag and GtkCellRendererText to do
|
||||
relative font scaling
|
||||
* Added "format_value" signal to GtkScale to reformat value text
|
||||
* framebuffer fixes
|
||||
* Property support added to lots of widgets
|
||||
* Many GtkTreeView new features and API/implementation fixes
|
||||
* Lots of new_with_mnemonic() convenience functions
|
||||
* Change GtkImageMenuItem API to be more consistent/useful
|
||||
* Added lots of new stock items/icons
|
||||
* Rewrote GtkRange/GtkScale/GtkScrollbar, includes support for
|
||||
enabling/disabling extra scrollbar stepper arrows in gtkrc so NeXT
|
||||
themes won't need broken hacks
|
||||
* Convenience API for GtkRange similar to the one added to GtkSpinButton
|
||||
a while back
|
||||
* Make menubar/toolbar work properly with xthickness/ythickness of 1 or 0,
|
||||
and move some attributes from program settings to user settings.
|
||||
Allows nice 1-pixel-bevel themes.
|
||||
* Moved ::focus virtual function from GtkContainer to GtkWidget
|
||||
* Plenty of bug fixes
|
||||
|
||||
Overview of Changes in GTK+ 1.3.5
|
||||
=================================
|
||||
|
||||
|
149
README
149
README
@@ -1,10 +1,15 @@
|
||||
General Information
|
||||
===================
|
||||
|
||||
This is GTK+ version 1.3.5. GTK+, which stands for the Gimp ToolKit,
|
||||
is a library for creating graphical user interfaces for the X Window
|
||||
System. It is designed to be small, efficient, and flexible. GTK+ is
|
||||
written in C with a very object-oriented approach.
|
||||
This is GTK+ version 2.0.2. GTK+ is a multi-platform toolkit for
|
||||
creating graphical user interfaces. Offering a complete set of widgets,
|
||||
GTK+ is suitable for projects ranging from small one-off projects to
|
||||
complete application suites.
|
||||
|
||||
GTK+ is free software and part of the GNU Project. However, the
|
||||
licensing terms for GTK+, the GNU LGPL, allow it to be used by all
|
||||
developers, including those developing proprietary software, without any
|
||||
license fees or royalties.
|
||||
|
||||
The official ftp site is:
|
||||
ftp://ftp.gtk.org/pub/gtk
|
||||
@@ -20,12 +25,100 @@ Installation
|
||||
|
||||
See the file 'INSTALL'
|
||||
|
||||
GTK+-2.0.0 Specific Notes
|
||||
=========================
|
||||
|
||||
* The default configuration of GTK+ has been stream-lined to reduce
|
||||
confusion on the part of new users or users coming from other
|
||||
environments. Users used to older versions of GTK+ may want to make
|
||||
some adjustments to the default configuration.
|
||||
|
||||
- Emacs keybindings such as Control-A and Control-E to move to the
|
||||
ends of lines are not enabled by default in the editing widgets. To
|
||||
turn on Emacs keybindings, add the line:
|
||||
|
||||
gtk-key-theme-name = "Emacs"
|
||||
|
||||
To your ~/.gtkrc-2.0
|
||||
|
||||
- Editing of menu accelerators by pressing an accelerator over the
|
||||
menu item is disabled by default. To enable, it, add:
|
||||
|
||||
gtk-can-change-accels = 1
|
||||
|
||||
to your ~/.gtkrc-2.0
|
||||
|
||||
- To improve useability for keyboard operation, GTK+ now selects the
|
||||
contents of an entry when tabbing into it or when it is focused on
|
||||
initial window map. To disable this behavior, add:
|
||||
|
||||
gtk-entry-select-on-focus = 0
|
||||
|
||||
to your ~/.gtkrc-2.0
|
||||
|
||||
* The GTK+ libraries use an '_' prefix to indicate private symbols that
|
||||
must not be used by applications. The intention was not to export
|
||||
symbols beginning with prefixes such as _gtk, _gdk, and _pango from
|
||||
the libraries at all, but due to a bug in libtool, they are actually
|
||||
exported at the moment on some platforms (including Linux).
|
||||
Applications that use these private symbols _will_ break when
|
||||
this bug is fixed.
|
||||
|
||||
* The Xft library that GTK+ uses to display anti-aliased fonts will
|
||||
undergo a major version revision in the next few months. To deal with
|
||||
this, by default, GTK+ and Pango are built so that applications will
|
||||
not have explicit dependencies on version 1 on Xft. To make sure that
|
||||
your application will be binary compatible with future versions of
|
||||
GTK+:
|
||||
|
||||
- Do not configure Pango or GTK+ with the --enable-static or
|
||||
--enable-explicit otions, since they will cause dependencies on
|
||||
Xft version 1.
|
||||
|
||||
- Do not use Xft directly in your applicatons.
|
||||
|
||||
* There is a bug in the Xft library in XFree86-4.1 and possibly previous
|
||||
versions that causes random crashes when using the Pango Xft
|
||||
backend. If you want to use Xft fonts, you should upgrade to
|
||||
XFree86-4.2.
|
||||
|
||||
* Xft support is not on by default. To turn it on set the environment
|
||||
variable GDK_USE_XFT to '1'
|
||||
|
||||
GDK_USE_XFT=1
|
||||
export GDK_USE_XFT
|
||||
|
||||
* The gdk_pixbuf_xlib library included in the contrib/ directory of GTK+
|
||||
is provided on a as-is basis and has not been tested at all. No
|
||||
guarantees about the degree of workingness or about future
|
||||
compatibility are provided.
|
||||
|
||||
* There are known problems with some of the image loaders in the
|
||||
gdk-pixbuf library included in GTK+ where corrupted images can cause
|
||||
crashes and conceivably worse problems. Until these problems are fixed
|
||||
(we hope to have this done for 2.0.1), gdk-pixbuf should not be used
|
||||
to load untrusted data.
|
||||
|
||||
* The assumption of GLib and GTK+ by default is that filenames on the
|
||||
filesystem are encoded in UTF-8 rather than the encoding of the locale;
|
||||
The GTK+ developers consider that having filenames whose interpretation
|
||||
depends on the current locale is fundamentally a bad idea.
|
||||
|
||||
If you have filenames encoded in the encoding of your locale, then
|
||||
you may want to set the G_BROKEN_FILENAMES environment variable:
|
||||
|
||||
G_BROKEN_FILENAMES=1
|
||||
export G_BROKEN_FILENAMES
|
||||
|
||||
Best integration of GTK+-2.0 with the environment is achieved by
|
||||
using a UTF-8 locale.
|
||||
|
||||
How to report bugs
|
||||
==================
|
||||
|
||||
Bugs should be reported to the GNOME bug tracking system.
|
||||
(http://bugzilla.gnome.org, product gtk+.) You will need
|
||||
to create an account for yourself.
|
||||
Bugs should be reported to the GNOME bug tracking system.
|
||||
(http://bugzilla.gnome.org, product gtk+.) You will need to create an
|
||||
account for yourself.
|
||||
|
||||
In the bug report please include:
|
||||
|
||||
@@ -39,34 +132,32 @@ In the bug report please include:
|
||||
|
||||
* How to reproduce the bug.
|
||||
|
||||
If you can reproduce it with the testgtk program that is built
|
||||
in the gtk/ subdirectory, that will be most convenient. Otherwise,
|
||||
please include a short test program that exhibits the behavior.
|
||||
As a last resort, you can also provide a pointer to a larger piece
|
||||
of software that can be downloaded.
|
||||
If you can reproduce it with the testgtk program that is built in the
|
||||
gtk/ subdirectory, that will be most convenient. Otherwise, please
|
||||
include a short test program that exhibits the behavior. As a last
|
||||
resort, you can also provide a pointer to a larger piece of software
|
||||
that can be downloaded.
|
||||
|
||||
* If the bug was a crash, the exact text that was printed out
|
||||
when the crash occured.
|
||||
* If the bug was a crash, the exact text that was printed out when the
|
||||
crash occured.
|
||||
|
||||
* Further information such as stack traces may be useful, but
|
||||
is not necessary. If you do send a stack trace, and the error
|
||||
is an X error, it will be more useful if the stacktrace
|
||||
is produced running the test program with the --sync command
|
||||
line option.
|
||||
* Further information such as stack traces may be useful, but is not
|
||||
necessary. If you do send a stack trace, and the error is an X error,
|
||||
it will be more useful if the stacktrace is produced running the test
|
||||
program with the --sync command line option.
|
||||
|
||||
Patches
|
||||
=======
|
||||
|
||||
Patches should also be submitted to bugzilla.gnome.org. If the
|
||||
patch fixes an existing bug, add the patch as an attachment
|
||||
to that bug report.
|
||||
Patches should also be submitted to bugzilla.gnome.org. If the patch
|
||||
fixes an existing bug, add the patch as an attachment to that bug
|
||||
report.
|
||||
|
||||
Otherwise, enter a new bug report that describes the patch,
|
||||
and attach the patch to that bug report.
|
||||
Otherwise, enter a new bug report that describes the patch, and attach
|
||||
the patch to that bug report.
|
||||
|
||||
Bug reports containing patches should include the PATCH keyword
|
||||
in their keyword fields. If the patch adds to or changes the GTK
|
||||
programming interface, the API keyword should also be included.
|
||||
Bug reports containing patches should include the PATCH keyword in their
|
||||
keyword fields. If the patch adds to or changes the GTK programming
|
||||
interface, the API keyword should also be included.
|
||||
|
||||
Patches should be in unified diff form. (The -u option to GNU
|
||||
diff.)
|
||||
Patches should be in unified diff form. (The -u option to GNU diff.)
|
||||
|
149
README.in
149
README.in
@@ -1,10 +1,15 @@
|
||||
General Information
|
||||
===================
|
||||
|
||||
This is GTK+ version @GTK_VERSION@. GTK+, which stands for the Gimp ToolKit,
|
||||
is a library for creating graphical user interfaces for the X Window
|
||||
System. It is designed to be small, efficient, and flexible. GTK+ is
|
||||
written in C with a very object-oriented approach.
|
||||
This is GTK+ version @GTK_VERSION@. GTK+ is a multi-platform toolkit for
|
||||
creating graphical user interfaces. Offering a complete set of widgets,
|
||||
GTK+ is suitable for projects ranging from small one-off projects to
|
||||
complete application suites.
|
||||
|
||||
GTK+ is free software and part of the GNU Project. However, the
|
||||
licensing terms for GTK+, the GNU LGPL, allow it to be used by all
|
||||
developers, including those developing proprietary software, without any
|
||||
license fees or royalties.
|
||||
|
||||
The official ftp site is:
|
||||
ftp://ftp.gtk.org/pub/gtk
|
||||
@@ -20,12 +25,100 @@ Installation
|
||||
|
||||
See the file 'INSTALL'
|
||||
|
||||
GTK+-2.0.0 Specific Notes
|
||||
=========================
|
||||
|
||||
* The default configuration of GTK+ has been stream-lined to reduce
|
||||
confusion on the part of new users or users coming from other
|
||||
environments. Users used to older versions of GTK+ may want to make
|
||||
some adjustments to the default configuration.
|
||||
|
||||
- Emacs keybindings such as Control-A and Control-E to move to the
|
||||
ends of lines are not enabled by default in the editing widgets. To
|
||||
turn on Emacs keybindings, add the line:
|
||||
|
||||
gtk-key-theme-name = "Emacs"
|
||||
|
||||
To your ~/.gtkrc-2.0
|
||||
|
||||
- Editing of menu accelerators by pressing an accelerator over the
|
||||
menu item is disabled by default. To enable, it, add:
|
||||
|
||||
gtk-can-change-accels = 1
|
||||
|
||||
to your ~/.gtkrc-2.0
|
||||
|
||||
- To improve useability for keyboard operation, GTK+ now selects the
|
||||
contents of an entry when tabbing into it or when it is focused on
|
||||
initial window map. To disable this behavior, add:
|
||||
|
||||
gtk-entry-select-on-focus = 0
|
||||
|
||||
to your ~/.gtkrc-2.0
|
||||
|
||||
* The GTK+ libraries use an '_' prefix to indicate private symbols that
|
||||
must not be used by applications. The intention was not to export
|
||||
symbols beginning with prefixes such as _gtk, _gdk, and _pango from
|
||||
the libraries at all, but due to a bug in libtool, they are actually
|
||||
exported at the moment on some platforms (including Linux).
|
||||
Applications that use these private symbols _will_ break when
|
||||
this bug is fixed.
|
||||
|
||||
* The Xft library that GTK+ uses to display anti-aliased fonts will
|
||||
undergo a major version revision in the next few months. To deal with
|
||||
this, by default, GTK+ and Pango are built so that applications will
|
||||
not have explicit dependencies on version 1 on Xft. To make sure that
|
||||
your application will be binary compatible with future versions of
|
||||
GTK+:
|
||||
|
||||
- Do not configure Pango or GTK+ with the --enable-static or
|
||||
--enable-explicit otions, since they will cause dependencies on
|
||||
Xft version 1.
|
||||
|
||||
- Do not use Xft directly in your applicatons.
|
||||
|
||||
* There is a bug in the Xft library in XFree86-4.1 and possibly previous
|
||||
versions that causes random crashes when using the Pango Xft
|
||||
backend. If you want to use Xft fonts, you should upgrade to
|
||||
XFree86-4.2.
|
||||
|
||||
* Xft support is not on by default. To turn it on set the environment
|
||||
variable GDK_USE_XFT to '1'
|
||||
|
||||
GDK_USE_XFT=1
|
||||
export GDK_USE_XFT
|
||||
|
||||
* The gdk_pixbuf_xlib library included in the contrib/ directory of GTK+
|
||||
is provided on a as-is basis and has not been tested at all. No
|
||||
guarantees about the degree of workingness or about future
|
||||
compatibility are provided.
|
||||
|
||||
* There are known problems with some of the image loaders in the
|
||||
gdk-pixbuf library included in GTK+ where corrupted images can cause
|
||||
crashes and conceivably worse problems. Until these problems are fixed
|
||||
(we hope to have this done for 2.0.1), gdk-pixbuf should not be used
|
||||
to load untrusted data.
|
||||
|
||||
* The assumption of GLib and GTK+ by default is that filenames on the
|
||||
filesystem are encoded in UTF-8 rather than the encoding of the locale;
|
||||
The GTK+ developers consider that having filenames whose interpretation
|
||||
depends on the current locale is fundamentally a bad idea.
|
||||
|
||||
If you have filenames encoded in the encoding of your locale, then
|
||||
you may want to set the G_BROKEN_FILENAMES environment variable:
|
||||
|
||||
G_BROKEN_FILENAMES=1
|
||||
export G_BROKEN_FILENAMES
|
||||
|
||||
Best integration of GTK+-2.0 with the environment is achieved by
|
||||
using a UTF-8 locale.
|
||||
|
||||
How to report bugs
|
||||
==================
|
||||
|
||||
Bugs should be reported to the GNOME bug tracking system.
|
||||
(http://bugzilla.gnome.org, product gtk+.) You will need
|
||||
to create an account for yourself.
|
||||
Bugs should be reported to the GNOME bug tracking system.
|
||||
(http://bugzilla.gnome.org, product gtk+.) You will need to create an
|
||||
account for yourself.
|
||||
|
||||
In the bug report please include:
|
||||
|
||||
@@ -39,34 +132,32 @@ In the bug report please include:
|
||||
|
||||
* How to reproduce the bug.
|
||||
|
||||
If you can reproduce it with the testgtk program that is built
|
||||
in the gtk/ subdirectory, that will be most convenient. Otherwise,
|
||||
please include a short test program that exhibits the behavior.
|
||||
As a last resort, you can also provide a pointer to a larger piece
|
||||
of software that can be downloaded.
|
||||
If you can reproduce it with the testgtk program that is built in the
|
||||
gtk/ subdirectory, that will be most convenient. Otherwise, please
|
||||
include a short test program that exhibits the behavior. As a last
|
||||
resort, you can also provide a pointer to a larger piece of software
|
||||
that can be downloaded.
|
||||
|
||||
* If the bug was a crash, the exact text that was printed out
|
||||
when the crash occured.
|
||||
* If the bug was a crash, the exact text that was printed out when the
|
||||
crash occured.
|
||||
|
||||
* Further information such as stack traces may be useful, but
|
||||
is not necessary. If you do send a stack trace, and the error
|
||||
is an X error, it will be more useful if the stacktrace
|
||||
is produced running the test program with the --sync command
|
||||
line option.
|
||||
* Further information such as stack traces may be useful, but is not
|
||||
necessary. If you do send a stack trace, and the error is an X error,
|
||||
it will be more useful if the stacktrace is produced running the test
|
||||
program with the --sync command line option.
|
||||
|
||||
Patches
|
||||
=======
|
||||
|
||||
Patches should also be submitted to bugzilla.gnome.org. If the
|
||||
patch fixes an existing bug, add the patch as an attachment
|
||||
to that bug report.
|
||||
Patches should also be submitted to bugzilla.gnome.org. If the patch
|
||||
fixes an existing bug, add the patch as an attachment to that bug
|
||||
report.
|
||||
|
||||
Otherwise, enter a new bug report that describes the patch,
|
||||
and attach the patch to that bug report.
|
||||
Otherwise, enter a new bug report that describes the patch, and attach
|
||||
the patch to that bug report.
|
||||
|
||||
Bug reports containing patches should include the PATCH keyword
|
||||
in their keyword fields. If the patch adds to or changes the GTK
|
||||
programming interface, the API keyword should also be included.
|
||||
Bug reports containing patches should include the PATCH keyword in their
|
||||
keyword fields. If the patch adds to or changes the GTK programming
|
||||
interface, the API keyword should also be included.
|
||||
|
||||
Patches should be in unified diff form. (The -u option to GNU
|
||||
diff.)
|
||||
Patches should be in unified diff form. (The -u option to GNU diff.)
|
||||
|
119
README.win32
119
README.win32
@@ -1,48 +1,95 @@
|
||||
The Win32 port of GTk+ is a work in progress, and not as stable or
|
||||
The Win32 port of GTK+ is a work in progress, and not as stable or
|
||||
correct as the Unix/X11 version. For more information about the Win32
|
||||
port, see http://www.gimp.org/win32/ or
|
||||
http://www.iki.fi/tml/gimp/win32/ .
|
||||
port, and prebuilt runtime and developer packages see
|
||||
http://www.gimp.org/win32/ .
|
||||
|
||||
This (CVS HEAD) version of the Win32 backend does *not* necessarily
|
||||
even compile properly. There is a gtk-1-3-win32-production branch that
|
||||
was branched off from before the addition of the no-flicker and other
|
||||
recent functionality. That is what should be used by "production" code
|
||||
until the CVS HEAD version is useable. (But note, the Win32 backend
|
||||
There is a gtk-1-3-win32-production branch of GTK+ that was branched
|
||||
off from before the addition of the no-flicker and other recent
|
||||
functionality. That is what should be used by "production" code until
|
||||
this CVS HEAD (2.0) version is useable. (But note, the Win32 backend
|
||||
has never been claimed to be "production quality", although it works
|
||||
surprisingly well for the GIMP.)
|
||||
|
||||
To build GTk+ on Win32, you need either gcc-2.95 or later, or the
|
||||
Microsoft compiler and tools. The mingw setup of gcc is preferred, but
|
||||
you can run gcc also under cygwin-b20.1 or later. Compile in
|
||||
gdk\win32, gdk and gtk with `make -f makefile.mingw` (gcc) or `nmake
|
||||
-f makefile.msc` (MSVC). The name makefile.mingw needs an explanation:
|
||||
It refers to the target, not the build environment. As build
|
||||
env<EFBFBD>ronment, only cygwin is tested. GNU Make is definitely needed.
|
||||
Building GTK+ on Win32
|
||||
======================
|
||||
|
||||
See the README.win32 file in the GLib distribution for instructions
|
||||
how to build with gcc.
|
||||
There are two ways to build GTK+ for win32:
|
||||
|
||||
To use GTk+ on Win32, you also need either one of the above mentioned
|
||||
compilers. Other compilers might work, but don't count on it. The
|
||||
same instructions on how to set up a correct version of gcc should
|
||||
also be followed if you want to build applications that use GTk+ with
|
||||
gcc.
|
||||
1) Use the autoconf-generated configure script, and the resulting
|
||||
Makefiles (which use libtool and gcc to do the compilation). I use
|
||||
this myself, but it might be hell to setup correctly.
|
||||
|
||||
Personally I run configure with:
|
||||
CC='gcc -mpentium -fnative-struct' CPPFLAGS='-I/target/include' CFLAGS=-O2 LDFLAGS='-L/target/lib' ./configure --disable-static --prefix=/target --with-gdktarget=win32 --with-wintab=/src/wtkit126 --with-ie55=/src/workshop/ie55_lib --host=i386-pc-mingw32 --enable-maintainer-mode
|
||||
|
||||
It might well be that in order for this to work, you will have to get
|
||||
a bleeding-edge version of libtool for Win32, run libtoolize yourself,
|
||||
and then run autoconf to generate the configure script.
|
||||
|
||||
2) Use the Microsoft compiler, cl and Make, nmake. Say nmake -f
|
||||
makefile.msc in gdk and gtk.
|
||||
|
||||
Alternative 1 also generates Microsoft import libraries (.lib), if you
|
||||
have lib.exe available. It might also work for cross-compilation from
|
||||
Unix.
|
||||
|
||||
There are hand-written makefiles for mingw (look for makefile.mingw in
|
||||
various directories), but those haven't been kept up-to-date, and
|
||||
probably won't work without editing. Sorry. If you make them work
|
||||
again, by all means do submit patches.
|
||||
|
||||
Note that I use method 1 myself. Hans Breuer has been taking care of
|
||||
the MSVC makefiles. At times, we disagree a bit about various issues,
|
||||
and the makefile.msc files might not produce identically named DLLs
|
||||
and import libraries as the "autoconfiscated" makefiles and libtool
|
||||
do.
|
||||
|
||||
Using GTK+ on Win32
|
||||
===================
|
||||
|
||||
To use GTK+ on Win32, you also need either one of the above mentioned
|
||||
compilers. Other compilers might work, but don't count on it. Look for
|
||||
prebuilt developer packages (DLLs, import libraries, headers) on the
|
||||
above website.
|
||||
|
||||
Multi-threaded use of GTK+ on Win32
|
||||
===================================
|
||||
|
||||
Multi-threaded GTK+ programs might work in special simple cases, but
|
||||
not in general. Sorry. If you have all GTK+ and GDK calls in the same
|
||||
thread, it might work. Otherwise, probably not at all. Possible ways
|
||||
to fix this are being investigated.
|
||||
|
||||
Wintab
|
||||
======
|
||||
|
||||
The tablet support uses the Wintab API. The Wintab development kit can
|
||||
be downloaded from http://www.pointing.com. If you don't care for
|
||||
that, undefine HAVE_WINTAB in config.h.win32 and remove references to
|
||||
the wntab32x library from the makefile before building.
|
||||
be downloaded from http://www.pointing.com. Pass the --with-wintab
|
||||
flag to configure if you use that. If you use nmake and you don't care
|
||||
for Wintab, undefine HAVE_WINTAB in config.h.win32 and remove
|
||||
references to the wntab32x library from the makefile before building.
|
||||
|
||||
GTk+ wants to be built with the GNU "intl" library for
|
||||
Libintl
|
||||
=======
|
||||
|
||||
GTK wants to be built with the GNU "intl" library for
|
||||
internationalisation (i18n). Get the version ported to Win32 (not a
|
||||
very big deal) from tml's web site mentioned above. We build the
|
||||
"intl" library as a DLL called gnu-intl.dll (the "gnu" prefix is used
|
||||
to reduce name clash risks). If you don't want any i18n stuff,
|
||||
undefine ENABLE_NLS, HAVE_GETTEXT and HAVE_LIBINTL in the
|
||||
config.h.win32 file, and remove references to the gnu-intl library
|
||||
from the makefiles.
|
||||
very big deal) from the web site mentioned above. The "intl" library
|
||||
as gets built as a DLL called libintl-1.dll. If you don't want any
|
||||
i18n stuff, undefine ENABLE_NLS, HAVE_GETTEXT and HAVE_LIBINTL in the
|
||||
config.h.win32 file, and remove references to the intl library from
|
||||
the makefiles.
|
||||
|
||||
Note that while the GNU gettext package is under the GPL license, the
|
||||
"intl" part of it is also distributed as part of the GNU C library
|
||||
(glibc) where it is under the LGPL license (as is GTk+ or GLib). We
|
||||
want the LGPL licensed version. The code is more or less the same.
|
||||
ActiveIMM
|
||||
=========
|
||||
|
||||
If you want to build a GTK+ that supports ActiveIMM (the Input Method
|
||||
Manager for non-EastAsia locales that can be used on Win9x/NT4), you
|
||||
need the dimm.h header file. That is somewhat difficult to find, but
|
||||
http://msdn.microsoft.com/downloads/samples/internet/wizard/ seems to
|
||||
be a good place to look nowadays. If you use "autoconfiscated" build,
|
||||
pass the --with-ie55 flag to configure specifyin the location of the
|
||||
ie55_lib directory created by downloading the IE5.5 headers and libs
|
||||
from the above URL.
|
||||
|
||||
--Tor Lillqvist <tml@iki.fi>
|
||||
|
13
acconfig.h
13
acconfig.h
@@ -19,7 +19,7 @@
|
||||
#undef GTK_COMPILED_WITH_DEBUGGING
|
||||
|
||||
#undef HAVE_CATGETS
|
||||
#undef HAVE_DIRENT_H
|
||||
#undef HAVE_DIMM_H
|
||||
#undef HAVE_GETTEXT
|
||||
#undef HAVE_IPC_H
|
||||
#undef HAVE_LC_MESSAGES
|
||||
@@ -31,9 +31,13 @@
|
||||
#undef HAVE_SHAPE_EXT
|
||||
#undef HAVE_SYS_SELECT_H
|
||||
#undef HAVE_SYS_TIME_H
|
||||
#undef HAVE_WINSOCK_H
|
||||
#undef HAVE_WINTAB
|
||||
#undef HAVE_XCONVERTCASE
|
||||
#undef HAVE_XFT
|
||||
|
||||
#undef HAVE_SIGSETJMP
|
||||
|
||||
#undef NO_FD_SET
|
||||
|
||||
#undef RESOURCE_BASE
|
||||
@@ -50,6 +54,9 @@
|
||||
/* Define to use shadowfb in the linux-fb port */
|
||||
#undef ENABLE_SHADOW_FB
|
||||
|
||||
/* Define to use a fb manager in the linux-fb port */
|
||||
#undef ENABLE_FB_MANAGER
|
||||
|
||||
#undef XINPUT_NONE
|
||||
#undef XINPUT_GXI
|
||||
#undef XINPUT_XFREE
|
||||
@@ -60,6 +67,10 @@
|
||||
/* Most machines will be happy with int or void. IRIX requires '...' */
|
||||
#undef SIGNAL_ARG_TYPE
|
||||
|
||||
#undef HAS_SOLARIS_XINERAMA
|
||||
#undef HAS_XFREE_XINERAMA
|
||||
#undef HAS_XINERAMA
|
||||
|
||||
#undef GETTEXT_PACKAGE
|
||||
|
||||
/* #undef PACKAGE */
|
||||
|
14
acinclude.m4
14
acinclude.m4
@@ -1,3 +1,17 @@
|
||||
# autoconf 2.13 / 2.50 compatibility macro
|
||||
|
||||
# GLIB_AC_DIVERT_BEFORE_HELP(STUFF)
|
||||
# ---------------------------------
|
||||
# Put STUFF early enough so that they are available for $ac_help expansion.
|
||||
# Handle both classic (<= v2.13) and modern autoconf
|
||||
AC_DEFUN([GLIB_AC_DIVERT_BEFORE_HELP],
|
||||
[ifdef([m4_divert_text], [m4_divert_text([NOTICE],[$1])],
|
||||
[ifdef([AC_DIVERT], [AC_DIVERT([NOTICE],[$1])],
|
||||
[AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)dnl
|
||||
$1
|
||||
AC_DIVERT_POP()])])])
|
||||
|
||||
|
||||
# Macro to add for using GNU gettext.
|
||||
# Ulrich Drepper <drepper@cygnus.com>, 1995.
|
||||
#
|
||||
|
32
autogen.sh
32
autogen.sh
@@ -14,7 +14,7 @@ DIE=0
|
||||
|
||||
have_libtool=false
|
||||
if libtool --version < /dev/null > /dev/null 2>&1 ; then
|
||||
libtool_version=`libtoolize --version | libtoolize --version | sed 's/^[^0-9]*\([0-9.]\+\).*/\1/'`
|
||||
libtool_version=`libtoolize --version | libtoolize --version | sed 's/^[^0-9]*\([0-9.][0-9.]*\).*/\1/'`
|
||||
case $libtool_version in
|
||||
1.4*)
|
||||
have_libtool=true
|
||||
@@ -65,9 +65,11 @@ test $TEST_TYPE $FILE || {
|
||||
exit 1
|
||||
}
|
||||
|
||||
if test -z "$*"; then
|
||||
echo "I am going to run ./configure with no arguments - if you wish "
|
||||
echo "to pass any to it, please specify them on the $0 command line."
|
||||
if test -z "$AUTOGEN_SUBDIR_MODE"; then
|
||||
if test -z "$*"; then
|
||||
echo "I am going to run ./configure with no arguments - if you wish "
|
||||
echo "to pass any to it, please specify them on the $0 command line."
|
||||
fi
|
||||
fi
|
||||
|
||||
case $CC in
|
||||
@@ -77,7 +79,7 @@ esac
|
||||
if test -z "$ACLOCAL_FLAGS"; then
|
||||
|
||||
acdir=`aclocal --print-ac-dir`
|
||||
m4list="glib-2.0.m4 gettext.m4"
|
||||
m4list="glib-2.0.m4 glib-gettext.m4"
|
||||
|
||||
for file in $m4list
|
||||
do
|
||||
@@ -93,18 +95,6 @@ if test -z "$ACLOCAL_FLAGS"; then
|
||||
done
|
||||
fi
|
||||
|
||||
echo "Running gettextize... Ignore non-fatal messages."
|
||||
# Hmm, we specify --force here, since otherwise things dont'
|
||||
# get added reliably, but we don't want to overwrite intl
|
||||
# while making dist.
|
||||
echo "no" | gettextize --copy --force
|
||||
|
||||
#
|
||||
# Really bad hack
|
||||
echo "Munging po/Makefile.in.in"
|
||||
sed s%@PACKAGE@%@GETTEXT_PACKAGE@% < po/Makefile.in.in > po/Makefile.in.in.new
|
||||
mv po/Makefile.in.in.new po/Makefile.in.in
|
||||
|
||||
aclocal $ACLOCAL_FLAGS
|
||||
|
||||
# optionally feature autoheader
|
||||
@@ -114,7 +104,9 @@ automake -a $am_opt
|
||||
autoconf
|
||||
cd $ORIGDIR
|
||||
|
||||
$srcdir/configure --enable-maintainer-mode "$@"
|
||||
if test -z "$AUTOGEN_SUBDIR_MODE"; then
|
||||
$srcdir/configure --enable-maintainer-mode --enable-gtk-doc "$@"
|
||||
|
||||
echo
|
||||
echo "Now type 'make' to compile $PROJECT."
|
||||
echo
|
||||
echo "Now type 'make' to compile $PROJECT."
|
||||
fi
|
1121
config.guess
vendored
1121
config.guess
vendored
File diff suppressed because it is too large
Load Diff
@@ -1,203 +1,289 @@
|
||||
/* config.h.win32. Handcrafted for Microsoft C or mingw */
|
||||
/* config.h.win32.in. Merged from two versions generated by configure for gcc and MSVC. */
|
||||
/* config.h.in. Generated from configure.in by autoheader. */
|
||||
/* acconfig.h
|
||||
This file is in the public domain.
|
||||
|
||||
#if ! (defined(_MSC_VER) || defined(__GNUC__))
|
||||
#error Unrecognized Win32 compiler, edit config.h.win32 by hand
|
||||
#endif
|
||||
Descriptive text for the C preprocessor macros that
|
||||
the distributed Autoconf macros can define.
|
||||
No software package will use all of them; autoheader copies the ones
|
||||
your configure.in uses into your configuration header file templates.
|
||||
|
||||
/* Define if using alloca.c. */
|
||||
/* #undef C_ALLOCA */
|
||||
The entries are in sort -df order: alphabetical, case insensitive,
|
||||
ignoring punctuation (such as underscores). Although this order
|
||||
can split up related entries, it makes it easier to check whether
|
||||
a given entry is in the file.
|
||||
|
||||
/* Define to empty if the keyword does not work. */
|
||||
/* #undef const */
|
||||
|
||||
/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems.
|
||||
This function is required for alloca.c support on those systems. */
|
||||
/* #undef CRAY_STACKSEG_END */
|
||||
|
||||
/* Define if you have alloca, as a function or macro. */
|
||||
#define HAVE_ALLOCA 1
|
||||
#ifndef alloca
|
||||
#ifdef _MSC_VER
|
||||
#define alloca _alloca
|
||||
#elif defined (__GNUC__)
|
||||
#define alloca __builtin_alloca
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Define if you have <alloca.h> and it should be used (not on Ultrix). */
|
||||
/* #undef HAVE_ALLOCA_H */
|
||||
|
||||
/* Define if you have a working `mmap' system call. */
|
||||
/* #undef HAVE_MMAP */
|
||||
|
||||
/* Define to empty, or __inline if that's what your compiler wants. */
|
||||
#define inline __inline
|
||||
|
||||
/* Define to `long' if <sys/types.h> doesn't define. */
|
||||
/* #undef off_t */
|
||||
|
||||
/* Define if you need to in order for stat and other things to work. */
|
||||
/* #undef _POSIX_SOURCE*/
|
||||
|
||||
/* Define as the return type of signal handlers (int or void). */
|
||||
#define RETSIGTYPE void
|
||||
|
||||
/* Define to `unsigned' if <sys/types.h> doesn't define. */
|
||||
/* #undef size_t */
|
||||
|
||||
/* If using the C implementation of alloca, define if you know the
|
||||
direction of stack growth for your system; otherwise it will be
|
||||
automatically deduced at run-time.
|
||||
STACK_DIRECTION > 0 => grows toward higher addresses
|
||||
STACK_DIRECTION < 0 => grows toward lower addresses
|
||||
STACK_DIRECTION = 0 => direction of growth unknown
|
||||
*/
|
||||
/* #undef STACK_DIRECTION */
|
||||
|
||||
/* Define if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
Leave the following blank line there!! Autoheader needs it. */
|
||||
|
||||
|
||||
/* Other stuff */
|
||||
#define ENABLE_NLS 1
|
||||
#define GTK_COMPILED_WITH_DEBUGGING "minimum"
|
||||
#define GTK_COMPILED_WITH_DEBUGGING "yes"
|
||||
|
||||
/* #undef HAVE_CATGETS */
|
||||
/* #undef HAVE_DIRENT_H */
|
||||
/* #undef HAVE_DIMM_H */
|
||||
#define HAVE_GETTEXT 1
|
||||
/* #undef HAVE_IPC_H */
|
||||
/* #undef HAVE_LC_MESSAGES */
|
||||
#define HAVE_PROGRESSIVE_JPEG 1
|
||||
/* #undef HAVE_PWD_H */
|
||||
/* #undef HAVE_SHM_H */
|
||||
/* #undef HAVE_STPCPY */
|
||||
/* #undef HAVE_XSHM_H */
|
||||
#define HAVE_SHAPE_EXT 1
|
||||
/* #undef HAVE_SHAPE_EXT */
|
||||
/* #undef HAVE_SYS_SELECT_H */
|
||||
#ifndef _MSC_VER
|
||||
#define HAVE_SYS_TIME_H 1
|
||||
#else /* _MSC_VER */
|
||||
/* #undef HAVE_SYS_TIME_H */
|
||||
/* #undef HAVE_XCONVERTCASE */
|
||||
|
||||
/* #undef NO_FD_SET */
|
||||
|
||||
/* #undef XINPUT_NONE */
|
||||
/* #undef XINPUT_GXI */
|
||||
/* #undef XINPUT_XFREE */
|
||||
#define XINPUT_WIN32 1
|
||||
|
||||
/* Define as the return type of signal handlers (int or void). */
|
||||
#define RETSIGTYPE void
|
||||
|
||||
/* Define if you have the __argz_count function. */
|
||||
/* #undef HAVE___ARGZ_COUNT */
|
||||
|
||||
/* Define if you have the __argz_next function. */
|
||||
/* #undef HAVE___ARGZ_NEXT */
|
||||
|
||||
/* Define if you have the __argz_stringify function. */
|
||||
/* #undef HAVE___ARGZ_STRINGIFY */
|
||||
|
||||
/* Define if you have the broken_wctype function. */
|
||||
/* #undef HAVE_BROKEN_WCTYPE */
|
||||
|
||||
/* Define if you have the dcgettext function. */
|
||||
/* #undef HAVE_DCGETTEXT */
|
||||
|
||||
/* Define if you have the getcwd function. */
|
||||
#define HAVE_GETCWD 1
|
||||
|
||||
/* Define if you have the getpagesize function. */
|
||||
#define HAVE_GETPAGESIZE 1
|
||||
|
||||
/* Define if you have the lstat function. */
|
||||
/* #undef HAVE_LSTAT */
|
||||
|
||||
/* Define if you have the munmap function. */
|
||||
/* #undef HAVE_MUNMAP */
|
||||
|
||||
/* Define if you have the putenv function. */
|
||||
#define HAVE_PUTENV 1
|
||||
#define putenv _putenv
|
||||
|
||||
/* Define if you have the setenv function. */
|
||||
/* #undef HAVE_SETENV */
|
||||
|
||||
/* Define if you have the setlocale function. */
|
||||
#define HAVE_SETLOCALE 1
|
||||
|
||||
/* Define if you have the stpcpy function. */
|
||||
/* #undef HAVE_STPCPY */
|
||||
|
||||
/* Define if you have the strcasecmp function. */
|
||||
#define HAVE_STRCASECMP 1
|
||||
#define strcasecmp _stricmp
|
||||
|
||||
/* Define if you have the strchr function. */
|
||||
#define HAVE_STRCHR 1
|
||||
|
||||
/* Define if you have the strdup function. */
|
||||
#define HAVE_STRDUP 1
|
||||
|
||||
/* Define if you have the <argz.h> header file. */
|
||||
/* #undef HAVE_ARGZ_H */
|
||||
|
||||
/* Define if you have the <dirent.h> header file. */
|
||||
/* #undef HAVE_DIRENT_H */
|
||||
|
||||
/* Define if you have the <limits.h> header file. */
|
||||
#define HAVE_LIMITS_H 1
|
||||
|
||||
/* Define if you have the <locale.h> header file. */
|
||||
#define HAVE_LOCALE_H 1
|
||||
|
||||
/* Define if you have the <malloc.h> header file. */
|
||||
#define HAVE_MALLOC_H 1
|
||||
|
||||
/* Define if you have the <nl_types.h> header file. */
|
||||
/* #undef HAVE_NL_TYPES_H */
|
||||
|
||||
/* Define if you have the <pwd.h> header file. */
|
||||
/* #undef HAVE_PWD_H */
|
||||
|
||||
/* Define if you have the <string.h> header file. */
|
||||
#define HAVE_STRING_H 1
|
||||
|
||||
/* Define if you have the <sys/param.h> header file. */
|
||||
/* #undef HAVE_SYS_PARAM_H */
|
||||
|
||||
/* Define if you have the <sys/time.h> header file. */
|
||||
/* #undef HAVE_SYS_TIME_H */
|
||||
|
||||
/* Define if you have the <unistd.h> header file. */
|
||||
/* #undef HAVE_UNISTD_H */
|
||||
|
||||
/* Define if you have the <wchar.h> header file. */
|
||||
#define HAVE_WCHAR_H 1
|
||||
|
||||
/* Define if you have the <wctype.h> header file. */
|
||||
#ifdef _MSC_VER
|
||||
#define HAVE_WCTYPE_H 1
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
/* Define if you have the i library (-li). */
|
||||
/* #undef HAVE_LIBI */
|
||||
|
||||
/* Define if you have the intl library (-lintl). */
|
||||
#define HAVE_LIBINTL 1
|
||||
|
||||
/* define if compiled symbols have a leading underscore */
|
||||
/* #undef WITH_SYMBOL_UNDERSCORE */
|
||||
|
||||
/* Define if you have the Wintab programmer's kit */
|
||||
#define HAVE_WINSOCK_H 1
|
||||
#define HAVE_WINTAB 1
|
||||
/* #undef HAVE_XCONVERTCASE */
|
||||
/* #undef HAVE_XFT */
|
||||
|
||||
/* Define if you have the <dimm.h> header file
|
||||
* (available in the Platform SDK)
|
||||
*/
|
||||
/* #define HAVE_DIMM_H 1 */
|
||||
/* #undef HAVE_SIGSETJMP */
|
||||
|
||||
#define NO_FD_SET 1
|
||||
|
||||
/* #undef RESOURCE_BASE */
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#define USE_GMODULE 1
|
||||
#define USE_MMX 1
|
||||
#endif
|
||||
|
||||
/* #undef HAVE_SIGSETJMP */
|
||||
/* Define to use X11R6 additions to XIM */
|
||||
/* #undef USE_X11R6_XIM */
|
||||
|
||||
/* Define to use XKB extension */
|
||||
/* #undef HAVE_XKB */
|
||||
|
||||
/* Define to use shadowfb in the linux-fb port */
|
||||
/* #undef ENABLE_SHADOW_FB */
|
||||
|
||||
/* Define to use a fb manager in the linux-fb port */
|
||||
/* #undef ENABLE_FB_MANAGER */
|
||||
|
||||
/* #undef XINPUT_NONE */
|
||||
/* #undef XINPUT_GXI */
|
||||
/* #undef XINPUT_XFREE */
|
||||
|
||||
/* Define as the return type of signal handlers (int or void). */
|
||||
#define RETSIGTYPE void
|
||||
|
||||
/* Most machines will be happy with int or void. IRIX requires '...' */
|
||||
/* #undef SIGNAL_ARG_TYPE */
|
||||
|
||||
#define GETTEXT_PACKAGE "@GETTEXT_PACKAGE@"
|
||||
|
||||
/* #undef PACKAGE */
|
||||
/* #undef VERSION */
|
||||
|
||||
|
||||
/* Leave that blank line there!! Autoheader needs it.
|
||||
If you're adding to this file, keep in mind:
|
||||
The entries are in sort -df order: alphabetical, case insensitive,
|
||||
ignoring punctuation (such as underscores). */
|
||||
|
||||
/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
|
||||
systems. This function is required for `alloca.c' support on those systems.
|
||||
*/
|
||||
/* #undef CRAY_STACKSEG_END */
|
||||
|
||||
/* Define if using `alloca.c'. */
|
||||
/* #undef C_ALLOCA */
|
||||
|
||||
/* always defined to indicate that i18n is enabled */
|
||||
#define ENABLE_NLS 1
|
||||
|
||||
/* Define if you have `alloca', as a function or macro. */
|
||||
#define HAVE_ALLOCA 1
|
||||
|
||||
/* Define if you have <alloca.h> and it should be used (not on Ultrix). */
|
||||
/* #undef HAVE_ALLOCA_H */
|
||||
|
||||
/* Define if you have the <argz.h> header file. */
|
||||
/* #undef HAVE_ARGZ_H */
|
||||
|
||||
/* Define if you have the `bind_textdomain_codeset' function. */
|
||||
/* #undef HAVE_BIND_TEXTDOMAIN_CODESET */
|
||||
|
||||
/* Is the wctype implementation broken */
|
||||
/* #undef HAVE_BROKEN_WCTYPE */
|
||||
|
||||
/* Define if you have the `dcgettext' function. */
|
||||
#define HAVE_DCGETTEXT 1
|
||||
|
||||
/* Define if you have the <dlfcn.h> header file. */
|
||||
/* #undef HAVE_DLFCN_H */
|
||||
|
||||
/* Define if you have the `getcwd' function. */
|
||||
#define HAVE_GETCWD 1
|
||||
|
||||
/* Define if you have the `getpagesize' function. */
|
||||
#ifndef _MSC_VER
|
||||
#define HAVE_GETPAGESIZE 1
|
||||
#else /* _MSC_VER */
|
||||
/* #undef HAVE_GETPAGESIZE */
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
/* Define if you have the `getresuid' function. */
|
||||
/* #undef HAVE_GETRESUID */
|
||||
|
||||
/* Define if the GNU gettext() function is already present or preinstalled. */
|
||||
#define HAVE_GETTEXT 1
|
||||
|
||||
/* Define if you have the <inttypes.h> header file. */
|
||||
/* #undef HAVE_INTTYPES_H */
|
||||
|
||||
/* Define if your <locale.h> file defines LC_MESSAGES. */
|
||||
/* #undef HAVE_LC_MESSAGES */
|
||||
|
||||
/* Define if you have the <limits.h> header file. */
|
||||
#define HAVE_LIMITS_H 1
|
||||
|
||||
/* Define if you have the <locale.h> header file. */
|
||||
#define HAVE_LOCALE_H 1
|
||||
|
||||
/* Define if you have the `lstat' function. */
|
||||
/* #undef HAVE_LSTAT */
|
||||
|
||||
/* Define if you have the <malloc.h> header file. */
|
||||
#define HAVE_MALLOC_H 1
|
||||
|
||||
/* Define if you have the <memory.h> header file. */
|
||||
#define HAVE_MEMORY_H 1
|
||||
|
||||
/* Define if you have the `mkstemp' function. */
|
||||
/* #undef HAVE_MKSTEMP */
|
||||
|
||||
/* Define if you have a working `mmap' system call. */
|
||||
/* #undef HAVE_MMAP */
|
||||
|
||||
/* Define if you have the `munmap' function. */
|
||||
/* #undef HAVE_MUNMAP */
|
||||
|
||||
/* Define if you have the <nl_types.h> header file. */
|
||||
/* #undef HAVE_NL_TYPES_H */
|
||||
|
||||
/* Define if you have the `putenv' function. */
|
||||
#define HAVE_PUTENV 1
|
||||
|
||||
/* Define if you have the <pwd.h> header file. */
|
||||
/* #undef HAVE_PWD_H */
|
||||
|
||||
/* Define if you have the `setenv' function. */
|
||||
/* #undef HAVE_SETENV */
|
||||
|
||||
/* Define if you have the `setlocale' function. */
|
||||
#define HAVE_SETLOCALE 1
|
||||
|
||||
/* Define if you have the <stdint.h> header file. */
|
||||
#ifndef _MSC_VER
|
||||
#define HAVE_STDINT_H 1
|
||||
#else /* _MSC_VER */
|
||||
/* #undef HAVE_STDINT_H */
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
/* Define if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
/* Define if you have the `strcasecmp' function. */
|
||||
#ifndef _MSC_VER
|
||||
#define HAVE_STRCASECMP 1
|
||||
#else /* _MSC_VER */
|
||||
/* #undef HAVE_STRCASECMP */
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
/* Define if you have the `strchr' function. */
|
||||
#define HAVE_STRCHR 1
|
||||
|
||||
/* Define if you have the `strdup' function. */
|
||||
#define HAVE_STRDUP 1
|
||||
|
||||
/* Define if you have the <strings.h> header file. */
|
||||
/* #undef HAVE_STRINGS_H */
|
||||
|
||||
/* Define if you have the <string.h> header file. */
|
||||
#define HAVE_STRING_H 1
|
||||
|
||||
/* Define if you have the <sys/param.h> header file. */
|
||||
/* #undef HAVE_SYS_PARAM_H */
|
||||
|
||||
/* Define if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define if you have the <sys/time.h> header file. */
|
||||
#ifndef _MSC_VER
|
||||
#define HAVE_SYS_TIME_H 1
|
||||
#else /* _MSC_VER */
|
||||
/* #undef HAVE_SYS_TIME_H */
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
/* Define if you have the <sys/types.h> header file. */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* Define if you have <sys/wait.h> that is POSIX.1 compatible. */
|
||||
/* #undef HAVE_SYS_WAIT_H */
|
||||
|
||||
/* Define if you have the <unistd.h> header file. */
|
||||
#ifndef _MSC_VER
|
||||
#define HAVE_UNISTD_H 1
|
||||
#else /* _MSC_VER */
|
||||
/* #undef HAVE_UNISTD_H */
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
/* Have wchar.h include file */
|
||||
#define HAVE_WCHAR_H 1
|
||||
|
||||
/* Have wctype.h include file */
|
||||
#define HAVE_WCTYPE_H 1
|
||||
|
||||
/* Define if you have the <winsock.h> header file. */
|
||||
#define HAVE_WINSOCK_H 1
|
||||
|
||||
/* Define if you have the `__argz_count' function. */
|
||||
/* #undef HAVE___ARGZ_COUNT */
|
||||
|
||||
/* Define if you have the `__argz_next' function. */
|
||||
/* #undef HAVE___ARGZ_NEXT */
|
||||
|
||||
/* Define if you have the `__argz_stringify' function. */
|
||||
/* #undef HAVE___ARGZ_STRINGIFY */
|
||||
|
||||
/* Define as the return type of signal handlers (`int' or `void'). */
|
||||
#define RETSIGTYPE void
|
||||
|
||||
/* If using the C implementation of alloca, define if you know the
|
||||
direction of stack growth for your system; otherwise it will be
|
||||
automatically deduced at run-time.
|
||||
STACK_DIRECTION > 0 => grows toward higher addresses
|
||||
STACK_DIRECTION < 0 => grows toward lower addresses
|
||||
STACK_DIRECTION = 0 => direction of growth unknown */
|
||||
/* #undef STACK_DIRECTION */
|
||||
|
||||
/* Define if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Define if the X Window System is missing or not being used. */
|
||||
/* #undef X_DISPLAY_MISSING */
|
||||
|
||||
/* Define to empty if `const' does not conform to ANSI C. */
|
||||
/* #undef const */
|
||||
|
||||
/* Define to `int' if <sys/types.h> doesn't define. */
|
||||
#define gid_t int
|
||||
|
||||
/* Define as `__inline' if that's what the C compiler calls it, or to nothing
|
||||
if it is not supported. */
|
||||
/* #undef inline */
|
||||
|
||||
/* Define to `long' if <sys/types.h> does not define. */
|
||||
/* #undef off_t */
|
||||
|
||||
/* Define to `unsigned' if <sys/types.h> does not define. */
|
||||
/* #undef size_t */
|
||||
|
||||
/* Define to `int' if <sys/types.h> doesn't define. */
|
||||
#define uid_t int
|
||||
|
1232
config.sub
vendored
1232
config.sub
vendored
File diff suppressed because it is too large
Load Diff
882
configure.in
882
configure.in
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,28 @@
|
||||
2002-01-25 Federico Mena Quintero <federico@ximian.com>
|
||||
|
||||
Merge from gdk-pixbuf stable.
|
||||
|
||||
* gdk-pixbuf-xlib-drawable.c (rgb565msb): Fixed the endianness
|
||||
conversion --- swap the individual 16 bit values instead of taking
|
||||
everying as a 32 bit value.
|
||||
(rgb565lsb): Likewise.
|
||||
(rgb555lsb): Likewise.
|
||||
(rgb555msb): Likewise.
|
||||
|
||||
2001-11-26 Akira TAGOH <tagoh@redhat.com>
|
||||
|
||||
* Makefile.am (libgdk_pixbuf_xlib_1_3_la_LDFLAGS):
|
||||
Added -version-info.
|
||||
|
||||
2001-05-19 Havoc Pennington <hp@pobox.com>
|
||||
|
||||
* gdk-pixbuf-xlibrgb.c: docs
|
||||
|
||||
2001-06-04 Havoc Pennington <hp@redhat.com>
|
||||
|
||||
* gdk-pixbuf-xlibrgb.c (xlib_rgb_init): remove C++ comment,
|
||||
reported by Dan McNichol
|
||||
|
||||
Mon Jan 8 11:41:41 2001 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* Makefile.am (INCLUDES): Add @x_cflags@ (#36310)
|
||||
|
@@ -1,4 +1,4 @@
|
||||
lib_LTLIBRARIES=libgdk_pixbuf_xlib-1.3.la
|
||||
lib_LTLIBRARIES=libgdk_pixbuf_xlib-2.0.la
|
||||
|
||||
INCLUDES = @STRIP_BEGIN@ \
|
||||
-I$(top_srcdir) -I$(top_builddir) \
|
||||
@@ -11,10 +11,11 @@ LDADDS = @STRIP_BEGIN@ \
|
||||
@GDK_PIXBUF_XLIB_DEP_LIBS@ \
|
||||
@STRIP_END@
|
||||
|
||||
libgdk_pixbuf_xlib_1_3_la_LDFLAGS = \
|
||||
-export-dynamic
|
||||
libgdk_pixbuf_xlib_2_0_la_LDFLAGS = \
|
||||
-export-dynamic \
|
||||
-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
|
||||
|
||||
libgdk_pixbuf_xlib_1_3_la_SOURCES = \
|
||||
libgdk_pixbuf_xlib_2_0_la_SOURCES = \
|
||||
gdk-pixbuf-xlib-private.h \
|
||||
gdk-pixbuf-xlib.c \
|
||||
gdk-pixbuf-xlib-render.c \
|
||||
@@ -27,4 +28,7 @@ libgdk_pixbuf_xlibinclude_HEADERS = \
|
||||
gdk-pixbuf-xlib.h \
|
||||
gdk-pixbuf-xlibrgb.h
|
||||
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA = gdk-pixbuf-xlib-2.0.pc
|
||||
|
||||
EXTRA_DIST = gdk-pixbuf-xlib-2.0.pc.in
|
||||
|
@@ -7,5 +7,5 @@ Name: GdkPixbuf Xlib
|
||||
Description: GdkPixbuf rendering for Xlib
|
||||
Version: @VERSION@
|
||||
Requires: gobject-2.0,gmodule-2.0,gdk-pixbuf-2.0
|
||||
Libs: -L${libdir} -lgdk_pixbuf_xlib-1.3
|
||||
Libs: -L${libdir} -lgdk_pixbuf_xlib-@GTK_API_VERSION@
|
||||
Cflags: -I${includedir}
|
||||
|
@@ -365,7 +365,7 @@ rgb565lsb (XImage *image, guchar *pixels, int rowstride, xlib_colormap *colormap
|
||||
| (data & 0x1f0000) >> 5 | (data & 0x1c0000) >> 10;
|
||||
#else
|
||||
/* swap endianness first */
|
||||
data = s[0] | s[1] << 8 | s[2] << 16 | s[3] << 24;
|
||||
data = s[1] | s[0] << 8 | s[3] << 16 | s[2] << 24;
|
||||
s += 4;
|
||||
*o++ = (data & 0xf800) | (data & 0xe000) >> 5
|
||||
| (data & 0x7e0) >> 3 | (data & 0x600) >> 9;
|
||||
@@ -428,7 +428,7 @@ rgb565msb (XImage *image, guchar *pixels, int rowstride, xlib_colormap *colormap
|
||||
register guint32 data;
|
||||
#ifdef LITTLE
|
||||
/* swap endianness first */
|
||||
data = s[0] | s[1] << 8 | s[2] << 16 | s[3] << 24;
|
||||
data = s[1] | s[0] << 8 | s[3] << 16 | s[2] << 24;
|
||||
s += 4;
|
||||
*o++ = (data & 0xf800) >> 8 | (data & 0xe000) >> 13
|
||||
| (data & 0x7e0) << 5 | (data & 0x600) >> 1;
|
||||
@@ -617,7 +617,7 @@ rgb555lsb (XImage *image, guchar *pixels, int rowstride, xlib_colormap *colormap
|
||||
| (data & 0x1f0000) >> 5 | (data & 0x1c0000) >> 10;
|
||||
#else
|
||||
/* swap endianness first */
|
||||
data = s[0] | s[1] << 8 | s[2] << 16 | s[3] << 24;
|
||||
data = s[1] | s[0] << 8 | s[3] << 16 | s[2] << 24;
|
||||
s += 4;
|
||||
*o++ = (data & 0x7c00) << 1 | (data & 0x7000) >> 4
|
||||
| (data & 0x3e0) >> 2 | (data & 0x380) >> 7;
|
||||
@@ -676,7 +676,7 @@ rgb555msb (XImage *image, guchar *pixels, int rowstride, xlib_colormap *colormap
|
||||
register guint32 data;
|
||||
#ifdef LITTLE
|
||||
/* swap endianness first */
|
||||
data = s[0] | s[1] << 8 | s[2] << 16 | s[3] << 24;
|
||||
data = s[1] | s[0] << 8 | s[3] << 16 | s[2] << 24;
|
||||
s += 4;
|
||||
*o++ = (data & 0x7c00) >> 7 | (data & 0x7000) >> 12
|
||||
| (data & 0x3e0) << 6 | (data & 0x380) << 1;
|
||||
|
@@ -460,18 +460,36 @@ xlib_rgb_colorcube_222 (void)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* xlib_rgb_set_verbose:
|
||||
* @verbose: %True to be verbose
|
||||
*
|
||||
* Enables/disables debug spew.
|
||||
**/
|
||||
void
|
||||
xlib_rgb_set_verbose (Bool verbose)
|
||||
{
|
||||
xlib_rgb_verbose = verbose;
|
||||
}
|
||||
|
||||
/**
|
||||
* xlib_rgb_set_install:
|
||||
* @install: %True to install a colormap
|
||||
*
|
||||
* Sets whether we install an RGB colormap.
|
||||
**/
|
||||
void
|
||||
xlib_rgb_set_install (Bool install)
|
||||
{
|
||||
xlib_rgb_install_cmap = install;
|
||||
}
|
||||
|
||||
/**
|
||||
* xlib_rgb_set_min_colors:
|
||||
* @min_colors: minimum colors to use
|
||||
*
|
||||
* Sets the minimum number of colors in the color cube.
|
||||
**/
|
||||
void
|
||||
xlib_rgb_set_min_colors (int min_colors)
|
||||
{
|
||||
@@ -730,7 +748,7 @@ xlib_rgb_set_gray_cmap (Colormap cmap)
|
||||
void
|
||||
xlib_rgb_init (Display *display, Screen *screen)
|
||||
{
|
||||
int prefDepth = -1; // let the function do the visual scoring
|
||||
int prefDepth = -1; /* let the function do the visual scoring */
|
||||
xlib_rgb_init_with_depth(display, screen, prefDepth);
|
||||
}
|
||||
|
||||
@@ -1020,7 +1038,7 @@ xlib_rgb_gc_set_foreground (GC gc, guint32 rgb)
|
||||
}
|
||||
|
||||
/**
|
||||
* xlib_rgb_gc_set_foreground:
|
||||
* xlib_rgb_gc_set_background:
|
||||
* @gc: A graphic context.
|
||||
* @rgb: 32-bit representation of an RGB value, specified as 0x00RRGGBB.
|
||||
*
|
||||
|
@@ -5,21 +5,23 @@ SUBDIRS = gtk-demo
|
||||
INCLUDES = @STRIP_BEGIN@ \
|
||||
-I$(top_srcdir) \
|
||||
-I$(top_builddir)/gdk \
|
||||
-DGTK_DISABLE_COMPAT_H \
|
||||
-DG_DISABLE_DEPRECATED \
|
||||
-DGDK_DISABLE_DEPRECATED \
|
||||
-DGDK_PIXBUF_DISABLE_DEPRECATED \
|
||||
-DGTK_DISABLE_DEPRECATED \
|
||||
@GTK_DEBUG_FLAGS@ \
|
||||
@GTK_DEP_CFLAGS@ \
|
||||
@STRIP_END@
|
||||
|
||||
DEPS = \
|
||||
$(top_builddir)/gdk-pixbuf/libgdk_pixbuf-1.3.la \
|
||||
$(top_builddir)/gdk/@gdktargetlib@ \
|
||||
$(top_builddir)/gdk-pixbuf/libgdk_pixbuf-$(GTK_API_VERSION).la \
|
||||
$(top_builddir)/gdk/@gdktargetlib@ \
|
||||
$(top_builddir)/gtk/@gtktargetlib@
|
||||
|
||||
LDADDS = @STRIP_BEGIN@ \
|
||||
$(top_builddir)/gdk-pixbuf/libgdk_pixbuf-1.3.la \
|
||||
$(top_builddir)/gdk/@gdktargetlib@ \
|
||||
$(top_builddir)/gtk/@gtktargetlib@ \
|
||||
LDADDS = @STRIP_BEGIN@ \
|
||||
$(top_builddir)/gdk-pixbuf/libgdk_pixbuf-$(GTK_API_VERSION).la \
|
||||
$(top_builddir)/gdk/@gdktargetlib@ \
|
||||
$(top_builddir)/gtk/@gtktargetlib@ \
|
||||
@STRIP_END@
|
||||
|
||||
noinst_PROGRAMS = \
|
||||
@@ -30,12 +32,12 @@ noinst_PROGRAMS = \
|
||||
testpixbuf-scale \
|
||||
pixbuf-demo
|
||||
|
||||
BUILT_SOURCES=test-inline-pixbufs.h
|
||||
|
||||
test-inline-pixbufs.h: $(top_builddir)/gdk-pixbuf/make-inline-pixbuf apple-red.png gnome-foot.png
|
||||
test-inline-pixbufs.h: $(top_builddir)/gdk-pixbuf/gdk-pixbuf-csource$(EXEEXT) apple-red.png gnome-foot.png
|
||||
(topdir=`cd $(top_builddir) && pwd` ; curdir=`pwd` ; \
|
||||
cd $(srcdir) && \
|
||||
GDK_PIXBUF_MODULEDIR=$$topdir/gdk-pixbuf/.libs $$topdir/gdk-pixbuf/make-inline-pixbuf $$curdir/test-inline-pixbufs.h apple_red apple-red.png gnome_foot gnome-foot.png)
|
||||
cd $(srcdir) && \
|
||||
GDK_PIXBUF_MODULEDIR=$$topdir/gdk-pixbuf/.libs \
|
||||
$$topdir/gdk-pixbuf/gdk-pixbuf-csource --build-list \
|
||||
apple_red apple-red.png gnome_foot gnome-foot.png >$$curdir/test-inline-pixbufs.h)
|
||||
|
||||
testpixbuf_DEPENDENCIES = $(DEPS)
|
||||
testpixbuf_drawable_DEPENDENCIES = $(DEPS)
|
||||
@@ -52,6 +54,7 @@ testanimation_LDADD = $(LDADDS)
|
||||
pixbuf_demo_LDADD = $(LDADDS)
|
||||
|
||||
testpixbuf_SOURCES = testpixbuf.c pixbuf-init.c
|
||||
$(testpixbuf_OBJECTS): test-inline-pixbufs.h
|
||||
testpixbuf_drawable_SOURCES = testpixbuf-drawable.c pixbuf-init.c
|
||||
testpixbuf_save_SOURCES = testpixbuf-save.c
|
||||
testpixbuf_scale_SOURCES = testpixbuf-scale.c pixbuf-init.c
|
||||
|
@@ -5,39 +5,49 @@ democodedir=$(datadir)/gtk-2.0/demo
|
||||
## These should be in the order you want them to appear in the
|
||||
## demo app, which means alphabetized by demo title, not filename
|
||||
demos = @STRIP_BEGIN@ \
|
||||
appwindow.c \
|
||||
button_box.c \
|
||||
colorsel.c \
|
||||
dialog.c \
|
||||
drawingarea.c \
|
||||
editable_cells.c \
|
||||
images.c \
|
||||
item_factory.c \
|
||||
list_store.c \
|
||||
menus.c \
|
||||
panes.c \
|
||||
pixbufs.c \
|
||||
sizegroup.c \
|
||||
stock_browser.c \
|
||||
textview.c \
|
||||
tree_store.c \
|
||||
multiscreen.c \
|
||||
multidisplay.c \
|
||||
virtualscreen.c \
|
||||
movedemo.c \
|
||||
@STRIP_END@
|
||||
|
||||
INCLUDES = @STRIP_BEGIN@ \
|
||||
-DDEMOCODEDIR="\"$(democodedir)\"" \
|
||||
-I$(top_srcdir) \
|
||||
-I$(top_builddir)/gdk \
|
||||
-DGDK_DISABLE_COMPAT_H \
|
||||
-DG_DISABLE_DEPRECATED \
|
||||
-DGDK_DISABLE_DEPRECATED \
|
||||
-DGTK_DISABLE_COMPAT_H \
|
||||
-DGDK_PIXBUF_DISABLE_DEPRECATED \
|
||||
-DGTK_DISABLE_DEPRECATED \
|
||||
@GTK_DEBUG_FLAGS@ \
|
||||
@GTK_DEP_CFLAGS@ \
|
||||
@STRIP_END@
|
||||
|
||||
DEPS = \
|
||||
$(top_builddir)/gdk-pixbuf/libgdk_pixbuf-1.3.la \
|
||||
$(top_builddir)/gdk/@gdktargetlib@ \
|
||||
$(top_builddir)/gdk-pixbuf/libgdk_pixbuf-$(GTK_API_VERSION).la \
|
||||
$(top_builddir)/gdk/@gdktargetlib@ \
|
||||
$(top_builddir)/gtk/@gtktargetlib@
|
||||
|
||||
LDADDS = @STRIP_BEGIN@ \
|
||||
$(top_builddir)/gdk-pixbuf/libgdk_pixbuf-1.3.la \
|
||||
$(top_builddir)/gdk/@gdktargetlib@ \
|
||||
$(top_builddir)/gtk/@gtktargetlib@ \
|
||||
LDADDS = @STRIP_BEGIN@ \
|
||||
$(top_builddir)/gdk-pixbuf/libgdk_pixbuf-$(GTK_API_VERSION).la \
|
||||
$(top_builddir)/gdk/@gdktargetlib@ \
|
||||
$(top_builddir)/gtk/@gtktargetlib@ \
|
||||
@STRIP_END@
|
||||
|
||||
bin_PROGRAMS = gtk-demo
|
||||
@@ -53,6 +63,7 @@ demos.h: $(demos) geninclude.pl
|
||||
|
||||
gtk_demo_SOURCES = \
|
||||
$(demos) \
|
||||
demo-common.h \
|
||||
main.c \
|
||||
demos.h
|
||||
|
||||
|
354
demos/gtk-demo/appwindow.c
Normal file
354
demos/gtk-demo/appwindow.c
Normal file
@@ -0,0 +1,354 @@
|
||||
/* Application main window
|
||||
*
|
||||
* Demonstrates a typical application window, with menubar, toolbar, statusbar.
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include "demo-common.h"
|
||||
#include <stdio.h>
|
||||
|
||||
static void
|
||||
menuitem_cb (gpointer callback_data,
|
||||
guint callback_action,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
|
||||
dialog = gtk_message_dialog_new (GTK_WINDOW (callback_data),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_INFO,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"You selected or toggled the menu item: \"%s\"",
|
||||
gtk_item_factory_path_from_widget (widget));
|
||||
|
||||
/* Close dialog on user response */
|
||||
g_signal_connect (G_OBJECT (dialog),
|
||||
"response",
|
||||
G_CALLBACK (gtk_widget_destroy),
|
||||
NULL);
|
||||
|
||||
gtk_widget_show (dialog);
|
||||
}
|
||||
|
||||
|
||||
static GtkItemFactoryEntry menu_items[] =
|
||||
{
|
||||
{ "/_File", NULL, 0, 0, "<Branch>" },
|
||||
{ "/File/_New", "<control>N", menuitem_cb, 0, "<StockItem>", GTK_STOCK_NEW },
|
||||
{ "/File/_Open", "<control>O", menuitem_cb, 0, "<StockItem>", GTK_STOCK_OPEN },
|
||||
{ "/File/_Save", "<control>S", menuitem_cb, 0, "<StockItem>", GTK_STOCK_SAVE },
|
||||
{ "/File/Save _As...", NULL, menuitem_cb, 0, "<StockItem>", GTK_STOCK_SAVE },
|
||||
{ "/File/sep1", NULL, menuitem_cb, 0, "<Separator>" },
|
||||
{ "/File/_Quit", "<control>Q", menuitem_cb, 0, "<StockItem>", GTK_STOCK_QUIT },
|
||||
|
||||
{ "/_Preferences", NULL, 0, 0, "<Branch>" },
|
||||
{ "/_Preferences/_Color", NULL, 0, 0, "<Branch>" },
|
||||
{ "/_Preferences/Color/_Red", NULL, menuitem_cb, 0, "<RadioItem>" },
|
||||
{ "/_Preferences/Color/_Green", NULL, menuitem_cb, 0, "/Preferences/Color/Red" },
|
||||
{ "/_Preferences/Color/_Blue", NULL, menuitem_cb, 0, "/Preferences/Color/Red" },
|
||||
{ "/_Preferences/_Shape", NULL, 0, 0, "<Branch>" },
|
||||
{ "/_Preferences/Shape/_Square", NULL, menuitem_cb, 0, "<RadioItem>" },
|
||||
{ "/_Preferences/Shape/_Rectangle", NULL, menuitem_cb, 0, "/Preferences/Shape/Square" },
|
||||
{ "/_Preferences/Shape/_Oval", NULL, menuitem_cb, 0, "/Preferences/Shape/Rectangle" },
|
||||
|
||||
/* If you wanted this to be right justified you would use "<LastBranch>", not "<Branch>".
|
||||
* Right justified help menu items are generally considered a bad idea now days.
|
||||
*/
|
||||
{ "/_Help", NULL, 0, 0, "<Branch>" },
|
||||
{ "/Help/_About", NULL, menuitem_cb, 0 },
|
||||
};
|
||||
|
||||
static void
|
||||
toolbar_cb (GtkWidget *button,
|
||||
gpointer data)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
|
||||
dialog = gtk_message_dialog_new (GTK_WINDOW (data),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_INFO,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"You selected a toolbar button");
|
||||
|
||||
/* Close dialog on user response */
|
||||
g_signal_connect (G_OBJECT (dialog),
|
||||
"response",
|
||||
G_CALLBACK (gtk_widget_destroy),
|
||||
NULL);
|
||||
|
||||
gtk_widget_show (dialog);
|
||||
}
|
||||
|
||||
/* This function registers our custom toolbar icons, so they can be themed.
|
||||
*
|
||||
* It's totally optional to do this, you could just manually insert icons
|
||||
* and have them not be themeable, especially if you never expect people
|
||||
* to theme your app.
|
||||
*/
|
||||
static void
|
||||
register_stock_icons (void)
|
||||
{
|
||||
static gboolean registered = FALSE;
|
||||
|
||||
if (!registered)
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
GtkIconFactory *factory;
|
||||
char *filename;
|
||||
|
||||
static GtkStockItem items[] = {
|
||||
{ "demo-gtk-logo",
|
||||
"_GTK!",
|
||||
0, 0, NULL }
|
||||
};
|
||||
|
||||
registered = TRUE;
|
||||
|
||||
/* Register our stock items */
|
||||
gtk_stock_add (items, G_N_ELEMENTS (items));
|
||||
|
||||
/* Add our custom icon factory to the list of defaults */
|
||||
factory = gtk_icon_factory_new ();
|
||||
gtk_icon_factory_add_default (factory);
|
||||
|
||||
/* 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)
|
||||
{
|
||||
GtkIconSet *icon_set;
|
||||
GdkPixbuf *transparent;
|
||||
|
||||
/* The gtk-logo-rgb icon has a white background, make it transparent */
|
||||
transparent = gdk_pixbuf_add_alpha (pixbuf, TRUE, 0xff, 0xff, 0xff);
|
||||
|
||||
icon_set = gtk_icon_set_new_from_pixbuf (transparent);
|
||||
gtk_icon_factory_add (factory, "demo-gtk-logo", icon_set);
|
||||
gtk_icon_set_unref (icon_set);
|
||||
g_object_unref (G_OBJECT (pixbuf));
|
||||
g_object_unref (G_OBJECT (transparent));
|
||||
}
|
||||
else
|
||||
g_warning ("failed to load GTK logo for toolbar");
|
||||
|
||||
/* Drop our reference to the factory, GTK will hold a reference. */
|
||||
g_object_unref (G_OBJECT (factory));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
update_statusbar (GtkTextBuffer *buffer,
|
||||
GtkStatusbar *statusbar)
|
||||
{
|
||||
gchar *msg;
|
||||
gint row, col;
|
||||
gint count;
|
||||
GtkTextIter iter;
|
||||
|
||||
gtk_statusbar_pop (statusbar, 0); /* clear any previous message, underflow is allowed */
|
||||
|
||||
count = gtk_text_buffer_get_char_count (buffer);
|
||||
|
||||
gtk_text_buffer_get_iter_at_mark (buffer,
|
||||
&iter,
|
||||
gtk_text_buffer_get_insert (buffer));
|
||||
|
||||
row = gtk_text_iter_get_line (&iter);
|
||||
col = gtk_text_iter_get_line_offset (&iter);
|
||||
|
||||
msg = g_strdup_printf ("Cursor at row %d column %d - %d chars in document",
|
||||
row, col, count);
|
||||
|
||||
gtk_statusbar_push (statusbar, 0, msg);
|
||||
|
||||
g_free (msg);
|
||||
}
|
||||
|
||||
static void
|
||||
mark_set_callback (GtkTextBuffer *buffer,
|
||||
const GtkTextIter *new_location,
|
||||
GtkTextMark *mark,
|
||||
gpointer data)
|
||||
{
|
||||
update_statusbar (buffer, GTK_STATUSBAR (data));
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_appwindow (GtkWidget *do_widget)
|
||||
{
|
||||
GtkWidget *window = get_cached_widget (do_widget, "do_appwindow");
|
||||
|
||||
if (!window)
|
||||
{
|
||||
GtkWidget *table;
|
||||
GtkWidget *toolbar;
|
||||
GtkWidget *statusbar;
|
||||
GtkWidget *contents;
|
||||
GtkWidget *sw;
|
||||
GtkTextBuffer *buffer;
|
||||
GtkAccelGroup *accel_group;
|
||||
GtkItemFactory *item_factory;
|
||||
|
||||
register_stock_icons ();
|
||||
|
||||
/* Create the toplevel window
|
||||
*/
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_screen (GTK_WINDOW (window),
|
||||
gtk_widget_get_screen (do_widget));
|
||||
cache_widget (window, "do_appwindow");
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Application Window");
|
||||
|
||||
/* NULL window variable when window is closed */
|
||||
g_signal_connect (G_OBJECT (window), "destroy",
|
||||
G_CALLBACK (remove_cached_widget),
|
||||
"do_appwindow");
|
||||
|
||||
table = gtk_table_new (1, 4, FALSE);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (window), table);
|
||||
|
||||
/* Create the menubar
|
||||
*/
|
||||
|
||||
accel_group = gtk_accel_group_new ();
|
||||
gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
|
||||
g_object_unref (accel_group);
|
||||
|
||||
item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>", accel_group);
|
||||
|
||||
/* Set up item factory to go away with the window */
|
||||
g_object_ref (item_factory);
|
||||
gtk_object_sink (GTK_OBJECT (item_factory));
|
||||
g_object_set_data_full (G_OBJECT (window),
|
||||
"<main>",
|
||||
item_factory,
|
||||
(GDestroyNotify) g_object_unref);
|
||||
|
||||
/* create menu items */
|
||||
gtk_item_factory_create_items (item_factory, G_N_ELEMENTS (menu_items),
|
||||
menu_items, window);
|
||||
|
||||
gtk_table_attach (GTK_TABLE (table),
|
||||
gtk_item_factory_get_widget (item_factory, "<main>"),
|
||||
/* X direction */ /* Y direction */
|
||||
0, 1, 0, 1,
|
||||
GTK_EXPAND | GTK_FILL, 0,
|
||||
0, 0);
|
||||
|
||||
/* Create the toolbar
|
||||
*/
|
||||
toolbar = gtk_toolbar_new ();
|
||||
|
||||
gtk_toolbar_insert_stock (GTK_TOOLBAR (toolbar),
|
||||
GTK_STOCK_OPEN,
|
||||
"This is a demo button with an 'open' icon",
|
||||
NULL,
|
||||
G_CALLBACK (toolbar_cb),
|
||||
window, /* user data for callback */
|
||||
-1); /* -1 means "append" */
|
||||
|
||||
gtk_toolbar_insert_stock (GTK_TOOLBAR (toolbar),
|
||||
GTK_STOCK_QUIT,
|
||||
"This is a demo button with a 'quit' icon",
|
||||
NULL,
|
||||
G_CALLBACK (toolbar_cb),
|
||||
window, /* user data for callback */
|
||||
-1); /* -1 means "append" */
|
||||
|
||||
gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));
|
||||
|
||||
gtk_toolbar_insert_stock (GTK_TOOLBAR (toolbar),
|
||||
"demo-gtk-logo",
|
||||
"This is a demo button with a 'gtk' icon",
|
||||
NULL,
|
||||
G_CALLBACK (toolbar_cb),
|
||||
window, /* user data for callback */
|
||||
-1); /* -1 means "append" */
|
||||
|
||||
gtk_table_attach (GTK_TABLE (table),
|
||||
toolbar,
|
||||
/* X direction */ /* Y direction */
|
||||
0, 1, 1, 2,
|
||||
GTK_EXPAND | GTK_FILL, 0,
|
||||
0, 0);
|
||||
|
||||
/* Create document
|
||||
*/
|
||||
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
|
||||
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_SHADOW_IN);
|
||||
|
||||
gtk_table_attach (GTK_TABLE (table),
|
||||
sw,
|
||||
/* X direction */ /* Y direction */
|
||||
0, 1, 2, 3,
|
||||
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL,
|
||||
0, 0);
|
||||
|
||||
gtk_window_set_default_size (GTK_WINDOW (window),
|
||||
200, 200);
|
||||
|
||||
contents = gtk_text_view_new ();
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (sw),
|
||||
contents);
|
||||
|
||||
/* Create statusbar */
|
||||
|
||||
statusbar = gtk_statusbar_new ();
|
||||
gtk_table_attach (GTK_TABLE (table),
|
||||
statusbar,
|
||||
/* X direction */ /* Y direction */
|
||||
0, 1, 3, 4,
|
||||
GTK_EXPAND | GTK_FILL, 0,
|
||||
0, 0);
|
||||
|
||||
/* Show text widget info in the statusbar */
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (contents));
|
||||
|
||||
g_signal_connect_object (buffer,
|
||||
"changed",
|
||||
G_CALLBACK (update_statusbar),
|
||||
statusbar,
|
||||
0);
|
||||
|
||||
g_signal_connect_object (buffer,
|
||||
"mark_set", /* cursor moved */
|
||||
G_CALLBACK (mark_set_callback),
|
||||
statusbar,
|
||||
0);
|
||||
|
||||
update_statusbar (buffer, GTK_STATUSBAR (statusbar));
|
||||
}
|
||||
|
||||
if (!GTK_WIDGET_VISIBLE (window))
|
||||
{
|
||||
gtk_widget_show_all (window);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_destroy (window);
|
||||
window = NULL;
|
||||
}
|
||||
|
||||
return window;
|
||||
}
|
||||
|
@@ -4,10 +4,11 @@
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <demo-common.h>
|
||||
|
||||
static GtkWidget *
|
||||
create_bbox (gint horizontal,
|
||||
char* title,
|
||||
char *title,
|
||||
gint spacing,
|
||||
gint layout)
|
||||
{
|
||||
@@ -28,10 +29,10 @@ create_bbox (gint horizontal,
|
||||
gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), layout);
|
||||
gtk_box_set_spacing (GTK_BOX (bbox), spacing);
|
||||
|
||||
button = gtk_button_new_from_stock (GTK_STOCK_BUTTON_OK);
|
||||
button = gtk_button_new_from_stock (GTK_STOCK_OK);
|
||||
gtk_container_add (GTK_CONTAINER (bbox), button);
|
||||
|
||||
button = gtk_button_new_from_stock (GTK_STOCK_BUTTON_CANCEL);
|
||||
button = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
|
||||
gtk_container_add (GTK_CONTAINER (bbox), button);
|
||||
|
||||
button = gtk_button_new_from_stock (GTK_STOCK_HELP);
|
||||
@@ -41,9 +42,9 @@ create_bbox (gint horizontal,
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_button_box (void)
|
||||
do_button_box (GtkWidget *do_widget)
|
||||
{
|
||||
static GtkWidget* window = NULL;
|
||||
GtkWidget *window = get_cached_widget (do_widget, "do_button_box");
|
||||
GtkWidget *main_vbox;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *hbox;
|
||||
@@ -53,11 +54,14 @@ do_button_box (void)
|
||||
if (!window)
|
||||
{
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_screen (GTK_WINDOW (window),
|
||||
gtk_widget_get_screen (do_widget));
|
||||
cache_widget (window, "do_button_box");
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Button Boxes");
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (window), "destroy",
|
||||
GTK_SIGNAL_FUNC(gtk_widget_destroyed),
|
||||
&window);
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (remove_cached_widget),
|
||||
"do_button_box");
|
||||
|
||||
gtk_container_set_border_width (GTK_CONTAINER (window), 10);
|
||||
|
||||
@@ -72,19 +76,19 @@ do_button_box (void)
|
||||
gtk_container_add (GTK_CONTAINER (frame_horz), vbox);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (vbox),
|
||||
create_bbox (TRUE, "Spread", 40, GTK_BUTTONBOX_SPREAD),
|
||||
create_bbox (TRUE, "Spread", 40, GTK_BUTTONBOX_SPREAD),
|
||||
TRUE, TRUE, 0);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (vbox),
|
||||
create_bbox (TRUE, "Edge", 40, GTK_BUTTONBOX_EDGE),
|
||||
create_bbox (TRUE, "Edge", 40, GTK_BUTTONBOX_EDGE),
|
||||
TRUE, TRUE, 5);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (vbox),
|
||||
create_bbox (TRUE, "Start", 40, GTK_BUTTONBOX_START),
|
||||
create_bbox (TRUE, "Start", 40, GTK_BUTTONBOX_START),
|
||||
TRUE, TRUE, 5);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (vbox),
|
||||
create_bbox (TRUE, "End", 40, GTK_BUTTONBOX_END),
|
||||
create_bbox (TRUE, "End", 40, GTK_BUTTONBOX_END),
|
||||
TRUE, TRUE, 5);
|
||||
|
||||
frame_vert = gtk_frame_new ("Vertical Button Boxes");
|
||||
@@ -95,19 +99,19 @@ do_button_box (void)
|
||||
gtk_container_add (GTK_CONTAINER (frame_vert), hbox);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (hbox),
|
||||
create_bbox (FALSE, "Spread", 30, GTK_BUTTONBOX_SPREAD),
|
||||
create_bbox (FALSE, "Spread", 30, GTK_BUTTONBOX_SPREAD),
|
||||
TRUE, TRUE, 0);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (hbox),
|
||||
create_bbox (FALSE, "Edge", 30, GTK_BUTTONBOX_EDGE),
|
||||
create_bbox (FALSE, "Edge", 30, GTK_BUTTONBOX_EDGE),
|
||||
TRUE, TRUE, 5);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (hbox),
|
||||
create_bbox (FALSE, "Start", 30, GTK_BUTTONBOX_START),
|
||||
create_bbox (FALSE, "Start", 30, GTK_BUTTONBOX_START),
|
||||
TRUE, TRUE, 5);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (hbox),
|
||||
create_bbox (FALSE, "End", 30, GTK_BUTTONBOX_END),
|
||||
create_bbox (FALSE, "End", 30, GTK_BUTTONBOX_END),
|
||||
TRUE, TRUE, 5);
|
||||
}
|
||||
|
||||
@@ -116,11 +120,10 @@ do_button_box (void)
|
||||
gtk_widget_show_all (window);
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
gtk_widget_destroy (window);
|
||||
window = NULL;
|
||||
}
|
||||
|
||||
return window;
|
||||
}
|
||||
|
||||
|
@@ -6,28 +6,29 @@
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <demo-common.h>
|
||||
|
||||
static GtkWidget *window = NULL;
|
||||
static GtkWidget *da;
|
||||
static GdkColor color;
|
||||
static GtkWidget *frame;
|
||||
|
||||
static void
|
||||
change_color_callback (GtkWidget *button,
|
||||
gpointer data)
|
||||
gpointer data)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
GtkColorSelection *colorsel;
|
||||
gint response;
|
||||
|
||||
GtkWidget *window = get_cached_widget (button, "do_colorsel");
|
||||
GtkWidget *da = get_cached_widget (button, "do_colorsel_da");
|
||||
GdkColor *color = get_cached_pointer (button, "do_colorsel_color");
|
||||
|
||||
dialog = gtk_color_selection_dialog_new ("Changing color");
|
||||
|
||||
gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (window));
|
||||
|
||||
colorsel = GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (dialog)->colorsel);
|
||||
|
||||
gtk_color_selection_set_previous_color (colorsel, &color);
|
||||
gtk_color_selection_set_current_color (colorsel, &color);
|
||||
gtk_color_selection_set_previous_color (colorsel, color);
|
||||
gtk_color_selection_set_current_color (colorsel, color);
|
||||
gtk_color_selection_set_has_palette (colorsel, TRUE);
|
||||
|
||||
response = gtk_dialog_run (GTK_DIALOG (dialog));
|
||||
@@ -35,31 +36,42 @@ change_color_callback (GtkWidget *button,
|
||||
if (response == GTK_RESPONSE_OK)
|
||||
{
|
||||
gtk_color_selection_get_current_color (colorsel,
|
||||
&color);
|
||||
color);
|
||||
|
||||
gtk_widget_modify_bg (da, GTK_STATE_NORMAL, &color);
|
||||
gtk_widget_modify_bg (da, GTK_STATE_NORMAL, color);
|
||||
}
|
||||
|
||||
g_free (color);
|
||||
gtk_widget_destroy (dialog);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_colorsel (void)
|
||||
do_colorsel (GtkWidget *do_widget)
|
||||
{
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *button;
|
||||
GtkWidget *alignment;
|
||||
GtkWidget *da;
|
||||
GtkWidget *window = get_cached_widget (do_widget, "do_colorsel");
|
||||
GdkColor *color;
|
||||
|
||||
if (!window)
|
||||
{
|
||||
color.red = 0;
|
||||
color.blue = 65535;
|
||||
color.green = 0;
|
||||
color = g_new (GdkColor, 1);
|
||||
color->red = 0;
|
||||
color->blue = 65535;
|
||||
color->green = 0;
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_screen (GTK_WINDOW (window),
|
||||
gtk_widget_get_screen (do_widget));
|
||||
cache_widget (window, "do_colorsel");
|
||||
cache_pointer (window, "do_colorsel_color", color);
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Color Selection");
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (window), "destroy", GTK_SIGNAL_FUNC (gtk_widget_destroyed), &window);
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (remove_cached_widget),
|
||||
"do_colorsel");
|
||||
|
||||
gtk_container_set_border_width (GTK_CONTAINER (window), 8);
|
||||
|
||||
@@ -78,11 +90,12 @@ do_colorsel (void)
|
||||
|
||||
da = gtk_drawing_area_new ();
|
||||
/* set a minimum size */
|
||||
gtk_widget_set_usize (da, 200, 200);
|
||||
gtk_widget_set_size_request (da, 200, 200);
|
||||
/* set the color */
|
||||
gtk_widget_modify_bg (da, GTK_STATE_NORMAL, &color);
|
||||
gtk_widget_modify_bg (da, GTK_STATE_NORMAL, color);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (frame), da);
|
||||
cache_widget (da, "do_colorsel_da");
|
||||
|
||||
alignment = gtk_alignment_new (1.0, 0.5, 0.0, 0.0);
|
||||
|
||||
@@ -91,9 +104,8 @@ do_colorsel (void)
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (vbox), alignment, FALSE, FALSE, 0);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
GTK_SIGNAL_FUNC (change_color_callback),
|
||||
NULL);
|
||||
g_signal_connect (button, "clicked",
|
||||
G_CALLBACK (change_color_callback), NULL);
|
||||
}
|
||||
|
||||
if (!GTK_WIDGET_VISIBLE (window))
|
||||
|
22
demos/gtk-demo/demo-common.h
Normal file
22
demos/gtk-demo/demo-common.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef __DEMO_COMMON_H__
|
||||
#define __DEMO_COMMON_H__
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
gchar *demo_find_file (const gchar *base,
|
||||
GError **err);
|
||||
|
||||
GtkWidget *get_cached_widget (GtkWidget *widget,
|
||||
gchar *key);
|
||||
void cache_widget (GtkWidget *widget,
|
||||
gchar *key);
|
||||
gpointer get_cached_pointer (GtkWidget *widget,
|
||||
gchar *key);
|
||||
void cache_pointer (GtkWidget *widget,
|
||||
gchar *key,
|
||||
gpointer data);
|
||||
void remove_cached_widget (GtkWidget *widget,
|
||||
gchar *key);
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __DEMO_COMMON_H__ */
|
@@ -4,15 +4,14 @@
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
static GtkWidget *window = NULL;
|
||||
static GtkWidget *entry1 = NULL;
|
||||
static GtkWidget *entry2 = NULL;
|
||||
#include "demo-common.h"
|
||||
|
||||
static void
|
||||
message_dialog_clicked (GtkButton *button, gpointer user_data)
|
||||
message_dialog_clicked (GtkButton *button,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
GtkWidget *window = get_cached_widget (GTK_WIDGET (button), "do_dialog");
|
||||
static gint i = 1;
|
||||
|
||||
dialog = gtk_message_dialog_new (GTK_WINDOW (window),
|
||||
@@ -28,7 +27,8 @@ message_dialog_clicked (GtkButton *button, gpointer user_data)
|
||||
}
|
||||
|
||||
static void
|
||||
interactive_dialog_clicked (GtkButton *button, gpointer user_data)
|
||||
interactive_dialog_clicked (GtkButton *button,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
GtkWidget *hbox;
|
||||
@@ -38,14 +38,20 @@ interactive_dialog_clicked (GtkButton *button, gpointer user_data)
|
||||
GtkWidget *local_entry2;
|
||||
GtkWidget *label;
|
||||
gint response;
|
||||
GtkWidget *window = get_cached_widget (GTK_WIDGET (button), "do_dialog");
|
||||
GtkWidget *entry1 = get_cached_widget (GTK_WIDGET (button),
|
||||
"do_dialog_entry_1");
|
||||
GtkWidget *entry2 = get_cached_widget (GTK_WIDGET (button),
|
||||
"do_dialog_entry_2");
|
||||
|
||||
dialog = gtk_dialog_new_with_buttons ("Interactive Dialog",
|
||||
GTK_WINDOW (window),
|
||||
GTK_DIALOG_MODAL| GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_STOCK_BUTTON_OK,
|
||||
GTK_STOCK_OK,
|
||||
GTK_RESPONSE_OK,
|
||||
"_Non-stock Button",
|
||||
GTK_RESPONSE_CANCEL,
|
||||
NULL);
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 8);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (hbox), 8);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox, FALSE, FALSE, 0);
|
||||
@@ -59,7 +65,7 @@ interactive_dialog_clicked (GtkButton *button, gpointer user_data)
|
||||
gtk_box_pack_start (GTK_BOX (hbox), table, TRUE, TRUE, 0);
|
||||
label = gtk_label_new_with_mnemonic ("_Entry 1");
|
||||
gtk_table_attach_defaults (GTK_TABLE (table),
|
||||
label,
|
||||
label,
|
||||
0, 1, 0, 1);
|
||||
local_entry1 = gtk_entry_new ();
|
||||
gtk_entry_set_text (GTK_ENTRY (local_entry1), gtk_entry_get_text (GTK_ENTRY (entry1)));
|
||||
@@ -68,7 +74,7 @@ interactive_dialog_clicked (GtkButton *button, gpointer user_data)
|
||||
|
||||
label = gtk_label_new_with_mnemonic ("E_ntry 2");
|
||||
gtk_table_attach_defaults (GTK_TABLE (table),
|
||||
label,
|
||||
label,
|
||||
0, 1, 1, 2);
|
||||
|
||||
local_entry2 = gtk_entry_new ();
|
||||
@@ -89,7 +95,7 @@ interactive_dialog_clicked (GtkButton *button, gpointer user_data)
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_dialog (void)
|
||||
do_dialog (GtkWidget *do_widget)
|
||||
{
|
||||
GtkWidget *frame;
|
||||
GtkWidget *vbox;
|
||||
@@ -98,13 +104,20 @@ do_dialog (void)
|
||||
GtkWidget *button;
|
||||
GtkWidget *table;
|
||||
GtkWidget *label;
|
||||
GtkWidget *window = get_cached_widget (do_widget, "do_dialog");
|
||||
GtkWidget *entry1;
|
||||
GtkWidget *entry2;
|
||||
|
||||
if (!window)
|
||||
{
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Dialogs");
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (window), "destroy", GTK_SIGNAL_FUNC (gtk_widget_destroyed), &window);
|
||||
gtk_window_set_screen (GTK_WINDOW (window),
|
||||
gtk_widget_get_screen (do_widget));
|
||||
cache_widget (window, "do_dialog");
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (remove_cached_widget),
|
||||
"do_dialog");
|
||||
gtk_container_set_border_width (GTK_CONTAINER (window), 8);
|
||||
|
||||
frame = gtk_frame_new ("Dialogs");
|
||||
@@ -118,8 +131,8 @@ do_dialog (void)
|
||||
hbox = gtk_hbox_new (FALSE, 8);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
||||
button = gtk_button_new_with_mnemonic ("_Message Dialog");
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
GTK_SIGNAL_FUNC (message_dialog_clicked), NULL);
|
||||
g_signal_connect (button, "clicked",
|
||||
G_CALLBACK (message_dialog_clicked), NULL);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (vbox), gtk_hseparator_new (), FALSE, FALSE, 0);
|
||||
@@ -130,8 +143,8 @@ do_dialog (void)
|
||||
vbox2 = gtk_vbox_new (FALSE, 0);
|
||||
|
||||
button = gtk_button_new_with_mnemonic ("_Interactive Dialog");
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
GTK_SIGNAL_FUNC (interactive_dialog_clicked), NULL);
|
||||
g_signal_connect (button, "clicked",
|
||||
G_CALLBACK (interactive_dialog_clicked), NULL);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), vbox2, FALSE, FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0);
|
||||
|
||||
@@ -142,22 +155,24 @@ do_dialog (void)
|
||||
|
||||
label = gtk_label_new_with_mnemonic ("_Entry 1");
|
||||
gtk_table_attach_defaults (GTK_TABLE (table),
|
||||
label,
|
||||
0, 1, 0, 1);
|
||||
label,
|
||||
0, 1, 0, 1);
|
||||
|
||||
entry1 = gtk_entry_new ();
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), entry1, 1, 2, 0, 1);
|
||||
gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry1);
|
||||
cache_widget (entry1, "do_dialog_entry_1");
|
||||
|
||||
label = gtk_label_new_with_mnemonic ("E_ntry 2");
|
||||
|
||||
gtk_table_attach_defaults (GTK_TABLE (table),
|
||||
label,
|
||||
0, 1, 1, 2);
|
||||
label,
|
||||
0, 1, 1, 2);
|
||||
|
||||
entry2 = gtk_entry_new ();
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), entry2, 1, 2, 1, 2);
|
||||
gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry2);
|
||||
cache_widget (entry2, "do_dialog_entry_2");
|
||||
}
|
||||
|
||||
if (!GTK_WIDGET_VISIBLE (window))
|
||||
@@ -165,7 +180,7 @@ do_dialog (void)
|
||||
gtk_widget_show_all (window);
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
gtk_widget_destroy (window);
|
||||
window = NULL;
|
||||
}
|
||||
|
@@ -14,24 +14,24 @@
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
static GtkWidget *window = NULL;
|
||||
/* Pixmap for scribble area, to store current scribbles */
|
||||
static GdkPixmap *pixmap = NULL;
|
||||
#include "demo-common.h"
|
||||
|
||||
/* Create a new pixmap of the appropriate size to store our scribbles */
|
||||
static gboolean
|
||||
scribble_configure_event (GtkWidget *widget,
|
||||
GdkEventConfigure *event,
|
||||
gpointer data)
|
||||
scribble_configure_event (GtkWidget *widget,
|
||||
GdkEventConfigure *event,
|
||||
gpointer data)
|
||||
{
|
||||
GdkPixmap *pixmap = get_cached_pointer (widget, "do_drawingarea_pixmap");
|
||||
if (pixmap)
|
||||
g_object_unref (G_OBJECT (pixmap));
|
||||
|
||||
/* Pixmap for scribble area, to store current scribbles */
|
||||
pixmap = gdk_pixmap_new (widget->window,
|
||||
widget->allocation.width,
|
||||
widget->allocation.height,
|
||||
-1);
|
||||
widget->allocation.width,
|
||||
widget->allocation.height,
|
||||
-1);
|
||||
cache_pointer (widget, "do_drawingarea_pixmap", pixmap);
|
||||
|
||||
/* Initialize the pixmap to white */
|
||||
gdk_draw_rectangle (pixmap,
|
||||
@@ -48,8 +48,8 @@ scribble_configure_event (GtkWidget *widget,
|
||||
/* Redraw the screen from the pixmap */
|
||||
static gboolean
|
||||
scribble_expose_event (GtkWidget *widget,
|
||||
GdkEventExpose *event,
|
||||
gpointer data)
|
||||
GdkEventExpose *event,
|
||||
gpointer data)
|
||||
{
|
||||
/* We use the "foreground GC" for the widget since it already exists,
|
||||
* but honestly any GC would work. The only thing to worry about
|
||||
@@ -57,12 +57,12 @@ scribble_expose_event (GtkWidget *widget,
|
||||
*/
|
||||
|
||||
gdk_draw_drawable (widget->window,
|
||||
widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
|
||||
pixmap,
|
||||
/* Only copy the area that was exposed. */
|
||||
event->area.x, event->area.y,
|
||||
event->area.x, event->area.y,
|
||||
event->area.width, event->area.height);
|
||||
widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
|
||||
get_cached_pointer (widget, "do_drawingarea_pixmap"),
|
||||
/* Only copy the area that was exposed. */
|
||||
event->area.x, event->area.y,
|
||||
event->area.x, event->area.y,
|
||||
event->area.width, event->area.height);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
@@ -70,8 +70,8 @@ scribble_expose_event (GtkWidget *widget,
|
||||
/* Draw a rectangle on the screen */
|
||||
static void
|
||||
draw_brush (GtkWidget *widget,
|
||||
gdouble x,
|
||||
gdouble y)
|
||||
gdouble x,
|
||||
gdouble y)
|
||||
{
|
||||
GdkRectangle update_rect;
|
||||
|
||||
@@ -81,7 +81,7 @@ draw_brush (GtkWidget *widget,
|
||||
update_rect.height = 6;
|
||||
|
||||
/* Paint to the pixmap, where we store our state */
|
||||
gdk_draw_rectangle (pixmap,
|
||||
gdk_draw_rectangle (get_cached_pointer (widget, "do_drawingarea_pixmap"),
|
||||
widget->style->black_gc,
|
||||
TRUE,
|
||||
update_rect.x, update_rect.y,
|
||||
@@ -89,16 +89,16 @@ draw_brush (GtkWidget *widget,
|
||||
|
||||
/* Now invalidate the affected region of the drawing area. */
|
||||
gdk_window_invalidate_rect (widget->window,
|
||||
&update_rect,
|
||||
FALSE);
|
||||
&update_rect,
|
||||
FALSE);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
scribble_button_press_event (GtkWidget *widget,
|
||||
GdkEventButton *event,
|
||||
gpointer data)
|
||||
scribble_button_press_event (GtkWidget *widget,
|
||||
GdkEventButton *event,
|
||||
gpointer data)
|
||||
{
|
||||
if (pixmap == NULL)
|
||||
if (get_cached_pointer (widget, "do_drawingarea_pixmap") == NULL)
|
||||
return FALSE; /* paranoia check, in case we haven't gotten a configure event */
|
||||
|
||||
if (event->button == 1)
|
||||
@@ -109,14 +109,14 @@ scribble_button_press_event (GtkWidget *widget,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
scribble_motion_notify_event (GtkWidget *widget,
|
||||
GdkEventMotion *event,
|
||||
gpointer data)
|
||||
scribble_motion_notify_event (GtkWidget *widget,
|
||||
GdkEventMotion *event,
|
||||
gpointer data)
|
||||
{
|
||||
int x, y;
|
||||
GdkModifierType state;
|
||||
|
||||
if (pixmap == NULL)
|
||||
if (get_cached_pointer (widget, "do_drawingarea_pixmap") == NULL)
|
||||
return FALSE; /* paranoia check, in case we haven't gotten a configure event */
|
||||
|
||||
/* This call is very important; it requests the next motion event.
|
||||
@@ -141,9 +141,9 @@ scribble_motion_notify_event (GtkWidget *widget,
|
||||
|
||||
|
||||
static gboolean
|
||||
checkerboard_expose (GtkWidget *da,
|
||||
GdkEventExpose *event,
|
||||
gpointer data)
|
||||
checkerboard_expose (GtkWidget *da,
|
||||
GdkEventExpose *event,
|
||||
gpointer data)
|
||||
{
|
||||
gint i, j, xcount, ycount;
|
||||
GdkGC *gc1, *gc2;
|
||||
@@ -182,28 +182,28 @@ checkerboard_expose (GtkWidget *da,
|
||||
j = SPACING;
|
||||
ycount = xcount % 2; /* start with even/odd depending on row */
|
||||
while (j < da->allocation.height)
|
||||
{
|
||||
GdkGC *gc;
|
||||
|
||||
if (ycount % 2)
|
||||
gc = gc1;
|
||||
else
|
||||
gc = gc2;
|
||||
{
|
||||
GdkGC *gc;
|
||||
|
||||
if (ycount % 2)
|
||||
gc = gc1;
|
||||
else
|
||||
gc = gc2;
|
||||
|
||||
/* If we're outside event->area, this will do nothing.
|
||||
* It might be mildly more efficient if we handled
|
||||
* the clipping ourselves, but again we're feeling lazy.
|
||||
*/
|
||||
gdk_draw_rectangle (da->window,
|
||||
gc,
|
||||
TRUE,
|
||||
i, j,
|
||||
CHECK_SIZE,
|
||||
CHECK_SIZE);
|
||||
/* If we're outside event->area, this will do nothing.
|
||||
* It might be mildly more efficient if we handled
|
||||
* the clipping ourselves, but again we're feeling lazy.
|
||||
*/
|
||||
gdk_draw_rectangle (da->window,
|
||||
gc,
|
||||
TRUE,
|
||||
i, j,
|
||||
CHECK_SIZE,
|
||||
CHECK_SIZE);
|
||||
|
||||
j += CHECK_SIZE + SPACING;
|
||||
++ycount;
|
||||
}
|
||||
j += CHECK_SIZE + SPACING;
|
||||
++ycount;
|
||||
}
|
||||
|
||||
i += CHECK_SIZE + SPACING;
|
||||
++xcount;
|
||||
@@ -219,19 +219,24 @@ checkerboard_expose (GtkWidget *da,
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_drawingarea (void)
|
||||
do_drawingarea (GtkWidget *do_widget)
|
||||
{
|
||||
GtkWidget *frame;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *da;
|
||||
GtkWidget *label;
|
||||
|
||||
GtkWidget *window = get_cached_widget (do_widget, "do_drawingarea");
|
||||
|
||||
if (!window)
|
||||
{
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Drawing Area");
|
||||
gtk_window_set_screen (GTK_WINDOW (window),
|
||||
gtk_widget_get_screen (do_widget));
|
||||
cache_widget (window, "do_drawingarea");
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (window), "destroy", GTK_SIGNAL_FUNC (gtk_widget_destroyed), &window);
|
||||
g_signal_connect (window, "destroy", G_CALLBACK (remove_cached_widget),
|
||||
"do_drawingarea");
|
||||
|
||||
gtk_container_set_border_width (GTK_CONTAINER (window), 8);
|
||||
|
||||
@@ -245,7 +250,7 @@ do_drawingarea (void)
|
||||
|
||||
label = gtk_label_new (NULL);
|
||||
gtk_label_set_markup (GTK_LABEL (label),
|
||||
"<u>Checkerboard pattern</u>");
|
||||
"<u>Checkerboard pattern</u>");
|
||||
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
@@ -254,14 +259,12 @@ do_drawingarea (void)
|
||||
|
||||
da = gtk_drawing_area_new ();
|
||||
/* set a minimum size */
|
||||
gtk_widget_set_usize (da, 100, 100);
|
||||
gtk_widget_set_size_request (da, 100, 100);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (frame), da);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (da),
|
||||
"expose_event",
|
||||
GTK_SIGNAL_FUNC (checkerboard_expose),
|
||||
NULL);
|
||||
g_signal_connect (da, "expose_event",
|
||||
G_CALLBACK (checkerboard_expose), NULL);
|
||||
|
||||
/*
|
||||
* Create the scribble area
|
||||
@@ -269,7 +272,7 @@ do_drawingarea (void)
|
||||
|
||||
label = gtk_label_new (NULL);
|
||||
gtk_label_set_markup (GTK_LABEL (label),
|
||||
"<u>Scribble area</u>");
|
||||
"<u>Scribble area</u>");
|
||||
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
@@ -278,33 +281,33 @@ do_drawingarea (void)
|
||||
|
||||
da = gtk_drawing_area_new ();
|
||||
/* set a minimum size */
|
||||
gtk_widget_set_usize (da, 100, 100);
|
||||
gtk_widget_set_size_request (da, 100, 100);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (frame), da);
|
||||
|
||||
/* Signals used to handle backing pixmap */
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (da), "expose_event",
|
||||
GTK_SIGNAL_FUNC (scribble_expose_event), NULL);
|
||||
gtk_signal_connect (GTK_OBJECT (da),"configure_event",
|
||||
GTK_SIGNAL_FUNC (scribble_configure_event), NULL);
|
||||
g_signal_connect (da, "expose_event",
|
||||
G_CALLBACK (scribble_expose_event), NULL);
|
||||
g_signal_connect (da,"configure_event",
|
||||
G_CALLBACK (scribble_configure_event), NULL);
|
||||
|
||||
/* Event signals */
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (da), "motion_notify_event",
|
||||
GTK_SIGNAL_FUNC (scribble_motion_notify_event), NULL);
|
||||
gtk_signal_connect (GTK_OBJECT (da), "button_press_event",
|
||||
GTK_SIGNAL_FUNC (scribble_button_press_event), NULL);
|
||||
g_signal_connect (da, "motion_notify_event",
|
||||
G_CALLBACK (scribble_motion_notify_event), NULL);
|
||||
g_signal_connect (da, "button_press_event",
|
||||
G_CALLBACK (scribble_button_press_event), NULL);
|
||||
|
||||
|
||||
/* Ask to receive events the drawing area doesn't normally
|
||||
* subscribe to
|
||||
*/
|
||||
gtk_widget_set_events (da, gtk_widget_get_events (da)
|
||||
| GDK_LEAVE_NOTIFY_MASK
|
||||
| GDK_BUTTON_PRESS_MASK
|
||||
| GDK_POINTER_MOTION_MASK
|
||||
| GDK_POINTER_MOTION_HINT_MASK);
|
||||
| GDK_LEAVE_NOTIFY_MASK
|
||||
| GDK_BUTTON_PRESS_MASK
|
||||
| GDK_POINTER_MOTION_MASK
|
||||
| GDK_POINTER_MOTION_HINT_MASK);
|
||||
|
||||
}
|
||||
|
||||
|
306
demos/gtk-demo/editable_cells.c
Normal file
306
demos/gtk-demo/editable_cells.c
Normal file
@@ -0,0 +1,306 @@
|
||||
/* Tree View/Editable Cells
|
||||
*
|
||||
* This demo demonstrates the use of editable cells in a GtkTreeView. If
|
||||
* you're new to the GtkTreeView widgets and associates, look into
|
||||
* the GtkListStore example first.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "demo-common.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gint number;
|
||||
gchar *product;
|
||||
gboolean editable;
|
||||
}
|
||||
Item;
|
||||
|
||||
enum
|
||||
{
|
||||
COLUMN_NUMBER,
|
||||
COLUMN_PRODUCT,
|
||||
COLUMN_EDITABLE,
|
||||
NUM_COLUMNS
|
||||
};
|
||||
|
||||
static GArray *articles = NULL;
|
||||
|
||||
static void
|
||||
add_items (void)
|
||||
{
|
||||
Item foo;
|
||||
|
||||
g_return_if_fail (articles != NULL);
|
||||
|
||||
foo.number = 3;
|
||||
foo.product = g_strdup ("bottles of coke");
|
||||
foo.editable = TRUE;
|
||||
g_array_append_vals (articles, &foo, 1);
|
||||
|
||||
foo.number = 5;
|
||||
foo.product = g_strdup ("packages of noodles");
|
||||
foo.editable = TRUE;
|
||||
g_array_append_vals (articles, &foo, 1);
|
||||
|
||||
foo.number = 2;
|
||||
foo.product = g_strdup ("packages of chocolate chip cookies");
|
||||
foo.editable = TRUE;
|
||||
g_array_append_vals (articles, &foo, 1);
|
||||
|
||||
foo.number = 1;
|
||||
foo.product = g_strdup ("can vanilla ice cream");
|
||||
foo.editable = TRUE;
|
||||
g_array_append_vals (articles, &foo, 1);
|
||||
|
||||
foo.number = 6;
|
||||
foo.product = g_strdup ("eggs");
|
||||
foo.editable = TRUE;
|
||||
g_array_append_vals (articles, &foo, 1);
|
||||
}
|
||||
|
||||
static GtkTreeModel *
|
||||
create_model (void)
|
||||
{
|
||||
gint i = 0;
|
||||
GtkListStore *model;
|
||||
GtkTreeIter iter;
|
||||
|
||||
/* create array */
|
||||
articles = g_array_sized_new (FALSE, FALSE, sizeof (Item), 1);
|
||||
|
||||
add_items ();
|
||||
|
||||
/* create list store */
|
||||
model = gtk_list_store_new (NUM_COLUMNS, G_TYPE_INT, G_TYPE_STRING,
|
||||
G_TYPE_BOOLEAN);
|
||||
|
||||
/* add items */
|
||||
for (i = 0; i < articles->len; i++)
|
||||
{
|
||||
gtk_list_store_append (model, &iter);
|
||||
|
||||
gtk_list_store_set (model, &iter,
|
||||
COLUMN_NUMBER,
|
||||
g_array_index (articles, Item, i).number,
|
||||
COLUMN_PRODUCT,
|
||||
g_array_index (articles, Item, i).product,
|
||||
COLUMN_EDITABLE,
|
||||
g_array_index (articles, Item, i).editable,
|
||||
-1);
|
||||
}
|
||||
|
||||
return GTK_TREE_MODEL (model);
|
||||
}
|
||||
|
||||
static void
|
||||
add_item (GtkWidget *button, gpointer data)
|
||||
{
|
||||
Item foo;
|
||||
GtkTreeIter iter;
|
||||
GtkTreeModel *model = (GtkTreeModel *)data;
|
||||
|
||||
g_return_if_fail (articles != NULL);
|
||||
|
||||
foo.number = 0;
|
||||
foo.product = g_strdup ("Description here");
|
||||
foo.editable = TRUE;
|
||||
g_array_append_vals (articles, &foo, 1);
|
||||
|
||||
gtk_list_store_append (GTK_LIST_STORE (model), &iter);
|
||||
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
|
||||
COLUMN_NUMBER, foo.number,
|
||||
COLUMN_PRODUCT, foo.product,
|
||||
COLUMN_EDITABLE, foo.editable,
|
||||
-1);
|
||||
}
|
||||
|
||||
static void
|
||||
remove_item (GtkWidget *widget, gpointer data)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
GtkTreeView *treeview = (GtkTreeView *)data;
|
||||
GtkTreeModel *model = gtk_tree_view_get_model (treeview);
|
||||
GtkTreeSelection *selection = gtk_tree_view_get_selection (treeview);
|
||||
|
||||
if (gtk_tree_selection_get_selected (selection, NULL, &iter))
|
||||
{
|
||||
gint i;
|
||||
GtkTreePath *path;
|
||||
|
||||
path = gtk_tree_model_get_path (model, &iter);
|
||||
i = gtk_tree_path_get_indices (path)[0];
|
||||
gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
|
||||
|
||||
g_array_remove_index (articles, i);
|
||||
|
||||
gtk_tree_path_free (path);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
cell_edited (GtkCellRendererText *cell,
|
||||
const gchar *path_string,
|
||||
const gchar *new_text,
|
||||
gpointer data)
|
||||
{
|
||||
GtkTreeModel *model = (GtkTreeModel *)data;
|
||||
GtkTreePath *path = gtk_tree_path_new_from_string (path_string);
|
||||
GtkTreeIter iter;
|
||||
|
||||
gint *column;
|
||||
|
||||
column = g_object_get_data (G_OBJECT (cell), "column");
|
||||
|
||||
gtk_tree_model_get_iter (model, &iter, path);
|
||||
|
||||
switch ((gint) column)
|
||||
{
|
||||
case COLUMN_NUMBER:
|
||||
{
|
||||
gint i;
|
||||
|
||||
i = gtk_tree_path_get_indices (path)[0];
|
||||
g_array_index (articles, Item, i).number = atoi (new_text);
|
||||
|
||||
gtk_list_store_set (GTK_LIST_STORE (model), &iter, column,
|
||||
g_array_index (articles, Item, i).number, -1);
|
||||
}
|
||||
break;
|
||||
|
||||
case COLUMN_PRODUCT:
|
||||
{
|
||||
gint i;
|
||||
gchar *old_text;
|
||||
|
||||
gtk_tree_model_get (model, &iter, column, &old_text, -1);
|
||||
g_free (old_text);
|
||||
|
||||
i = gtk_tree_path_get_indices (path)[0];
|
||||
g_free (g_array_index (articles, Item, i).product);
|
||||
g_array_index (articles, Item, i).product = g_strdup (new_text);
|
||||
|
||||
gtk_list_store_set (GTK_LIST_STORE (model), &iter, column,
|
||||
g_array_index (articles, Item, i).product, -1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
gtk_tree_path_free (path);
|
||||
}
|
||||
|
||||
static void
|
||||
add_columns (GtkTreeView *treeview)
|
||||
{
|
||||
GtkCellRenderer *renderer;
|
||||
GtkTreeModel *model = gtk_tree_view_get_model (treeview);
|
||||
|
||||
/* number column */
|
||||
renderer = gtk_cell_renderer_text_new ();
|
||||
g_signal_connect (G_OBJECT (renderer), "edited",
|
||||
G_CALLBACK (cell_edited), model);
|
||||
g_object_set_data (G_OBJECT (renderer), "column", (gint *)COLUMN_NUMBER);
|
||||
|
||||
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview),
|
||||
-1, "Number", renderer,
|
||||
"text", COLUMN_NUMBER,
|
||||
"editable", COLUMN_EDITABLE,
|
||||
NULL);
|
||||
|
||||
/* product column */
|
||||
renderer = gtk_cell_renderer_text_new ();
|
||||
g_signal_connect (G_OBJECT (renderer), "edited",
|
||||
G_CALLBACK (cell_edited), model);
|
||||
g_object_set_data (G_OBJECT (renderer), "column", (gint *)COLUMN_PRODUCT);
|
||||
|
||||
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview),
|
||||
-1, "Product", renderer,
|
||||
"text", COLUMN_PRODUCT,
|
||||
"editable", COLUMN_EDITABLE,
|
||||
NULL);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_editable_cells (GtkWidget *do_widget)
|
||||
{
|
||||
GtkWidget *window = get_cached_widget (do_widget, "do_editable_cells");
|
||||
|
||||
if (!window)
|
||||
{
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *sw;
|
||||
GtkWidget *treeview;
|
||||
GtkWidget *button;
|
||||
GtkTreeModel *model;
|
||||
|
||||
/* create window, etc */
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_screen (GTK_WINDOW (window),
|
||||
gtk_widget_get_screen (do_widget));
|
||||
cache_widget (window, "do_editable_cells");
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Shopping list");
|
||||
gtk_container_set_border_width (GTK_CONTAINER (window), 5);
|
||||
g_signal_connect (G_OBJECT (window), "destroy",
|
||||
G_CALLBACK (remove_cached_widget),
|
||||
"do_editable_cells");
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 5);
|
||||
gtk_container_add (GTK_CONTAINER (window), vbox);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (vbox),
|
||||
gtk_label_new ("Shopping list (you can edit the cells!)"),
|
||||
FALSE, FALSE, 0);
|
||||
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_SHADOW_ETCHED_IN);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0);
|
||||
|
||||
/* create model */
|
||||
model = create_model ();
|
||||
|
||||
/* create tree view */
|
||||
treeview = gtk_tree_view_new_with_model (model);
|
||||
g_object_unref (G_OBJECT (model));
|
||||
gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (treeview), TRUE);
|
||||
gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview)),
|
||||
GTK_SELECTION_SINGLE);
|
||||
|
||||
add_columns (GTK_TREE_VIEW (treeview));
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (sw), treeview);
|
||||
|
||||
/* some buttons */
|
||||
hbox = gtk_hbox_new (TRUE, 4);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
||||
|
||||
button = gtk_button_new_with_label ("Add item");
|
||||
g_signal_connect (G_OBJECT (button), "clicked",
|
||||
G_CALLBACK (add_item), model);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
|
||||
|
||||
button = gtk_button_new_with_label ("Remove item");
|
||||
g_signal_connect (G_OBJECT (button), "clicked",
|
||||
G_CALLBACK (remove_item), treeview);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
|
||||
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 320, 200);
|
||||
}
|
||||
|
||||
if (!GTK_WIDGET_VISIBLE (window))
|
||||
gtk_widget_show_all (window);
|
||||
else
|
||||
{
|
||||
gtk_widget_destroy (window);
|
||||
window = NULL;
|
||||
}
|
||||
|
||||
return window;
|
||||
}
|
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
print <<EOT;
|
||||
typedef GtkWidget *(*GDoDemoFunc) (void);
|
||||
typedef GtkWidget *(*GDoDemoFunc) (GtkWidget *do_widget);
|
||||
|
||||
typedef struct _Demo Demo;
|
||||
|
||||
@@ -10,22 +10,16 @@ struct _Demo
|
||||
gchar *title;
|
||||
gchar *filename;
|
||||
GDoDemoFunc func;
|
||||
Demo *children;
|
||||
};
|
||||
|
||||
EOT
|
||||
|
||||
$array = "";
|
||||
$first = 1;
|
||||
for $file (@ARGV) {
|
||||
my %demo;
|
||||
|
||||
($basename = $file) =~ s/\.c$//;
|
||||
|
||||
if ($first) {
|
||||
$first = 0;
|
||||
} else {
|
||||
$array .= ",\n";
|
||||
}
|
||||
|
||||
open INFO_FILE, $file or die "Cannot open '$file'\n";
|
||||
$title = <INFO_FILE>;
|
||||
$title =~ s@^\s*/\*\s*@@;
|
||||
@@ -33,10 +27,137 @@ for $file (@ARGV) {
|
||||
|
||||
close INFO_FILE;
|
||||
|
||||
print "GtkWidget *do_$basename (void);\n";
|
||||
$array .= qq( { "$title", "$file", do_$basename });
|
||||
print "GtkWidget *do_$basename (GtkWidget *do_widget);\n";
|
||||
|
||||
push @demos, {"title" => $title, "file" => $file,
|
||||
"func" => "do_$basename"};
|
||||
}
|
||||
|
||||
print "\nDemo testgtk_demos[] = {";
|
||||
print $array;
|
||||
# generate a list of 'parent names'
|
||||
foreach $href (@demos) {
|
||||
if ($href->{"title"} =~ m|^([\w\s]+)/[\w\s]+$|) {
|
||||
my $parent_name = $1;
|
||||
my $do_next = 0;
|
||||
|
||||
# parent detected
|
||||
if (defined @parents) {
|
||||
foreach $foo (@parents) {
|
||||
if ($foo eq $parent_name) {
|
||||
$do_next = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ($do_next) {
|
||||
next;
|
||||
}
|
||||
}
|
||||
|
||||
push @parents, $parent_name;
|
||||
|
||||
$tmp = (defined @child_arrays)?($#child_arrays + 1):0;
|
||||
push @child_arrays, "child$tmp";
|
||||
|
||||
push @demos, {"title" => $parent_name, "file" => "NULL",
|
||||
"func" => "NULL"};
|
||||
}
|
||||
}
|
||||
|
||||
if (defined @parents) {
|
||||
$i = 0;
|
||||
for ($i = 0; $i <= $#parents; $i++) {
|
||||
$first = 1;
|
||||
|
||||
print "\nDemo ", $child_arrays[$i], "[] = {\n";
|
||||
|
||||
$j = 0;
|
||||
for ($j = 0; $j <= $#demos; $j++) {
|
||||
$href = $demos[$j];
|
||||
|
||||
if (!defined $demos[$j]) {
|
||||
next;
|
||||
}
|
||||
|
||||
if ($demos[$j]{"title"} =~ m|^$parents[$i]/([\w\s]+)$|) {
|
||||
if ($first) {
|
||||
$first = 0;
|
||||
} else {
|
||||
print ",\n";
|
||||
}
|
||||
|
||||
print qq ( { "$1", "$demos[$j]{file}", $demos[$j]{func}, NULL });
|
||||
|
||||
# hack ... ugly
|
||||
$demos[$j]{"title"} = "foo";
|
||||
}
|
||||
}
|
||||
|
||||
print ",\n";
|
||||
print qq ( { NULL } );
|
||||
print "\n};\n";
|
||||
}
|
||||
}
|
||||
|
||||
# sort @demos
|
||||
@demos_old = @demos;
|
||||
|
||||
@demos = sort {
|
||||
$a->{"title"} cmp $b->{"title"};
|
||||
} @demos_old;
|
||||
|
||||
# sort the child arrays
|
||||
if (defined @child_arrays) {
|
||||
for ($i = 0; $i <= $#child_arrays; $i++) {
|
||||
@foo_old = @{$child_arrays[$i]};
|
||||
|
||||
@{$child_arrays[$i]} = sort {
|
||||
$a->{"title"} cmp $b->{"title"};
|
||||
} @foo_old;
|
||||
}
|
||||
}
|
||||
|
||||
# toplevel
|
||||
print "\nDemo testgtk_demos[] = {\n";
|
||||
|
||||
$first = 1;
|
||||
foreach $href (@demos) {
|
||||
$handled = 0;
|
||||
|
||||
# ugly evil hack
|
||||
if ($href->{title} eq "foo") {
|
||||
next;
|
||||
}
|
||||
|
||||
if ($first) {
|
||||
$first = 0;
|
||||
} else {
|
||||
print ", \n";
|
||||
}
|
||||
|
||||
if (defined @parents) {
|
||||
for ($i = 0; $i <= $#parents; $i++) {
|
||||
if ($parents[$i] eq $href->{title}) {
|
||||
|
||||
if ($href->{file} eq 'NULL') {
|
||||
print qq ( { "$href->{title}", NULL, $href->{func}, $child_arrays[$i] });
|
||||
} else {
|
||||
print qq ( { "$href->{title}", "$href->{file}", $href->{func}, $child_arrays[$i] });
|
||||
}
|
||||
|
||||
$handled = 1;
|
||||
last;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($handled) {
|
||||
next;
|
||||
}
|
||||
|
||||
print qq ( { "$href->{title}", "$href->{file}", $href->{func}, NULL });
|
||||
}
|
||||
|
||||
print ",\n";
|
||||
print qq ( { NULL } );
|
||||
print "\n};\n";
|
||||
|
||||
exit 0;
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
print <<EOT;
|
||||
typedef GtkWidget *(*GDoDemoFunc) (void);
|
||||
typedef GtkWidget *(*GDoDemoFunc) (GtkWidget *do_widget);
|
||||
|
||||
typedef struct _Demo Demo;
|
||||
|
||||
@@ -10,22 +10,16 @@ struct _Demo
|
||||
gchar *title;
|
||||
gchar *filename;
|
||||
GDoDemoFunc func;
|
||||
Demo *children;
|
||||
};
|
||||
|
||||
EOT
|
||||
|
||||
$array = "";
|
||||
$first = 1;
|
||||
for $file (@ARGV) {
|
||||
my %demo;
|
||||
|
||||
($basename = $file) =~ s/\.c$//;
|
||||
|
||||
if ($first) {
|
||||
$first = 0;
|
||||
} else {
|
||||
$array .= ",\n";
|
||||
}
|
||||
|
||||
open INFO_FILE, $file or die "Cannot open '$file'\n";
|
||||
$title = <INFO_FILE>;
|
||||
$title =~ s@^\s*/\*\s*@@;
|
||||
@@ -33,10 +27,137 @@ for $file (@ARGV) {
|
||||
|
||||
close INFO_FILE;
|
||||
|
||||
print "GtkWidget *do_$basename (void);\n";
|
||||
$array .= qq( { "$title", "$file", do_$basename });
|
||||
print "GtkWidget *do_$basename (GtkWidget *do_widget);\n";
|
||||
|
||||
push @demos, {"title" => $title, "file" => $file,
|
||||
"func" => "do_$basename"};
|
||||
}
|
||||
|
||||
print "\nDemo testgtk_demos[] = {";
|
||||
print $array;
|
||||
# generate a list of 'parent names'
|
||||
foreach $href (@demos) {
|
||||
if ($href->{"title"} =~ m|^([\w\s]+)/[\w\s]+$|) {
|
||||
my $parent_name = $1;
|
||||
my $do_next = 0;
|
||||
|
||||
# parent detected
|
||||
if (defined @parents) {
|
||||
foreach $foo (@parents) {
|
||||
if ($foo eq $parent_name) {
|
||||
$do_next = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ($do_next) {
|
||||
next;
|
||||
}
|
||||
}
|
||||
|
||||
push @parents, $parent_name;
|
||||
|
||||
$tmp = (defined @child_arrays)?($#child_arrays + 1):0;
|
||||
push @child_arrays, "child$tmp";
|
||||
|
||||
push @demos, {"title" => $parent_name, "file" => "NULL",
|
||||
"func" => "NULL"};
|
||||
}
|
||||
}
|
||||
|
||||
if (defined @parents) {
|
||||
$i = 0;
|
||||
for ($i = 0; $i <= $#parents; $i++) {
|
||||
$first = 1;
|
||||
|
||||
print "\nDemo ", $child_arrays[$i], "[] = {\n";
|
||||
|
||||
$j = 0;
|
||||
for ($j = 0; $j <= $#demos; $j++) {
|
||||
$href = $demos[$j];
|
||||
|
||||
if (!defined $demos[$j]) {
|
||||
next;
|
||||
}
|
||||
|
||||
if ($demos[$j]{"title"} =~ m|^$parents[$i]/([\w\s]+)$|) {
|
||||
if ($first) {
|
||||
$first = 0;
|
||||
} else {
|
||||
print ",\n";
|
||||
}
|
||||
|
||||
print qq ( { "$1", "$demos[$j]{file}", $demos[$j]{func}, NULL });
|
||||
|
||||
# hack ... ugly
|
||||
$demos[$j]{"title"} = "foo";
|
||||
}
|
||||
}
|
||||
|
||||
print ",\n";
|
||||
print qq ( { NULL } );
|
||||
print "\n};\n";
|
||||
}
|
||||
}
|
||||
|
||||
# sort @demos
|
||||
@demos_old = @demos;
|
||||
|
||||
@demos = sort {
|
||||
$a->{"title"} cmp $b->{"title"};
|
||||
} @demos_old;
|
||||
|
||||
# sort the child arrays
|
||||
if (defined @child_arrays) {
|
||||
for ($i = 0; $i <= $#child_arrays; $i++) {
|
||||
@foo_old = @{$child_arrays[$i]};
|
||||
|
||||
@{$child_arrays[$i]} = sort {
|
||||
$a->{"title"} cmp $b->{"title"};
|
||||
} @foo_old;
|
||||
}
|
||||
}
|
||||
|
||||
# toplevel
|
||||
print "\nDemo testgtk_demos[] = {\n";
|
||||
|
||||
$first = 1;
|
||||
foreach $href (@demos) {
|
||||
$handled = 0;
|
||||
|
||||
# ugly evil hack
|
||||
if ($href->{title} eq "foo") {
|
||||
next;
|
||||
}
|
||||
|
||||
if ($first) {
|
||||
$first = 0;
|
||||
} else {
|
||||
print ", \n";
|
||||
}
|
||||
|
||||
if (defined @parents) {
|
||||
for ($i = 0; $i <= $#parents; $i++) {
|
||||
if ($parents[$i] eq $href->{title}) {
|
||||
|
||||
if ($href->{file} eq 'NULL') {
|
||||
print qq ( { "$href->{title}", NULL, $href->{func}, $child_arrays[$i] });
|
||||
} else {
|
||||
print qq ( { "$href->{title}", "$href->{file}", $href->{func}, $child_arrays[$i] });
|
||||
}
|
||||
|
||||
$handled = 1;
|
||||
last;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($handled) {
|
||||
next;
|
||||
}
|
||||
|
||||
print qq ( { "$href->{title}", "$href->{file}", $href->{func}, NULL });
|
||||
}
|
||||
|
||||
print ",\n";
|
||||
print qq ( { NULL } );
|
||||
print "\n};\n";
|
||||
|
||||
exit 0;
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 6.3 KiB |
@@ -15,17 +15,36 @@
|
||||
#include <gtk/gtk.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include "demo-common.h"
|
||||
|
||||
static GtkWidget *window = NULL;
|
||||
static GdkPixbufLoader *pixbuf_loader = NULL;
|
||||
static guint load_timeout = 0;
|
||||
static FILE* image_stream = NULL;
|
||||
|
||||
typedef struct {
|
||||
GdkPixbufLoader *pixbuf_loader;
|
||||
guint load_timeout;
|
||||
FILE* image_stream;
|
||||
} ImageVarPerScr;
|
||||
|
||||
static ImageVarPerScr * get_image_var (GtkWidget *widget,
|
||||
gchar *key)
|
||||
{
|
||||
ImageVarPerScr *tmp =
|
||||
g_object_get_data (G_OBJECT (gtk_widget_get_screen (widget)),
|
||||
key);
|
||||
if (tmp)
|
||||
return tmp;
|
||||
|
||||
tmp = g_new0 (ImageVarPerScr, 1);
|
||||
g_object_set_data (G_OBJECT (gtk_widget_get_screen (widget)),
|
||||
key, tmp);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
static void
|
||||
progressive_prepared_callback (GdkPixbufLoader* loader, gpointer data)
|
||||
progressive_prepared_callback (GdkPixbufLoader *loader,
|
||||
gpointer data)
|
||||
{
|
||||
GdkPixbuf* pixbuf;
|
||||
GtkWidget* image;
|
||||
GdkPixbuf *pixbuf;
|
||||
GtkWidget *image;
|
||||
|
||||
image = GTK_WIDGET (data);
|
||||
|
||||
@@ -40,11 +59,14 @@ progressive_prepared_callback (GdkPixbufLoader* loader, gpointer data)
|
||||
}
|
||||
|
||||
static void
|
||||
progressive_updated_callback (GdkPixbufLoader* loader,
|
||||
gint x, gint y, gint width, gint height,
|
||||
gpointer data)
|
||||
progressive_updated_callback (GdkPixbufLoader *loader,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
gpointer data)
|
||||
{
|
||||
GtkWidget* image;
|
||||
GtkWidget *image;
|
||||
|
||||
image = GTK_WIDGET (data);
|
||||
|
||||
@@ -62,176 +84,177 @@ progressive_updated_callback (GdkPixbufLoader* loader,
|
||||
static gint
|
||||
progressive_timeout (gpointer data)
|
||||
{
|
||||
GtkWidget *image;
|
||||
GtkWidget *image = GTK_WIDGET (data);
|
||||
GtkWidget *window = get_cached_widget (image, "do_images");
|
||||
ImageVarPerScr *i = get_image_var (window, "do_images_var");
|
||||
|
||||
image = GTK_WIDGET (data);
|
||||
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
if (image_stream)
|
||||
if (i->image_stream)
|
||||
{
|
||||
size_t bytes_read;
|
||||
guchar buf[256];
|
||||
GError *error = NULL;
|
||||
|
||||
bytes_read = fread (buf, 1, 256, image_stream);
|
||||
bytes_read = fread (buf, 1, 256, i->image_stream);
|
||||
|
||||
if (ferror (image_stream))
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
|
||||
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));
|
||||
if (ferror (i->image_stream))
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
|
||||
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));
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (dialog),
|
||||
"response",
|
||||
GTK_SIGNAL_FUNC (gtk_widget_destroy),
|
||||
NULL);
|
||||
g_signal_connect (dialog, "response",
|
||||
G_CALLBACK (gtk_widget_destroy), NULL);
|
||||
|
||||
fclose (image_stream);
|
||||
image_stream = NULL;
|
||||
fclose (i->image_stream);
|
||||
i->image_stream = NULL;
|
||||
|
||||
gtk_widget_show (dialog);
|
||||
|
||||
load_timeout = 0;
|
||||
gtk_widget_show (dialog);
|
||||
|
||||
i->load_timeout = 0;
|
||||
|
||||
return FALSE; /* uninstall the timeout */
|
||||
}
|
||||
return FALSE; /* uninstall the timeout */
|
||||
}
|
||||
|
||||
if (!gdk_pixbuf_loader_write (pixbuf_loader,
|
||||
buf, bytes_read,
|
||||
&error))
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
|
||||
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);
|
||||
if (!gdk_pixbuf_loader_write (i->pixbuf_loader,
|
||||
buf, bytes_read,
|
||||
&error))
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
|
||||
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);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (dialog),
|
||||
"response",
|
||||
GTK_SIGNAL_FUNC (gtk_widget_destroy),
|
||||
NULL);
|
||||
g_error_free (error);
|
||||
|
||||
g_signal_connect (dialog, "response",
|
||||
G_CALLBACK (gtk_widget_destroy), NULL);
|
||||
|
||||
fclose (image_stream);
|
||||
image_stream = NULL;
|
||||
|
||||
gtk_widget_show (dialog);
|
||||
fclose (i->image_stream);
|
||||
i->image_stream = NULL;
|
||||
|
||||
gtk_widget_show (dialog);
|
||||
|
||||
load_timeout = 0;
|
||||
i->load_timeout = 0;
|
||||
|
||||
return FALSE; /* uninstall the timeout */
|
||||
}
|
||||
return FALSE; /* uninstall the timeout */
|
||||
}
|
||||
|
||||
if (feof (image_stream))
|
||||
{
|
||||
fclose (image_stream);
|
||||
image_stream = NULL;
|
||||
if (feof (i->image_stream))
|
||||
{
|
||||
fclose (i->image_stream);
|
||||
i->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;
|
||||
|
||||
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);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (dialog),
|
||||
"response",
|
||||
GTK_SIGNAL_FUNC (gtk_widget_destroy),
|
||||
NULL);
|
||||
|
||||
gtk_widget_show (dialog);
|
||||
/* 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 (i->pixbuf_loader,
|
||||
&error))
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
|
||||
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);
|
||||
|
||||
g_signal_connect (dialog, "response",
|
||||
G_CALLBACK (gtk_widget_destroy), NULL);
|
||||
|
||||
gtk_widget_show (dialog);
|
||||
|
||||
g_object_unref (G_OBJECT (pixbuf_loader));
|
||||
pixbuf_loader = NULL;
|
||||
|
||||
load_timeout = 0;
|
||||
|
||||
return FALSE; /* uninstall the timeout */
|
||||
}
|
||||
|
||||
g_object_unref (G_OBJECT (pixbuf_loader));
|
||||
pixbuf_loader = NULL;
|
||||
}
|
||||
g_object_unref (G_OBJECT (i->pixbuf_loader));
|
||||
i->pixbuf_loader = NULL;
|
||||
|
||||
i->load_timeout = 0;
|
||||
|
||||
return FALSE; /* uninstall the timeout */
|
||||
}
|
||||
|
||||
g_object_unref (G_OBJECT (i->pixbuf_loader));
|
||||
i->pixbuf_loader = NULL;
|
||||
}
|
||||
}
|
||||
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";
|
||||
{
|
||||
i->image_stream = fopen (filename, "r");
|
||||
g_free (filename);
|
||||
|
||||
if (!i->image_stream)
|
||||
error_message = g_strdup_printf ("Unable to open image file 'alphatest.png': %s",
|
||||
g_strerror (errno));
|
||||
}
|
||||
|
||||
if (i->image_stream == NULL)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
|
||||
dialog = gtk_message_dialog_new (GTK_WINDOW (window),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"%s", error_message);
|
||||
g_free (error_message);
|
||||
|
||||
g_signal_connect (dialog, "response",
|
||||
G_CALLBACK (gtk_widget_destroy), NULL);
|
||||
|
||||
gtk_widget_show (dialog);
|
||||
|
||||
i->load_timeout = 0;
|
||||
|
||||
return FALSE; /* uninstall the timeout */
|
||||
}
|
||||
|
||||
if (i->pixbuf_loader)
|
||||
{
|
||||
gdk_pixbuf_loader_close (i->pixbuf_loader, NULL);
|
||||
g_object_unref (G_OBJECT (i->pixbuf_loader));
|
||||
i->pixbuf_loader = NULL;
|
||||
}
|
||||
|
||||
image_stream = fopen (filename, "r");
|
||||
|
||||
if (image_stream == NULL)
|
||||
{
|
||||
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 'alphatest.png': %s",
|
||||
g_strerror (errno));
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (dialog),
|
||||
"response",
|
||||
GTK_SIGNAL_FUNC (gtk_widget_destroy),
|
||||
NULL);
|
||||
|
||||
gtk_widget_show (dialog);
|
||||
|
||||
load_timeout = 0;
|
||||
|
||||
return FALSE; /* uninstall the timeout */
|
||||
}
|
||||
|
||||
if (pixbuf_loader)
|
||||
{
|
||||
gdk_pixbuf_loader_close (pixbuf_loader, NULL);
|
||||
g_object_unref (G_OBJECT (pixbuf_loader));
|
||||
pixbuf_loader = NULL;
|
||||
}
|
||||
i->pixbuf_loader = gdk_pixbuf_loader_new ();
|
||||
|
||||
pixbuf_loader = gdk_pixbuf_loader_new ();
|
||||
g_signal_connect (G_OBJECT (i->pixbuf_loader), "area_prepared",
|
||||
G_CALLBACK (progressive_prepared_callback), image);
|
||||
|
||||
g_signal_connect_data (G_OBJECT (pixbuf_loader),
|
||||
"area_prepared",
|
||||
G_CALLBACK (progressive_prepared_callback),
|
||||
image,
|
||||
NULL, FALSE, FALSE);
|
||||
|
||||
g_signal_connect_data (G_OBJECT (pixbuf_loader),
|
||||
"area_updated",
|
||||
G_CALLBACK (progressive_updated_callback),
|
||||
image,
|
||||
NULL, FALSE, FALSE);
|
||||
g_signal_connect (G_OBJECT (i->pixbuf_loader), "area_updated",
|
||||
G_CALLBACK (progressive_updated_callback), image);
|
||||
}
|
||||
|
||||
/* leave timeout installed */
|
||||
@@ -248,49 +271,91 @@ start_progressive_loading (GtkWidget *image)
|
||||
* The timeout simply simulates a slow data source by inserting
|
||||
* pauses in the reading process.
|
||||
*/
|
||||
load_timeout = g_timeout_add (150,
|
||||
progressive_timeout,
|
||||
image);
|
||||
ImageVarPerScr *i = get_image_var (image, "do_images_var");
|
||||
i->load_timeout = g_timeout_add (150,
|
||||
progressive_timeout,
|
||||
image);
|
||||
}
|
||||
|
||||
static void
|
||||
cleanup_callback (GtkObject *object,
|
||||
gpointer data)
|
||||
gpointer data)
|
||||
{
|
||||
if (load_timeout)
|
||||
ImageVarPerScr *i = get_image_var (GTK_WIDGET (object), "do_images_var");
|
||||
g_object_set_data (G_OBJECT (gtk_widget_get_screen (GTK_WIDGET (object))),
|
||||
"do_images_var", NULL);
|
||||
|
||||
if (i->load_timeout)
|
||||
{
|
||||
g_source_remove (load_timeout);
|
||||
load_timeout = 0;
|
||||
g_source_remove (i->load_timeout);
|
||||
i->load_timeout = 0;
|
||||
}
|
||||
|
||||
if (pixbuf_loader)
|
||||
if (i->pixbuf_loader)
|
||||
{
|
||||
gdk_pixbuf_loader_close (pixbuf_loader, NULL);
|
||||
g_object_unref (G_OBJECT (pixbuf_loader));
|
||||
pixbuf_loader = NULL;
|
||||
gdk_pixbuf_loader_close (i->pixbuf_loader, NULL);
|
||||
g_object_unref (G_OBJECT (i->pixbuf_loader));
|
||||
i->pixbuf_loader = NULL;
|
||||
}
|
||||
|
||||
if (image_stream)
|
||||
fclose (image_stream);
|
||||
image_stream = NULL;
|
||||
if (i->image_stream)
|
||||
fclose (i->image_stream);
|
||||
i->image_stream = NULL;
|
||||
|
||||
g_free (i);
|
||||
}
|
||||
|
||||
static void
|
||||
toggle_sensitivity_callback (GtkWidget *togglebutton,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkContainer *container = user_data;
|
||||
GList *list;
|
||||
GList *tmp;
|
||||
|
||||
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)));
|
||||
|
||||
tmp = tmp->next;
|
||||
}
|
||||
|
||||
g_list_free (list);
|
||||
}
|
||||
|
||||
|
||||
GtkWidget *
|
||||
do_images (void)
|
||||
do_images (GtkWidget *do_widget)
|
||||
{
|
||||
GtkWidget *frame;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *image;
|
||||
GtkWidget *label;
|
||||
GtkWidget *align;
|
||||
|
||||
GtkWidget *button;
|
||||
GdkPixbuf *pixbuf;
|
||||
GError *error = NULL;
|
||||
char *filename;
|
||||
GtkWidget *window = get_cached_widget (do_widget, "do_images");
|
||||
|
||||
if (!window)
|
||||
{
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_screen (GTK_WINDOW (window),
|
||||
gtk_widget_get_screen (do_widget));
|
||||
cache_widget (window, "do_images");
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Images");
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (window), "destroy", GTK_SIGNAL_FUNC (gtk_widget_destroyed), &window);
|
||||
gtk_signal_connect (GTK_OBJECT (window), "destroy", GTK_SIGNAL_FUNC (cleanup_callback), NULL);
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (cleanup_callback), NULL);
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (remove_cached_widget), "do_images");
|
||||
|
||||
gtk_container_set_border_width (GTK_CONTAINER (window), 8);
|
||||
|
||||
@@ -300,7 +365,7 @@ do_images (void)
|
||||
|
||||
label = gtk_label_new (NULL);
|
||||
gtk_label_set_markup (GTK_LABEL (label),
|
||||
"<u>Image loaded from a file</u>");
|
||||
"<u>Image loaded from a file</u>");
|
||||
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
@@ -312,52 +377,42 @@ 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))
|
||||
{
|
||||
/* 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.
|
||||
*/
|
||||
GdkPixbuf *pixbuf;
|
||||
GError *error = NULL;
|
||||
|
||||
pixbuf = gdk_pixbuf_new_from_file ("./gtk-logo-rgb.gif",
|
||||
&error);
|
||||
if (error)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
pixbuf = NULL;
|
||||
filename = demo_find_file ("gtk-logo-rgb.gif", &error);
|
||||
if (filename)
|
||||
{
|
||||
pixbuf = gdk_pixbuf_new_from_file (filename, &error);
|
||||
g_free (filename);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (dialog),
|
||||
"response",
|
||||
GTK_SIGNAL_FUNC (gtk_widget_destroy),
|
||||
NULL);
|
||||
|
||||
gtk_widget_show (dialog);
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
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
|
||||
* 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.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
image = gtk_image_new_from_pixbuf (pixbuf);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (frame), image);
|
||||
|
||||
@@ -366,7 +421,7 @@ do_images (void)
|
||||
|
||||
label = gtk_label_new (NULL);
|
||||
gtk_label_set_markup (GTK_LABEL (label),
|
||||
"<u>Animation loaded from a file</u>");
|
||||
"<u>Animation loaded from a file</u>");
|
||||
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
@@ -378,13 +433,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);
|
||||
|
||||
@@ -394,7 +445,7 @@ do_images (void)
|
||||
|
||||
label = gtk_label_new (NULL);
|
||||
gtk_label_set_markup (GTK_LABEL (label),
|
||||
"<u>Progressive image loading</u>");
|
||||
"<u>Progressive image loading</u>");
|
||||
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
@@ -413,6 +464,14 @@ do_images (void)
|
||||
gtk_container_add (GTK_CONTAINER (frame), image);
|
||||
|
||||
start_progressive_loading (image);
|
||||
|
||||
/* Sensitivity control */
|
||||
button = gtk_toggle_button_new_with_mnemonic ("_Insensitive");
|
||||
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
||||
|
||||
g_signal_connect (G_OBJECT (button), "toggled",
|
||||
G_CALLBACK (toggle_sensitivity_callback),
|
||||
vbox);
|
||||
}
|
||||
|
||||
if (!GTK_WIDGET_VISIBLE (window))
|
||||
|
@@ -5,46 +5,48 @@
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include "demo-common.h"
|
||||
|
||||
static void
|
||||
gtk_ifactory_cb (gpointer callback_data,
|
||||
guint callback_action,
|
||||
GtkWidget *widget)
|
||||
gtk_ifactory_cb (gpointer callback_data,
|
||||
guint callback_action,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
g_message ("ItemFactory: activated \"%s\"", gtk_item_factory_path_from_widget (widget));
|
||||
g_message ("ItemFactory: activated \"%s\"",
|
||||
gtk_item_factory_path_from_widget (widget));
|
||||
}
|
||||
|
||||
static GtkItemFactoryEntry menu_items[] =
|
||||
{
|
||||
{ "/_File", NULL, 0, 0, "<Branch>" },
|
||||
{ "/File/tearoff1", NULL, gtk_ifactory_cb, 0, "<Tearoff>" },
|
||||
{ "/File/_New", "<control>N", gtk_ifactory_cb, 0 },
|
||||
{ "/File/_Open", "<control>O", gtk_ifactory_cb, 0 },
|
||||
{ "/File/_Save", "<control>S", gtk_ifactory_cb, 0 },
|
||||
{ "/File/Save _As...", NULL, gtk_ifactory_cb, 0 },
|
||||
{ "/File/sep1", NULL, gtk_ifactory_cb, 0, "<Separator>" },
|
||||
{ "/File/_Quit", "<control>Q", gtk_ifactory_cb, 0 },
|
||||
{ "/_File", NULL, 0, 0, "<Branch>" },
|
||||
{ "/File/tearoff1", NULL, gtk_ifactory_cb, 0, "<Tearoff>" },
|
||||
{ "/File/_New", "<control>N", gtk_ifactory_cb, 0 },
|
||||
{ "/File/_Open", "<control>O", gtk_ifactory_cb, 0 },
|
||||
{ "/File/_Save", "<control>S", gtk_ifactory_cb, 0 },
|
||||
{ "/File/Save _As...", NULL, gtk_ifactory_cb, 0 },
|
||||
{ "/File/sep1", NULL, gtk_ifactory_cb, 0, "<Separator>" },
|
||||
{ "/File/_Quit", "<control>Q", gtk_ifactory_cb, 0 },
|
||||
|
||||
{ "/_Preferences", NULL, 0, 0, "<Branch>" },
|
||||
{ "/_Preferences/_Color", NULL, 0, 0, "<Branch>" },
|
||||
{ "/_Preferences/Color/_Red", NULL, gtk_ifactory_cb, 0, "<RadioItem>" },
|
||||
{ "/_Preferences/Color/_Green", NULL, gtk_ifactory_cb, 0, "/Preferences/Color/Red" },
|
||||
{ "/_Preferences/Color/_Blue", NULL, gtk_ifactory_cb, 0, "/Preferences/Color/Red" },
|
||||
{ "/_Preferences/_Shape", NULL, 0, 0, "<Branch>" },
|
||||
{ "/_Preferences/Shape/_Square", NULL, gtk_ifactory_cb, 0, "<RadioItem>" },
|
||||
{ "/_Preferences/Shape/_Rectangle", NULL, gtk_ifactory_cb, 0, "/Preferences/Shape/Square" },
|
||||
{ "/_Preferences/Shape/_Oval", NULL, gtk_ifactory_cb, 0, "/Preferences/Shape/Rectangle" },
|
||||
{ "/_Preferences", NULL, 0, 0, "<Branch>" },
|
||||
{ "/_Preferences/_Color", NULL, 0, 0, "<Branch>" },
|
||||
{ "/_Preferences/Color/_Red", NULL, gtk_ifactory_cb, 0, "<RadioItem>" },
|
||||
{ "/_Preferences/Color/_Green", NULL, gtk_ifactory_cb, 0, "/Preferences/Color/Red" },
|
||||
{ "/_Preferences/Color/_Blue", NULL, gtk_ifactory_cb, 0, "/Preferences/Color/Red" },
|
||||
{ "/_Preferences/_Shape", NULL, 0, 0, "<Branch>" },
|
||||
{ "/_Preferences/Shape/_Square", NULL, gtk_ifactory_cb, 0, "<RadioItem>" },
|
||||
{ "/_Preferences/Shape/_Rectangle", NULL, gtk_ifactory_cb, 0, "/Preferences/Shape/Square" },
|
||||
{ "/_Preferences/Shape/_Oval", NULL, gtk_ifactory_cb, 0, "/Preferences/Shape/Rectangle" },
|
||||
|
||||
{ "/_Help", NULL, 0, 0, "<LastBranch>" },
|
||||
{ "/Help/_About", NULL, gtk_ifactory_cb, 0 },
|
||||
{ "/_Help", NULL, 0, 0, "<LastBranch>" },
|
||||
{ "/Help/_About", NULL, gtk_ifactory_cb, 0 },
|
||||
};
|
||||
|
||||
static int nmenu_items = sizeof (menu_items) / sizeof (menu_items[0]);
|
||||
|
||||
GtkWidget *
|
||||
do_item_factory (void)
|
||||
do_item_factory (GtkWidget *do_widget)
|
||||
{
|
||||
static GtkWidget *window = NULL;
|
||||
GtkWidget *window = get_cached_widget (do_widget, "do_item_factory");
|
||||
|
||||
if (!window)
|
||||
{
|
||||
@@ -57,30 +59,30 @@ do_item_factory (void)
|
||||
GtkItemFactory *item_factory;
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_screen (GTK_WINDOW (window),
|
||||
gtk_widget_get_screen (do_widget));
|
||||
cache_widget (window, "do_item_factory");
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (window), "destroy",
|
||||
GTK_SIGNAL_FUNC(gtk_widget_destroyed),
|
||||
&window);
|
||||
gtk_signal_connect (GTK_OBJECT (window), "delete-event",
|
||||
GTK_SIGNAL_FUNC (gtk_true),
|
||||
NULL);
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (remove_cached_widget), "do_item_factory");
|
||||
g_signal_connect (window, "delete-event",
|
||||
G_CALLBACK (gtk_true), NULL);
|
||||
|
||||
accel_group = gtk_accel_group_new ();
|
||||
item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>", accel_group);
|
||||
gtk_object_set_data_full (GTK_OBJECT (window),
|
||||
"<main>",
|
||||
item_factory,
|
||||
(GtkDestroyNotify) gtk_object_unref);
|
||||
gtk_accel_group_attach (accel_group, GTK_OBJECT (window));
|
||||
g_object_set_data_full (G_OBJECT (window), "<main>",
|
||||
item_factory, (GDestroyNotify) g_object_unref);
|
||||
gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Item Factory");
|
||||
gtk_container_set_border_width (GTK_CONTAINER (window), 0);
|
||||
gtk_item_factory_create_items (item_factory, nmenu_items, menu_items, NULL);
|
||||
|
||||
/* preselect /Preferences/Shape/Oval over the other radios
|
||||
*/
|
||||
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (gtk_item_factory_get_item (item_factory,
|
||||
"/Preferences/Shape/Oval")),
|
||||
TRUE);
|
||||
gtk_check_menu_item_set_active
|
||||
(GTK_CHECK_MENU_ITEM (gtk_item_factory_get_item (item_factory,
|
||||
"/Preferences/Shape/Oval")),
|
||||
TRUE);
|
||||
|
||||
box1 = gtk_vbox_new (FALSE, 0);
|
||||
gtk_container_add (GTK_CONTAINER (window), box1);
|
||||
@@ -90,7 +92,7 @@ do_item_factory (void)
|
||||
FALSE, FALSE, 0);
|
||||
|
||||
label = gtk_label_new ("Type\n<alt>\nto start");
|
||||
gtk_widget_set_usize (label, 200, 200);
|
||||
gtk_widget_set_size_request (label, 200, 200);
|
||||
gtk_misc_set_alignment (GTK_MISC (label), 0.5, 0.5);
|
||||
gtk_box_pack_start (GTK_BOX (box1), label, TRUE, TRUE, 0);
|
||||
|
||||
@@ -104,9 +106,8 @@ do_item_factory (void)
|
||||
gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, TRUE, 0);
|
||||
|
||||
button = gtk_button_new_with_label ("close");
|
||||
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
|
||||
GTK_SIGNAL_FUNC(gtk_widget_destroy),
|
||||
GTK_OBJECT (window));
|
||||
g_signal_connect_swapped (button, "clicked",
|
||||
G_CALLBACK (gtk_widget_destroy), window);
|
||||
gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
|
||||
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
|
||||
gtk_widget_grab_default (button);
|
||||
|
222
demos/gtk-demo/list_store.c
Normal file
222
demos/gtk-demo/list_store.c
Normal file
@@ -0,0 +1,222 @@
|
||||
/* Tree View/List Store
|
||||
*
|
||||
* The GtkListStore is used to store data in list form, to be used
|
||||
* later on by a GtkTreeView to display it. This demo builds a
|
||||
* simple GtkListStore and displays it. See the Stock Browser
|
||||
* demo for a more advanced example.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include "demo-common.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const gboolean fixed;
|
||||
const guint number;
|
||||
const gchar *severity;
|
||||
const gchar *description;
|
||||
}
|
||||
Bug;
|
||||
|
||||
enum
|
||||
{
|
||||
COLUMN_FIXED,
|
||||
COLUMN_NUMBER,
|
||||
COLUMN_SEVERITY,
|
||||
COLUMN_DESCRIPTION,
|
||||
NUM_COLUMNS
|
||||
};
|
||||
|
||||
static Bug data[] =
|
||||
{
|
||||
{ FALSE, 60482, "Normal", "scrollable notebooks and hidden tabs" },
|
||||
{ FALSE, 60620, "Critical", "gdk_window_clear_area (gdkwindow-win32.c) is not thread-safe" },
|
||||
{ FALSE, 50214, "Major", "Xft support does not clean up correctly" },
|
||||
{ TRUE, 52877, "Major", "GtkFileSelection needs a refresh method. " },
|
||||
{ FALSE, 56070, "Normal", "Can't click button after setting in sensitive" },
|
||||
{ TRUE, 56355, "Normal", "GtkLabel - Not all changes propagate correctly" },
|
||||
{ FALSE, 50055, "Normal", "Rework width/height computations for TreeView" },
|
||||
{ FALSE, 58278, "Normal", "gtk_dialog_set_response_sensitive () doesn't work" },
|
||||
{ FALSE, 55767, "Normal", "Getters for all setters" },
|
||||
{ FALSE, 56925, "Normal", "Gtkcalender size" },
|
||||
{ FALSE, 56221, "Normal", "Selectable label needs right-click copy menu" },
|
||||
{ TRUE, 50939, "Normal", "Add shift clicking to GtkTextView" },
|
||||
{ FALSE, 6112, "Enhancement","netscape-like collapsable toolbars" },
|
||||
{ FALSE, 1, "Normal", "First bug :=)" },
|
||||
};
|
||||
|
||||
static GtkTreeModel *
|
||||
create_model (void)
|
||||
{
|
||||
gint i = 0;
|
||||
GtkListStore *store;
|
||||
GtkTreeIter iter;
|
||||
|
||||
/* create list store */
|
||||
store = gtk_list_store_new (NUM_COLUMNS,
|
||||
G_TYPE_BOOLEAN,
|
||||
G_TYPE_UINT,
|
||||
G_TYPE_STRING,
|
||||
G_TYPE_STRING);
|
||||
|
||||
/* add data to the list store */
|
||||
for (i = 0; i < G_N_ELEMENTS (data); i++)
|
||||
{
|
||||
gtk_list_store_append (store, &iter);
|
||||
gtk_list_store_set (store, &iter,
|
||||
COLUMN_FIXED, data[i].fixed,
|
||||
COLUMN_NUMBER, data[i].number,
|
||||
COLUMN_SEVERITY, data[i].severity,
|
||||
COLUMN_DESCRIPTION, data[i].description,
|
||||
-1);
|
||||
}
|
||||
|
||||
return GTK_TREE_MODEL (store);
|
||||
}
|
||||
|
||||
static void
|
||||
fixed_toggled (GtkCellRendererToggle *cell,
|
||||
gchar *path_str,
|
||||
gpointer data)
|
||||
{
|
||||
GtkTreeModel *model = (GtkTreeModel *)data;
|
||||
GtkTreeIter iter;
|
||||
GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
|
||||
gboolean fixed;
|
||||
|
||||
/* get toggled iter */
|
||||
gtk_tree_model_get_iter (model, &iter, path);
|
||||
gtk_tree_model_get (model, &iter, COLUMN_FIXED, &fixed, -1);
|
||||
|
||||
/* do something with the value */
|
||||
fixed ^= 1;
|
||||
|
||||
/* set new value */
|
||||
gtk_list_store_set (GTK_LIST_STORE (model), &iter, COLUMN_FIXED, fixed, -1);
|
||||
|
||||
/* clean up */
|
||||
gtk_tree_path_free (path);
|
||||
}
|
||||
|
||||
static void
|
||||
add_columns (GtkTreeView *treeview)
|
||||
{
|
||||
GtkCellRenderer *renderer;
|
||||
GtkTreeViewColumn *column;
|
||||
GtkTreeModel *model = gtk_tree_view_get_model (treeview);
|
||||
|
||||
/* column for fixed toggles */
|
||||
renderer = gtk_cell_renderer_toggle_new ();
|
||||
g_signal_connect (G_OBJECT (renderer), "toggled",
|
||||
G_CALLBACK (fixed_toggled), model);
|
||||
|
||||
column = gtk_tree_view_column_new_with_attributes ("Fixed?",
|
||||
renderer,
|
||||
"active", COLUMN_FIXED,
|
||||
NULL);
|
||||
|
||||
/* set this column to a fixed sizing (of 50 pixels) */
|
||||
gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column),
|
||||
GTK_TREE_VIEW_COLUMN_FIXED);
|
||||
gtk_tree_view_column_set_fixed_width (GTK_TREE_VIEW_COLUMN (column), 50);
|
||||
gtk_tree_view_append_column (treeview, column);
|
||||
|
||||
/* column for bug numbers */
|
||||
renderer = gtk_cell_renderer_text_new ();
|
||||
column = gtk_tree_view_column_new_with_attributes ("Bug number",
|
||||
renderer,
|
||||
"text",
|
||||
COLUMN_NUMBER,
|
||||
NULL);
|
||||
gtk_tree_view_column_set_sort_column_id (column, COLUMN_NUMBER);
|
||||
gtk_tree_view_append_column (treeview, column);
|
||||
|
||||
/* column for severities */
|
||||
renderer = gtk_cell_renderer_text_new ();
|
||||
column = gtk_tree_view_column_new_with_attributes ("Severity",
|
||||
renderer,
|
||||
"text",
|
||||
COLUMN_SEVERITY,
|
||||
NULL);
|
||||
gtk_tree_view_column_set_sort_column_id (column, COLUMN_SEVERITY);
|
||||
gtk_tree_view_append_column (treeview, column);
|
||||
|
||||
/* column for description */
|
||||
renderer = gtk_cell_renderer_text_new ();
|
||||
column = gtk_tree_view_column_new_with_attributes ("Description",
|
||||
renderer,
|
||||
"text",
|
||||
COLUMN_DESCRIPTION,
|
||||
NULL);
|
||||
gtk_tree_view_column_set_sort_column_id (column, COLUMN_DESCRIPTION);
|
||||
gtk_tree_view_append_column (treeview, column);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_list_store (GtkWidget *do_widget)
|
||||
{
|
||||
GtkWidget *window = get_cached_widget (do_widget, "do_list_store");
|
||||
|
||||
if (!window)
|
||||
{
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *label;
|
||||
GtkWidget *sw;
|
||||
GtkTreeModel *model;
|
||||
GtkWidget *treeview;
|
||||
|
||||
/* create window, etc */
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_title (GTK_WINDOW (window), "GtkListStore demo");
|
||||
gtk_window_set_screen (GTK_WINDOW (window),
|
||||
gtk_widget_get_screen (do_widget));
|
||||
cache_widget (window, "do_list_store");
|
||||
g_signal_connect (G_OBJECT (window), "destroy",
|
||||
G_CALLBACK (remove_cached_widget), "do_list_store");
|
||||
gtk_container_set_border_width (GTK_CONTAINER (window), 8);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 8);
|
||||
gtk_container_add (GTK_CONTAINER (window), vbox);
|
||||
|
||||
label = gtk_label_new ("This is the bug list (note: not based on real data, it would be nice to have a nice ODBC interface to bugzilla or so, though).");
|
||||
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
|
||||
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_SHADOW_ETCHED_IN);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_NEVER,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0);
|
||||
|
||||
/* create tree model */
|
||||
model = create_model ();
|
||||
|
||||
/* create tree view */
|
||||
treeview = gtk_tree_view_new_with_model (model);
|
||||
gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (treeview), TRUE);
|
||||
gtk_tree_view_set_search_column (GTK_TREE_VIEW (treeview),
|
||||
COLUMN_DESCRIPTION);
|
||||
|
||||
g_object_unref (G_OBJECT (model));
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (sw), treeview);
|
||||
|
||||
/* add columns to the tree view */
|
||||
add_columns (GTK_TREE_VIEW (treeview));
|
||||
|
||||
/* finish & show */
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 280, 250);
|
||||
}
|
||||
|
||||
if (!GTK_WIDGET_VISIBLE (window))
|
||||
gtk_widget_show_all (window);
|
||||
else
|
||||
{
|
||||
gtk_widget_destroy (window);
|
||||
window = NULL;
|
||||
}
|
||||
|
||||
return window;
|
||||
}
|
@@ -1,7 +1,7 @@
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
@@ -10,8 +10,11 @@
|
||||
static GtkTextBuffer *info_buffer;
|
||||
static GtkTextBuffer *source_buffer;
|
||||
|
||||
GtkWidget *notebook;
|
||||
|
||||
static gchar *current_file = NULL;
|
||||
|
||||
|
||||
enum {
|
||||
TITLE_COLUMN,
|
||||
FILENAME_COLUMN,
|
||||
@@ -27,6 +30,95 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get_cached_widget:
|
||||
* @widget: a widget on the same screen as the demo_widget.
|
||||
* @key: a string representing the cache key.
|
||||
*
|
||||
* Check is the widget is cached on this screen
|
||||
*
|
||||
* Return value: widget is present returns the widget,
|
||||
* NULL otherwise
|
||||
*/
|
||||
|
||||
GtkWidget * get_cached_widget (GtkWidget *widget,
|
||||
gchar *key)
|
||||
{
|
||||
GdkScreen *screen;
|
||||
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
|
||||
screen = gtk_widget_get_screen (widget);
|
||||
g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
|
||||
|
||||
return g_object_get_data (G_OBJECT (screen), key);
|
||||
}
|
||||
void cache_widget (GtkWidget *widget,
|
||||
gchar *key)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||
|
||||
g_object_set_data (G_OBJECT (gtk_widget_get_screen (widget)),
|
||||
key, widget);
|
||||
}
|
||||
|
||||
gpointer get_cached_pointer (GtkWidget *widget,
|
||||
gchar *key)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
|
||||
|
||||
return g_object_get_data (G_OBJECT (gtk_widget_get_screen (widget)), key);
|
||||
}
|
||||
void cache_pointer (GtkWidget *widget,
|
||||
gchar *key,
|
||||
gpointer data)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||
|
||||
g_object_set_data (G_OBJECT (gtk_widget_get_screen (widget)),
|
||||
key, data);
|
||||
}
|
||||
|
||||
void remove_cached_widget (GtkWidget *widget, gchar *key)
|
||||
{
|
||||
g_object_set_data (G_OBJECT (gtk_widget_get_screen (widget)),
|
||||
key, NULL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void
|
||||
window_closed_cb (GtkWidget *window, gpointer data)
|
||||
{
|
||||
@@ -52,7 +144,9 @@ read_line (FILE *stream, GString *str)
|
||||
{
|
||||
int n_read = 0;
|
||||
|
||||
#ifndef G_OS_WIN32
|
||||
flockfile (stream);
|
||||
#endif
|
||||
|
||||
g_string_truncate (str, 0);
|
||||
|
||||
@@ -60,7 +154,11 @@ read_line (FILE *stream, GString *str)
|
||||
{
|
||||
int c;
|
||||
|
||||
#ifndef G_OS_WIN32
|
||||
c = getc_unlocked (stream);
|
||||
#else
|
||||
c = getc (stream);
|
||||
#endif
|
||||
|
||||
if (c == EOF)
|
||||
goto done;
|
||||
@@ -72,7 +170,11 @@ read_line (FILE *stream, GString *str)
|
||||
case '\r':
|
||||
case '\n':
|
||||
{
|
||||
#ifndef G_OS_WIN32
|
||||
int next_c = getc_unlocked (stream);
|
||||
#else
|
||||
int next_c = getc (stream);
|
||||
#endif
|
||||
|
||||
if (!(next_c == EOF ||
|
||||
(c == '\r' && next_c == '\n') ||
|
||||
@@ -88,16 +190,285 @@ read_line (FILE *stream, GString *str)
|
||||
|
||||
done:
|
||||
|
||||
#ifndef G_OS_WIN32
|
||||
funlockfile (stream);
|
||||
#endif
|
||||
|
||||
return n_read > 0;
|
||||
}
|
||||
|
||||
|
||||
/* Stupid syntax highlighting.
|
||||
*
|
||||
* No regex was used in the making of this highlighting.
|
||||
* It should only work for simple cases. This is good, as
|
||||
* that's all we should have in the demos.
|
||||
*/
|
||||
/* This code should not be used elsewhere, except perhaps as an example of how
|
||||
* to iterate through a text buffer.
|
||||
*/
|
||||
enum {
|
||||
STATE_NORMAL,
|
||||
STATE_IN_COMMENT
|
||||
};
|
||||
|
||||
static gchar *tokens[] =
|
||||
{
|
||||
"/*",
|
||||
"\"",
|
||||
NULL
|
||||
};
|
||||
|
||||
static gchar *types[] =
|
||||
{
|
||||
"static",
|
||||
"const ",
|
||||
"void",
|
||||
"gint",
|
||||
"int ",
|
||||
"char ",
|
||||
"gchar ",
|
||||
"gfloat",
|
||||
"float",
|
||||
"gint8",
|
||||
"gint16",
|
||||
"gint32",
|
||||
"guint",
|
||||
"guint8",
|
||||
"guint16",
|
||||
"guint32",
|
||||
"guchar",
|
||||
"glong",
|
||||
"gboolean" ,
|
||||
"gshort",
|
||||
"gushort",
|
||||
"gulong",
|
||||
"gdouble",
|
||||
"gldouble",
|
||||
"gpointer",
|
||||
"NULL",
|
||||
"GList",
|
||||
"GSList",
|
||||
"FALSE",
|
||||
"TRUE",
|
||||
"FILE ",
|
||||
"GtkObject ",
|
||||
"GtkColorSelection ",
|
||||
"GtkWidget ",
|
||||
"GtkButton ",
|
||||
"GdkColor ",
|
||||
"GdkRectangle ",
|
||||
"GdkEventExpose ",
|
||||
"GdkGC ",
|
||||
"GdkPixbufLoader ",
|
||||
"GdkPixbuf ",
|
||||
"GError",
|
||||
"size_t",
|
||||
NULL
|
||||
};
|
||||
|
||||
static gchar *control[] =
|
||||
{
|
||||
" if ",
|
||||
" while ",
|
||||
" else",
|
||||
" do ",
|
||||
" for ",
|
||||
"?",
|
||||
":",
|
||||
"return ",
|
||||
"goto ",
|
||||
NULL
|
||||
};
|
||||
void
|
||||
parse_chars (gchar *text,
|
||||
gchar **end_ptr,
|
||||
gint *state,
|
||||
gchar **tag,
|
||||
gboolean start)
|
||||
{
|
||||
gint i;
|
||||
gchar *next_token;
|
||||
|
||||
/* Handle comments first */
|
||||
if (*state == STATE_IN_COMMENT)
|
||||
{
|
||||
*end_ptr = strstr (text, "*/");
|
||||
if (*end_ptr)
|
||||
{
|
||||
*end_ptr += 2;
|
||||
*state = STATE_NORMAL;
|
||||
*tag = "comment";
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
*tag = NULL;
|
||||
*end_ptr = NULL;
|
||||
|
||||
/* check for comment */
|
||||
if (!strncmp (text, "/*", 2))
|
||||
{
|
||||
*end_ptr = strstr (text, "*/");
|
||||
if (*end_ptr)
|
||||
*end_ptr += 2;
|
||||
else
|
||||
*state = STATE_IN_COMMENT;
|
||||
*tag = "comment";
|
||||
return;
|
||||
}
|
||||
|
||||
/* check for preprocessor defines */
|
||||
if (*text == '#' && start)
|
||||
{
|
||||
*end_ptr = NULL;
|
||||
*tag = "preprocessor";
|
||||
return;
|
||||
}
|
||||
|
||||
/* functions */
|
||||
if (start && * text != '\t' && *text != ' ' && *text != '{' && *text != '}')
|
||||
{
|
||||
if (strstr (text, "("))
|
||||
{
|
||||
*end_ptr = strstr (text, "(");
|
||||
*tag = "function";
|
||||
return;
|
||||
}
|
||||
}
|
||||
/* check for types */
|
||||
for (i = 0; types[i] != NULL; i++)
|
||||
if (!strncmp (text, types[i], strlen (types[i])))
|
||||
{
|
||||
*end_ptr = text + strlen (types[i]);
|
||||
*tag = "type";
|
||||
return;
|
||||
}
|
||||
|
||||
/* check for control */
|
||||
for (i = 0; control[i] != NULL; i++)
|
||||
if (!strncmp (text, control[i], strlen (control[i])))
|
||||
{
|
||||
*end_ptr = text + strlen (control[i]);
|
||||
*tag = "control";
|
||||
return;
|
||||
}
|
||||
|
||||
/* check for string */
|
||||
if (text[0] == '"')
|
||||
{
|
||||
gint maybe_escape = FALSE;
|
||||
|
||||
*end_ptr = text + 1;
|
||||
*tag = "string";
|
||||
while (**end_ptr != '\000')
|
||||
{
|
||||
if (**end_ptr == '\"' && !maybe_escape)
|
||||
{
|
||||
*end_ptr += 1;
|
||||
return;
|
||||
}
|
||||
if (**end_ptr == '\\')
|
||||
maybe_escape = TRUE;
|
||||
else
|
||||
maybe_escape = FALSE;
|
||||
*end_ptr += 1;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* not at the start of a tag. Find the next one. */
|
||||
for (i = 0; tokens[i] != NULL; i++)
|
||||
{
|
||||
next_token = strstr (text, tokens[i]);
|
||||
if (next_token)
|
||||
{
|
||||
if (*end_ptr)
|
||||
*end_ptr = (*end_ptr<next_token)?*end_ptr:next_token;
|
||||
else
|
||||
*end_ptr = next_token;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; types[i] != NULL; i++)
|
||||
{
|
||||
next_token = strstr (text, types[i]);
|
||||
if (next_token)
|
||||
{
|
||||
if (*end_ptr)
|
||||
*end_ptr = (*end_ptr<next_token)?*end_ptr:next_token;
|
||||
else
|
||||
*end_ptr = next_token;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; control[i] != NULL; i++)
|
||||
{
|
||||
next_token = strstr (text, control[i]);
|
||||
if (next_token)
|
||||
{
|
||||
if (*end_ptr)
|
||||
*end_ptr = (*end_ptr<next_token)?*end_ptr:next_token;
|
||||
else
|
||||
*end_ptr = next_token;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* While not as cool as c-mode, this will do as a quick attempt at highlighting */
|
||||
static void
|
||||
fontify ()
|
||||
{
|
||||
GtkTextIter start_iter, next_iter, tmp_iter;
|
||||
gint state;
|
||||
gchar *text;
|
||||
gchar *start_ptr, *end_ptr;
|
||||
gchar *tag;
|
||||
|
||||
state = STATE_NORMAL;
|
||||
|
||||
gtk_text_buffer_get_iter_at_offset (source_buffer, &start_iter, 0);
|
||||
|
||||
next_iter = start_iter;
|
||||
while (gtk_text_iter_forward_line (&next_iter))
|
||||
{
|
||||
gboolean start = TRUE;
|
||||
start_ptr = text = gtk_text_iter_get_text (&start_iter, &next_iter);
|
||||
|
||||
do
|
||||
{
|
||||
parse_chars (start_ptr, &end_ptr, &state, &tag, start);
|
||||
|
||||
start = FALSE;
|
||||
if (end_ptr)
|
||||
{
|
||||
tmp_iter = start_iter;
|
||||
gtk_text_iter_forward_chars (&tmp_iter, end_ptr - start_ptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp_iter = next_iter;
|
||||
}
|
||||
if (tag)
|
||||
gtk_text_buffer_apply_tag_by_name (source_buffer, tag, &start_iter, &tmp_iter);
|
||||
|
||||
start_iter = tmp_iter;
|
||||
start_ptr = end_ptr;
|
||||
}
|
||||
while (end_ptr);
|
||||
|
||||
g_free (text);
|
||||
start_iter = next_iter;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
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;
|
||||
@@ -117,40 +488,44 @@ 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");
|
||||
|
||||
if (!file)
|
||||
full_filename = demo_find_file (filename, &err);
|
||||
if (!full_filename)
|
||||
{
|
||||
char *installed = g_strconcat (DEMOCODEDIR,
|
||||
G_DIR_SEPARATOR_S,
|
||||
filename,
|
||||
NULL);
|
||||
|
||||
file = fopen (installed, "r");
|
||||
|
||||
g_free (installed);
|
||||
}
|
||||
|
||||
if (!file)
|
||||
{
|
||||
g_warning ("Cannot open %s: %s\n", filename, g_strerror (errno));
|
||||
g_warning ("%s", err->message);
|
||||
g_error_free (err);
|
||||
return;
|
||||
}
|
||||
|
||||
file = fopen (full_filename, "r");
|
||||
|
||||
if (!file)
|
||||
g_warning ("Cannot open %s: %s\n", full_filename, g_strerror (errno));
|
||||
|
||||
g_free (full_filename);
|
||||
|
||||
if (!file)
|
||||
return;
|
||||
|
||||
gtk_text_buffer_get_iter_at_offset (info_buffer, &start, 0);
|
||||
while (read_line (file, buffer))
|
||||
{
|
||||
gchar *p = buffer->str;
|
||||
gchar *q;
|
||||
gchar *r;
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case 0:
|
||||
/* Reading title */
|
||||
while (*p == '/' || *p == '*' || isspace (*p))
|
||||
while (*p == '/' || *p == '*' || g_ascii_isspace (*p))
|
||||
p++;
|
||||
r = p;
|
||||
while (*r != '/' && strlen (r))
|
||||
r++;
|
||||
if (strlen (r) > 0)
|
||||
p = r + 1;
|
||||
q = p + strlen (p);
|
||||
while (q > p && isspace (*(q - 1)))
|
||||
while (q > p && g_ascii_isspace (*(q - 1)))
|
||||
q--;
|
||||
|
||||
if (q > p)
|
||||
@@ -174,7 +549,7 @@ load_file (const gchar *filename)
|
||||
|
||||
case 1:
|
||||
/* Reading body of info section */
|
||||
while (isspace (*p))
|
||||
while (g_ascii_isspace (*p))
|
||||
p++;
|
||||
if (*p == '*' && *(p + 1) == '/')
|
||||
{
|
||||
@@ -185,11 +560,11 @@ load_file (const gchar *filename)
|
||||
{
|
||||
int len;
|
||||
|
||||
while (*p == '*' || isspace (*p))
|
||||
while (*p == '*' || g_ascii_isspace (*p))
|
||||
p++;
|
||||
|
||||
len = strlen (p);
|
||||
while (isspace (*(p + len - 1)))
|
||||
while (g_ascii_isspace (*(p + len - 1)))
|
||||
len--;
|
||||
|
||||
if (len > 0)
|
||||
@@ -211,7 +586,7 @@ load_file (const gchar *filename)
|
||||
|
||||
case 2:
|
||||
/* Skipping blank lines */
|
||||
while (isspace (*p))
|
||||
while (g_ascii_isspace (*p))
|
||||
p++;
|
||||
if (*p)
|
||||
{
|
||||
@@ -225,80 +600,16 @@ load_file (const gchar *filename)
|
||||
case 3:
|
||||
/* Reading program body */
|
||||
gtk_text_buffer_insert (source_buffer, &start, p, -1);
|
||||
gtk_text_buffer_insert (info_buffer, &start, "\n", 1);
|
||||
gtk_text_buffer_insert (source_buffer, &start, "\n", 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
gtk_text_buffer_get_bounds (source_buffer, &start, &end);
|
||||
gtk_text_buffer_apply_tag_by_name (info_buffer, "source", &start, &end);
|
||||
fontify ();
|
||||
|
||||
g_string_free (buffer, TRUE);
|
||||
}
|
||||
|
||||
gboolean
|
||||
button_press_event_cb (GtkTreeView *tree_view,
|
||||
GdkEventButton *event,
|
||||
GtkTreeModel *model)
|
||||
{
|
||||
if (event->type == GDK_2BUTTON_PRESS)
|
||||
{
|
||||
GtkTreePath *path = NULL;
|
||||
|
||||
gtk_tree_view_get_path_at_pos (tree_view,
|
||||
event->window,
|
||||
event->x,
|
||||
event->y,
|
||||
&path,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
if (path)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
gboolean italic;
|
||||
GDoDemoFunc func;
|
||||
GtkWidget *window;
|
||||
|
||||
gtk_tree_model_get_iter (model, &iter, path);
|
||||
gtk_tree_model_get (GTK_TREE_MODEL (model),
|
||||
&iter,
|
||||
FUNC_COLUMN, &func,
|
||||
ITALIC_COLUMN, &italic,
|
||||
-1);
|
||||
gtk_tree_store_set (GTK_TREE_STORE (model),
|
||||
&iter,
|
||||
ITALIC_COLUMN, !italic,
|
||||
-1);
|
||||
window = (func) ();
|
||||
if (window != NULL)
|
||||
{
|
||||
CallbackData *cbdata;
|
||||
|
||||
cbdata = g_new (CallbackData, 1);
|
||||
cbdata->model = model;
|
||||
cbdata->path = path;
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (window),
|
||||
"destroy",
|
||||
window_closed_cb,
|
||||
cbdata);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_tree_path_free (path);
|
||||
}
|
||||
}
|
||||
|
||||
gtk_signal_emit_stop_by_name (GTK_OBJECT (tree_view),
|
||||
"button_press_event");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
row_activated_cb (GtkTreeView *tree_view,
|
||||
GtkTreePath *path,
|
||||
@@ -318,24 +629,26 @@ row_activated_cb (GtkTreeView *tree_view,
|
||||
FUNC_COLUMN, &func,
|
||||
ITALIC_COLUMN, &italic,
|
||||
-1);
|
||||
gtk_tree_store_set (GTK_TREE_STORE (model),
|
||||
&iter,
|
||||
ITALIC_COLUMN, !italic,
|
||||
-1);
|
||||
window = (func) ();
|
||||
|
||||
if (window != NULL)
|
||||
if (func)
|
||||
{
|
||||
CallbackData *cbdata;
|
||||
gtk_tree_store_set (GTK_TREE_STORE (model),
|
||||
&iter,
|
||||
ITALIC_COLUMN, !italic,
|
||||
-1);
|
||||
window = (func) (GTK_WIDGET (tree_view));
|
||||
|
||||
cbdata = g_new (CallbackData, 1);
|
||||
cbdata->model = model;
|
||||
cbdata->path = gtk_tree_path_copy (path);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (window),
|
||||
"destroy",
|
||||
window_closed_cb,
|
||||
cbdata);
|
||||
if (window != NULL)
|
||||
{
|
||||
CallbackData *cbdata;
|
||||
|
||||
cbdata = g_new (CallbackData, 1);
|
||||
cbdata->model = model;
|
||||
cbdata->path = gtk_tree_path_copy (path);
|
||||
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (window_closed_cb), cbdata);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -352,7 +665,8 @@ selection_cb (GtkTreeSelection *selection,
|
||||
gtk_tree_model_get_value (model, &iter,
|
||||
FILENAME_COLUMN,
|
||||
&value);
|
||||
load_file (g_value_get_string (&value));
|
||||
if (g_value_get_string (&value))
|
||||
load_file (g_value_get_string (&value));
|
||||
g_value_unset (&value);
|
||||
}
|
||||
|
||||
@@ -372,16 +686,17 @@ create_text (GtkTextBuffer **buffer,
|
||||
GTK_SHADOW_IN);
|
||||
|
||||
text_view = gtk_text_view_new ();
|
||||
gtk_container_add (GTK_CONTAINER (scrolled_window), text_view);
|
||||
|
||||
*buffer = gtk_text_buffer_new (NULL);
|
||||
gtk_text_view_set_buffer (GTK_TEXT_VIEW (text_view), *buffer);
|
||||
gtk_text_view_set_editable (GTK_TEXT_VIEW (text_view), FALSE);
|
||||
gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (text_view), FALSE);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (scrolled_window), text_view);
|
||||
|
||||
if (is_source)
|
||||
{
|
||||
font_desc = pango_font_description_from_string ("Courier 10");
|
||||
font_desc = pango_font_description_from_string ("Courier 12");
|
||||
gtk_widget_modify_font (text_view, font_desc);
|
||||
pango_font_description_free (font_desc);
|
||||
|
||||
@@ -402,7 +717,6 @@ create_text (GtkTextBuffer **buffer,
|
||||
return scrolled_window;
|
||||
}
|
||||
|
||||
/* Technically a list, but if we do go to 80 demos, we may want to move to a tree */
|
||||
static GtkWidget *
|
||||
create_tree (void)
|
||||
{
|
||||
@@ -412,27 +726,56 @@ create_tree (void)
|
||||
GtkTreeViewColumn *column;
|
||||
GtkTreeStore *model;
|
||||
GtkTreeIter iter;
|
||||
gint i;
|
||||
|
||||
model = gtk_tree_store_new_with_types (NUM_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_BOOLEAN);
|
||||
tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
|
||||
Demo *d = testgtk_demos;
|
||||
|
||||
model = gtk_tree_store_new (NUM_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_BOOLEAN);
|
||||
tree_view = gtk_tree_view_new ();
|
||||
gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), GTK_TREE_MODEL (model));
|
||||
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
|
||||
|
||||
gtk_tree_selection_set_mode (GTK_TREE_SELECTION (selection),
|
||||
GTK_TREE_SELECTION_SINGLE);
|
||||
gtk_widget_set_usize (tree_view, 200, -1);
|
||||
GTK_SELECTION_BROWSE);
|
||||
gtk_widget_set_size_request (tree_view, 200, -1);
|
||||
|
||||
for (i=0; i < G_N_ELEMENTS (testgtk_demos); i++)
|
||||
/* this code only supports 1 level of children. If we
|
||||
* want more we probably have to use a recursing function.
|
||||
*/
|
||||
while (d->title)
|
||||
{
|
||||
Demo *children = d->children;
|
||||
|
||||
gtk_tree_store_append (GTK_TREE_STORE (model), &iter, NULL);
|
||||
|
||||
gtk_tree_store_set (GTK_TREE_STORE (model),
|
||||
&iter,
|
||||
TITLE_COLUMN, testgtk_demos[i].title,
|
||||
FILENAME_COLUMN, testgtk_demos[i].filename,
|
||||
FUNC_COLUMN, testgtk_demos[i].func,
|
||||
TITLE_COLUMN, d->title,
|
||||
FILENAME_COLUMN, d->filename,
|
||||
FUNC_COLUMN, d->func,
|
||||
ITALIC_COLUMN, FALSE,
|
||||
-1);
|
||||
|
||||
d++;
|
||||
|
||||
if (!children)
|
||||
continue;
|
||||
|
||||
while (children->title)
|
||||
{
|
||||
GtkTreeIter child_iter;
|
||||
|
||||
gtk_tree_store_append (GTK_TREE_STORE (model), &child_iter, &iter);
|
||||
|
||||
gtk_tree_store_set (GTK_TREE_STORE (model),
|
||||
&child_iter,
|
||||
TITLE_COLUMN, children->title,
|
||||
FILENAME_COLUMN, children->filename,
|
||||
FUNC_COLUMN, children->func,
|
||||
ITALIC_COLUMN, FALSE,
|
||||
-1);
|
||||
|
||||
children++;
|
||||
}
|
||||
}
|
||||
|
||||
cell = gtk_cell_renderer_text_new ();
|
||||
@@ -450,17 +793,70 @@ create_tree (void)
|
||||
gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view),
|
||||
GTK_TREE_VIEW_COLUMN (column));
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (selection), "selection_changed", selection_cb, model);
|
||||
gtk_signal_connect (GTK_OBJECT (tree_view), "row_activated", GTK_SIGNAL_FUNC (row_activated_cb), model);
|
||||
g_signal_connect (selection, "changed", G_CALLBACK (selection_cb), model);
|
||||
g_signal_connect (tree_view, "row_activated", G_CALLBACK (row_activated_cb), model);
|
||||
|
||||
gtk_tree_view_expand_all (GTK_TREE_VIEW (tree_view));
|
||||
return tree_view;
|
||||
}
|
||||
|
||||
static void
|
||||
setup_default_icon (void)
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
char *filename;
|
||||
GError *err;
|
||||
|
||||
err = NULL;
|
||||
|
||||
pixbuf = NULL;
|
||||
filename = demo_find_file ("gtk-logo-rgb.gif", &err);
|
||||
if (filename)
|
||||
{
|
||||
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)
|
||||
{
|
||||
GList *list;
|
||||
GdkPixbuf *transparent;
|
||||
|
||||
/* The gtk-logo-rgb icon has a white background, make it transparent */
|
||||
transparent = gdk_pixbuf_add_alpha (pixbuf, TRUE, 0xff, 0xff, 0xff);
|
||||
|
||||
list = NULL;
|
||||
list = g_list_append (list, transparent);
|
||||
gtk_window_set_default_icon_list (list);
|
||||
g_list_free (list);
|
||||
g_object_unref (G_OBJECT (pixbuf));
|
||||
g_object_unref (G_OBJECT (transparent));
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
GtkWidget *window;
|
||||
GtkWidget *notebook;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *tree;
|
||||
GtkTextTag *tag;
|
||||
@@ -469,20 +865,22 @@ main (int argc, char **argv)
|
||||
* these few lines, which are just a hack so gtk-demo will work
|
||||
* in the GTK tree without installing it.
|
||||
*/
|
||||
if (g_file_test ("../../gdk-pixbuf/.libs/libpixbufloader-pnm.so",
|
||||
if (g_file_test ("../../gdk-pixbuf/libpixbufloader-pnm.la",
|
||||
G_FILE_TEST_EXISTS))
|
||||
{
|
||||
putenv ("GDK_PIXBUF_MODULEDIR=../../gdk-pixbuf/.libs");
|
||||
putenv ("GDK_PIXBUF_MODULEDIR=../../gdk-pixbuf");
|
||||
putenv ("GTK_IM_MODULE_FILE=../../modules/input/gtk.immodules");
|
||||
}
|
||||
/* -- 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");
|
||||
gtk_signal_connect (GTK_OBJECT (window), "destroy",
|
||||
GTK_SIGNAL_FUNC (gtk_main_quit), NULL);
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (gtk_main_quit), NULL);
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 0);
|
||||
gtk_container_add (GTK_CONTAINER (window), hbox);
|
||||
@@ -504,13 +902,28 @@ main (int argc, char **argv)
|
||||
tag = gtk_text_buffer_create_tag (info_buffer, "title",
|
||||
"font", "Sans 18",
|
||||
NULL);
|
||||
|
||||
tag = gtk_text_buffer_create_tag (info_buffer, "source",
|
||||
"font", "Courier 10",
|
||||
"pixels_above_lines", 0,
|
||||
"pixels_below_lines", 0,
|
||||
tag = gtk_text_buffer_create_tag (source_buffer, "comment",
|
||||
"foreground", "red",
|
||||
NULL);
|
||||
|
||||
tag = gtk_text_buffer_create_tag (source_buffer, "type",
|
||||
"foreground", "ForestGreen",
|
||||
NULL);
|
||||
tag = gtk_text_buffer_create_tag (source_buffer, "string",
|
||||
"foreground", "RosyBrown",
|
||||
"weight", PANGO_WEIGHT_BOLD,
|
||||
NULL);
|
||||
tag = gtk_text_buffer_create_tag (source_buffer, "control",
|
||||
"foreground", "purple",
|
||||
NULL);
|
||||
tag = gtk_text_buffer_create_tag (source_buffer, "preprocessor",
|
||||
"style", PANGO_STYLE_OBLIQUE,
|
||||
"foreground", "burlywood4",
|
||||
NULL);
|
||||
tag = gtk_text_buffer_create_tag (source_buffer, "function",
|
||||
"weight", PANGO_WEIGHT_BOLD,
|
||||
"foreground", "DarkGoldenrod4",
|
||||
NULL);
|
||||
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);
|
||||
gtk_widget_show_all (window);
|
||||
|
||||
|
80
demos/gtk-demo/makefile.msc.in
Normal file
80
demos/gtk-demo/makefile.msc.in
Normal file
@@ -0,0 +1,80 @@
|
||||
## Makefile for building the gtk test apps with Microsoft C
|
||||
## Use: nmake -f makefile.msc
|
||||
|
||||
## There is no install target, you have to decide where and
|
||||
## how to install for yourself.
|
||||
|
||||
TOP = ..\..\..
|
||||
!INCLUDE $(TOP)/glib/build/win32/make.msc
|
||||
|
||||
!IFNDEF PERL
|
||||
PERL = perl
|
||||
!ENDIF
|
||||
|
||||
################################################################
|
||||
|
||||
# Possibly override versions from build/win32/module.defs
|
||||
GTK_VER = @GTK_MAJOR_VERSION@.@GTK_MINOR_VERSION@
|
||||
GDK_PIXBUF_VER = @GDK_PIXBUF_MAJOR@.@GDK_PIXBUF_MINOR@
|
||||
|
||||
GDK_LIBS = ../../gdk/gdk-win32-$(GTK_VER).lib
|
||||
GTK_LIBS = ../../gtk/gtk-win32-$(GTK_VER).lib
|
||||
GDK_PIXBUF_LIBS = ../../gdk-pixbuf/gdk_pixbuf-$(GDK_PIXBUF_VER).lib
|
||||
|
||||
INCLUDES = -FImsvc_recommended_pragmas.h -I . -I ../.. -I ../../gdk -I ../../gdk-pixbuf -I ../../gtk
|
||||
DEPCFLAGS = $(PANGO_CFLAGS) $(GLIB_CFLAGS) $(LIBICONV_CFLAGS) $(INTL_CFLAGS) $(ATK_CFLAGS)
|
||||
LDFLAGS = /link /machine:ix86 $(LINKDEBUG)
|
||||
DEFINES = -DG_LOG_DOMAIN=\"GtkDemo\" -DGTK_VERSION=\"$(GTK_VER)\" \
|
||||
-DDEMOCODEDIR=\".\"
|
||||
|
||||
TOUCH = copy makefile.msc+nul
|
||||
|
||||
all : \
|
||||
demos.h \
|
||||
gtk-demo.exe
|
||||
|
||||
## These should be in the order you want them to appear in the
|
||||
## demo app, which means alphabetized by demo title, not filename
|
||||
DEMOS = \
|
||||
appwindow.c \
|
||||
button_box.c \
|
||||
colorsel.c \
|
||||
dialog.c \
|
||||
drawingarea.c \
|
||||
editable_cells.c \
|
||||
images.c \
|
||||
item_factory.c \
|
||||
list_store.c \
|
||||
menus.c \
|
||||
panes.c \
|
||||
pixbufs.c \
|
||||
sizegroup.c \
|
||||
stock_browser.c \
|
||||
textview.c \
|
||||
tree_store.c \
|
||||
|
||||
demos.h: $(DEMOS) geninclude.pl
|
||||
$(PERL) geninclude.pl $(DEMOS) > demos.h
|
||||
|
||||
OBJECTS = \
|
||||
appwindow.obj \
|
||||
button_box.obj \
|
||||
colorsel.obj \
|
||||
dialog.obj \
|
||||
drawingarea.obj \
|
||||
editable_cells.obj \
|
||||
images.obj \
|
||||
item_factory.obj \
|
||||
list_store.obj \
|
||||
menus.obj \
|
||||
panes.obj \
|
||||
pixbufs.obj \
|
||||
sizegroup.obj \
|
||||
stock_browser.obj \
|
||||
textview.obj \
|
||||
tree_store.obj \
|
||||
main.obj \
|
||||
|
||||
gtk-demo.exe : demos.h $(OBJECTS)
|
||||
$(CC) $(CFLAGS) -Fegtk-demo.exe $(OBJECTS) $(GTK_LIBS) $(GDK_LIBS) $(GDK_PIXBUF_LIBS) $(PANGO_LIBS) $(GLIB_LIBS) $(LDFLAGS)
|
||||
|
@@ -28,13 +28,14 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
#include <stdio.h>
|
||||
#include "demo-common.h"
|
||||
|
||||
static GtkWidget*
|
||||
create_menu (gint depth, gboolean tearoff)
|
||||
static GtkWidget *
|
||||
create_menu (gint depth,
|
||||
gboolean tearoff)
|
||||
{
|
||||
GtkWidget *menu;
|
||||
GtkWidget *menuitem;
|
||||
@@ -59,7 +60,7 @@ create_menu (gint depth, gboolean tearoff)
|
||||
{
|
||||
sprintf (buf, "item %2d - %d", depth, j);
|
||||
menuitem = gtk_radio_menu_item_new_with_label (group, buf);
|
||||
group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (menuitem));
|
||||
group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menuitem));
|
||||
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
|
||||
gtk_widget_show (menuitem);
|
||||
@@ -73,9 +74,9 @@ create_menu (gint depth, gboolean tearoff)
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_menus (void)
|
||||
do_menus (GtkWidget *do_widget)
|
||||
{
|
||||
static GtkWidget *window = NULL;
|
||||
GtkWidget *window = get_cached_widget (do_widget, "do_menus");
|
||||
GtkWidget *box1;
|
||||
GtkWidget *box2;
|
||||
GtkWidget *button;
|
||||
@@ -90,16 +91,16 @@ do_menus (void)
|
||||
GtkAccelGroup *accel_group;
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (window), "destroy",
|
||||
GTK_SIGNAL_FUNC(gtk_widget_destroyed),
|
||||
&window);
|
||||
gtk_signal_connect (GTK_OBJECT (window), "delete-event",
|
||||
GTK_SIGNAL_FUNC (gtk_true),
|
||||
NULL);
|
||||
gtk_window_set_screen (GTK_WINDOW (window),
|
||||
gtk_widget_get_screen (do_widget));
|
||||
cache_widget (window, "do_menus");
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK(remove_cached_widget), "do_menus");
|
||||
g_signal_connect (window, "delete-event",
|
||||
G_CALLBACK (gtk_true), NULL);
|
||||
|
||||
accel_group = gtk_accel_group_new ();
|
||||
gtk_accel_group_attach (accel_group, GTK_OBJECT (window));
|
||||
gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
|
||||
|
||||
gtk_window_set_title (GTK_WINDOW (window), "menus");
|
||||
gtk_container_set_border_width (GTK_CONTAINER (window), 0);
|
||||
@@ -117,18 +118,18 @@ do_menus (void)
|
||||
|
||||
menuitem = gtk_menu_item_new_with_label ("test\nline2");
|
||||
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menu);
|
||||
gtk_menu_bar_append (GTK_MENU_BAR (menubar), menuitem);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menubar), menuitem);
|
||||
gtk_widget_show (menuitem);
|
||||
|
||||
menuitem = gtk_menu_item_new_with_label ("foo");
|
||||
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), create_menu (3, TRUE));
|
||||
gtk_menu_bar_append (GTK_MENU_BAR (menubar), menuitem);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menubar), menuitem);
|
||||
gtk_widget_show (menuitem);
|
||||
|
||||
menuitem = gtk_menu_item_new_with_label ("bar");
|
||||
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), create_menu (4, TRUE));
|
||||
gtk_menu_item_right_justify (GTK_MENU_ITEM (menuitem));
|
||||
gtk_menu_bar_append (GTK_MENU_BAR (menubar), menuitem);
|
||||
gtk_menu_item_set_right_justified (GTK_MENU_ITEM (menuitem), TRUE);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menubar), menuitem);
|
||||
gtk_widget_show (menuitem);
|
||||
|
||||
box2 = gtk_vbox_new (FALSE, 10);
|
||||
@@ -151,7 +152,7 @@ do_menus (void)
|
||||
accel_group,
|
||||
GDK_F1,
|
||||
0,
|
||||
GTK_ACCEL_VISIBLE | GTK_ACCEL_SIGNAL_VISIBLE);
|
||||
GTK_ACCEL_VISIBLE);
|
||||
menuitem = gtk_check_menu_item_new_with_label ("Accelerator Locked");
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
|
||||
gtk_widget_show (menuitem);
|
||||
@@ -176,7 +177,6 @@ do_menus (void)
|
||||
GDK_F3,
|
||||
0,
|
||||
GTK_ACCEL_VISIBLE);
|
||||
gtk_widget_lock_accelerators (menuitem);
|
||||
|
||||
optionmenu = gtk_option_menu_new ();
|
||||
gtk_option_menu_set_menu (GTK_OPTION_MENU (optionmenu), menu);
|
||||
@@ -194,9 +194,8 @@ do_menus (void)
|
||||
gtk_widget_show (box2);
|
||||
|
||||
button = gtk_button_new_with_label ("close");
|
||||
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
|
||||
GTK_SIGNAL_FUNC(gtk_widget_destroy),
|
||||
GTK_OBJECT (window));
|
||||
g_signal_connect_swapped (button, "clicked",
|
||||
G_CALLBACK(gtk_widget_destroy), window);
|
||||
gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
|
||||
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
|
||||
gtk_widget_grab_default (button);
|
||||
@@ -215,4 +214,3 @@ do_menus (void)
|
||||
|
||||
return window;
|
||||
}
|
||||
|
||||
|
226
demos/gtk-demo/movedemo.c
Normal file
226
demos/gtk-demo/movedemo.c
Normal file
@@ -0,0 +1,226 @@
|
||||
/* Multihead Support/Move Demo
|
||||
*
|
||||
* Demostrates a way of recreating a widget tree from a top level window
|
||||
* to either a other screen of the same display or a different display.
|
||||
*
|
||||
*/
|
||||
#include <gtk/gtk.h>
|
||||
#include "demo-common.h"
|
||||
|
||||
static GtkWidget *window = NULL;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GtkEntry *entry;
|
||||
GtkWidget *radio_dpy;
|
||||
GtkWidget *toplevel;
|
||||
GtkWidget *dialog_window;
|
||||
GList *valid_display_list;
|
||||
}
|
||||
ScreenDisplaySelection;
|
||||
|
||||
/* Create a new toplevel and reparent */
|
||||
void
|
||||
change_screen (GdkScreen * new_screen, GtkWidget * toplevel)
|
||||
{
|
||||
GtkWidget *child = gtk_bin_get_child (GTK_BIN (toplevel));
|
||||
GtkWidget *new_toplevel;
|
||||
|
||||
new_toplevel = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
|
||||
gtk_window_set_screen (GTK_WINDOW (new_toplevel), new_screen);
|
||||
|
||||
gtk_widget_set_name (new_toplevel, "main window");
|
||||
gtk_window_set_default_size (GTK_WINDOW (new_toplevel), 600, 400);
|
||||
|
||||
g_signal_connect (G_OBJECT (new_toplevel), "destroy",
|
||||
G_CALLBACK (gtk_main_quit), NULL);
|
||||
g_signal_connect (G_OBJECT (new_toplevel), "delete-event",
|
||||
G_CALLBACK (gtk_false), NULL);
|
||||
|
||||
gtk_widget_reparent (GTK_WIDGET (child), new_toplevel);
|
||||
/* App dependant initialization */
|
||||
|
||||
|
||||
gtk_widget_show_all (new_toplevel);
|
||||
|
||||
g_signal_handlers_disconnect_by_func (G_OBJECT (toplevel),
|
||||
G_CALLBACK (gtk_main_quit), NULL);
|
||||
g_signal_handlers_disconnect_by_func (G_OBJECT (toplevel),
|
||||
G_CALLBACK (gtk_false), NULL);
|
||||
gtk_widget_destroy (toplevel);
|
||||
}
|
||||
|
||||
static gint
|
||||
display_name_cmp (gconstpointer a, gconstpointer b)
|
||||
{
|
||||
return g_ascii_strcasecmp (a, b);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
screen_display_check (GtkWidget * widget, ScreenDisplaySelection * data)
|
||||
{
|
||||
char *display_name;
|
||||
GdkDisplay *display = gtk_widget_get_display (widget);
|
||||
GtkWidget *dialog;
|
||||
GdkScreen *new_screen = NULL;
|
||||
GdkScreen *current_screen = gtk_widget_get_screen (widget);
|
||||
|
||||
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (data->radio_dpy)))
|
||||
{
|
||||
display_name = g_strdup (gtk_entry_get_text (data->entry));
|
||||
display = gdk_display_new (0, NULL, (char *) display_name);
|
||||
|
||||
if (!display)
|
||||
{
|
||||
dialog =
|
||||
gtk_message_dialog_new (GTK_WINDOW
|
||||
(gtk_widget_get_toplevel (widget)),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
|
||||
"The display :\n%s\ncannot be opened",
|
||||
display_name);
|
||||
gtk_window_set_screen (GTK_WINDOW (dialog), current_screen);
|
||||
gtk_widget_show (dialog);
|
||||
g_signal_connect (G_OBJECT (dialog), "response",
|
||||
G_CALLBACK (gtk_widget_destroy), NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!g_list_find_custom (data->valid_display_list,
|
||||
display_name, display_name_cmp))
|
||||
data->valid_display_list =
|
||||
g_list_append (data->valid_display_list, display_name);
|
||||
|
||||
new_screen = gdk_display_get_default_screen (display);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int number_of_screens = gdk_display_get_n_screens (display);
|
||||
int screen_num = gdk_screen_get_number (current_screen);
|
||||
if ((screen_num + 1) < number_of_screens)
|
||||
new_screen = gdk_display_get_screen (display, screen_num + 1);
|
||||
else
|
||||
new_screen = gdk_display_get_screen (display, 0);
|
||||
}
|
||||
if (new_screen)
|
||||
{
|
||||
change_screen (new_screen, data->toplevel);
|
||||
gtk_widget_destroy (data->dialog_window);
|
||||
window = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
screen_display_destroy_diag (GtkWidget * widget, GtkWidget * data)
|
||||
{
|
||||
gtk_widget_destroy (data);
|
||||
window = NULL;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_movedemo (GtkWidget * do_widget)
|
||||
{
|
||||
GtkWidget *table, *frame, *combo_dpy, *vbox;
|
||||
GtkWidget *radio_dpy, *radio_scr, *applyb, *cancelb;
|
||||
GtkWidget *bbox;
|
||||
ScreenDisplaySelection *scr_dpy_data;
|
||||
GdkScreen *screen = gtk_widget_get_screen (do_widget);
|
||||
static GList *valid_display_list = NULL;
|
||||
|
||||
if (!window)
|
||||
{
|
||||
GdkDisplay *display = gdk_screen_get_display (screen);
|
||||
|
||||
window = gtk_widget_new (gtk_window_get_type (),
|
||||
"screen", screen,
|
||||
"user_data", NULL,
|
||||
"type", GTK_WINDOW_TOPLEVEL,
|
||||
"title",
|
||||
"Screen or Display selection",
|
||||
"border_width", 10, NULL);
|
||||
g_signal_connect (G_OBJECT (window), "destroy",
|
||||
G_CALLBACK (gtk_widget_destroy), NULL);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 3);
|
||||
gtk_container_add (GTK_CONTAINER (window), vbox);
|
||||
|
||||
frame = gtk_frame_new ("Select screen or display");
|
||||
gtk_container_add (GTK_CONTAINER (vbox), frame);
|
||||
|
||||
table = gtk_table_new (2, 2, TRUE);
|
||||
gtk_table_set_row_spacings (GTK_TABLE (table), 3);
|
||||
gtk_table_set_col_spacings (GTK_TABLE (table), 3);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (frame), table);
|
||||
|
||||
radio_dpy =
|
||||
gtk_radio_button_new_with_label (NULL, "move to another X display");
|
||||
if (gdk_display_get_n_screens (display) > 1)
|
||||
radio_scr = gtk_radio_button_new_with_label
|
||||
(gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio_dpy)),
|
||||
"move to next screen");
|
||||
else
|
||||
{
|
||||
radio_scr = gtk_radio_button_new_with_label
|
||||
(gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio_dpy)),
|
||||
"only one screen on the current display");
|
||||
gtk_widget_set_sensitive (radio_scr, FALSE);
|
||||
}
|
||||
combo_dpy = gtk_combo_new ();
|
||||
if (!valid_display_list)
|
||||
valid_display_list =
|
||||
g_list_append (valid_display_list, "diabolo:0.0");
|
||||
|
||||
gtk_combo_set_popdown_strings (GTK_COMBO (combo_dpy),
|
||||
valid_display_list);
|
||||
|
||||
gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (combo_dpy)->entry),
|
||||
"<hostname>:<X Server Num>.<Screen Num>");
|
||||
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), radio_dpy, 0, 1, 0, 1);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), radio_scr, 0, 1, 1, 2);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), combo_dpy, 1, 2, 0, 1);
|
||||
|
||||
bbox = gtk_hbutton_box_new ();
|
||||
applyb = gtk_button_new_from_stock (GTK_STOCK_APPLY);
|
||||
cancelb = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (vbox), bbox);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (bbox), applyb);
|
||||
gtk_container_add (GTK_CONTAINER (bbox), cancelb);
|
||||
|
||||
scr_dpy_data = g_new0 (ScreenDisplaySelection, 1);
|
||||
|
||||
scr_dpy_data->entry = GTK_ENTRY (GTK_COMBO (combo_dpy)->entry);
|
||||
scr_dpy_data->radio_dpy = radio_dpy;
|
||||
scr_dpy_data->toplevel = gtk_widget_get_toplevel (do_widget);
|
||||
scr_dpy_data->dialog_window = window;
|
||||
scr_dpy_data->valid_display_list = valid_display_list;
|
||||
|
||||
g_signal_connect (G_OBJECT (cancelb), "clicked",
|
||||
G_CALLBACK (screen_display_destroy_diag),
|
||||
G_OBJECT (window));
|
||||
g_signal_connect (G_OBJECT (applyb), "clicked",
|
||||
G_CALLBACK (screen_display_check), scr_dpy_data);
|
||||
{ /* FIXME need to realize the two notebook pages before moving display
|
||||
* otherwise the text tags created on the first display get realized
|
||||
* on the new display then core dump */
|
||||
extern GtkWidget *notebook;
|
||||
gint num_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));
|
||||
gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), num_page ? 0 : 1);
|
||||
gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), num_page);
|
||||
}
|
||||
gtk_widget_show_all (window);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_destroy (window);
|
||||
window = NULL;
|
||||
}
|
||||
|
||||
return window;
|
||||
}
|
191
demos/gtk-demo/multidisplay.c
Normal file
191
demos/gtk-demo/multidisplay.c
Normal file
@@ -0,0 +1,191 @@
|
||||
/* Multihead Support/Multidisplay demo
|
||||
*
|
||||
* Demonstrates a multidisplay application, here multi display cut and paste.
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include "demo-common.h"
|
||||
#include <stdio.h>
|
||||
|
||||
gchar *screen2_name = NULL;
|
||||
static GtkWidget *entry = NULL;
|
||||
static GtkWidget *entry2 = NULL;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GtkEntry *e1;
|
||||
GtkEntry *e2;
|
||||
}
|
||||
MyDoubleGtkEntry;
|
||||
|
||||
void
|
||||
get_dialog_response (GtkDialog * dialog, gint arg1, gpointer data)
|
||||
{
|
||||
GtkEntry *entry;
|
||||
if (arg1 == GTK_RESPONSE_DELETE_EVENT)
|
||||
return;
|
||||
g_return_if_fail (GTK_IS_ENTRY (data));
|
||||
entry = GTK_ENTRY (data);
|
||||
screen2_name = g_strdup (gtk_entry_get_text (entry));
|
||||
}
|
||||
|
||||
void
|
||||
clear_entry (GtkWidget * widget, gpointer * data)
|
||||
{
|
||||
MyDoubleGtkEntry *de = (MyDoubleGtkEntry *) data;
|
||||
gtk_entry_set_text (de->e2, gtk_entry_get_text (de->e1));
|
||||
}
|
||||
|
||||
void
|
||||
quit_all (GtkWidget * widget, gpointer * data)
|
||||
{
|
||||
MyDoubleGtkEntry *de = (MyDoubleGtkEntry *) data;
|
||||
if (entry)
|
||||
gtk_widget_destroy (gtk_widget_get_toplevel (entry));
|
||||
if (entry2)
|
||||
gtk_widget_destroy (gtk_widget_get_toplevel (entry2));
|
||||
if (de)
|
||||
g_free (de);
|
||||
entry = NULL;
|
||||
entry2 = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
make_selection_dialog (GdkScreen * screen,
|
||||
GtkWidget * entry, GtkWidget * other_entry)
|
||||
{
|
||||
GtkWidget *window, *vbox, *button_box, *clear, *quit;
|
||||
MyDoubleGtkEntry *double_entry = g_new (MyDoubleGtkEntry, 1);
|
||||
double_entry->e1 = GTK_ENTRY (entry);
|
||||
double_entry->e2 = GTK_ENTRY (other_entry);
|
||||
|
||||
window = gtk_widget_new (gtk_window_get_type (),
|
||||
"screen", screen,
|
||||
"user_data", NULL,
|
||||
"type", GTK_WINDOW_TOPLEVEL,
|
||||
"title",
|
||||
"MultiDisplay Cut & Paste",
|
||||
"border_width", 10, NULL);
|
||||
g_signal_connect (G_OBJECT (window), "destroy",
|
||||
G_CALLBACK (quit_all), double_entry);
|
||||
|
||||
vbox = gtk_vbox_new (TRUE, 0);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (window), vbox);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, FALSE, 0);
|
||||
|
||||
button_box = gtk_hbutton_box_new ();
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (vbox), button_box, FALSE, FALSE, 0);
|
||||
|
||||
clear = gtk_button_new_from_stock (GTK_STOCK_APPLY);
|
||||
quit = gtk_button_new_from_stock (GTK_STOCK_QUIT);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (button_box), clear, FALSE, FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (button_box), quit, FALSE, FALSE, 0);
|
||||
|
||||
g_signal_connect (G_OBJECT (quit), "clicked", G_CALLBACK (quit_all),
|
||||
double_entry);
|
||||
g_signal_connect (G_OBJECT (clear), "clicked", G_CALLBACK (clear_entry),
|
||||
double_entry);
|
||||
|
||||
gtk_widget_show_all (window);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_multidisplay (GtkWidget * do_widget)
|
||||
{
|
||||
GtkWidget *dialog, *display_entry, *dialog_label;
|
||||
GdkDisplay *dpy2;
|
||||
GdkScreen *scr2 = NULL; /* Quiet GCC */
|
||||
gboolean correct_second_display = FALSE;
|
||||
|
||||
/* Get the second display */
|
||||
|
||||
if (!entry)
|
||||
{
|
||||
char label_text[300] =
|
||||
" <big><span foreground=\"white\" background=\"black\">"
|
||||
"Multiple Display Test</span></big>\n"
|
||||
"Please enter the name of the second display";
|
||||
|
||||
dialog = gtk_dialog_new_with_buttons ("Second Display Selection",
|
||||
GTK_WINDOW
|
||||
(gtk_widget_get_toplevel
|
||||
(do_widget)), GTK_DIALOG_MODAL,
|
||||
GTK_STOCK_OK, GTK_RESPONSE_OK,
|
||||
NULL);
|
||||
|
||||
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
|
||||
display_entry = gtk_entry_new ();
|
||||
gtk_entry_set_activates_default (GTK_ENTRY (display_entry), TRUE);
|
||||
dialog_label = gtk_label_new (NULL);
|
||||
gtk_label_set_markup (GTK_LABEL (dialog_label), label_text);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox),
|
||||
dialog_label);
|
||||
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox),
|
||||
display_entry);
|
||||
g_signal_connect (G_OBJECT (dialog), "response",
|
||||
G_CALLBACK (get_dialog_response), display_entry);
|
||||
|
||||
gtk_widget_grab_focus (display_entry);
|
||||
|
||||
gtk_widget_show_all (dialog);
|
||||
gtk_dialog_run (GTK_DIALOG (dialog));
|
||||
|
||||
while (!correct_second_display)
|
||||
{
|
||||
|
||||
if (!g_strcasecmp (screen2_name, ""))
|
||||
g_print ("No display name, reverting to default display\n");
|
||||
|
||||
dpy2 = gdk_display_new (0, NULL, screen2_name);
|
||||
if (dpy2)
|
||||
{
|
||||
scr2 = gdk_display_get_default_screen (dpy2);
|
||||
correct_second_display = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
char *error_msg = g_new (char, 1000);
|
||||
sprintf (error_msg,
|
||||
"<big><span foreground=\"white\" background=\"black\">"
|
||||
"<b>Can't open display :</b></span>"
|
||||
"\n\t%s\nplease try another one </big>", screen2_name);
|
||||
gtk_label_set_markup (GTK_LABEL (dialog_label), error_msg);
|
||||
gtk_entry_set_text (GTK_ENTRY (display_entry), "");
|
||||
gtk_widget_show_all (dialog);
|
||||
gtk_dialog_run (GTK_DIALOG (dialog));
|
||||
g_free (error_msg);
|
||||
}
|
||||
}
|
||||
g_free (screen2_name);
|
||||
gtk_widget_destroy (dialog);
|
||||
|
||||
entry = gtk_widget_new (gtk_entry_get_type (),
|
||||
"activates_default", TRUE,
|
||||
"visible", TRUE, NULL);
|
||||
entry2 = gtk_widget_new (gtk_entry_get_type (), "visible", TRUE, NULL);
|
||||
|
||||
/* for default display */
|
||||
make_selection_dialog (gtk_widget_get_screen (do_widget), entry2, entry);
|
||||
/* for selected display */
|
||||
make_selection_dialog (scr2, entry, entry2);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (entry)
|
||||
{
|
||||
gtk_widget_destroy (gtk_widget_get_toplevel (GTK_WIDGET (entry)));
|
||||
entry = NULL;
|
||||
}
|
||||
if (entry2)
|
||||
{
|
||||
gtk_widget_destroy (gtk_widget_get_toplevel (GTK_WIDGET (entry2)));
|
||||
entry2 = NULL;
|
||||
}
|
||||
}
|
||||
return entry;
|
||||
}
|
118
demos/gtk-demo/multiscreen.c
Normal file
118
demos/gtk-demo/multiscreen.c
Normal file
@@ -0,0 +1,118 @@
|
||||
/* Multihead Support/Multiple Screen demo
|
||||
*
|
||||
* Demonstrates an application displaying a window per screen
|
||||
*
|
||||
*/
|
||||
#include <gtk/gtk.h>
|
||||
#include <stdio.h>
|
||||
#include "demo-common.h"
|
||||
|
||||
void
|
||||
multiscreen_close_all (GtkWidget * widget)
|
||||
{
|
||||
GdkDisplay *display = gtk_widget_get_display (widget);
|
||||
GtkWidget **window = g_object_get_data (G_OBJECT (display),
|
||||
"do_multiscreen");
|
||||
if (window)
|
||||
{
|
||||
gint j = gdk_display_get_n_screens (display);
|
||||
j--;
|
||||
g_object_set_data (G_OBJECT (display), "do_multiscreen", NULL);
|
||||
while (j >= 0)
|
||||
{
|
||||
if (window[j])
|
||||
{
|
||||
gtk_widget_destroy (window[j]);
|
||||
window[j] = NULL;
|
||||
}
|
||||
j--;
|
||||
}
|
||||
if (window)
|
||||
g_free (window);
|
||||
}
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_multiscreen (GtkWidget * do_widget)
|
||||
{
|
||||
gint i, num_screen;
|
||||
GdkDisplay *dpy = gtk_widget_get_display (do_widget);
|
||||
GtkWidget *vbox, *label, *button;
|
||||
GtkWidget **window = g_object_get_data (G_OBJECT (dpy), "do_multiscreen");
|
||||
|
||||
if (!window)
|
||||
{
|
||||
num_screen = gdk_display_get_n_screens (dpy);
|
||||
|
||||
if (num_screen <= 1)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
GtkWidget *w = gtk_widget_get_toplevel (do_widget);
|
||||
|
||||
dialog = gtk_message_dialog_new (GTK_WINDOW (w),
|
||||
GTK_DIALOG_MODAL,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"This display (%s) manages only one screen.",
|
||||
gdk_display_get_name (dpy));
|
||||
|
||||
g_signal_connect (dialog, "response",
|
||||
G_CALLBACK (gtk_widget_destroy), NULL);
|
||||
|
||||
gtk_widget_show (dialog);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
window = g_new (GtkWidget *, num_screen);
|
||||
g_object_set_data (G_OBJECT (dpy), "do_multiscreen", window);
|
||||
|
||||
for (i = 0; i < num_screen; i++)
|
||||
{
|
||||
char *label_text = g_new (char, 300);
|
||||
GdkScreen *screen = gdk_display_get_screen (dpy, i);
|
||||
|
||||
window[i] = gtk_widget_new (gtk_window_get_type (), "screen",
|
||||
screen,
|
||||
"user_data", NULL, "type",
|
||||
GTK_WINDOW_TOPLEVEL, "title", label,
|
||||
"allow_grow", FALSE, "allow_shrink",
|
||||
FALSE, "border_width", 10, NULL);
|
||||
/* you can also use gtk_window_new and set the screen afterwards with
|
||||
* gtk_window_set_screen */
|
||||
|
||||
g_signal_connect (G_OBJECT (window[i]), "destroy",
|
||||
G_CALLBACK (multiscreen_close_all), NULL);
|
||||
|
||||
vbox = gtk_vbox_new (TRUE, 0);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (window[i]), vbox);
|
||||
|
||||
label = gtk_label_new (NULL);
|
||||
|
||||
sprintf (label_text,
|
||||
" <big><span foreground=\"white\" background=\"black\">"
|
||||
"Screen %d of %d</span></big>\n"
|
||||
"<span background=\"darkcyan\"><i>Width - Height : (%d,%d)\n</i></span>",
|
||||
i + 1, num_screen, gdk_screen_get_width (screen),
|
||||
gdk_screen_get_height (screen));
|
||||
|
||||
gtk_label_set_markup (GTK_LABEL (label), label_text);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (vbox), label);
|
||||
|
||||
button = gtk_button_new_with_label ("Close");
|
||||
g_signal_connect (G_OBJECT (button), "clicked",
|
||||
G_CALLBACK (multiscreen_close_all), NULL);
|
||||
gtk_container_add (GTK_CONTAINER (vbox), button);
|
||||
gtk_widget_show_all (window[i]);
|
||||
}
|
||||
return window[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
multiscreen_close_all (do_widget);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -12,9 +12,11 @@
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include "demo-common.h"
|
||||
|
||||
void
|
||||
toggle_resize (GtkWidget *widget, GtkWidget *child)
|
||||
toggle_resize (GtkWidget *widget,
|
||||
GtkWidget *child)
|
||||
{
|
||||
GtkPaned *paned = GTK_PANED (child->parent);
|
||||
gboolean is_child1 = (child == paned->child1);
|
||||
@@ -33,7 +35,8 @@ toggle_resize (GtkWidget *widget, GtkWidget *child)
|
||||
}
|
||||
|
||||
void
|
||||
toggle_shrink (GtkWidget *widget, GtkWidget *child)
|
||||
toggle_shrink (GtkWidget *widget,
|
||||
GtkWidget *child)
|
||||
{
|
||||
GtkPaned *paned = GTK_PANED (child->parent);
|
||||
gboolean is_child1 = (child == paned->child1);
|
||||
@@ -52,7 +55,7 @@ toggle_shrink (GtkWidget *widget, GtkWidget *child)
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
create_pane_options (GtkPaned *paned,
|
||||
create_pane_options (GtkPaned *paned,
|
||||
const gchar *frame_label,
|
||||
const gchar *label1,
|
||||
const gchar *label2)
|
||||
@@ -75,18 +78,16 @@ create_pane_options (GtkPaned *paned,
|
||||
check_button = gtk_check_button_new_with_mnemonic ("_Resize");
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), check_button,
|
||||
0, 1, 1, 2);
|
||||
gtk_signal_connect (GTK_OBJECT (check_button), "toggled",
|
||||
GTK_SIGNAL_FUNC (toggle_resize),
|
||||
paned->child1);
|
||||
g_signal_connect (check_button, "toggled",
|
||||
G_CALLBACK (toggle_resize), paned->child1);
|
||||
|
||||
check_button = gtk_check_button_new_with_mnemonic ("_Shrink");
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), check_button,
|
||||
0, 1, 2, 3);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button),
|
||||
TRUE);
|
||||
gtk_signal_connect (GTK_OBJECT (check_button), "toggled",
|
||||
GTK_SIGNAL_FUNC (toggle_shrink),
|
||||
paned->child1);
|
||||
g_signal_connect (check_button, "toggled",
|
||||
G_CALLBACK (toggle_shrink), paned->child1);
|
||||
|
||||
label = gtk_label_new (label2);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), label,
|
||||
@@ -97,26 +98,24 @@ create_pane_options (GtkPaned *paned,
|
||||
1, 2, 1, 2);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button),
|
||||
TRUE);
|
||||
gtk_signal_connect (GTK_OBJECT (check_button), "toggled",
|
||||
GTK_SIGNAL_FUNC (toggle_resize),
|
||||
paned->child2);
|
||||
g_signal_connect (check_button, "toggled",
|
||||
G_CALLBACK (toggle_resize), paned->child2);
|
||||
|
||||
check_button = gtk_check_button_new_with_mnemonic ("_Shrink");
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), check_button,
|
||||
1, 2, 2, 3);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button),
|
||||
TRUE);
|
||||
gtk_signal_connect (GTK_OBJECT (check_button), "toggled",
|
||||
GTK_SIGNAL_FUNC (toggle_shrink),
|
||||
paned->child2);
|
||||
g_signal_connect (check_button, "toggled",
|
||||
G_CALLBACK (toggle_shrink), paned->child2);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_panes (void)
|
||||
do_panes (GtkWidget *do_widget)
|
||||
{
|
||||
static GtkWidget *window = NULL;
|
||||
GtkWidget *window = get_cached_widget (do_widget, "do_panes");
|
||||
GtkWidget *frame;
|
||||
GtkWidget *hpaned;
|
||||
GtkWidget *vpaned;
|
||||
@@ -126,10 +125,11 @@ do_panes (void)
|
||||
if (!window)
|
||||
{
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (window), "destroy",
|
||||
GTK_SIGNAL_FUNC(gtk_widget_destroyed),
|
||||
&window);
|
||||
gtk_window_set_screen (GTK_WINDOW (window),
|
||||
gtk_widget_get_screen (do_widget));
|
||||
cache_widget (window, "do_panes");
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (remove_cached_widget), "do_panes");
|
||||
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Panes");
|
||||
gtk_container_set_border_width (GTK_CONTAINER (window), 0);
|
||||
@@ -146,7 +146,7 @@ do_panes (void)
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME(frame), GTK_SHADOW_IN);
|
||||
gtk_widget_set_usize (frame, 60, 60);
|
||||
gtk_widget_set_size_request (frame, 60, 60);
|
||||
gtk_paned_add1 (GTK_PANED (hpaned), frame);
|
||||
|
||||
button = gtk_button_new_with_mnemonic ("_Hi there");
|
||||
@@ -154,12 +154,12 @@ do_panes (void)
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME(frame), GTK_SHADOW_IN);
|
||||
gtk_widget_set_usize (frame, 80, 60);
|
||||
gtk_widget_set_size_request (frame, 80, 60);
|
||||
gtk_paned_add2 (GTK_PANED (hpaned), frame);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME(frame), GTK_SHADOW_IN);
|
||||
gtk_widget_set_usize (frame, 60, 80);
|
||||
gtk_widget_set_size_request (frame, 60, 80);
|
||||
gtk_paned_add2 (GTK_PANED (vpaned), frame);
|
||||
|
||||
/* Now create toggle buttons to control sizing */
|
||||
|
@@ -9,7 +9,7 @@
|
||||
* off how to use GtkDrawingArea to do a simple animation.
|
||||
*
|
||||
* Look at the Image demo for additional pixbuf usage examples.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
@@ -17,14 +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",
|
||||
@@ -35,68 +34,53 @@ 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)
|
||||
|
||||
/* demo window */
|
||||
static GtkWindow *window = NULL;
|
||||
|
||||
/* Current frame */
|
||||
static GdkPixbuf *frame;
|
||||
#define N_IMAGES G_N_ELEMENTS (image_names)
|
||||
|
||||
/* Background image */
|
||||
static GdkPixbuf *background;
|
||||
static int back_width, back_height;
|
||||
static gint back_width, back_height;
|
||||
|
||||
/* Images */
|
||||
static GdkPixbuf *images[N_IMAGES];
|
||||
|
||||
/* Widgets */
|
||||
static GtkWidget *da;
|
||||
|
||||
|
||||
|
||||
/* Loads the images for the demo and returns whether the operation succeeded */
|
||||
static gboolean
|
||||
load_pixbufs (GError **error)
|
||||
{
|
||||
int i;
|
||||
const char **image_names;
|
||||
gint i;
|
||||
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);
|
||||
|
||||
if (!background)
|
||||
/* 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 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 */
|
||||
return FALSE; /* Note that "error" was filled with a GError */
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@@ -104,22 +88,26 @@ load_pixbufs (GError **error)
|
||||
|
||||
/* Expose callback for the drawing area */
|
||||
static gint
|
||||
expose_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data)
|
||||
expose_cb (GtkWidget *widget,
|
||||
GdkEventExpose *event,
|
||||
gpointer data)
|
||||
{
|
||||
guchar *pixels;
|
||||
int rowstride;
|
||||
|
||||
GdkPixbuf *frame = get_cached_pointer (gtk_widget_get_toplevel (widget),
|
||||
"do_pixbufs_frame");
|
||||
g_assert (GDK_IS_PIXBUF (frame));
|
||||
rowstride = gdk_pixbuf_get_rowstride (frame);
|
||||
|
||||
pixels = gdk_pixbuf_get_pixels (frame) + rowstride * event->area.y + event->area.x * 3;
|
||||
|
||||
|
||||
gdk_draw_rgb_image_dithalign (widget->window,
|
||||
widget->style->black_gc,
|
||||
event->area.x, event->area.y,
|
||||
event->area.width, event->area.height,
|
||||
GDK_RGB_DITHER_NORMAL,
|
||||
pixels, rowstride,
|
||||
event->area.x, event->area.y);
|
||||
widget->style->black_gc,
|
||||
event->area.x, event->area.y,
|
||||
event->area.width, event->area.height,
|
||||
GDK_RGB_DITHER_NORMAL,
|
||||
pixels, rowstride,
|
||||
event->area.x, event->area.y);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -136,9 +124,13 @@ timeout (gpointer data)
|
||||
int i;
|
||||
double xmid, ymid;
|
||||
double radius;
|
||||
|
||||
GdkPixbuf *frame = get_cached_pointer (GTK_WIDGET (data),
|
||||
"do_pixbufs_frame");
|
||||
GtkWidget *da = get_cached_pointer (GTK_WIDGET (data),
|
||||
"do_pixbufs_da");
|
||||
|
||||
gdk_pixbuf_copy_area (background, 0, 0, back_width, back_height,
|
||||
frame, 0, 0);
|
||||
frame, 0, 0);
|
||||
|
||||
f = (double) (frame_num % CYCLE_LEN) / CYCLE_LEN;
|
||||
|
||||
@@ -156,17 +148,17 @@ timeout (gpointer data)
|
||||
GdkRectangle r1, r2, dest;
|
||||
double k;
|
||||
|
||||
ang = 2.0 * M_PI * (double) i / N_IMAGES - f * 2.0 * M_PI;
|
||||
ang = 2.0 * G_PI * (double) i / N_IMAGES - f * 2.0 * G_PI;
|
||||
|
||||
iw = gdk_pixbuf_get_width (images[i]);
|
||||
ih = gdk_pixbuf_get_height (images[i]);
|
||||
|
||||
r = radius + (radius / 3.0) * sin (f * 2.0 * M_PI);
|
||||
r = radius + (radius / 3.0) * sin (f * 2.0 * G_PI);
|
||||
|
||||
xpos = floor (xmid + r * cos (ang) - iw / 2.0 + 0.5);
|
||||
ypos = floor (ymid + r * sin (ang) - ih / 2.0 + 0.5);
|
||||
|
||||
k = (i & 1) ? sin (f * 2.0 * M_PI) : cos (f * 2.0 * M_PI);
|
||||
k = (i & 1) ? sin (f * 2.0 * G_PI) : cos (f * 2.0 * G_PI);
|
||||
k = 2.0 * k * k;
|
||||
k = MAX (0.25, k);
|
||||
|
||||
@@ -181,16 +173,16 @@ timeout (gpointer data)
|
||||
r2.height = back_height;
|
||||
|
||||
if (gdk_rectangle_intersect (&r1, &r2, &dest))
|
||||
gdk_pixbuf_composite (images[i],
|
||||
frame,
|
||||
dest.x, dest.y,
|
||||
dest.width, dest.height,
|
||||
xpos, ypos,
|
||||
k, k,
|
||||
GDK_INTERP_NEAREST,
|
||||
((i & 1)
|
||||
? MAX (127, fabs (255 * sin (f * 2.0 * M_PI)))
|
||||
: MAX (127, fabs (255 * cos (f * 2.0 * M_PI)))));
|
||||
gdk_pixbuf_composite (images[i],
|
||||
frame,
|
||||
dest.x, dest.y,
|
||||
dest.width, dest.height,
|
||||
xpos, ypos,
|
||||
k, k,
|
||||
GDK_INTERP_NEAREST,
|
||||
((i & 1)
|
||||
? MAX (127, fabs (255 * sin (f * 2.0 * G_PI)))
|
||||
: MAX (127, fabs (255 * cos (f * 2.0 * G_PI)))));
|
||||
}
|
||||
|
||||
gtk_widget_queue_draw (da);
|
||||
@@ -203,66 +195,76 @@ static guint timeout_id;
|
||||
|
||||
static void
|
||||
cleanup_callback (GtkObject *object,
|
||||
gpointer data)
|
||||
gpointer data)
|
||||
{
|
||||
g_source_remove (timeout_id);
|
||||
timeout_id = 0;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_pixbufs (void)
|
||||
do_pixbufs (GtkWidget *do_widget)
|
||||
{
|
||||
GdkPixbuf *frame;
|
||||
GtkWidget *da;
|
||||
GtkWidget *window = get_cached_widget (do_widget, "do_pixbufs");
|
||||
|
||||
if (!window)
|
||||
{
|
||||
GError *error;
|
||||
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Pixbufs");
|
||||
gtk_window_set_resizeable (GTK_WINDOW (window), FALSE);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (window), "destroy", GTK_SIGNAL_FUNC (gtk_widget_destroyed), &window);
|
||||
gtk_signal_connect (GTK_OBJECT (window), "destroy", GTK_SIGNAL_FUNC (cleanup_callback), NULL);
|
||||
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_screen (GTK_WINDOW (window),
|
||||
gtk_widget_get_screen (do_widget));
|
||||
cache_widget (window, "do_pixbufs");
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Pixbufs");
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
|
||||
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (cleanup_callback), NULL);
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (remove_cached_widget),"do_pixbufs");
|
||||
|
||||
|
||||
error = NULL;
|
||||
if (!load_pixbufs (&error))
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
|
||||
dialog = gtk_message_dialog_new (GTK_WINDOW (window),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"Failed to load an image: %s",
|
||||
error->message);
|
||||
|
||||
g_error_free (error);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (dialog),
|
||||
"response",
|
||||
GTK_SIGNAL_FUNC (gtk_widget_destroy),
|
||||
NULL);
|
||||
|
||||
gtk_widget_show (dialog);
|
||||
}
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
|
||||
dialog = gtk_message_dialog_new (GTK_WINDOW (window),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"Failed to load an image: %s",
|
||||
error->message);
|
||||
|
||||
g_error_free (error);
|
||||
|
||||
g_signal_connect (dialog, "response",
|
||||
G_CALLBACK (gtk_widget_destroy), NULL);
|
||||
|
||||
gtk_widget_show (dialog);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_set_usize (window, back_width, back_height);
|
||||
|
||||
frame = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, back_width, back_height);
|
||||
|
||||
da = gtk_drawing_area_new ();
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (da), "expose_event",
|
||||
GTK_SIGNAL_FUNC (expose_cb), NULL);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (window), da);
|
||||
|
||||
timeout_id = gtk_timeout_add (FRAME_DELAY, timeout, NULL);
|
||||
}
|
||||
{
|
||||
gtk_widget_set_size_request (window, back_width, back_height);
|
||||
|
||||
frame = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, back_width, back_height);
|
||||
|
||||
da = gtk_drawing_area_new ();
|
||||
|
||||
cache_pointer (window, "do_pixbufs_frame", frame);
|
||||
cache_pointer (window, "do_pixbufs_da", da);
|
||||
|
||||
g_signal_connect (da, "expose_event",
|
||||
G_CALLBACK (expose_cb), NULL);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (window), da);
|
||||
|
||||
timeout_id = gtk_timeout_add (FRAME_DELAY, timeout, window);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!GTK_WIDGET_VISIBLE (window))
|
||||
{
|
||||
gtk_widget_show_all (window);
|
||||
|
177
demos/gtk-demo/sizegroup.c
Normal file
177
demos/gtk-demo/sizegroup.c
Normal file
@@ -0,0 +1,177 @@
|
||||
/* Size Groups
|
||||
*
|
||||
* GtkSizeGroup provides a mechanism for grouping a number of
|
||||
* widgets together so they all request the same amount of space.
|
||||
* This is typically useful when you want a column of widgets to
|
||||
* have the same size, but you can't use a GtkTable widget.
|
||||
*
|
||||
* Note that size groups only affect the amount of space requested,
|
||||
* not the size that the widgets finally receive. If you want the
|
||||
* widgets in a GtkSizeGroup to actually be the same size, you need
|
||||
* to pack them in such a way that they get the size they request
|
||||
* and not more. For example, if you are packing your widgets
|
||||
* into a table, you would not include the GTK_FILL flag.
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include "demo-common.h"
|
||||
|
||||
/* Convenience function to create an option menu holding a number of strings
|
||||
*/
|
||||
GtkWidget *
|
||||
create_option_menu (GtkWidget *widget, const char **strings)
|
||||
{
|
||||
GtkWidget *menu;
|
||||
GtkWidget *option_menu;
|
||||
const char **str;
|
||||
|
||||
menu = gtk_menu_new ();
|
||||
gtk_menu_set_screen (GTK_MENU (menu), gtk_widget_get_screen (widget));
|
||||
|
||||
for (str = strings; *str; str++)
|
||||
{
|
||||
GtkWidget *menu_item = gtk_menu_item_new_with_label (*str);
|
||||
gtk_widget_show (menu_item);
|
||||
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
|
||||
}
|
||||
|
||||
option_menu = gtk_option_menu_new ();
|
||||
gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu);
|
||||
|
||||
return option_menu;
|
||||
}
|
||||
|
||||
static void
|
||||
add_row (GtkTable *table,
|
||||
int row,
|
||||
GtkSizeGroup *size_group,
|
||||
const char *label_text,
|
||||
const char **options)
|
||||
{
|
||||
GtkWidget *option_menu;
|
||||
GtkWidget *label;
|
||||
|
||||
label = gtk_label_new_with_mnemonic (label_text);
|
||||
gtk_misc_set_alignment (GTK_MISC (label), 0, 1);
|
||||
gtk_table_attach (GTK_TABLE (table), label,
|
||||
0, 1, row, row + 1,
|
||||
GTK_EXPAND | GTK_FILL, 0,
|
||||
0, 0);
|
||||
|
||||
option_menu = create_option_menu (GTK_WIDGET (table), options);
|
||||
gtk_label_set_mnemonic_widget (GTK_LABEL (label), option_menu);
|
||||
gtk_size_group_add_widget (size_group, option_menu);
|
||||
gtk_table_attach (GTK_TABLE (table), option_menu,
|
||||
1, 2, row, row + 1,
|
||||
0, 0,
|
||||
0, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
toggle_grouping (GtkToggleButton *check_button,
|
||||
GtkSizeGroup *size_group)
|
||||
{
|
||||
GtkSizeGroupMode new_mode;
|
||||
|
||||
/* GTK_SIZE_GROUP_NONE is not generally useful, but is useful
|
||||
* here to show the effect of GTK_SIZE_GROUP_HORIZONTAL by
|
||||
* contrast.
|
||||
*/
|
||||
if (gtk_toggle_button_get_active (check_button))
|
||||
new_mode = GTK_SIZE_GROUP_HORIZONTAL;
|
||||
else
|
||||
new_mode = GTK_SIZE_GROUP_NONE;
|
||||
|
||||
gtk_size_group_set_mode (size_group, new_mode);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_sizegroup (GtkWidget *do_widget)
|
||||
{
|
||||
GtkWidget *window = get_cached_widget (do_widget, "do_sizegroup");
|
||||
GtkWidget *table;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *check_button;
|
||||
GtkSizeGroup *size_group;
|
||||
|
||||
static const char *color_options[] = {
|
||||
"Red", "Green", "Blue", NULL
|
||||
};
|
||||
|
||||
static const char *dash_options[] = {
|
||||
"Solid", "Dashed", "Dotted", NULL
|
||||
};
|
||||
|
||||
static const char *end_options[] = {
|
||||
"Square", "Round", "Arrow", NULL
|
||||
};
|
||||
|
||||
if (!window)
|
||||
{
|
||||
window = gtk_dialog_new_with_buttons ("GtkSizeGroup",
|
||||
NULL, 0,
|
||||
GTK_STOCK_CLOSE,
|
||||
GTK_RESPONSE_NONE,
|
||||
NULL);
|
||||
gtk_window_set_screen (GTK_WINDOW (window),
|
||||
gtk_widget_get_screen (do_widget));
|
||||
cache_widget (window, "do_sizegroup");
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
|
||||
|
||||
g_signal_connect (window, "response",
|
||||
G_CALLBACK (gtk_widget_destroy), NULL);
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (remove_cached_widget), "do_sizegroup");
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 5);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->vbox), vbox, TRUE, TRUE, 0);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
|
||||
|
||||
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
||||
|
||||
/* Create one frame holding color options
|
||||
*/
|
||||
frame = gtk_frame_new ("Color Options");
|
||||
gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0);
|
||||
|
||||
table = gtk_table_new (2, 2, FALSE);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (table), 5);
|
||||
gtk_table_set_row_spacings (GTK_TABLE (table), 5);
|
||||
gtk_table_set_col_spacings (GTK_TABLE (table), 10);
|
||||
gtk_container_add (GTK_CONTAINER (frame), table);
|
||||
|
||||
add_row (GTK_TABLE (table), 0, size_group, "_Foreground", color_options);
|
||||
add_row (GTK_TABLE (table), 1, size_group, "_Background", color_options);
|
||||
|
||||
/* And another frame holding line style options
|
||||
*/
|
||||
frame = gtk_frame_new ("Line Options");
|
||||
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
||||
|
||||
table = gtk_table_new (2, 2, FALSE);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (table), 5);
|
||||
gtk_table_set_row_spacings (GTK_TABLE (table), 5);
|
||||
gtk_table_set_col_spacings (GTK_TABLE (table), 10);
|
||||
gtk_container_add (GTK_CONTAINER (frame), table);
|
||||
|
||||
add_row (GTK_TABLE (table), 0, size_group, "_Dashing", dash_options);
|
||||
add_row (GTK_TABLE (table), 1, size_group, "_Line ends", end_options);
|
||||
|
||||
/* And a check button to turn grouping on and off */
|
||||
check_button = gtk_check_button_new_with_mnemonic ("_Enable grouping");
|
||||
gtk_box_pack_start (GTK_BOX (vbox), check_button, FALSE, FALSE, 0);
|
||||
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button), TRUE);
|
||||
g_signal_connect (check_button, "toggled",
|
||||
G_CALLBACK (toggle_grouping), size_group);
|
||||
}
|
||||
|
||||
if (!GTK_WIDGET_VISIBLE (window))
|
||||
gtk_widget_show_all (window);
|
||||
else
|
||||
gtk_widget_destroy (window);
|
||||
|
||||
return window;
|
||||
}
|
570
demos/gtk-demo/stock_browser.c
Normal file
570
demos/gtk-demo/stock_browser.c
Normal file
@@ -0,0 +1,570 @@
|
||||
/* Stock Item and Icon Browser
|
||||
*
|
||||
* This source code for this demo doesn't demonstrate anything
|
||||
* particularly useful in applications. The purpose of the "demo" is
|
||||
* just to provide a handy place to browse the available stock icons
|
||||
* and stock items.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include "demo-common.h"
|
||||
|
||||
typedef struct _StockItemInfo StockItemInfo;
|
||||
struct _StockItemInfo
|
||||
{
|
||||
gchar *id;
|
||||
GtkStockItem item;
|
||||
GdkPixbuf *small_icon;
|
||||
gchar *macro;
|
||||
gchar *accel_str;
|
||||
};
|
||||
|
||||
/* Make StockItemInfo a boxed type so we can automatically
|
||||
* manage memory
|
||||
*/
|
||||
#define STOCK_ITEM_INFO_TYPE stock_item_info_get_type ()
|
||||
|
||||
static void
|
||||
stock_item_info_free (StockItemInfo *info)
|
||||
{
|
||||
g_free (info->id);
|
||||
g_free (info->macro);
|
||||
g_free (info->accel_str);
|
||||
if (info->small_icon)
|
||||
g_object_unref (G_OBJECT (info->small_icon));
|
||||
|
||||
g_free (info);
|
||||
}
|
||||
|
||||
static StockItemInfo*
|
||||
stock_item_info_copy (StockItemInfo *src)
|
||||
{
|
||||
StockItemInfo *info;
|
||||
|
||||
info = g_new (StockItemInfo, 1);
|
||||
info->id = g_strdup (src->id);
|
||||
info->macro = g_strdup (src->macro);
|
||||
info->accel_str = g_strdup (src->accel_str);
|
||||
|
||||
info->item = src->item;
|
||||
|
||||
info->small_icon = src->small_icon;
|
||||
if (info->small_icon)
|
||||
g_object_ref (G_OBJECT (info->small_icon));
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
static GType
|
||||
stock_item_info_get_type (void)
|
||||
{
|
||||
static GType our_type = 0;
|
||||
|
||||
if (our_type == 0)
|
||||
our_type = g_boxed_type_register_static ("StockItemInfo",
|
||||
(GBoxedCopyFunc) stock_item_info_copy,
|
||||
(GBoxedFreeFunc) stock_item_info_free);
|
||||
|
||||
return our_type;
|
||||
}
|
||||
|
||||
typedef struct _StockItemDisplay StockItemDisplay;
|
||||
struct _StockItemDisplay
|
||||
{
|
||||
GtkWidget *type_label;
|
||||
GtkWidget *macro_label;
|
||||
GtkWidget *id_label;
|
||||
GtkWidget *label_accel_label;
|
||||
GtkWidget *icon_image;
|
||||
};
|
||||
|
||||
static gchar*
|
||||
id_to_macro (const gchar *id)
|
||||
{
|
||||
GString *macro = NULL;
|
||||
const gchar *cp;
|
||||
|
||||
/* gtk-foo-bar -> GTK_STOCK_FOO_BAR */
|
||||
|
||||
macro = g_string_new (NULL);
|
||||
|
||||
cp = id;
|
||||
|
||||
if (strncmp (cp, "gtk-", 4) == 0)
|
||||
{
|
||||
g_string_append (macro, "GTK_STOCK_");
|
||||
cp += 4;
|
||||
}
|
||||
|
||||
while (*cp)
|
||||
{
|
||||
if (*cp == '-')
|
||||
g_string_append_c (macro, '_');
|
||||
else if (g_ascii_islower (*cp))
|
||||
g_string_append_c (macro, g_ascii_toupper (*cp));
|
||||
else
|
||||
g_string_append_c (macro, *cp);
|
||||
|
||||
cp++;
|
||||
}
|
||||
|
||||
return g_string_free (macro, FALSE);
|
||||
}
|
||||
|
||||
static GtkTreeModel*
|
||||
create_model (GtkWidget *window)
|
||||
{
|
||||
GtkListStore *store;
|
||||
GSList *ids;
|
||||
GSList *tmp_list;
|
||||
|
||||
store = gtk_list_store_new (1, STOCK_ITEM_INFO_TYPE);
|
||||
|
||||
ids = gtk_stock_list_ids ();
|
||||
ids = g_slist_sort (ids, (GCompareFunc) strcmp);
|
||||
tmp_list = ids;
|
||||
while (tmp_list != NULL)
|
||||
{
|
||||
StockItemInfo info;
|
||||
GtkStockItem item;
|
||||
GtkTreeIter iter;
|
||||
GtkIconSet *icon_set;
|
||||
|
||||
info.id = tmp_list->data;
|
||||
|
||||
if (gtk_stock_lookup (info.id, &item))
|
||||
{
|
||||
info.item = item;
|
||||
}
|
||||
else
|
||||
{
|
||||
info.item.label = NULL;
|
||||
info.item.stock_id = NULL;
|
||||
info.item.modifier = 0;
|
||||
info.item.keyval = 0;
|
||||
info.item.translation_domain = NULL;
|
||||
}
|
||||
|
||||
/* only show icons for stock IDs that have default icons */
|
||||
icon_set = gtk_icon_factory_lookup_default (info.id);
|
||||
if (icon_set)
|
||||
{
|
||||
GtkIconSize *sizes = NULL;
|
||||
gint n_sizes = 0;
|
||||
gint i;
|
||||
GtkIconSize size;
|
||||
|
||||
/* See what sizes this stock icon really exists at */
|
||||
gtk_icon_set_get_sizes (icon_set, &sizes, &n_sizes);
|
||||
|
||||
/* Use menu size if it exists, otherwise first size found */
|
||||
size = sizes[0];
|
||||
i = 0;
|
||||
while (i < n_sizes)
|
||||
{
|
||||
if (sizes[i] == GTK_ICON_SIZE_MENU)
|
||||
{
|
||||
size = GTK_ICON_SIZE_MENU;
|
||||
break;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
g_free (sizes);
|
||||
|
||||
info.small_icon = gtk_widget_render_icon (window, info.id,
|
||||
size,
|
||||
NULL);
|
||||
|
||||
if (size != GTK_ICON_SIZE_MENU)
|
||||
{
|
||||
/* Make the result the proper size for our thumbnail */
|
||||
gint w, h;
|
||||
GdkPixbuf *scaled;
|
||||
|
||||
gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &w, &h);
|
||||
|
||||
scaled = gdk_pixbuf_scale_simple (info.small_icon,
|
||||
w, h,
|
||||
GDK_INTERP_BILINEAR);
|
||||
|
||||
g_object_unref (G_OBJECT (info.small_icon));
|
||||
info.small_icon = scaled;
|
||||
}
|
||||
}
|
||||
else
|
||||
info.small_icon = NULL;
|
||||
|
||||
if (info.item.keyval != 0)
|
||||
{
|
||||
info.accel_str = gtk_accelerator_name (info.item.keyval,
|
||||
info.item.modifier);
|
||||
}
|
||||
else
|
||||
{
|
||||
info.accel_str = g_strdup ("");
|
||||
}
|
||||
|
||||
info.macro = id_to_macro (info.id);
|
||||
|
||||
gtk_list_store_append (store, &iter);
|
||||
gtk_list_store_set (store, &iter, 0, &info, -1);
|
||||
|
||||
g_free (info.macro);
|
||||
g_free (info.accel_str);
|
||||
if (info.small_icon)
|
||||
g_object_unref (G_OBJECT (info.small_icon));
|
||||
|
||||
tmp_list = g_slist_next (tmp_list);
|
||||
}
|
||||
|
||||
g_slist_foreach (ids, (GFunc)g_free, NULL);
|
||||
g_slist_free (ids);
|
||||
|
||||
return GTK_TREE_MODEL (store);
|
||||
}
|
||||
|
||||
/* Finds the largest size at which the given image stock id is
|
||||
* available. This would not be useful for a normal application
|
||||
*/
|
||||
static GtkIconSize
|
||||
get_largest_size (const char *id)
|
||||
{
|
||||
GtkIconSet *set = gtk_icon_factory_lookup_default (id);
|
||||
GtkIconSize *sizes;
|
||||
gint n_sizes, i;
|
||||
GtkIconSize best_size = GTK_ICON_SIZE_INVALID;
|
||||
gint best_pixels = 0;
|
||||
|
||||
gtk_icon_set_get_sizes (set, &sizes, &n_sizes);
|
||||
|
||||
for (i = 0; i < n_sizes; i++)
|
||||
{
|
||||
gint width, height;
|
||||
|
||||
gtk_icon_size_lookup (sizes[i], &width, &height);
|
||||
|
||||
if (width * height > best_pixels)
|
||||
{
|
||||
best_size = sizes[i];
|
||||
best_pixels = width * height;
|
||||
}
|
||||
}
|
||||
|
||||
g_free (sizes);
|
||||
|
||||
return best_size;
|
||||
}
|
||||
|
||||
static void
|
||||
selection_changed (GtkTreeSelection *selection)
|
||||
{
|
||||
GtkTreeView *treeview;
|
||||
StockItemDisplay *display;
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
|
||||
treeview = gtk_tree_selection_get_tree_view (selection);
|
||||
display = g_object_get_data (G_OBJECT (treeview), "stock-display");
|
||||
|
||||
if (gtk_tree_selection_get_selected (selection, &model, &iter))
|
||||
{
|
||||
StockItemInfo *info;
|
||||
gchar *str;
|
||||
|
||||
gtk_tree_model_get (model, &iter,
|
||||
0, &info,
|
||||
-1);
|
||||
|
||||
if (info->small_icon && info->item.label)
|
||||
gtk_label_set_text (GTK_LABEL (display->type_label), "Icon and Item");
|
||||
else if (info->small_icon)
|
||||
gtk_label_set_text (GTK_LABEL (display->type_label), "Icon Only");
|
||||
else if (info->item.label)
|
||||
gtk_label_set_text (GTK_LABEL (display->type_label), "Item Only");
|
||||
else
|
||||
gtk_label_set_text (GTK_LABEL (display->type_label), "???????");
|
||||
|
||||
gtk_label_set_text (GTK_LABEL (display->macro_label), info->macro);
|
||||
gtk_label_set_text (GTK_LABEL (display->id_label), info->id);
|
||||
|
||||
if (info->item.label)
|
||||
{
|
||||
str = g_strdup_printf ("%s %s", info->item.label, info->accel_str);
|
||||
gtk_label_set_text_with_mnemonic (GTK_LABEL (display->label_accel_label), str);
|
||||
g_free (str);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_label_set_text (GTK_LABEL (display->label_accel_label), "");
|
||||
}
|
||||
|
||||
if (info->small_icon)
|
||||
gtk_image_set_from_stock (GTK_IMAGE (display->icon_image), info->id,
|
||||
get_largest_size (info->id));
|
||||
else
|
||||
gtk_image_set_from_pixbuf (GTK_IMAGE (display->icon_image), NULL);
|
||||
|
||||
stock_item_info_free (info);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_label_set_text (GTK_LABEL (display->type_label), "No selected item");
|
||||
gtk_label_set_text (GTK_LABEL (display->macro_label), "");
|
||||
gtk_label_set_text (GTK_LABEL (display->id_label), "");
|
||||
gtk_label_set_text (GTK_LABEL (display->label_accel_label), "");
|
||||
gtk_image_set_from_pixbuf (GTK_IMAGE (display->icon_image), NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
macro_set_func_text (GtkTreeViewColumn *tree_column,
|
||||
GtkCellRenderer *cell,
|
||||
GtkTreeModel *model,
|
||||
GtkTreeIter *iter,
|
||||
gpointer data)
|
||||
{
|
||||
StockItemInfo *info;
|
||||
|
||||
gtk_tree_model_get (model, iter,
|
||||
0, &info,
|
||||
-1);
|
||||
|
||||
g_object_set (GTK_CELL_RENDERER (cell),
|
||||
"text", info->macro,
|
||||
NULL);
|
||||
|
||||
stock_item_info_free (info);
|
||||
}
|
||||
|
||||
static void
|
||||
macro_set_func_pixbuf (GtkTreeViewColumn *tree_column,
|
||||
GtkCellRenderer *cell,
|
||||
GtkTreeModel *model,
|
||||
GtkTreeIter *iter,
|
||||
gpointer data)
|
||||
{
|
||||
StockItemInfo *info;
|
||||
|
||||
gtk_tree_model_get (model, iter,
|
||||
0, &info,
|
||||
-1);
|
||||
|
||||
g_object_set (GTK_CELL_RENDERER (cell),
|
||||
"pixbuf", info->small_icon,
|
||||
NULL);
|
||||
|
||||
stock_item_info_free (info);
|
||||
}
|
||||
|
||||
static void
|
||||
id_set_func (GtkTreeViewColumn *tree_column,
|
||||
GtkCellRenderer *cell,
|
||||
GtkTreeModel *model,
|
||||
GtkTreeIter *iter,
|
||||
gpointer data)
|
||||
{
|
||||
StockItemInfo *info;
|
||||
|
||||
gtk_tree_model_get (model, iter,
|
||||
0, &info,
|
||||
-1);
|
||||
|
||||
g_object_set (GTK_CELL_RENDERER (cell),
|
||||
"text", info->id,
|
||||
NULL);
|
||||
|
||||
stock_item_info_free (info);
|
||||
}
|
||||
|
||||
static void
|
||||
accel_set_func (GtkTreeViewColumn *tree_column,
|
||||
GtkCellRenderer *cell,
|
||||
GtkTreeModel *model,
|
||||
GtkTreeIter *iter,
|
||||
gpointer data)
|
||||
{
|
||||
StockItemInfo *info;
|
||||
|
||||
gtk_tree_model_get (model, iter,
|
||||
0, &info,
|
||||
-1);
|
||||
|
||||
g_object_set (GTK_CELL_RENDERER (cell),
|
||||
"text", info->accel_str,
|
||||
NULL);
|
||||
|
||||
stock_item_info_free (info);
|
||||
}
|
||||
|
||||
static void
|
||||
label_set_func (GtkTreeViewColumn *tree_column,
|
||||
GtkCellRenderer *cell,
|
||||
GtkTreeModel *model,
|
||||
GtkTreeIter *iter,
|
||||
gpointer data)
|
||||
{
|
||||
StockItemInfo *info;
|
||||
|
||||
gtk_tree_model_get (model, iter,
|
||||
0, &info,
|
||||
-1);
|
||||
|
||||
g_object_set (GTK_CELL_RENDERER (cell),
|
||||
"text", info->item.label,
|
||||
NULL);
|
||||
|
||||
stock_item_info_free (info);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_stock_browser (GtkWidget *do_widget)
|
||||
{
|
||||
GtkWidget *window = get_cached_widget (do_widget, "do_stock_browser");
|
||||
|
||||
if (!window)
|
||||
{
|
||||
GtkWidget *frame;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *sw;
|
||||
GtkWidget *treeview;
|
||||
GtkWidget *align;
|
||||
GtkTreeModel *model;
|
||||
GtkCellRenderer *cell_renderer;
|
||||
StockItemDisplay *display;
|
||||
GtkTreeSelection *selection;
|
||||
GtkTreeViewColumn *column;
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
|
||||
gtk_window_set_screen (GTK_WINDOW (window),
|
||||
gtk_widget_get_screen (do_widget));
|
||||
cache_widget (window, "do_stock_browser");
|
||||
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Stock Icons and Items");
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), -1, 500);
|
||||
|
||||
g_signal_connect (window, "destroy", G_CALLBACK (remove_cached_widget),
|
||||
"do_stock_browser");
|
||||
|
||||
gtk_container_set_border_width (GTK_CONTAINER (window), 8);
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 8);
|
||||
gtk_container_add (GTK_CONTAINER (window), hbox);
|
||||
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_NEVER,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), sw, FALSE, FALSE, 0);
|
||||
|
||||
model = create_model (window);
|
||||
|
||||
treeview = gtk_tree_view_new_with_model (model);
|
||||
|
||||
g_object_unref (G_OBJECT (model));
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (sw), treeview);
|
||||
|
||||
column = gtk_tree_view_column_new ();
|
||||
gtk_tree_view_column_set_title (column, "Macro");
|
||||
|
||||
cell_renderer = gtk_cell_renderer_pixbuf_new ();
|
||||
gtk_tree_view_column_pack_start (column,
|
||||
cell_renderer,
|
||||
FALSE);
|
||||
gtk_tree_view_column_set_cell_data_func (column, cell_renderer,
|
||||
macro_set_func_pixbuf, NULL, NULL);
|
||||
cell_renderer = gtk_cell_renderer_text_new ();
|
||||
gtk_tree_view_column_pack_start (column,
|
||||
cell_renderer,
|
||||
TRUE);
|
||||
gtk_tree_view_column_set_cell_data_func (column, cell_renderer,
|
||||
macro_set_func_text, NULL, NULL);
|
||||
|
||||
gtk_tree_view_append_column (GTK_TREE_VIEW (treeview),
|
||||
column);
|
||||
|
||||
cell_renderer = gtk_cell_renderer_text_new ();
|
||||
|
||||
gtk_tree_view_insert_column_with_data_func (GTK_TREE_VIEW (treeview),
|
||||
-1,
|
||||
"Label",
|
||||
cell_renderer,
|
||||
label_set_func,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
gtk_tree_view_insert_column_with_data_func (GTK_TREE_VIEW (treeview),
|
||||
-1,
|
||||
"Accel",
|
||||
cell_renderer,
|
||||
accel_set_func,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
gtk_tree_view_insert_column_with_data_func (GTK_TREE_VIEW (treeview),
|
||||
-1,
|
||||
"ID",
|
||||
cell_renderer,
|
||||
id_set_func,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
align = gtk_alignment_new (0.5, 0.0, 0.0, 0.0);
|
||||
gtk_box_pack_end (GTK_BOX (hbox), align, FALSE, FALSE, 0);
|
||||
|
||||
frame = gtk_frame_new ("Selected Item");
|
||||
gtk_container_add (GTK_CONTAINER (align), frame);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 8);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
|
||||
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
||||
|
||||
display = g_new (StockItemDisplay, 1);
|
||||
g_object_set_data_full (G_OBJECT (treeview),
|
||||
"stock-display",
|
||||
display,
|
||||
g_free); /* free display with treeview */
|
||||
|
||||
display->type_label = gtk_label_new (NULL);
|
||||
display->macro_label = gtk_label_new (NULL);
|
||||
display->id_label = gtk_label_new (NULL);
|
||||
display->label_accel_label = gtk_label_new (NULL);
|
||||
display->icon_image = gtk_image_new_from_pixbuf (NULL); /* empty image */
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (vbox), display->type_label,
|
||||
FALSE, FALSE, 0);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (vbox), display->icon_image,
|
||||
FALSE, FALSE, 0);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (vbox), display->label_accel_label,
|
||||
FALSE, FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), display->macro_label,
|
||||
FALSE, FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), display->id_label,
|
||||
FALSE, FALSE, 0);
|
||||
|
||||
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
|
||||
gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
|
||||
|
||||
g_signal_connect (G_OBJECT (selection),
|
||||
"changed",
|
||||
G_CALLBACK (selection_changed),
|
||||
NULL);
|
||||
}
|
||||
|
||||
if (!GTK_WIDGET_VISIBLE (window))
|
||||
{
|
||||
gtk_widget_show_all (window);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_destroy (window);
|
||||
window = NULL;
|
||||
}
|
||||
|
||||
return window;
|
||||
}
|
@@ -8,36 +8,11 @@
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <stdlib.h> /* for exit() */
|
||||
|
||||
/* Don't copy this bad example; inline RGB data is always a better
|
||||
* idea than inline XPMs.
|
||||
*/
|
||||
static char *book_closed_xpm[] = {
|
||||
"16 16 6 1",
|
||||
" c None s None",
|
||||
". c black",
|
||||
"X c red",
|
||||
"o c yellow",
|
||||
"O c #808080",
|
||||
"# c white",
|
||||
" ",
|
||||
" .. ",
|
||||
" ..XX. ",
|
||||
" ..XXXXX. ",
|
||||
" ..XXXXXXXX. ",
|
||||
".ooXXXXXXXXX. ",
|
||||
"..ooXXXXXXXXX. ",
|
||||
".X.ooXXXXXXXXX. ",
|
||||
".XX.ooXXXXXX.. ",
|
||||
" .XX.ooXXX..#O ",
|
||||
" .XX.oo..##OO. ",
|
||||
" .XX..##OO.. ",
|
||||
" .X.#OO.. ",
|
||||
" ..O.. ",
|
||||
" .. ",
|
||||
" "
|
||||
};
|
||||
#include "demo-common.h"
|
||||
|
||||
static void easter_egg_callback (GtkWidget *button, gpointer data);
|
||||
|
||||
#define gray50_width 2
|
||||
#define gray50_height 2
|
||||
@@ -46,7 +21,8 @@ static char gray50_bits[] = {
|
||||
};
|
||||
|
||||
static void
|
||||
create_tags (GtkTextBuffer *buffer)
|
||||
create_tags (GdkScreen *screen,
|
||||
GtkTextBuffer *buffer)
|
||||
{
|
||||
GdkBitmap *stipple;
|
||||
|
||||
@@ -63,111 +39,111 @@ create_tags (GtkTextBuffer *buffer)
|
||||
* new copies of the same tags for every buffer.
|
||||
*
|
||||
* Tags are assigned default priorities in order of addition to the
|
||||
* tag table. That is, tags created later that affect the same text
|
||||
* tag table. That is, tags created later that affect the same text
|
||||
* property affected by an earlier tag will override the earlier
|
||||
* tag. You can modify tag priorities with
|
||||
* gtk_text_tag_set_priority().
|
||||
*/
|
||||
|
||||
gtk_text_buffer_create_tag (buffer, "heading",
|
||||
"weight", PANGO_WEIGHT_BOLD,
|
||||
"size", 20 * PANGO_SCALE,
|
||||
NULL);
|
||||
"weight", PANGO_WEIGHT_BOLD,
|
||||
"size", 15 * PANGO_SCALE,
|
||||
NULL);
|
||||
|
||||
gtk_text_buffer_create_tag (buffer, "italic",
|
||||
"style", PANGO_STYLE_ITALIC, NULL);
|
||||
"style", PANGO_STYLE_ITALIC, NULL);
|
||||
|
||||
gtk_text_buffer_create_tag (buffer, "bold",
|
||||
"weight", PANGO_WEIGHT_BOLD, NULL);
|
||||
"weight", PANGO_WEIGHT_BOLD, NULL);
|
||||
|
||||
gtk_text_buffer_create_tag (buffer, "big",
|
||||
/* points times the PANGO_SCALE factor */
|
||||
"size", 30 * PANGO_SCALE, NULL);
|
||||
/* points times the PANGO_SCALE factor */
|
||||
"size", 20 * PANGO_SCALE, NULL);
|
||||
|
||||
gtk_text_buffer_create_tag (buffer, "xx-small",
|
||||
"scale", PANGO_SCALE_XX_SMALL, NULL);
|
||||
"scale", PANGO_SCALE_XX_SMALL, NULL);
|
||||
|
||||
gtk_text_buffer_create_tag (buffer, "x-large",
|
||||
"scale", PANGO_SCALE_X_LARGE, NULL);
|
||||
"scale", PANGO_SCALE_X_LARGE, NULL);
|
||||
|
||||
gtk_text_buffer_create_tag (buffer, "monospace",
|
||||
"family", "monospace", NULL);
|
||||
"family", "monospace", NULL);
|
||||
|
||||
gtk_text_buffer_create_tag (buffer, "blue_foreground",
|
||||
"foreground", "blue", NULL);
|
||||
"foreground", "blue", NULL);
|
||||
|
||||
gtk_text_buffer_create_tag (buffer, "red_background",
|
||||
"background", "red", NULL);
|
||||
"background", "red", NULL);
|
||||
|
||||
stipple = gdk_bitmap_create_from_data (NULL,
|
||||
gray50_bits, gray50_width,
|
||||
gray50_height);
|
||||
stipple = gdk_bitmap_create_from_data (gdk_screen_get_root_window (screen),
|
||||
gray50_bits, gray50_width,
|
||||
gray50_height);
|
||||
|
||||
gtk_text_buffer_create_tag (buffer, "background_stipple",
|
||||
"background_stipple", stipple, NULL);
|
||||
"background_stipple", stipple, NULL);
|
||||
|
||||
gtk_text_buffer_create_tag (buffer, "foreground_stipple",
|
||||
"foreground_stipple", stipple, NULL);
|
||||
"foreground_stipple", stipple, NULL);
|
||||
|
||||
g_object_unref (G_OBJECT (stipple));
|
||||
|
||||
gtk_text_buffer_create_tag (buffer, "big_gap_before_line",
|
||||
"pixels_above_lines", 30, NULL);
|
||||
"pixels_above_lines", 30, NULL);
|
||||
|
||||
gtk_text_buffer_create_tag (buffer, "big_gap_after_line",
|
||||
"pixels_below_lines", 30, NULL);
|
||||
"pixels_below_lines", 30, NULL);
|
||||
|
||||
gtk_text_buffer_create_tag (buffer, "double_spaced_line",
|
||||
"pixels_inside_wrap", 10, NULL);
|
||||
"pixels_inside_wrap", 10, NULL);
|
||||
|
||||
gtk_text_buffer_create_tag (buffer, "not_editable",
|
||||
"editable", FALSE, NULL);
|
||||
"editable", FALSE, NULL);
|
||||
|
||||
gtk_text_buffer_create_tag (buffer, "word_wrap",
|
||||
"wrap_mode", GTK_WRAP_WORD, NULL);
|
||||
"wrap_mode", GTK_WRAP_WORD, NULL);
|
||||
|
||||
gtk_text_buffer_create_tag (buffer, "char_wrap",
|
||||
"wrap_mode", GTK_WRAP_CHAR, NULL);
|
||||
"wrap_mode", GTK_WRAP_CHAR, NULL);
|
||||
|
||||
gtk_text_buffer_create_tag (buffer, "no_wrap",
|
||||
"wrap_mode", GTK_WRAP_NONE, NULL);
|
||||
"wrap_mode", GTK_WRAP_NONE, NULL);
|
||||
|
||||
gtk_text_buffer_create_tag (buffer, "center",
|
||||
"justification", GTK_JUSTIFY_CENTER, NULL);
|
||||
"justification", GTK_JUSTIFY_CENTER, NULL);
|
||||
|
||||
gtk_text_buffer_create_tag (buffer, "right_justify",
|
||||
"justification", GTK_JUSTIFY_RIGHT, NULL);
|
||||
"justification", GTK_JUSTIFY_RIGHT, NULL);
|
||||
|
||||
gtk_text_buffer_create_tag (buffer, "wide_margins",
|
||||
"left_margin", 50, "right_margin", 50,
|
||||
NULL);
|
||||
"left_margin", 50, "right_margin", 50,
|
||||
NULL);
|
||||
|
||||
gtk_text_buffer_create_tag (buffer, "strikethrough",
|
||||
"strikethrough", TRUE, NULL);
|
||||
"strikethrough", TRUE, NULL);
|
||||
|
||||
gtk_text_buffer_create_tag (buffer, "underline",
|
||||
"underline", PANGO_UNDERLINE_SINGLE, NULL);
|
||||
"underline", PANGO_UNDERLINE_SINGLE, NULL);
|
||||
|
||||
gtk_text_buffer_create_tag (buffer, "double_underline",
|
||||
"underline", PANGO_UNDERLINE_DOUBLE, NULL);
|
||||
"underline", PANGO_UNDERLINE_DOUBLE, NULL);
|
||||
|
||||
gtk_text_buffer_create_tag (buffer, "superscript",
|
||||
"rise", 10 * PANGO_SCALE, /* 10 pixels */
|
||||
"size", 8 * PANGO_SCALE, /* 8 points */
|
||||
NULL);
|
||||
"rise", 10 * PANGO_SCALE, /* 10 pixels */
|
||||
"size", 8 * PANGO_SCALE, /* 8 points */
|
||||
NULL);
|
||||
|
||||
gtk_text_buffer_create_tag (buffer, "subscript",
|
||||
"rise", -10 * PANGO_SCALE, /* 10 pixels */
|
||||
"size", 8 * PANGO_SCALE, /* 8 points */
|
||||
NULL);
|
||||
"rise", -10 * PANGO_SCALE, /* 10 pixels */
|
||||
"size", 8 * PANGO_SCALE, /* 8 points */
|
||||
NULL);
|
||||
|
||||
gtk_text_buffer_create_tag (buffer, "rtl_quote",
|
||||
"wrap_mode", GTK_WRAP_WORD,
|
||||
"direction", GTK_TEXT_DIR_RTL,
|
||||
"indent", 30,
|
||||
"left_margin", 20,
|
||||
"right_margin", 20,
|
||||
NULL);
|
||||
"wrap_mode", GTK_WRAP_WORD,
|
||||
"direction", GTK_TEXT_DIR_RTL,
|
||||
"indent", 30,
|
||||
"left_margin", 20,
|
||||
"right_margin", 20,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -176,8 +152,31 @@ insert_text (GtkTextBuffer *buffer)
|
||||
GtkTextIter iter;
|
||||
GtkTextIter start, end;
|
||||
GdkPixbuf *pixbuf;
|
||||
GdkPixbuf *scaled;
|
||||
GtkTextChildAnchor *anchor;
|
||||
char *filename;
|
||||
|
||||
pixbuf = gdk_pixbuf_new_from_xpm_data ((const char **) book_closed_xpm);
|
||||
/* 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)
|
||||
{
|
||||
g_printerr ("Failed to load image file gtk-logo-rgb.gif\n");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
scaled = gdk_pixbuf_scale_simple (pixbuf, 32, 32, GDK_INTERP_BILINEAR);
|
||||
g_object_unref (G_OBJECT (pixbuf));
|
||||
pixbuf = scaled;
|
||||
|
||||
/* get start of buffer; each insertion will revalidate the
|
||||
* iterator to point to just after the inserted text.
|
||||
@@ -187,88 +186,88 @@ insert_text (GtkTextBuffer *buffer)
|
||||
gtk_text_buffer_insert (buffer, &iter, "The text widget can display text with all kinds of nifty attributes. It also supports multiple views of the same buffer; this demo is showing the same buffer in two places.\n\n", -1);
|
||||
|
||||
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "Font styles. ", -1,
|
||||
"heading", NULL);
|
||||
"heading", NULL);
|
||||
|
||||
gtk_text_buffer_insert (buffer, &iter, "For example, you can have ", -1);
|
||||
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
|
||||
"italic", -1,
|
||||
"italic", NULL);
|
||||
"italic", -1,
|
||||
"italic", NULL);
|
||||
gtk_text_buffer_insert (buffer, &iter, ", ", -1);
|
||||
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
|
||||
"bold", -1,
|
||||
"bold", NULL);
|
||||
"bold", -1,
|
||||
"bold", NULL);
|
||||
gtk_text_buffer_insert (buffer, &iter, ", or ", -1);
|
||||
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
|
||||
"monospace (typewriter)", -1,
|
||||
"monospace", NULL);
|
||||
"monospace (typewriter)", -1,
|
||||
"monospace", NULL);
|
||||
gtk_text_buffer_insert (buffer, &iter, ", or ", -1);
|
||||
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
|
||||
"big", -1,
|
||||
"big", NULL);
|
||||
"big", -1,
|
||||
"big", NULL);
|
||||
gtk_text_buffer_insert (buffer, &iter, " text. ", -1);
|
||||
gtk_text_buffer_insert (buffer, &iter, "It's best not to hardcode specific text sizes; you can use relative sizes as with CSS, such as ", -1);
|
||||
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
|
||||
"xx-small", -1,
|
||||
"xx-small", NULL);
|
||||
"xx-small", -1,
|
||||
"xx-small", NULL);
|
||||
gtk_text_buffer_insert (buffer, &iter, " or ", -1);
|
||||
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
|
||||
"x-large", -1,
|
||||
"x-large", NULL);
|
||||
"x-large", -1,
|
||||
"x-large", NULL);
|
||||
gtk_text_buffer_insert (buffer, &iter, " to ensure that your program properly adapts if the user changes the default font size.\n\n", -1);
|
||||
|
||||
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "Colors. ", -1,
|
||||
"heading", NULL);
|
||||
"heading", NULL);
|
||||
|
||||
gtk_text_buffer_insert (buffer, &iter, "Colors such as ", -1);
|
||||
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
|
||||
"a blue foreground", -1,
|
||||
"blue_foreground", NULL);
|
||||
"a blue foreground", -1,
|
||||
"blue_foreground", NULL);
|
||||
gtk_text_buffer_insert (buffer, &iter, " or ", -1);
|
||||
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
|
||||
"a red background", -1,
|
||||
"red_background", NULL);
|
||||
"a red background", -1,
|
||||
"red_background", NULL);
|
||||
gtk_text_buffer_insert (buffer, &iter, " or even ", -1);
|
||||
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
|
||||
"a stippled red background", -1,
|
||||
"red_background",
|
||||
"background_stipple",
|
||||
NULL);
|
||||
"a stippled red background", -1,
|
||||
"red_background",
|
||||
"background_stipple",
|
||||
NULL);
|
||||
|
||||
gtk_text_buffer_insert (buffer, &iter, " or ", -1);
|
||||
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
|
||||
"a stippled blue foreground on solid red background", -1,
|
||||
"blue_foreground",
|
||||
"red_background",
|
||||
"foreground_stipple",
|
||||
NULL);
|
||||
"a stippled blue foreground on solid red background", -1,
|
||||
"blue_foreground",
|
||||
"red_background",
|
||||
"foreground_stipple",
|
||||
NULL);
|
||||
gtk_text_buffer_insert (buffer, &iter, " (select that to read it) can be used.\n\n", -1);
|
||||
|
||||
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "Underline, strikethrough, and rise. ", -1,
|
||||
"heading", NULL);
|
||||
"heading", NULL);
|
||||
|
||||
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
|
||||
"Strikethrough", -1,
|
||||
"strikethrough", NULL);
|
||||
"Strikethrough", -1,
|
||||
"strikethrough", NULL);
|
||||
gtk_text_buffer_insert (buffer, &iter, ", ", -1);
|
||||
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
|
||||
"underline", -1,
|
||||
"underline", NULL);
|
||||
"underline", -1,
|
||||
"underline", NULL);
|
||||
gtk_text_buffer_insert (buffer, &iter, ", ", -1);
|
||||
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
|
||||
"double underline", -1,
|
||||
"double_underline", NULL);
|
||||
"double underline", -1,
|
||||
"double_underline", NULL);
|
||||
gtk_text_buffer_insert (buffer, &iter, ", ", -1);
|
||||
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
|
||||
"superscript", -1,
|
||||
"superscript", NULL);
|
||||
"superscript", -1,
|
||||
"superscript", NULL);
|
||||
gtk_text_buffer_insert (buffer, &iter, ", and ", -1);
|
||||
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
|
||||
"subscript", -1,
|
||||
"subscript", NULL);
|
||||
"subscript", -1,
|
||||
"subscript", NULL);
|
||||
gtk_text_buffer_insert (buffer, &iter, " are all supported.\n\n", -1);
|
||||
|
||||
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "Images. ", -1,
|
||||
"heading", NULL);
|
||||
"heading", NULL);
|
||||
|
||||
gtk_text_buffer_insert (buffer, &iter, "The buffer can have images in it: ", -1);
|
||||
gtk_text_buffer_insert_pixbuf (buffer, &iter, pixbuf);
|
||||
@@ -277,68 +276,80 @@ insert_text (GtkTextBuffer *buffer)
|
||||
gtk_text_buffer_insert (buffer, &iter, " for example.\n\n", -1);
|
||||
|
||||
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "Spacing. ", -1,
|
||||
"heading", NULL);
|
||||
"heading", NULL);
|
||||
|
||||
gtk_text_buffer_insert (buffer, &iter, "You can adjust the amount of space before each line.\n", -1);
|
||||
|
||||
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
|
||||
"This line has a whole lot of space before it.\n", -1,
|
||||
"big_gap_before_line", "wide_margins", NULL);
|
||||
"This line has a whole lot of space before it.\n", -1,
|
||||
"big_gap_before_line", "wide_margins", NULL);
|
||||
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
|
||||
"You can also adjust the amount of space after each line; this line has a whole lot of space after it.\n", -1,
|
||||
"big_gap_after_line", "wide_margins", NULL);
|
||||
"You can also adjust the amount of space after each line; this line has a whole lot of space after it.\n", -1,
|
||||
"big_gap_after_line", "wide_margins", NULL);
|
||||
|
||||
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
|
||||
"You can also adjust the amount of space between wrapped lines; this line has extra space between each wrapped line in the same paragraph. To show off wrapping, some filler text: the quick brown fox jumped over the lazy dog. Blah blah blah blah blah blah blah blah blah.\n", -1,
|
||||
"double_spaced_line", "wide_margins", NULL);
|
||||
"You can also adjust the amount of space between wrapped lines; this line has extra space between each wrapped line in the same paragraph. To show off wrapping, some filler text: the quick brown fox jumped over the lazy dog. Blah blah blah blah blah blah blah blah blah.\n", -1,
|
||||
"double_spaced_line", "wide_margins", NULL);
|
||||
|
||||
gtk_text_buffer_insert (buffer, &iter, "Also note that those lines have extra-wide margins.\n\n", -1);
|
||||
|
||||
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "Editability. ", -1,
|
||||
"heading", NULL);
|
||||
"heading", NULL);
|
||||
|
||||
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
|
||||
"This line is 'locked down' and can't be edited by the user - just try it! You can't delete this line.\n\n", -1,
|
||||
"not_editable", NULL);
|
||||
"This line is 'locked down' and can't be edited by the user - just try it! You can't delete this line.\n\n", -1,
|
||||
"not_editable", NULL);
|
||||
|
||||
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "Wrapping. ", -1,
|
||||
"heading", NULL);
|
||||
"heading", NULL);
|
||||
|
||||
gtk_text_buffer_insert (buffer, &iter,
|
||||
"This line (and most of the others in this buffer) is word-wrapped, using the proper Unicode algorithm. Word wrap should work in all scripts and languages that GTK+ supports. Let's make this a long paragraph to demonstrate: blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah\n\n", -1);
|
||||
"This line (and most of the others in this buffer) is word-wrapped, using the proper Unicode algorithm. Word wrap should work in all scripts and languages that GTK+ supports. Let's make this a long paragraph to demonstrate: blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah\n\n", -1);
|
||||
|
||||
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
|
||||
"This line has character-based wrapping, and can wrap between any two character glyphs. Let's make this a long paragraph to demonstrate: blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah\n\n", -1,
|
||||
"char_wrap", NULL);
|
||||
"This line has character-based wrapping, and can wrap between any two character glyphs. Let's make this a long paragraph to demonstrate: blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah\n\n", -1,
|
||||
"char_wrap", NULL);
|
||||
|
||||
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
|
||||
"This line has all wrapping turned off, so it makes the horizontal scrollbar appear.\n\n\n", -1,
|
||||
"no_wrap", NULL);
|
||||
"This line has all wrapping turned off, so it makes the horizontal scrollbar appear.\n\n\n", -1,
|
||||
"no_wrap", NULL);
|
||||
|
||||
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "Justification. ", -1,
|
||||
"heading", NULL);
|
||||
"heading", NULL);
|
||||
|
||||
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
|
||||
"\nThis line has center justification.\n", -1,
|
||||
"center", NULL);
|
||||
"\nThis line has center justification.\n", -1,
|
||||
"center", NULL);
|
||||
|
||||
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
|
||||
"This line has right justification.\n", -1,
|
||||
"right_justify", NULL);
|
||||
"This line has right justification.\n", -1,
|
||||
"right_justify", NULL);
|
||||
|
||||
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
|
||||
"\nThis line has big wide margins. Text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text.\n", -1,
|
||||
"wide_margins", NULL);
|
||||
"\nThis line has big wide margins. Text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text.\n", -1,
|
||||
"wide_margins", NULL);
|
||||
|
||||
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "Internationalization. ", -1,
|
||||
"heading", NULL);
|
||||
|
||||
"heading", NULL);
|
||||
|
||||
gtk_text_buffer_insert (buffer, &iter,
|
||||
"You can put all sorts of Unicode text in the buffer.\n\nGerman (Deutsch Süd) Grüß Gott\nGreek (Ελληνικά) Γειά σας\nHebrew שלום\nJapanese (日本語)\n\nThe widget properly handles bidirectional text, word wrapping, DOS/UNIX/Unicode paragraph separators, grapheme boundaries, and so on using the Pango internationalization framework.\n", -1);
|
||||
"You can put all sorts of Unicode text in the buffer.\n\nGerman (Deutsch Süd) Grüß Gott\nGreek (Ελληνικά) Γειά σας\nHebrew שלום\nJapanese (日本語)\n\nThe widget properly handles bidirectional text, word wrapping, DOS/UNIX/Unicode paragraph separators, grapheme boundaries, and so on using the Pango internationalization framework.\n", -1);
|
||||
|
||||
gtk_text_buffer_insert (buffer, &iter, "Here's a word-wrapped quote in a right-to-left language:\n", -1);
|
||||
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "وقد بدأ ثلاث من أكثر المؤسسات تقدما في شبكة اكسيون برامجها كمنظمات لا تسعى للربح، ثم تحولت في السنوات الخمس الماضية إلى مؤسسات مالية منظمة، وباتت جزءا من النظام المالي في بلدانها، ولكنها تتخصص في خدمة قطاع المشروعات الصغيرة. وأحد أكثر هذه المؤسسات نجاحا هو »بانكوسول« في بوليفيا.\n\n", -1,
|
||||
"rtl_quote", NULL);
|
||||
gtk_text_buffer_insert (buffer, &iter, "Here's a word-wrapped quote in a right-to-left language:\n", -1);
|
||||
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "وقد بدأ ثلاث من أكثر المؤسسات تقدما في شبكة اكسيون برامجها كمنظمات لا تسعى للربح، ثم تحولت في السنوات الخمس الماضية إلى مؤسسات مالية منظمة، وباتت جزءا من النظام المالي في بلدانها، ولكنها تتخصص في خدمة قطاع المشروعات الصغيرة. وأحد أكثر هذه المؤسسات نجاحا هو »بانكوسول« في بوليفيا.\n\n", -1,
|
||||
"rtl_quote", NULL);
|
||||
|
||||
gtk_text_buffer_insert (buffer, &iter, "You can put widgets in the buffer: Here's a button: ", -1);
|
||||
anchor = gtk_text_buffer_create_child_anchor (buffer, &iter);
|
||||
gtk_text_buffer_insert (buffer, &iter, " and a menu: ", -1);
|
||||
anchor = gtk_text_buffer_create_child_anchor (buffer, &iter);
|
||||
gtk_text_buffer_insert (buffer, &iter, " and a scale: ", -1);
|
||||
anchor = gtk_text_buffer_create_child_anchor (buffer, &iter);
|
||||
gtk_text_buffer_insert (buffer, &iter, " and an animation: ", -1);
|
||||
anchor = gtk_text_buffer_create_child_anchor (buffer, &iter);
|
||||
gtk_text_buffer_insert (buffer, &iter, " finally a text entry: ", -1);
|
||||
anchor = gtk_text_buffer_create_child_anchor (buffer, &iter);
|
||||
gtk_text_buffer_insert (buffer, &iter, ".\n", -1);
|
||||
|
||||
gtk_text_buffer_insert (buffer, &iter, "\n\nThis demo doesn't demonstrate all the GtkTextBuffer features; it leaves out, for example: invisible/hidden text (doesn't work in GTK 2, but planned), tab stops, application-drawn areas on the sides of the widget for displaying breakpoints and such...", -1);
|
||||
|
||||
@@ -349,10 +360,98 @@ insert_text (GtkTextBuffer *buffer)
|
||||
g_object_unref (G_OBJECT (pixbuf));
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_textview (void)
|
||||
static gboolean
|
||||
find_anchor (GtkTextIter *iter)
|
||||
{
|
||||
static GtkWidget *window = NULL;
|
||||
while (gtk_text_iter_forward_char (iter))
|
||||
{
|
||||
if (gtk_text_iter_get_child_anchor (iter))
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
attach_widgets (GtkTextView *text_view)
|
||||
{
|
||||
GtkTextIter iter;
|
||||
GtkTextBuffer *buffer;
|
||||
int i;
|
||||
|
||||
buffer = gtk_text_view_get_buffer (text_view);
|
||||
|
||||
gtk_text_buffer_get_start_iter (buffer, &iter);
|
||||
|
||||
i = 0;
|
||||
while (find_anchor (&iter))
|
||||
{
|
||||
GtkTextChildAnchor *anchor;
|
||||
GtkWidget *widget;
|
||||
|
||||
anchor = gtk_text_iter_get_child_anchor (&iter);
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
widget = gtk_button_new_with_label ("Click Me");
|
||||
|
||||
g_signal_connect (G_OBJECT (widget), "clicked",
|
||||
G_CALLBACK (easter_egg_callback),
|
||||
NULL);
|
||||
}
|
||||
else if (i == 1)
|
||||
{
|
||||
GtkWidget *menu_item;
|
||||
GtkWidget *menu;
|
||||
|
||||
menu = gtk_menu_new ();
|
||||
|
||||
widget = gtk_option_menu_new ();
|
||||
|
||||
menu_item = gtk_menu_item_new_with_label ("Option 1");
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
|
||||
menu_item = gtk_menu_item_new_with_label ("Option 2");
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
|
||||
menu_item = gtk_menu_item_new_with_label ("Option 3");
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
|
||||
|
||||
gtk_option_menu_set_menu (GTK_OPTION_MENU (widget), menu);
|
||||
}
|
||||
else if (i == 2)
|
||||
{
|
||||
widget = gtk_hscale_new (NULL);
|
||||
gtk_range_set_range (GTK_RANGE (widget), 0, 100);
|
||||
gtk_widget_set_size_request (widget, 70, -1);
|
||||
}
|
||||
else if (i == 3)
|
||||
{
|
||||
gchar *filename = demo_find_file ("floppybuddy.gif", NULL);
|
||||
widget = gtk_image_new_from_file (filename);
|
||||
g_free (filename);
|
||||
}
|
||||
else if (i == 4)
|
||||
{
|
||||
widget = gtk_entry_new ();
|
||||
}
|
||||
else
|
||||
{
|
||||
widget = NULL; /* avoids a compiler warning */
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
gtk_text_view_add_child_at_anchor (text_view,
|
||||
widget,
|
||||
anchor);
|
||||
|
||||
gtk_widget_show_all (widget);
|
||||
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_textview (GtkWidget *do_widget)
|
||||
{
|
||||
GtkWidget *window = get_cached_widget (do_widget, "do_textview");
|
||||
|
||||
if (!window)
|
||||
{
|
||||
@@ -363,12 +462,16 @@ do_textview (void)
|
||||
GtkTextBuffer *buffer;
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_default_size (GTK_WINDOW (window),
|
||||
450, 450);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (window), "destroy",
|
||||
GTK_SIGNAL_FUNC(gtk_widget_destroyed),
|
||||
&window);
|
||||
gtk_window_set_screen (GTK_WINDOW (window),
|
||||
gtk_widget_get_screen (do_widget));
|
||||
cache_widget (window, "do_textview");
|
||||
|
||||
gtk_window_set_default_size (GTK_WINDOW (window),
|
||||
450, 450);
|
||||
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (remove_cached_widget), "do_textview");
|
||||
|
||||
gtk_window_set_title (GTK_WINDOW (window), "TextView");
|
||||
gtk_container_set_border_width (GTK_CONTAINER (window), 0);
|
||||
@@ -388,22 +491,25 @@ do_textview (void)
|
||||
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
gtk_paned_add1 (GTK_PANED (vpaned), sw);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (sw), view1);
|
||||
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
gtk_paned_add2 (GTK_PANED (vpaned), sw);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (sw), view2);
|
||||
|
||||
create_tags (buffer);
|
||||
create_tags (gtk_widget_get_screen (window), buffer);
|
||||
insert_text (buffer);
|
||||
|
||||
attach_widgets (GTK_TEXT_VIEW (view1));
|
||||
attach_widgets (GTK_TEXT_VIEW (view2));
|
||||
|
||||
gtk_widget_show_all (vpaned);
|
||||
}
|
||||
@@ -421,3 +527,88 @@ do_textview (void)
|
||||
return window;
|
||||
}
|
||||
|
||||
static void
|
||||
recursive_attach_view (int depth,
|
||||
GtkTextView *view,
|
||||
GtkTextChildAnchor *anchor)
|
||||
{
|
||||
GtkWidget *child_view;
|
||||
GtkWidget *event_box;
|
||||
GdkColor color;
|
||||
GtkWidget *align;
|
||||
|
||||
if (depth > 4)
|
||||
return;
|
||||
|
||||
child_view = gtk_text_view_new_with_buffer (gtk_text_view_get_buffer (view));
|
||||
|
||||
/* Event box is to add a black border around each child view */
|
||||
event_box = gtk_event_box_new ();
|
||||
gdk_color_parse ("black", &color);
|
||||
gtk_widget_modify_bg (event_box, GTK_STATE_NORMAL, &color);
|
||||
|
||||
align = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (align), 1);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (event_box), align);
|
||||
gtk_container_add (GTK_CONTAINER (align), child_view);
|
||||
|
||||
gtk_text_view_add_child_at_anchor (view, event_box, anchor);
|
||||
|
||||
recursive_attach_view (depth + 1, GTK_TEXT_VIEW (child_view), anchor);
|
||||
}
|
||||
|
||||
static void
|
||||
easter_egg_callback (GtkWidget *button,
|
||||
gpointer data)
|
||||
{
|
||||
static GtkWidget *window = NULL;
|
||||
GtkTextBuffer *buffer;
|
||||
GtkWidget *view;
|
||||
GtkTextIter iter;
|
||||
GtkTextChildAnchor *anchor;
|
||||
GtkWidget *sw;
|
||||
|
||||
if (window)
|
||||
{
|
||||
gtk_window_present (GTK_WINDOW (window));
|
||||
return;
|
||||
}
|
||||
|
||||
buffer = gtk_text_buffer_new (NULL);
|
||||
|
||||
gtk_text_buffer_get_start_iter (buffer, &iter);
|
||||
|
||||
gtk_text_buffer_insert (buffer, &iter,
|
||||
"This buffer is shared by a set of nested text views.\n Nested view:\n", -1);
|
||||
anchor = gtk_text_buffer_create_child_anchor (buffer, &iter);
|
||||
gtk_text_buffer_insert (buffer, &iter,
|
||||
"\nDon't do this in real applications, please.\n", -1);
|
||||
|
||||
view = gtk_text_view_new_with_buffer (buffer);
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_screen (GTK_WINDOW (window),
|
||||
gtk_widget_get_screen (button));
|
||||
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (window), sw);
|
||||
gtk_container_add (GTK_CONTAINER (sw), view);
|
||||
|
||||
recursive_attach_view (0, GTK_TEXT_VIEW (view), anchor);
|
||||
|
||||
g_object_unref (G_OBJECT (buffer));
|
||||
|
||||
|
||||
g_object_add_weak_pointer (G_OBJECT (window),
|
||||
(gpointer *) &window);
|
||||
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 300, 400);
|
||||
|
||||
gtk_widget_show_all (window);
|
||||
}
|
||||
|
||||
|
453
demos/gtk-demo/tree_store.c
Normal file
453
demos/gtk-demo/tree_store.c
Normal file
@@ -0,0 +1,453 @@
|
||||
/* Tree View/Tree Store
|
||||
*
|
||||
* The GtkTreeStore is used to store data in tree form, to be
|
||||
* used later on by a GtkTreeView to display it. This demo builds
|
||||
* a simple GtkTreeStore and displays it. If you're new to the
|
||||
* GtkTreeView widgets and associates, look into the GtkListStore
|
||||
* example first.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include "demo-common.h"
|
||||
|
||||
/* TreeItem structure */
|
||||
typedef struct _TreeItem TreeItem;
|
||||
struct _TreeItem
|
||||
{
|
||||
const gchar *label;
|
||||
gboolean alex;
|
||||
gboolean havoc;
|
||||
gboolean tim;
|
||||
gboolean owen;
|
||||
gboolean dave;
|
||||
gboolean world_holiday; /* shared by the European hackers */
|
||||
TreeItem *children;
|
||||
};
|
||||
|
||||
/* columns */
|
||||
enum
|
||||
{
|
||||
HOLIDAY_NAME_COLUMN = 0,
|
||||
ALEX_COLUMN,
|
||||
HAVOC_COLUMN,
|
||||
TIM_COLUMN,
|
||||
OWEN_COLUMN,
|
||||
DAVE_COLUMN,
|
||||
|
||||
VISIBLE_COLUMN,
|
||||
WORLD_COLUMN,
|
||||
NUM_COLUMNS
|
||||
};
|
||||
|
||||
/* tree data */
|
||||
static TreeItem january[] =
|
||||
{
|
||||
{"New Years Day", TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, NULL },
|
||||
{"Presidential Inauguration", FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, NULL },
|
||||
{"Martin Luther King Jr. day", FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, NULL },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static TreeItem february[] =
|
||||
{
|
||||
{ "Presidents' Day", FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, NULL },
|
||||
{ "Groundhog Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
|
||||
{ "Valentine's Day", FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, NULL },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static TreeItem march[] =
|
||||
{
|
||||
{ "National Tree Planting Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
|
||||
{ "St Patrick's Day", FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, NULL },
|
||||
{ NULL }
|
||||
};
|
||||
static TreeItem april[] =
|
||||
{
|
||||
{ "April Fools' Day", FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, NULL },
|
||||
{ "Army Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
|
||||
{ "Earth Day", FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, NULL },
|
||||
{ "Administrative Professionals' Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static TreeItem may[] =
|
||||
{
|
||||
{ "Nurses' Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
|
||||
{ "National Day of Prayer", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
|
||||
{ "Mothers' Day", FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, NULL },
|
||||
{ "Armed Forces Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
|
||||
{ "Memorial Day", TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, NULL },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static TreeItem june[] =
|
||||
{
|
||||
{ "June Fathers' Day", FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, NULL },
|
||||
{ "Juneteenth (Liberation of Slaves)", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
|
||||
{ "Flag Day", FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, NULL },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static TreeItem july[] =
|
||||
{
|
||||
{ "Parents' Day", FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, NULL },
|
||||
{ "Independence Day", FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, NULL },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static TreeItem august[] =
|
||||
{
|
||||
{ "Air Force Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
|
||||
{ "Coast Guard Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
|
||||
{ "Friendship Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static TreeItem september[] =
|
||||
{
|
||||
{ "Grandparents' Day", FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, NULL },
|
||||
{ "Citizenship Day or Constitution Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
|
||||
{ "Labor Day", TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, NULL },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static TreeItem october[] =
|
||||
{
|
||||
{ "National Children's Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
|
||||
{ "Bosses' Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
|
||||
{ "Sweetest Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
|
||||
{ "Mother-in-Law's Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
|
||||
{ "Navy Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
|
||||
{ "Columbus Day", FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, NULL },
|
||||
{ "Halloween", FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, NULL },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static TreeItem november[] =
|
||||
{
|
||||
{ "Marine Corps Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
|
||||
{ "Veterans' Day", TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, NULL },
|
||||
{ "Thanksgiving", FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, NULL },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static TreeItem december[] =
|
||||
{
|
||||
{ "Pearl Harbor Remembrance Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
|
||||
{ "Christmas", TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, NULL },
|
||||
{ "Kwanzaa", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
|
||||
static TreeItem toplevel[] =
|
||||
{
|
||||
{"January", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, january},
|
||||
{"February", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, february},
|
||||
{"March", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, march},
|
||||
{"April", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, april},
|
||||
{"May", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, may},
|
||||
{"June", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, june},
|
||||
{"July", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, july},
|
||||
{"August", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, august},
|
||||
{"September", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, september},
|
||||
{"October", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, october},
|
||||
{"November", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, november},
|
||||
{"December", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, december},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
|
||||
static GtkTreeModel *
|
||||
create_model (void)
|
||||
{
|
||||
GtkTreeStore *model;
|
||||
GtkTreeIter iter;
|
||||
TreeItem *month = toplevel;
|
||||
|
||||
/* create tree store */
|
||||
model = gtk_tree_store_new (NUM_COLUMNS,
|
||||
G_TYPE_STRING,
|
||||
G_TYPE_BOOLEAN,
|
||||
G_TYPE_BOOLEAN,
|
||||
G_TYPE_BOOLEAN,
|
||||
G_TYPE_BOOLEAN,
|
||||
G_TYPE_BOOLEAN,
|
||||
G_TYPE_BOOLEAN,
|
||||
G_TYPE_BOOLEAN);
|
||||
|
||||
/* add data to the tree store */
|
||||
while (month->label)
|
||||
{
|
||||
TreeItem *holiday = month->children;
|
||||
|
||||
gtk_tree_store_append (model, &iter, NULL);
|
||||
gtk_tree_store_set (model, &iter,
|
||||
HOLIDAY_NAME_COLUMN, month->label,
|
||||
ALEX_COLUMN, FALSE,
|
||||
HAVOC_COLUMN, FALSE,
|
||||
TIM_COLUMN, FALSE,
|
||||
OWEN_COLUMN, FALSE,
|
||||
DAVE_COLUMN, FALSE,
|
||||
VISIBLE_COLUMN, FALSE,
|
||||
WORLD_COLUMN, FALSE,
|
||||
-1);
|
||||
|
||||
/* add children */
|
||||
while (holiday->label)
|
||||
{
|
||||
GtkTreeIter child_iter;
|
||||
|
||||
gtk_tree_store_append (model, &child_iter, &iter);
|
||||
gtk_tree_store_set (model, &child_iter,
|
||||
HOLIDAY_NAME_COLUMN, holiday->label,
|
||||
ALEX_COLUMN, holiday->alex,
|
||||
HAVOC_COLUMN, holiday->havoc,
|
||||
TIM_COLUMN, holiday->tim,
|
||||
OWEN_COLUMN, holiday->owen,
|
||||
DAVE_COLUMN, holiday->dave,
|
||||
VISIBLE_COLUMN, TRUE,
|
||||
WORLD_COLUMN, holiday->world_holiday,
|
||||
-1);
|
||||
|
||||
holiday++;
|
||||
}
|
||||
|
||||
month++;
|
||||
}
|
||||
|
||||
return GTK_TREE_MODEL (model);
|
||||
}
|
||||
|
||||
static void
|
||||
item_toggled (GtkCellRendererToggle *cell,
|
||||
gchar *path_str,
|
||||
gpointer data)
|
||||
{
|
||||
GtkTreeModel *model = (GtkTreeModel *)data;
|
||||
GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
|
||||
GtkTreeIter iter;
|
||||
gboolean toggle_item;
|
||||
|
||||
gint *column;
|
||||
|
||||
column = g_object_get_data (G_OBJECT (cell), "column");
|
||||
|
||||
/* get toggled iter */
|
||||
gtk_tree_model_get_iter (model, &iter, path);
|
||||
gtk_tree_model_get (model, &iter, column, &toggle_item, -1);
|
||||
|
||||
/* do something with the value */
|
||||
toggle_item ^= 1;
|
||||
|
||||
/* set new value */
|
||||
gtk_tree_store_set (GTK_TREE_STORE (model), &iter, column,
|
||||
toggle_item, -1);
|
||||
|
||||
/* clean up */
|
||||
gtk_tree_path_free (path);
|
||||
}
|
||||
|
||||
static void
|
||||
add_columns (GtkTreeView *treeview)
|
||||
{
|
||||
gint col_offset;
|
||||
GtkCellRenderer *renderer;
|
||||
GtkTreeViewColumn *column;
|
||||
GtkTreeModel *model = gtk_tree_view_get_model (treeview);
|
||||
|
||||
/* column for holiday names */
|
||||
renderer = gtk_cell_renderer_text_new ();
|
||||
g_object_set (G_OBJECT (renderer), "xalign", 0.0, NULL);
|
||||
|
||||
col_offset = gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview),
|
||||
-1, "Holiday",
|
||||
renderer, "text",
|
||||
HOLIDAY_NAME_COLUMN,
|
||||
NULL);
|
||||
column = gtk_tree_view_get_column (GTK_TREE_VIEW (treeview), col_offset - 1);
|
||||
gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (column), TRUE);
|
||||
|
||||
/* alex column */
|
||||
renderer = gtk_cell_renderer_toggle_new ();
|
||||
g_object_set (G_OBJECT (renderer), "xalign", 0.0, NULL);
|
||||
g_object_set_data (G_OBJECT (renderer), "column", (gint *)ALEX_COLUMN);
|
||||
|
||||
g_signal_connect (G_OBJECT (renderer), "toggled", G_CALLBACK (item_toggled),
|
||||
model);
|
||||
col_offset = gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview),
|
||||
-1, "Alex",
|
||||
renderer,
|
||||
"active",
|
||||
ALEX_COLUMN,
|
||||
"visible",
|
||||
VISIBLE_COLUMN,
|
||||
"activatable",
|
||||
WORLD_COLUMN, NULL);
|
||||
|
||||
column = gtk_tree_view_get_column (GTK_TREE_VIEW (treeview), col_offset - 1);
|
||||
gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column),
|
||||
GTK_TREE_VIEW_COLUMN_FIXED);
|
||||
gtk_tree_view_column_set_fixed_width (GTK_TREE_VIEW_COLUMN (column), 50);
|
||||
gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (column), TRUE);
|
||||
|
||||
/* havoc column */
|
||||
renderer = gtk_cell_renderer_toggle_new ();
|
||||
g_object_set (G_OBJECT (renderer), "xalign", 0.0, NULL);
|
||||
g_object_set_data (G_OBJECT (renderer), "column", (gint *)HAVOC_COLUMN);
|
||||
|
||||
g_signal_connect (G_OBJECT (renderer), "toggled", G_CALLBACK (item_toggled),
|
||||
model);
|
||||
col_offset = gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview),
|
||||
-1, "Havoc",
|
||||
renderer,
|
||||
"active",
|
||||
HAVOC_COLUMN,
|
||||
"visible",
|
||||
VISIBLE_COLUMN,
|
||||
NULL);
|
||||
|
||||
column = gtk_tree_view_get_column (GTK_TREE_VIEW (treeview), col_offset - 1);
|
||||
gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column),
|
||||
GTK_TREE_VIEW_COLUMN_FIXED);
|
||||
gtk_tree_view_column_set_fixed_width (GTK_TREE_VIEW_COLUMN (column), 50);
|
||||
gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (column), TRUE);
|
||||
|
||||
/* tim column */
|
||||
renderer = gtk_cell_renderer_toggle_new ();
|
||||
g_object_set (G_OBJECT (renderer), "xalign", 0.0, NULL);
|
||||
g_object_set_data (G_OBJECT (renderer), "column", (gint *)TIM_COLUMN);
|
||||
|
||||
g_signal_connect (G_OBJECT (renderer), "toggled", G_CALLBACK (item_toggled),
|
||||
model);
|
||||
col_offset = gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview),
|
||||
-1, "Tim",
|
||||
renderer,
|
||||
"active",
|
||||
TIM_COLUMN,
|
||||
"visible",
|
||||
VISIBLE_COLUMN,
|
||||
"activatable",
|
||||
WORLD_COLUMN, NULL);
|
||||
|
||||
column = gtk_tree_view_get_column (GTK_TREE_VIEW (treeview), col_offset - 1);
|
||||
gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column),
|
||||
GTK_TREE_VIEW_COLUMN_FIXED);
|
||||
gtk_tree_view_column_set_fixed_width (GTK_TREE_VIEW_COLUMN (column), 50);
|
||||
gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (column), TRUE);
|
||||
|
||||
/* owen column */
|
||||
renderer = gtk_cell_renderer_toggle_new ();
|
||||
g_object_set (G_OBJECT (renderer), "xalign", 0.0, NULL);
|
||||
g_object_set_data (G_OBJECT (renderer), "column", (gint *)OWEN_COLUMN);
|
||||
|
||||
g_signal_connect (G_OBJECT (renderer), "toggled", G_CALLBACK (item_toggled),
|
||||
model);
|
||||
col_offset = gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview),
|
||||
-1, "Owen",
|
||||
renderer,
|
||||
"active",
|
||||
OWEN_COLUMN,
|
||||
"visible",
|
||||
VISIBLE_COLUMN,
|
||||
NULL);
|
||||
|
||||
column = gtk_tree_view_get_column (GTK_TREE_VIEW (treeview), col_offset - 1);
|
||||
gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column),
|
||||
GTK_TREE_VIEW_COLUMN_FIXED);
|
||||
gtk_tree_view_column_set_fixed_width (GTK_TREE_VIEW_COLUMN (column), 50);
|
||||
gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (column), TRUE);
|
||||
|
||||
/* dave column */
|
||||
renderer = gtk_cell_renderer_toggle_new ();
|
||||
g_object_set (G_OBJECT (renderer), "xalign", 0.0, NULL);
|
||||
g_object_set_data (G_OBJECT (renderer), "column", (gint *)DAVE_COLUMN);
|
||||
|
||||
g_signal_connect (G_OBJECT (renderer), "toggled", G_CALLBACK (item_toggled),
|
||||
model);
|
||||
col_offset = gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview),
|
||||
-1, "Dave",
|
||||
renderer,
|
||||
"active",
|
||||
DAVE_COLUMN,
|
||||
"visible",
|
||||
VISIBLE_COLUMN,
|
||||
NULL);
|
||||
|
||||
column = gtk_tree_view_get_column (GTK_TREE_VIEW (treeview), col_offset - 1);
|
||||
gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column),
|
||||
GTK_TREE_VIEW_COLUMN_FIXED);
|
||||
gtk_tree_view_column_set_fixed_width (GTK_TREE_VIEW_COLUMN (column), 50);
|
||||
gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (column), TRUE);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_tree_store (GtkWidget *do_widget)
|
||||
{
|
||||
GtkWidget *window = get_cached_widget (do_widget, "do_tree_store");
|
||||
|
||||
if (!window)
|
||||
{
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *sw;
|
||||
GtkWidget *treeview;
|
||||
GtkTreeModel *model;
|
||||
|
||||
/* create window, etc */
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_screen (GTK_WINDOW (window),
|
||||
gtk_widget_get_screen (do_widget));
|
||||
cache_widget (window, "do_tree_store");
|
||||
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Card planning sheet");
|
||||
g_signal_connect (G_OBJECT (window), "destroy",
|
||||
G_CALLBACK (remove_cached_widget), "do_tree_store");
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 8);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 8);
|
||||
gtk_container_add (GTK_CONTAINER (window), vbox);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (vbox),
|
||||
gtk_label_new ("Jonathan's Holiday Card Planning Sheet"),
|
||||
FALSE, FALSE, 0);
|
||||
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_SHADOW_ETCHED_IN);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0);
|
||||
|
||||
/* create model */
|
||||
model = create_model ();
|
||||
|
||||
/* create tree view */
|
||||
treeview = gtk_tree_view_new_with_model (model);
|
||||
g_object_unref (G_OBJECT (model));
|
||||
gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (treeview), TRUE);
|
||||
gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview)),
|
||||
GTK_SELECTION_MULTIPLE);
|
||||
|
||||
add_columns (GTK_TREE_VIEW (treeview));
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (sw), treeview);
|
||||
|
||||
/* expand all rows after the treeview widget has been realized */
|
||||
g_signal_connect (G_OBJECT (treeview), "realize",
|
||||
G_CALLBACK (gtk_tree_view_expand_all), NULL);
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 650, 400);
|
||||
}
|
||||
|
||||
if (!GTK_WIDGET_VISIBLE (window))
|
||||
gtk_widget_show_all (window);
|
||||
else
|
||||
{
|
||||
gtk_widget_destroy (window);
|
||||
window = NULL;
|
||||
}
|
||||
|
||||
return window;
|
||||
}
|
157
demos/gtk-demo/virtualscreen.c
Normal file
157
demos/gtk-demo/virtualscreen.c
Normal file
@@ -0,0 +1,157 @@
|
||||
/* Multihead Support/Virtual Screen Demo
|
||||
*
|
||||
* Demonstrates possible use of virtual screen information available when
|
||||
* a screen is made of multiple physical monitor screen.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include "demo-common.h"
|
||||
#include "x11/gdkx.h"
|
||||
|
||||
static void
|
||||
virtualscreen_close (GtkWidget * widget)
|
||||
{
|
||||
GtkWidget **window = get_cached_pointer (widget, "do_virtualscreen");
|
||||
if (window)
|
||||
{
|
||||
gint j = gdk_screen_get_num_monitors (gtk_widget_get_screen (widget));
|
||||
j--;
|
||||
cache_pointer (widget, "do_virtualscreen", NULL);
|
||||
while (j >= 0)
|
||||
{
|
||||
if (window[j])
|
||||
{
|
||||
gtk_widget_destroy (window[j]);
|
||||
window[j] = NULL;
|
||||
}
|
||||
j--;
|
||||
}
|
||||
if (window)
|
||||
g_free (window);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
virtualscreen_request (GtkWidget * widget,
|
||||
GdkEventMotion * event, gpointer user_data)
|
||||
{
|
||||
|
||||
gchar *str = g_new0 (gchar, 300);
|
||||
GdkScreen *screen = gtk_widget_get_screen (widget);
|
||||
|
||||
gint i = gdk_screen_get_monitor_num_at_window
|
||||
(screen, GDK_WINDOW_XWINDOW (widget->window));
|
||||
|
||||
GdkRectangle *monitor = gdk_screen_get_monitor_geometry (screen, i);
|
||||
|
||||
sprintf (str, "<big><span foreground=\"white\" background=\"black\">"
|
||||
"Screen %d of %d</span></big>\n"
|
||||
"<i>Width - Height </i>: (%d,%d)\n"
|
||||
"<i>Top left coordinate </i>: (%d,%d)", i + 1,
|
||||
gdk_screen_get_num_monitors (screen),
|
||||
monitor->width, monitor->height, monitor->x, monitor->y);
|
||||
gtk_label_set_markup (GTK_LABEL (user_data), str);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_virtualscreen (GtkWidget * do_widget)
|
||||
{
|
||||
GtkWidget *label, *vbox, *button;
|
||||
GdkScreen *screen;
|
||||
gint num_monitors;
|
||||
gint i;
|
||||
GtkWidget **window = get_cached_pointer (do_widget, "do_virtualscreen");
|
||||
|
||||
screen = gtk_widget_get_screen (do_widget);
|
||||
|
||||
if (!gdk_screen_use_virtual_screen (screen))
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
GtkWidget *w = gtk_widget_get_toplevel (do_widget);
|
||||
|
||||
dialog = gtk_message_dialog_new (GTK_WINDOW (w),
|
||||
GTK_DIALOG_MODAL,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"The current display is not "
|
||||
"supporting Virtual screen Mode");
|
||||
|
||||
g_signal_connect (dialog, "response",
|
||||
G_CALLBACK (gtk_widget_destroy), NULL);
|
||||
gtk_widget_show (dialog);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
num_monitors = gdk_screen_get_num_monitors (screen);
|
||||
|
||||
if (num_monitors == 1)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
GtkWidget *w = gtk_widget_get_toplevel (do_widget);
|
||||
|
||||
dialog = gtk_message_dialog_new (GTK_WINDOW (w),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"The current display is supporting "
|
||||
"Virtual screen Mode but has only "
|
||||
"one monitor, Strange...");
|
||||
|
||||
g_signal_connect (dialog, "response",
|
||||
G_CALLBACK (gtk_widget_destroy), NULL);
|
||||
gtk_widget_show (dialog);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
if (!window)
|
||||
{
|
||||
window = g_new (GtkWidget *, num_monitors);
|
||||
cache_pointer (do_widget, "do_virtualscreen", window);
|
||||
|
||||
for (i = 0; i < num_monitors; i++)
|
||||
{
|
||||
gchar str[300];
|
||||
|
||||
GdkRectangle *monitor = gdk_screen_get_monitor_geometry (screen, i);
|
||||
|
||||
window[i] = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_screen (GTK_WINDOW (window [i]), screen);
|
||||
|
||||
gtk_window_set_default_size (GTK_WINDOW (window[i]), 200, 200);
|
||||
gtk_window_move (GTK_WINDOW (window[i]),
|
||||
(monitor->width - 200) / 2 + monitor->x,
|
||||
(monitor->height - 200) / 2 + monitor->y);
|
||||
|
||||
label = gtk_label_new (NULL);
|
||||
sprintf (str,
|
||||
"<big><span foreground=\"white\" background=\"black\">"
|
||||
"Screen %d of %d</span></big>\n"
|
||||
"<i>Width - Height </i>: (%d,%d)\n"
|
||||
"<i>Top left coordinate </i>: (%d,%d)", i + 1,
|
||||
num_monitors, monitor->width, monitor->height, monitor->x,
|
||||
monitor->y);
|
||||
gtk_label_set_markup (GTK_LABEL (label), str);
|
||||
button = gtk_button_new_with_label ("Close");
|
||||
g_signal_connect (G_OBJECT (button), "clicked",
|
||||
G_CALLBACK (virtualscreen_close), NULL);
|
||||
/* check if the window is not a different monitor */
|
||||
g_signal_connect (G_OBJECT (window[i]), "configure-event",
|
||||
G_CALLBACK (virtualscreen_request), label);
|
||||
g_signal_connect (G_OBJECT (window[i]), "destroy",
|
||||
G_CALLBACK (virtualscreen_close), NULL);
|
||||
|
||||
vbox = gtk_vbox_new (TRUE, 1);
|
||||
gtk_container_add (GTK_CONTAINER (window[i]), vbox);
|
||||
gtk_container_add (GTK_CONTAINER (vbox), label);
|
||||
gtk_container_add (GTK_CONTAINER (vbox), button);
|
||||
gtk_widget_show_all (window[i]);
|
||||
}
|
||||
return window[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
virtualscreen_close (do_widget);
|
||||
return NULL;
|
||||
}
|
||||
}
|
@@ -138,17 +138,17 @@ timeout (gpointer data)
|
||||
GdkRectangle r1, r2, dest;
|
||||
double k;
|
||||
|
||||
ang = 2.0 * M_PI * (double) i / N_IMAGES - f * 2.0 * M_PI;
|
||||
ang = 2.0 * G_PI * (double) i / N_IMAGES - f * 2.0 * G_PI;
|
||||
|
||||
iw = gdk_pixbuf_get_width (images[i]);
|
||||
ih = gdk_pixbuf_get_height (images[i]);
|
||||
|
||||
r = radius + (radius / 3.0) * sin (f * 2.0 * M_PI);
|
||||
r = radius + (radius / 3.0) * sin (f * 2.0 * G_PI);
|
||||
|
||||
xpos = floor (xmid + r * cos (ang) - iw / 2.0 + 0.5);
|
||||
ypos = floor (ymid + r * sin (ang) - ih / 2.0 + 0.5);
|
||||
|
||||
k = (i & 1) ? sin (f * 2.0 * M_PI) : cos (f * 2.0 * M_PI);
|
||||
k = (i & 1) ? sin (f * 2.0 * G_PI) : cos (f * 2.0 * G_PI);
|
||||
k = 2.0 * k * k;
|
||||
k = MAX (0.25, k);
|
||||
|
||||
@@ -171,8 +171,8 @@ timeout (gpointer data)
|
||||
k, k,
|
||||
GDK_INTERP_NEAREST,
|
||||
((i & 1)
|
||||
? MAX (127, fabs (255 * sin (f * 2.0 * M_PI)))
|
||||
: MAX (127, fabs (255 * cos (f * 2.0 * M_PI)))));
|
||||
? MAX (127, fabs (255 * sin (f * 2.0 * G_PI)))
|
||||
: MAX (127, fabs (255 * cos (f * 2.0 * G_PI)))));
|
||||
}
|
||||
|
||||
gtk_widget_queue_draw (da);
|
||||
@@ -202,7 +202,6 @@ main (int argc, char **argv)
|
||||
|
||||
pixbuf_init ();
|
||||
gtk_init (&argc, &argv);
|
||||
gdk_rgb_init ();
|
||||
|
||||
if (!load_pixbufs ()) {
|
||||
g_message ("main(): Could not load all the pixbufs!");
|
||||
@@ -212,16 +211,17 @@ main (int argc, char **argv)
|
||||
frame = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, back_width, back_height);
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_widget_set_usize (window, back_width, back_height);
|
||||
gtk_window_set_policy (GTK_WINDOW (window), FALSE, FALSE, FALSE);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (window), "destroy",
|
||||
GTK_SIGNAL_FUNC (destroy_cb), NULL);
|
||||
gtk_widget_set_size_request (window, back_width, back_height);
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
|
||||
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (destroy_cb), NULL);
|
||||
|
||||
da = gtk_drawing_area_new ();
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (da), "expose_event",
|
||||
GTK_SIGNAL_FUNC (expose_cb), NULL);
|
||||
g_signal_connect (da, "expose_event",
|
||||
G_CALLBACK (expose_cb), NULL);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (window), da);
|
||||
|
||||
|
@@ -14,6 +14,6 @@ file_exists (const char *filename)
|
||||
void
|
||||
pixbuf_init ()
|
||||
{
|
||||
if (file_exists ("../gdk-pixbuf/.libs/libpixbufloader-pnm.so"))
|
||||
putenv ("GDK_PIXBUF_MODULEDIR=../gdk-pixbuf/.libs");
|
||||
if (file_exists ("../gdk-pixbuf/libpixbufloader-pnm.la"))
|
||||
putenv ("GDK_PIXBUF_MODULEDIR=../gdk-pixbuf");
|
||||
}
|
||||
|
@@ -160,10 +160,8 @@ progressive_timeout (gpointer data)
|
||||
"Failure reading image file 'alphatest.png': %s",
|
||||
g_strerror (errno));
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (dialog),
|
||||
"response",
|
||||
GTK_SIGNAL_FUNC (gtk_widget_destroy),
|
||||
NULL);
|
||||
g_signal_connect (dialog, "response",
|
||||
G_CALLBACK (gtk_widget_destroy), NULL);
|
||||
|
||||
fclose (lc->image_stream);
|
||||
lc->image_stream = NULL;
|
||||
@@ -190,10 +188,8 @@ progressive_timeout (gpointer data)
|
||||
|
||||
g_error_free (error);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (dialog),
|
||||
"response",
|
||||
GTK_SIGNAL_FUNC (gtk_widget_destroy),
|
||||
NULL);
|
||||
g_signal_connect (dialog, "response",
|
||||
G_CALLBACK (gtk_widget_destroy), NULL);
|
||||
|
||||
fclose (lc->image_stream);
|
||||
lc->image_stream = NULL;
|
||||
@@ -229,10 +225,8 @@ progressive_timeout (gpointer data)
|
||||
|
||||
g_error_free (error);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (dialog),
|
||||
"response",
|
||||
GTK_SIGNAL_FUNC (gtk_widget_destroy),
|
||||
NULL);
|
||||
g_signal_connect (dialog, "response",
|
||||
G_CALLBACK (gtk_widget_destroy), NULL);
|
||||
|
||||
gtk_widget_show (dialog);
|
||||
|
||||
@@ -264,10 +258,8 @@ progressive_timeout (gpointer data)
|
||||
lc->filename,
|
||||
g_strerror (errno));
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (dialog),
|
||||
"response",
|
||||
GTK_SIGNAL_FUNC (gtk_widget_destroy),
|
||||
NULL);
|
||||
g_signal_connect (dialog, "response",
|
||||
G_CALLBACK (gtk_widget_destroy), NULL);
|
||||
|
||||
gtk_widget_show (dialog);
|
||||
|
||||
@@ -285,17 +277,10 @@ progressive_timeout (gpointer data)
|
||||
|
||||
lc->pixbuf_loader = gdk_pixbuf_loader_new ();
|
||||
|
||||
g_signal_connect_data (G_OBJECT (lc->pixbuf_loader),
|
||||
"area_prepared",
|
||||
G_CALLBACK (progressive_prepared_callback),
|
||||
image,
|
||||
NULL, FALSE, FALSE);
|
||||
|
||||
g_signal_connect_data (G_OBJECT (lc->pixbuf_loader),
|
||||
"area_updated",
|
||||
G_CALLBACK (progressive_updated_callback),
|
||||
image,
|
||||
NULL, FALSE, FALSE);
|
||||
g_signal_connect (lc->pixbuf_loader, "area_prepared",
|
||||
G_CALLBACK (progressive_prepared_callback), image);
|
||||
g_signal_connect (lc->pixbuf_loader, "area_updated",
|
||||
G_CALLBACK (progressive_updated_callback), image);
|
||||
}
|
||||
|
||||
/* leave timeout installed */
|
||||
|
@@ -1,392 +0,0 @@
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <demos.h>
|
||||
|
||||
static GtkTextBuffer *info_buffer;
|
||||
static GtkTextBuffer *source_buffer;
|
||||
|
||||
static gchar *current_file = NULL;
|
||||
|
||||
enum {
|
||||
TITLE_COLUMN,
|
||||
FILENAME_COLUMN,
|
||||
FUNC_COLUMN,
|
||||
ITALIC_COLUMN,
|
||||
NUM_COLUMNS
|
||||
};
|
||||
|
||||
gboolean
|
||||
read_line (FILE *stream, GString *str)
|
||||
{
|
||||
int n_read = 0;
|
||||
|
||||
flockfile (stream);
|
||||
|
||||
g_string_truncate (str, 0);
|
||||
|
||||
while (1)
|
||||
{
|
||||
int c;
|
||||
|
||||
c = getc_unlocked (stream);
|
||||
|
||||
if (c == EOF)
|
||||
goto done;
|
||||
else
|
||||
n_read++;
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case '\r':
|
||||
case '\n':
|
||||
{
|
||||
int next_c = getc_unlocked (stream);
|
||||
|
||||
if (!(next_c == EOF ||
|
||||
(c == '\r' && next_c == '\n') ||
|
||||
(c == '\n' && next_c == '\r')))
|
||||
ungetc (next_c, stream);
|
||||
|
||||
goto done;
|
||||
}
|
||||
default:
|
||||
g_string_append_c (str, c);
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
|
||||
funlockfile (stream);
|
||||
|
||||
return n_read > 0;
|
||||
}
|
||||
|
||||
void
|
||||
load_file (const gchar *filename)
|
||||
{
|
||||
FILE *file;
|
||||
GtkTextIter start, end;
|
||||
GString *buffer = g_string_new (NULL);
|
||||
int state = 0;
|
||||
gboolean in_para = 0;
|
||||
|
||||
if (current_file && !strcmp (current_file, filename))
|
||||
return;
|
||||
|
||||
g_free (current_file);
|
||||
current_file = g_strdup (filename);
|
||||
|
||||
gtk_text_buffer_get_bounds (info_buffer, &start, &end);
|
||||
gtk_text_buffer_delete (info_buffer, &start, &end);
|
||||
|
||||
gtk_text_buffer_get_bounds (source_buffer, &start, &end);
|
||||
gtk_text_buffer_delete (source_buffer, &start, &end);
|
||||
|
||||
file = fopen (filename, "r");
|
||||
if (!file)
|
||||
{
|
||||
g_warning ("Cannot open %s: %s\n", filename, g_strerror (errno));
|
||||
return;
|
||||
}
|
||||
|
||||
gtk_text_buffer_get_iter_at_offset (info_buffer, &start, 0);
|
||||
while (read_line (file, buffer))
|
||||
{
|
||||
gchar *p = buffer->str;
|
||||
gchar *q;
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case 0:
|
||||
/* Reading title */
|
||||
while (*p == '/' || *p == '*' || isspace (*p))
|
||||
p++;
|
||||
q = p + strlen (p);
|
||||
while (q > p && isspace (*(q - 1)))
|
||||
q--;
|
||||
|
||||
if (q > p)
|
||||
{
|
||||
int len_chars = g_utf8_pointer_to_offset (p, q);
|
||||
|
||||
end = start;
|
||||
|
||||
g_assert (strlen (p) >= q - p);
|
||||
gtk_text_buffer_insert (info_buffer, &end, p, q - p);
|
||||
start = end;
|
||||
|
||||
gtk_text_iter_backward_chars (&start, len_chars);
|
||||
gtk_text_buffer_apply_tag_by_name (info_buffer, "title", &start, &end);
|
||||
|
||||
start = end;
|
||||
|
||||
state++;
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
/* Reading body of info section */
|
||||
while (isspace (*p))
|
||||
p++;
|
||||
if (*p == '*' && *(p + 1) == '/')
|
||||
{
|
||||
gtk_text_buffer_get_iter_at_offset (source_buffer, &start, 0);
|
||||
state++;
|
||||
}
|
||||
else
|
||||
{
|
||||
int len;
|
||||
|
||||
while (*p == '*' || isspace (*p))
|
||||
p++;
|
||||
|
||||
len = strlen (p);
|
||||
while (isspace (*(p + len - 1)))
|
||||
len--;
|
||||
|
||||
if (len > 0)
|
||||
{
|
||||
if (in_para)
|
||||
gtk_text_buffer_insert (info_buffer, &start, " ", 1);
|
||||
|
||||
g_assert (strlen (p) >= len);
|
||||
gtk_text_buffer_insert (info_buffer, &start, p, len);
|
||||
in_para = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_text_buffer_insert (info_buffer, &start, "\n", 1);
|
||||
in_para = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
/* Skipping blank lines */
|
||||
while (isspace (*p))
|
||||
p++;
|
||||
if (*p)
|
||||
{
|
||||
p = buffer->str;
|
||||
state++;
|
||||
/* Fall through */
|
||||
}
|
||||
else
|
||||
break;
|
||||
|
||||
case 3:
|
||||
/* Reading program body */
|
||||
gtk_text_buffer_insert (source_buffer, &start, p, -1);
|
||||
gtk_text_buffer_insert (info_buffer, &start, "\n", 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
gtk_text_buffer_get_bounds (source_buffer, &start, &end);
|
||||
gtk_text_buffer_apply_tag_by_name (info_buffer, "source", &start, &end);
|
||||
}
|
||||
|
||||
gboolean
|
||||
button_press_event_cb (GtkTreeView *tree_view,
|
||||
GdkEventButton *event,
|
||||
GtkTreeModel *model)
|
||||
{
|
||||
if (event->type == GDK_2BUTTON_PRESS)
|
||||
{
|
||||
GtkTreePath *path = NULL;
|
||||
|
||||
gtk_tree_view_get_path_at_pos (tree_view,
|
||||
event->window,
|
||||
event->x,
|
||||
event->y,
|
||||
&path,
|
||||
NULL);
|
||||
|
||||
if (path)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
gboolean italic;
|
||||
GVoidFunc func;
|
||||
|
||||
gtk_tree_model_get_iter (model, &iter, path);
|
||||
gtk_tree_store_get (GTK_TREE_STORE (model),
|
||||
&iter,
|
||||
FUNC_COLUMN, &func,
|
||||
ITALIC_COLUMN, &italic,
|
||||
-1);
|
||||
(func) ();
|
||||
gtk_tree_store_set (GTK_TREE_STORE (model),
|
||||
&iter,
|
||||
ITALIC_COLUMN, !italic,
|
||||
-1);
|
||||
gtk_tree_path_free (path);
|
||||
}
|
||||
|
||||
gtk_signal_emit_stop_by_name (GTK_OBJECT (tree_view),
|
||||
"button_press_event");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
selection_cb (GtkTreeSelection *selection,
|
||||
GtkTreeModel *model)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
GValue value = {0, };
|
||||
|
||||
if (! gtk_tree_selection_get_selected (selection, NULL, &iter))
|
||||
return;
|
||||
|
||||
gtk_tree_model_get_value (model, &iter,
|
||||
FILENAME_COLUMN,
|
||||
&value);
|
||||
load_file (g_value_get_string (&value));
|
||||
g_value_unset (&value);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
create_text (GtkTextBuffer **buffer,
|
||||
gboolean is_source)
|
||||
{
|
||||
GtkWidget *scrolled_window;
|
||||
GtkWidget *text_view;
|
||||
PangoFontDescription *font_desc;
|
||||
|
||||
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
|
||||
GTK_SHADOW_IN);
|
||||
|
||||
text_view = gtk_text_view_new ();
|
||||
gtk_container_add (GTK_CONTAINER (scrolled_window), text_view);
|
||||
|
||||
*buffer = gtk_text_buffer_new (NULL);
|
||||
gtk_text_view_set_buffer (GTK_TEXT_VIEW (text_view), *buffer);
|
||||
gtk_text_view_set_editable (GTK_TEXT_VIEW (text_view), FALSE);
|
||||
gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (text_view), FALSE);
|
||||
|
||||
if (is_source)
|
||||
{
|
||||
font_desc = pango_font_description_from_string ("Courier 10");
|
||||
gtk_widget_modify_font (text_view, font_desc);
|
||||
pango_font_description_free (font_desc);
|
||||
}
|
||||
|
||||
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (text_view), !is_source);
|
||||
|
||||
return scrolled_window;
|
||||
}
|
||||
|
||||
/* Technically a list, but if we do go to 80 demos, we may want to move to a tree */
|
||||
static GtkWidget *
|
||||
create_tree (void)
|
||||
{
|
||||
GtkTreeSelection *selection;
|
||||
GtkCellRenderer *cell;
|
||||
GtkWidget *tree_view;
|
||||
GtkTreeViewColumn *column;
|
||||
GtkTreeStore *model;
|
||||
GtkTreeIter iter;
|
||||
gint i;
|
||||
|
||||
model = gtk_tree_store_new_with_types (NUM_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_BOOLEAN);
|
||||
tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
|
||||
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
|
||||
|
||||
gtk_tree_selection_set_type (GTK_TREE_SELECTION (selection),
|
||||
GTK_TREE_SELECTION_SINGLE);
|
||||
gtk_widget_set_usize (tree_view, 200, -1);
|
||||
|
||||
for (i=0; i < G_N_ELEMENTS (testgtk_demos); i++)
|
||||
{
|
||||
gtk_tree_store_append (GTK_TREE_STORE (model), &iter, NULL);
|
||||
|
||||
gtk_tree_store_set (GTK_TREE_STORE (model),
|
||||
&iter,
|
||||
TITLE_COLUMN, testgtk_demos[i].title,
|
||||
FILENAME_COLUMN, testgtk_demos[i].filename,
|
||||
FUNC_COLUMN, testgtk_demos[i].func,
|
||||
ITALIC_COLUMN, FALSE,
|
||||
-1);
|
||||
}
|
||||
|
||||
cell = gtk_cell_renderer_text_new ();
|
||||
column = gtk_tree_view_column_new_with_attributes ("Widget",
|
||||
cell,
|
||||
"text", TITLE_COLUMN,
|
||||
"italic", ITALIC_COLUMN,
|
||||
NULL);
|
||||
gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view),
|
||||
GTK_TREE_VIEW_COLUMN (column));
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (selection), "selection_changed", selection_cb, model);
|
||||
gtk_signal_connect (GTK_OBJECT (tree_view), "button_press_event", GTK_SIGNAL_FUNC (button_press_event_cb), model);
|
||||
|
||||
return tree_view;
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
GtkWidget *window;
|
||||
GtkWidget *notebook;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *tree;
|
||||
GtkTextTag *tag;
|
||||
|
||||
gtk_init (&argc, &argv);
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_signal_connect (GTK_OBJECT (window), "destroy",
|
||||
GTK_SIGNAL_FUNC (gtk_main_quit), NULL);
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 0);
|
||||
gtk_container_add (GTK_CONTAINER (window), hbox);
|
||||
|
||||
tree = create_tree ();
|
||||
gtk_box_pack_start (GTK_BOX (hbox), tree, FALSE, FALSE, 0);
|
||||
|
||||
notebook = gtk_notebook_new ();
|
||||
gtk_box_pack_start (GTK_BOX (hbox), notebook, TRUE, TRUE, 0);
|
||||
|
||||
gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
|
||||
create_text (&info_buffer, FALSE),
|
||||
gtk_label_new ("Info"));
|
||||
|
||||
|
||||
gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
|
||||
create_text (&source_buffer, TRUE),
|
||||
gtk_label_new ("Source"));
|
||||
|
||||
tag = gtk_text_buffer_create_tag (info_buffer, "title");
|
||||
gtk_object_set (GTK_OBJECT (tag),
|
||||
"font", "Sans 18",
|
||||
NULL);
|
||||
|
||||
tag = gtk_text_buffer_create_tag (info_buffer, "source");
|
||||
gtk_object_set (GTK_OBJECT (tag),
|
||||
"font", "Courier 10",
|
||||
"pixels_above_lines", 0,
|
||||
"pixels_below_lines", 0,
|
||||
NULL);
|
||||
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);
|
||||
gtk_widget_show_all (window);
|
||||
|
||||
|
||||
load_file (testgtk_demos[0].filename);
|
||||
|
||||
gtk_main ();
|
||||
|
||||
return 0;
|
||||
}
|
@@ -1,80 +1,75 @@
|
||||
#include <config.h>
|
||||
#include <gtk/gtk.h>
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
#include <gdk/x11/gdkx.h>
|
||||
#elif defined (GDK_WINDOWING_WIN32)
|
||||
#include <gdk/win32/gdkwin32.h>
|
||||
#elif defined (GDK_WINDOWING_FB)
|
||||
#include <gdk/linux-fb/gdkfb.h>
|
||||
#endif
|
||||
|
||||
int close_app(GtkWidget *widget, gpointer data)
|
||||
int
|
||||
close_app (GtkWidget *widget, gpointer data)
|
||||
{
|
||||
gtk_main_quit();
|
||||
gtk_main_quit ();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int expose_cb(GtkWidget *drawing_area, GdkEventExpose *evt, gpointer data)
|
||||
int
|
||||
expose_cb (GtkWidget *drawing_area, GdkEventExpose *evt, gpointer data)
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
|
||||
pixbuf = (GdkPixbuf *) gtk_object_get_data(GTK_OBJECT(drawing_area),
|
||||
"pixbuf");
|
||||
if(gdk_pixbuf_get_has_alpha (pixbuf))
|
||||
pixbuf = (GdkPixbuf *) g_object_get_data (G_OBJECT (drawing_area), "pixbuf");
|
||||
if (gdk_pixbuf_get_has_alpha (pixbuf))
|
||||
{
|
||||
gdk_draw_rgb_32_image(drawing_area->window,
|
||||
drawing_area->style->black_gc,
|
||||
evt->area.x, evt->area.y,
|
||||
evt->area.width,
|
||||
evt->area.height,
|
||||
GDK_RGB_DITHER_MAX,
|
||||
gdk_pixbuf_get_pixels (pixbuf) +
|
||||
(evt->area.y * gdk_pixbuf_get_rowstride (pixbuf)) +
|
||||
(evt->area.x * gdk_pixbuf_get_n_channels (pixbuf)),
|
||||
gdk_pixbuf_get_rowstride (pixbuf));
|
||||
gdk_draw_rgb_32_image (drawing_area->window,
|
||||
drawing_area->style->black_gc,
|
||||
evt->area.x, evt->area.y,
|
||||
evt->area.width,
|
||||
evt->area.height,
|
||||
GDK_RGB_DITHER_MAX,
|
||||
gdk_pixbuf_get_pixels (pixbuf) +
|
||||
(evt->area.y * gdk_pixbuf_get_rowstride (pixbuf)) +
|
||||
(evt->area.x * gdk_pixbuf_get_n_channels (pixbuf)),
|
||||
gdk_pixbuf_get_rowstride (pixbuf));
|
||||
}
|
||||
else
|
||||
{
|
||||
gdk_draw_rgb_image(drawing_area->window,
|
||||
drawing_area->style->black_gc,
|
||||
evt->area.x, evt->area.y,
|
||||
evt->area.width,
|
||||
evt->area.height,
|
||||
GDK_RGB_DITHER_NORMAL,
|
||||
gdk_pixbuf_get_pixels (pixbuf) +
|
||||
(evt->area.y * gdk_pixbuf_get_rowstride (pixbuf)) +
|
||||
(evt->area.x * gdk_pixbuf_get_n_channels (pixbuf)),
|
||||
gdk_pixbuf_get_rowstride (pixbuf));
|
||||
gdk_draw_rgb_image (drawing_area->window,
|
||||
drawing_area->style->black_gc,
|
||||
evt->area.x, evt->area.y,
|
||||
evt->area.width,
|
||||
evt->area.height,
|
||||
GDK_RGB_DITHER_NORMAL,
|
||||
gdk_pixbuf_get_pixels (pixbuf) +
|
||||
(evt->area.y * gdk_pixbuf_get_rowstride (pixbuf)) +
|
||||
(evt->area.x * gdk_pixbuf_get_n_channels (pixbuf)),
|
||||
gdk_pixbuf_get_rowstride (pixbuf));
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int configure_cb(GtkWidget *drawing_area, GdkEventConfigure *evt, gpointer data)
|
||||
int
|
||||
configure_cb (GtkWidget *drawing_area, GdkEventConfigure *evt, gpointer data)
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
|
||||
pixbuf = (GdkPixbuf *) gtk_object_get_data(GTK_OBJECT(drawing_area),
|
||||
"pixbuf");
|
||||
pixbuf = (GdkPixbuf *) g_object_get_data (G_OBJECT (drawing_area), "pixbuf");
|
||||
|
||||
g_print("X:%d Y:%d\n", evt->width, evt->height);
|
||||
if(evt->width != gdk_pixbuf_get_width (pixbuf) || evt->height != gdk_pixbuf_get_height (pixbuf))
|
||||
g_print ("X:%d Y:%d\n", evt->width, evt->height);
|
||||
if (evt->width != gdk_pixbuf_get_width (pixbuf) || evt->height != gdk_pixbuf_get_height (pixbuf))
|
||||
{
|
||||
GdkWindow *root;
|
||||
GdkPixbuf *new_pixbuf;
|
||||
|
||||
root = GDK_ROOT_PARENT();
|
||||
new_pixbuf = gdk_pixbuf_get_from_drawable(NULL, root, NULL,
|
||||
0, 0, 0, 0, evt->width, evt->height);
|
||||
gtk_object_set_data(GTK_OBJECT(drawing_area), "pixbuf", new_pixbuf);
|
||||
gdk_pixbuf_unref(pixbuf);
|
||||
root = gdk_get_default_root_window ();
|
||||
new_pixbuf = gdk_pixbuf_get_from_drawable (NULL, root, NULL,
|
||||
0, 0, 0, 0, evt->width, evt->height);
|
||||
g_object_set_data (G_OBJECT (drawing_area), "pixbuf", new_pixbuf);
|
||||
g_object_unref (pixbuf);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
extern void pixbuf_init();
|
||||
extern void pixbuf_init ();
|
||||
|
||||
int main(int argc, char **argv)
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
GdkWindow *root;
|
||||
GtkWidget *window;
|
||||
@@ -84,38 +79,38 @@ int main(int argc, char **argv)
|
||||
|
||||
pixbuf_init ();
|
||||
|
||||
gtk_init(&argc, &argv);
|
||||
gdk_rgb_set_verbose(TRUE);
|
||||
gdk_rgb_init();
|
||||
gtk_init (&argc, &argv);
|
||||
gdk_rgb_set_verbose (TRUE);
|
||||
|
||||
gtk_widget_set_default_colormap(gdk_rgb_get_cmap());
|
||||
gtk_widget_set_default_colormap(
|
||||
gdk_rgb_get_colormap_for_screen (gdk_get_default_screen ()));
|
||||
|
||||
root = GDK_ROOT_PARENT();
|
||||
pixbuf = gdk_pixbuf_get_from_drawable(NULL, root, NULL,
|
||||
0, 0, 0, 0, 150, 160);
|
||||
root = gdk_get_default_root_window ();
|
||||
pixbuf = gdk_pixbuf_get_from_drawable (NULL, root, NULL,
|
||||
0, 0, 0, 0, 150, 160);
|
||||
|
||||
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
gtk_signal_connect(GTK_OBJECT(window), "delete_event",
|
||||
GTK_SIGNAL_FUNC(close_app), NULL);
|
||||
gtk_signal_connect(GTK_OBJECT(window), "destroy",
|
||||
GTK_SIGNAL_FUNC(close_app), NULL);
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
g_signal_connect (window, "delete_event",
|
||||
G_CALLBACK (close_app), NULL);
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (close_app), NULL);
|
||||
|
||||
vbox = gtk_vbox_new(FALSE, 0);
|
||||
gtk_container_add(GTK_CONTAINER(window), vbox);
|
||||
vbox = gtk_vbox_new (FALSE, 0);
|
||||
gtk_container_add (GTK_CONTAINER (window), vbox);
|
||||
|
||||
drawing_area = gtk_drawing_area_new();
|
||||
gtk_widget_set_usize(GTK_WIDGET(drawing_area),
|
||||
gdk_pixbuf_get_width (pixbuf),
|
||||
gdk_pixbuf_get_height (pixbuf));
|
||||
gtk_signal_connect(GTK_OBJECT(drawing_area), "expose_event",
|
||||
GTK_SIGNAL_FUNC(expose_cb), NULL);
|
||||
drawing_area = gtk_drawing_area_new ();
|
||||
gtk_widget_set_size_request (GTK_WIDGET (drawing_area),
|
||||
gdk_pixbuf_get_width (pixbuf),
|
||||
gdk_pixbuf_get_height (pixbuf));
|
||||
g_signal_connect (drawing_area, "expose_event",
|
||||
G_CALLBACK (expose_cb), NULL);
|
||||
|
||||
gtk_signal_connect(GTK_OBJECT(drawing_area), "configure_event",
|
||||
GTK_SIGNAL_FUNC(configure_cb), NULL);
|
||||
gtk_object_set_data(GTK_OBJECT(drawing_area), "pixbuf", pixbuf);
|
||||
gtk_box_pack_start(GTK_BOX(vbox), drawing_area, TRUE, TRUE, 0);
|
||||
g_signal_connect (drawing_area, "configure_event",
|
||||
G_CALLBACK (configure_cb), NULL);
|
||||
g_object_set_data (G_OBJECT (drawing_area), "pixbuf", pixbuf);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), drawing_area, TRUE, TRUE, 0);
|
||||
|
||||
gtk_widget_show_all(window);
|
||||
gtk_main();
|
||||
gtk_widget_show_all (window);
|
||||
gtk_main ();
|
||||
return 0;
|
||||
}
|
||||
|
@@ -1,26 +1,81 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdkscreen.h>
|
||||
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
#include <gdk/x11/gdkx.h>
|
||||
#elif defined (GDK_WINDOWING_WIN32)
|
||||
#include <gdk/win32/gdkwin32.h>
|
||||
#elif defined (GDK_WINDOWING_FB)
|
||||
#include <gdk/linux-fb/gdkfb.h>
|
||||
#endif
|
||||
static void
|
||||
compare_pixbufs (GdkPixbuf *pixbuf, GdkPixbuf *compare, const gchar *file_type)
|
||||
{
|
||||
if ((gdk_pixbuf_get_width (pixbuf) !=
|
||||
gdk_pixbuf_get_width (compare)) ||
|
||||
(gdk_pixbuf_get_height (pixbuf) !=
|
||||
gdk_pixbuf_get_height (compare)) ||
|
||||
(gdk_pixbuf_get_n_channels (pixbuf) !=
|
||||
gdk_pixbuf_get_n_channels (compare)) ||
|
||||
(gdk_pixbuf_get_has_alpha (pixbuf) !=
|
||||
gdk_pixbuf_get_has_alpha (compare)) ||
|
||||
(gdk_pixbuf_get_bits_per_sample (pixbuf) !=
|
||||
gdk_pixbuf_get_bits_per_sample (compare))) {
|
||||
fprintf (stderr,
|
||||
"saved %s file differs from copy in memory\n",
|
||||
file_type);
|
||||
} else {
|
||||
guchar *orig_pixels;
|
||||
guchar *compare_pixels;
|
||||
gint orig_rowstride;
|
||||
gint compare_rowstride;
|
||||
gint width;
|
||||
gint height;
|
||||
gint bytes_per_pixel;
|
||||
gint x, y;
|
||||
guchar *p1, *p2;
|
||||
gint count = 0;
|
||||
|
||||
orig_pixels = gdk_pixbuf_get_pixels (pixbuf);
|
||||
compare_pixels = gdk_pixbuf_get_pixels (compare);
|
||||
|
||||
void
|
||||
orig_rowstride = gdk_pixbuf_get_rowstride (pixbuf);
|
||||
compare_rowstride = gdk_pixbuf_get_rowstride (compare);
|
||||
|
||||
width = gdk_pixbuf_get_width (pixbuf);
|
||||
height = gdk_pixbuf_get_height (pixbuf);
|
||||
|
||||
/* well... */
|
||||
bytes_per_pixel = gdk_pixbuf_get_n_channels (pixbuf);
|
||||
|
||||
p1 = orig_pixels;
|
||||
p2 = compare_pixels;
|
||||
|
||||
for (y = 0; y < height; y++) {
|
||||
for (x = 0; x < width * bytes_per_pixel; x++)
|
||||
count += (*p1++ != *p2++);
|
||||
|
||||
orig_pixels += orig_rowstride;
|
||||
compare_pixels += compare_rowstride;
|
||||
|
||||
p1 = orig_pixels;
|
||||
p2 = compare_pixels;
|
||||
}
|
||||
|
||||
if (count > 0) {
|
||||
fprintf (stderr,
|
||||
"saved %s file differs from copy in memory\n",
|
||||
file_type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
keypress_check (GtkWidget *widget, GdkEventKey *evt, gpointer data)
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
GtkDrawingArea *da = (GtkDrawingArea*)data;
|
||||
GError *err = NULL;
|
||||
|
||||
pixbuf = (GdkPixbuf *) gtk_object_get_data (GTK_OBJECT (da), "pixbuf");
|
||||
pixbuf = (GdkPixbuf *) g_object_get_data (G_OBJECT (da), "pixbuf");
|
||||
|
||||
if (evt->keyval == 'q')
|
||||
gtk_main_quit ();
|
||||
@@ -36,36 +91,78 @@ keypress_check (GtkWidget *widget, GdkEventKey *evt, gpointer data)
|
||||
NULL)) {
|
||||
fprintf (stderr, "%s", err->message);
|
||||
g_error_free (err);
|
||||
} else {
|
||||
GdkPixbuf *compare;
|
||||
|
||||
compare = gdk_pixbuf_new_from_file ("foo.jpg", &err);
|
||||
|
||||
if (!compare) {
|
||||
fprintf (stderr, "%s", err->message);
|
||||
g_error_free (err);
|
||||
} else {
|
||||
compare_pixbufs (pixbuf, compare, "jpeg");
|
||||
g_object_unref (G_OBJECT (compare));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else if (evt->keyval == 'p') {
|
||||
if (pixbuf == NULL) {
|
||||
fprintf (stderr, "PIXBUF NULL\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!gdk_pixbuf_save (pixbuf, "foo.png", "png", &err, NULL)) {
|
||||
if (!gdk_pixbuf_save (pixbuf, "foo.png", "png",
|
||||
&err,
|
||||
"tEXt::Software", "testpixbuf-save",
|
||||
NULL)) {
|
||||
fprintf (stderr, "%s", err->message);
|
||||
g_error_free (err);
|
||||
} else {
|
||||
GdkPixbuf *compare;
|
||||
|
||||
compare = gdk_pixbuf_new_from_file ("foo.png", &err);
|
||||
|
||||
if (!compare) {
|
||||
fprintf (stderr, "%s", err->message);
|
||||
g_error_free (err);
|
||||
} else {
|
||||
compare_pixbufs (pixbuf, compare, "png");
|
||||
g_object_unref (G_OBJECT (compare));
|
||||
}
|
||||
|
||||
}
|
||||
} else if (evt->keyval == 'a') {
|
||||
if (pixbuf == NULL) {
|
||||
fprintf (stderr, "PIXBUF NULL\n");
|
||||
return;
|
||||
} else {
|
||||
GdkPixbuf *alpha_buf;
|
||||
|
||||
alpha_buf = gdk_pixbuf_add_alpha (pixbuf,
|
||||
FALSE, 0, 0, 0);
|
||||
|
||||
g_object_set_data_full (G_OBJECT (da),
|
||||
"pixbuf", alpha_buf,
|
||||
(GDestroyNotify) g_object_unref);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
static int
|
||||
close_app (GtkWidget *widget, gpointer data)
|
||||
{
|
||||
gtk_main_quit ();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
expose_cb (GtkWidget *drawing_area, GdkEventExpose *evt, gpointer data)
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
|
||||
pixbuf = (GdkPixbuf *) gtk_object_get_data (GTK_OBJECT (drawing_area),
|
||||
"pixbuf");
|
||||
pixbuf = (GdkPixbuf *) g_object_get_data (G_OBJECT (drawing_area),
|
||||
"pixbuf");
|
||||
if (gdk_pixbuf_get_has_alpha (pixbuf)) {
|
||||
gdk_draw_rgb_32_image (drawing_area->window,
|
||||
drawing_area->style->black_gc,
|
||||
@@ -92,24 +189,24 @@ expose_cb (GtkWidget *drawing_area, GdkEventExpose *evt, gpointer data)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
configure_cb (GtkWidget *drawing_area, GdkEventConfigure *evt, gpointer data)
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
|
||||
pixbuf = (GdkPixbuf *) gtk_object_get_data (GTK_OBJECT (drawing_area),
|
||||
"pixbuf");
|
||||
pixbuf = (GdkPixbuf *) g_object_get_data (G_OBJECT (drawing_area),
|
||||
"pixbuf");
|
||||
|
||||
g_print ("X:%d Y:%d\n", evt->width, evt->height);
|
||||
if (evt->width != gdk_pixbuf_get_width (pixbuf) || evt->height != gdk_pixbuf_get_height (pixbuf)) {
|
||||
GdkWindow *root;
|
||||
GdkPixbuf *new_pixbuf;
|
||||
|
||||
root = GDK_ROOT_PARENT ();
|
||||
root = gdk_screen_get_root_window (gtk_widget_get_screen (drawing_area));
|
||||
new_pixbuf = gdk_pixbuf_get_from_drawable (NULL, root, NULL,
|
||||
0, 0, 0, 0, evt->width, evt->height);
|
||||
gtk_object_set_data (GTK_OBJECT (drawing_area), "pixbuf", new_pixbuf);
|
||||
gdk_pixbuf_unref (pixbuf);
|
||||
g_object_set_data_full (G_OBJECT (drawing_area), "pixbuf", new_pixbuf,
|
||||
(GDestroyNotify) g_object_unref);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
@@ -126,33 +223,35 @@ main (int argc, char **argv)
|
||||
|
||||
gtk_init (&argc, &argv);
|
||||
|
||||
gtk_widget_set_default_colormap (gdk_rgb_get_cmap ());
|
||||
gtk_widget_set_default_colormap (
|
||||
gdk_rgb_get_colormap_for_screen (gdk_get_default_screen ()));
|
||||
|
||||
root = GDK_ROOT_PARENT ();
|
||||
root = gdk_screen_get_root_window (gdk_get_default_screen ());
|
||||
pixbuf = gdk_pixbuf_get_from_drawable (NULL, root, NULL,
|
||||
0, 0, 0, 0, 150, 160);
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_signal_connect (GTK_OBJECT (window), "delete_event",
|
||||
GTK_SIGNAL_FUNC (close_app), NULL);
|
||||
gtk_signal_connect (GTK_OBJECT (window), "destroy",
|
||||
GTK_SIGNAL_FUNC (close_app), NULL);
|
||||
g_signal_connect (window, "delete_event",
|
||||
G_CALLBACK (close_app), NULL);
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (close_app), NULL);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 0);
|
||||
gtk_container_add (GTK_CONTAINER (window), vbox);
|
||||
|
||||
drawing_area = gtk_drawing_area_new ();
|
||||
gtk_widget_set_usize (GTK_WIDGET (drawing_area),
|
||||
gdk_pixbuf_get_width (pixbuf),
|
||||
gdk_pixbuf_get_height (pixbuf));
|
||||
gtk_signal_connect (GTK_OBJECT (drawing_area), "expose_event",
|
||||
GTK_SIGNAL_FUNC (expose_cb), NULL);
|
||||
gtk_widget_set_size_request (GTK_WIDGET (drawing_area),
|
||||
gdk_pixbuf_get_width (pixbuf),
|
||||
gdk_pixbuf_get_height (pixbuf));
|
||||
g_signal_connect (drawing_area, "expose_event",
|
||||
G_CALLBACK (expose_cb), NULL);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (drawing_area), "configure_event",
|
||||
GTK_SIGNAL_FUNC (configure_cb), NULL);
|
||||
gtk_signal_connect (GTK_OBJECT (window), "key_press_event",
|
||||
GTK_SIGNAL_FUNC (keypress_check), drawing_area);
|
||||
gtk_object_set_data (GTK_OBJECT (drawing_area), "pixbuf", pixbuf);
|
||||
g_signal_connect (drawing_area, "configure_event",
|
||||
G_CALLBACK (configure_cb), NULL);
|
||||
g_signal_connect (window, "key_press_event",
|
||||
G_CALLBACK (keypress_check), drawing_area);
|
||||
g_object_set_data_full (G_OBJECT (drawing_area), "pixbuf", pixbuf,
|
||||
(GDestroyNotify) g_object_unref);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), drawing_area, TRUE, TRUE, 0);
|
||||
|
||||
gtk_widget_show_all (window);
|
||||
|
@@ -1,6 +1,7 @@
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
GdkInterpType interp_type = GDK_INTERP_BILINEAR;
|
||||
int overall_alpha = 255;
|
||||
@@ -46,7 +47,7 @@ expose_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data)
|
||||
event->area.width, event->area.height,
|
||||
GDK_RGB_DITHER_NORMAL, event->area.x, event->area.y);
|
||||
|
||||
gdk_pixbuf_unref (dest);
|
||||
g_object_unref (dest);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -62,12 +63,12 @@ main(int argc, char **argv)
|
||||
GtkWidget *hbox, *label, *hscale;
|
||||
GtkAdjustment *adjustment;
|
||||
GtkRequisition scratch_requisition;
|
||||
const gchar *creator;
|
||||
GError *error;
|
||||
|
||||
pixbuf_init ();
|
||||
|
||||
gtk_init (&argc, &argv);
|
||||
gdk_rgb_init ();
|
||||
|
||||
if (argc != 2) {
|
||||
fprintf (stderr, "Usage: testpixbuf-scale FILE\n");
|
||||
@@ -83,9 +84,13 @@ main(int argc, char **argv)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
creator = gdk_pixbuf_get_option (pixbuf, "tEXt::Software");
|
||||
if (creator)
|
||||
g_print ("%s was created by '%s'\n", argv[1], creator);
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_signal_connect (GTK_OBJECT (window), "destroy",
|
||||
GTK_SIGNAL_FUNC (gtk_main_quit), NULL);
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (gtk_main_quit), NULL);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 0);
|
||||
gtk_container_add (GTK_CONTAINER (window), vbox);
|
||||
@@ -93,29 +98,29 @@ main(int argc, char **argv)
|
||||
menu = gtk_menu_new ();
|
||||
|
||||
menuitem = gtk_menu_item_new_with_label ("NEAREST");
|
||||
gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
|
||||
GTK_SIGNAL_FUNC (set_interp_type),
|
||||
GUINT_TO_POINTER (GDK_INTERP_NEAREST));
|
||||
g_signal_connect (menuitem, "activate",
|
||||
G_CALLBACK (set_interp_type),
|
||||
GUINT_TO_POINTER (GDK_INTERP_NEAREST));
|
||||
gtk_widget_show (menuitem);
|
||||
gtk_container_add (GTK_CONTAINER (menu), menuitem);
|
||||
|
||||
menuitem = gtk_menu_item_new_with_label ("BILINEAR");
|
||||
gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
|
||||
GTK_SIGNAL_FUNC (set_interp_type),
|
||||
GUINT_TO_POINTER (GDK_INTERP_BILINEAR));
|
||||
g_signal_connect (menuitem, "activate",
|
||||
G_CALLBACK (set_interp_type),
|
||||
GUINT_TO_POINTER (GDK_INTERP_BILINEAR));
|
||||
gtk_widget_show (menuitem);
|
||||
gtk_container_add (GTK_CONTAINER (menu), menuitem);
|
||||
|
||||
menuitem = gtk_menu_item_new_with_label ("TILES");
|
||||
gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
|
||||
GTK_SIGNAL_FUNC (set_interp_type),
|
||||
GUINT_TO_POINTER (GDK_INTERP_TILES));
|
||||
g_signal_connect (menuitem, "activate",
|
||||
G_CALLBACK (set_interp_type),
|
||||
GUINT_TO_POINTER (GDK_INTERP_TILES));
|
||||
gtk_container_add (GTK_CONTAINER (menu), menuitem);
|
||||
|
||||
menuitem = gtk_menu_item_new_with_label ("HYPER");
|
||||
gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
|
||||
GTK_SIGNAL_FUNC (set_interp_type),
|
||||
GUINT_TO_POINTER (GDK_INTERP_HYPER));
|
||||
g_signal_connect (menuitem, "activate",
|
||||
G_CALLBACK (set_interp_type),
|
||||
GUINT_TO_POINTER (GDK_INTERP_HYPER));
|
||||
gtk_container_add (GTK_CONTAINER (menu), menuitem);
|
||||
|
||||
optionmenu = gtk_option_menu_new ();
|
||||
@@ -132,8 +137,8 @@ main(int argc, char **argv)
|
||||
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
||||
|
||||
adjustment = GTK_ADJUSTMENT (gtk_adjustment_new (overall_alpha, 0, 255, 1, 10, 0));
|
||||
gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed",
|
||||
GTK_SIGNAL_FUNC (overall_changed_cb), NULL);
|
||||
g_signal_connect (adjustment, "value_changed",
|
||||
G_CALLBACK (overall_changed_cb), NULL);
|
||||
|
||||
hscale = gtk_hscale_new (adjustment);
|
||||
gtk_scale_set_digits (GTK_SCALE (hscale), 0);
|
||||
@@ -148,8 +153,8 @@ main(int argc, char **argv)
|
||||
darea = gtk_drawing_area_new ();
|
||||
gtk_box_pack_start (GTK_BOX (vbox), darea, TRUE, TRUE, 0);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (darea), "expose_event",
|
||||
GTK_SIGNAL_FUNC (expose_cb), NULL);
|
||||
g_signal_connect (darea, "expose_event",
|
||||
G_CALLBACK (expose_cb), NULL);
|
||||
|
||||
gtk_window_set_default_size (GTK_WINDOW (window),
|
||||
gdk_pixbuf_get_width (pixbuf),
|
||||
|
@@ -318,7 +318,7 @@ expose_func (GtkWidget *drawing_area, GdkEventExpose *event, gpointer data)
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
|
||||
pixbuf = (GdkPixbuf *)gtk_object_get_data(GTK_OBJECT(drawing_area), "pixbuf");
|
||||
pixbuf = (GdkPixbuf *)g_object_get_data (G_OBJECT (drawing_area), "pixbuf");
|
||||
|
||||
if (gdk_pixbuf_get_has_alpha (pixbuf)) {
|
||||
gdk_draw_rgb_32_image (drawing_area->window,
|
||||
@@ -350,14 +350,14 @@ config_func (GtkWidget *drawing_area, GdkEventConfigure *event, gpointer data)
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
|
||||
pixbuf = (GdkPixbuf *)gtk_object_get_data(GTK_OBJECT(drawing_area), "pixbuf");
|
||||
pixbuf = (GdkPixbuf *)g_object_get_data (G_OBJECT (drawing_area), "pixbuf");
|
||||
|
||||
g_print("X:%d Y:%d\n", event->width, event->height);
|
||||
g_print ("X:%d Y:%d\n", event->width, event->height);
|
||||
|
||||
#if 0
|
||||
if (((event->width) != gdk_pixbuf_get_width (pixbuf)) ||
|
||||
((event->height) != gdk_pixbuf_get_height (pixbuf)))
|
||||
gdk_pixbuf_scale(pixbuf, event->width, event->height);
|
||||
gdk_pixbuf_scale (pixbuf, event->width, event->height);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -381,8 +381,8 @@ new_testrgb_window (GdkPixbuf *pixbuf, gchar *title)
|
||||
"GtkWindow::title", title ? title : "testrgb",
|
||||
"GtkWindow::allow_shrink", TRUE,
|
||||
NULL);
|
||||
gtk_signal_connect (GTK_OBJECT (window), "destroy",
|
||||
(GtkSignalFunc) quit_func, NULL);
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (quit_func), NULL);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 0);
|
||||
|
||||
@@ -393,25 +393,24 @@ new_testrgb_window (GdkPixbuf *pixbuf, gchar *title)
|
||||
drawing_area = gtk_drawing_area_new ();
|
||||
|
||||
temp_box = gtk_hbox_new (FALSE, 0);
|
||||
gtk_widget_set_usize (GTK_WIDGET(drawing_area), w, h);
|
||||
gtk_widget_set_size_request (GTK_WIDGET (drawing_area), w, h);
|
||||
gtk_box_pack_start (GTK_BOX (temp_box), drawing_area, FALSE, FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), temp_box, FALSE, FALSE, 0);
|
||||
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT(drawing_area), "expose_event",
|
||||
GTK_SIGNAL_FUNC(expose_func), NULL);
|
||||
gtk_signal_connect (GTK_OBJECT(drawing_area), "configure_event",
|
||||
GTK_SIGNAL_FUNC (config_func), NULL);
|
||||
g_signal_connect (drawing_area, "expose_event",
|
||||
G_CALLBACK (expose_func), NULL);
|
||||
g_signal_connect (drawing_area, "configure_event",
|
||||
G_CALLBACK (config_func), NULL);
|
||||
|
||||
gtk_object_set_data (GTK_OBJECT(drawing_area), "pixbuf", pixbuf);
|
||||
g_object_set_data (G_OBJECT (drawing_area), "pixbuf", pixbuf);
|
||||
|
||||
gtk_widget_show (drawing_area);
|
||||
|
||||
button = gtk_button_new_with_label ("Quit");
|
||||
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
||||
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
|
||||
(GtkSignalFunc) gtk_widget_destroy,
|
||||
GTK_OBJECT (window));
|
||||
g_signal_connect_swapped (button, "clicked",
|
||||
G_CALLBACK (gtk_widget_destroy), window);
|
||||
|
||||
gtk_widget_show (button);
|
||||
|
||||
@@ -425,7 +424,7 @@ new_testrgb_window (GdkPixbuf *pixbuf, gchar *title)
|
||||
|
||||
|
||||
static gint
|
||||
update_timeout(gpointer data)
|
||||
update_timeout (gpointer data)
|
||||
{
|
||||
ProgressFileStatus *status = data;
|
||||
gboolean done;
|
||||
@@ -433,10 +432,10 @@ update_timeout(gpointer data)
|
||||
|
||||
done = FALSE;
|
||||
error = FALSE;
|
||||
if (!feof(status->imagefile)) {
|
||||
if (!feof (status->imagefile)) {
|
||||
gint nbytes;
|
||||
|
||||
nbytes = fread(status->buf, 1, status->readlen,
|
||||
nbytes = fread (status->buf, 1, status->readlen,
|
||||
status->imagefile);
|
||||
|
||||
|
||||
@@ -449,19 +448,15 @@ update_timeout(gpointer data)
|
||||
}
|
||||
|
||||
|
||||
} else { /* Really done */
|
||||
|
||||
GdkPixbuf *pixbuf = gdk_pixbuf_loader_get_pixbuf (status->loader);
|
||||
new_testrgb_window (pixbuf, "After progressive load");
|
||||
done = TRUE;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
done = TRUE;
|
||||
|
||||
if (done) {
|
||||
gtk_widget_queue_draw(*status->rgbwin);
|
||||
/* ignoring errors, we should not do that. */
|
||||
gdk_pixbuf_loader_close (GDK_PIXBUF_LOADER (status->loader), NULL);
|
||||
g_object_unref (G_OBJECT(status->loader));
|
||||
gtk_widget_queue_draw (*status->rgbwin);
|
||||
g_object_unref (G_OBJECT (status->loader));
|
||||
fclose (status->imagefile);
|
||||
g_free (status->buf);
|
||||
}
|
||||
@@ -471,31 +466,31 @@ update_timeout(gpointer data)
|
||||
|
||||
|
||||
static void
|
||||
progressive_prepared_callback(GdkPixbufLoader* loader, gpointer data)
|
||||
progressive_prepared_callback (GdkPixbufLoader* loader, gpointer data)
|
||||
{
|
||||
GtkWidget** retloc = data;
|
||||
GdkPixbuf* pixbuf;
|
||||
|
||||
pixbuf = gdk_pixbuf_loader_get_pixbuf(loader);
|
||||
g_assert(pixbuf != NULL);
|
||||
pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
|
||||
g_assert (pixbuf != NULL);
|
||||
|
||||
gdk_pixbuf_ref(pixbuf); /* for the RGB window */
|
||||
g_object_ref (pixbuf); /* for the RGB window */
|
||||
|
||||
*retloc = new_testrgb_window(pixbuf, "Progressive");
|
||||
*retloc = new_testrgb_window (pixbuf, "Progressive");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
progressive_updated_callback(GdkPixbufLoader* loader, guint x, guint y, guint width, guint height, gpointer data)
|
||||
progressive_updated_callback (GdkPixbufLoader* loader, guint x, guint y, guint width, guint height, gpointer data)
|
||||
{
|
||||
GtkWidget** window_loc = data;
|
||||
|
||||
/* g_print ("progressive_updated_callback:\n\t%d\t%d\t%d\t%d\n", x, y, width, height); */
|
||||
|
||||
if (*window_loc != NULL)
|
||||
gtk_widget_queue_draw_area(*window_loc,
|
||||
gtk_widget_queue_draw_area (*window_loc,
|
||||
x, y, width, height);
|
||||
|
||||
return;
|
||||
@@ -503,7 +498,7 @@ progressive_updated_callback(GdkPixbufLoader* loader, guint x, guint y, guint wi
|
||||
|
||||
static int readlen = 4096;
|
||||
|
||||
extern void pixbuf_init();
|
||||
extern void pixbuf_init ();
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
@@ -520,21 +515,20 @@ main (int argc, char **argv)
|
||||
|
||||
gdk_rgb_set_verbose (TRUE);
|
||||
|
||||
gdk_rgb_init ();
|
||||
|
||||
gtk_widget_set_default_colormap (gdk_rgb_get_cmap ());
|
||||
gtk_widget_set_default_colormap (
|
||||
gdk_rgb_get_colormap_for_screen (gdk_get_default_screen ()));
|
||||
|
||||
{
|
||||
char *tbf_readlen = getenv("TBF_READLEN");
|
||||
if(tbf_readlen) readlen = atoi(tbf_readlen);
|
||||
char *tbf_readlen = getenv ("TBF_READLEN");
|
||||
if (tbf_readlen) readlen = atoi (tbf_readlen);
|
||||
}
|
||||
|
||||
{
|
||||
char *tbf_bps = getenv("TBF_KBPS");
|
||||
char *tbf_bps = getenv ("TBF_KBPS");
|
||||
guint bps;
|
||||
|
||||
if (tbf_bps) {
|
||||
bps = atoi(tbf_bps);
|
||||
bps = atoi (tbf_bps);
|
||||
g_print ("Simulating %d kBytes/sec\n", bps);
|
||||
readlen = (bps*1024)/10;
|
||||
}
|
||||
@@ -543,7 +537,8 @@ main (int argc, char **argv)
|
||||
i = 1;
|
||||
if (argc == 1) {
|
||||
const gchar*** xpmp;
|
||||
|
||||
GError *error = NULL;
|
||||
|
||||
pixbuf = gdk_pixbuf_new_from_data (default_image, GDK_COLORSPACE_RGB, FALSE, 8,
|
||||
DEFAULT_WIDTH, DEFAULT_HEIGHT, DEFAULT_WIDTH * 3,
|
||||
NULL, NULL);
|
||||
@@ -557,11 +552,18 @@ main (int argc, char **argv)
|
||||
}
|
||||
|
||||
/* Test loading from inline data. */
|
||||
pixbuf = gdk_pixbuf_new_from_inline (apple_red, FALSE, -1, NULL);
|
||||
new_testrgb_window (pixbuf, "Red apple from inline data");
|
||||
pixbuf = gdk_pixbuf_new_from_inline (-1, apple_red, FALSE, &error);
|
||||
if (!pixbuf)
|
||||
{
|
||||
fprintf (stderr, "failed to construct \"red apple\" pixbuf: %s\n",
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
else
|
||||
new_testrgb_window (pixbuf, "Red apple from inlined RLE data");
|
||||
|
||||
pixbuf = gdk_pixbuf_new_from_inline (gnome_foot, TRUE, sizeof (gnome_foot), NULL);
|
||||
new_testrgb_window (pixbuf, "Foot from inline data");
|
||||
pixbuf = gdk_pixbuf_new_from_inline (sizeof (gnome_foot), gnome_foot, TRUE, NULL);
|
||||
new_testrgb_window (pixbuf, "GNOME Foot from inlined RLE data");
|
||||
|
||||
found_valid = TRUE;
|
||||
} else {
|
||||
@@ -578,7 +580,7 @@ main (int argc, char **argv)
|
||||
}
|
||||
|
||||
#if 0
|
||||
pixbuf = gdk_pixbuf_rotate(pixbuf, 10.0);
|
||||
pixbuf = gdk_pixbuf_rotate (pixbuf, 10.0);
|
||||
#endif
|
||||
|
||||
if (pixbuf) {
|
||||
@@ -597,25 +599,19 @@ main (int argc, char **argv)
|
||||
status.rgbwin = &rgb_window;
|
||||
|
||||
status.buf = g_malloc (readlen);
|
||||
g_signal_connect_data (G_OBJECT(pixbuf_loader),
|
||||
"area_prepared",
|
||||
GTK_SIGNAL_FUNC(progressive_prepared_callback),
|
||||
&rgb_window,
|
||||
NULL, FALSE, FALSE);
|
||||
|
||||
g_signal_connect_data (G_OBJECT(pixbuf_loader),
|
||||
"area_updated",
|
||||
GTK_SIGNAL_FUNC(progressive_updated_callback),
|
||||
&rgb_window,
|
||||
NULL, FALSE, FALSE);
|
||||
|
||||
g_signal_connect (pixbuf_loader, "area_prepared",
|
||||
G_CALLBACK (progressive_prepared_callback),
|
||||
&rgb_window);
|
||||
g_signal_connect (pixbuf_loader, "area_updated",
|
||||
G_CALLBACK (progressive_updated_callback),
|
||||
&rgb_window);
|
||||
|
||||
status.imagefile = fopen (argv[1], "r");
|
||||
g_assert (status.imagefile != NULL);
|
||||
|
||||
status.readlen = readlen;
|
||||
|
||||
status.timeout = gtk_timeout_add(100, update_timeout, &status);
|
||||
status.timeout = gtk_timeout_add (100, update_timeout, &status);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@@ -1,3 +1,15 @@
|
||||
|
||||
|
||||
DON'T EDIT THIS FILE - changes are now maintained in the reference
|
||||
manual, see docs/reference/gtk/changes-*.sgml. Also, when adding a
|
||||
change to the manual, you should amend the docs for all
|
||||
newly-deprecated features to point to the replacement for that
|
||||
feature, and be sure the GTK_DISABLE_DEPRECATED guards are in place in
|
||||
the header files. Be sure to add a note to the docs for EACH
|
||||
deprecated function; don't just do the changes-*.sgml change.
|
||||
|
||||
|
||||
|
||||
Incompatible Changes from GTK+-1.0 to GTK+-1.2:
|
||||
|
||||
* GtkAcceleratorTable has been replaced with GtkAccelGroup
|
||||
@@ -272,3 +284,12 @@ Incompatible Changes from GTK+-1.0 to GTK+-1.2:
|
||||
which returns the requisition of the given widget, modified
|
||||
by calls to gtk_widget_set_usize().
|
||||
|
||||
|
||||
|
||||
DON'T EDIT THIS FILE - changes are now maintained in the reference
|
||||
manual, see docs/reference/gtk/changes-*.sgml. Also, when adding a
|
||||
change to the manual, you should amend the docs for all
|
||||
newly-deprecated features to point to the replacement for that
|
||||
feature, and be sure the GTK_DISABLE_DEPRECATED guards are in place in
|
||||
the header files. Be sure to add a note to the docs for EACH
|
||||
deprecated function; don't just do the changes-*.sgml change.
|
||||
|
@@ -1,3 +1,18 @@
|
||||
|
||||
|
||||
|
||||
DON'T EDIT THIS FILE - changes are now maintained in the reference
|
||||
manual, see docs/reference/gtk/changes-*.sgml. Also, when adding a
|
||||
change to the manual, you should amend the docs for all
|
||||
newly-deprecated features to point to the replacement for that
|
||||
feature, and be sure the GTK_DISABLE_DEPRECATED guards are in place in
|
||||
the header files. Be sure to add a note to the docs for EACH
|
||||
deprecated function; don't just do the changes-*.sgml change.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Incompatible Changes from GTK+-1.2 to GTK+-2.0:
|
||||
|
||||
* gtk_container_get_toplevels() was removed and replaced with
|
||||
@@ -20,6 +35,9 @@ Incompatible Changes from GTK+-1.2 to GTK+-2.0:
|
||||
has been changed to include the entire area previously occupied by
|
||||
the gutter.
|
||||
|
||||
* gtk_paned_set_handle_size() has been removed, in favor of a style property,
|
||||
since this is an option that only makes sense for themes to adjust.
|
||||
|
||||
* GDK no longer selects OwnerGrabButtonMask for button presses. This means
|
||||
that the automatic grab that occurs when the user presses a button
|
||||
will have owner_events = FALSE, so all events are redirected to the
|
||||
@@ -116,6 +134,12 @@ Incompatible Changes from GTK+-1.2 to GTK+-2.0:
|
||||
have to be moved into the ::destroy implementations. The reason for doing
|
||||
this is that all object reference cycles should be broken at destruction
|
||||
time.
|
||||
|
||||
Because the ::destroy signal can be emitted multiple times, it no longer
|
||||
makes sense to check if a widget has been destroyed using the
|
||||
GTK_OBJECT_DESTROYED() macro, and this macro has been removed. If
|
||||
catching destruction is still needed, it can be done with a signal
|
||||
connection to ::destroy.
|
||||
|
||||
* Signal system changes:
|
||||
The Gtk 2.0 signal merly proxies the GSignal system now.
|
||||
@@ -191,7 +215,7 @@ Incompatible Changes from GTK+-1.2 to GTK+-2.0:
|
||||
|
||||
* A number of functions in GDK have been renamed for consistency and
|
||||
clarity. #defines to provide backwards compatibility have been
|
||||
included, but can be disabled by defineing GDK_DISABLE_COMPAT_H.
|
||||
included, but can be disabled by defineing GDK_DISABLE_DEPRECATED.
|
||||
|
||||
#define gdk_draw_pixmap gdk_draw_drawable
|
||||
#define gdk_draw_bitmap gdk_draw_drawable
|
||||
@@ -322,3 +346,242 @@ Incompatible Changes from GTK+-1.2 to GTK+-2.0:
|
||||
|
||||
* GdkColorContext is gone; you probably weren't using it anyway.
|
||||
Use GdkColormap and the gdk_rgb_* functions instead.
|
||||
|
||||
* GtkMenuBar now draws the GtkContainer::border_width space outside
|
||||
the frame, not inside the frame
|
||||
|
||||
* In GTK 1.2, if an event handler returned TRUE it prevented
|
||||
propagation of that event to parent widgets. That is, the
|
||||
event signal would not be emitted on parent widgets. In
|
||||
GTK 2.0, if an event handler returns TRUE, the current signal
|
||||
emission on the current widget is immediately stopped. That is,
|
||||
other callbacks connected to the signal will not be invoked.
|
||||
|
||||
* gtk_toolbar_new() no longer has arguments. This function
|
||||
was broken because the default GtkToolbarStyle (icons, text, both)
|
||||
is now a user preference, which is overridden when you call
|
||||
gtk_toolbar_set_style(). The constructor forced everyone to
|
||||
override the preference, which was undesirable. So to port
|
||||
your app, decide if you want to force the toolbar style
|
||||
or conform to the user's global defaults; if you want to force
|
||||
it, call gtk_toolbar_set_style().
|
||||
|
||||
The orientation arg was removed from toolbar_new() as well, just
|
||||
because it wasn't very useful and we were breaking the function
|
||||
anyway so had an opportunity to lose it. Call
|
||||
gtk_toolbar_set_orientation() to set toolbar orientation.
|
||||
|
||||
* GtkRange/GtkScrollbar/GtkScale were rewritten; this means that most
|
||||
theme engines won't draw them properly, and any custom subclasses of
|
||||
these widgets will need a rewrite (though if you could figure out
|
||||
how to subclass the old version of GtkRange, you have our
|
||||
respect). Also, GtkTroughType is gone.
|
||||
|
||||
* The GtkContainer::focus signal/virtualfunction and
|
||||
gtk_container_focus() call were replaced by
|
||||
GtkWidget::focus and gtk_widget_child_focus().
|
||||
The semantics are the same, so you should be able to just
|
||||
replace "container_class->focus = mywidget_focus" with
|
||||
"widget_class->focus = mywidget_focus" and replace
|
||||
gtk_container_focus() calls with gtk_widget_child_focus() calls.
|
||||
|
||||
The purpose of this change was to allow non-containers to have
|
||||
focusable elements.
|
||||
|
||||
* gtk_rc_set_image_loader() and gtk_rc_load_image() has been removed, now
|
||||
that GTK+ includes decent image loading capabilities itself.
|
||||
|
||||
* An extra GtkSettings argument has been added to
|
||||
gtk_rc_find_pixmap_in_path(). This function is only actually useful
|
||||
from a theme engine during parsing, at which point the GtkSettings
|
||||
is provided.
|
||||
|
||||
* The child argument facility in gtkcontainer.c has been converted
|
||||
to a child property facility using GParamSpec and other facilities
|
||||
for GObject.
|
||||
|
||||
- The set_child_arg and get_child_arg virtual methods have been
|
||||
replaced with set_child_property / get_child_property, which
|
||||
work similar to GObject->set_property/get_property.
|
||||
|
||||
- Other removed functions with the replacements:
|
||||
|
||||
gtk_container_add_child_arg_type => gtk_container_class_install_child_property
|
||||
gtk_container_query_child_args => gtk_container_class_list_child_properties
|
||||
gtk_container_child_getv => gtk_container_child_set_property
|
||||
gtk_container_child_setv => gtk_container_child_get_property
|
||||
gtk_container_add_with_args => gtk_container_add_with_properties
|
||||
gtk_container_addv => gtk_container_add / gtk_container_child_set_property
|
||||
|
||||
* gdk_image_get() (or rather its replacement,
|
||||
gdk_drawable_get_image()) now handles errors properly by returning
|
||||
NULL, previously it would crash. Also, a window being offscreen is
|
||||
no longer considered an error; instead, the area being contains
|
||||
undefined contents for the offscreen areas. In most cases, code
|
||||
using gdk_image_get() should really be ported to
|
||||
gdk_pixbuf_get_from_drawable().
|
||||
|
||||
* gtk_widget_set_usize() has been renamed to
|
||||
gtk_widget_set_size_request(), however the old name still exists
|
||||
unless you define GTK_DISABLE_DEPRECATED.
|
||||
|
||||
* gtk_widget_set_uposition() is deprecated; use gtk_window_move(),
|
||||
gtk_fixed_put(), or gtk_layout_put() instead.
|
||||
|
||||
* gtk_window_set_policy() is deprecated. To get the effect of
|
||||
"allow_shrink", call gtk_widget_set_size_request(window, 0, 0). To
|
||||
get the effect of "allow_grow", call
|
||||
gtk_window_set_resizable(window, TRUE). You didn't want the effect
|
||||
of auto_shrink, it made no sense. But maybe if you were using it you
|
||||
want to use gtk_window_resize (window, 1, 1) to snap a window back
|
||||
to its minimum size (the 1, 1 will be rounded up to the minimum
|
||||
window size).
|
||||
|
||||
* The core GTK+ now takes care of handling mapping, unmapping and
|
||||
realizing the child widgets of containers in
|
||||
gtk_widget_set_parent(). In most cases, this allows container
|
||||
implementations to be simplifid by removing the code in add()
|
||||
methods to map and realize children. However, there are
|
||||
a couple of things to watch out for here:
|
||||
|
||||
- If the parent is realized before the add() happens,
|
||||
gtk_widget_set_parent_window() must be called before
|
||||
gtk_widget_set_parent(), since gtk_widget_set_parent()
|
||||
will realize the child.
|
||||
|
||||
- If a container depended on its children not being mapped
|
||||
unless it did so itself (for example, GtkNotebook only
|
||||
mapped the current page), then the new function
|
||||
gtk_widget_set_child_visible() must be called to keep
|
||||
widgets that should not be mapped not mapped.
|
||||
|
||||
As part of this change, most containers also will no longer need
|
||||
custom implementations of the map() and unmap() virtual
|
||||
functions. The only cases where this is necessary are:
|
||||
|
||||
- For !NO_WINDOW widgets, if you create children of widget->window
|
||||
and don't map them in realize() then you must map them
|
||||
in map(). [ In almost all cases, you can simply map the
|
||||
windows in realize() ]
|
||||
|
||||
- For NO_WINDOW widgets, if you create windows in your realize()
|
||||
method, you must map then in map() and unmap them in unmap().
|
||||
|
||||
* gtk_widget_set_default_style (), gtk_widget_push_style (),
|
||||
and gtk_widget_pop_style () have been removed, since they
|
||||
did not work properly with themes and there were better
|
||||
alternatives for modifying the appearance of widgets.
|
||||
|
||||
You should generally use gtk_widget_modify_fg/bg/base/text/font
|
||||
instead.
|
||||
|
||||
* gtk_image_new() now takes no arguments and creates an empty GtkImage
|
||||
widget. To create a GtkImage widget from a GdkImage (the least
|
||||
common usage of GdkImage), use gtk_image_new_from_image.
|
||||
|
||||
* GTK_SELECTION_EXTENDED is now deprecated, and neither the
|
||||
GtkList/GtkTree nor the GtkCList/GtkCTree support
|
||||
GTK_SELECTION_EXTENDED anymore. However, the old extended behavior
|
||||
replaces MULTIPLE behavior.
|
||||
|
||||
* The following variables are no longer exported from GDK. (Other variables
|
||||
are also no longer exported; the following are the ones found used
|
||||
externally in a large sample of GTK+ code.)
|
||||
|
||||
Variable Replacement
|
||||
======== ===========
|
||||
gdk_null_window_warnings None - did nothing in GTK+-1.2.
|
||||
gdk_leader_window None - private variable
|
||||
gdk_screen gdk_x11_get_default_screen ()
|
||||
gdk_root_window gdk_x11_get_default_root_xwindow ()
|
||||
gdk_root_parent gdk_get_default_root_window ()
|
||||
gdk_error_code/gdk_error_warnings gdk_error_trap_push()/pop()
|
||||
gdk_display_name gdk_get_display ()
|
||||
gdk_wm_delete_window gdk_atom_intern ("WM_DELETE_WINDOW", FALSE)
|
||||
gdk_wm_take_focus gdk_atom_intern ("WM_TAKE_FOCUS", FALSE)
|
||||
gdk_wm_protocols gdk_atom_intern ("WM_PROTOCOLS", FALSE)
|
||||
|
||||
* The handling of Colormaps and widgets has been changed:
|
||||
|
||||
- The default colormap for widgets is now the GdkRGB colormap, not
|
||||
the system default colormap. If you try to use resources created for
|
||||
a widget (e.g., widget->style) with a window using the system
|
||||
colormap, errors will result on some machines.
|
||||
|
||||
- gtk_widget_push/pop_colormap() only cause the colormap to be
|
||||
explicitely set on toplevel widgets not on all widgets. The
|
||||
colormap for other widgets (when not set using
|
||||
gtk_widget_set_colormap()), is determined by finding the nearest
|
||||
ancestor with a colormap set on it explicitely, or if that
|
||||
fails, the default colormap.
|
||||
|
||||
* The default selected day for GtkCalendar is now the current day in the
|
||||
month, not the first day in the month. The current month and year
|
||||
were already used.
|
||||
|
||||
* GDK is no longer put into threaded mode automatically when
|
||||
g_thread_init() has been called. In order to use the
|
||||
global GDK thread mutex with gdk_threads_enter() and
|
||||
gdk_threads_leave(), you must call gdk_threads_init() explicitely.
|
||||
|
||||
If you aren't using GDK and GTK+ functions from multiple threads,
|
||||
there is no reason to call gdk_threads_init().
|
||||
|
||||
* The GtkPreviewInfo struct has had its visual and colormap fields
|
||||
removed. Also, gtk_preview_get_cmap() and gtk_preview_get_visual()
|
||||
are deprecated, as GdkRgb works on any colormap and visual. You no
|
||||
longer need to gtk_widget_push_cmap (gtk_preview_get_cmap ()) in
|
||||
your code.
|
||||
|
||||
* The GtkBox, GtkTable, and GtkAlignment widgets now call
|
||||
gtk_widget_set_redraw_on_allocate (widget, FALSE); on themselves.
|
||||
If you want to actually draw contents in a widget derived from
|
||||
one of these widgets, you'll probably want to change this
|
||||
in your init() function.
|
||||
|
||||
* A number of widgets are now NO_WINDOW widgets (most importantly
|
||||
GtkButton, but also GtkRange and GtkNotebook)
|
||||
|
||||
This has a couple of effects:
|
||||
|
||||
- If you are deriving from one of these widgets, you need to
|
||||
adapt your code appropriately -- for instance, drawing coordinates
|
||||
start from widget->allocation.x, widget->allocation.y.
|
||||
|
||||
- If you are embedding one of these widgets in a custom widget,
|
||||
you must make sure you call gtk_container_propagate_expose()
|
||||
correctly, as you must for any NO_WINDOW widgets.
|
||||
|
||||
GtkFixed is a little special; it is now created by default as
|
||||
a NO_WINDOW widget, but if you do
|
||||
|
||||
gtk_fixed_set_has_window (fixed, TRUE);
|
||||
|
||||
after creating a fixed widget, it will create a window and
|
||||
handle it properly.
|
||||
|
||||
* GtkLayout no longer has the xoffset, yoffset fields, which used
|
||||
to store the difference between world and window coordinates for
|
||||
layout->bin_window. These coordinate systems are now always
|
||||
the same.
|
||||
|
||||
* gtk_paint_focus(), gtk_draw_focus() and GtkStyle::draw_focus()
|
||||
have been changed a bit:
|
||||
|
||||
- A GtkStateType argument has been added to gtk_paint_focus()
|
||||
- The default implementation of GtkStyle::draw_focus virtual
|
||||
function now draws a focus rectangle whose width is
|
||||
determinted by the GtkWidget::focus-width style property.
|
||||
- The rectangle passed in is the bounding box, instead of
|
||||
the rectangle used in the gdk_draw_rectangle() call, so it is
|
||||
no longer necessary to subtract 1 from the width and height.
|
||||
|
||||
|
||||
|
||||
DON'T EDIT THIS FILE - changes are now maintained in the reference
|
||||
manual, see docs/reference/gtk/changes-*.sgml. Also, when adding a
|
||||
change to the manual, you should amend the docs for all
|
||||
newly-deprecated features to point to the replacement for that
|
||||
feature, and be sure the GTK_DISABLE_DEPRECATED guards are in place in
|
||||
the header files. Be sure to add a note to the docs for EACH
|
||||
deprecated function; don't just do the changes-*.sgml change.
|
||||
|
@@ -2,23 +2,19 @@
|
||||
|
||||
SUBDIRS = tutorial faq reference
|
||||
|
||||
man_MANS = gtk-config.1
|
||||
|
||||
EXTRA_DIST += \
|
||||
Changes-1.2.txt \
|
||||
Changes-2.0.txt \
|
||||
EXTRA_DIST = \
|
||||
debugging.txt \
|
||||
defsformat.txt \
|
||||
developers.txt \
|
||||
dnd_internals.txt \
|
||||
make-todo \
|
||||
refcounting.txt \
|
||||
sizing-test.txt \
|
||||
styles.txt \
|
||||
text_widget.txt \
|
||||
tree-column-sizing.txt \
|
||||
widget_geometry.txt \
|
||||
widget_system.txt \
|
||||
generation.txt \
|
||||
README.linux-fb \
|
||||
gtk-config.txt \
|
||||
gtk-config.1.in \
|
||||
gtkdocs_fix
|
||||
|
||||
|
@@ -1,3 +1,15 @@
|
||||
|
||||
|
||||
|
||||
|
||||
THIS FILE IS OBSOLETE - use docs/reference/gtk/framebuffer.sgml
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
About GtkFB:
|
||||
------------
|
||||
The linux-fb port of Gtk+, also known as GtkFB is an implementation of
|
||||
@@ -44,7 +56,7 @@ it looks in $prefix/lib/ft2fonts, and if you want to change this you
|
||||
must add something like:
|
||||
|
||||
[PangoFT2]
|
||||
FontPath = /usr/share/fonts/default/TrueType
|
||||
FontPath = /usr/share/fonts/default/Type1:/usr/share/fonts/default/TrueType
|
||||
|
||||
To your $prefix/etc/pango/pangorc or ~/.pangorc.
|
||||
|
||||
@@ -53,7 +65,12 @@ This is done by creating a $prefix/etc/pango/pangoft2.aliases or
|
||||
~/.pangoft2_aliases file. You can also set the name of this file using the
|
||||
key AliasFiles in the PangoFT2 section in pangorc.
|
||||
|
||||
An example of a font alias file is:
|
||||
An example of a font alias file for the urw fontset is:
|
||||
sans normal normal normal normal "urw gothic l"
|
||||
serif normal normal normal normal "urw palladio l"
|
||||
monospace normal normal normal normal "nimbus mono l"
|
||||
|
||||
And one using the Windows truetype fonts is:
|
||||
sans normal normal normal normal "arial"
|
||||
serif normal normal normal normal "times new roman"
|
||||
monospace normal normal normal normal "courier new"
|
||||
|
@@ -19,7 +19,7 @@ G_DISABLE_ASSERT
|
||||
G_DISABLE_CHECKS
|
||||
If set, disable the g_return_if_fail and g_return_val_if_fail macros
|
||||
|
||||
GTK_NO_CHECK_CASTS
|
||||
G_DISABLE_CAST_CHECKS
|
||||
If set, don't check casts between different object types
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ time by the --enable-debug option.
|
||||
|
||||
--enable-debug=minimum [default]
|
||||
Enable only inexpensive sanity checking
|
||||
sets GTK_NO_CHECK_CASTS
|
||||
sets G_DISABLE_CAST_CHECKS
|
||||
|
||||
--enable-debug=yes
|
||||
Enable all debugging support
|
||||
@@ -36,10 +36,16 @@ time by the --enable-debug option.
|
||||
|
||||
--enable-debug=no (or --disable-debug)
|
||||
Disable all debugging support (fastest)
|
||||
sets G_DISABLE_ASSERT, G_DISABLE_CHECKS, and GTK_NO_CHECK_CASTS
|
||||
sets G_DISABLE_ASSERT, G_DISABLE_CHECKS, and G_DISABLE_CAST_CHECKS
|
||||
|
||||
Note that !G_DISABLE_CHECKS and --enable-debug=no are to be considered
|
||||
not only fast, but dangerous as they tend to destabilize even mostly
|
||||
bug-free software by changing the effect of many bugs from simple warnings
|
||||
into fatal crashes. Thus --enable-debug=no should *not* be used for
|
||||
stable releases of gtk+.
|
||||
|
||||
|
||||
RUN TIME OPTIONS
|
||||
RUNTIME OPTIONS
|
||||
----------------
|
||||
|
||||
At run time, if GTK+ was compiled with debugging enabled, different
|
||||
@@ -67,15 +73,9 @@ For instance:
|
||||
|
||||
runs testgtk with the 'misc' and 'events' debugging options.
|
||||
|
||||
GTK_DEBUG
|
||||
---------
|
||||
See glib/docs/debugging.txt for information about debugging signal emission
|
||||
and the object system.
|
||||
|
||||
Application relevant options:
|
||||
|
||||
'objects' - Trace the creation and destruction of objects, print
|
||||
out a summary at program termination
|
||||
|
||||
Options only interesting to library maintainers:
|
||||
|
||||
GDK_DEBUG
|
||||
---------
|
||||
@@ -88,10 +88,19 @@ runs testgtk with the 'misc' and 'events' debugging options.
|
||||
|
||||
'misc' - Miscellaneous information
|
||||
'dnd' - Information about drag-and-drop
|
||||
'color-context' - Information about the internal workings of
|
||||
GdkColorContext
|
||||
'xim' - Information about X Input Method support
|
||||
|
||||
|
||||
- Owen Taylor <owt1@cornell.edu>
|
||||
98/02/19
|
||||
GTK_DEBUG
|
||||
---------
|
||||
|
||||
Options only interesting to library maintainers:
|
||||
|
||||
'misc' - Miscellaneous information
|
||||
'text' - Information about text widget internals
|
||||
'tree' - Information about tree widget internals
|
||||
'updates' - Visual feedback about window updates
|
||||
|
||||
|
||||
- 2001-08-13 Matthias Clasen
|
||||
- 98/02/19 Owen Taylor
|
||||
|
@@ -1,42 +1,34 @@
|
||||
.PHONY: htmldir textdir faq
|
||||
EXTRA_DIST = \
|
||||
gtk-faq.sgml
|
||||
|
||||
FAQ_FILES=html/gtkfaq.html \
|
||||
html/gtkfaq-1.html \
|
||||
html/gtkfaq-2.html \
|
||||
html/gtkfaq-3.html \
|
||||
html/gtkfaq-4.html \
|
||||
html/gtkfaq-5.html \
|
||||
html/gtkfaq-6.html \
|
||||
html/gtkfaq-7.html \
|
||||
text/gtkfaq.txt
|
||||
if HAVE_DOCBOOK
|
||||
html:
|
||||
(cd $(srcdir); \
|
||||
db2html gtk-faq.sgml; \
|
||||
test -d html && rm -r html; \
|
||||
mv gtk-faq html)
|
||||
|
||||
$(FAQ_FILES): faq
|
||||
pdf:
|
||||
(cd $(srcdir); db2pdf gtk-faq.sgml)
|
||||
|
||||
htmldir:
|
||||
mkdir -p $(srcdir)/html
|
||||
|
||||
textdir:
|
||||
mkdir -p $(srcdir)/text
|
||||
|
||||
faq: htmldir textdir
|
||||
(cd $(srcdir); sgml2html gtkfaq.sgml; \
|
||||
perl $(top_srcdir)/docs/gtkdocs_fix gtkfaq*html; \
|
||||
mv gtkfaq*html html/; \
|
||||
sgml2txt gtkfaq.sgml; \
|
||||
mv gtkfaq.txt text/)
|
||||
|
||||
EXTRA_DIST += gtkfaq.sgml gtk-faq.sgml
|
||||
|
||||
if HAVE_SGML2HTML
|
||||
dist-hook: faq
|
||||
mkdir $(distdir)/html
|
||||
cp -p $(srcdir)/html/*.html $(distdir)/html
|
||||
mkdir $(distdir)/text
|
||||
cp -p $(srcdir)/text/*.txt $(distdir)/text
|
||||
dist-hook: html
|
||||
cp -Rp $(srcdir)/html $(distdir)
|
||||
else
|
||||
dist-hook:
|
||||
html:
|
||||
echo "***"
|
||||
echo "*** Warning: FAQ not built"
|
||||
echo "***"
|
||||
|
||||
pdf:
|
||||
echo "***"
|
||||
echo "*** Warning: FAQ not built"
|
||||
echo "***"
|
||||
|
||||
dist-hook:
|
||||
echo "***"
|
||||
echo "*** Warning: Tutorial not built"
|
||||
echo "*** DISTRIBUTION IS INCOMPLETE"
|
||||
echo "***"
|
||||
endif
|
||||
|
||||
.PHONY: html
|
||||
|
@@ -1,49 +0,0 @@
|
||||
.TH GTK+ 1 "25 October 1998" Version @VERSION@
|
||||
.SH NAME
|
||||
gtk-config - script to get information about the installed version of GTK+
|
||||
.SH SYNOPSIS
|
||||
.B gtk-config
|
||||
[\-\-prefix\fI[=DIR]\fP] [\-\-exec\-prefix\fI[=DIR]\fP] [\-\-version] [\-\-libs] [\-\-cflags]
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
\fIgtk-config\fP is a tool that is used to configure to determine
|
||||
the compiler and linker flags that should be used to compile
|
||||
and link programs that use \fIGTK+\fP. It is also used internally
|
||||
to the .m4 macros for GNU autoconf that are included with \fIGTK+\fP.
|
||||
.
|
||||
.SH OPTIONS
|
||||
.l
|
||||
\fIgtk-config\fP accepts the following options:
|
||||
.TP 8
|
||||
.B \-\-version
|
||||
Print the currently installed version of \fIGTK+\fP on the standard output.
|
||||
.TP 8
|
||||
.B \-\-libs
|
||||
Print the linker flags that are necessary to link a \fIGTK+\fP program.
|
||||
.TP 8
|
||||
.B \-\-cflags
|
||||
Print the compiler flags that are necessary to compile a \fIGTK+\fP program.
|
||||
.TP 8
|
||||
.B \-\-prefix=PREFIX
|
||||
If specified, use PREFIX instead of the installation prefix that \fIGTK+\fP
|
||||
was built with when computing the output for the \-\-cflags and
|
||||
\-\-libs options. This option is also used for the exec prefix
|
||||
if \-\-exec\-prefix was not specified. This option must be specified
|
||||
before any \-\-libs or \-\-cflags options.
|
||||
.TP 8
|
||||
.B \-\-exec\-prefix=PREFIX
|
||||
If specified, use PREFIX instead of the installation exec prefix that
|
||||
\fIGTK+\fP was built with when computing the output for the \-\-cflags
|
||||
and \-\-libs options. This option must be specified before any
|
||||
\-\-libs or \-\-cflags options.
|
||||
.SH SEE ALSO
|
||||
.BR gimp (1),
|
||||
.BR gimptool (1)
|
||||
.SH COPYRIGHT
|
||||
Copyright \(co 1998 Owen Taylor
|
||||
|
||||
Permission to use, copy, modify, and distribute this software and its
|
||||
documentation for any purpose and without fee is hereby granted,
|
||||
provided that the above copyright notice appear in all copies and that
|
||||
both that copyright notice and this permission notice appear in
|
||||
supporting documentation.
|
File diff suppressed because it is too large
Load Diff
@@ -7,6 +7,7 @@ gdk-pixbuf.hierarchy
|
||||
gdk-pixbuf.signals
|
||||
gdk-pixbuf-decl.txt
|
||||
gdk-pixbuf-decl-list.txt
|
||||
gdk-pixbuf-undocumented.txt
|
||||
gdk-pixbuf-unused.txt
|
||||
*.stamp
|
||||
*.lo
|
||||
|
@@ -10,10 +10,10 @@ DOC_MAIN_SGML_FILE=gdk-pixbuf.sgml
|
||||
DOC_SOURCE_DIR=../../../gdk-pixbuf
|
||||
|
||||
# Extra options to supply to gtkdoc-scan
|
||||
SCAN_OPTIONS=--source-dir=../../../contrib/gdk-pixbuf-xlib
|
||||
SCAN_OPTIONS=--source-dir=../../../contrib/gdk-pixbuf-xlib --deprecated-guards="GDK_PIXBUF_ENABLE_BROKEN|GDK_PIXBUF_DISABLE_DEPRECATED"
|
||||
|
||||
# Extra options to supply to gtkdoc-mkdb
|
||||
MKDB_OPTIONS=--source-dir=../../../contrib/gdk-pixbuf-xlib
|
||||
MKDB_OPTIONS=--sgml-mode --source-dir=../../../contrib/gdk-pixbuf-xlib
|
||||
|
||||
# Extra options to supply to gtkdoc-fixref
|
||||
FIXXREF_OPTIONS=
|
||||
@@ -28,7 +28,9 @@ IGNORE_HFILES= \
|
||||
gdk-pixbuf-marshal.h \
|
||||
gdk-pixbuf-xlib-private.h \
|
||||
gdk-pixbuf-i18n.h \
|
||||
gdk-pixbuf-private.h
|
||||
gdk-pixbuf-private.h \
|
||||
io-gif-animation.h \
|
||||
test-images.h
|
||||
|
||||
# Extra files to add when scanning
|
||||
EXTRA_HFILES=
|
||||
@@ -38,7 +40,7 @@ HTML_IMAGES =
|
||||
|
||||
# Extra SGML files that are included by DOC_MAIN_SGML_FILE
|
||||
content_files = \
|
||||
compiling.sgml \
|
||||
gdk-pixbuf-from-drawables.sgml \
|
||||
gdk-pixbuf.sgml \
|
||||
porting-from-imlib.sgml
|
||||
|
||||
@@ -52,16 +54,15 @@ GTKDOC_CFLAGS = @STRIP_BEGIN@ \
|
||||
-I$(top_srcdir) \
|
||||
-I$(top_builddir) \
|
||||
-I$(top_builddir)/gdk \
|
||||
-DGTK_DISABLE_COMPAT_H \
|
||||
@GTK_DEBUG_FLAGS@ \
|
||||
@GTK_DEP_CFLAGS@ \
|
||||
@STRIP_END@
|
||||
|
||||
GTKDOC_LIBS = @STRIP_BEGIN@ \
|
||||
$(top_builddir)/gdk-pixbuf/libgdk_pixbuf-1.3.la \
|
||||
$(top_builddir)/gdk/@gdktargetlib@ \
|
||||
$(top_builddir)/gtk/@gtktargetlib@ \
|
||||
@GTK_DEP_LIBS@ \
|
||||
GTKDOC_LIBS = @STRIP_BEGIN@ \
|
||||
$(top_builddir)/gdk-pixbuf/libgdk_pixbuf-$(GTK_API_VERSION).la \
|
||||
$(top_builddir)/gdk/@gdktargetlib@ \
|
||||
$(top_builddir)/gtk/@gtktargetlib@ \
|
||||
@GTK_DEP_LIBS@ \
|
||||
@STRIP_END@
|
||||
|
||||
GTKDOC_CC=$(LIBTOOL) --mode=compile $(CC)
|
||||
@@ -72,6 +73,13 @@ GTKDOC_LD=$(LIBTOOL) --mode=link $(CC)
|
||||
# Everything below here is generic #
|
||||
####################################
|
||||
|
||||
# We set GPATH here; this gives us semantics for GNU make
|
||||
# which are more like other make's VPATH, when it comes to
|
||||
# whether a source that is a target of one rule is then
|
||||
# searched for in VPATH/GPATH.
|
||||
#
|
||||
GPATH = $(srcdir)
|
||||
|
||||
TARGET_DIR=$(HTML_DIR)/$(DOC_MODULE)
|
||||
|
||||
EXTRA_DIST = \
|
||||
@@ -138,7 +146,8 @@ sgml.stamp: sgml-build.stamp
|
||||
|
||||
html-build.stamp: sgml.stamp $(DOC_MAIN_SGML_FILE) $(content_files)
|
||||
@echo '*** Building HTML ***'
|
||||
test -d $(srcdir)/html || mkdir $(srcdir)/html
|
||||
rm -rf $(srcdir)/html
|
||||
mkdir $(srcdir)/html
|
||||
cd $(srcdir)/html && gtkdoc-mkhtml $(DOC_MODULE) ../$(DOC_MAIN_SGML_FILE)
|
||||
test "x$(HTML_IMAGES)" = "x" || ( cd $(srcdir) && cp $(HTML_IMAGES) html )
|
||||
@echo '-- Fixing Crossreferences'
|
||||
@@ -156,8 +165,8 @@ maintainer-clean-local: clean
|
||||
|
||||
install-data-local:
|
||||
$(mkinstalldirs) $(DESTDIR)$(TARGET_DIR)
|
||||
(installfiles=`echo $(srcdir)/html/*.html`; \
|
||||
if test "$$installfiles" = '$(srcdir)/html/*.html'; \
|
||||
(installfiles=`echo $(srcdir)/html/*`; \
|
||||
if test "$$installfiles" = '$(srcdir)/html/*'; \
|
||||
then echo '-- Nothing to install' ; \
|
||||
else \
|
||||
for i in $$installfiles; do \
|
||||
@@ -185,12 +194,6 @@ dist-hook: dist-check-gtkdoc dist-hook-local
|
||||
mkdir $(distdir)/html
|
||||
-cp $(srcdir)/tmpl/*.sgml $(distdir)/tmpl
|
||||
-cp $(srcdir)/sgml/*.sgml $(distdir)/sgml
|
||||
-cp $(srcdir)/html/index.sgml $(distdir)/html
|
||||
-cp $(srcdir)/html/*.html $(srcdir)/html/*.css $(distdir)/html
|
||||
|
||||
images=$(HTML_IMAGES) ; \
|
||||
for i in $$images ; do \
|
||||
cp $(srcdir)/$$i $(distdir)/html ; \
|
||||
done
|
||||
-cp $(srcdir)/html/* $(distdir)/html
|
||||
|
||||
.PHONY : dist-hook-local
|
||||
|
@@ -1,103 +0,0 @@
|
||||
<appendix id="compiling">
|
||||
<title>Compiling the &gdk-pixbuf; library</title>
|
||||
|
||||
<para>
|
||||
This appendix describes the special options you can use while
|
||||
compiling the &gdk-pixbuf; library.
|
||||
</para>
|
||||
|
||||
<sect1 id="building">
|
||||
<title>Building the Library</title>
|
||||
<para>
|
||||
The &gdk-pixbuf; library uses the standard GNU build system,
|
||||
using <application>autoconf</application> for package
|
||||
configuration and resolving portability issues,
|
||||
<application>automake</application> for building makefiles
|
||||
that comply with the GNU Coding Standards, and
|
||||
<application>libtool</application> for building shared
|
||||
libraries on multiple platforms. The normal sequence for
|
||||
compiling and installing the &gdk-pixbuf; library is thus:
|
||||
|
||||
<literallayout>
|
||||
<userinput>./configure</userinput>
|
||||
<userinput>make</userinput>
|
||||
<userinput>make install</userinput>
|
||||
</literallayout>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The standard options provided by <application>GNU
|
||||
autoconf</application> may be passed to the
|
||||
<command>configure</command> script. Please see the
|
||||
<application>autoconf</application> documentation or run
|
||||
<command>./configure --help</command> for information about
|
||||
the standard options.
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
<sect1 id="extra-configuration-options">
|
||||
<title>Extra Configuration Options</title>
|
||||
|
||||
<para>
|
||||
In addition to the normal options, the
|
||||
<command>configure</command> script in the &gdk-pixbuf;
|
||||
library supports these additional arguments:
|
||||
|
||||
<cmdsynopsis>
|
||||
<command>configure</command>
|
||||
|
||||
<group>
|
||||
<arg>--disable-modules</arg>
|
||||
<arg>--enable-modules</arg>
|
||||
</group>
|
||||
|
||||
<group>
|
||||
<arg>--disable-gtk-doc</arg>
|
||||
<arg>--enable-gtk-doc</arg>
|
||||
</group>
|
||||
</cmdsynopsis>
|
||||
</para>
|
||||
|
||||
<formalpara>
|
||||
<title><systemitem>--disable-modules</systemitem> and
|
||||
<systemitem>--enable-modules</systemitem></title>
|
||||
|
||||
<para>
|
||||
Normally &gdk-pixbuf; will try to build the image file
|
||||
format loaders as little shared libraries that are loaded on
|
||||
demand. The <systemitem>--disable-modules</systemitem>
|
||||
argument indicates that they should all be built statically
|
||||
into the &gdk-pixbuf; library instead. This is useful for
|
||||
people who need to produce statically-linked binaries. If
|
||||
neither <systemitem>--disable-modules</systemitem> nor
|
||||
<systemitem>--enable-modules</systemitem> is specified, then
|
||||
the <command>configure</command> script will try to
|
||||
auto-detect whether shared modules work on your system.
|
||||
</para>
|
||||
</formalpara>
|
||||
|
||||
<formalpara>
|
||||
<title><systemitem>--disable-gtk-doc</systemitem> and
|
||||
<systemitem>--enable-gtk-doc</systemitem></title>
|
||||
|
||||
<para>
|
||||
By default the <command>configure</command> script will try
|
||||
to auto-detect whether the
|
||||
<application>gtk-doc</application> package is installed. If
|
||||
it is, then it will use it to extract and build the
|
||||
documentation for the &gdk-pixbuf; library. These options
|
||||
can be used to explicitly control whether gtk-doc should be
|
||||
used or not. If it is not used, the distributed,
|
||||
pre-generated HTML files will be installed instead of
|
||||
building them on your machine.
|
||||
</para>
|
||||
</formalpara>
|
||||
</sect1>
|
||||
</appendix>
|
||||
|
||||
<!--
|
||||
Local variables:
|
||||
mode: sgml
|
||||
sgml-parent-document: ("gdk-pixbuf.sgml" "book" "book" "")
|
||||
End:
|
||||
-->
|
25
docs/reference/gdk-pixbuf/gdk-pixbuf-from-drawables.sgml
Normal file
25
docs/reference/gdk-pixbuf/gdk-pixbuf-from-drawables.sgml
Normal file
@@ -0,0 +1,25 @@
|
||||
<refentry id="gdk-pixbuf-gdk-pixbuf-from-drawables">
|
||||
<refmeta>
|
||||
<refentrytitle>Drawables to Pixbufs</refentrytitle>
|
||||
<manvolnum>3</manvolnum>
|
||||
<refmiscinfo>GDK-PIXBUF Library</refmiscinfo>
|
||||
</refmeta>
|
||||
|
||||
<refnamediv>
|
||||
<refname>Drawables to Pixbufs</refname><refpurpose>Getting parts of a GDK drawable's image data into a pixbuf.</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
<para>
|
||||
The functions to take the image data from a GDK drawable and dump it
|
||||
into a pixbuf are contained in GDK, see the
|
||||
<link linkend="gdk-Pixbufs">Pixbufs</link> section of the GDK
|
||||
documentation.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
|
||||
|
||||
|
||||
</refentry>
|
28
docs/reference/gdk-pixbuf/gdk-pixbuf-rendering.sgml
Normal file
28
docs/reference/gdk-pixbuf/gdk-pixbuf-rendering.sgml
Normal file
@@ -0,0 +1,28 @@
|
||||
<refentry id="gdk-pixbuf-gdk-pixbuf-rendering">
|
||||
<refmeta>
|
||||
<refentrytitle>Rendering</refentrytitle>
|
||||
<manvolnum>3</manvolnum>
|
||||
<refmiscinfo>GDK-PIXBUF Library</refmiscinfo>
|
||||
</refmeta>
|
||||
|
||||
<refnamediv>
|
||||
<refname>Rendering</refname><refpurpose>Rendering a pixbuf to a GDK drawable.</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
<para>
|
||||
The functions to render pixbufs to GDK drawables are contained in
|
||||
GDK, see the <link linkend="gdk-Pixbufs">Pixbufs</link> section
|
||||
of the GDK documentation.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
|
||||
|
@@ -27,15 +27,23 @@ gdk_pixbuf_get_pixels
|
||||
gdk_pixbuf_get_width
|
||||
gdk_pixbuf_get_height
|
||||
gdk_pixbuf_get_rowstride
|
||||
gdk_pixbuf_get_option
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GDK_TYPE_PIXBUF_ERROR
|
||||
GDK_TYPE_COLORSPACE
|
||||
GDK_TYPE_PIXBUF_ALPHA_MODE
|
||||
GDK_PIXBUF
|
||||
GDK_TYPE_PIXBUF
|
||||
GDK_IS_PIXBUF
|
||||
|
||||
|
||||
<SUBSECTION Private>
|
||||
gdk_pixbuf_get_type
|
||||
gdk_pixbuf_error_quark
|
||||
gdk_colorspace_get_type
|
||||
gdk_pixbuf_alpha_mode_get_type
|
||||
gdk_pixbuf_error_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
@@ -66,52 +74,73 @@ gdk_pixbuf_new_subpixbuf
|
||||
gdk_pixbuf_copy
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>inline</FILE>
|
||||
GdkPixdata
|
||||
GdkPixdataType
|
||||
GdkPixdataDumpType
|
||||
GDK_PIXBUF_MAGIC_NUMBER
|
||||
GDK_PIXDATA_HEADER_LENGTH
|
||||
gdk_pixdata_from_pixbuf
|
||||
gdk_pixbuf_from_pixdata
|
||||
gdk_pixdata_serialize
|
||||
gdk_pixdata_deserialize
|
||||
gdk_pixdata_to_csource
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>util</FILE>
|
||||
gdk_pixbuf_add_alpha
|
||||
gdk_pixbuf_copy_area
|
||||
gdk_pixbuf_saturate_and_pixelate
|
||||
gdk_pixbuf_fill
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>animation</FILE>
|
||||
GdkPixbufFrameAction
|
||||
GdkPixbufFrame
|
||||
GdkPixbufAnimation
|
||||
GdkPixbufAnimationIter
|
||||
gdk_pixbuf_animation_new_from_file
|
||||
gdk_pixbuf_animation_ref
|
||||
gdk_pixbuf_animation_unref
|
||||
gdk_pixbuf_animation_get_frames
|
||||
gdk_pixbuf_animation_get_width
|
||||
gdk_pixbuf_animation_get_num_frames
|
||||
gdk_pixbuf_animation_get_height
|
||||
gdk_pixbuf_frame_copy
|
||||
gdk_pixbuf_frame_free
|
||||
gdk_pixbuf_frame_get_pixbuf
|
||||
gdk_pixbuf_frame_get_action
|
||||
gdk_pixbuf_frame_get_y_offset
|
||||
gdk_pixbuf_frame_get_delay_time
|
||||
gdk_pixbuf_frame_get_x_offset
|
||||
gdk_pixbuf_animation_get_iter
|
||||
gdk_pixbuf_animation_is_static_image
|
||||
gdk_pixbuf_animation_get_static_image
|
||||
gdk_pixbuf_animation_iter_advance
|
||||
gdk_pixbuf_animation_iter_get_delay_time
|
||||
gdk_pixbuf_animation_iter_on_currently_loading_frame
|
||||
gdk_pixbuf_animation_iter_get_pixbuf
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GDK_PIXBUF_ANIMATION
|
||||
GDK_TYPE_PIXBUF_ANIMATION
|
||||
GDK_IS_PIXBUF_ANIMATION
|
||||
GDK_TYPE_PIXBUF_FRAME
|
||||
GDK_IS_PIXBUF_ANIMATION_ITER
|
||||
GDK_PIXBUF_ANIMATION_ITER
|
||||
GDK_TYPE_PIXBUF_ANIMATION_ITER
|
||||
|
||||
<SUBSECTION Private>
|
||||
gdk_pixbuf_frame_get_type
|
||||
gdk_pixbuf_animation_get_type
|
||||
gdk_pixbuf_animation_iter_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>scaling</FILE>
|
||||
GdkInterpType
|
||||
gdk_pixbuf_scale_simple
|
||||
gdk_pixbuf_scale
|
||||
gdk_pixbuf_composite_color_simple
|
||||
gdk_pixbuf_composite
|
||||
gdk_pixbuf_composite_color
|
||||
gdk_pixbuf_scale_simple
|
||||
gdk_pixbuf_composite_color_simple
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GDK_TYPE_INTERP_TYPE
|
||||
|
||||
<SUBSECTION Private>
|
||||
gdk_interp_type_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
@@ -141,8 +170,6 @@ gdk_pixbuf_loader_get_type
|
||||
ModuleFillVtableFunc
|
||||
ModulePreparedNotifyFunc
|
||||
ModuleUpdatedNotifyFunc
|
||||
ModuleFrameDoneNotifyFunc
|
||||
ModuleAnimationDoneNotifyFunc
|
||||
GdkPixbufModule
|
||||
</SECTION>
|
||||
|
||||
@@ -191,3 +218,4 @@ xlib_rgb_get_depth
|
||||
xlib_rgb_get_display
|
||||
xlib_rgb_get_screen
|
||||
</SECTION>
|
||||
|
||||
|
@@ -3,18 +3,23 @@
|
||||
<!entity gdk-pixbuf-gdk-pixbuf SYSTEM "sgml/gdk-pixbuf.sgml">
|
||||
<!entity gdk-pixbuf-refcounting SYSTEM "sgml/refcounting.sgml">
|
||||
<!entity gdk-pixbuf-file-loading SYSTEM "sgml/file-loading.sgml">
|
||||
<!entity gdk-pixbuf-file-saving SYSTEM "sgml/file-saving.sgml">
|
||||
<!entity gdk-pixbuf-creating SYSTEM "sgml/creating.sgml">
|
||||
<!entity gdk-pixbuf-inline SYSTEM "sgml/inline.sgml">
|
||||
<!entity gdk-pixbuf-scaling SYSTEM "sgml/scaling.sgml">
|
||||
<!entity gdk-pixbuf-rendering SYSTEM "gdk-pixbuf-rendering.sgml">
|
||||
<!entity gdk-pixbuf-from-drawables SYSTEM "gdk-pixbuf-from-drawables.sgml">
|
||||
<!entity gdk-pixbuf-util SYSTEM "sgml/util.sgml">
|
||||
<!entity gdk-pixbuf-animation SYSTEM "sgml/animation.sgml">
|
||||
<!entity GdkPixbufLoader SYSTEM "sgml/gdk-pixbuf-loader.sgml">
|
||||
<!entity module-interface SYSTEM "sgml/module_interface.sgml">
|
||||
<!entity initialization-versions SYSTEM "sgml/initialization_versions.sgml">
|
||||
<!entity gdk-pixbuf-gdk-pixbuf-xlib-init SYSTEM "sgml/gdk-pixbuf-xlib-init.sgml">
|
||||
<!entity gdk-pixbuf-gdk-pixbuf-xlib-rendering SYSTEM "sgml/gdk-pixbuf-xlib-rendering.sgml">
|
||||
<!entity gdk-pixbuf-gdk-pixbuf-xlib-from-drawables SYSTEM "sgml/gdk-pixbuf-xlib-from-drawables.sgml">
|
||||
<!entity gdk-pixbuf-gdk-pixbuf-xlib-rgb SYSTEM "sgml/gdk-pixbuf-xlib-rgb.sgml">
|
||||
|
||||
<!entity Porting-From-Imlib SYSTEM "porting-from-imlib.sgml">
|
||||
<!entity Compiling SYSTEM "compiling.sgml">
|
||||
|
||||
<!entity gdk-pixbuf "<application>gdk-pixbuf</application>">
|
||||
<!entity Imlib "<application>Imlib</application>">
|
||||
@@ -84,15 +89,22 @@
|
||||
</para>
|
||||
</partintro>
|
||||
|
||||
&initialization-versions;
|
||||
|
||||
&gdk-pixbuf-gdk-pixbuf;
|
||||
&gdk-pixbuf-refcounting;
|
||||
&gdk-pixbuf-file-loading;
|
||||
&gdk-pixbuf-file-saving;
|
||||
&gdk-pixbuf-creating;
|
||||
&gdk-pixbuf-inline;
|
||||
&gdk-pixbuf-scaling;
|
||||
&gdk-pixbuf-rendering;
|
||||
&gdk-pixbuf-from-drawables;
|
||||
&gdk-pixbuf-util;
|
||||
&gdk-pixbuf-animation;
|
||||
|
||||
&GdkPixbufLoader;
|
||||
&module-interface;
|
||||
|
||||
&gdk-pixbuf-gdk-pixbuf-xlib-init;
|
||||
&gdk-pixbuf-gdk-pixbuf-xlib-rendering;
|
||||
@@ -101,7 +113,6 @@
|
||||
</reference>
|
||||
|
||||
&Porting-From-Imlib;
|
||||
&Compiling;
|
||||
|
||||
<!-- License -->
|
||||
|
||||
|
@@ -1,4 +1,7 @@
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
#include <gdk-pixbuf/gdk-pixbuf-loader.h>
|
||||
|
||||
gdk_pixbuf_get_type
|
||||
gdk_pixbuf_loader_get_type
|
||||
gdk_pixbuf_animation_get_type
|
||||
gdk_pixbuf_animation_iter_get_type
|
||||
|
@@ -62,11 +62,6 @@
|
||||
|
||||
<para>
|
||||
The &gdk-pixbuf; library does not need to be initialized.
|
||||
However, if you intend to use the rendering functions or
|
||||
anything else from the <application>GdkRGB</application>
|
||||
library, you should call <function>gdk_rgb_init()</function>
|
||||
after calling <function>gtk_init()</function> or
|
||||
<function>gnome_init()</function> in your program.
|
||||
</para>
|
||||
|
||||
<note>
|
||||
@@ -101,14 +96,13 @@
|
||||
a new <link linkend="GdkPixbuf">GdkPixbuf</link> structure,
|
||||
it is created with an initial reference count of 1. When
|
||||
another part of the program wants to keep a reference to the
|
||||
pixbuf, it should call <link
|
||||
linkend="gdk-pixbuf-ref">gdk_pixbuf_ref()</link>; this will
|
||||
increase the reference count by 1. When some part of the
|
||||
program does not need to keep a reference to a pixbuf
|
||||
pixbuf, it should call <function>g_object_ref()</function>;
|
||||
this will increase the reference count by 1. When some part
|
||||
of the program does not need to keep a reference to a pixbuf
|
||||
anymore and wants to release the pixbuf, it should call
|
||||
<link linkend="gdk-pixbuf-unref">gdk_pixbuf_unref()</link>;
|
||||
this will decrease the reference count by 1. When the
|
||||
reference count drops to zero, the pixbuf gets destroyed or
|
||||
<function>g_object_unref()</function>; this will decrease
|
||||
the reference count by 1. When the reference count drops to
|
||||
zero, the pixbuf gets destroyed or
|
||||
<emphasis>finalized</emphasis> and its memory is freed.
|
||||
</para>
|
||||
|
||||
@@ -131,9 +125,9 @@
|
||||
|
||||
<para>
|
||||
Most applications will simply need to call
|
||||
<function>gdk_pixbuf_ref()</function> when they want to keep
|
||||
<function>g_object_ref()</function> when they want to keep
|
||||
an extra reference to a pixbuf, and then
|
||||
<function>gdk_pixbuf_unref()</function> when they are done
|
||||
<function>g_object_unref()</function> when they are done
|
||||
with it.
|
||||
</para>
|
||||
</sect2>
|
||||
@@ -145,7 +139,7 @@
|
||||
|
||||
<para>
|
||||
The &gdk-pixbuf; library has the policy of always rendering
|
||||
pixbufs to Gdk drawables you provide; it will not create
|
||||
pixbufs to GDK drawables you provide; it will not create
|
||||
them for you. This is in general more flexible than
|
||||
&Imlib;'s policy of always creating a pixmap and making you
|
||||
use that instead.
|
||||
@@ -232,7 +226,7 @@
|
||||
<para>
|
||||
After you have created a pixbuf, you can manipulate it in
|
||||
any way you please and then finally call
|
||||
<function>gdk_pixbuf_unref()</function> when you are done
|
||||
<function>g_object_unref()</function> when you are done
|
||||
with it. This can be thought of as a replacement for
|
||||
<function>gdk_imlib_destroy_image()</function> but with much
|
||||
cleaner semantics.
|
||||
|
@@ -5,7 +5,7 @@ Animations
|
||||
Animated images.
|
||||
|
||||
<!-- ##### SECTION Long_Description ##### -->
|
||||
<para>
|
||||
<para><anchor id="GdkPixbufAnimation">
|
||||
The &gdk-pixbuf; library provides a simple mechanism to load and represent
|
||||
animations. An animation is conceptually a series of frames to be displayed
|
||||
over time. Each frame is the same size. The animation may not be represented
|
||||
@@ -20,30 +20,11 @@ Animated images.
|
||||
#GdkPixbufLoader
|
||||
</para>
|
||||
|
||||
<!-- ##### ENUM GdkPixbufFrameAction ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@GDK_PIXBUF_FRAME_RETAIN:
|
||||
@GDK_PIXBUF_FRAME_DISPOSE:
|
||||
@GDK_PIXBUF_FRAME_REVERT:
|
||||
|
||||
<!-- ##### STRUCT GdkPixbufFrame ##### -->
|
||||
<para>
|
||||
|
||||
This object describes an individual frame of an animation.
|
||||
</para>
|
||||
|
||||
@pixbuf:
|
||||
@x_offset:
|
||||
@y_offset:
|
||||
@delay_time:
|
||||
@elapsed:
|
||||
@action:
|
||||
@need_recomposite:
|
||||
@bg_transparent:
|
||||
@composited:
|
||||
@revert:
|
||||
|
||||
<!-- ##### STRUCT GdkPixbufAnimation ##### -->
|
||||
<para>
|
||||
@@ -51,6 +32,13 @@ Animated images.
|
||||
</para>
|
||||
|
||||
|
||||
<!-- ##### STRUCT GdkPixbufAnimationIter ##### -->
|
||||
<para>
|
||||
A #GdkPixbufAnimationIter provides the necessary functionality to
|
||||
display an animation. See gdk_pixbuf_animation_get_iter().
|
||||
</para>
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gdk_pixbuf_animation_new_from_file ##### -->
|
||||
<para>
|
||||
|
||||
@@ -96,3 +84,68 @@ Animated images.
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gdk_pixbuf_animation_get_iter ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@animation:
|
||||
@start_time:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gdk_pixbuf_animation_is_static_image ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@animation:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gdk_pixbuf_animation_get_static_image ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@animation:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gdk_pixbuf_animation_iter_advance ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@iter:
|
||||
@current_time:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gdk_pixbuf_animation_iter_get_delay_time ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@iter:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gdk_pixbuf_animation_iter_on_currently_loading_frame ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@iter:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gdk_pixbuf_animation_iter_get_pixbuf ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@iter:
|
||||
@Returns:
|
||||
|
||||
|
||||
|
@@ -13,17 +13,17 @@ Creating a pixbuf from image data that is already in memory.
|
||||
data buffer needs to be freed; this will happen when a #GdkPixbuf
|
||||
is finalized by the reference counting functions If you have a
|
||||
chunk of static data compiled into your application, you can pass
|
||||
in #NULL as the destroy notification function so that the data
|
||||
in %NULL as the destroy notification function so that the data
|
||||
will not be freed.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The gdk_pixbuf_new() function can be used as a convenience to
|
||||
create a pixbuf with an empty buffer. This is equivalent to
|
||||
allocating a data buffer using malloc() and then wrapping it with
|
||||
gdk_pixbuf_new_from_data(). The gdk_pixbuf_new() function will
|
||||
compute an optimal rowstride so that rendering can be performed
|
||||
with an efficient algorithm.
|
||||
allocating a data buffer using <function>malloc()</function> and
|
||||
then wrapping it with gdk_pixbuf_new_from_data(). The gdk_pixbuf_new()
|
||||
function will compute an optimal rowstride so that rendering can be
|
||||
performed with an efficient algorithm.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
@@ -33,7 +33,7 @@ Creating a pixbuf from image data that is already in memory.
|
||||
|
||||
<para>
|
||||
You can also copy an existing pixbuf with the gdk_pixbuf_copy()
|
||||
function. This is not the same as just doing a gdk_pixbuf_ref()
|
||||
function. This is not the same as just doing a g_object_ref()
|
||||
on the old pixbuf; the copy function will actually duplicate the
|
||||
pixel data in memory and create a new #GdkPixbuf structure for it.
|
||||
</para>
|
||||
@@ -87,11 +87,14 @@ Creating a pixbuf from image data that is already in memory.
|
||||
|
||||
</para>
|
||||
|
||||
@inline_pixbuf:
|
||||
@data_length:
|
||||
@data:
|
||||
@copy_pixels:
|
||||
@length:
|
||||
@error:
|
||||
@Returns:
|
||||
<!-- # Unused Parameters # -->
|
||||
@inline_pixbuf:
|
||||
@length:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gdk_pixbuf_new_subpixbuf ##### -->
|
||||
|
@@ -1,8 +1,8 @@
|
||||
<!-- ##### SECTION Title ##### -->
|
||||
file-saving
|
||||
File saving
|
||||
|
||||
<!-- ##### SECTION Short_Description ##### -->
|
||||
|
||||
Saving a pixbuf to a file.
|
||||
|
||||
<!-- ##### SECTION Long_Description ##### -->
|
||||
<para>
|
||||
|
@@ -365,6 +365,15 @@ XlibRGB
|
||||
|
||||
@obj: A GTK+ object.
|
||||
|
||||
<!-- ##### ENUM GdkPixbufFrameAction ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@GDK_PIXBUF_FRAME_RETAIN:
|
||||
@GDK_PIXBUF_FRAME_DISPOSE:
|
||||
@GDK_PIXBUF_FRAME_REVERT:
|
||||
|
||||
<!-- ##### USER_FUNCTION GdkPixbufLastUnref ##### -->
|
||||
<para>
|
||||
A function of this type can be used to override the default
|
||||
@@ -552,3 +561,14 @@ End:
|
||||
</para>
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gdk_pixbuf_new_from_stream ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@stream_length:
|
||||
@stream:
|
||||
@copy_pixels:
|
||||
@error:
|
||||
@Returns:
|
||||
|
||||
|
@@ -14,7 +14,7 @@ Getting parts of an X drawable's image data into a pixbuf.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
These functions are analogous to those for the Gdk version of
|
||||
These functions are analogous to those for the GDK version of
|
||||
&gdk-pixbuf;.
|
||||
</para>
|
||||
|
||||
|
@@ -11,10 +11,8 @@ Initializing the &gdk-pixbuf; Xlib library.
|
||||
use #GdkPixbuf structures and render them to X drawables. The
|
||||
functions in this section are used to initialize the &gdk-pixbuf;
|
||||
Xlib library. This library must be initialized near the beginning
|
||||
or the program or before calling any of the other &gdk-pixbuf;
|
||||
Xlib functions; it cannot be initialized automatically since
|
||||
Xlib-only applications do not call gdk_rgb_init() like GNOME
|
||||
applications do.
|
||||
of the program or before calling any of the other &gdk-pixbuf;
|
||||
Xlib functions.
|
||||
</para>
|
||||
|
||||
<!-- ##### SECTION See_Also ##### -->
|
||||
|
@@ -12,7 +12,7 @@ Rendering a pixbuf to an X drawable.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
These functions are analogous to those for the Gdk version of
|
||||
These functions are analogous to those for the GDK version of
|
||||
&gdk-pixbuf;.
|
||||
</para>
|
||||
|
||||
@@ -86,7 +86,7 @@ Rendering a pixbuf to an X drawable.
|
||||
@mask_return:
|
||||
@alpha_threshold: <!--
|
||||
Local variables:
|
||||
mode: sgml
|
||||
Kode: sgml
|
||||
sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")
|
||||
End:
|
||||
-->
|
||||
|
@@ -2,11 +2,11 @@
|
||||
XlibRGB
|
||||
|
||||
<!-- ##### SECTION Short_Description ##### -->
|
||||
Functions for rendering RGB buffers to X drawables.
|
||||
Rendering RGB buffers to X drawables.
|
||||
|
||||
<!-- ##### SECTION Long_Description ##### -->
|
||||
<para>
|
||||
The XlibRGB set of functions is a port of the GdkRGB library to
|
||||
The XlibRGB set of functions is a port of the #GdkRGB library to
|
||||
use plain Xlib and X drawables. You can use these functions to
|
||||
render RGB buffers into drawables very quickly with high-quality
|
||||
dithering.
|
||||
|
@@ -6,7 +6,7 @@ Information that describes an image.
|
||||
|
||||
<!-- ##### SECTION Long_Description ##### -->
|
||||
|
||||
<para>
|
||||
<para><anchor id="GdkPixbuf">
|
||||
The <structname>GdkPixbuf</structname> structure contains
|
||||
information that describes an image in memory.
|
||||
</para>
|
||||
@@ -17,19 +17,24 @@ Information that describes an image.
|
||||
|
||||
<!-- ##### ENUM GdkPixbufError ##### -->
|
||||
<para>
|
||||
|
||||
An error code in the #GDK_PIXBUF_ERROR domain. Many &gdk-pixbuf;
|
||||
operations can cause errors in this domain, or in the #G_FILE_ERROR
|
||||
domain.
|
||||
</para>
|
||||
|
||||
@GDK_PIXBUF_ERROR_CORRUPT_IMAGE:
|
||||
@GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY:
|
||||
@GDK_PIXBUF_ERROR_BAD_OPTION_VALUE:
|
||||
@GDK_PIXBUF_ERROR_UNKNOWN_TYPE:
|
||||
@GDK_PIXBUF_ERROR_UNSUPPORTED_OPERATION:
|
||||
@GDK_PIXBUF_ERROR_FAILED:
|
||||
@GDK_PIXBUF_ERROR_CORRUPT_IMAGE: An image file was broken somehow.
|
||||
@GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY: Not enough memory.
|
||||
@GDK_PIXBUF_ERROR_BAD_OPTION: A bad option was passed to a pixbuf save module.
|
||||
@GDK_PIXBUF_ERROR_UNKNOWN_TYPE: Unknown image type.
|
||||
@GDK_PIXBUF_ERROR_UNSUPPORTED_OPERATION: Don't know how to perform the
|
||||
given operation on the type of image at hand.
|
||||
@GDK_PIXBUF_ERROR_FAILED: Generic failure code, something went wrong.
|
||||
|
||||
<!-- ##### MACRO GDK_PIXBUF_ERROR ##### -->
|
||||
<para>
|
||||
|
||||
Error domain used for pixbuf operations. Indicates that the error code
|
||||
will be in the #GdkPixbufError enumeration. See #GError for
|
||||
information on error domains and error codes.
|
||||
</para>
|
||||
|
||||
|
||||
@@ -147,3 +152,13 @@ End:
|
||||
-->
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gdk_pixbuf_get_option ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@pixbuf:
|
||||
@key:
|
||||
@Returns:
|
||||
|
||||
|
||||
|
@@ -3,10 +3,12 @@ Initialization and Versions
|
||||
|
||||
<!-- ##### SECTION Short_Description ##### -->
|
||||
|
||||
Library version numbers.
|
||||
|
||||
<!-- ##### SECTION Long_Description ##### -->
|
||||
<para>
|
||||
|
||||
These macros and variables let you check the version of &gdk-pixbuf;
|
||||
you're linking against.
|
||||
</para>
|
||||
|
||||
<!-- ##### SECTION See_Also ##### -->
|
||||
@@ -16,34 +18,40 @@ Initialization and Versions
|
||||
|
||||
<!-- ##### VARIABLE gdk_pixbuf_version ##### -->
|
||||
<para>
|
||||
|
||||
Contains the full version of the &gdk-pixbuf; library as a string.
|
||||
This is the version currently in use by a running program.
|
||||
</para>
|
||||
|
||||
|
||||
<!-- ##### MACRO GDK_PIXBUF_VERSION ##### -->
|
||||
<para>
|
||||
|
||||
Contains the full version of the &gdk-pixbuf; header as a string.
|
||||
This is the version being compiled against; contrast with
|
||||
#gdk_pixbuf_version.
|
||||
</para>
|
||||
|
||||
|
||||
|
||||
<!-- ##### MACRO GDK_PIXBUF_MAJOR ##### -->
|
||||
<para>
|
||||
|
||||
Major version of &gdk-pixbuf; library, that is the first "0" in
|
||||
"0.8.0" for example.
|
||||
</para>
|
||||
|
||||
|
||||
|
||||
<!-- ##### MACRO GDK_PIXBUF_MINOR ##### -->
|
||||
<para>
|
||||
|
||||
Minor version of &gdk-pixbuf; library, that is the "8" in
|
||||
"0.8.0" for example.
|
||||
</para>
|
||||
|
||||
|
||||
|
||||
<!-- ##### MACRO GDK_PIXBUF_MICRO ##### -->
|
||||
<para>
|
||||
|
||||
Micro version of &gdk-pixbuf; library, that is the last "0" in
|
||||
"0.8.0" for example.
|
||||
</para>
|
||||
|
||||
|
||||
|
126
docs/reference/gdk-pixbuf/tmpl/inline.sgml
Normal file
126
docs/reference/gdk-pixbuf/tmpl/inline.sgml
Normal file
@@ -0,0 +1,126 @@
|
||||
<!-- ##### SECTION Title ##### -->
|
||||
Inline data
|
||||
|
||||
<!-- ##### SECTION Short_Description ##### -->
|
||||
Functions for inlined pixbuf handling.
|
||||
|
||||
<!-- ##### SECTION Long_Description ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
<!-- ##### SECTION See_Also ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
<!-- ##### STRUCT GdkPixdata ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@magic:
|
||||
@length:
|
||||
@pixdata_type:
|
||||
@rowstride:
|
||||
@width:
|
||||
@height:
|
||||
@pixel_data:
|
||||
|
||||
<!-- ##### ENUM GdkPixdataType ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@GDK_PIXDATA_COLOR_TYPE_RGB:
|
||||
@GDK_PIXDATA_COLOR_TYPE_RGBA:
|
||||
@GDK_PIXDATA_COLOR_TYPE_MASK:
|
||||
@GDK_PIXDATA_SAMPLE_WIDTH_8:
|
||||
@GDK_PIXDATA_SAMPLE_WIDTH_MASK:
|
||||
@GDK_PIXDATA_ENCODING_RAW:
|
||||
@GDK_PIXDATA_ENCODING_RLE:
|
||||
@GDK_PIXDATA_ENCODING_MASK:
|
||||
|
||||
<!-- ##### ENUM GdkPixdataDumpType ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@GDK_PIXDATA_DUMP_PIXDATA_STREAM:
|
||||
@GDK_PIXDATA_DUMP_PIXDATA_STRUCT:
|
||||
@GDK_PIXDATA_DUMP_MACROS:
|
||||
@GDK_PIXDATA_DUMP_GTYPES:
|
||||
@GDK_PIXDATA_DUMP_CTYPES:
|
||||
@GDK_PIXDATA_DUMP_STATIC:
|
||||
@GDK_PIXDATA_DUMP_CONST:
|
||||
@GDK_PIXDATA_DUMP_RLE_DECODER:
|
||||
|
||||
<!-- ##### MACRO GDK_PIXBUF_MAGIC_NUMBER ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
|
||||
|
||||
<!-- ##### MACRO GDK_PIXDATA_HEADER_LENGTH ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gdk_pixdata_from_pixbuf ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@pixdata:
|
||||
@pixbuf:
|
||||
@use_rle:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gdk_pixbuf_from_pixdata ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@pixdata:
|
||||
@copy_pixels:
|
||||
@error:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gdk_pixdata_serialize ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@pixdata:
|
||||
@stream_length_p:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gdk_pixdata_deserialize ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@pixdata:
|
||||
@stream_length:
|
||||
@stream:
|
||||
@error:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gdk_pixdata_to_csource ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@pixdata:
|
||||
@name:
|
||||
@dump_type:
|
||||
@Returns:
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
Module Interface
|
||||
|
||||
<!-- ##### SECTION Short_Description ##### -->
|
||||
|
||||
Extending &gdk-pixbuf;
|
||||
|
||||
<!-- ##### SECTION Long_Description ##### -->
|
||||
<para>
|
||||
@@ -16,48 +16,71 @@ Module Interface
|
||||
|
||||
<!-- ##### USER_FUNCTION ModuleFillVtableFunc ##### -->
|
||||
<para>
|
||||
|
||||
Defines the type of the function used to set the vtable of a
|
||||
#GdkPixbufModule when it is loaded.
|
||||
</para>
|
||||
|
||||
@module:
|
||||
@module: a #GdkPixbufModule.
|
||||
|
||||
|
||||
<!-- ##### USER_FUNCTION ModulePreparedNotifyFunc ##### -->
|
||||
<para>
|
||||
|
||||
Defines the type of the function that gets called once the initial
|
||||
setup of @pixbuf is done.
|
||||
</para>
|
||||
<para>
|
||||
#GdkPixbufLoader uses a function of this type to emit the
|
||||
"<link linkend="GdkPixbufLoader-area-prepared">area_prepared</link>"
|
||||
signal.
|
||||
</para>
|
||||
|
||||
@pixbuf:
|
||||
@anim:
|
||||
@user_data:
|
||||
@pixbuf: the #GdkPixbuf that is currently being loaded.
|
||||
@anim: if an animation is being loaded, the #GdkPixbufAnimation, else %NULL.
|
||||
@user_data: the loader.
|
||||
|
||||
|
||||
<!-- ##### USER_FUNCTION ModuleUpdatedNotifyFunc ##### -->
|
||||
<para>
|
||||
|
||||
Defines the type of the function that gets called every time a region
|
||||
of @pixbuf is updated.
|
||||
</para>
|
||||
<para>
|
||||
#GdkPixbufLoader uses a function of this type to emit the
|
||||
"<link linkend="GdkPixbufLoader-area-updated">area_updated</link>"
|
||||
signal.
|
||||
</para>
|
||||
|
||||
@pixbuf:
|
||||
@x:
|
||||
@y:
|
||||
@width:
|
||||
@height:
|
||||
@user_data:
|
||||
@pixbuf: the #GdkPixbuf that is currently being loaded.
|
||||
@x: the X origin of the updated area.
|
||||
@y: the Y origin of the updated area.
|
||||
@width: the width of the updated area.
|
||||
@height: the height of the updated area.
|
||||
@user_data: the loader.
|
||||
|
||||
|
||||
<!-- ##### STRUCT GdkPixbufModule ##### -->
|
||||
<para>
|
||||
|
||||
A #GdkPixbufModule contains the necessary functions to load and save
|
||||
images in a certain file format.
|
||||
</para>
|
||||
<para>
|
||||
A #GdkPixbufModule can be loaded dynamically from a #GModule.
|
||||
Each loadable module must contain a #ModuleFillVtableFunc function named
|
||||
<function>gdk_pixbuf__<replaceable>module_name</replaceable>_fill_vtable</function>.
|
||||
It will get called when the module is loaded and must set the function
|
||||
pointers of the #GdkPixbufModule.
|
||||
</para>
|
||||
|
||||
@module_name:
|
||||
@format_check:
|
||||
@module:
|
||||
@load:
|
||||
@load_xpm_data:
|
||||
@begin_load:
|
||||
@stop_load:
|
||||
@load_increment:
|
||||
@load_animation:
|
||||
@save:
|
||||
@module_name: the name of the module, usually the same as the
|
||||
usual file extension for images of this type, eg. "xpm", "jpeg" or "png".
|
||||
@format_check: checks if the given data is the beginning of a valid image
|
||||
in the format supported by the module.
|
||||
@module: the loaded #GModule.
|
||||
@load: loads an image from a file.
|
||||
@load_xpm_data: loads an image from data in memory.
|
||||
@begin_load: begins an incremental load.
|
||||
@stop_load: stops an incremental load.
|
||||
@load_increment: continues an incremental load.
|
||||
@load_animation: loads an animation from a file.
|
||||
@save: saves a #GdkPixbuf to a file.
|
||||
|
||||
|
@@ -3,20 +3,28 @@ Reference Counting and Memory Mangement
|
||||
|
||||
<!-- ##### SECTION Short_Description ##### -->
|
||||
|
||||
Functions to perform reference counting and memory management on a
|
||||
#GdkPixbuf.
|
||||
Functions for reference counting and memory management on pixbufs.
|
||||
|
||||
<!-- ##### SECTION Long_Description ##### -->
|
||||
<para>
|
||||
#GdkPixbuf structures are reference counted. This means that
|
||||
an application can share a single pixbuf among many parts of the
|
||||
#GdkPixbuf structures are reference counted. This means that an
|
||||
application can share a single pixbuf among many parts of the
|
||||
code. When a piece of the program needs to keep a pointer to a
|
||||
pixbuf, it should add a reference to it. When it no longer needs
|
||||
the pixbuf, it should subtract a reference. The pixbuf will be
|
||||
destroyed when its reference count drops to zero. Newly-created
|
||||
#GdkPixbuf structures start with a reference count of one.
|
||||
pixbuf, it should add a reference to it by calling g_object_ref().
|
||||
When it no longer needs the pixbuf, it should subtract a reference
|
||||
by calling g_object_unref(). The pixbuf will be destroyed when
|
||||
its reference count drops to zero. Newly-created #GdkPixbuf
|
||||
structures start with a reference count of one.
|
||||
</para>
|
||||
|
||||
<note>
|
||||
<para>
|
||||
As #GdkPixbuf is derived from #GObject now, gdk_pixbuf_ref() and
|
||||
gdk_pixbuf_unref() are deprecated in favour of g_object_ref()
|
||||
and g_object_unref () resp.
|
||||
</para>
|
||||
</note>
|
||||
|
||||
<para>
|
||||
<emphasis>Finalizing</emphasis> a pixbuf means to free its pixel
|
||||
data and to free the #GdkPixbuf structure itself. Most of the
|
||||
@@ -35,7 +43,7 @@ Functions to perform reference counting and memory management on a
|
||||
<para>
|
||||
As an extension to traditional reference counting, #GdkPixbuf
|
||||
structures support defining a handler for the last unref
|
||||
operation. If gdk_pixbuf_unref() is called on a #GdkPixbuf
|
||||
operation. If g_object_unref() is called on a #GdkPixbuf
|
||||
structure that has a reference count of 1, i.e. its last
|
||||
reference, then the pixbuf's last unref handler function will be
|
||||
called. It is up to this function to determine whether to
|
||||
|
@@ -20,7 +20,7 @@ Scaling pixbufs and scaling and compositing pixbufs
|
||||
convenience functions are provided, gdk_pixbuf_scale_simple() and
|
||||
gdk_pixbuf_composite_color_simple() which create a new pixbuf of a
|
||||
given size, scale an original image to fit, and then return the
|
||||
new pixmap.
|
||||
new pixbuf.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
@@ -34,6 +34,8 @@ Scaling pixbufs and scaling and compositing pixbufs
|
||||
as calling gdk_pixbuf_scale().
|
||||
</para>
|
||||
|
||||
<example>
|
||||
<title>Handling an expose event.</title>
|
||||
<programlisting>
|
||||
gboolean
|
||||
expose_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data)
|
||||
@@ -62,16 +64,20 @@ expose_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data)
|
||||
return TRUE;
|
||||
}
|
||||
</programlisting>
|
||||
</example>
|
||||
|
||||
<!-- ##### SECTION See_Also ##### -->
|
||||
<para>
|
||||
GdkRGB
|
||||
<link linkend="gdk-GdkRGB">GdkRGB</link>.
|
||||
</para>
|
||||
|
||||
<!-- ##### ENUM GdkInterpType ##### -->
|
||||
<para>
|
||||
This enumeration describes the different interpolation modes that
|
||||
can be used with the scaling functions.
|
||||
can be used with the scaling functions. @GDK_INTERP_NEAREST is
|
||||
the fastest scaling method, but has horrible quality when
|
||||
scaling down. @GDK_INTERP_BILINEAR is the best choice if you
|
||||
aren't sure what to choose, it has a good speed/quality balance.
|
||||
|
||||
<note>
|
||||
<para>
|
||||
@@ -82,22 +88,36 @@ expose_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data)
|
||||
</para>
|
||||
|
||||
@GDK_INTERP_NEAREST: Nearest neighbor sampling; this is the fastest
|
||||
and lowest quality mode.
|
||||
and lowest quality mode. Quality is normally unacceptable when scaling
|
||||
down, but may be OK when scaling up.
|
||||
@GDK_INTERP_TILES: This is an accurate simulation of the PostScript
|
||||
image operator without any interpolation enabled. Each pixel is
|
||||
rendered as a tiny parallelogram of solid color, the edges of which
|
||||
are implemented with antialiasing. It resembles nearest neighbor for
|
||||
enlargement, and bilinear for reduction.
|
||||
@GDK_INTERP_BILINEAR: Bilinear interpolation. For enlargement, it is
|
||||
@GDK_INTERP_BILINEAR: Best quality/speed balance; use this mode by
|
||||
default. Bilinear interpolation. For enlargement, it is
|
||||
equivalent to point-sampling the ideal bilinear-interpolated image.
|
||||
For reduction, it is equivalent to laying down small tiles and
|
||||
integrating over the coverage area.
|
||||
@GDK_INTERP_HYPER: This is the slowest and highest quality
|
||||
reconstruction function. It is derived from the hyperbolic filters in
|
||||
reconstruction function. It is derived from the hyperbolic filters in
|
||||
Wolberg's "Digital Image Warping", and is formally defined as the
|
||||
hyperbolic-filter sampling the ideal hyperbolic-filter interpolated
|
||||
image (the filter is designed to be idempotent for 1:1 pixel mapping).
|
||||
|
||||
<!-- ##### FUNCTION gdk_pixbuf_scale_simple ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@src:
|
||||
@dest_width:
|
||||
@dest_height:
|
||||
@interp_type:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gdk_pixbuf_scale ##### -->
|
||||
<para>
|
||||
|
||||
@@ -116,6 +136,27 @@ image (the filter is designed to be idempotent for 1:1 pixel mapping).
|
||||
@interp_type:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gdk_pixbuf_composite_color_simple ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@src:
|
||||
@dest_width:
|
||||
@dest_height:
|
||||
@interp_type:
|
||||
@overall_alpha:
|
||||
@check_size:
|
||||
@color1:
|
||||
@color2:
|
||||
@Returns: <!--
|
||||
Local variables:
|
||||
mode: sgml
|
||||
sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")
|
||||
End:
|
||||
-->
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gdk_pixbuf_composite ##### -->
|
||||
<para>
|
||||
|
||||
@@ -159,36 +200,3 @@ image (the filter is designed to be idempotent for 1:1 pixel mapping).
|
||||
@color2:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gdk_pixbuf_scale_simple ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@src:
|
||||
@dest_width:
|
||||
@dest_height:
|
||||
@interp_type:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gdk_pixbuf_composite_color_simple ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@src:
|
||||
@dest_width:
|
||||
@dest_height:
|
||||
@interp_type:
|
||||
@overall_alpha:
|
||||
@check_size:
|
||||
@color1:
|
||||
@color2:
|
||||
@Returns: <!--
|
||||
Local variables:
|
||||
mode: sgml
|
||||
sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")
|
||||
End:
|
||||
-->
|
||||
|
||||
|
||||
|
@@ -61,3 +61,12 @@ End:
|
||||
@pixelate:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gdk_pixbuf_fill ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@pixbuf:
|
||||
@pixel:
|
||||
|
||||
|
||||
|
@@ -7,6 +7,7 @@ gdk.signals
|
||||
gdk.hierarchy
|
||||
gdk-decl.txt
|
||||
gdk-decl-list.txt
|
||||
gdk-undocumented.txt
|
||||
gdk-unused.txt
|
||||
*.stamp
|
||||
*.lo
|
||||
|
@@ -13,7 +13,7 @@ DOC_SOURCE_DIR=../../../gdk
|
||||
SCAN_OPTIONS=--deprecated-guards="GDK_ENABLE_BROKEN|GDK_DISABLE_DEPRECATED"
|
||||
|
||||
# Extra options to supply to gtkdoc-mkdb
|
||||
MKDB_OPTIONS=
|
||||
MKDB_OPTIONS=--sgml-mode
|
||||
|
||||
# Extra options to supply to gtkdoc-fixref
|
||||
FIXXREF_OPTIONS=--extra-dir=../gdk-pixbuf/html
|
||||
@@ -39,7 +39,84 @@ EXTRA_HFILES= \
|
||||
../../../gdk/x11/gdkx.h
|
||||
|
||||
# Images to copy into HTML directory
|
||||
HTML_IMAGES =
|
||||
HTML_IMAGES = \
|
||||
images/X_cursor.png \
|
||||
images/arrow.png \
|
||||
images/based_arrow_down.png \
|
||||
images/based_arrow_up.png \
|
||||
images/boat.png \
|
||||
images/bogosity.png \
|
||||
images/bottom_left_corner.png \
|
||||
images/bottom_right_corner.png \
|
||||
images/bottom_side.png \
|
||||
images/bottom_tee.png \
|
||||
images/box_spiral.png \
|
||||
images/center_ptr.png \
|
||||
images/circle.png \
|
||||
images/clock.png \
|
||||
images/coffee_mug.png \
|
||||
images/cross.png \
|
||||
images/cross_reverse.png \
|
||||
images/crosshair.png \
|
||||
images/diamond_cross.png \
|
||||
images/dot.png \
|
||||
images/dotbox.png \
|
||||
images/double_arrow.png \
|
||||
images/draft_large.png \
|
||||
images/draft_small.png \
|
||||
images/draped_box.png \
|
||||
images/exchange.png \
|
||||
images/fleur.png \
|
||||
images/gobbler.png \
|
||||
images/gumby.png \
|
||||
images/hand1.png \
|
||||
images/hand2.png \
|
||||
images/heart.png \
|
||||
images/icon.png \
|
||||
images/iron_cross.png \
|
||||
images/left_ptr.png \
|
||||
images/left_side.png \
|
||||
images/left_tee.png \
|
||||
images/leftbutton.png \
|
||||
images/ll_angle.png \
|
||||
images/lr_angle.png \
|
||||
images/man.png \
|
||||
images/middlebutton.png \
|
||||
images/mouse.png \
|
||||
images/pencil.png \
|
||||
images/pirate.png \
|
||||
images/plus.png \
|
||||
images/question_arrow.png \
|
||||
images/right_ptr.png \
|
||||
images/right_side.png \
|
||||
images/right_tee.png \
|
||||
images/rightbutton.png \
|
||||
images/rtl_logo.png \
|
||||
images/sailboat.png \
|
||||
images/sb_down_arrow.png \
|
||||
images/sb_h_double_arrow.png \
|
||||
images/sb_left_arrow.png \
|
||||
images/sb_right_arrow.png \
|
||||
images/sb_up_arrow.png \
|
||||
images/sb_v_double_arrow.png \
|
||||
images/shuttle.png \
|
||||
images/sizing.png \
|
||||
images/spider.png \
|
||||
images/spraycan.png \
|
||||
images/star.png \
|
||||
images/target.png \
|
||||
images/tcross.png \
|
||||
images/top_left_arrow.png \
|
||||
images/top_left_corner.png \
|
||||
images/top_right_corner.png \
|
||||
images/top_side.png \
|
||||
images/top_tee.png \
|
||||
images/trek.png \
|
||||
images/ul_angle.png \
|
||||
images/umbrella.png \
|
||||
images/ur_angle.png \
|
||||
images/watch.png \
|
||||
images/xterm.png
|
||||
|
||||
# Extra SGML files that are included by DOC_MAIN_SGML_FILE
|
||||
content_files =
|
||||
@@ -61,6 +138,13 @@ GTKDOC_LD=$(LIBTOOL) --mode=link $(CC)
|
||||
# Everything below here is generic #
|
||||
####################################
|
||||
|
||||
# We set GPATH here; this gives us semantics for GNU make
|
||||
# which are more like other make's VPATH, when it comes to
|
||||
# whether a source that is a target of one rule is then
|
||||
# searched for in VPATH/GPATH.
|
||||
#
|
||||
GPATH = $(srcdir)
|
||||
|
||||
TARGET_DIR=$(HTML_DIR)/$(DOC_MODULE)
|
||||
|
||||
EXTRA_DIST = \
|
||||
@@ -114,7 +198,7 @@ tmpl.stamp: tmpl-build.stamp
|
||||
|
||||
#### sgml ####
|
||||
|
||||
sgml-build.stamp: tmpl.stamp $(CFILE_GLOB)
|
||||
sgml-build.stamp: tmpl.stamp $(CFILE_GLOB) $(srcdir)/tmpl/*.sgml
|
||||
@echo '*** Building SGML ***'
|
||||
cd $(srcdir) && \
|
||||
gtkdoc-mkdb --module=$(DOC_MODULE) --source-dir=$(DOC_SOURCE_DIR) $(MKDB_OPTIONS)
|
||||
@@ -127,7 +211,8 @@ sgml.stamp: sgml-build.stamp
|
||||
|
||||
html-build.stamp: sgml.stamp $(DOC_MAIN_SGML_FILE) $(content_files)
|
||||
@echo '*** Building HTML ***'
|
||||
test -d $(srcdir)/html || mkdir $(srcdir)/html
|
||||
rm -rf $(srcdir)/html
|
||||
mkdir $(srcdir)/html
|
||||
cd $(srcdir)/html && gtkdoc-mkhtml $(DOC_MODULE) ../$(DOC_MAIN_SGML_FILE)
|
||||
test "x$(HTML_IMAGES)" = "x" || ( cd $(srcdir) && cp $(HTML_IMAGES) html )
|
||||
@echo '-- Fixing Crossreferences'
|
||||
@@ -145,8 +230,8 @@ maintainer-clean-local: clean
|
||||
|
||||
install-data-local:
|
||||
$(mkinstalldirs) $(DESTDIR)$(TARGET_DIR)
|
||||
(installfiles=`echo $(srcdir)/html/*.html`; \
|
||||
if test "$$installfiles" = '$(srcdir)/html/*.html'; \
|
||||
(installfiles=`echo $(srcdir)/html/*`; \
|
||||
if test "$$installfiles" = '$(srcdir)/html/*'; \
|
||||
then echo '-- Nothing to install' ; \
|
||||
else \
|
||||
for i in $$installfiles; do \
|
||||
@@ -174,12 +259,6 @@ dist-hook: dist-check-gtkdoc dist-hook-local
|
||||
mkdir $(distdir)/html
|
||||
-cp $(srcdir)/tmpl/*.sgml $(distdir)/tmpl
|
||||
-cp $(srcdir)/sgml/*.sgml $(distdir)/sgml
|
||||
-cp $(srcdir)/html/index.sgml $(distdir)/html
|
||||
-cp $(srcdir)/html/*.html $(srcdir)/html/*.css $(distdir)/html
|
||||
|
||||
images=$(HTML_IMAGES) ; \
|
||||
for i in $$images ; do \
|
||||
cp $(srcdir)/$$i $(distdir)/html ; \
|
||||
done
|
||||
-cp $(srcdir)/html/* $(distdir)/html
|
||||
|
||||
.PHONY : dist-hook-local
|
||||
|
@@ -1,4 +1,7 @@
|
||||
<!doctype book PUBLIC "-//Davenport//DTD DocBook V3.0//EN" [
|
||||
<!notation PNG system "PNG">
|
||||
<!entity % local.notation.class "| PNG">
|
||||
|
||||
<!entity gdk-General SYSTEM "sgml/general.sgml">
|
||||
<!entity gdk-Bitmaps-and-Pixmaps SYSTEM "sgml/pixmaps.sgml">
|
||||
<!entity gdk-Images SYSTEM "sgml/images.sgml">
|
||||
@@ -22,6 +25,10 @@
|
||||
<!entity gdk-Cursors SYSTEM "sgml/cursors.sgml">
|
||||
<!entity gdk-Input SYSTEM "sgml/input.sgml">
|
||||
<!entity gdk-Drag-and-Drop SYSTEM "sgml/dnd.sgml">
|
||||
<!entity gdk-Multihead SYSTEM "sgml/multihead.sgml">
|
||||
<!entity gdk-Screen SYSTEM "sgml/gdkscreen.sgml">
|
||||
<!entity gdk-Display SYSTEM "sgml/gdkdisplay.sgml">
|
||||
<!entity gdk-Virtual-screen SYSTEM "sgml/virtual_screen.sgml">
|
||||
<!entity gdk-X-Window-System-Interaction SYSTEM "sgml/x_interaction.sgml">
|
||||
]>
|
||||
|
||||
@@ -30,7 +37,7 @@
|
||||
<title>GDK Reference Manual</title>
|
||||
</bookinfo>
|
||||
|
||||
<reference id="reference">
|
||||
<chapter id="reference" role="no-toc">
|
||||
<title>API Reference</title>
|
||||
&gdk-General;
|
||||
|
||||
@@ -69,6 +76,12 @@
|
||||
|
||||
&gdk-Pango-Interaction;
|
||||
|
||||
|
||||
&gdk-Multihead;
|
||||
&gdk-Screen;
|
||||
&gdk-Display;
|
||||
&gdk-Virtual-screen;
|
||||
|
||||
&gdk-X-Window-System-Interaction;
|
||||
</reference>
|
||||
</chapter>
|
||||
</book>
|
||||
|
@@ -29,6 +29,11 @@ struct GdkDrawable
|
||||
};
|
||||
</STRUCT>
|
||||
|
||||
# GdkAtom is an opaque typedef
|
||||
<STRUCT>
|
||||
<NAME>GdkAtom</NAME>
|
||||
</STRUCT>
|
||||
|
||||
<MACRO>
|
||||
<NAME>GDK_WINDOWING_X11</NAME>
|
||||
#define GDK_WINDOWING_X11
|
||||
@@ -39,11 +44,6 @@ struct GdkDrawable
|
||||
#define GDK_WINDOWING_WIN32
|
||||
</MACRO>
|
||||
|
||||
<MACRO>
|
||||
<NAME>GDK_WINDOWING_NANOX</NAME>
|
||||
#define GDK_WINDOWING_NANOX
|
||||
</MACRO>
|
||||
|
||||
<MACRO>
|
||||
<NAME>GDK_WINDOWING_FB</NAME>
|
||||
#define GDK_WINDOWING_FB
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user