From: Jim Evins Date: Sun, 28 Dec 2003 00:13:29 +0000 (+0000) Subject: 2003-12-27 Jim Evins X-Git-Tag: glabels-2_3_0~505 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=374483b9c1e3bd3054a71d6b502c02218baee4c5;p=glabels 2003-12-27 Jim Evins * configure.in: Updated to work with latest gnome-common package from CVS. Removed recursive configuration of barcode-0.98. * acconfig.h: * macros/*: Removed. * Makefile.am: Added barcode-0.98/ as a SUBDIR, and removed dist-hook. * barcode-0.98/Makefile.in: * barcode-0.98/configure.in: * barcode-0.98/Makefile.am: * barcode-0.98/README.glabels: Modified to ignore the barcode package's build system, and build as a part of glabels. Renamed Makefile.in to Makefile.in.dist. Renamed configure.in to configure.in.dist. Added barcode-0.98/Makefile.am and barcode-0.98/README.glabels. * src/Makefile.am: * src/mygal/Makefile.am: * src/recent-files/Makefile.am: In order to build against the GNOME 2.5 platform, all use of *_DISABLE_DEPRECATED compile-time flags has been removed. * src/mygal/Makefile.am: * src/mygal/mygal-combo-box.c: * src/mygal/mygal-combo-box.h: * src/mygal/widget-color-combo.c: * src/mygal/widget-color-combo.h: * po/POTFILES.in: In order to build against the GNOME 2.5 platform, Renamed gtk_combo_box widget to mygal_combo_box, to prevent namespace collisions with the real gtk_combo_box widget, now a part of gtk. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@390 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- diff --git a/glabels2/ChangeLog b/glabels2/ChangeLog index dc06d5ac..3cc321f7 100644 --- a/glabels2/ChangeLog +++ b/glabels2/ChangeLog @@ -1,3 +1,42 @@ +2003-12-27 Jim Evins + + * configure.in: + Updated to work with latest gnome-common package from CVS. + Removed recursive configuration of barcode-0.98. + + * acconfig.h: + * macros/*: + Removed. + + * Makefile.am: + Added barcode-0.98/ as a SUBDIR, and removed dist-hook. + + * barcode-0.98/Makefile.in: + * barcode-0.98/configure.in: + * barcode-0.98/Makefile.am: + * barcode-0.98/README.glabels: + Modified to ignore the barcode package's build system, and build + as a part of glabels. + Renamed Makefile.in to Makefile.in.dist. + Renamed configure.in to configure.in.dist. + Added barcode-0.98/Makefile.am and barcode-0.98/README.glabels. + + * src/Makefile.am: + * src/mygal/Makefile.am: + * src/recent-files/Makefile.am: + In order to build against the GNOME 2.5 platform, + all use of *_DISABLE_DEPRECATED compile-time flags has been removed. + + * src/mygal/Makefile.am: + * src/mygal/mygal-combo-box.c: + * src/mygal/mygal-combo-box.h: + * src/mygal/widget-color-combo.c: + * src/mygal/widget-color-combo.h: + * po/POTFILES.in: + In order to build against the GNOME 2.5 platform, + Renamed gtk_combo_box widget to mygal_combo_box, to prevent namespace + collisions with the real gtk_combo_box widget, now a part of gtk. + 2003-12-26 Jim Evins * src/paper.c: diff --git a/glabels2/Makefile.am b/glabels2/Makefile.am index 415edfe8..56d5fac5 100644 --- a/glabels2/Makefile.am +++ b/glabels2/Makefile.am @@ -2,7 +2,7 @@ LIB_BARCODE_DIR = barcode-0.98 -SUBDIRS = po src data pixmaps doc +SUBDIRS = po $(LIB_BARCODE_DIR) src data pixmaps doc EXTRA_DIST = \ README \ @@ -18,11 +18,3 @@ EXTRA_DIST = \ glabels.spec.in \ glabels.spec -dist-hook: - if test -d $(LIB_BARCODE_DIR); then \ - if test -f $(LIB_BARCODE_DIR)/Makefile; then \ - (cd $(LIB_BARCODE_DIR); $(MAKE) distclean); \ - fi; \ - mkdir $(distdir)/$(LIB_BARCODE_DIR); \ - cp -rp $(LIB_BARCODE_DIR)/* $(distdir)/$(LIB_BARCODE_DIR); \ - fi diff --git a/glabels2/acconfig.h b/glabels2/acconfig.h deleted file mode 100644 index 5d5943a5..00000000 --- a/glabels2/acconfig.h +++ /dev/null @@ -1,9 +0,0 @@ -#undef ENABLE_NLS -#undef HAVE_CATGETS -#undef HAVE_GETTEXT -#undef HAVE_LC_MESSAGES -#undef HAVE_STPCPY -#undef PACKAGE -#undef VERSION -#undef HAVE_LIBSM -#undef GETTEXT_PACKAGE diff --git a/glabels2/barcode-0.98/Makefile.in b/glabels2/barcode-0.98/Makefile.in index 848aa265..c43a7436 100644 --- a/glabels2/barcode-0.98/Makefile.in +++ b/glabels2/barcode-0.98/Makefile.in @@ -1,141 +1,456 @@ -# -# This Makefile should run fine with both pmake and gmake -# +# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am +# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +DESTDIR = + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +host_alias = @host_alias@ +host_triplet = @host@ +AS = @AS@ +CATALOGS = @CATALOGS@ +CATOBJEXT = @CATOBJEXT@ CC = @CC@ -CFLAGS = @CFLAGS@ @DEFS@ @NO_GETOPT@ @NO_LIBPAPER@ @NO_STRERROR@ +DATADIRNAME = @DATADIRNAME@ +DLLTOOL = @DLLTOOL@ +ECHO = @ECHO@ +EXEEXT = @EXEEXT@ +GENCAT = @GENCAT@ +GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ +GLABELS_CFLAGS = @GLABELS_CFLAGS@ +GLABELS_LIBS = @GLABELS_LIBS@ +GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ +GMOFILES = @GMOFILES@ +GMSGFMT = @GMSGFMT@ +GT_NO = @GT_NO@ +GT_YES = @GT_YES@ +INCLUDE_LOCALE_H = @INCLUDE_LOCALE_H@ +INSTOBJEXT = @INSTOBJEXT@ +INTLDEPS = @INTLDEPS@ +INTLLIBS = @INTLLIBS@ +INTLOBJS = @INTLOBJS@ +INTLTOOL_CAVES_RULE = @INTLTOOL_CAVES_RULE@ +INTLTOOL_DESKTOP_RULE = @INTLTOOL_DESKTOP_RULE@ +INTLTOOL_DIRECTORY_RULE = @INTLTOOL_DIRECTORY_RULE@ +INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ +INTLTOOL_KEYS_RULE = @INTLTOOL_KEYS_RULE@ +INTLTOOL_MERGE = @INTLTOOL_MERGE@ +INTLTOOL_OAF_RULE = @INTLTOOL_OAF_RULE@ +INTLTOOL_PERL = @INTLTOOL_PERL@ +INTLTOOL_PONG_RULE = @INTLTOOL_PONG_RULE@ +INTLTOOL_PROP_RULE = @INTLTOOL_PROP_RULE@ +INTLTOOL_SCHEMAS_RULE = @INTLTOOL_SCHEMAS_RULE@ +INTLTOOL_SERVER_RULE = @INTLTOOL_SERVER_RULE@ +INTLTOOL_SHEET_RULE = @INTLTOOL_SHEET_RULE@ +INTLTOOL_SOUNDLIST_RULE = @INTLTOOL_SOUNDLIST_RULE@ +INTLTOOL_THEME_RULE = @INTLTOOL_THEME_RULE@ +INTLTOOL_UI_RULE = @INTLTOOL_UI_RULE@ +INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ +INTLTOOL_XML_RULE = @INTLTOOL_XML_RULE@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MKINSTALLDIRS = @MKINSTALLDIRS@ +MSGFMT = @MSGFMT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PKG_CONFIG = @PKG_CONFIG@ +POFILES = @POFILES@ +POSUB = @POSUB@ +PO_IN_DATADIR_FALSE = @PO_IN_DATADIR_FALSE@ +PO_IN_DATADIR_TRUE = @PO_IN_DATADIR_TRUE@ RANLIB = @RANLIB@ +STRIP = @STRIP@ +USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@ +USE_NLS = @USE_NLS@ +VERSION = @VERSION@ +WARN_CFLAGS = @WARN_CFLAGS@ +WARN_CXXFLAGS = @WARN_CXXFLAGS@ +l = @l@ + +INCLUDES = \ + $(GLABELS_CFLAGS) + + +BC_FILES = \ + library.c \ + ean.c \ + code128.c \ + code39.c \ + code93.c \ + i25.c \ + msi.c \ + plessey.c \ + codabar.c \ + ps.c \ + pcl.c \ + barcode.h + + +noinst_LTLIBRARIES = libbarcode.la + +libbarcode_la_SOURCES = $(BC_FILES) + +EXTRA_DIST = \ + barcode.spec \ + ChangeLog \ + cmdline.c \ + cmdline.h \ + config.status \ + configure \ + configure.in.dist \ + COPYING \ + INSTALL \ + install-sh \ + main.c \ + Makefile.in.dist \ + missing \ + mkinstalldirs \ + README \ + README.glabels \ + sample.c \ + TODO \ + bookland/bookland.py \ + compat/getopt.c \ + compat/getopt.h \ + contrib/barcode-for-delphi.tar.gz \ + contrib/barcode-SVG.tar.gz.README \ + contrib/barcode-for-delphi.tar.gz.README \ + contrib/barcodeps-0.1.tgz \ + contrib/grab-0.0.4.tar.gz \ + contrib/barcodeps-0.1.tgz.README \ + contrib/grab-0.0.4.tar.gz.README \ + contrib/barcode-SVG.tar.gz \ + debian/changelog \ + debian/control \ + debian/copyright \ + debian/dirs \ + debian/info \ + debian/README.debian \ + debian/rules \ + doc/barcodedoc.txt \ + doc/barcode.ps \ + doc/infofilter \ + doc/manpager \ + doc/texi2html \ + doc/barcode.info \ + doc/Makefile \ + doc/mktxt \ + doc/barcode.pdf \ + doc/doc.barcode \ + doc/Makefile.in \ + doc/README \ + po/Makefile.in.in + +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../config.h +CONFIG_CLEAN_FILES = +LTLIBRARIES = $(noinst_LTLIBRARIES) + + +DEFS = @DEFS@ -I. -I$(srcdir) -I.. +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +libbarcode_la_LDFLAGS = +libbarcode_la_LIBADD = +libbarcode_la_OBJECTS = library.lo ean.lo code128.lo code39.lo \ +code93.lo i25.lo msi.lo plessey.lo codabar.lo ps.lo pcl.lo +CFLAGS = @CFLAGS@ +COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ +DIST_COMMON = README COPYING ChangeLog INSTALL Makefile.am Makefile.in \ +TODO configure install-sh missing mkinstalldirs + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = gtar +GZIP_ENV = --best +DEP_FILES = .deps/codabar.P .deps/code128.P .deps/code39.P \ +.deps/code93.P .deps/ean.P .deps/i25.P .deps/library.P .deps/msi.P \ +.deps/pcl.P .deps/plessey.P .deps/ps.P +SOURCES = $(libbarcode_la_SOURCES) +OBJECTS = $(libbarcode_la_OBJECTS) + +all: all-redirect +.SUFFIXES: +.SUFFIXES: .S .c .lo .o .obj .s +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu barcode-0.98/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + + +mostlyclean-noinstLTLIBRARIES: + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + +distclean-noinstLTLIBRARIES: + +maintainer-clean-noinstLTLIBRARIES: + +# FIXME: We should only use cygpath when building on Windows, +# and only if it is available. +.c.obj: + $(COMPILE) -c `cygpath -w $<` + +.s.o: + $(COMPILE) -c $< + +.S.o: + $(COMPILE) -c $< + +mostlyclean-compile: + -rm -f *.o core *.core + -rm -f *.$(OBJEXT) + +clean-compile: + +distclean-compile: + -rm -f *.tab.c + +maintainer-clean-compile: + +.s.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +.S.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + +maintainer-clean-libtool: + +libbarcode.la: $(libbarcode_la_OBJECTS) $(libbarcode_la_DEPENDENCIES) + $(LINK) $(libbarcode_la_LDFLAGS) $(libbarcode_la_OBJECTS) $(libbarcode_la_LIBADD) $(LIBS) + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + here=`pwd` && cd $(srcdir) \ + && mkid -f$$here/ID $$unique $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) + +mostlyclean-tags: + +clean-tags: -INSTALL = @INSTALL@ +distclean-tags: + -rm -f TAGS ID -LDFLAGS = -L. -l$(TARGET) @LIBPAPER@ +maintainer-clean-tags: -prefix = @prefix@ -BINDIR = $(prefix)/bin -LIBDIR = $(prefix)/lib -INCDIR = $(prefix)/include -MAN1DIR = $(prefix)/man/man1 -MAN3DIR = $(prefix)/man/man3 -INFODIR = $(prefix)/info - -# getopt may be installed or not, if not take our copy -GETOPT_O = @GETOPT_O@ - -TARGET = barcode -LIBRARY = lib$(TARGET).a -MAN1 = $(TARGET).1 -MAN3 = $(TARGET).3 -INFO = doc/$(TARGET).info -HEADER = $(TARGET).h - -LIBOBJECTS = library.o ean.o code128.o code39.o code93.o i25.o \ - msi.o plessey.o codabar.o \ - ps.o pcl.o -EXEOBJECTS = main.o cmdline.o $(GETOPT_O) -ALLSOURCES = $(LIBOBJECTS:.o=.c) $(EXEOBJECT:.o=.c) - - -#Hmm... "RM" is undefined in pmake -RM = rm - -all: $(TARGET) $(LIBRARY) $(MAN1) $(MAN3) $(INFO) sample - -$(TARGET): $(LIBRARY) $(EXEOBJECTS) - $(CC) $(CFLAGS) $(EXEOBJECTS) $(LDFLAGS) -o $(TARGET) - -sample: sample.o $(LIBRARY) - $(CC) $(CFLAGS) sample.o $(LDFLAGS) -o $@ - -# Avoid the standard CFLAGS, to avoid -Wall and -DNO_GETOPT -compat/getopt.o: compat/getopt.c - $(CC) -O -c compat/getopt.c -o $@ - -$(LIBRARY): $(LIBOBJECTS) - $(AR) r $(LIBRARY) $(LIBOBJECTS) - $(RANLIB) $(LIBRARY) - -$(MAN1) $(MAN3): doc/doc.$(TARGET) - awk -f doc/manpager doc/doc.$(TARGET) - - -# Unfortunately, pmake has no "-C". Also, "pmake -n" doesn't follow the cd. -$(INFO): doc/doc.$(TARGET) - cd doc && $(MAKE) - -install: - $(INSTALL) -d $(BINDIR) $(INCDIR) $(LIBDIR) $(MAN1DIR) \ - $(MAN3DIR) $(INFODIR) - $(INSTALL) -c $(TARGET) $(BINDIR) - $(INSTALL) -c -m 0644 $(HEADER) $(INCDIR) - $(INSTALL) -c -m 0644 $(LIBRARY) $(LIBDIR) - $(INSTALL) -c -m 0644 $(MAN1) $(MAN1DIR) - $(INSTALL) -c -m 0644 $(MAN3) $(MAN3DIR) - $(INSTALL) -c -m 0644 $(INFO) $(INFODIR) - -uninstall: - $(RM) -f $(BINDIR)/$(TARGET) - $(RM) -f $(INCDIR)/$(HEADER) - $(RM) -f $(LIBDIR)/$(LIBRARY) - $(RM) -f $(MAN1DIR)/$(MAN1) - $(RM) -f $(MAN3DIR)/$(MAN3) - $(RM) -f $(INDODIR)/$(INFO) - -#Make clean keeps the compiled documents -clean: - $(RM) -f *.o */*.o *~ */*~ $(TARGET) $(LIBRARY) - $(RM) -f $(MAN1) $(MAN3) core sample - cd doc && $(MAKE) terse - $(RM) -f .depend - -distclean: clean - if [ -f build ]; then debian/rules clean; fi - # remove the configure stuff as well - $(RM) -f Makefile config.h config.log config.status config.cache \ - doc/Makefile - -cleanest: clean - cd doc && $(MAKE) clean - -Makefile: Makefile.in configure - ./configure - -configure: configure.in - autoconf - -.depend: $(ALLSOURCES) - $(CC) $(CFLAGS) -MM $(ALLSOURCES) > $@ - -depend: .depend - -tar: - @if [ "x" = "x$(RELEASE)" ]; then \ - n=`basename \`pwd\``; cd ..; tar cvf - $$n | gzip > $$n.tar.gz; \ - echo 'you can set a numeric $$(RELEASE) to make a named tar'; \ - else \ - if [ -d ../$(TARGET)-$(RELEASE) ]; then \ - rm -rf ../$(TARGET)-$(RELEASE); \ - fi; \ - mkdir ../$(TARGET)-$(RELEASE) || exit 1; \ - cp -a . ../$(TARGET)-$(RELEASE) && cd .. && \ - tar --exclude '*/CVS*' \ - -cvzf $(TARGET)-$(RELEASE).tar.gz $(TARGET)-$(RELEASE); \ - fi - -# print the version, as I usually forget to update it when distributing -printv: - @grep -n VERSION $(HEADER) /dev/null - @grep -n set.version doc/doc.$(TARGET) /dev/null - @grep -n dpkg.-i INSTALL /dev/null - -# and this is how I make the distribution -distrib: $(INFO) distclean tar printv - - -.PHONY: all install uninstall mostlyclean clean disclean depend \ - tar printv distrib +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) -# Only if make is gmake, have a rule to conditionally include .depend -@GMAKEDEPEND0@ -@GMAKEDEPEND1@ -@GMAKEDEPEND2@ +subdir = barcode-0.98 +distdir: $(DISTFILES) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(top_distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu barcode-0.98/Makefile + $(mkinstalldirs) $(distdir)/bookland $(distdir)/compat \ + $(distdir)/contrib $(distdir)/debian $(distdir)/doc \ + $(distdir)/po + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pr $$d/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done + +DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :) + +-include $(DEP_FILES) + +mostlyclean-depend: + +clean-depend: + +distclean-depend: + -rm -rf .deps + +maintainer-clean-depend: + +%.o: %.c + @echo '$(COMPILE) -c $<'; \ + $(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-cp .deps/$(*F).pp .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm .deps/$(*F).pp + +%.lo: %.c + @echo '$(LTCOMPILE) -c $<'; \ + $(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \ + < .deps/$(*F).pp > .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm -f .deps/$(*F).pp +info-am: +info: info-am +dvi-am: +dvi: dvi-am +check-am: all-am +check: check-am +installcheck-am: +installcheck: installcheck-am +install-exec-am: +install-exec: install-exec-am + +install-data-am: +install-data: install-data-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-am +uninstall-am: +uninstall: uninstall-am +all-am: Makefile $(LTLIBRARIES) +all-redirect: all-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install +installdirs: + + +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: +mostlyclean-am: mostlyclean-noinstLTLIBRARIES mostlyclean-compile \ + mostlyclean-libtool mostlyclean-tags mostlyclean-depend \ + mostlyclean-generic + +mostlyclean: mostlyclean-am + +clean-am: clean-noinstLTLIBRARIES clean-compile clean-libtool \ + clean-tags clean-depend clean-generic mostlyclean-am + +clean: clean-am + +distclean-am: distclean-noinstLTLIBRARIES distclean-compile \ + distclean-libtool distclean-tags distclean-depend \ + distclean-generic clean-am + -rm -f libtool + +distclean: distclean-am + +maintainer-clean-am: maintainer-clean-noinstLTLIBRARIES \ + maintainer-clean-compile maintainer-clean-libtool \ + maintainer-clean-tags maintainer-clean-depend \ + maintainer-clean-generic distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-am + +.PHONY: mostlyclean-noinstLTLIBRARIES distclean-noinstLTLIBRARIES \ +clean-noinstLTLIBRARIES maintainer-clean-noinstLTLIBRARIES \ +mostlyclean-compile distclean-compile clean-compile \ +maintainer-clean-compile mostlyclean-libtool distclean-libtool \ +clean-libtool maintainer-clean-libtool tags mostlyclean-tags \ +distclean-tags clean-tags maintainer-clean-tags distdir \ +mostlyclean-depend distclean-depend clean-depend \ +maintainer-clean-depend info-am info dvi-am dvi check check-am \ +installcheck-am installcheck install-exec-am install-exec \ +install-data-am install-data install-am install uninstall-am uninstall \ +all-redirect all-am all installdirs mostlyclean-generic \ +distclean-generic clean-generic maintainer-clean-generic clean \ +mostlyclean distclean maintainer-clean + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/glabels2/barcode-0.98/Makefile.in.dist b/glabels2/barcode-0.98/Makefile.in.dist new file mode 100644 index 00000000..848aa265 --- /dev/null +++ b/glabels2/barcode-0.98/Makefile.in.dist @@ -0,0 +1,141 @@ +# +# This Makefile should run fine with both pmake and gmake +# + +CC = @CC@ +CFLAGS = @CFLAGS@ @DEFS@ @NO_GETOPT@ @NO_LIBPAPER@ @NO_STRERROR@ +RANLIB = @RANLIB@ + +INSTALL = @INSTALL@ + +LDFLAGS = -L. -l$(TARGET) @LIBPAPER@ + +prefix = @prefix@ +BINDIR = $(prefix)/bin +LIBDIR = $(prefix)/lib +INCDIR = $(prefix)/include +MAN1DIR = $(prefix)/man/man1 +MAN3DIR = $(prefix)/man/man3 +INFODIR = $(prefix)/info + +# getopt may be installed or not, if not take our copy +GETOPT_O = @GETOPT_O@ + +TARGET = barcode +LIBRARY = lib$(TARGET).a +MAN1 = $(TARGET).1 +MAN3 = $(TARGET).3 +INFO = doc/$(TARGET).info +HEADER = $(TARGET).h + +LIBOBJECTS = library.o ean.o code128.o code39.o code93.o i25.o \ + msi.o plessey.o codabar.o \ + ps.o pcl.o +EXEOBJECTS = main.o cmdline.o $(GETOPT_O) +ALLSOURCES = $(LIBOBJECTS:.o=.c) $(EXEOBJECT:.o=.c) + + +#Hmm... "RM" is undefined in pmake +RM = rm + +all: $(TARGET) $(LIBRARY) $(MAN1) $(MAN3) $(INFO) sample + +$(TARGET): $(LIBRARY) $(EXEOBJECTS) + $(CC) $(CFLAGS) $(EXEOBJECTS) $(LDFLAGS) -o $(TARGET) + +sample: sample.o $(LIBRARY) + $(CC) $(CFLAGS) sample.o $(LDFLAGS) -o $@ + +# Avoid the standard CFLAGS, to avoid -Wall and -DNO_GETOPT +compat/getopt.o: compat/getopt.c + $(CC) -O -c compat/getopt.c -o $@ + +$(LIBRARY): $(LIBOBJECTS) + $(AR) r $(LIBRARY) $(LIBOBJECTS) + $(RANLIB) $(LIBRARY) + +$(MAN1) $(MAN3): doc/doc.$(TARGET) + awk -f doc/manpager doc/doc.$(TARGET) + + +# Unfortunately, pmake has no "-C". Also, "pmake -n" doesn't follow the cd. +$(INFO): doc/doc.$(TARGET) + cd doc && $(MAKE) + +install: + $(INSTALL) -d $(BINDIR) $(INCDIR) $(LIBDIR) $(MAN1DIR) \ + $(MAN3DIR) $(INFODIR) + $(INSTALL) -c $(TARGET) $(BINDIR) + $(INSTALL) -c -m 0644 $(HEADER) $(INCDIR) + $(INSTALL) -c -m 0644 $(LIBRARY) $(LIBDIR) + $(INSTALL) -c -m 0644 $(MAN1) $(MAN1DIR) + $(INSTALL) -c -m 0644 $(MAN3) $(MAN3DIR) + $(INSTALL) -c -m 0644 $(INFO) $(INFODIR) + +uninstall: + $(RM) -f $(BINDIR)/$(TARGET) + $(RM) -f $(INCDIR)/$(HEADER) + $(RM) -f $(LIBDIR)/$(LIBRARY) + $(RM) -f $(MAN1DIR)/$(MAN1) + $(RM) -f $(MAN3DIR)/$(MAN3) + $(RM) -f $(INDODIR)/$(INFO) + +#Make clean keeps the compiled documents +clean: + $(RM) -f *.o */*.o *~ */*~ $(TARGET) $(LIBRARY) + $(RM) -f $(MAN1) $(MAN3) core sample + cd doc && $(MAKE) terse + $(RM) -f .depend + +distclean: clean + if [ -f build ]; then debian/rules clean; fi + # remove the configure stuff as well + $(RM) -f Makefile config.h config.log config.status config.cache \ + doc/Makefile + +cleanest: clean + cd doc && $(MAKE) clean + +Makefile: Makefile.in configure + ./configure + +configure: configure.in + autoconf + +.depend: $(ALLSOURCES) + $(CC) $(CFLAGS) -MM $(ALLSOURCES) > $@ + +depend: .depend + +tar: + @if [ "x" = "x$(RELEASE)" ]; then \ + n=`basename \`pwd\``; cd ..; tar cvf - $$n | gzip > $$n.tar.gz; \ + echo 'you can set a numeric $$(RELEASE) to make a named tar'; \ + else \ + if [ -d ../$(TARGET)-$(RELEASE) ]; then \ + rm -rf ../$(TARGET)-$(RELEASE); \ + fi; \ + mkdir ../$(TARGET)-$(RELEASE) || exit 1; \ + cp -a . ../$(TARGET)-$(RELEASE) && cd .. && \ + tar --exclude '*/CVS*' \ + -cvzf $(TARGET)-$(RELEASE).tar.gz $(TARGET)-$(RELEASE); \ + fi + +# print the version, as I usually forget to update it when distributing +printv: + @grep -n VERSION $(HEADER) /dev/null + @grep -n set.version doc/doc.$(TARGET) /dev/null + @grep -n dpkg.-i INSTALL /dev/null + +# and this is how I make the distribution +distrib: $(INFO) distclean tar printv + + +.PHONY: all install uninstall mostlyclean clean disclean depend \ + tar printv distrib + +# Only if make is gmake, have a rule to conditionally include .depend +@GMAKEDEPEND0@ +@GMAKEDEPEND1@ +@GMAKEDEPEND2@ + diff --git a/glabels2/barcode-0.98/README.glabels b/glabels2/barcode-0.98/README.glabels new file mode 100644 index 00000000..b0dc9592 --- /dev/null +++ b/glabels2/barcode-0.98/README.glabels @@ -0,0 +1,7 @@ +The following changes have been made to the stock barcode-0.98 distribution +to facilitate compilation with glabels: + + Makefile.in renamed to Makefile.in.dist + configure.in renamed to configure.in.dist + added Makefile.am, which is configured from ../configure.in + diff --git a/glabels2/barcode-0.98/configure.in b/glabels2/barcode-0.98/configure.in deleted file mode 100644 index 07120b48..00000000 --- a/glabels2/barcode-0.98/configure.in +++ /dev/null @@ -1,65 +0,0 @@ -dnl Process this file with autoconf to produce a configure script. - -AC_INIT(barcode.h) -AC_PREREQ(2.12) - -AC_PROG_CC -AC_PROG_RANLIB -AC_PROG_INSTALL - -dnl Add "-Wall" if this is gcc -if test x$GCC = xyes; then - CFLAGS="$CFLAGS -Wall" -fi - - -dnl Check for getopt and libpaper. If getopt is missing, use our version -AC_CHECK_HEADER(getopt.h, ,NO_GETOPT=-DNO_GETOPT;GETOPT_O=compat/getopt.o) -AC_CHECK_HEADER(paper.h, LIBPAPER=-lpaper, NO_LIBPAPER=-DNO_LIBPAPER) -AC_CHECK_HEADERS(unistd.h) - -AC_CHECK_FUNC(strerror, , NO_STRERROR=-DNO_STRERROR) -AC_CHECK_FUNCS(strcasecmp) - -dnl Check if this is gmake, but allow ovverriding using $MAKE -AC_MSG_CHECKING("for gmake") -GMAKE=no -${MAKE=make} --version 2> /dev/null | grep GNU > /dev/null && GMAKE=yes -AC_MSG_RESULT($GMAKE) -if test "$GMAKE" = "yes"; then - GMAKEDEPEND0='ifeq (.depend,$(wildcard .depend))' - GMAKEDEPEND1='include .depend' - GMAKEDEPEND2='endif' -fi - -dnl Check if we use makeinfo or the local texi2html tool -AC_MSG_CHECKING("if makeinfo can output html") -MAKEINFOHTML=no -${MAKEINFO=makeinfo} --help | grep .--html > /dev/null && MAKEINFOHTML=yes -AC_MSG_RESULT($MAKEINFOHTML) -if test "$MAKEINFOHTML" = "yes"; then - REMOVEHTMLTAGS="cat" - INFOTOHTML="$MAKEINFO --html" -else - REMOVEHTMLTAGS="sed 's/ifnottex/ifinfo/; s/ifnotinfo/iftex/'" - INFOTOHTML="perl texi2html -monolithic" -fi - - -AC_SUBST(GETOPT_O) -AC_SUBST(NO_GETOPT) -AC_SUBST(NO_LIBPAPER) -AC_SUBST(LIBPAPER) -AC_SUBST(NO_STRERROR) -AC_SUBST(GMAKEDEPEND0) -AC_SUBST(GMAKEDEPEND1) -AC_SUBST(GMAKEDEPEND2) - -AC_OUTPUT(Makefile) - -AC_SUBST(MAKEINFO) -AC_SUBST(REMOVEHTMLTAGS) -AC_SUBST(INFOTOHTML) - -AC_OUTPUT(doc/Makefile) - diff --git a/glabels2/barcode-0.98/configure.in.dist b/glabels2/barcode-0.98/configure.in.dist new file mode 100644 index 00000000..07120b48 --- /dev/null +++ b/glabels2/barcode-0.98/configure.in.dist @@ -0,0 +1,65 @@ +dnl Process this file with autoconf to produce a configure script. + +AC_INIT(barcode.h) +AC_PREREQ(2.12) + +AC_PROG_CC +AC_PROG_RANLIB +AC_PROG_INSTALL + +dnl Add "-Wall" if this is gcc +if test x$GCC = xyes; then + CFLAGS="$CFLAGS -Wall" +fi + + +dnl Check for getopt and libpaper. If getopt is missing, use our version +AC_CHECK_HEADER(getopt.h, ,NO_GETOPT=-DNO_GETOPT;GETOPT_O=compat/getopt.o) +AC_CHECK_HEADER(paper.h, LIBPAPER=-lpaper, NO_LIBPAPER=-DNO_LIBPAPER) +AC_CHECK_HEADERS(unistd.h) + +AC_CHECK_FUNC(strerror, , NO_STRERROR=-DNO_STRERROR) +AC_CHECK_FUNCS(strcasecmp) + +dnl Check if this is gmake, but allow ovverriding using $MAKE +AC_MSG_CHECKING("for gmake") +GMAKE=no +${MAKE=make} --version 2> /dev/null | grep GNU > /dev/null && GMAKE=yes +AC_MSG_RESULT($GMAKE) +if test "$GMAKE" = "yes"; then + GMAKEDEPEND0='ifeq (.depend,$(wildcard .depend))' + GMAKEDEPEND1='include .depend' + GMAKEDEPEND2='endif' +fi + +dnl Check if we use makeinfo or the local texi2html tool +AC_MSG_CHECKING("if makeinfo can output html") +MAKEINFOHTML=no +${MAKEINFO=makeinfo} --help | grep .--html > /dev/null && MAKEINFOHTML=yes +AC_MSG_RESULT($MAKEINFOHTML) +if test "$MAKEINFOHTML" = "yes"; then + REMOVEHTMLTAGS="cat" + INFOTOHTML="$MAKEINFO --html" +else + REMOVEHTMLTAGS="sed 's/ifnottex/ifinfo/; s/ifnotinfo/iftex/'" + INFOTOHTML="perl texi2html -monolithic" +fi + + +AC_SUBST(GETOPT_O) +AC_SUBST(NO_GETOPT) +AC_SUBST(NO_LIBPAPER) +AC_SUBST(LIBPAPER) +AC_SUBST(NO_STRERROR) +AC_SUBST(GMAKEDEPEND0) +AC_SUBST(GMAKEDEPEND1) +AC_SUBST(GMAKEDEPEND2) + +AC_OUTPUT(Makefile) + +AC_SUBST(MAKEINFO) +AC_SUBST(REMOVEHTMLTAGS) +AC_SUBST(INFOTOHTML) + +AC_OUTPUT(doc/Makefile) + diff --git a/glabels2/configure.in b/glabels2/configure.in index c71f4f62..f6bcbaf7 100644 --- a/glabels2/configure.in +++ b/glabels2/configure.in @@ -13,9 +13,6 @@ AC_PROG_INTLTOOL([0.21]) AM_PROG_LIBTOOL -GNOME_PLATFORM_GNOME_2(yes, force) -GNOME_COMMON_INIT - AC_ISC_POSIX AC_PROG_CC AM_PROG_CC_STDC @@ -59,24 +56,18 @@ dnl **************************************** dnl Add the languages which your application supports here. GETTEXT_PACKAGE=glabels AC_SUBST(GETTEXT_PACKAGE) -AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE") +AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [Gettext package]) ALL_LINGUAS="fr de ja pt_BR es ru zh_TW.Big5 pl cs it" AM_GLIB_GNU_GETTEXT -dnl **************************************** -dnl * Configure barcode library -dnl **************************************** -AC_CONFIG_SUBDIRS(barcode-0.98) - - - dnl **************************************** dnl * Makefiles dnl **************************************** AC_OUTPUT([ Makefile +barcode-0.98/Makefile src/Makefile src/pixmaps/Makefile src/stock-pixmaps/Makefile diff --git a/glabels2/po/POTFILES.in b/glabels2/po/POTFILES.in index 632b3911..9e4795a5 100644 --- a/glabels2/po/POTFILES.in +++ b/glabels2/po/POTFILES.in @@ -149,8 +149,8 @@ src/mygal/color-palette.h src/mygal/e-colors.c src/mygal/e-colors.h src/mygal/e-util.h -src/mygal/gtk-combo-box.c -src/mygal/gtk-combo-box.h +src/mygal/mygal-combo-box.c +src/mygal/mygal-combo-box.h src/mygal/widget-color-combo.c src/mygal/widget-color-combo.h data/paper-sizes.xml diff --git a/glabels2/src/Makefile.am b/glabels2/src/Makefile.am index 19de0b58..9df6c1b0 100644 --- a/glabels2/src/Makefile.am +++ b/glabels2/src/Makefile.am @@ -19,12 +19,7 @@ INCLUDES = \ -DLIBDIR=\""$(libdir)"\" \ -DGLABELS_LOCALEDIR=\""$(datadir)/locale"\" \ -DGLABELS_UI_DIR=\""$(datadir)/glabels/ui/"\" \ - -DGLABELS_GLADE_DIR=\""$(datadir)/glabels/glade/"\" \ - -DG_DISABLE_DEPRECATED \ - -DGDK_DISABLE_DEPRECATED \ - -DGTK_DISABLE_DEPRECATED \ - -DGDK_PIXBUF_DISABLE_DEPRECATED \ - -DGNOME_DISABLE_DEPRECATED + -DGLABELS_GLADE_DIR=\""$(datadir)/glabels/glade/"\" glabels_LDFLAGS = -export-dynamic @@ -32,13 +27,13 @@ glabels_LDADD = \ $(GLABELS_LIBS) \ mygal/libmygal.la \ recent-files/librecent.la \ - -L$(LIB_BARCODE_DIR) -lbarcode + $(LIB_BARCODE_DIR)/libbarcode.la glabels_batch_LDFLAGS = -export-dynamic glabels_batch_LDADD = \ $(GLABELS_LIBS) \ - -L$(LIB_BARCODE_DIR) -lbarcode + $(LIB_BARCODE_DIR)/libbarcode.la BUILT_SOURCES = \ marshal.c \ @@ -270,18 +265,8 @@ EXTRA_DIST = \ CLEANFILES = $(BUILT_SOURCES) -$(bin_PROGRAMS): $(LIB_BARCODE_DIR)/libbarcode.a +$(bin_PROGRAMS): $(LIB_BARCODE_DIR)/libbarcode.la -$(LIB_BARCODE_DIR)/libbarcode.a: +$(LIB_BARCODE_DIR)/libbarcode.la: cd $(LIB_BARCODE_DIR); $(MAKE) -clean: barcode_clean - -barcode_clean: - cd $(LIB_BARCODE_DIR); $(MAKE) clean - -distclean maintainer-clean: barcode_distclean - -barcode_distclean: - cd $(LIB_BARCODE_DIR); $(MAKE) distclean - diff --git a/glabels2/src/mygal/Makefile.am b/glabels2/src/mygal/Makefile.am index a0847044..c4f29d46 100644 --- a/glabels2/src/mygal/Makefile.am +++ b/glabels2/src/mygal/Makefile.am @@ -1,10 +1,6 @@ INCLUDES = \ - $(GLABELS_CFLAGS) \ - -DG_DISABLE_DEPRECATED \ - -DGDK_DISABLE_DEPRECATED \ - -DGTK_DISABLE_DEPRECATED \ - -DGDK_PIXBUF_DISABLE_DEPRECATED \ - -DGNOME_DISABLE_DEPRECATED + $(GLABELS_CFLAGS) + noinst_LTLIBRARIES = libmygal.la @@ -14,8 +10,8 @@ libmygal_la_SOURCES = \ e-util.h \ e-colors.c \ e-colors.h \ - gtk-combo-box.c \ - gtk-combo-box.h \ + mygal-combo-box.c \ + mygal-combo-box.h \ color-palette.c \ color-palette.h \ color-group.c \ diff --git a/glabels2/src/mygal/gtk-combo-box.c b/glabels2/src/mygal/gtk-combo-box.c deleted file mode 100644 index 21b2e902..00000000 --- a/glabels2/src/mygal/gtk-combo-box.c +++ /dev/null @@ -1,837 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gtk-combo-box.c - a customizable combobox - * Copyright 2000, 2001, Ximian, Inc. - * - * Authors: - * Miguel de Icaza (miguel@gnu.org) - * Adrian E Feiguin (feiguin@ifir.edu.ar) - * Paolo Molnaro (lupus@debian.org). - * Jon K Hellan (hellan@acm.org) - * - * Modified for gLabels by: - * Jim Evins - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License, version 2, as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "gtk-combo-box.h" -#include "e-util.h" - -#define PARENT_TYPE GTK_TYPE_HBOX -static GObjectClass *gtk_combo_box_parent_class; - -static int gtk_combo_toggle_pressed (GtkToggleButton *tbutton, - GtkComboBox *combo_box); -static void gtk_combo_popup_tear_off (GtkComboBox *combo, - gboolean set_position); -static void gtk_combo_set_tearoff_state (GtkComboBox *combo, - gboolean torn_off); -static void gtk_combo_popup_reparent (GtkWidget *popup, GtkWidget *new_parent, - gboolean unrealize); -static gboolean cb_popup_delete (GtkWidget *w, GdkEventAny *event, - GtkComboBox *combo); -static void gtk_combo_tearoff_bg_copy (GtkComboBox *combo); - -enum { - POP_DOWN_WIDGET, - POP_DOWN_DONE, - PRE_POP_DOWN, - POST_POP_HIDE, - LAST_SIGNAL -}; - -static guint gtk_combo_box_signals [LAST_SIGNAL] = { 0, }; - -struct _GtkComboBoxPrivate { - GtkWidget *pop_down_widget; - GtkWidget *display_widget; - - /* - * Internal widgets used to implement the ComboBox - */ - GtkWidget *frame; - GtkWidget *arrow_button; - - GtkWidget *toplevel; /* Popup's toplevel when not torn off */ - GtkWidget *tearoff_window; /* Popup's toplevel when torn off */ - guint torn_off; - - GtkWidget *tearable; /* The tearoff "button" */ - GtkWidget *popup; /* Popup */ - - /* - * Closure for invoking the callbacks above - */ - void *closure; -}; - -static void -gtk_combo_box_finalize (GObject *object) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (object); - - g_free (combo_box->priv); - - gtk_combo_box_parent_class->finalize (object); -} - -static void -gtk_combo_box_destroy (GtkObject *object) -{ - GtkObjectClass *klass = (GtkObjectClass *)gtk_combo_box_parent_class; - GtkComboBox *combo_box = GTK_COMBO_BOX (object); - - if (combo_box->priv->toplevel) { - gtk_object_destroy (GTK_OBJECT (combo_box->priv->toplevel)); - combo_box->priv->toplevel = NULL; - } - - if (combo_box->priv->tearoff_window) { - gtk_object_destroy (GTK_OBJECT (combo_box->priv->tearoff_window)); - combo_box->priv->tearoff_window = NULL; - } - - if (klass->destroy) - klass->destroy (object); -} - -static gboolean -gtk_combo_box_mnemonic_activate (GtkWidget *w, gboolean group_cycling) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (w); - gtk_toggle_button_set_active ( - GTK_TOGGLE_BUTTON (combo_box->priv->arrow_button), TRUE); - return TRUE; -} - -static void -gtk_combo_box_class_init (GObjectClass *object_class) -{ - GtkWidgetClass *widget_class = (GtkWidgetClass *)object_class; - gtk_combo_box_parent_class = g_type_class_peek_parent (object_class); - - object_class->finalize = gtk_combo_box_finalize; - widget_class->mnemonic_activate = gtk_combo_box_mnemonic_activate; - ((GtkObjectClass *)object_class)->destroy = gtk_combo_box_destroy; - - gtk_combo_box_signals [POP_DOWN_WIDGET] = g_signal_new ( - "pop_down_widget", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GtkComboBoxClass, pop_down_widget), - NULL, NULL, - e_marshal_POINTER__NONE, - G_TYPE_POINTER, 0, G_TYPE_NONE); - - gtk_combo_box_signals [POP_DOWN_DONE] = g_signal_new ( - "pop_down_done", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GtkComboBoxClass, pop_down_done), - NULL, NULL, - e_marshal_BOOLEAN__OBJECT, - G_TYPE_BOOLEAN, 1, G_TYPE_OBJECT); - - gtk_combo_box_signals [PRE_POP_DOWN] = g_signal_new ( - "pre_pop_down", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GtkComboBoxClass, pre_pop_down), - NULL, NULL, - e_marshal_NONE__NONE, - G_TYPE_NONE, 0); - - gtk_combo_box_signals [POST_POP_HIDE] = g_signal_new ( - "post_pop_hide", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GtkComboBoxClass, post_pop_hide), - NULL, NULL, - e_marshal_NONE__NONE, - G_TYPE_NONE, 0); -} - -static void -deactivate_arrow (GtkComboBox *combo_box) -{ - GtkToggleButton *arrow; - - arrow = GTK_TOGGLE_BUTTON (combo_box->priv->arrow_button); - g_signal_handlers_block_matched (arrow, - G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, - 0, 0, NULL, - gtk_combo_toggle_pressed, combo_box); - - gtk_toggle_button_set_active (arrow, FALSE); - - g_signal_handlers_unblock_matched (arrow, - G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, - 0, 0, NULL, - gtk_combo_toggle_pressed, combo_box); -} - -/** - * gtk_combo_box_popup_hide_unconditional - * @combo_box: Combo box - * - * Hide popup, whether or not it is torn off. - */ -static void -gtk_combo_box_popup_hide_unconditional (GtkComboBox *combo_box) -{ - gboolean popup_info_destroyed = FALSE; - - g_return_if_fail (combo_box != NULL); - g_return_if_fail (GTK_IS_COMBO_BOX (combo_box)); - - gtk_widget_hide (combo_box->priv->toplevel); - gtk_widget_hide (combo_box->priv->popup); - if (combo_box->priv->torn_off) { - GTK_TEAROFF_MENU_ITEM (combo_box->priv->tearable)->torn_off - = FALSE; - gtk_combo_set_tearoff_state (combo_box, FALSE); - } - - gtk_grab_remove (combo_box->priv->toplevel); - gdk_pointer_ungrab (GDK_CURRENT_TIME); - - g_object_ref (combo_box->priv->pop_down_widget); - g_signal_emit (combo_box, - gtk_combo_box_signals [POP_DOWN_DONE], 0, - combo_box->priv->pop_down_widget, &popup_info_destroyed); - - if (popup_info_destroyed){ - gtk_container_remove ( - GTK_CONTAINER (combo_box->priv->frame), - combo_box->priv->pop_down_widget); - combo_box->priv->pop_down_widget = NULL; - } - g_object_unref (combo_box->priv->pop_down_widget); - deactivate_arrow (combo_box); - - g_signal_emit (combo_box, gtk_combo_box_signals [POST_POP_HIDE], 0); -} - -/** - * gtk_combo_box_popup_hide: - * @combo_box: Combo box - * - * Hide popup, but not when it is torn off. - * This is the external interface - for subclasses and apps which expect a - * regular combo which doesn't do tearoffs. - */ -void -gtk_combo_box_popup_hide (GtkComboBox *combo_box) -{ - if (!combo_box->priv->torn_off) - gtk_combo_box_popup_hide_unconditional (combo_box); - else if (GTK_WIDGET_VISIBLE (combo_box->priv->toplevel)) { - /* Both popup and tearoff window present. Get rid of just - the popup shell. */ - gtk_combo_popup_tear_off (combo_box, FALSE); - deactivate_arrow (combo_box); - } -} - -/* - * Find best location for displaying - */ -void -gtk_combo_box_get_pos (GtkComboBox *combo_box, int *x, int *y) -{ - GtkWidget *wcombo = GTK_WIDGET (combo_box); - int ph, pw; - - gdk_window_get_origin (wcombo->window, x, y); - *y += wcombo->allocation.height + wcombo->allocation.y; - *x += wcombo->allocation.x; - - ph = combo_box->priv->popup->allocation.height; - pw = combo_box->priv->popup->allocation.width; - - if ((*y + ph) > gdk_screen_height ()) - *y = gdk_screen_height () - ph; - - if ((*x + pw) > gdk_screen_width ()) - *x = gdk_screen_width () - pw; -} - -static void -gtk_combo_box_popup_display (GtkComboBox *combo_box) -{ - int x, y; - - g_return_if_fail (combo_box != NULL); - g_return_if_fail (GTK_IS_COMBO_BOX (combo_box)); - - /* - * If we have no widget to display on the popdown, - * create it - */ - if (!combo_box->priv->pop_down_widget){ - GtkWidget *pw = NULL; - - g_signal_emit (combo_box, - gtk_combo_box_signals [POP_DOWN_WIDGET], 0, &pw); - g_assert (pw != NULL); - combo_box->priv->pop_down_widget = pw; - gtk_container_add (GTK_CONTAINER (combo_box->priv->frame), pw); - } - - g_signal_emit (combo_box, gtk_combo_box_signals [PRE_POP_DOWN], 0); - - if (combo_box->priv->torn_off) { - /* To give the illusion that tearoff still displays the - * popup, we copy the image in the popup window to the - * background. Thus, it won't be blank after reparenting */ - gtk_combo_tearoff_bg_copy (combo_box); - - /* We force an unrealize here so that we don't trigger - * redrawing/ clearing code - we just want to reveal our - * backing pixmap. - */ - gtk_combo_popup_reparent (combo_box->priv->popup, - combo_box->priv->toplevel, TRUE); - } - - gtk_combo_box_get_pos (combo_box, &x, &y); - - gtk_widget_set_uposition (combo_box->priv->toplevel, x, y); - gtk_widget_realize (combo_box->priv->popup); - gtk_widget_show (combo_box->priv->popup); - gtk_widget_realize (combo_box->priv->toplevel); - gtk_widget_show (combo_box->priv->toplevel); - - gtk_grab_add (combo_box->priv->toplevel); - gdk_pointer_grab (combo_box->priv->toplevel->window, TRUE, - GDK_BUTTON_PRESS_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_POINTER_MOTION_MASK, - NULL, NULL, GDK_CURRENT_TIME); -} - -static int -gtk_combo_toggle_pressed (GtkToggleButton *tbutton, GtkComboBox *combo_box) -{ - if (tbutton->active) - gtk_combo_box_popup_display (combo_box); - else - gtk_combo_box_popup_hide_unconditional (combo_box); - - return TRUE; -} - -static gint -gtk_combo_box_button_press (GtkWidget *widget, GdkEventButton *event, GtkComboBox *combo_box) -{ - GtkWidget *child; - - child = gtk_get_event_widget ((GdkEvent *) event); - if (child != widget){ - while (child){ - if (child == widget) - return FALSE; - child = child->parent; - } - } - - gtk_combo_box_popup_hide (combo_box); - return TRUE; -} - -/** - * gtk_combo_box_key_press - * @widget: Widget - * @event: Event - * @combo_box: Combo box - * - * Key press handler which dismisses popup on escape. - * Popup is dismissed whether or not popup is torn off. - */ -static gint -gtk_combo_box_key_press (GtkWidget *widget, GdkEventKey *event, - GtkComboBox *combo_box) -{ - if (event->keyval == GDK_Escape) { - gtk_combo_box_popup_hide_unconditional (combo_box); - return TRUE; - } else - return FALSE; -} - -static void -cb_state_change (GtkWidget *widget, GtkStateType old_state, GtkComboBox *combo_box) -{ - GtkStateType const new_state = GTK_WIDGET_STATE(widget); - gtk_widget_set_state (combo_box->priv->display_widget, new_state); -} - -static void -gtk_combo_box_init (GtkComboBox *combo_box) -{ - GtkWidget *arrow; - GdkCursor *cursor; - - combo_box->priv = g_new0 (GtkComboBoxPrivate, 1); - - /* - * Create the arrow - */ - combo_box->priv->arrow_button = gtk_toggle_button_new (); - gtk_button_set_relief (GTK_BUTTON (combo_box->priv->arrow_button), GTK_RELIEF_NONE); - GTK_WIDGET_UNSET_FLAGS (combo_box->priv->arrow_button, GTK_CAN_FOCUS); - - arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_IN); - gtk_container_add (GTK_CONTAINER (combo_box->priv->arrow_button), arrow); - gtk_box_pack_end (GTK_BOX (combo_box), combo_box->priv->arrow_button, FALSE, FALSE, 0); - g_signal_connect (combo_box->priv->arrow_button, "toggled", - G_CALLBACK (gtk_combo_toggle_pressed), combo_box); - gtk_widget_show_all (combo_box->priv->arrow_button); - - /* - * prelight the display widget when mousing over the arrow. - */ - g_signal_connect (combo_box->priv->arrow_button, "state-changed", - G_CALLBACK (cb_state_change), combo_box); - - /* - * The pop-down container - */ - - combo_box->priv->toplevel = gtk_window_new (GTK_WINDOW_POPUP); - gtk_widget_ref (combo_box->priv->toplevel); - gtk_object_sink (GTK_OBJECT (combo_box->priv->toplevel)); - gtk_window_set_policy (GTK_WINDOW (combo_box->priv->toplevel), - FALSE, TRUE, FALSE); - - combo_box->priv->popup = gtk_event_box_new (); - gtk_container_add (GTK_CONTAINER (combo_box->priv->toplevel), - combo_box->priv->popup); - gtk_widget_show (combo_box->priv->popup); - - gtk_widget_realize (combo_box->priv->popup); - cursor = gdk_cursor_new (GDK_TOP_LEFT_ARROW); - gdk_window_set_cursor (combo_box->priv->popup->window, cursor); - gdk_cursor_unref (cursor); - - combo_box->priv->torn_off = FALSE; - combo_box->priv->tearoff_window = NULL; - - combo_box->priv->frame = gtk_frame_new (NULL); - gtk_container_add (GTK_CONTAINER (combo_box->priv->popup), - combo_box->priv->frame); - gtk_frame_set_shadow_type (GTK_FRAME (combo_box->priv->frame), GTK_SHADOW_OUT); - - g_signal_connect (combo_box->priv->toplevel, "button_press_event", - G_CALLBACK (gtk_combo_box_button_press), combo_box); - g_signal_connect (combo_box->priv->toplevel, "key_press_event", - G_CALLBACK (gtk_combo_box_key_press), combo_box); -} - -E_MAKE_TYPE (gtk_combo_box, - "MyGtkComboBox", - GtkComboBox, - gtk_combo_box_class_init, - gtk_combo_box_init, - PARENT_TYPE) - -/** - * gtk_combo_box_set_display: - * @combo_box: the Combo Box to modify - * @display_widget: The widget to be displayed - - * Sets the displayed widget for the @combo_box to be @display_widget - */ -void -gtk_combo_box_set_display (GtkComboBox *combo_box, GtkWidget *display_widget) -{ - g_return_if_fail (combo_box != NULL); - g_return_if_fail (GTK_IS_COMBO_BOX (combo_box)); - g_return_if_fail (display_widget != NULL); - g_return_if_fail (GTK_IS_WIDGET (display_widget)); - - if (combo_box->priv->display_widget && - combo_box->priv->display_widget != display_widget) - gtk_container_remove (GTK_CONTAINER (combo_box), - combo_box->priv->display_widget); - - combo_box->priv->display_widget = display_widget; - - gtk_box_pack_start (GTK_BOX (combo_box), display_widget, TRUE, TRUE, 0); -} - -static gboolean -cb_tearable_enter_leave (GtkWidget *w, GdkEventCrossing *event, gpointer data) -{ - gboolean const flag = GPOINTER_TO_INT(data); - gtk_widget_set_state (w, flag ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL); - return FALSE; -} - -/** - * gtk_combo_popup_tear_off - * @combo: Combo box - * @set_position: Set to position of popup shell if true - * - * Tear off the popup - * - * FIXME: - * Gtk popup menus are toplevel windows, not dialogs. I think this is wrong, - * and make the popups dialogs. But may be there should be a way to make - * them toplevel. We can do this after creating: - * GTK_WINDOW (tearoff)->type = GTK_WINDOW_TOPLEVEL; - */ -static void -gtk_combo_popup_tear_off (GtkComboBox *combo, gboolean set_position) -{ - int x, y; - - if (!combo->priv->tearoff_window) { - GtkWidget *tearoff; - gchar *title; - - /* FIXME: made this a toplevel, not a dialog ! */ - tearoff = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_widget_ref (tearoff); - gtk_object_sink (GTK_OBJECT (tearoff)); - combo->priv->tearoff_window = tearoff; - gtk_widget_set_app_paintable (tearoff, TRUE); - g_signal_connect (tearoff, "key_press_event", - G_CALLBACK (gtk_combo_box_key_press), - combo); - gtk_widget_realize (tearoff); - title = g_object_get_data (G_OBJECT (combo), - "gtk-combo-title"); - if (title) - gdk_window_set_title (tearoff->window, title); - gtk_window_set_policy (GTK_WINDOW (tearoff), - FALSE, TRUE, FALSE); - gtk_window_set_transient_for - (GTK_WINDOW (tearoff), - GTK_WINDOW (gtk_widget_get_toplevel - GTK_WIDGET (combo))); - } - - if (GTK_WIDGET_VISIBLE (combo->priv->popup)) { - gtk_widget_hide (combo->priv->toplevel); - - gtk_grab_remove (combo->priv->toplevel); - gdk_pointer_ungrab (GDK_CURRENT_TIME); - } - - gtk_combo_popup_reparent (combo->priv->popup, - combo->priv->tearoff_window, FALSE); - - /* It may have got confused about size */ - gtk_widget_queue_resize (GTK_WIDGET (combo->priv->popup)); - - if (set_position) { - gtk_combo_box_get_pos (combo, &x, &y); - gtk_widget_set_uposition (combo->priv->tearoff_window, x, y); - } - gtk_widget_show (GTK_WIDGET (combo->priv->popup)); - gtk_widget_show (combo->priv->tearoff_window); - -} - -/** - * gtk_combo_set_tearoff_state - * @combo_box: Combo box - * @torn_off: TRUE: Tear off. FALSE: Pop down and reattach - * - * Set the tearoff state of the popup - * - * Compare with gtk_menu_set_tearoff_state in gtk/gtkmenu.c - */ -static void -gtk_combo_set_tearoff_state (GtkComboBox *combo, - gboolean torn_off) -{ - g_return_if_fail (combo != NULL); - g_return_if_fail (GTK_IS_COMBO_BOX (combo)); - - if (combo->priv->torn_off != torn_off) { - combo->priv->torn_off = torn_off; - - if (combo->priv->torn_off) { - gtk_combo_popup_tear_off (combo, TRUE); - deactivate_arrow (combo); - } else { - gtk_widget_hide (combo->priv->tearoff_window); - gtk_combo_popup_reparent (combo->priv->popup, - combo->priv->toplevel, - FALSE); - } - } -} - -/** - * gtk_combo_tearoff_bg_copy - * @combo_box: Combo box - * - * Copy popup window image to the tearoff window. - */ -static void -gtk_combo_tearoff_bg_copy (GtkComboBox *combo) -{ - GdkPixmap *pixmap; - GdkGC *gc; - GdkGCValues gc_values; - - GtkWidget *widget = combo->priv->popup; - - if (combo->priv->torn_off) { - gc_values.subwindow_mode = GDK_INCLUDE_INFERIORS; - gc = gdk_gc_new_with_values (widget->window, - &gc_values, GDK_GC_SUBWINDOW); - - pixmap = gdk_pixmap_new (widget->window, - widget->allocation.width, - widget->allocation.height, - -1); - - gdk_draw_drawable (pixmap, gc, - widget->window, - 0, 0, 0, 0, -1, -1); - gdk_gc_unref (gc); - - gtk_widget_set_usize (combo->priv->tearoff_window, - widget->allocation.width, - widget->allocation.height); - - gdk_window_set_back_pixmap - (combo->priv->tearoff_window->window, pixmap, FALSE); - gdk_drawable_unref (pixmap); - } -} - -/** - * gtk_combo_popup_reparent - * @popup: Popup - * @new_parent: New parent - * @unrealize: Unrealize popup if TRUE. - * - * Reparent the popup, taking care of the refcounting - * - * Compare with gtk_menu_reparent in gtk/gtkmenu.c - */ -static void -gtk_combo_popup_reparent (GtkWidget *popup, - GtkWidget *new_parent, - gboolean unrealize) -{ - GtkObject *object = GTK_OBJECT (popup); - gboolean was_floating = GTK_OBJECT_FLOATING (object); - - g_object_ref (object); - gtk_object_sink (object); - - if (unrealize) { - g_object_ref (object); - gtk_container_remove (GTK_CONTAINER (popup->parent), popup); - gtk_container_add (GTK_CONTAINER (new_parent), popup); - g_object_unref (object); - } - else - gtk_widget_reparent (GTK_WIDGET (popup), new_parent); - gtk_widget_set_usize (new_parent, -1, -1); - - if (was_floating) - GTK_OBJECT_SET_FLAGS (object, GTK_FLOATING); - else - g_object_unref (object); -} - -/** - * cb_tearable_button_release - * @w: Widget - * @event: Event - * @combo: Combo box - * - * Toggle tearoff state. - */ -static gboolean -cb_tearable_button_release (GtkWidget *w, GdkEventButton *event, - GtkComboBox *combo) -{ - GtkTearoffMenuItem *tearable; - - g_return_val_if_fail (w != NULL, FALSE); - g_return_val_if_fail (GTK_IS_TEAROFF_MENU_ITEM (w), FALSE); - - tearable = GTK_TEAROFF_MENU_ITEM (w); - tearable->torn_off = !tearable->torn_off; - - if (!combo->priv->torn_off) { - gboolean need_connect; - - need_connect = (!combo->priv->tearoff_window); - gtk_combo_set_tearoff_state (combo, TRUE); - if (need_connect) - g_signal_connect (combo->priv->tearoff_window, - "delete_event", - G_CALLBACK (cb_popup_delete), - combo); - } else - gtk_combo_box_popup_hide_unconditional (combo); - - return TRUE; -} - -static gboolean -cb_popup_delete (GtkWidget *w, GdkEventAny *event, GtkComboBox *combo) -{ - gtk_combo_box_popup_hide_unconditional (combo); - return TRUE; -} - -void -gtk_combo_box_construct (GtkComboBox *combo_box, GtkWidget *display_widget, GtkWidget *pop_down_widget) -{ - GtkWidget *tearable; - GtkWidget *vbox; - - g_return_if_fail (combo_box != NULL); - g_return_if_fail (GTK_IS_COMBO_BOX (combo_box)); - g_return_if_fail (display_widget != NULL); - g_return_if_fail (GTK_IS_WIDGET (display_widget)); - - GTK_BOX (combo_box)->spacing = 0; - GTK_BOX (combo_box)->homogeneous = FALSE; - - combo_box->priv->pop_down_widget = pop_down_widget; - combo_box->priv->display_widget = NULL; - - vbox = gtk_vbox_new (FALSE, 5); - tearable = gtk_tearoff_menu_item_new (); - g_signal_connect (tearable, "enter-notify-event", - G_CALLBACK (cb_tearable_enter_leave), - GINT_TO_POINTER (TRUE)); - g_signal_connect (tearable, "leave-notify-event", - G_CALLBACK (cb_tearable_enter_leave), - GINT_TO_POINTER (FALSE)); - g_signal_connect (tearable, "button-release-event", - G_CALLBACK (cb_tearable_button_release), - (gpointer) combo_box); - gtk_box_pack_start (GTK_BOX (vbox), tearable, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox), pop_down_widget, TRUE, TRUE, 0); - combo_box->priv->tearable = tearable; - - /* - * Finish setup - */ - gtk_combo_box_set_display (combo_box, display_widget); - - gtk_container_add (GTK_CONTAINER (combo_box->priv->frame), vbox); - gtk_widget_show_all (combo_box->priv->frame); -} - -GtkWidget * -gtk_combo_box_new (GtkWidget *display_widget, GtkWidget *optional_popdown) -{ - GtkComboBox *combo_box; - - g_return_val_if_fail (display_widget != NULL, NULL); - g_return_val_if_fail (GTK_IS_WIDGET (display_widget), NULL); - - combo_box = g_object_new (GTK_COMBO_BOX_TYPE, NULL); - gtk_combo_box_construct (combo_box, display_widget, optional_popdown); - return GTK_WIDGET (combo_box); -} - -void -gtk_combo_box_set_arrow_relief (GtkComboBox *cc, GtkReliefStyle relief) -{ - g_return_if_fail (cc != NULL); - g_return_if_fail (GTK_IS_COMBO_BOX (cc)); - - gtk_button_set_relief (GTK_BUTTON (cc->priv->arrow_button), relief); -} - -/** - * gtk_combo_box_set_title - * @combo: Combo box - * @title: Title - * - * Set a title to display over the tearoff window. - * - * FIXME: - * - * This should really change the title even when the popup is already torn off. - * I guess the tearoff window could attach a listener to title change or - * something. But I don't think we need the functionality, so I didn't bother - * to investigate. - */ -void -gtk_combo_box_set_title (GtkComboBox *combo, - const gchar *title) -{ - g_return_if_fail (combo != NULL); - g_return_if_fail (GTK_IS_COMBO_BOX (combo)); - - g_object_set_data_full (G_OBJECT (combo), "gtk-combo-title", - g_strdup (title), (GDestroyNotify) g_free); -} - -/** - * gtk_combo_box_set_arrow_sensitive - * @combo: Combo box - * @sensitive: Sensitivity value - * - * Toggle the sensitivity of the arrow button - */ - -void -gtk_combo_box_set_arrow_sensitive (GtkComboBox *combo, - gboolean sensitive) -{ - g_return_if_fail (combo != NULL); - - gtk_widget_set_sensitive (combo->priv->arrow_button, sensitive); -} - -/** - * gtk_combo_box_set_tearable: - * @combo: Combo box - * @tearable: whether to allow the @combo to be tearable - * - * controls whether the combo box's pop up widget can be torn off. - */ -void -gtk_combo_box_set_tearable (GtkComboBox *combo, gboolean tearable) -{ - g_return_if_fail (combo != NULL); - g_return_if_fail (GTK_IS_COMBO_BOX (combo)); - - if (tearable){ - gtk_widget_show (combo->priv->tearable); - } else { - gtk_combo_set_tearoff_state (combo, FALSE); - gtk_widget_hide (combo->priv->tearable); - } -} diff --git a/glabels2/src/mygal/gtk-combo-box.h b/glabels2/src/mygal/gtk-combo-box.h deleted file mode 100644 index 18b53554..00000000 --- a/glabels2/src/mygal/gtk-combo-box.h +++ /dev/null @@ -1,94 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gtk-combo-box.h - a customizable combobox - * Copyright 2000, 2001, Ximian, Inc. - * - * Authors: - * Miguel de Icaza - * - * Modified for gLabels by: - * Jim Evins - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License, version 2, as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#ifndef _GTK_COMBO_BOX_H_ -#define _GTK_COMBO_BOX_H_ - -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#define GTK_COMBO_BOX_TYPE (gtk_combo_box_get_type()) -#define GTK_COMBO_BOX(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, gtk_combo_box_get_type (), GtkComboBox) -#define GTK_COMBO_BOX_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, gtk_combo_box_get_type (), GtkComboBoxClass) -#define GTK_IS_COMBO_BOX(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, gtk_combo_box_get_type ()) - -typedef struct _GtkComboBox GtkComboBox; -typedef struct _GtkComboBoxPrivate GtkComboBoxPrivate; -typedef struct _GtkComboBoxClass GtkComboBoxClass; - -struct _GtkComboBox { - GtkHBox hbox; - GtkComboBoxPrivate *priv; -}; - -struct _GtkComboBoxClass { - GtkHBoxClass parent_class; - - GtkWidget *(*pop_down_widget) (GtkComboBox *cbox); - - /* - * invoked when the popup has been hidden, if the signal - * returns TRUE, it means it should be killed from the - */ - gboolean *(*pop_down_done) (GtkComboBox *cbox, GtkWidget *); - - /* - * Notification signals. - */ - void (*pre_pop_down) (GtkComboBox *cbox); - void (*post_pop_hide) (GtkComboBox *cbox); -}; - -GtkType gtk_combo_box_get_type (void); -void gtk_combo_box_construct (GtkComboBox *combo_box, - GtkWidget *display_widget, - GtkWidget *optional_pop_down_widget); -void gtk_combo_box_get_pos (GtkComboBox *combo_box, int *x, int *y); - -GtkWidget *gtk_combo_box_new (GtkWidget *display_widget, - GtkWidget *optional_pop_down_widget); -void gtk_combo_box_popup_hide (GtkComboBox *combo_box); - -void gtk_combo_box_set_display (GtkComboBox *combo_box, - GtkWidget *display_widget); - -void gtk_combo_box_set_title (GtkComboBox *combo, - const gchar *title); - -void gtk_combo_box_set_tearable (GtkComboBox *combo, - gboolean tearable); -void gtk_combo_box_set_arrow_sensitive (GtkComboBox *combo, - gboolean sensitive); -void gtk_combo_box_set_arrow_relief (GtkComboBox *cc, - GtkReliefStyle relief); -#ifdef __cplusplus -}; -#endif /* __cplusplus */ - -#endif /* _GTK_COMBO_BOX_H_ */ diff --git a/glabels2/src/mygal/mygal-combo-box.c b/glabels2/src/mygal/mygal-combo-box.c new file mode 100644 index 00000000..daa6466b --- /dev/null +++ b/glabels2/src/mygal/mygal-combo-box.c @@ -0,0 +1,837 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * mygal-combo-box.c - a customizable combobox + * Copyright 2000, 2001, Ximian, Inc. + * + * Authors: + * Miguel de Icaza (miguel@gnu.org) + * Adrian E Feiguin (feiguin@ifir.edu.ar) + * Paolo Molnaro (lupus@debian.org). + * Jon K Hellan (hellan@acm.org) + * + * Modified for gLabels by: + * Jim Evins + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License, version 2, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "mygal-combo-box.h" +#include "e-util.h" + +#define PARENT_TYPE GTK_TYPE_HBOX +static GObjectClass *mygal_combo_box_parent_class; + +static int gtk_combo_toggle_pressed (GtkToggleButton *tbutton, + MygalComboBox *combo_box); +static void gtk_combo_popup_tear_off (MygalComboBox *combo, + gboolean set_position); +static void gtk_combo_set_tearoff_state (MygalComboBox *combo, + gboolean torn_off); +static void gtk_combo_popup_reparent (GtkWidget *popup, GtkWidget *new_parent, + gboolean unrealize); +static gboolean cb_popup_delete (GtkWidget *w, GdkEventAny *event, + MygalComboBox *combo); +static void gtk_combo_tearoff_bg_copy (MygalComboBox *combo); + +enum { + POP_DOWN_WIDGET, + POP_DOWN_DONE, + PRE_POP_DOWN, + POST_POP_HIDE, + LAST_SIGNAL +}; + +static guint mygal_combo_box_signals [LAST_SIGNAL] = { 0, }; + +struct _MygalComboBoxPrivate { + GtkWidget *pop_down_widget; + GtkWidget *display_widget; + + /* + * Internal widgets used to implement the ComboBox + */ + GtkWidget *frame; + GtkWidget *arrow_button; + + GtkWidget *toplevel; /* Popup's toplevel when not torn off */ + GtkWidget *tearoff_window; /* Popup's toplevel when torn off */ + guint torn_off; + + GtkWidget *tearable; /* The tearoff "button" */ + GtkWidget *popup; /* Popup */ + + /* + * Closure for invoking the callbacks above + */ + void *closure; +}; + +static void +mygal_combo_box_finalize (GObject *object) +{ + MygalComboBox *combo_box = MYGAL_COMBO_BOX (object); + + g_free (combo_box->priv); + + mygal_combo_box_parent_class->finalize (object); +} + +static void +mygal_combo_box_destroy (GtkObject *object) +{ + GtkObjectClass *klass = (GtkObjectClass *)mygal_combo_box_parent_class; + MygalComboBox *combo_box = MYGAL_COMBO_BOX (object); + + if (combo_box->priv->toplevel) { + gtk_object_destroy (GTK_OBJECT (combo_box->priv->toplevel)); + combo_box->priv->toplevel = NULL; + } + + if (combo_box->priv->tearoff_window) { + gtk_object_destroy (GTK_OBJECT (combo_box->priv->tearoff_window)); + combo_box->priv->tearoff_window = NULL; + } + + if (klass->destroy) + klass->destroy (object); +} + +static gboolean +mygal_combo_box_mnemonic_activate (GtkWidget *w, gboolean group_cycling) +{ + MygalComboBox *combo_box = MYGAL_COMBO_BOX (w); + gtk_toggle_button_set_active ( + GTK_TOGGLE_BUTTON (combo_box->priv->arrow_button), TRUE); + return TRUE; +} + +static void +mygal_combo_box_class_init (GObjectClass *object_class) +{ + GtkWidgetClass *widget_class = (GtkWidgetClass *)object_class; + mygal_combo_box_parent_class = g_type_class_peek_parent (object_class); + + object_class->finalize = mygal_combo_box_finalize; + widget_class->mnemonic_activate = mygal_combo_box_mnemonic_activate; + ((GtkObjectClass *)object_class)->destroy = mygal_combo_box_destroy; + + mygal_combo_box_signals [POP_DOWN_WIDGET] = g_signal_new ( + "pop_down_widget", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (MygalComboBoxClass, pop_down_widget), + NULL, NULL, + e_marshal_POINTER__NONE, + G_TYPE_POINTER, 0, G_TYPE_NONE); + + mygal_combo_box_signals [POP_DOWN_DONE] = g_signal_new ( + "pop_down_done", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (MygalComboBoxClass, pop_down_done), + NULL, NULL, + e_marshal_BOOLEAN__OBJECT, + G_TYPE_BOOLEAN, 1, G_TYPE_OBJECT); + + mygal_combo_box_signals [PRE_POP_DOWN] = g_signal_new ( + "pre_pop_down", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (MygalComboBoxClass, pre_pop_down), + NULL, NULL, + e_marshal_NONE__NONE, + G_TYPE_NONE, 0); + + mygal_combo_box_signals [POST_POP_HIDE] = g_signal_new ( + "post_pop_hide", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (MygalComboBoxClass, post_pop_hide), + NULL, NULL, + e_marshal_NONE__NONE, + G_TYPE_NONE, 0); +} + +static void +deactivate_arrow (MygalComboBox *combo_box) +{ + GtkToggleButton *arrow; + + arrow = GTK_TOGGLE_BUTTON (combo_box->priv->arrow_button); + g_signal_handlers_block_matched (arrow, + G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, + 0, 0, NULL, + gtk_combo_toggle_pressed, combo_box); + + gtk_toggle_button_set_active (arrow, FALSE); + + g_signal_handlers_unblock_matched (arrow, + G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, + 0, 0, NULL, + gtk_combo_toggle_pressed, combo_box); +} + +/** + * mygal_combo_box_popup_hide_unconditional + * @combo_box: Combo box + * + * Hide popup, whether or not it is torn off. + */ +static void +mygal_combo_box_popup_hide_unconditional (MygalComboBox *combo_box) +{ + gboolean popup_info_destroyed = FALSE; + + g_return_if_fail (combo_box != NULL); + g_return_if_fail (GTK_IS_COMBO_BOX (combo_box)); + + gtk_widget_hide (combo_box->priv->toplevel); + gtk_widget_hide (combo_box->priv->popup); + if (combo_box->priv->torn_off) { + GTK_TEAROFF_MENU_ITEM (combo_box->priv->tearable)->torn_off + = FALSE; + gtk_combo_set_tearoff_state (combo_box, FALSE); + } + + gtk_grab_remove (combo_box->priv->toplevel); + gdk_pointer_ungrab (GDK_CURRENT_TIME); + + g_object_ref (combo_box->priv->pop_down_widget); + g_signal_emit (combo_box, + mygal_combo_box_signals [POP_DOWN_DONE], 0, + combo_box->priv->pop_down_widget, &popup_info_destroyed); + + if (popup_info_destroyed){ + gtk_container_remove ( + GTK_CONTAINER (combo_box->priv->frame), + combo_box->priv->pop_down_widget); + combo_box->priv->pop_down_widget = NULL; + } + g_object_unref (combo_box->priv->pop_down_widget); + deactivate_arrow (combo_box); + + g_signal_emit (combo_box, mygal_combo_box_signals [POST_POP_HIDE], 0); +} + +/** + * mygal_combo_box_popup_hide: + * @combo_box: Combo box + * + * Hide popup, but not when it is torn off. + * This is the external interface - for subclasses and apps which expect a + * regular combo which doesn't do tearoffs. + */ +void +mygal_combo_box_popup_hide (MygalComboBox *combo_box) +{ + if (!combo_box->priv->torn_off) + mygal_combo_box_popup_hide_unconditional (combo_box); + else if (GTK_WIDGET_VISIBLE (combo_box->priv->toplevel)) { + /* Both popup and tearoff window present. Get rid of just + the popup shell. */ + gtk_combo_popup_tear_off (combo_box, FALSE); + deactivate_arrow (combo_box); + } +} + +/* + * Find best location for displaying + */ +void +mygal_combo_box_get_pos (MygalComboBox *combo_box, int *x, int *y) +{ + GtkWidget *wcombo = GTK_WIDGET (combo_box); + int ph, pw; + + gdk_window_get_origin (wcombo->window, x, y); + *y += wcombo->allocation.height + wcombo->allocation.y; + *x += wcombo->allocation.x; + + ph = combo_box->priv->popup->allocation.height; + pw = combo_box->priv->popup->allocation.width; + + if ((*y + ph) > gdk_screen_height ()) + *y = gdk_screen_height () - ph; + + if ((*x + pw) > gdk_screen_width ()) + *x = gdk_screen_width () - pw; +} + +static void +mygal_combo_box_popup_display (MygalComboBox *combo_box) +{ + int x, y; + + g_return_if_fail (combo_box != NULL); + g_return_if_fail (GTK_IS_COMBO_BOX (combo_box)); + + /* + * If we have no widget to display on the popdown, + * create it + */ + if (!combo_box->priv->pop_down_widget){ + GtkWidget *pw = NULL; + + g_signal_emit (combo_box, + mygal_combo_box_signals [POP_DOWN_WIDGET], 0, &pw); + g_assert (pw != NULL); + combo_box->priv->pop_down_widget = pw; + gtk_container_add (GTK_CONTAINER (combo_box->priv->frame), pw); + } + + g_signal_emit (combo_box, mygal_combo_box_signals [PRE_POP_DOWN], 0); + + if (combo_box->priv->torn_off) { + /* To give the illusion that tearoff still displays the + * popup, we copy the image in the popup window to the + * background. Thus, it won't be blank after reparenting */ + gtk_combo_tearoff_bg_copy (combo_box); + + /* We force an unrealize here so that we don't trigger + * redrawing/ clearing code - we just want to reveal our + * backing pixmap. + */ + gtk_combo_popup_reparent (combo_box->priv->popup, + combo_box->priv->toplevel, TRUE); + } + + mygal_combo_box_get_pos (combo_box, &x, &y); + + gtk_widget_set_uposition (combo_box->priv->toplevel, x, y); + gtk_widget_realize (combo_box->priv->popup); + gtk_widget_show (combo_box->priv->popup); + gtk_widget_realize (combo_box->priv->toplevel); + gtk_widget_show (combo_box->priv->toplevel); + + gtk_grab_add (combo_box->priv->toplevel); + gdk_pointer_grab (combo_box->priv->toplevel->window, TRUE, + GDK_BUTTON_PRESS_MASK | + GDK_BUTTON_RELEASE_MASK | + GDK_POINTER_MOTION_MASK, + NULL, NULL, GDK_CURRENT_TIME); +} + +static int +gtk_combo_toggle_pressed (GtkToggleButton *tbutton, MygalComboBox *combo_box) +{ + if (tbutton->active) + mygal_combo_box_popup_display (combo_box); + else + mygal_combo_box_popup_hide_unconditional (combo_box); + + return TRUE; +} + +static gint +mygal_combo_box_button_press (GtkWidget *widget, GdkEventButton *event, MygalComboBox *combo_box) +{ + GtkWidget *child; + + child = gtk_get_event_widget ((GdkEvent *) event); + if (child != widget){ + while (child){ + if (child == widget) + return FALSE; + child = child->parent; + } + } + + mygal_combo_box_popup_hide (combo_box); + return TRUE; +} + +/** + * mygal_combo_box_key_press + * @widget: Widget + * @event: Event + * @combo_box: Combo box + * + * Key press handler which dismisses popup on escape. + * Popup is dismissed whether or not popup is torn off. + */ +static gint +mygal_combo_box_key_press (GtkWidget *widget, GdkEventKey *event, + MygalComboBox *combo_box) +{ + if (event->keyval == GDK_Escape) { + mygal_combo_box_popup_hide_unconditional (combo_box); + return TRUE; + } else + return FALSE; +} + +static void +cb_state_change (GtkWidget *widget, GtkStateType old_state, MygalComboBox *combo_box) +{ + GtkStateType const new_state = GTK_WIDGET_STATE(widget); + gtk_widget_set_state (combo_box->priv->display_widget, new_state); +} + +static void +mygal_combo_box_init (MygalComboBox *combo_box) +{ + GtkWidget *arrow; + GdkCursor *cursor; + + combo_box->priv = g_new0 (MygalComboBoxPrivate, 1); + + /* + * Create the arrow + */ + combo_box->priv->arrow_button = gtk_toggle_button_new (); + gtk_button_set_relief (GTK_BUTTON (combo_box->priv->arrow_button), GTK_RELIEF_NONE); + GTK_WIDGET_UNSET_FLAGS (combo_box->priv->arrow_button, GTK_CAN_FOCUS); + + arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_IN); + gtk_container_add (GTK_CONTAINER (combo_box->priv->arrow_button), arrow); + gtk_box_pack_end (GTK_BOX (combo_box), combo_box->priv->arrow_button, FALSE, FALSE, 0); + g_signal_connect (combo_box->priv->arrow_button, "toggled", + G_CALLBACK (gtk_combo_toggle_pressed), combo_box); + gtk_widget_show_all (combo_box->priv->arrow_button); + + /* + * prelight the display widget when mousing over the arrow. + */ + g_signal_connect (combo_box->priv->arrow_button, "state-changed", + G_CALLBACK (cb_state_change), combo_box); + + /* + * The pop-down container + */ + + combo_box->priv->toplevel = gtk_window_new (GTK_WINDOW_POPUP); + gtk_widget_ref (combo_box->priv->toplevel); + gtk_object_sink (GTK_OBJECT (combo_box->priv->toplevel)); + gtk_window_set_policy (GTK_WINDOW (combo_box->priv->toplevel), + FALSE, TRUE, FALSE); + + combo_box->priv->popup = gtk_event_box_new (); + gtk_container_add (GTK_CONTAINER (combo_box->priv->toplevel), + combo_box->priv->popup); + gtk_widget_show (combo_box->priv->popup); + + gtk_widget_realize (combo_box->priv->popup); + cursor = gdk_cursor_new (GDK_TOP_LEFT_ARROW); + gdk_window_set_cursor (combo_box->priv->popup->window, cursor); + gdk_cursor_unref (cursor); + + combo_box->priv->torn_off = FALSE; + combo_box->priv->tearoff_window = NULL; + + combo_box->priv->frame = gtk_frame_new (NULL); + gtk_container_add (GTK_CONTAINER (combo_box->priv->popup), + combo_box->priv->frame); + gtk_frame_set_shadow_type (GTK_FRAME (combo_box->priv->frame), GTK_SHADOW_OUT); + + g_signal_connect (combo_box->priv->toplevel, "button_press_event", + G_CALLBACK (mygal_combo_box_button_press), combo_box); + g_signal_connect (combo_box->priv->toplevel, "key_press_event", + G_CALLBACK (mygal_combo_box_key_press), combo_box); +} + +E_MAKE_TYPE (mygal_combo_box, + "MygalComboBox", + MygalComboBox, + mygal_combo_box_class_init, + mygal_combo_box_init, + PARENT_TYPE) + +/** + * mygal_combo_box_set_display: + * @combo_box: the Combo Box to modify + * @display_widget: The widget to be displayed + + * Sets the displayed widget for the @combo_box to be @display_widget + */ +void +mygal_combo_box_set_display (MygalComboBox *combo_box, GtkWidget *display_widget) +{ + g_return_if_fail (combo_box != NULL); + g_return_if_fail (GTK_IS_COMBO_BOX (combo_box)); + g_return_if_fail (display_widget != NULL); + g_return_if_fail (GTK_IS_WIDGET (display_widget)); + + if (combo_box->priv->display_widget && + combo_box->priv->display_widget != display_widget) + gtk_container_remove (GTK_CONTAINER (combo_box), + combo_box->priv->display_widget); + + combo_box->priv->display_widget = display_widget; + + gtk_box_pack_start (GTK_BOX (combo_box), display_widget, TRUE, TRUE, 0); +} + +static gboolean +cb_tearable_enter_leave (GtkWidget *w, GdkEventCrossing *event, gpointer data) +{ + gboolean const flag = GPOINTER_TO_INT(data); + gtk_widget_set_state (w, flag ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL); + return FALSE; +} + +/** + * gtk_combo_popup_tear_off + * @combo: Combo box + * @set_position: Set to position of popup shell if true + * + * Tear off the popup + * + * FIXME: + * Gtk popup menus are toplevel windows, not dialogs. I think this is wrong, + * and make the popups dialogs. But may be there should be a way to make + * them toplevel. We can do this after creating: + * GTK_WINDOW (tearoff)->type = GTK_WINDOW_TOPLEVEL; + */ +static void +gtk_combo_popup_tear_off (MygalComboBox *combo, gboolean set_position) +{ + int x, y; + + if (!combo->priv->tearoff_window) { + GtkWidget *tearoff; + gchar *title; + + /* FIXME: made this a toplevel, not a dialog ! */ + tearoff = gtk_window_new (GTK_WINDOW_TOPLEVEL); + gtk_widget_ref (tearoff); + gtk_object_sink (GTK_OBJECT (tearoff)); + combo->priv->tearoff_window = tearoff; + gtk_widget_set_app_paintable (tearoff, TRUE); + g_signal_connect (tearoff, "key_press_event", + G_CALLBACK (mygal_combo_box_key_press), + combo); + gtk_widget_realize (tearoff); + title = g_object_get_data (G_OBJECT (combo), + "gtk-combo-title"); + if (title) + gdk_window_set_title (tearoff->window, title); + gtk_window_set_policy (GTK_WINDOW (tearoff), + FALSE, TRUE, FALSE); + gtk_window_set_transient_for + (GTK_WINDOW (tearoff), + GTK_WINDOW (gtk_widget_get_toplevel + GTK_WIDGET (combo))); + } + + if (GTK_WIDGET_VISIBLE (combo->priv->popup)) { + gtk_widget_hide (combo->priv->toplevel); + + gtk_grab_remove (combo->priv->toplevel); + gdk_pointer_ungrab (GDK_CURRENT_TIME); + } + + gtk_combo_popup_reparent (combo->priv->popup, + combo->priv->tearoff_window, FALSE); + + /* It may have got confused about size */ + gtk_widget_queue_resize (GTK_WIDGET (combo->priv->popup)); + + if (set_position) { + mygal_combo_box_get_pos (combo, &x, &y); + gtk_widget_set_uposition (combo->priv->tearoff_window, x, y); + } + gtk_widget_show (GTK_WIDGET (combo->priv->popup)); + gtk_widget_show (combo->priv->tearoff_window); + +} + +/** + * gtk_combo_set_tearoff_state + * @combo_box: Combo box + * @torn_off: TRUE: Tear off. FALSE: Pop down and reattach + * + * Set the tearoff state of the popup + * + * Compare with gtk_menu_set_tearoff_state in gtk/gtkmenu.c + */ +static void +gtk_combo_set_tearoff_state (MygalComboBox *combo, + gboolean torn_off) +{ + g_return_if_fail (combo != NULL); + g_return_if_fail (GTK_IS_COMBO_BOX (combo)); + + if (combo->priv->torn_off != torn_off) { + combo->priv->torn_off = torn_off; + + if (combo->priv->torn_off) { + gtk_combo_popup_tear_off (combo, TRUE); + deactivate_arrow (combo); + } else { + gtk_widget_hide (combo->priv->tearoff_window); + gtk_combo_popup_reparent (combo->priv->popup, + combo->priv->toplevel, + FALSE); + } + } +} + +/** + * gtk_combo_tearoff_bg_copy + * @combo_box: Combo box + * + * Copy popup window image to the tearoff window. + */ +static void +gtk_combo_tearoff_bg_copy (MygalComboBox *combo) +{ + GdkPixmap *pixmap; + GdkGC *gc; + GdkGCValues gc_values; + + GtkWidget *widget = combo->priv->popup; + + if (combo->priv->torn_off) { + gc_values.subwindow_mode = GDK_INCLUDE_INFERIORS; + gc = gdk_gc_new_with_values (widget->window, + &gc_values, GDK_GC_SUBWINDOW); + + pixmap = gdk_pixmap_new (widget->window, + widget->allocation.width, + widget->allocation.height, + -1); + + gdk_draw_drawable (pixmap, gc, + widget->window, + 0, 0, 0, 0, -1, -1); + gdk_gc_unref (gc); + + gtk_widget_set_usize (combo->priv->tearoff_window, + widget->allocation.width, + widget->allocation.height); + + gdk_window_set_back_pixmap + (combo->priv->tearoff_window->window, pixmap, FALSE); + gdk_drawable_unref (pixmap); + } +} + +/** + * gtk_combo_popup_reparent + * @popup: Popup + * @new_parent: New parent + * @unrealize: Unrealize popup if TRUE. + * + * Reparent the popup, taking care of the refcounting + * + * Compare with gtk_menu_reparent in gtk/gtkmenu.c + */ +static void +gtk_combo_popup_reparent (GtkWidget *popup, + GtkWidget *new_parent, + gboolean unrealize) +{ + GtkObject *object = GTK_OBJECT (popup); + gboolean was_floating = GTK_OBJECT_FLOATING (object); + + g_object_ref (object); + gtk_object_sink (object); + + if (unrealize) { + g_object_ref (object); + gtk_container_remove (GTK_CONTAINER (popup->parent), popup); + gtk_container_add (GTK_CONTAINER (new_parent), popup); + g_object_unref (object); + } + else + gtk_widget_reparent (GTK_WIDGET (popup), new_parent); + gtk_widget_set_usize (new_parent, -1, -1); + + if (was_floating) + GTK_OBJECT_SET_FLAGS (object, GTK_FLOATING); + else + g_object_unref (object); +} + +/** + * cb_tearable_button_release + * @w: Widget + * @event: Event + * @combo: Combo box + * + * Toggle tearoff state. + */ +static gboolean +cb_tearable_button_release (GtkWidget *w, GdkEventButton *event, + MygalComboBox *combo) +{ + GtkTearoffMenuItem *tearable; + + g_return_val_if_fail (w != NULL, FALSE); + g_return_val_if_fail (GTK_IS_TEAROFF_MENU_ITEM (w), FALSE); + + tearable = GTK_TEAROFF_MENU_ITEM (w); + tearable->torn_off = !tearable->torn_off; + + if (!combo->priv->torn_off) { + gboolean need_connect; + + need_connect = (!combo->priv->tearoff_window); + gtk_combo_set_tearoff_state (combo, TRUE); + if (need_connect) + g_signal_connect (combo->priv->tearoff_window, + "delete_event", + G_CALLBACK (cb_popup_delete), + combo); + } else + mygal_combo_box_popup_hide_unconditional (combo); + + return TRUE; +} + +static gboolean +cb_popup_delete (GtkWidget *w, GdkEventAny *event, MygalComboBox *combo) +{ + mygal_combo_box_popup_hide_unconditional (combo); + return TRUE; +} + +void +mygal_combo_box_construct (MygalComboBox *combo_box, GtkWidget *display_widget, GtkWidget *pop_down_widget) +{ + GtkWidget *tearable; + GtkWidget *vbox; + + g_return_if_fail (combo_box != NULL); + g_return_if_fail (GTK_IS_COMBO_BOX (combo_box)); + g_return_if_fail (display_widget != NULL); + g_return_if_fail (GTK_IS_WIDGET (display_widget)); + + GTK_BOX (combo_box)->spacing = 0; + GTK_BOX (combo_box)->homogeneous = FALSE; + + combo_box->priv->pop_down_widget = pop_down_widget; + combo_box->priv->display_widget = NULL; + + vbox = gtk_vbox_new (FALSE, 5); + tearable = gtk_tearoff_menu_item_new (); + g_signal_connect (tearable, "enter-notify-event", + G_CALLBACK (cb_tearable_enter_leave), + GINT_TO_POINTER (TRUE)); + g_signal_connect (tearable, "leave-notify-event", + G_CALLBACK (cb_tearable_enter_leave), + GINT_TO_POINTER (FALSE)); + g_signal_connect (tearable, "button-release-event", + G_CALLBACK (cb_tearable_button_release), + (gpointer) combo_box); + gtk_box_pack_start (GTK_BOX (vbox), tearable, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (vbox), pop_down_widget, TRUE, TRUE, 0); + combo_box->priv->tearable = tearable; + + /* + * Finish setup + */ + mygal_combo_box_set_display (combo_box, display_widget); + + gtk_container_add (GTK_CONTAINER (combo_box->priv->frame), vbox); + gtk_widget_show_all (combo_box->priv->frame); +} + +GtkWidget * +mygal_combo_box_new (GtkWidget *display_widget, GtkWidget *optional_popdown) +{ + MygalComboBox *combo_box; + + g_return_val_if_fail (display_widget != NULL, NULL); + g_return_val_if_fail (GTK_IS_WIDGET (display_widget), NULL); + + combo_box = g_object_new (MYGAL_COMBO_BOX_TYPE, NULL); + mygal_combo_box_construct (combo_box, display_widget, optional_popdown); + return GTK_WIDGET (combo_box); +} + +void +mygal_combo_box_set_arrow_relief (MygalComboBox *cc, GtkReliefStyle relief) +{ + g_return_if_fail (cc != NULL); + g_return_if_fail (GTK_IS_COMBO_BOX (cc)); + + gtk_button_set_relief (GTK_BUTTON (cc->priv->arrow_button), relief); +} + +/** + * mygal_combo_box_set_title + * @combo: Combo box + * @title: Title + * + * Set a title to display over the tearoff window. + * + * FIXME: + * + * This should really change the title even when the popup is already torn off. + * I guess the tearoff window could attach a listener to title change or + * something. But I don't think we need the functionality, so I didn't bother + * to investigate. + */ +void +mygal_combo_box_set_title (MygalComboBox *combo, + const gchar *title) +{ + g_return_if_fail (combo != NULL); + g_return_if_fail (GTK_IS_COMBO_BOX (combo)); + + g_object_set_data_full (G_OBJECT (combo), "gtk-combo-title", + g_strdup (title), (GDestroyNotify) g_free); +} + +/** + * mygal_combo_box_set_arrow_sensitive + * @combo: Combo box + * @sensitive: Sensitivity value + * + * Toggle the sensitivity of the arrow button + */ + +void +mygal_combo_box_set_arrow_sensitive (MygalComboBox *combo, + gboolean sensitive) +{ + g_return_if_fail (combo != NULL); + + gtk_widget_set_sensitive (combo->priv->arrow_button, sensitive); +} + +/** + * mygal_combo_box_set_tearable: + * @combo: Combo box + * @tearable: whether to allow the @combo to be tearable + * + * controls whether the combo box's pop up widget can be torn off. + */ +void +mygal_combo_box_set_tearable (MygalComboBox *combo, gboolean tearable) +{ + g_return_if_fail (combo != NULL); + g_return_if_fail (GTK_IS_COMBO_BOX (combo)); + + if (tearable){ + gtk_widget_show (combo->priv->tearable); + } else { + gtk_combo_set_tearoff_state (combo, FALSE); + gtk_widget_hide (combo->priv->tearable); + } +} diff --git a/glabels2/src/mygal/mygal-combo-box.h b/glabels2/src/mygal/mygal-combo-box.h new file mode 100644 index 00000000..25a8df14 --- /dev/null +++ b/glabels2/src/mygal/mygal-combo-box.h @@ -0,0 +1,94 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * mygal-combo-box.h - a customizable combobox + * Copyright 2000, 2001, Ximian, Inc. + * + * Authors: + * Miguel de Icaza + * + * Modified for gLabels by: + * Jim Evins + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License, version 2, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifndef _MYGAL_COMBO_BOX_H_ +#define _MYGAL_COMBO_BOX_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define MYGAL_COMBO_BOX_TYPE (mygal_combo_box_get_type()) +#define MYGAL_COMBO_BOX(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, mygal_combo_box_get_type (), MygalComboBox) +#define MYGAL_COMBO_BOX_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, mygal_combo_box_get_type (), MygalComboBoxClass) +#define GTK_IS_COMBO_BOX(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, mygal_combo_box_get_type ()) + +typedef struct _MygalComboBox MygalComboBox; +typedef struct _MygalComboBoxPrivate MygalComboBoxPrivate; +typedef struct _MygalComboBoxClass MygalComboBoxClass; + +struct _MygalComboBox { + GtkHBox hbox; + MygalComboBoxPrivate *priv; +}; + +struct _MygalComboBoxClass { + GtkHBoxClass parent_class; + + GtkWidget *(*pop_down_widget) (MygalComboBox *cbox); + + /* + * invoked when the popup has been hidden, if the signal + * returns TRUE, it means it should be killed from the + */ + gboolean *(*pop_down_done) (MygalComboBox *cbox, GtkWidget *); + + /* + * Notification signals. + */ + void (*pre_pop_down) (MygalComboBox *cbox); + void (*post_pop_hide) (MygalComboBox *cbox); +}; + +GtkType mygal_combo_box_get_type (void); +void mygal_combo_box_construct (MygalComboBox *combo_box, + GtkWidget *display_widget, + GtkWidget *optional_pop_down_widget); +void mygal_combo_box_get_pos (MygalComboBox *combo_box, int *x, int *y); + +GtkWidget *mygal_combo_box_new (GtkWidget *display_widget, + GtkWidget *optional_pop_down_widget); +void mygal_combo_box_popup_hide (MygalComboBox *combo_box); + +void mygal_combo_box_set_display (MygalComboBox *combo_box, + GtkWidget *display_widget); + +void mygal_combo_box_set_title (MygalComboBox *combo, + const gchar *title); + +void mygal_combo_box_set_tearable (MygalComboBox *combo, + gboolean tearable); +void mygal_combo_box_set_arrow_sensitive (MygalComboBox *combo, + gboolean sensitive); +void mygal_combo_box_set_arrow_relief (MygalComboBox *cc, + GtkReliefStyle relief); +#ifdef __cplusplus +}; +#endif /* __cplusplus */ + +#endif /* _MYGAL_COMBO_BOX_H_ */ diff --git a/glabels2/src/mygal/widget-color-combo.c b/glabels2/src/mygal/widget-color-combo.c index f25b375c..5ca2708f 100644 --- a/glabels2/src/mygal/widget-color-combo.c +++ b/glabels2/src/mygal/widget-color-combo.c @@ -47,7 +47,7 @@ enum { static guint color_combo_signals [LAST_SIGNAL] = { 0, }; -#define PARENT_TYPE GTK_COMBO_BOX_TYPE +#define PARENT_TYPE MYGAL_COMBO_BOX_TYPE static GObjectClass *color_combo_parent_class; #define make_color(CC,COL) (((COL) != NULL) ? (COL) : ((CC) ? ((CC)->default_color) : NULL)) @@ -140,7 +140,7 @@ emit_color_changed (ColorCombo *cc, GdkColor *color, g_signal_emit (cc, color_combo_signals [CHANGED], 0, color, is_custom, by_user, is_default); - gtk_combo_box_popup_hide (GTK_COMBO_BOX (cc)); + mygal_combo_box_popup_hide (MYGAL_COMBO_BOX (cc)); } static void @@ -165,7 +165,7 @@ preview_clicked (GtkWidget *button, ColorCombo *cc) static void cb_cust_color_clicked (GtkWidget *widget, ColorCombo *cc) { - gtk_combo_box_popup_hide (GTK_COMBO_BOX (cc)); + mygal_combo_box_popup_hide (MYGAL_COMBO_BOX (cc)); } /* @@ -255,11 +255,11 @@ color_combo_construct (ColorCombo *cc, GdkPixbuf *icon, gtk_widget_show_all (cc->preview_button); - gtk_combo_box_construct (GTK_COMBO_BOX (cc), - cc->preview_button, - GTK_WIDGET (cc->palette)); + mygal_combo_box_construct (MYGAL_COMBO_BOX (cc), + cc->preview_button, + GTK_WIDGET (cc->palette)); - gtk_combo_box_set_tearable (GTK_COMBO_BOX (cc), FALSE); + mygal_combo_box_set_tearable (MYGAL_COMBO_BOX (cc), FALSE); color = color_palette_get_current_color (cc->palette, NULL); color_combo_set_color_internal (cc, color); diff --git a/glabels2/src/mygal/widget-color-combo.h b/glabels2/src/mygal/widget-color-combo.h index 581e4a43..3fb283c7 100644 --- a/glabels2/src/mygal/widget-color-combo.h +++ b/glabels2/src/mygal/widget-color-combo.h @@ -35,13 +35,13 @@ #define GNUMERIC_WIDGET_COLOR_COMBO_H #include -#include "gtk-combo-box.h" +#include "mygal-combo-box.h" #include "color-palette.h" G_BEGIN_DECLS typedef struct _ColorCombo { - GtkComboBox combo_box; + MygalComboBox combo_box; /* * GtkImage where we display @@ -57,7 +57,7 @@ typedef struct _ColorCombo { } ColorCombo; typedef struct { - GtkComboBoxClass parent_class; + MygalComboBoxClass parent_class; /* Signals emited by this widget */ void (* color_changed) (ColorCombo *color_combo, GdkColor *color, diff --git a/glabels2/src/recent-files/Makefile.am b/glabels2/src/recent-files/Makefile.am index a6e2bc6e..5d4b02a7 100644 --- a/glabels2/src/recent-files/Makefile.am +++ b/glabels2/src/recent-files/Makefile.am @@ -1,10 +1,6 @@ INCLUDES = \ - $(GLABELS_CFLAGS) \ - -DG_DISABLE_DEPRECATED \ - -DGDK_DISABLE_DEPRECATED \ - -DGTK_DISABLE_DEPRECATED \ - -DGDK_PIXBUF_DISABLE_DEPRECATED \ - -DGNOME_DISABLE_DEPRECATED + $(GLABELS_CFLAGS) + EGG_FILES = \ egg-recent-model.c \