gimp r24828 - in trunk: . app/widgets
- From: neo svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r24828 - in trunk: . app/widgets
- Date: Thu, 7 Feb 2008 16:50:11 +0000 (GMT)
Author: neo
Date: Thu Feb 7 16:50:11 2008
New Revision: 24828
URL: http://svn.gnome.org/viewvc/gimp?rev=24828&view=rev
Log:
2008-02-07 Sven Neumann <sven gimp org>
* configure.in: added configure checks for the iso-codes package.
* app/widgets/Makefile.am
* app/widgets/widgets-types.h
* app/widgets/gimplanguagestore.[ch]:
* app/widgets/gimplanguagestore-parser.[ch]: added rough outline
of GtkListStore for language selection.
Added:
trunk/app/widgets/gimplanguagestore-parser.c (contents, props changed)
trunk/app/widgets/gimplanguagestore-parser.h (contents, props changed)
trunk/app/widgets/gimplanguagestore.c (contents, props changed)
trunk/app/widgets/gimplanguagestore.h (contents, props changed)
Modified:
trunk/ChangeLog
trunk/app/widgets/Makefile.am
trunk/app/widgets/widgets-types.h
trunk/configure.in
Modified: trunk/app/widgets/Makefile.am
==============================================================================
--- trunk/app/widgets/Makefile.am (original)
+++ trunk/app/widgets/Makefile.am Thu Feb 7 16:50:11 2008
@@ -1,6 +1,8 @@
## Process this file with automake to produce Makefile.in
AM_CPPFLAGS = \
+ -DISO_CODES_LOCATION=\"$(ISO_CODES_LOCATION)\" \
+ -DISO_CODES_LOCALEDIR=\"$(ISO_CODES_LOCALEDIR)\" \
-DG_LOG_DOMAIN=\"Gimp-Widgets\"
INCLUDES = \
@@ -187,6 +189,10 @@
gimpimageview.h \
gimpitemtreeview.c \
gimpitemtreeview.h \
+ gimplanguagestore.c \
+ gimplanguagestore.h \
+ gimplanguagestore-parser.c \
+ gimplanguagestore-parser.h \
gimplayertreeview.c \
gimplayertreeview.h \
gimpmenudock.c \
Added: trunk/app/widgets/gimplanguagestore-parser.c
==============================================================================
--- (empty file)
+++ trunk/app/widgets/gimplanguagestore-parser.c Thu Feb 7 16:50:11 2008
@@ -0,0 +1,181 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * gimplanguagestore-parser.c
+ * Copyright (C) 2008 Sven Neumann <sven gimp org>
+ *
+ * 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 of the License, 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.
+ */
+
+#include "config.h"
+
+#include <string.h>
+
+#include <gtk/gtk.h>
+
+#include "widgets-types.h"
+
+#include "config/gimpxmlparser.h"
+
+#include "gimplanguagestore.h"
+#include "gimplanguagestore-parser.h"
+
+
+typedef enum
+{
+ ISO_CODES_START,
+ ISO_CODES_IN_ENTRIES,
+ ISO_CODES_IN_ENTRY,
+ ISO_CODES_IN_UNKNOWN
+} IsoCodesParserState;
+
+typedef struct
+{
+ IsoCodesParserState state;
+ IsoCodesParserState last_known_state;
+ gint unknown_depth;
+ GString *value;
+ GimpLanguageStore *store;
+} IsoCodesParser;
+
+
+static void iso_codes_parser_start_element (GMarkupParseContext *context,
+ const gchar *element_name,
+ const gchar **attribute_names,
+ const gchar **attribute_values,
+ gpointer user_data,
+ GError **error);
+static void iso_codes_parser_end_element (GMarkupParseContext *context,
+ const gchar *element_name,
+ gpointer user_data,
+ GError **error);
+static void iso_codes_parser_characters (GMarkupParseContext *context,
+ const gchar *text,
+ gsize text_len,
+ gpointer user_data,
+ GError **error);
+
+static void iso_codes_parser_start_unknown (IsoCodesParser *parser);
+static void iso_codes_parser_end_unknown (IsoCodesParser *parser);
+
+
+static const GMarkupParser markup_parser =
+{
+ iso_codes_parser_start_element,
+ iso_codes_parser_end_element,
+ iso_codes_parser_characters,
+ NULL, /* passthrough */
+ NULL /* error */
+};
+
+
+gboolean
+gimp_language_store_populate (GimpLanguageStore *store,
+ GError **error)
+{
+#ifdef HAVE_ISO_CODES
+ GimpXmlParser *xml_parser;
+ gchar *filename;
+ IsoCodesParser parser = { 0, };
+
+ g_return_val_if_fail (GIMP_IS_LANGUAGE_STORE (store), FALSE);
+ g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+ parser.value = g_string_new (NULL);
+
+ xml_parser = gimp_xml_parser_new (&markup_parser, &parser);
+
+ filename = g_build_filename (ISO_CODES_LOCATION, "iso_639.xml", NULL);
+
+ gimp_xml_parser_parse_file (xml_parser, filename, error);
+
+ gimp_xml_parser_free (xml_parser);
+ g_free (filename);
+ g_string_free (parser.value, TRUE);
+#endif
+
+ return TRUE;
+}
+
+static void
+iso_codes_parser_start_element (GMarkupParseContext *context,
+ const gchar *element_name,
+ const gchar **attribute_names,
+ const gchar **attribute_values,
+ gpointer user_data,
+ GError **error)
+{
+ IsoCodesParser *parser = user_data;
+
+ switch (parser->state)
+ {
+ default:
+ iso_codes_parser_start_unknown (parser);
+ break;
+ }
+}
+
+static void
+iso_codes_parser_end_element (GMarkupParseContext *context,
+ const gchar *element_name,
+ gpointer user_data,
+ GError **error)
+{
+ IsoCodesParser *parser = user_data;
+
+ switch (parser->state)
+ {
+ default:
+ iso_codes_parser_end_unknown (parser);
+ break;
+ }
+}
+
+static void
+iso_codes_parser_characters (GMarkupParseContext *context,
+ const gchar *text,
+ gsize text_len,
+ gpointer user_data,
+ GError **error)
+{
+ IsoCodesParser *parser = user_data;
+
+ switch (parser->state)
+ {
+ default:
+ break;
+ }
+}
+
+static void
+iso_codes_parser_start_unknown (IsoCodesParser *parser)
+{
+ if (parser->unknown_depth == 0)
+ parser->last_known_state = parser->state;
+
+ parser->state = ISO_CODES_IN_UNKNOWN;
+ parser->unknown_depth++;
+}
+
+static void
+iso_codes_parser_end_unknown (IsoCodesParser *parser)
+{
+ g_assert (parser->unknown_depth > 0 && parser->state == ISO_CODES_IN_UNKNOWN);
+
+ parser->unknown_depth--;
+
+ if (parser->unknown_depth == 0)
+ parser->state = parser->last_known_state;
+}
Added: trunk/app/widgets/gimplanguagestore-parser.h
==============================================================================
--- (empty file)
+++ trunk/app/widgets/gimplanguagestore-parser.h Thu Feb 7 16:50:11 2008
@@ -0,0 +1,30 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * gimplanguagestore-parser.h
+ * Copyright (C) 2008 Sven Neumann <sven gimp org>
+ *
+ * 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 of the License, 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.
+ */
+
+#ifndef __GIMP_LANGUAGE_STORE_PARSER_H__
+#define __GIMP_LANGUAGE_STORE_PARSER_H__
+
+
+gboolean gimp_language_store_populate (GimpLanguageStore *store,
+ GError **error);
+
+
+#endif /* __GIMP_LANGUAGE_STORE_PARSER_H__ */
Added: trunk/app/widgets/gimplanguagestore.c
==============================================================================
--- (empty file)
+++ trunk/app/widgets/gimplanguagestore.c Thu Feb 7 16:50:11 2008
@@ -0,0 +1,121 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * gimplanguagestore.c
+ * Copyright (C) 2008 Sven Neumann <sven gimp org>
+ *
+ * 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 of the License, 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.
+ */
+
+#include "config.h"
+
+#include <gtk/gtk.h>
+
+#include "widgets-types.h"
+
+#include "gimplanguagestore.h"
+#include "gimplanguagestore-parser.h"
+
+
+enum
+{
+ PROP_0,
+ PROP_TRANSLATIONS
+};
+
+
+static void gimp_language_store_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gimp_language_store_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+
+G_DEFINE_TYPE (GimpLanguageStore, gimp_language_store, GTK_TYPE_LIST_STORE)
+
+static void
+gimp_language_store_class_init (GimpLanguageStoreClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->set_property = gimp_language_store_set_property;
+ object_class->get_property = gimp_language_store_get_property;
+
+ g_object_class_install_property (object_class, PROP_TRANSLATIONS,
+ g_param_spec_boolean ("translations",
+ NULL, NULL,
+ FALSE,
+ GIMP_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+}
+
+static void
+gimp_language_store_init (GimpLanguageStore *store)
+{
+ GType column_types[2] = { G_TYPE_STRING, G_TYPE_STRING };
+
+ gtk_list_store_set_column_types (GTK_LIST_STORE (store),
+ G_N_ELEMENTS (column_types), column_types);
+}
+
+static void
+gimp_language_store_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GimpLanguageStore *store = GIMP_LANGUAGE_STORE (object);
+
+ switch (property_id)
+ {
+ case PROP_TRANSLATIONS:
+ store->translations = g_value_get_boolean (value);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+gimp_language_store_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GimpLanguageStore *store = GIMP_LANGUAGE_STORE (object);
+
+ switch (property_id)
+ {
+ case PROP_TRANSLATIONS:
+ g_value_set_boolean (value, store->translations);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+GtkListStore *
+gimp_language_store_new (gboolean translations)
+{
+ return g_object_new (GIMP_TYPE_LANGUAGE_STORE,
+ "translations", translations,
+ NULL);
+}
Added: trunk/app/widgets/gimplanguagestore.h
==============================================================================
--- (empty file)
+++ trunk/app/widgets/gimplanguagestore.h Thu Feb 7 16:50:11 2008
@@ -0,0 +1,61 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * gimplanguagestore.h
+ * Copyright (C) 2008 Sven Neumann <sven gimp org>
+ *
+ * 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 of the License, 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.
+ */
+
+#ifndef __GIMP_LANGUAGE_STORE_H__
+#define __GIMP_LANGUAGE_STORE_H__
+
+
+enum
+{
+ GIMP_LANGUAGE_STORE_LANGUAGE,
+ GIMP_LANGUAGE_STORE_ISO_639_1
+};
+
+
+#define GIMP_TYPE_LANGUAGE_STORE (gimp_language_store_get_type ())
+#define GIMP_LANGUAGE_STORE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_LANGUAGE_STORE, GimpLanguageStore))
+#define GIMP_LANGUAGE_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_LANGUAGE_STORE, GimpLanguageStoreClass))
+#define GIMP_IS_LANGUAGE_STORE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_LANGUAGE_STORE))
+#define GIMP_IS_LANGUAGE_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_LANGUAGE_STORE))
+#define GIMP_LANGUAGE_STORE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_LANGUAGE_STORE, GimpLanguageStoreClass))
+
+
+typedef struct _GimpLanguageStoreClass GimpLanguageStoreClass;
+
+struct _GimpLanguageStoreClass
+{
+ GtkListStoreClass parent_class;
+};
+
+struct _GimpLanguageStore
+{
+ GtkListStore parent_instance;
+
+ gboolean translations;
+};
+
+
+GType gimp_language_store_get_type (void) G_GNUC_CONST;
+
+GtkListStore * gimp_language_store_new (gboolean translations);
+
+
+#endif /* __GIMP_LANGUAGE_STORE_H__ */
Modified: trunk/app/widgets/widgets-types.h
==============================================================================
--- trunk/app/widgets/widgets-types.h (original)
+++ trunk/app/widgets/widgets-types.h Thu Feb 7 16:50:11 2008
@@ -208,6 +208,7 @@
/* misc utilities & constructors */
typedef struct _GimpDialogFactory GimpDialogFactory;
+typedef struct _GimpLanguageStore GimpLanguageStore;
typedef struct _GimpUnitStore GimpUnitStore;
typedef struct _GimpUnitComboBox GimpUnitComboBox;
Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in (original)
+++ trunk/configure.in Thu Feb 7 16:50:11 2008
@@ -155,6 +155,10 @@
ACLOCAL="$ACLOCAL $ACLOCAL_FLAGS"
+# Check for pkg-config
+PKG_PROG_PKG_CONFIG(0.16)
+
+
###########################
# Check target architecture
###########################
@@ -401,6 +405,21 @@
AM_GLIB_GNU_GETTEXT
+AC_MSG_CHECKING([for iso-codes])
+PKG_CHECK_EXISTS(iso-codes,
+ have_iso_codes="yes"
+ AC_DEFINE(HAVE_ISO_CODES, 1,
+ [Define to 1 if the iso-codes package is available])
+ ISO_CODES_PREFIX=`$PKG_CONFIG --variable=prefix iso-codes`
+ ISO_CODES_LOCATION="$ISO_CODES_PREFIX/share/xml/iso-codes"
+ ISO_CODES_LOCALEDIR="$ISO_CODES_PREFIX/$DATADIRNAME/locale",
+ have_iso_codes="no (iso-codes package not found)")
+AC_MSG_RESULT($have_iso_codes)
+
+AC_SUBST(ISO_CODES_LOCATION)
+AC_SUBST(ISO_CODES_LOCALEDIR)
+
+
###############################
# Checks for required libraries
###############################
@@ -2067,6 +2086,7 @@
Optional Features:
D-Bus service: $have_dbus_glib
+ Language selection: $have_iso_codes
Optional Plug-Ins:
Ascii Art: $have_libaa
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]