Commit 45b85cd0 authored by Noah Levitt's avatar Noah Levitt

2003-11-23 Noah Levitt

	* gucharmap/Makefile.am:
	* gucharmap/charcell_accessible.c:
	* gucharmap/chartable_accessible.c:
	* gucharmap/gucharmap-charmap.c:
	* gucharmap/gucharmap-codepoint-list.c:
	* gucharmap/gucharmap-codepoint-list.h:
	* gucharmap/gucharmap-table.c:
	* gucharmap/gucharmap-table.h:
	* gucharmap/gucharmap-window.c:
	* gucharmap/gucharmap.h: Change chartable to keep track of cells by
	cell number instead of by character. GucharmapCodepointList gives the
	codepoint for a particular cell.
parent ed605758
2003-11-23 Noah Levitt
* gucharmap/Makefile.am:
* gucharmap/charcell_accessible.c:
* gucharmap/chartable_accessible.c:
* gucharmap/gucharmap-charmap.c:
* gucharmap/gucharmap-codepoint-list.c:
* gucharmap/gucharmap-codepoint-list.h:
* gucharmap/gucharmap-table.c:
* gucharmap/gucharmap-table.h:
* gucharmap/gucharmap-window.c:
* gucharmap/gucharmap.h: Change chartable to keep track of cells by
cell number instead of by character. GucharmapCodepointList gives the
codepoint for a particular cell.
2003-11-23 Noah Levitt
* gucharmap.desktop.in: Change Terminal=0 to Terminal=false. (#127748,
......
......@@ -39,7 +39,8 @@ libgucharmap_la_SOURCES = gucharmap_marshal.c gucharmap_marshal.h \
gucharmap-mini-fontsel.c gucharmap-mini-fontsel.h \
gucharmap-table.c gucharmap-table.h \
gucharmap-unicode-info.c gucharmap-unicode-info.h \
gucharmap-window.c gucharmap-window.h
gucharmap-window.c gucharmap-window.h \
gucharmap-codepoint-list.c gucharmap-codepoint-list.h
# this is different from the project version
......
......@@ -33,8 +33,8 @@ extern gint gucharmap_table_x_offset (GucharmapTable *chartable,
gint col);
extern gint gucharmap_table_y_offset (GucharmapTable *chartable,
gint row);
extern gint gucharmap_table_unichar_column (GucharmapTable *chartable,
gunichar uc);
extern gint gucharmap_table_cell_column (GucharmapTable *chartable,
guint cell);
extern gint gucharmap_table_row_height (GucharmapTable *chartable,
gint row);
extern gint gucharmap_table_column_width (GucharmapTable *chartable,
......@@ -139,13 +139,13 @@ charcell_accessible_get_extents (AtkComponent *component,
* Is the cell visible on the screen
*/
chartable = GUCHARMAP_TABLE (cell->widget);
if (cell->index >= chartable->page_first_char && cell->index < chartable->page_first_char + chartable->rows * chartable->cols)
if (cell->index >= chartable->page_first_cell && cell->index < chartable->page_first_cell + chartable->rows * chartable->cols)
{
atk_component_get_extents (ATK_COMPONENT (cell_parent),
&real_x, &real_y, &real_width, &real_height,
coord_type);
row = (cell->index - chartable->page_first_char)/ chartable->cols;
column = gucharmap_table_unichar_column (chartable, cell->index);
row = (cell->index - chartable->page_first_cell)/ chartable->cols;
column = gucharmap_table_cell_column (chartable, cell->index);
*x = real_x + gucharmap_table_x_offset (chartable, column);
*y = real_y + gucharmap_table_y_offset (chartable, row);
*width = gucharmap_table_column_width (chartable, column);
......
......@@ -34,8 +34,8 @@ extern gint gucharmap_table_x_offset (GucharmapTable *chartable,
gint col);
extern gint gucharmap_table_y_offset (GucharmapTable *chartable,
gint row);
extern gint gucharmap_table_unichar_column (GucharmapTable *chartable,
gunichar uc);
extern gint gucharmap_table_cell_column (GucharmapTable *chartable,
guint cell);
typedef struct
......@@ -104,8 +104,8 @@ set_cell_visibility (GucharmapTable *chartable,
{
charcell_accessible_add_state (cell, ATK_STATE_VISIBLE, emit_signal);
if (cell->index >= chartable->page_first_char &&
cell->index < chartable->page_first_char
if (cell->index >= chartable->page_first_cell &&
cell->index < chartable->page_first_cell
+ chartable->rows * chartable->cols)
{
charcell_accessible_add_state (cell, ATK_STATE_SHOWING, emit_signal);
......@@ -322,7 +322,7 @@ chartable_accessible_ref_accessible_at_point (AtkComponent *component,
if (row == chartable->rows || row < 0)
return NULL;
row += chartable->page_first_char / chartable->cols;
row += chartable->page_first_cell / chartable->cols;
return chartable_accessible_ref_at (ATK_TABLE (component), row, col);
}
......@@ -478,7 +478,7 @@ find_object (GucharmapTable *chartable,
gint row, column;
row = uc / chartable->cols;
column = gucharmap_table_unichar_column (chartable, uc);
column = gucharmap_table_cell_column (chartable, uc);
return atk_table_ref_at (ATK_TABLE (obj), row, column);
}
......@@ -528,7 +528,7 @@ chartable_accessible_initialize (AtkObject *obj,
g_signal_connect (chartable, "set_active_char",
G_CALLBACK (active_char_set), obj);
focus_obj = find_object (chartable, chartable->active_char, obj);
focus_obj = find_object (chartable, chartable->active_cell, obj);
set_focus_object (obj, focus_obj);
}
......
......@@ -81,12 +81,13 @@ find_block_index_tree_path (GucharmapCharmap *charmap, gunichar uc)
/* selects the active block in the block selector tree view based on the
* active character */
static void
set_active_block (GucharmapCharmap *charmap, gunichar uc)
set_active_block (GucharmapCharmap *charmap,
gunichar wc)
{
GtkTreePath *parent = NULL;
GtkTreePath *tree_path;
tree_path = find_block_index_tree_path (charmap, uc);
tree_path = find_block_index_tree_path (charmap, wc);
/* block our "changed" handler */
g_signal_handler_block (G_OBJECT (charmap->block_selection),
......@@ -105,20 +106,15 @@ set_active_block (GucharmapCharmap *charmap, gunichar uc)
static void
block_selection_changed (GtkTreeSelection *selection,
gpointer user_data)
GucharmapCharmap *charmap)
{
GtkTreeModel *model;
GtkTreeIter iter;
GucharmapCharmap *charmap;
gunichar uc_start;
charmap = GUCHARMAP_CHARMAP (user_data);
if (gtk_tree_selection_get_selected (selection, &model, &iter))
{
gtk_tree_model_get (model, &iter, BLOCK_SELECTOR_UC_START,
&uc_start, -1);
gunichar uc_start;
gtk_tree_model_get (model, &iter, BLOCK_SELECTOR_UC_START, &uc_start, -1);
gucharmap_table_set_active_character (charmap->chartable, uc_start);
}
}
......@@ -188,9 +184,8 @@ make_unicode_block_selector (GucharmapCharmap *charmap)
GTK_TREE_VIEW_COLUMN (column));
gtk_tree_selection_set_mode (charmap->block_selection, GTK_SELECTION_BROWSE);
charmap->block_selection_changed_handler_id = g_signal_connect (
G_OBJECT (charmap->block_selection), "changed",
G_CALLBACK (block_selection_changed), charmap);
charmap->block_selection_changed_handler_id = g_signal_connect (G_OBJECT (charmap->block_selection), "changed",
G_CALLBACK (block_selection_changed), charmap);
gtk_container_add (GTK_CONTAINER (scrolled_window),
charmap->block_selector_view);
......@@ -222,14 +217,14 @@ gucharmap_charmap_class_init (GucharmapCharmapClass *clazz)
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GucharmapCharmapClass, status_message),
NULL, NULL, gucharmap_marshal_VOID__STRING, G_TYPE_NONE,
1, G_TYPE_STRING);
1, G_TYPE_STRING);
gucharmap_charmap_signals[LINK_CLICKED] =
g_signal_new ("link-clicked", gucharmap_charmap_get_type (),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GucharmapCharmapClass, link_clicked),
NULL, NULL, gucharmap_marshal_VOID__UINT_UINT, G_TYPE_NONE,
2, G_TYPE_UINT, G_TYPE_UINT);
2, G_TYPE_UINT, G_TYPE_UINT);
G_OBJECT_CLASS (clazz)->finalize = charmap_finalize;
}
......@@ -594,8 +589,8 @@ set_details (GucharmapCharmap *charmap,
static void
active_char_set (GtkWidget *widget,
gunichar uc,
active_char_set (GtkWidget *widget,
gunichar wc,
GucharmapCharmap *charmap)
{
GString *gs;
......@@ -603,20 +598,20 @@ active_char_set (GtkWidget *widget,
const gchar **temps;
gint i;
set_active_block (charmap, uc);
set_details (charmap, uc);
set_active_block (charmap, wc);
set_details (charmap, wc);
gs = g_string_new (NULL);
g_string_append_printf (gs, "U+%4.4X %s", uc,
gucharmap_get_unicode_name (uc));
g_string_append_printf (gs, "U+%4.4X %s", wc,
gucharmap_get_unicode_name (wc));
#if ENABLE_UNIHAN
temp = gucharmap_get_unicode_kDefinition (uc);
temp = gucharmap_get_unicode_kDefinition (wc);
if (temp)
g_string_append_printf (gs, " %s", temp);
#endif
temps = gucharmap_get_nameslist_equals (uc);
temps = gucharmap_get_nameslist_equals (wc);
if (temps)
{
g_string_append_printf (gs, " = %s", temps[0]);
......@@ -625,7 +620,7 @@ active_char_set (GtkWidget *widget,
g_free (temps);
}
temps = gucharmap_get_nameslist_stars (uc);
temps = gucharmap_get_nameslist_stars (wc);
if (temps)
{
g_string_append_printf (gs, " • %s", temps[0]);
......@@ -649,15 +644,15 @@ create_tags (GucharmapCharmap *charmap)
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (charmap->details));
default_font_size = pango_font_description_get_size (
GTK_WIDGET (charmap)->style->font_desc);
GTK_WIDGET (charmap)->style->font_desc);
gtk_text_buffer_create_tag (buffer, "gimongous",
"size", 8 * default_font_size,
"size", 8 * default_font_size,
"left-margin", PANGO_PIXELS (5 * default_font_size),
NULL);
NULL);
gtk_text_buffer_create_tag (buffer, "bold",
"weight", PANGO_WEIGHT_BOLD,
NULL);
"weight", PANGO_WEIGHT_BOLD,
NULL);
gtk_text_buffer_create_tag (buffer, "big",
"size", default_font_size * 5 / 4,
NULL);
......@@ -685,7 +680,7 @@ follow_if_link (GucharmapCharmap *charmap,
if (uc != (gunichar)(-1))
{
g_signal_emit (charmap, gucharmap_charmap_signals[LINK_CLICKED],
0, charmap->chartable->active_char, uc);
0, charmap->chartable->active_cell, uc);
gucharmap_table_set_active_character (charmap->chartable, uc);
break;
}
......@@ -922,8 +917,8 @@ gucharmap_charmap_init (GucharmapCharmap *charmap)
gtk_paned_pack2 (GTK_PANED (charmap), make_chartable_pane (charmap),
TRUE, TRUE);
set_active_block (charmap, charmap->chartable->active_char);
set_details (charmap, charmap->chartable->active_char);
set_active_block (charmap, gucharmap_table_get_active_character (charmap->chartable));
set_details (charmap, gucharmap_table_get_active_character (charmap->chartable));
}
......@@ -992,28 +987,40 @@ gucharmap_charmap_go_to_character (GucharmapCharmap *charmap,
/* direction is +1 (forward) or -1 (backward) */
GucharmapSearchResult
gucharmap_charmap_search (GucharmapCharmap *charmap,
const gchar *search_text,
gint direction)
const gchar *search_text,
gint direction)
{
gunichar uc;
GucharmapSearchResult result;
gunichar wc, first_wc;
g_assert (direction == -1 || direction == 1);
if (search_text[0] == '\0')
return GUCHARMAP_NOTHING_TO_SEARCH_FOR;
uc = gucharmap_find_substring_match (charmap->chartable->active_char,
search_text, direction);
if (uc != (gunichar)(-1) && uc <= UNICHAR_MAX)
wc = gucharmap_find_substring_match (gucharmap_table_get_active_character (charmap->chartable), search_text, direction);
first_wc = wc;
while (wc != (gunichar)(-1) && wc <= UNICHAR_MAX
&& gucharmap_codepoint_list_get_index (charmap->chartable->codepoint_list, wc) == (guint)(-1))
{
wc = gucharmap_find_substring_match (wc, search_text, direction);
if (wc == first_wc)
{
wc = (gunichar)(-1);
break;
}
}
if (wc != (gunichar)(-1) && wc <= UNICHAR_MAX)
{
if ((direction == 1 && uc <= charmap->chartable->active_char)
|| (direction == -1 && uc >= charmap->chartable->active_char))
if ((direction == 1 && wc <= charmap->chartable->active_cell)
|| (direction == -1 && wc >= charmap->chartable->active_cell))
result = GUCHARMAP_WRAPPED;
else
result = GUCHARMAP_FOUND;
gucharmap_table_set_active_character (charmap->chartable, uc);
gucharmap_table_set_active_character (charmap->chartable, wc);
}
else
result = GUCHARMAP_NOT_FOUND;
......
/* $Id$ */
/*
* Copyright (c) 2003 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 02111-1307 USA
*/
#include "config.h"
#include <glib.h>
#include <gucharmap/gucharmap-codepoint-list.h>
static gunichar
default_get_char (GucharmapCodepointList *list,
guint index)
{
if (index * 2 > UNICHAR_MAX)
return (gunichar)(-1);
else
return (gunichar) index * 2;
}
static guint
default_get_index (GucharmapCodepointList *list,
gunichar wc)
{
if (wc > UNICHAR_MAX || wc % 2 == 1)
return (guint)(-1);
else
return (guint) wc / 2;
}
static guint
default_get_last_index (GucharmapCodepointList *list)
{
return (guint) UNICHAR_MAX / 2;
}
static void
gucharmap_codepoint_list_class_init (GucharmapCodepointListClass *clazz)
{
/* 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;
}
GType
gucharmap_codepoint_list_get_type ()
{
static GType t = 0;
if (t == 0)
{
static const GTypeInfo type_info =
{
sizeof (GucharmapCodepointListClass),
NULL,
NULL,
(GClassInitFunc) gucharmap_codepoint_list_class_init,
NULL,
NULL,
sizeof (GucharmapCodepointList),
0,
NULL
};
t = g_type_register_static (G_TYPE_OBJECT, "GucharmapCodepointList", &type_info, 0);
}
return t;
}
/**
* gucharmap_codepoint_list_get_char:
* @list: a #GucharmapCodepointList
* @index: index indicating which character to get
*
* Return value: code point at index @index in the codepoint list, or
* (gunichar)(-1) if @index is beyond the last index.
**/
gunichar
gucharmap_codepoint_list_get_char (GucharmapCodepointList *list,
guint index)
{
g_return_val_if_fail (IS_GUCHARMAP_CODEPOINT_LIST (list), (gunichar)(-1));
return GUCHARMAP_CODEPOINT_LIST_GET_CLASS (list)->get_char (list, index);
}
/**
* gucharmap_codepoint_list_get_index:
* @list: a #GucharmapCodepointList
* @wc: character for which to find the index
*
* Return value: index of @wc, or (guint)(-1) if @wc is not in this
* codepoint list.
**/
guint
gucharmap_codepoint_list_get_index (GucharmapCodepointList *list,
gunichar wc)
{
g_return_val_if_fail (IS_GUCHARMAP_CODEPOINT_LIST (list), (guint)(-1));
return GUCHARMAP_CODEPOINT_LIST_GET_CLASS (list)->get_index (list, wc);
}
/**
* gucharmap_codepoint_list_get_last_index:
* @list: a #GucharmapCodepointList
*
* Return value: last index in this codepoint list.
**/
guint
gucharmap_codepoint_list_get_last_index (GucharmapCodepointList *list)
{
g_return_val_if_fail (IS_GUCHARMAP_CODEPOINT_LIST (list), (guint)(-1));
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 ()
{
return g_object_new (gucharmap_codepoint_list_get_type (), NULL);
}
/* $Id$ */
/*
* Copyright (c) 2003 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 02111-1307 USA
*/
#ifndef GUCHARMAP_CODEPOINT_LIST_H
#define GUCHARMAP_CODEPOINT_LIST_H
#include <glib-object.h>
G_BEGIN_DECLS
#define GUCHARMAP_CODEPOINT_LIST (obj) \
(G_TYPE_CHECK_INSTANCE_CASE ((obj), gucharmap_codepoint_list_get_type (), GucharmapCodepointList))
#define GUCHARMAP_CODEPOINT_LIST_CLASS(clazz) \
(G_TYPE_CHECK_CLASS_CAST ((clazz), gucharmap_codepoint_list_get_type (), GucharmapCodepointListClass))
#define IS_GUCHARMAP_CODEPOINT_LIST(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), gucharmap_codepoint_list_get_type ()))
#define GUCHARMAP_CODEPOINT_LIST_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), gucharmap_codepoint_list_get_type (), GucharmapCodepointListClass))
typedef struct _GucharmapCodepointList GucharmapCodepointList;
typedef struct _GucharmapCodepointListClass GucharmapCodepointListClass;
struct _GucharmapCodepointList
{
GObject parent;
};
struct _GucharmapCodepointListClass
{
GObjectClass parent_class;
/* zero is the first index */
gunichar (*get_char) (GucharmapCodepointList *list, guint index);
guint (*get_index) (GucharmapCodepointList *list, gunichar wc);
guint (*get_last_index) (GucharmapCodepointList *list);
};
GType gucharmap_codepoint_list_get_type ();
GucharmapCodepointList * gucharmap_codepoint_list_new ();
gunichar gucharmap_codepoint_list_get_char (GucharmapCodepointList *list,
guint index);
guint gucharmap_codepoint_list_get_index (GucharmapCodepointList *list,
gunichar wc);
guint gucharmap_codepoint_list_get_last_index (GucharmapCodepointList *list);
G_END_DECLS
#endif /* #ifndef GUCHARMAP_CODEPOINT_LIST_H */
This diff is collapsed.
......@@ -21,10 +21,10 @@
#define GUCHARMAP_TABLE_H
#include <gtk/gtk.h>
#include <gucharmap/gucharmap-codepoint-list.h>
G_BEGIN_DECLS
#define GUCHARMAP_TABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
gucharmap_table_get_type (), GucharmapTable))
......@@ -32,11 +32,9 @@ G_BEGIN_DECLS
#define IS_GUCHARMAP_TABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), gucharmap_table_get_type ()))
typedef struct _GucharmapTable GucharmapTable;
typedef struct _GucharmapTableClass GucharmapTableClass;
struct _GucharmapTable
{
GtkHBox parent;
......@@ -51,10 +49,10 @@ struct _GucharmapTable
PangoFontMetrics *font_metrics;
PangoLayout *pango_layout;
gunichar page_first_char; /* the character in the upper left square */
gunichar active_char;
gunichar old_page_first_char; /* helps us know what to redraw */
gunichar old_active_char;
guint page_first_cell;
guint active_cell;
guint old_page_first_cell;
guint old_active_cell;
/* for the scrollbar */
GtkObject *adjustment;
......@@ -68,8 +66,9 @@ struct _GucharmapTable
/* for dragging (#114534) */
gdouble click_x, click_y;
};
GucharmapCodepointList *codepoint_list;
};
struct _GucharmapTableClass
{
......@@ -80,7 +79,6 @@ struct _GucharmapTableClass
void (* status_message) (GucharmapTable *chartable, const gchar *message);
};
GType gucharmap_table_get_type (void);
GtkWidget * gucharmap_table_new (void);
void gucharmap_table_set_font (GucharmapTable *chartable,
......@@ -96,7 +94,6 @@ void gucharmap_table_grab_focus (GucharmapTable *chartable);
void gucharmap_table_set_snap_pow2 (GucharmapTable *chartable,
gboolean snap);
G_END_DECLS
#endif /* #ifndef GUCHARMAP_TABLE_H */
......
This diff is collapsed.
......@@ -17,16 +17,14 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef GUCHARMAP_H
#define GUCHARMAP_H
#include <gucharmap/gucharmap-table.h>
#include <gucharmap/gucharmap-charmap.h>
#include <gucharmap/gucharmap-window.h>
#include <gucharmap/gucharmap-unicode-info.h>
#include <gucharmap/gucharmap-mini-fontsel.h>
#include <gucharmap/gucharmap-codepoint-list.h>
#endif /* #ifndef GUCHARMAP_H */
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