Commit Graph

59 Commits

Author SHA1 Message Date
Kalev Lember
a37450110b Fix string allocation handling with GtkBuilder translations
Use g_string_assign to avoid issues with assigning GString's internal
buffer back to the same string. This can happen when no translations are
available and _gtk_builder_parser_translate returns back the same
pointer that was passed in.

This fixes a regression from commit e9f182e37a
that caused GtkComboBoxText <items> from GtkBuilder to show up empty if
no translations are available.

https://bugzilla.gnome.org/show_bug.cgi?id=700629
2013-06-08 10:54:25 +02:00
Matthias Clasen
e9f182e37a Fix a few memory leaks wrt to translations
Pointed out in https://bugzilla.gnome.org/show_bug.cgi?id=699016
The fix here is slightly different. We make
_gtk_builder_parser_translate return a const char * instead of
a dup'ed string, and fix up the callers.
2013-04-28 21:43:49 -04:00
Tristan Van Berkom
b7da0d21f8 GtkBuilder: Add private _gtk_builder_extend_with_template()
This adds the definition of the <template> tag with some documentation
on the variant of the format.

_gtk_builder_extend_with_template() is to be used while GtkContainer
builds from composite templates. A couple of error codes are also added
to handle a few new possible failure cases.

DTD Files gtkbuilder.rnc and gtkbuilder.rng have been updated to include
the new <template> tag and it's attributes.
2013-04-08 21:19:27 +09:00
Benjamin Otte
12683da8f7 gtk: Make functions static that don't need to be non-static
Also remove the starting underscore from function names where
appropriate, as those functions are static now and not exported anymore.

This is part of a bunch of fixes for gcc complaining about
-Wmissing-declarations.
2012-10-02 19:32:51 +02:00
Matthias Clasen
aa3d30e256 Fix a cornercase of menu parsing
When a uimanager in a gtkbuilder file contains a menu,
the builder parser was getting confused.

https://bugzilla.gnome.org/show_bug.cgi?id=672789
2012-04-20 01:50:01 -04:00
Javier Jardón
9d0febc9a6 Change FSF Address 2012-02-27 17:06:11 +00:00
Ryan Lortie
eed307713b GtkBuilder: change format of menus
Change the format of GtkBuilder <menu> to be more in-line with the style
of the rest of GtkBuilder so that we can do translation in a consistent
way.

The format is now substantially more difficult to hand-write, but tools
should be along soon.

There is an xslt program attached to the bug to help you convert your
existing .ui files from the old format to the new one.

https://bugzilla.gnome.org/show_bug.cgi?id=668696
2012-01-25 19:42:19 -05:00
Matthias Clasen
a991bb9927 GtkBuilder: pick up named submenus
When parsing GMenu xml, use the facility for pick up named submenus.
Note that <section id='foo'>...</section> is _not_ a named submenu.
It is a named item with an unnamed submenu :-(
2011-12-19 12:51:12 -05:00
Matthias Clasen
f13083bf0d Pass domain to the menu parser
This is necessary to make translations in markup work.
2011-12-19 12:45:51 -05:00
Matthias Clasen
1ddaf01aed Quick-and-dirty GtkBuilder integration
This makes GtkBuilder accept a GMenuMarkup tree at the toplevel
(ie with <menu id='foo'> being a child of <interface>) and the resulting
GMenu object can be obtained via gtk_builder_get_object (builder, "foo").
2011-12-19 12:45:50 -05:00
Matthias Clasen
16877b4d7b Reduce includes of gtktypeutils.h to a minimum 2011-01-04 12:05:05 -05:00
Tor Lillqvist
801875b805 Replace gtk_debug_flags with getter and setter functions
Preferrably should be made just into a local variable for libgtk like
_gdk_debug_flags for libgdk. But for now used by
gtk/tests/textbuffer.c and modules/printbackends/cups/gtkprintbackendcups.c.
2010-09-08 21:31:34 +03:00
Philip Withnall
5fa4a05ccc Miscellaneous string fixes
Mostly capitalisation fixes. Closes: bgo#528257
2010-08-22 15:06:45 +01:00
Javier Jardón
0a07e9733b gtk/: fully remove gtkalias hacks
https://bugzilla.gnome.org/show_bug.cgi?id=623845
2010-07-10 02:51:26 +02:00
Paolo Borelli
03018f1d01 Fix memory leaks when using add_objects 2009-08-14 15:56:44 +02:00
Paolo Borelli
6cfb23d185 Fix duplicated id detection in gtkbuilder
Fix memory handling of duplicated id hashtable and add unit test
2009-08-14 15:56:44 +02:00
Matthias Clasen
de3cc27706 Cleanup some translation handling
Use g_*gettext functions in gdk-pixbuf instead direct gettext
calls to benefit from the maybe-dont-translate functionality
in GLib. Also, replace a hand-rolled version by g_dpgettext2
in gtkbuilderparser.c. Fixes bug 585791.
2009-06-15 18:25:04 -04:00
Matthias Clasen
6eb95098b1 Don't leak RequiresInfo when parsing GtkBuilder files
This fixes bug 579366.
2009-05-03 23:32:33 -04:00
Matthias Clasen
eeb3223802 Trivial formatting fix 2009-04-06 20:45:11 -04:00
Matthias Clasen
1a312bfa3e Improve GtkBuilder error reporting
Make GtkBuilder report an error when it encounters a duplicate id,
instead of segfaulting later on
2009-04-06 20:13:35 -04:00
Matthias Clasen
c885c8afd2 2.15.0
svn path=/trunk/; revision=22037
2009-01-01 22:24:56 +00:00
Matthias Clasen
70675377c0 Make gtk_builder_get_translation_domain() useful for subparsers.
* gtk/gtkbuilderparser.c: Make gtk_builder_get_translation_domain()
        useful for subparsers.

        * gtk/gtkcontainer.c: Make the child property parser support
        translatable child properties.


svn path=/trunk/; revision=21855
2008-12-08 03:57:16 +00:00
Paolo Borelli
6ee8be8899 Bug 447998 - GtkBuilder does not support building parts of the xml tree
2008-07-15  Paolo Borelli  <pborelli@katamail.com>

	Bug 447998 - GtkBuilder does not support building parts of the xml tree

	* gtk/gtkbuilder.c:
	* gtk/gtkbuilder.h:
	* gtk/gtkbuilderprivate.h:
	* gtk/gtkbuilderparser.c:
	* gtk/gtk.symbols:
	Add two new functions that allow cherry picking and construct
	objects from a ui description file or string.

	* gtk/tests/builder.c: tests for the above.


svn path=/trunk/; revision=20845
2008-07-16 15:36:53 +00:00
Matthias Clasen
7d9cf87a04 Set properties in the order in which they are specified in the xml file.
* gtk/gtkbuilderparser.c (parse_custom): Set properties in the order
        in which they are specified in the xml file.


svn path=/trunk/; revision=20749
2008-07-03 18:09:04 +00:00
Johan Dahlin
d97cdbdf53 Include "config.h" instead of <config.h> Command used: find -name
2008-06-21  Johan Dahlin  <jdahlin@async.com.br>

    * *.[ch]: Include "config.h" instead of <config.h>
    Command used:
    find -name \*.[ch]|xargs perl -p -i -e 's/^#include <config.h>/#include "config.h"/g'
    Rubberstamped by Mitch and Tim


svn path=/trunk/; revision=20669
2008-06-22 14:28:52 +00:00
Behdad Esfahbod
d76e3d552e Bug 503071 – Application direction changes to right to left even if
2008-06-11  Behdad Esfahbod  <behdad@gnome.org>

        Bug 503071 – Application direction changes to right to left even if
        theres no translation

        * configure.in: Bump glib requirement.

        * gtk/gtkaccellabel.c
        (_gtk_accel_label_class_get_accelerator_label):
        * gtk/gtkactiongroup.c (dgettext_swapped):
        * gtk/gtkbuilder.c (gtk_builder_class_init):
        * gtk/gtkbuilderparser.c (_dpgettext),
        (_gtk_builder_parser_translate):
        * gtk/gtkfilechooserdefault.c (list_size_data_func):
        * gtk/gtkimmulticontext.c (gtk_im_multicontext_append_menuitems):
        * gtk/gtkintl.h:
        * gtk/gtkmain.c (setlocale_initialization),
        (do_pre_parse_initialization), (gettext_initialization):
        * gtk/gtkstock.c (gtk_stock_lookup), (sgettext_swapped):
        Use g_dgettext() and g_dngettext().


svn path=/trunk/; revision=20358
2008-06-11 23:40:35 +00:00
Tristan Van Berkom
7b0ef2095a Added support for parsing required toolkit versions (so that ui
* gtk/gtkbuilderprivate.h, gtk/gtkbuilder.h, gtk/gtkbuilderparser.c:
	Added support for parsing required toolkit versions (so that ui descriptions
	can target specific versions of the backend widget libraries) bug 527612.

	* gtk/docs/reference/gtk/tmpl/gtkbuilder.sgml: Added documentation
	for the added xml tags to the ui description.


svn path=/trunk/; revision=20152
2008-05-25 15:12:39 +00:00
14:27:34 Tim Janik
4d1892710f Bug 503071 - Application direction changes to right to left even if theres
2008-05-20 14:27:34  Tim Janik  <timj@imendio.com>

        * reverted recent unapproved changes by Yair Hershkovitz, regarding:
        Bug 503071 - Application direction changes to right to left even if theres no translation.



svn path=/trunk/; revision=20116
2008-05-20 13:03:41 +00:00
Yair Hershkovitz
670775d8d8 call g_i18n_init() in gettext_initialization(). do gettext_initialization
2008-05-11  Yair Hershkovitz  <yairhr@gmail.com>

        * gtk/gtkmain.c: call g_i18n_init() in gettext_initialization(). do
        gettext_initialization only once.

        *  gtk/gtkbuilderparser.c: use glib i18n api. removed dpgettext() as it
        duplicates g_dpgettext() and added _g_dpgettext() to wrap g_dpgettext 
        with the extended functionality that was in the removed dpgettext().

        * gtk/gtkaccellabelc:
        * gtk/gtkstock.c:
        * gtk/gtkimmulticontext.c:
        * gtk/gtkactiongroup.c:
        * gtk/gtkintl.h: use glib i18n api.


svn path=/trunk/; revision=20091
2008-05-11 09:49:30 +00:00
Michael Natterer
9f1bc132a2 gtk/gtkicontheme.h include <gdk/gdk.h> instead of <gdk/gdkscreen.h>.
2008-04-18  Michael Natterer  <mitch@imendio.com>

	* gtk/gtkicontheme.h
	* gtk/gtkrecentmanager.h: include <gdk/gdk.h> instead of
	<gdk/gdkscreen.h>.

	* gtk/gtkbuilderparser.c
	* gtk/gtklinkbutton.c
	* gtk/gtkpreview.c
	* gtk/gtkrecentchooserdefault.c
	* gtk/gtkrecentchoosermenu.c
	* modules/input/gtkimcontextthai.c: remove inclusion of single
	files from gdk, none of the includes was actually needed.


svn path=/trunk/; revision=20023
2008-04-18 14:56:23 +00:00
Johan Dahlin
424cc287f1 - Treat enums like enums and not values - Avoid invalid free, in case of
2008-03-07  Johan Dahlin  <johan@gnome.org>

    * gtk/gtkbuilder.c:
    * gtk/gtkbuilderparser.c:
    * gtk/gtkbuilderprivate.h:
    * gtk/gtkiconfactory.c:
    * tests/buildertest.c:
    - Treat enums like enums and not values
    - Avoid invalid free, in case of more than two sources
    - Add better error messages
    - Add much improved tests
    (#520979, Christian Persch)


svn path=/trunk/; revision=19732
2008-03-07 20:03:35 +00:00
Johan Dahlin
e2534d54e1 Add translatable/context and comment attributes on <col> tags under a
2008-02-29  Johan Dahlin  <johan@gnome.org>

	* demos/gtk-demo/demo.ui:
	* gtk/gtkbuilderparser.c:
	* gtk/gtkbuilderprivate.h:
	* gtk/gtkliststore.c:
	* tests/buildertest.c:
	Add translatable/context and comment attributes on
	<col> tags under a GtkListStore. Refactor parts of the
	translation api and make it available inside gtk+ itself.
	Update tests and example.
	Fixes a part of #518642


svn path=/trunk/; revision=19685
2008-03-02 01:14:48 +00:00
Johan Dahlin
a57b66aac2 Do not use g_error for a few more errors, instead set the GError sent in
2008-02-29  Johan Dahlin  <johan@gnome.org>

	* gtk/gtkbuilder.c:
	* gtk/gtkbuilderparser.c:
	* gtk/gtkbuilderprivate.h:
	Do not use g_error for a few more errors, instead set
	the GError sent in through add_from_file/add_from_string.
	* tests/buildertest.c:
	Add a couple of new parsing tests.
	(#519199, Pavel Syomin)


svn path=/trunk/; revision=19681
2008-03-01 13:49:06 +00:00
Matthias Clasen
9d6954734d Fix some i18n errors. Pointed out by Behdad Esfahbod.
2008-02-12  Matthias Clasen  <mclasne@redhat.com>

        * gtk/gtkpapersize.c:
        * gtk/gtkprintoperation.c:
        * gtk/gtkvolumebutton.c:
        * gtk/gtkbulderparser.c: Fix some i18n errors. Pointed
        out by Behdad Esfahbod.



svn path=/trunk/; revision=19547
2008-02-12 22:43:35 +00:00
Michael Natterer
63af2cd041 use the right type for "subparser_data" and remove the (gpointer*) cast.
2008-01-30  Michael Natterer  <mitch@imendio.com>

	* gtk/gtkbuilderparser.c (parse_custom): use the right type for
	"subparser_data" and remove the (gpointer*) cast. Fixes bogus
	aliasing warning.

	* gtk/updateiconcache.c (add_string): cast const gchar* to
	gpointer when inserting in a GHashTable.

	* tests/testcalendar.c (calendar_detail_cb): remove const from
	return value since it's a newly allocated string.

	(calendar_update_details): free the detail.


svn path=/trunk/; revision=19431
2008-01-30 15:06:06 +00:00
Johan Dahlin
0e09e8b3ff Allow domains to be overridden in <interface>'s if a translation-domain is
2008-01-06  Johan Dahlin  <johan@gnome.org>

	* gtk/gtkbuilderparser.c (parse_interface): 
	Allow domains to be overridden in <interface>'s if a translation-domain
	is set in the builder.
	(_gtk_builder_parser_parse_buffer): Do not modify the translation-domain
	of the builder, make the domain set in the <interface> apply only to strings
	in that interface.
	(#496831, Ryan Lortie)


svn path=/trunk/; revision=19316
2008-01-06 15:17:26 +00:00
Matthias Clasen
464ae98495 Leak less in error paths
svn path=/trunk/; revision=18980
2007-11-10 23:57:32 +00:00
Matthias Clasen
6665188687 More robustness improvements of the parser
svn path=/trunk/; revision=18978
2007-11-10 04:50:15 +00:00
Matthias Clasen
f489387039 Don't assert on misplaced signal elements
svn path=/trunk/; revision=18977
2007-11-10 04:15:44 +00:00
Matthias Clasen
c3fcd42eda Handle misplaced property elements without asserting.
2007-11-09  Matthias Clasen  <mclasen@redhat.com>

        * gtk/gtkbuilderparser.c (parse_property): Handle misplaced
        property elements without asserting.


svn path=/trunk/; revision=18976
2007-11-10 02:36:56 +00:00
Ryan Lortie
36605333d0 Add GString 'text' to the property info structure. Used to accumulate
2007-11-07  Ryan Lortie  <desrt@desrt.ca>

        * gtk/gtkbuilderprivate.h: Add GString 'text' to the property info
        structure.  Used to accumulate property text across multiple 'text'
        calls.

        * gtk/gtkbuilderparser.c: Instead of translating/copying text on each
        'text' call while in <property> accumulate the text until the end and
        do it all in one go.  This fixes handling of <!-- --> inside
        properties as well as <property/> cases.


svn path=/trunk/; revision=18970
2007-11-08 04:12:52 +00:00
Johan Dahlin
fa13277655 Parse signals after <child> tags and add tests. (#468793, Benjamin Otte)
2007-10-24  Johan Dahlin  <jdahlin@async.com.br>

	* gtk/gtkbuilder.c: (_gtk_builder_construct),
	(_gtk_builder_add_signals):
	* gtk/gtkbuilderparser.c: (end_element):
	* gtk/gtkbuilderprivate.h:
	* tests/buildertest.c: (test_connect_signals):

	Parse signals after <child> tags and add tests.
	(#468793, Benjamin Otte)


svn path=/trunk/; revision=18944
2007-10-24 11:48:17 +00:00
Johan Dahlin
1d332bbb44 Allow empty property nodes so we can set empty strings. (#486420, Xavier
2007-10-24  Johan Dahlin  <jdahlin@async.com.br>

	* gtk/gtkbuilderparser.c (end_element): Allow empty property nodes
	so we can set empty strings. (#486420, Xavier Claessens)


svn path=/trunk/; revision=18943
2007-10-24 09:46:31 +00:00
Hans Breuer
7f1bc40a84 svn path=/trunk/; revision=18842
svn path=/trunk/; revision=18842
2007-09-17 19:53:54 +00:00
Jan Arne Petersen
d18eaf32dd Duplicate the string returned by d[n]gettext before it is potentially
2007-08-23  Jan Arne Petersen  <jpetersen@jpetersen.org>

	* gtk/gtkbuilderparser.c: (text): Duplicate the string returned by
	d[n]gettext before it is potentially freed. (#461945)


svn path=/trunk/; revision=18678
2007-08-23 15:29:59 +00:00
Johan Dahlin
12e1855bba Do not assume that text is null-terminated as pointed out by Christopher
2007-08-07  Johan Dahlin  <jdahlin@async.com.br>

    * gtk/gtkbuilderparser.c (text): 
    * gtk/gtkcelllayout.c (attributes_text_element): 
    * gtk/gtkliststore.c (list_store_text): 
    Do not assume that text is null-terminated as pointed out by
    Christopher Fergeau


svn path=/trunk/; revision=18592
2007-08-07 21:52:29 +00:00
Johan Dahlin
f09b3248af Use g_strdup on the translated string instead of g_strndup() + the length
2007-08-07  Johan Dahlin  <jdahlin@async.com.br>

    * gtk/gtkbuilderparser.c (text): Use g_strdup on the translated
    string instead of g_strndup() + the length of the untranslated
    string. (#461945, Claude Paroz)


svn path=/trunk/; revision=18588
2007-08-07 21:04:23 +00:00
Matthias Clasen
8f98233aff Support old-style message contexts, too.
2007-07-08  Matthias Clasen  <mclasen@redhat.com>

        * gtk/gtkbuilderparser.c (pgettext): Support old-style
        message contexts, too.



svn path=/trunk/; revision=18405
2007-07-08 16:37:43 +00:00
Johan Dahlin
db376bf7de Parse last_modification_time attribute in <signal> tag
2007-07-08  Johan Dahlin  <jdahlin@async.com.br>

    * gtk/gtkbuilderparser.c (parse_signal): Parse last_modification_time
    attribute in <signal> tag


svn path=/trunk/; revision=18402
2007-07-08 13:39:42 +00:00
Matthias Clasen
5f3729b87c Add support for context and comments on properties
svn path=/trunk/; revision=18401
2007-07-08 05:27:22 +00:00