Commit f6a3aa02 authored by Christian Persch's avatar Christian Persch

Make GucharmapCodepointList abstract, and move the block codepoint list to...

Make GucharmapCodepointList abstract, and move the block codepoint list to GucharmapBlockCodepointList.

svn path=/trunk/; revision=1732
parent 7ed1362e
......@@ -2,7 +2,6 @@
<FILE>gucharmap-codepoint-list</FILE>
<TITLE>GucharmapCodepointList</TITLE>
GucharmapCodepointList
gucharmap_codepoint_list_new
gucharmap_codepoint_list_get_char
gucharmap_codepoint_list_get_index
gucharmap_codepoint_list_get_last_index
......@@ -52,6 +51,22 @@ GUCHARMAP_IS_CHAPTERS_MODEL_CLASS
GUCHARMAP_CHAPTERS_MODEL_GET_CLASS
</SECTION>
<SECTION>
<FILE>gucharmap-block-codepoint-list</FILE>
GucharmapBlockCodepointListPrivate
<TITLE>GucharmapBlockCodepointList</TITLE>
GucharmapBlockCodepointList
gucharmap_block_codepoint_list_new
<SUBSECTION Standard>
GUCHARMAP_BLOCK_CODEPOINT_LIST
GUCHARMAP_IS_BLOCK_CODEPOINT_LIST
GUCHARMAP_TYPE_BLOCK_CODEPOINT_LIST
gucharmap_block_codepoint_list_get_type
GUCHARMAP_BLOCK_CODEPOINT_LIST_CLASS
GUCHARMAP_IS_BLOCK_CODEPOINT_LIST_CLASS
GUCHARMAP_BLOCK_CODEPOINT_LIST_GET_CLASS
</SECTION>
<SECTION>
<FILE>gucharmap-chartable</FILE>
GucharmapChartablePrivate
......@@ -95,6 +110,7 @@ GUCHARMAP_SCRIPT_CHAPTERS_MODEL_GET_CLASS
<SECTION>
<FILE>gucharmap-script-codepoint-list</FILE>
GucharmapScriptCodepointListPrivate
<TITLE>GucharmapScriptCodepointList</TITLE>
GucharmapScriptCodepointList
gucharmap_script_codepoint_list_new
......@@ -196,11 +212,3 @@ gucharmap_unicode_version_to_string
gucharmap_unicode_get_locale_character
</SECTION>
<SECTION>
<FILE>gucharmap</FILE>
GUCHARMAP_VERSION_MAJOR
GUCHARMAP_VERSION_MINOR
GUCHARMAP_VERSION_MICRO
GUCHARMAP_CHECK_VERSION
</SECTION>
......@@ -2,6 +2,7 @@
#include <gucharmap/gucharmap.h>
gucharmap_block_chapters_model_get_type
gucharmap_block_codepoint_list_get_type
gucharmap_chapters_model_get_type
gucharmap_chapters_view_get_type
gucharmap_charmap_get_type
......
<!-- ##### SECTION Title ##### -->
GucharmapBlockCodepointList
<!-- ##### SECTION Short_Description ##### -->
<!-- ##### SECTION Long_Description ##### -->
<para>
</para>
<!-- ##### SECTION See_Also ##### -->
<para>
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GucharmapBlockCodepointListPrivate ##### -->
<para>
</para>
<!-- ##### STRUCT GucharmapBlockCodepointList ##### -->
<para>
</para>
<!-- ##### FUNCTION gucharmap_block_codepoint_list_new ##### -->
<para>
</para>
@start:
@end:
@Returns:
......@@ -23,16 +23,6 @@ GucharmapCodepointList
</para>
<!-- ##### FUNCTION gucharmap_codepoint_list_new ##### -->
<para>
</para>
@start:
@end:
@Returns:
<!-- ##### FUNCTION gucharmap_codepoint_list_get_char ##### -->
<para>
......
......@@ -17,6 +17,12 @@ GucharmapScriptCodepointList
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GucharmapScriptCodepointListPrivate ##### -->
<para>
</para>
<!-- ##### STRUCT GucharmapScriptCodepointList ##### -->
<para>
......
<!-- ##### SECTION ./tmpl/gucharmap.sgml:Long_Description ##### -->
<para>
</para>
<!-- ##### SECTION ./tmpl/gucharmap.sgml:See_Also ##### -->
<para>
</para>
<!-- ##### SECTION ./tmpl/gucharmap.sgml:Short_Description ##### -->
<!-- ##### SECTION ./tmpl/gucharmap.sgml:Stability_Level ##### -->
<!-- ##### SECTION ./tmpl/gucharmap.sgml:Title ##### -->
gucharmap
<!-- ##### MACRO GUCHARMAP_CHECK_VERSION ##### -->
<para>
</para>
@major:
@minor:
@micro:
<!-- ##### MACRO GUCHARMAP_VERSION_MAJOR ##### -->
<para>
</para>
<!-- ##### MACRO GUCHARMAP_VERSION_MICRO ##### -->
<para>
</para>
<!-- ##### MACRO GUCHARMAP_VERSION_MINOR ##### -->
<para>
</para>
<!-- ##### FUNCTION gucharmap_codepoint_list_new ##### -->
<para>
</para>
@start:
@end:
@Returns:
......@@ -17,34 +17,3 @@ gucharmap
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### MACRO GUCHARMAP_VERSION_MAJOR ##### -->
<para>
</para>
<!-- ##### MACRO GUCHARMAP_VERSION_MINOR ##### -->
<para>
</para>
<!-- ##### MACRO GUCHARMAP_VERSION_MICRO ##### -->
<para>
</para>
<!-- ##### MACRO GUCHARMAP_CHECK_VERSION ##### -->
<para>
</para>
@major:
@minor:
@micro:
......@@ -18,13 +18,13 @@
NULL =
localedir = $(datadir)/locale
lib_LTLIBRARIES = libgucharmap.la
libgucharmap_la_SOURCES = \
gucharmap-block-chapters-model.c \
gucharmap-block-chapters-model.h \
gucharmap-block-codepoint-list.c \
gucharmap-block-codepoint-list.h \
gucharmap-chapters-model.c \
gucharmap-chapters-model.h \
gucharmap-chapters-view.c \
......@@ -64,7 +64,7 @@ libgucharmap_la_CPPFLAGS = \
-I$(top_srcdir) \
-DGUCHARMAP_COMPILATION \
-DDATADIR=\"$(datadir)\" \
-DLOCALEDIR=\"$(localedir)\" \
-DLOCALEDIR=\"$(datadir)/locale\" \
$(DISABLE_DEPRECATED) \
$(AM_CPPFLAGS)
......@@ -116,7 +116,7 @@ gucharmap_SOURCES = \
gucharmap_CPPFLAGS = \
-I$(top_srcdir) \
-DDATADIR=\"$(datadir)\" \
-DLOCALEDIR=\"$(localedir)\" \
-DLOCALEDIR=\"$(datadir)/locale\" \
$(DISABLE_DEPRECATED) \
$(AM_CPPFLAGS)
......
......@@ -80,9 +80,9 @@ get_codepoint_list (GucharmapChaptersModel *chapters,
/* special "All" block */
if (unicode_block == NULL)
return gucharmap_codepoint_list_new (0, UNICHAR_MAX);
return gucharmap_block_codepoint_list_new (0, UNICHAR_MAX);
return gucharmap_codepoint_list_new (unicode_block->start, unicode_block->end);
return gucharmap_block_codepoint_list_new (unicode_block->start, unicode_block->end);
}
static G_CONST_RETURN GucharmapCodepointList *
......@@ -91,7 +91,7 @@ get_book_codepoint_list (GucharmapChaptersModel *model)
GucharmapChaptersModelPrivate *model_priv = model->priv;
if (model_priv->book_list == NULL) {
model_priv->book_list = gucharmap_codepoint_list_new (0, UNICHAR_MAX);
model_priv->book_list = gucharmap_block_codepoint_list_new (0, UNICHAR_MAX);
}
return model_priv->book_list;
......
/*
* Copyright © 2004 Noah Levitt
*
* 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 02110-1301 USA
*/
#include <config.h>
#include <glib.h>
#include "gucharmap.h"
#include "gucharmap-private.h"
struct _GucharmapBlockCodepointListPrivate
{
gunichar start;
gunichar end;
};
static gunichar
get_char (GucharmapCodepointList *list,
gint index)
{
GucharmapBlockCodepointList *block_list = GUCHARMAP_BLOCK_CODEPOINT_LIST (list);
GucharmapBlockCodepointListPrivate *priv = block_list->priv;
if (index > (gint)priv->end - priv->start)
return (gunichar)(-1);
else
return (gunichar) priv->start + index;
}
static gint
get_index (GucharmapCodepointList *list,
gunichar wc)
{
GucharmapBlockCodepointList *block_list = GUCHARMAP_BLOCK_CODEPOINT_LIST (list);
GucharmapBlockCodepointListPrivate *priv = block_list->priv;
if (wc < priv->start || wc > priv->end)
return -1;
else
return wc - priv->start;
}
static gint
get_last_index (GucharmapCodepointList *list)
{
GucharmapBlockCodepointList *block_list = GUCHARMAP_BLOCK_CODEPOINT_LIST (list);
GucharmapBlockCodepointListPrivate *priv = block_list->priv;
return priv->end - priv->start;
}
static void
gucharmap_block_codepoint_list_init (GucharmapBlockCodepointList *list)
{
list->priv = G_TYPE_INSTANCE_GET_PRIVATE (list, GUCHARMAP_TYPE_BLOCK_CODEPOINT_LIST, GucharmapBlockCodepointListPrivate);
}
static void
gucharmap_block_codepoint_list_class_init (GucharmapBlockCodepointListClass *klass)
{
GucharmapCodepointListClass *codepoint_list_class = GUCHARMAP_CODEPOINT_LIST_CLASS (klass);
g_type_class_add_private (klass, sizeof (GucharmapBlockCodepointListPrivate));
codepoint_list_class->get_char = get_char;
codepoint_list_class->get_index = get_index;
codepoint_list_class->get_last_index = get_last_index;
}
G_DEFINE_TYPE (GucharmapBlockCodepointList, gucharmap_block_codepoint_list, GUCHARMAP_TYPE_CODEPOINT_LIST)
/**
* gucharmap_block_codepoint_list_new:
*
* Creates a new codepoint list.
*
* Return value: the newly-created #GucharmapBlockCodepointList. Use
* g_object_unref() to free the result.
**/
GucharmapCodepointList *
gucharmap_block_codepoint_list_new (gunichar start,
gunichar end)
{
GucharmapCodepointList *list;
GucharmapBlockCodepointListPrivate *priv;
g_return_val_if_fail (start <= end, NULL);
list = g_object_new (GUCHARMAP_TYPE_BLOCK_CODEPOINT_LIST, NULL);
priv = GUCHARMAP_BLOCK_CODEPOINT_LIST (list)->priv;
/* XXX: what to do if start > end, etc */
priv->start = start;
if (end <= UNICHAR_MAX)
priv->end = end;
else
priv->end = UNICHAR_MAX;
return list;
}
/*
* Copyright © 2004 Noah Levitt
*
* 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 02110-1301 USA
*/
#if !defined (__GUCHARMAP_GUCHARMAP_H_INSIDE__) && !defined (GUCHARMAP_COMPILATION)
#error "Only <gucharmap/gucharmap.h> can be included directly."
#endif
#ifndef GUCHARMAP_BLOCK_CODEPOINT_LIST_H
#define GUCHARMAP_BLOCK_CODEPOINT_LIST_H
#include <glib-object.h>
#include <gucharmap/gucharmap-codepoint-list.h>
G_BEGIN_DECLS
#define GUCHARMAP_TYPE_BLOCK_CODEPOINT_LIST (gucharmap_block_codepoint_list_get_type ())
#define GUCHARMAP_BLOCK_CODEPOINT_LIST(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GUCHARMAP_TYPE_BLOCK_CODEPOINT_LIST, GucharmapBlockCodepointList))
#define GUCHARMAP_BLOCK_CODEPOINT_LIST_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GUCHARMAP_TYPE_BLOCK_CODEPOINT_LIST, GucharmapBlockCodepointListClass))
#define GUCHARMAP_IS_BLOCK_CODEPOINT_LIST(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GUCHARMAP_TYPE_BLOCK_CODEPOINT_LIST))
#define GUCHARMAP_IS_BLOCK_CODEPOINT_LIST_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GUCHARMAP_TYPE_BLOCK_CODEPOINT_LIST))
#define GUCHARMAP_BLOCK_CODEPOINT_LIST_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GUCHARMAP_TYPE_BLOCK_CODEPOINT_LIST, GucharmapBlockCodepointListClass))
typedef struct _GucharmapBlockCodepointList GucharmapBlockCodepointList;
typedef struct _GucharmapBlockCodepointListPrivate GucharmapBlockCodepointListPrivate;
typedef struct _GucharmapBlockCodepointListClass GucharmapBlockCodepointListClass;
struct _GucharmapBlockCodepointList
{
GucharmapCodepointList parent_instance;
/*< private >*/
GucharmapBlockCodepointListPrivate *priv;
};
struct _GucharmapBlockCodepointListClass
{
GucharmapCodepointListClass parent_class;
};
GType gucharmap_block_codepoint_list_get_type (void);
GucharmapCodepointList * gucharmap_block_codepoint_list_new (gunichar start,
gunichar end);
G_END_DECLS
#endif /* #ifndef GUCHARMAP_BLOCK_CODEPOINT_LIST_H */
......@@ -31,7 +31,7 @@ static GucharmapCodepointList *
default_get_codepoint_list (GucharmapChaptersModel *chapters,
GtkTreeIter *iter)
{
return gucharmap_codepoint_list_new (0, UNICHAR_MAX);
return gucharmap_block_codepoint_list_new (0, UNICHAR_MAX);
}
static void
......
......@@ -22,49 +22,6 @@
#include "gucharmap.h"
#include "gucharmap-private.h"
typedef struct _DefaultCodepointListPrivate DefaultCodepointListPrivate;
struct _DefaultCodepointListPrivate
{
gunichar start;
gunichar end;
};
#define GUCHARMAP_CODEPOINT_LIST_GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), gucharmap_codepoint_list_get_type (), DefaultCodepointListPrivate))
static gunichar
default_get_char (GucharmapCodepointList *list,
gint index)
{
DefaultCodepointListPrivate *priv = GUCHARMAP_CODEPOINT_LIST_GET_PRIVATE (list);
if (index > (gint)priv->end - priv->start)
return (gunichar)(-1);
else
return (gunichar) priv->start + index;
}
static gint
default_get_index (GucharmapCodepointList *list,
gunichar wc)
{
DefaultCodepointListPrivate *priv = GUCHARMAP_CODEPOINT_LIST_GET_PRIVATE (list);
if (wc < priv->start || wc > priv->end)
return -1;
else
return wc - priv->start;
}
static gint
default_get_last_index (GucharmapCodepointList *list)
{
DefaultCodepointListPrivate *priv = GUCHARMAP_CODEPOINT_LIST_GET_PRIVATE (list);
return priv->end - priv->start;
}
static void
gucharmap_codepoint_list_init (GucharmapCodepointList *list)
{
......@@ -73,15 +30,9 @@ gucharmap_codepoint_list_init (GucharmapCodepointList *list)
static void
gucharmap_codepoint_list_class_init (GucharmapCodepointListClass *clazz)
{
g_type_class_add_private (clazz, sizeof (DefaultCodepointListPrivate));
/* the default implementation is all unicode codepoints in order */
clazz->get_char = default_get_char;
clazz->get_index = default_get_index;
clazz->get_last_index = default_get_last_index;
}
G_DEFINE_TYPE (GucharmapCodepointList, gucharmap_codepoint_list, G_TYPE_OBJECT)
G_DEFINE_ABSTRACT_TYPE (GucharmapCodepointList, gucharmap_codepoint_list, G_TYPE_OBJECT)
/**
* gucharmap_codepoint_list_get_char:
......@@ -130,33 +81,3 @@ gucharmap_codepoint_list_get_last_index (GucharmapCodepointList *list)
return GUCHARMAP_CODEPOINT_LIST_GET_CLASS (list)->get_last_index (list);
}
/**
* gucharmap_codepoint_list_new:
*
* Creates a new codepoint list.
*
* Return value: the newly-created #GucharmapCodepointList. Use
* g_object_unref() to free the result.
**/
GucharmapCodepointList *
gucharmap_codepoint_list_new (gunichar start,
gunichar end)
{
GucharmapCodepointList *list;
DefaultCodepointListPrivate *priv;
list = GUCHARMAP_CODEPOINT_LIST (g_object_new (gucharmap_codepoint_list_get_type (), NULL));
priv = GUCHARMAP_CODEPOINT_LIST_GET_PRIVATE (list);
/* XXX: what to do if start > end, etc */
priv->start = start;
if (end <= UNICHAR_MAX)
priv->end = end;
else
priv->end = UNICHAR_MAX;
return list;
}
......@@ -29,7 +29,7 @@ G_BEGIN_DECLS
#define GUCHARMAP_TYPE_CODEPOINT_LIST (gucharmap_codepoint_list_get_type ())
#define GUCHARMAP_CODEPOINT_LIST(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GUCHARMAP_TYPE_CODEPOINT_LIST, GucharmapCodepointList))
#define GUCHARMAP_CODEPOINT_LIST_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GUCHARMAP_TYPE_CODEPOINT_LIST, GucharmapCodepointListClass))
#define GUCHARMAP_CODEPOINT_LIST_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GUCHARMAP_TYPE_CODEPOINT_LIST, GucharmapCodepointListClass))
#define GUCHARMAP_IS_CODEPOINT_LIST(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GUCHARMAP_TYPE_CODEPOINT_LIST))
#define GUCHARMAP_IS_CODEPOINT_LIST_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GUCHARMAP_TYPE_CODEPOINT_LIST))
#define GUCHARMAP_CODEPOINT_LIST_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GUCHARMAP_TYPE_CODEPOINT_LIST, GucharmapCodepointListClass))
......@@ -55,15 +55,15 @@ struct _GucharmapCodepointListClass
};
GType gucharmap_codepoint_list_get_type (void);
GucharmapCodepointList * gucharmap_codepoint_list_new (gunichar start,
gunichar end);
gunichar gucharmap_codepoint_list_get_char (GucharmapCodepointList *list,
gunichar gucharmap_codepoint_list_get_char (GucharmapCodepointList *list,
gint index);
gint gucharmap_codepoint_list_get_index (GucharmapCodepointList *list,
gunichar wc);
gint gucharmap_codepoint_list_get_last_index (GucharmapCodepointList *list);
G_END_DECLS
#endif /* #ifndef GUCHARMAP_CODEPOINT_LIST_H */
......@@ -24,7 +24,6 @@
#define GUCHARMAP_SCRIPT_CODEPOINT_LIST_H
#include <glib-object.h>
#include <glib.h>
#include <gucharmap/gucharmap-codepoint-list.h>
......
......@@ -31,14 +31,19 @@
(GUCHARMAP_VERSION_MAJOR == (major) && GUCHARMAP_VERSION_MINOR > (minor)) || \
(GUCHARMAP_VERSION_MAJOR == (major) && GUCHARMAP_VERSION_MINOR == (minor) && GUCHARMAP_VERSION_MICRO >= (micro)))
#include <gucharmap/gucharmap-block-chapters-model.h>
#include <gucharmap/gucharmap-chapters-model.h>
#include <gucharmap/gucharmap-charmap.h>
#include <gucharmap/gucharmap-chartable.h>
#include <gucharmap/gucharmap-codepoint-list.h>
#include <gucharmap/gucharmap-script-chapters-model.h>
#include <gucharmap/gucharmap-block-codepoint-list.h>
#include <gucharmap/gucharmap-script-codepoint-list.h>
#include <gucharmap/gucharmap-chapters-model.h>
#include <gucharmap/gucharmap-block-chapters-model.h>
#include <gucharmap/gucharmap-script-chapters-model.h>
#include <gucharmap/gucharmap-chartable.h>
#include <gucharmap/gucharmap-charmap.h>
#include <gucharmap/gucharmap-type-builtins.h>
#include <gucharmap/gucharmap-unicode-info.h>
#undef __GUCHARMAP_GUCHARMAP_H_INSIDE__
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment