From: Bruno Haible Date: Mon, 11 Feb 2002 12:10:58 +0000 (+0000) Subject: New Glade backend. X-Git-Tag: v0.11.1~85 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=96ad11383679e16e94af21790364e53eca75b33a;p=thirdparty%2Fgettext.git New Glade backend. --- diff --git a/ChangeLog b/ChangeLog index 89e641524..4eadda782 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2002-01-14 Bruno Haible + + * configure.in: Add check for libexpat. + 2002-02-02 Bruno Haible * Makefile.am (SUBDIRS): Add libuniname. diff --git a/configure.in b/configure.in index fecd9524c..455087617 100644 --- a/configure.in +++ b/configure.in @@ -93,6 +93,25 @@ dnl These are the only lines required to internationalize the package. dnl (OK, not quite, the AC_OUTPUT has also some parts.) AM_GNU_GETTEXT(use-libtool, need-ngettext) +dnl Check for the expat XML parser. +dnl On operating systems where binary distribution vendors are likely to +dnl ship both gettext and expat, we use dynamic loading to avoid a hard +dnl dependency from gettext to expat. +case "$host_os" in + linux*) + AC_DEFINE([DYNLOAD_LIBEXPAT], 1, + [Define to 1 if libexpat shall be dynamically loaded via dlopen().]) + LIBEXPAT="-ldl" + LTLIBEXPAT="-ldl" + AC_SUBST(LIBEXPAT) + AC_SUBST(LTLIBEXPAT) + ;; + *) + AC_LIB_HAVE_LINKFLAGS([expat], [], + [#include ], [XML_ExpatVersion();]) + ;; +esac + dnl Check for Emacs and where to install .elc files. AM_PATH_LISPDIR diff --git a/doc/ChangeLog b/doc/ChangeLog index b8f8079aa..91801f498 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,7 @@ +2002-01-14 Bruno Haible + + * gettext.texi (Glade): New node. + 2002-01-27 Bruno Haible * gettext.texi (gawk): Update. diff --git a/doc/gettext.texi b/doc/gettext.texi index 6edc36dec..1a4ccbe8c 100644 --- a/doc/gettext.texi +++ b/doc/gettext.texi @@ -315,6 +315,7 @@ Internationalizable Data * POT:: POT - Portable Object Template * RST:: Resource String Table +* Glade:: Glade - GNOME user interface description Concluding Remarks @@ -7320,6 +7321,7 @@ using GNU gettext. @menu * POT:: POT - Portable Object Template * RST:: Resource String Table +* Glade:: Glade - GNOME user interface description @end menu @node POT, RST, List of Data Formats, List of Data Formats @@ -7336,7 +7338,7 @@ gettext @code{xgettext} @end table -@node RST, , POT, List of Data Formats +@node RST, Glade, POT, List of Data Formats @subsection Resource String Table @cindex RST @@ -7351,6 +7353,20 @@ fpk @code{xgettext}, @code{rstconv} @end table +@node Glade, , RST, List of Data Formats +@subsection Glade - GNOME user interface description + +@table @asis +@item RPMs +glade, libglade, xml-i18n-tools + +@item File extension +@code{glade} + +@item Extractor +@code{xgettext}, @code{libglade-xgettext} +@end table + @c This is the template for new data formats. @ignore diff --git a/src/ChangeLog b/src/ChangeLog index ef6eb4ce1..dea45cd0d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,15 @@ +2002-01-14 Bruno Haible + + * x-glade.h: New file. + * x-glade.c: New file. + * xgettext.c: Include x-glade.h. + (main): Call x_glade_extract_all, x_glade_keyword. + (language_to_scanner): Add glade rule. + (extension_to_language): Add glade rule. + * Makefile.am (noinst_HEADERS): Add x-glade.h. + (xgettext_SOURCES): Add x-glade.c. + (xgettext_LDADD): Add @LTLIBEXPAT@. + 2002-01-27 Bruno Haible * message.h (format_type): New enum value 'format_awk'. diff --git a/src/Makefile.am b/src/Makefile.am index 1b5ed1fb2..9eeaca99d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -33,7 +33,7 @@ po-gram-gen.h po-hash-gen.h msgl-charset.h msgl-equal.h msgl-iconv.h \ msgl-ascii.h msgl-cat.h msgl-english.h msgfmt.h msgunfmt.h read-mo.h \ write-mo.h read-java.h write-java.h po-time.h plural-table.h format.h \ xgettext.h x-c.h x-po.h x-python.h x-lisp.h x-elisp.h x-librep.h x-java.h \ -x-awk.h x-ycp.h x-rst.h +x-awk.h x-ycp.h x-rst.h x-glade.h EXTRA_DIST = FILES project-id \ gnu/gettext/DumpResource.java gnu/gettext/GetURL.java @@ -88,7 +88,7 @@ msgmerge_SOURCES = msgmerge.c msgunfmt_SOURCES = msgunfmt.c read-mo.c read-java.c xgettext_SOURCES = xgettext.c \ x-c.c x-po.c x-python.c x-lisp.c x-elisp.c x-librep.c x-java.l x-awk.c \ - x-ycp.c x-rst.c + x-ycp.c x-rst.c x-glade.c msgattrib_SOURCES = msgattrib.c msgcat_SOURCES = msgcat.c msgcomm_SOURCES = msgcomm.c @@ -118,7 +118,7 @@ msgcmp_LDADD = libgettextsrc.la msgfmt_LDADD = libgettextsrc.la msgmerge_LDADD = libgettextsrc.la msgunfmt_LDADD = libgettextsrc.la -xgettext_LDADD = libgettextsrc.la $(LIBUNINAME) +xgettext_LDADD = libgettextsrc.la $(LIBUNINAME) @LTLIBEXPAT@ msgattrib_LDADD = libgettextsrc.la msgcat_LDADD = libgettextsrc.la msgcomm_LDADD = libgettextsrc.la diff --git a/src/x-glade.c b/src/x-glade.c new file mode 100644 index 000000000..10d1f2fe9 --- /dev/null +++ b/src/x-glade.c @@ -0,0 +1,451 @@ +/* xgettext glade backend. + Copyright (C) 2002 Free Software Foundation, Inc. + + This file was written by Bruno Haible , 2002. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program 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 program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include +#include +#include +#include +#if DYNLOAD_LIBEXPAT +# include +#else +# if HAVE_LIBEXPAT +# include +# endif +#endif + +#include "message.h" +#include "x-glade.h" +#include "xgettext.h" +#include "error.h" +#include "xerror.h" +#include "basename.h" +#include "progname.h" +#include "xmalloc.h" +#include "exit.h" +#include "hash.h" +#include "po-charset.h" +#include "msgl-ascii.h" +#include "msgl-iconv.h" +#include "gettext.h" + +#define _(s) gettext(s) + + +/* glade is an XML based format. Some example files are contained in + libglade-0.16. */ + + +/* Prototypes for local functions. Needed to ensure compiler checking of + function argument counts despite of K&R C function definition syntax. */ +static void init_keywords PARAMS ((void)); + + +/* ====================== Keyword set customization. ====================== */ + +/* If true extract all strings. */ +static bool extract_all = false; + +static hash_table keywords; +static bool default_keywords = true; + + +void +x_glade_extract_all () +{ + extract_all = true; +} + + +void +x_glade_keyword (name) + const char *name; +{ + if (name == NULL) + default_keywords = false; + else + { + if (keywords.table == NULL) + init_hash (&keywords, 100); + + insert_entry (&keywords, name, strlen (name), NULL); + } +} + +/* Finish initializing the keywords hash table. + Called after argument processing, before each file is processed. */ +static void +init_keywords () +{ + if (default_keywords) + { + x_glade_keyword ("label"); + x_glade_keyword ("title"); + x_glade_keyword ("text"); + x_glade_keyword ("format"); + x_glade_keyword ("copyright"); + x_glade_keyword ("comments"); + x_glade_keyword ("preview_text"); + x_glade_keyword ("tooltip"); + default_keywords = false; + } +} + + +/* ===================== Dynamic loading of libexpat. ===================== */ + +#if DYNLOAD_LIBEXPAT + +/* Prototypes for local functions. Needed to ensure compiler checking of + function argument counts despite of K&R C function definition syntax. */ +static bool load_libexpat PARAMS ((void)); + +typedef void *XML_Parser; +typedef char XML_Char; +typedef char XML_LChar; +enum XML_Error { XML_ERROR_NONE }; +typedef void (*XML_StartElementHandler) PARAMS ((void *userData, const XML_Char *name, const XML_Char **atts)); +typedef void (*XML_EndElementHandler) PARAMS ((void *userData, const XML_Char *name)); +typedef void (*XML_CharacterDataHandler) PARAMS ((void *userData, const XML_Char *s, int len)); +typedef void (*XML_CommentHandler) PARAMS ((void *userData, const XML_Char *data)); + +static XML_Parser (*p_XML_ParserCreate) PARAMS ((const XML_Char *encoding)); +static void (*p_XML_SetElementHandler) PARAMS ((XML_Parser parser, XML_StartElementHandler start, XML_EndElementHandler end)); +static void (*p_XML_SetCharacterDataHandler) PARAMS ((XML_Parser parser, XML_CharacterDataHandler handler)); +static void (*p_XML_SetCommentHandler) PARAMS ((XML_Parser parser, XML_CommentHandler handler)); +static int (*p_XML_Parse) PARAMS ((XML_Parser parser, const char *s, int len, int isFinal)); +static enum XML_Error (*p_XML_GetErrorCode) PARAMS ((XML_Parser parser)); +static int (*p_XML_GetCurrentLineNumber) PARAMS ((XML_Parser parser)); +static int (*p_XML_GetCurrentColumnNumber) PARAMS ((XML_Parser parser)); +static void (*p_XML_ParserFree) PARAMS ((XML_Parser parser)); +static const XML_LChar * (*p_XML_ErrorString) PARAMS ((int code)); + +#define XML_ParserCreate (*p_XML_ParserCreate) +#define XML_SetElementHandler (*p_XML_SetElementHandler) +#define XML_SetCharacterDataHandler (*p_XML_SetCharacterDataHandler) +#define XML_SetCommentHandler (*p_XML_SetCommentHandler) +#define XML_Parse (*p_XML_Parse) +#define XML_GetErrorCode (*p_XML_GetErrorCode) +#define XML_GetCurrentLineNumber (*p_XML_GetCurrentLineNumber) +#define XML_GetCurrentColumnNumber (*p_XML_GetCurrentColumnNumber) +#define XML_ParserFree (*p_XML_ParserFree) +#define XML_ErrorString (*p_XML_ErrorString) + +static int libexpat_loaded = 0; + +static bool +load_libexpat () +{ + if (libexpat_loaded == 0) + { + void *handle = dlopen ("libexpat.so.0", RTLD_LAZY); + if (handle != NULL + && (p_XML_ParserCreate = dlsym (handle, "XML_ParserCreate")) != NULL + && (p_XML_SetElementHandler = dlsym (handle, "XML_SetElementHandler")) != NULL + && (p_XML_SetCharacterDataHandler = dlsym (handle, "XML_SetCharacterDataHandler")) != NULL + && (p_XML_SetCommentHandler = dlsym (handle, "XML_SetCommentHandler")) != NULL + && (p_XML_Parse = dlsym (handle, "XML_Parse")) != NULL + && (p_XML_GetErrorCode = dlsym (handle, "XML_GetErrorCode")) != NULL + && (p_XML_GetCurrentLineNumber = dlsym (handle, "XML_GetCurrentLineNumber")) != NULL + && (p_XML_GetCurrentColumnNumber = dlsym (handle, "XML_GetCurrentColumnNumber")) != NULL + && (p_XML_ParserFree = dlsym (handle, "XML_ParserFree")) != NULL + && (p_XML_ErrorString = dlsym (handle, "XML_ErrorString")) != NULL) + libexpat_loaded = 1; + else + libexpat_loaded = -1; + } + return libexpat_loaded >= 0; +} + +#define LIBEXPAT_AVAILABLE() (load_libexpat ()) + +#elif HAVE_LIBEXPAT + +#define LIBEXPAT_AVAILABLE() true + +#endif + +/* ============================= XML parsing. ============================= */ + +#if DYNLOAD_LIBEXPAT || HAVE_LIBEXPAT + +/* Prototypes for local functions. Needed to ensure compiler checking of + function argument counts despite of K&R C function definition syntax. */ +static void ensure_stack_size PARAMS ((size_t size)); +static void start_element_handler PARAMS ((void *userData, const char *name, + const char **attributes)); +static void end_element_handler PARAMS ((void *userData, const char *name)); +static void character_data_handler PARAMS ((void *userData, const char *s, + int len)); +static void comment_handler PARAMS ((void *userData, const char *data)); +static void do_extract_glade PARAMS ((FILE *fp, const char *real_filename, + const char *logical_filename, + msgdomain_list_ty *mdlp)); + + +/* Accumulator for the extracted messages. */ +static message_list_ty *mlp; + +/* Logical filename, used to label the extracted messages. */ +static char *logical_file_name; + +/* XML parser. */ +static XML_Parser parser; + +struct element_state +{ + bool extract_string; + int lineno; + char *buffer; + size_t bufmax; + size_t buflen; +}; +static struct element_state *stack; +static size_t stack_size; + +/* Ensures stack_size >= size. */ +static void +ensure_stack_size (size) + size_t size; +{ + if (size > stack_size) + { + stack_size = 2 * stack_size; + if (stack_size < size) + stack_size = size; + stack = + (struct element_state *) + xrealloc (stack, stack_size * sizeof (struct element_state)); + } +} + +static size_t stack_depth; + +/* Callback called when is seen. */ +static void +start_element_handler (userData, name, attributes) + void *userData; + const char *name; + const char **attributes; +{ + struct element_state *p; + void *hash_result; + + /* Increase stack depth. */ + stack_depth++; + ensure_stack_size (stack_depth + 1); + + /* Don't extract a string for the containing element. */ + stack[stack_depth - 1].extract_string = false; + + p = &stack[stack_depth]; + p->extract_string = + (find_entry (&keywords, name, strlen (name), &hash_result) == 0); + p->lineno = XML_GetCurrentLineNumber (parser); + p->buffer = NULL; + p->bufmax = 0; + p->buflen = 0; + if (!p->extract_string) + xgettext_comment_reset (); +} + +/* Callback called when is seen. */ +static void +end_element_handler (userData, name) + void *userData; + const char *name; +{ + struct element_state *p = &stack[stack_depth]; + + /* Actually extract string. */ + if (p->extract_string) + { + /* Don't extract the empty string. */ + if (p->buflen > 0) + { + lex_pos_ty pos; + + if (p->buflen == p->bufmax) + p->buffer = (char *) xrealloc (p->buffer, p->buflen + 1); + p->buffer[p->buflen] = '\0'; + + pos.file_name = logical_file_name; + pos.line_number = p->lineno; + + remember_a_message (mlp, p->buffer, &pos); + p->buffer = NULL; + } + } + + /* Free memory for this stack level. */ + if (p->buffer != NULL) + free (p->buffer); + + /* Decrease stack depth. */ + stack_depth--; + + xgettext_comment_reset (); +} + +/* Callback called when some text is seen. */ +static void +character_data_handler (userData, s, len) + void *userData; + const char *s; + int len; +{ + struct element_state *p = &stack[stack_depth]; + + /* Accumulate character data. */ + if (len > 0) + { + if (p->buflen + len > p->bufmax) + { + p->bufmax = 2 * p->bufmax; + if (p->bufmax < p->buflen + len) + p->bufmax = p->buflen + len; + p->buffer = (char *) xrealloc (p->buffer, p->bufmax); + } + memcpy (p->buffer + p->buflen, s, len); + p->buflen += len; + } +} + +/* Callback called when some comment text is seen. */ +static void +comment_handler (userData, data) + void *userData; + const char *data; +{ + /* Split multiline comment into lines, and remove leading and trailing + whitespace. */ + char *copy = xstrdup (data); + char *p = copy; + char *q; + + for (p = copy; (q = strchr (p, '\n')) != NULL; p = q + 1) + { + while (p[0] == ' ' || p[0] == '\t') + p++; + while (q > p && (q[-1] == ' ' || q[-1] == '\t')) + q--; + *q = '\0'; + xgettext_comment_add (p); + } + q = p + strlen (p); + while (p[0] == ' ' || p[0] == '\t') + p++; + while (q > p && (q[-1] == ' ' || q[-1] == '\t')) + q--; + *q = '\0'; + xgettext_comment_add (p); + free (copy); +} + + +static void +do_extract_glade (fp, real_filename, logical_filename, mdlp) + FILE *fp; + const char *real_filename; + const char *logical_filename; + msgdomain_list_ty *mdlp; +{ + mlp = mdlp->item[0]->messages; + + logical_file_name = xstrdup (logical_filename); + + init_keywords (); + + parser = XML_ParserCreate (NULL); + if (parser == NULL) + error (EXIT_FAILURE, 0, _("memory exhausted")); + + XML_SetElementHandler (parser, start_element_handler, end_element_handler); + XML_SetCharacterDataHandler (parser, character_data_handler); + XML_SetCommentHandler (parser, comment_handler); + + while (!feof (fp)) + { + char buf[4096]; + int count = fread (buf, 1, sizeof buf, fp); + + if (count == 0) + { + if (ferror (fp)) + error (EXIT_FAILURE, errno, _("\ +error while reading \"%s\""), real_filename); + /* EOF reached. */ + break; + } + + if (XML_Parse (parser, buf, count, 0) == 0) + error (EXIT_FAILURE, 0, _("%s:%d:%d: %s"), logical_filename, + XML_GetCurrentLineNumber (parser), + XML_GetCurrentColumnNumber (parser) + 1, + XML_ErrorString (XML_GetErrorCode (parser))); + } + + if (XML_Parse (parser, NULL, 0, 1) == 0) + error (EXIT_FAILURE, 0, _("%s:%d:%d: %s"), logical_filename, + XML_GetCurrentLineNumber (parser), + XML_GetCurrentColumnNumber (parser) + 1, + XML_ErrorString (XML_GetErrorCode (parser))); + + XML_ParserFree (parser); + + /* expat feeds us strings in UTF-8 encoding. If not all the strings + were plain ASCII, set the charset in the header to UTF-8. */ + if (!is_ascii_message_list (mlp)) + { + const char *canon_utf_8 = po_charset_canonicalize ("UTF-8"); + iconv_message_list (mlp, canon_utf_8, canon_utf_8); + } + + /* Close scanner. */ + logical_file_name = NULL; + parser = NULL; +} + +#endif + +void +extract_glade (fp, real_filename, logical_filename, mdlp) + FILE *fp; + const char *real_filename; + const char *logical_filename; + msgdomain_list_ty *mdlp; +{ +#if DYNLOAD_LIBEXPAT || HAVE_LIBEXPAT + if (LIBEXPAT_AVAILABLE ()) + do_extract_glade (fp, real_filename, logical_filename, mdlp); + else +#endif + { + multiline_error (xstrdup (""), + xasprintf (_("\ +Language \"glade\" is not supported. %s relies on expat.\n\ +This version was built without expat.\n"), + basename (program_name))); + exit (EXIT_FAILURE); + } +} diff --git a/src/x-glade.h b/src/x-glade.h new file mode 100644 index 000000000..3d9672a5d --- /dev/null +++ b/src/x-glade.h @@ -0,0 +1,35 @@ +/* xgettext glade backend. + Copyright (C) 2002 Free Software Foundation, Inc. + Written by Bruno Haible , 2002. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program 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 program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + + +#define EXTENSIONS_GLADE \ + { "glade", "glade" }, \ + +#define SCANNERS_GLADE \ + { "glade", extract_glade, NULL }, \ + +/* Scan a glade XML file and add its translatable strings to mdlp. */ +extern void extract_glade PARAMS ((FILE *fp, const char *real_filename, + const char *logical_filename, + msgdomain_list_ty *mdlp)); + + +/* Handling of options specific to this language. */ + +extern void x_glade_extract_all PARAMS ((void)); +extern void x_glade_keyword PARAMS ((const char *name)); diff --git a/src/xgettext.c b/src/xgettext.c index 11f174ddd..c9381be3a 100644 --- a/src/xgettext.c +++ b/src/xgettext.c @@ -67,6 +67,7 @@ #include "x-awk.h" #include "x-ycp.h" #include "x-rst.h" +#include "x-glade.h" /* If nonzero add all comments immediately preceding one of the keywords. */ @@ -231,6 +232,7 @@ main (argc, argv) x_librep_extract_all (); x_java_extract_all (); x_awk_extract_all (); + x_glade_extract_all (); break; case 'c': if (optarg == NULL) @@ -287,6 +289,7 @@ main (argc, argv) x_librep_keyword (optarg); x_java_keyword (optarg); x_awk_keyword (optarg); + x_glade_keyword (optarg); } break; case 'K': @@ -1258,6 +1261,7 @@ language_to_extractor (name) SCANNERS_AWK SCANNERS_YCP SCANNERS_RST + SCANNERS_GLADE /* Here will follow more languages and their scanners: perl, etc... Make sure new scanners honor the --exclude-file option. */ }; @@ -1302,6 +1306,7 @@ extension_to_language (extension) EXTENSIONS_AWK EXTENSIONS_YCP EXTENSIONS_RST + EXTENSIONS_GLADE /* Here will follow more file extensions: sh, pl, tcl ... */ }; diff --git a/tests/ChangeLog b/tests/ChangeLog index 762397c17..90422d5a1 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,9 @@ +2002-01-28 Bruno Haible + + * xgettext-19: New file. + * xgettext-20: New file. + * Makefile.am (TESTS): Add them. + 2002-01-27 Bruno Haible * format-awk-1: New file. diff --git a/tests/xgettext-19 b/tests/xgettext-19 new file mode 100755 index 000000000..eb575d60c --- /dev/null +++ b/tests/xgettext-19 @@ -0,0 +1,1569 @@ +#!/bin/sh + +# Test of Glade support. + +tmpfiles="" +trap 'rm -fr $tmpfiles' 1 2 3 15 + +tmpfiles="$tmpfiles empty.glade" +cat < empty.glade + + +EOF + +tmpfiles="$tmpfiles xg-test19.pot" +: ${XGETTEXT=xgettext} +${XGETTEXT} -o xg-test19.pot empty.glade 2>/dev/null +test $? = 0 || { echo "SKIP: xgettext-19"; rm -fr $tmpfiles; exit 1; } + +tmpfiles="$tmpfiles widgets.glade" +cat < widgets.glade + + + + + project1 + + src + + C + True + True + False + True + True + True + True + interface.c + interface.h + callbacks.c + callbacks.h + support.c + support.h + + + + GnomeApp + appwin + + destroy + gtk_main_quit + Thu, 17 Jun 1999 15:06:07 GMT + + Libglade-GNOME Test + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + False + True + False + True + + + GnomeDock + GnomeApp:dock + dock1 + True + + 0 + True + True + + + + GnomeDockItem + dockitem1 + 2 + GNOME_DOCK_TOP + 0 + 0 + 0 + False + False + False + True + False + GTK_SHADOW_OUT + + + GtkMenuBar + menubar1 + GTK_SHADOW_NONE + + + GtkMenuItem + file1 + GNOMEUIINFO_MENU_FILE_TREE + + + GtkMenu + file1_menu + + + GtkPixmapMenuItem + open2 + + activate + gtk_widget_show + filesel + Thu, 17 Jun 1999 15:03:18 GMT + + GNOMEUIINFO_MENU_OPEN_ITEM + + + + GtkMenuItem + show_tests1 + + activate + gtk_widget_show + testwin + Thu, 17 Jun 1999 14:52:01 GMT + + + False + + + + GtkMenuItem + druid_test1 + + activate + gtk_widget_show + druidwin + Thu, 28 Oct 1999 15:53:37 GMT + + + False + + + + GtkMenuItem + separator2 + False + + + + GtkPixmapMenuItem + exit1 + + activate + gtk_widget_show + closebox + Thu, 17 Jun 1999 07:44:23 GMT + + GNOMEUIINFO_MENU_EXIT_ITEM + + + + + + GtkMenuItem + edit1 + GNOMEUIINFO_MENU_EDIT_TREE + + + GtkMenu + edit1_menu + + + GtkPixmapMenuItem + undo1 + GNOMEUIINFO_MENU_UNDO_ITEM + + + + GtkPixmapMenuItem + redo1 + GNOMEUIINFO_MENU_REDO_ITEM + + + + GtkMenuItem + separator3 + False + + + + GtkPixmapMenuItem + cut1 + + activate + gtk_editable_cut_clipboard + textbox + Thu, 17 Jun 1999 07:34:00 GMT + + GNOMEUIINFO_MENU_CUT_ITEM + + + + GtkPixmapMenuItem + copy1 + + activate + gtk_editable_copy_clipboard + textbox + Thu, 17 Jun 1999 07:34:21 GMT + + GNOMEUIINFO_MENU_COPY_ITEM + + + + GtkPixmapMenuItem + paste1 + + activate + gtk_editable_paste_clipboard + textbox + Thu, 17 Jun 1999 07:34:47 GMT + + GNOMEUIINFO_MENU_PASTE_ITEM + + + + GtkPixmapMenuItem + clear1 + + activate + gtk_editable_delete_selection + textbox + Thu, 17 Jun 1999 07:35:04 GMT + + GNOMEUIINFO_MENU_CLEAR_ITEM + + + + + + GtkMenuItem + settings1 + GNOMEUIINFO_MENU_SETTINGS_TREE + + + GtkMenu + settings1_menu + + + GtkPixmapMenuItem + preferences1 + + activate + gtk_widget_show + propbox + Tue, 28 Sep 1999 04:29:36 GMT + + GNOMEUIINFO_MENU_PREFERENCES_ITEM + + + + + + GtkMenuItem + help1 + GNOMEUIINFO_MENU_HELP_TREE + + + GtkMenu + help1_menu + + + GtkPixmapMenuItem + about1 + + activate + gtk_widget_show + aboutwin + Thu, 17 Jun 1999 07:38:13 GMT + + GNOMEUIINFO_MENU_ABOUT_ITEM + + + + + + + + GnomeDockItem + dockitem2 + 1 + GNOME_DOCK_TOP + 1 + 0 + 0 + False + False + False + False + False + GTK_SHADOW_OUT + + + GtkToolbar + toolbar1 + 1 + GTK_ORIENTATION_HORIZONTAL + GTK_TOOLBAR_BOTH + 16 + GTK_TOOLBAR_SPACE_LINE + GTK_RELIEF_NONE + True + + + GtkButton + Toolbar:button + button1 + + GNOME_STOCK_PIXMAP_NEW + + + + GtkButton + Toolbar:button + button2 + + GNOME_STOCK_PIXMAP_OPEN + + + + GtkButton + Toolbar:button + button3 + + GNOME_STOCK_PIXMAP_SAVE + + + + GtkButton + Toolbar:button + button4 + + clicked + gtk_editable_cut_clipboard + textbox + Thu, 17 Jun 1999 07:31:19 GMT + + + GNOME_STOCK_PIXMAP_CUT + + True + + + + + GtkButton + Toolbar:button + button5 + + clicked + gtk_editable_copy_clipboard + textbox + Thu, 17 Jun 1999 07:32:16 GMT + + + GNOME_STOCK_PIXMAP_COPY + + + + GtkButton + Toolbar:button + button6 + + clicked + gtk_editable_paste_clipboard + textbox + Thu, 17 Jun 1999 07:33:13 GMT + + + GNOME_STOCK_PIXMAP_PASTE + + + + GtkButton + Toolbar:button + button7 + + clicked + gtk_editable_delete_selection + textbox + Thu, 17 Jun 1999 07:33:30 GMT + + + GNOME_STOCK_PIXMAP_CLEAR + + + + GtkToggleButton + Toolbar:button + togglebutton1 + + GNOME_STOCK_PIXMAP_ATTACH + False + + True + + + + + + + GtkText + GnomeDock:contents + textbox + True + True + True + The cut copy paste and clear buttons should work correctly. + + + + + GnomeAppBar + GnomeApp:appbar + appbar1 + False + True + + 0 + True + True + + + + + + GnomeAbout + aboutwin + False + + clicked + gtk_widget_hide + Thu, 17 Jun 1999 07:37:41 GMT + + True + Copyright (C) 1999 + James Henstridge <james@daa.com.au> + + A simple program demonstrating what is possible with GNOME and +libglade. This interface has been coded entirely with GLADE, and +no C code specific to this interface has been written. + + + + GnomeMessageBox + closebox + False + GNOME_MESSAGE_BOX_QUESTION + Are you sure you want to quit +the application? + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + False + False + False + True + False + + + GtkVBox + GnomeDialog:vbox + dialog-vbox1 + False + 8 + + 4 + True + True + + + + GtkHButtonBox + GnomeDialog:action_area + dialog-action_area1 + GTK_BUTTONBOX_END + 8 + 85 + 27 + 7 + 0 + + 0 + False + True + GTK_PACK_END + + + + GtkButton + button8 + True + True + + clicked + gtk_main_quit + Sat, 19 Jun 1999 13:56:42 GMT + + GNOME_STOCK_BUTTON_YES + + + + GtkButton + button9 + True + True + + clicked + gtk_widget_hide + closebox + Sat, 19 Jun 1999 13:56:56 GMT + + GNOME_STOCK_BUTTON_NO + + + + GtkButton + button11 + True + True + + GNOME_STOCK_PIXMAP_OPEN + + + + + + + GtkWindow + testwin + False + + delete_event + gtk_widget_hide + Thu, 17 Jun 1999 14:53:15 GMT + + + delete_event + gtk_true + Thu, 17 Jun 1999 14:53:29 GMT + + Widget Tests + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + False + True + False + + + GtkNotebook + notebook1 + True + True + True + GTK_POS_TOP + True + 2 + 2 + False + + + GnomeColorPicker + colorpicker1 + 100 + True + True + False + Pick a colour + Pick a colour + + + + GtkLabel + Notebook:tab + label1 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GnomeFontPicker + fontpicker1 + 75 + True + Pick a Font + AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz + GNOME_FONT_PICKER_MODE_FONT_INFO + True + True + 14 + + + + GtkLabel + Notebook:tab + label2 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GnomeIconEntry + iconentry1 + + Hello + iconent_hist + 10 + + + + GtkLabel + Notebook:tab + label3 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GnomeHRef + href1 + 150 + True + http://www.daa.com.au/~james/gnome/ + + + + + GtkLabel + Notebook:tab + label4 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GnomeEntry + entry1 + EntTest + 10 + + + GtkEntry + GnomeEntry:entry + entry2 + True + True + True + 0 + + + + + + GtkLabel + Notebook:tab + label5 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GnomeFileEntry + fileentry1 + 50 + FileEntTest + 10 + False + False + + + GtkEntry + GnomeEntry:entry + entry3 + True + True + True + 0 + + + + + + GtkLabel + Notebook:tab + label6 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkDial + dial1 + False + GTK_UPDATE_CONTINUOUS + 0 + 0 + 100 + 0 + 0 + 0 + + + + GtkLabel + Notebook:tab + label7 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkClock + clock1 + + GTK_CLOCK_REALTIME + + + %H:%M + 0 + 60 + + + + GtkLabel + Notebook:tab + label8 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GnomeAnimator + animator1 + 0 + 0 + GNOME_ANIMATOR_LOOP_NONE + False + 1 + + + + GtkLabel + Notebook:tab + label9 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GnomeCalculator + calculator1 + + + + GtkLabel + Notebook:tab + label10 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GnomeLess + less1 + -b&h-lucidatypewriter-bold-r-normal-*-*-140-*-*-m-*-iso8859-1 + + + + GtkLabel + Notebook:tab + label11 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GnomePaperSelector + paperselector1 + 50 + + + + GtkLabel + Notebook:tab + label12 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GnomeSpell + spell1 + + + + GtkLabel + Notebook:tab + label13 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + + + GtkFileSelection + filesel + 10 + False + + delete_event + gtk_widget_hide + Thu, 17 Jun 1999 14:58:58 GMT + + + delete_event + gtk_true + Thu, 17 Jun 1999 14:59:07 GMT + + Select File + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + False + True + False + True + + + GtkButton + FileSel:ok_button + ok_button1 + True + True + + clicked + gtk_widget_hide + filesel + Thu, 17 Jun 1999 15:02:33 GMT + + + clicked + gtk_widget_show + msgdialog + Thu, 17 Jun 1999 15:02:51 GMT + + + + + + GtkButton + FileSel:cancel_button + cancel_button1 + True + True + True + + clicked + gtk_widget_hide + filesel + Thu, 17 Jun 1999 14:59:25 GMT + + + + + + + GnomeDialog + msgdialog + False + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + False + False + False + True + True + + + GtkVBox + GnomeDialog:vbox + dialog-vbox2 + False + 8 + + 4 + True + True + + + + GtkLabel + label14 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + 0 + False + False + + + + + GtkHButtonBox + GnomeDialog:action_area + dialog-action_area2 + GTK_BUTTONBOX_END + 8 + 85 + 27 + 7 + 0 + + 0 + False + True + GTK_PACK_END + + + + GtkButton + button10 + True + True + GNOME_STOCK_BUTTON_OK + + + + GtkButton + button10 + True + True + + + + + + + + GnomePropertyBox + propbox + False + + delete_event + gtk_widget_hide + Tue, 28 Sep 1999 04:29:52 GMT + + + delete_event + gtk_true + Tue, 28 Sep 1999 04:30:00 GMT + + + clicked + gtk_widget_hide + Tue, 28 Sep 1999 04:30:37 GMT + + + + GtkNotebook + GnomePropertyBox:notebook + notebook2 + True + True + True + GTK_POS_TOP + False + 2 + 2 + False + + 0 + True + True + + + + GtkFrame + frame1 + 5 + 0 + GTK_SHADOW_ETCHED_IN + + + GtkVBox + vbox1 + 5 + False + 3 + + + GtkCombo + combo1 + False + True + False + True + False + + + 0 + False + False + + + + GtkEntry + GtkCombo:entry + combo-entry1 + True + + changed + gnome_property_box_changed + propbox + Tue, 28 Sep 1999 04:25:07 GMT + + True + True + 0 + + + + + + GnomeFileEntry + fileentry2 + 10 + False + False + + 0 + False + False + + + + GtkEntry + GnomeEntry:entry + combo-entry3 + True + + changed + gnome_property_box_changed + propbox + Tue, 28 Sep 1999 04:25:19 GMT + + True + True + 0 + + + + + + GnomePixmapEntry + pixmapentry1 + True + + 0 + False + False + + + + GnomeFileEntry + GnomePixmapEntry:file-entry + entry4 + 10 + False + False + + + GtkEntry + GnomeEntry:entry + combo-entry2 + True + + changed + gnome_property_box_changed + propbox + Tue, 28 Sep 1999 04:25:38 GMT + + True + True + 0 + + + + + + + + + GtkLabel + Notebook:tab + label15 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkFrame + frame2 + 5 + 0 + GTK_SHADOW_OUT + + + GtkDial + dial2 + False + GTK_UPDATE_CONTINUOUS + 0 + 0 + 100 + 0 + 0 + 0 + + + + + GtkLabel + Notebook:tab + label16 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + + + GtkWindow + druidwin + False + + delete_event + gtk_widget_hide + Thu, 28 Oct 1999 15:52:59 GMT + + + delete_event + gtk_true + Thu, 28 Oct 1999 15:53:09 GMT + + GnomeDruid + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + False + True + False + + + GnomeDruid + druid1 + + cancel + gtk_widget_hide + druidwin + Thu, 28 Oct 1999 15:55:01 GMT + + + + GnomeDruidPageStart + druidpagestart1 + Test GnomeDruid + This is a simple test of the GnomeDruid +code in gnome-libs and the wrapper +for said code in libglade. + 255,255,255 + 0,0,0 + 254,226,40 + 255,0,20 + 95,254,235 + + + + GnomeDruidPageStandard + druidpagestandard1 + A dial in a druid + 255,255,255 + 55,190,93 + 255,5,234 + + + GtkVBox + GnomeDruidPageStandard:vbox + druid-vbox1 + 50 + False + 0 + + 0 + True + True + + + + GtkDial + dial3 + False + GTK_UPDATE_CONTINUOUS + 0 + 0 + 100 + 0 + 0 + 0 + + 0 + True + True + + + + + + + GnomeDruidPageFinish + druidpagefinish1 + + finish + gtk_widget_hide + druidwin + Thu, 28 Oct 1999 15:55:24 GMT + + Last Page + This is the end of the druid example + 25,25,112 + 255,147,6 + 190,190,190 + 0,0,0 + 255,255,255 + + + + + +EOF + +tmpfiles="$tmpfiles xg-test19.pot" +: ${XGETTEXT=xgettext} +${XGETTEXT} --add-comments -o - widgets.glade | grep -v 'POT-Creation-Date' > xg-test19.pot +test $? = 0 || { rm -fr $tmpfiles; exit 1; } + +tmpfiles="$tmpfiles xg-test19.ok" +cat < xg-test19.ok +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: widgets.glade:33 +msgid "Libglade-GNOME Test" +msgstr "" + +#: widgets.glade:103 +msgid "Show _Tests" +msgstr "" + +#: widgets.glade:116 +msgid "Druid Test" +msgstr "" + +#: widgets.glade:295 +msgid "New" +msgstr "" + +#: widgets.glade:303 +msgid "Open" +msgstr "" + +#: widgets.glade:311 +msgid "Save" +msgstr "" + +#: widgets.glade:325 +msgid "Cut" +msgstr "" + +#: widgets.glade:342 +msgid "Copy" +msgstr "" + +#: widgets.glade:356 +msgid "Paste" +msgstr "" + +#: widgets.glade:370 +msgid "Clear" +msgstr "" + +#: widgets.glade:378 +msgid "Tog" +msgstr "" + +#: widgets.glade:395 +msgid "The cut copy paste and clear buttons should work correctly." +msgstr "" + +#: widgets.glade:423 +msgid "Copyright (C) 1999" +msgstr "" + +#: widgets.glade:426 +msgid "" +"A simple program demonstrating what is possible with GNOME and\n" +"libglade. This interface has been coded entirely with GLADE, and\n" +"no C code specific to this interface has been written." +msgstr "" + +#: widgets.glade:508 +msgid "X" +msgstr "" + +#: widgets.glade:529 +msgid "Widget Tests" +msgstr "" + +#: widgets.glade:556 widgets.glade:557 +msgid "Pick a colour" +msgstr "" + +#: widgets.glade:564 +msgid "Colour Picker" +msgstr "" + +#: widgets.glade:578 +msgid "Pick a Font" +msgstr "" + +#: widgets.glade:579 +msgid "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz" +msgstr "" + +#: widgets.glade:590 +msgid "Font Picker" +msgstr "" + +#. The welcome greeting +#: widgets.glade:603 +msgid "Hello" +msgstr "" + +#: widgets.glade:612 +msgid "Icon Sel" +msgstr "" + +#: widgets.glade:627 +msgid "My Gnome Site" +msgstr "" + +#: widgets.glade:634 +msgid "HRef" +msgstr "" + +#: widgets.glade:665 +msgid "Entry" +msgstr "" + +#: widgets.glade:699 +msgid "File Entry" +msgstr "" + +#: widgets.glade:725 +msgid "Dial" +msgstr "" + +#. This is a comment for the translators. +#. This should be an strftime format, +#. as described in the strftime(3) manual page. +#: widgets.glade:742 +msgid "%H:%M" +msgstr "" + +#: widgets.glade:751 +msgid "Clock" +msgstr "" + +#: widgets.glade:774 +msgid "Animator" +msgstr "" + +#: widgets.glade:792 +msgid "Calculator" +msgstr "" + +#: widgets.glade:811 +msgid "Less" +msgstr "" + +#: widgets.glade:830 +msgid "PaperSel" +msgstr "" + +#: widgets.glade:848 +msgid "GnomeSpell" +msgstr "" + +#: widgets.glade:874 +msgid "Select File" +msgstr "" + +#: widgets.glade:901 +msgid "OK" +msgstr "" + +#: widgets.glade:917 +msgid "Cancel" +msgstr "" + +#: widgets.glade:949 +msgid "" +"If this was a real application, clicking on the\n" +"OK button would probably have done something\n" +"useful, rather than just displaying this dialog." +msgstr "" + +#: widgets.glade:995 +msgid "Nothing" +msgstr "" + +#: widgets.glade:1159 +msgid "_Entry" +msgstr "" + +#: widgets.glade:1193 +msgid "_Dial" +msgstr "" + +#: widgets.glade:1218 +msgid "GnomeDruid" +msgstr "" + +#: widgets.glade:1239 +msgid "Test GnomeDruid" +msgstr "" + +#: widgets.glade:1240 +msgid "" +"This is a simple test of the GnomeDruid\n" +"code in gnome-libs and the wrapper\n" +"for said code in libglade." +msgstr "" + +#: widgets.glade:1253 +msgid "A dial in a druid" +msgstr "" + +#: widgets.glade:1300 +msgid "Last Page" +msgstr "" + +#: widgets.glade:1301 +msgid "This is the end of the druid example" +msgstr "" +EOF + +: ${DIFF=diff} +${DIFF} xg-test19.ok xg-test19.pot +result=$? + +rm -fr $tmpfiles + +exit $result diff --git a/tests/xgettext-20 b/tests/xgettext-20 new file mode 100755 index 000000000..0483a446a --- /dev/null +++ b/tests/xgettext-20 @@ -0,0 +1,103 @@ +#!/bin/sh + +# Test of Glade support, in particular ISO-8859-1 to UTF-8 conversion +# and ASCII entities (< > "). + +tmpfiles="" +trap 'rm -fr $tmpfiles' 1 2 3 15 + +tmpfiles="$tmpfiles empty.glade" +cat < empty.glade + + +EOF + +tmpfiles="$tmpfiles xg-test20.pot" +: ${XGETTEXT=xgettext} +${XGETTEXT} -o xg-test20.pot empty.glade 2>/dev/null +test $? = 0 || { echo "SKIP: xgettext-20"; rm -fr $tmpfiles; exit 1; } + +tmpfiles="$tmpfiles simple.glade" +cat <<\EOF > simple.glade + + + + + + GtkWindow + HelloWindow + 5 + + destroy + gtk_main_quit + + Hello + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + True + True + False + + + GtkButton + Hello World + True + + clicked + gtk_widget_destroy + HelloWindow + + + + This <button> diplays "Hello World". + + + + +EOF + +tmpfiles="$tmpfiles xg-test20.tmp xg-test20.pot" +: ${XGETTEXT=xgettext} +${XGETTEXT} --add-comments -o xg-test20.tmp simple.glade +test $? = 0 || { rm -fr $tmpfiles; exit 1; } +grep -v 'POT-Creation-Date' < xg-test20.tmp > xg-test20.pot + +tmpfiles="$tmpfiles xg-test20.ok" +cat < xg-test20.ok +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: simple.glade:13 +msgid "Hello" +msgstr "" + +#. Der übliche Programm-Gruß +#: simple.glade:30 +msgid "Hello World" +msgstr "" + +#: simple.glade:31 +msgid "This