Commit 93da621a authored by Paolo Borelli's avatar Paolo Borelli Committed by Paolo Borelli

move the local copy of textregion to gedittextregion to avoid symbols

2006-01-09  Paolo Borelli  <pborelli@katamail.com>

	* gedit/Makefile.am:
	* gedit/gedittextregion.[ch]:
	* gedit/gtktextregion.[ch]:
	* gedit/gedit-document.c:
	* gedit/update-gedittextregion.sh:

	move the local copy of textregion to gedittextregion to avoid
	symbols conflicts with the sourceview copy. Add a simple shell
	script to automate updating.
parent 3f66ddb9
2006-01-09 Paolo Borelli <pborelli@katamail.com>
* gedit/Makefile.am:
* gedit/gedittextregion.[ch]:
* gedit/gtktextregion.[ch]:
* gedit/gedit-document.c:
* gedit/update-gedittextregion.sh:
move the local copy of textregion to gedittextregion to avoid
symbols conflicts with the sourceview copy. Add a simple shell
script to automate updating.
2006-01-09 Nickolay V. Shmyrev <nshmyrev@yandex.ru>
* gedit/gedit-metadata-manager.c: (parseItem), (save_item):
......
......@@ -55,7 +55,7 @@ NOINST_H_FILES = \
gedit-io-error-message-area.h \
gedit-spinner.h \
sexy-icon-entry.h \
gtktextregion.h \
gedittextregion.h \
gedit-session.h
if ENABLE_PYTHON
......@@ -143,7 +143,7 @@ gedit_SOURCES = \
gedit-view.c \
gedit-window.c \
sexy-icon-entry.c \
gtktextregion.c \
gedittextregion.c \
$(NOINST_H_FILES) \
$(INST_H_FILES)
......
......@@ -50,8 +50,7 @@
#include "gedit-document-loader.h"
#include "gedit-document-saver.h"
#include "gedit-marshal.h"
#include "gtktextregion.h"
#include "gedittextregion.h"
#include <gtksourceview/gtksourceiter.h>
......@@ -131,8 +130,8 @@ struct _GeditDocumentPrivate
GeditDocumentSaver *saver;
/* Search highlighting support variables */
GtkTextRegion *to_search_region;
GtkTextTag *found_tag;
GeditTextRegion *to_search_region;
GtkTextTag *found_tag;
};
enum {
......@@ -272,7 +271,7 @@ gedit_document_finalize (GObject *object)
if (doc->priv->to_search_region != NULL)
{
/* we can't delete marks if we're finalizing the buffer */
gtk_text_region_destroy (doc->priv->to_search_region, FALSE);
gedit_text_region_destroy (doc->priv->to_search_region, FALSE);
}
G_OBJECT_CLASS (gedit_document_parent_class)->finalize (object);
......@@ -1848,9 +1847,9 @@ to_search_region_range (GeditDocument *doc,
g_print ("+ [%u (%u), %u (%u)]\n", gtk_text_iter_get_line (start), gtk_text_iter_get_offset (start),
gtk_text_iter_get_line (end), gtk_text_iter_get_offset (end));
*/
/* Add the region to the refresh region */
gtk_text_region_add (doc->priv->to_search_region, start, end);
gedit_text_region_add (doc->priv->to_search_region, start, end);
/* Notify views of the updated highlight region */
gtk_text_iter_backward_lines (start, doc->priv->num_of_lines_search_text);
......@@ -1864,7 +1863,7 @@ _gedit_document_search_region (GeditDocument *doc,
const GtkTextIter *start,
const GtkTextIter *end)
{
GtkTextRegion *region;
GeditTextRegion *region;
gedit_debug (DEBUG_DOCUMENT);
......@@ -1881,40 +1880,36 @@ _gedit_document_search_region (GeditDocument *doc,
*/
/* get the subregions not yet highlighted */
region = gtk_text_region_intersect (doc->priv->to_search_region,
start,
end);
region = gedit_text_region_intersect (doc->priv->to_search_region,
start,
end);
if (region)
{
gint i;
GtkTextIter start_search;
GtkTextIter end_search;
i = gtk_text_region_subregions (region);
gtk_text_region_nth_subregion (region,
0,
&start_search,
NULL);
gtk_text_region_nth_subregion (region,
i - 1,
NULL,
&end_search);
gtk_text_region_destroy (region, TRUE);
i = gedit_text_region_subregions (region);
gedit_text_region_nth_subregion (region,
0,
&start_search,
NULL);
gedit_text_region_nth_subregion (region,
i - 1,
NULL,
&end_search);
gedit_text_region_destroy (region, TRUE);
gtk_text_iter_order (&start_search, &end_search);
search_region (doc, &start_search, &end_search);
/* remove the just highlighted region */
gtk_text_region_subtract (doc->priv->to_search_region,
start,
end);
gtk_text_region_clear_zero_length_subregions (
doc->priv->to_search_region);
/* remove the just highlighted region */
gedit_text_region_subtract (doc->priv->to_search_region,
start,
end);
}
}
......@@ -1989,13 +1984,13 @@ gedit_document_set_enable_search_highlighting (GeditDocument *doc,
&end);
}
gtk_text_region_destroy (doc->priv->to_search_region,
TRUE);
gedit_text_region_destroy (doc->priv->to_search_region,
TRUE);
doc->priv->to_search_region = NULL;
}
else
{
doc->priv->to_search_region = gtk_text_region_new (GTK_TEXT_BUFFER (doc));
doc->priv->to_search_region = gedit_text_region_new (GTK_TEXT_BUFFER (doc));
if (gedit_document_get_can_search_again (doc))
{
/* If search_text is not empty, highligth all its occurrences */
......
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* gtktextregion.h - GtkTextMark based region utility functions
* gedittextregion.h - GtkTextMark based region utility functions
*
* This file is part of the GtkSourceView widget
*
......@@ -28,7 +28,7 @@
#include <glib.h>
#include "gtktextregion.h"
#include "gedittextregion.h"
#undef ENABLE_DEBUG
......@@ -47,16 +47,16 @@ typedef struct _Subregion {
GtkTextMark *end;
} Subregion;
struct _GtkTextRegion {
struct _GeditTextRegion {
GtkTextBuffer *buffer;
GList *subregions;
guint32 time_stamp;
};
typedef struct _GtkTextRegionIteratorReal GtkTextRegionIteratorReal;
typedef struct _GeditTextRegionIteratorReal GeditTextRegionIteratorReal;
struct _GtkTextRegionIteratorReal {
GtkTextRegion *region;
struct _GeditTextRegionIteratorReal {
GeditTextRegion *region;
guint32 region_time_stamp;
GList *subregions;
......@@ -72,7 +72,7 @@ struct _GtkTextRegionIteratorReal {
the text iter or which is the leftmost; else return the rightmost
subregion */
static GList *
find_nearest_subregion (GtkTextRegion *region,
find_nearest_subregion (GeditTextRegion *region,
const GtkTextIter *iter,
GList *begin,
gboolean leftmost,
......@@ -119,14 +119,14 @@ find_nearest_subregion (GtkTextRegion *region,
Public interface
---------------------------------------------------------------------- */
GtkTextRegion *
gtk_text_region_new (GtkTextBuffer *buffer)
GeditTextRegion *
gedit_text_region_new (GtkTextBuffer *buffer)
{
GtkTextRegion *region;
GeditTextRegion *region;
g_return_val_if_fail (buffer != NULL, NULL);
region = g_new (GtkTextRegion, 1);
region = g_new (GeditTextRegion, 1);
region->buffer = buffer;
region->subregions = NULL;
region->time_stamp = 0;
......@@ -135,7 +135,7 @@ gtk_text_region_new (GtkTextBuffer *buffer)
}
void
gtk_text_region_destroy (GtkTextRegion *region, gboolean delete_marks)
gedit_text_region_destroy (GeditTextRegion *region, gboolean delete_marks)
{
g_return_if_fail (region != NULL);
......@@ -156,15 +156,15 @@ gtk_text_region_destroy (GtkTextRegion *region, gboolean delete_marks)
}
GtkTextBuffer *
gtk_text_region_get_buffer (GtkTextRegion *region)
gedit_text_region_get_buffer (GeditTextRegion *region)
{
g_return_val_if_fail (region != NULL, NULL);
return region->buffer;
}
void
gtk_text_region_clear_zero_length_subregions (GtkTextRegion *region)
static void
gedit_text_region_clear_zero_length_subregions (GeditTextRegion *region)
{
GtkTextIter start, end;
GList *node;
......@@ -193,7 +193,7 @@ gtk_text_region_clear_zero_length_subregions (GtkTextRegion *region)
}
void
gtk_text_region_add (GtkTextRegion *region,
gedit_text_region_add (GeditTextRegion *region,
const GtkTextIter *_start,
const GtkTextIter *_end)
{
......@@ -206,7 +206,7 @@ gtk_text_region_add (GtkTextRegion *region,
end = *_end;
DEBUG (g_print ("---\n"));
DEBUG (gtk_text_region_debug_print (region));
DEBUG (gedit_text_region_debug_print (region));
DEBUG (g_message ("region_add (%d, %d)",
gtk_text_iter_get_offset (&start),
gtk_text_iter_get_offset (&end)));
......@@ -239,7 +239,6 @@ gtk_text_region_add (GtkTextRegion *region,
/* we are in the middle of two subregions */
region->subregions = g_list_insert_before (region->subregions,
start_node, sr);
}
}
else {
......@@ -275,11 +274,11 @@ gtk_text_region_add (GtkTextRegion *region,
++region->time_stamp;
DEBUG (gtk_text_region_debug_print (region));
DEBUG (gedit_text_region_debug_print (region));
}
void
gtk_text_region_subtract (GtkTextRegion *region,
gedit_text_region_subtract (GeditTextRegion *region,
const GtkTextIter *_start,
const GtkTextIter *_end)
{
......@@ -289,14 +288,14 @@ gtk_text_region_subtract (GtkTextRegion *region,
gboolean start_is_outside, end_is_outside;
Subregion *sr;
GtkTextIter start, end;
g_return_if_fail (region != NULL && _start != NULL && _end != NULL);
start = *_start;
end = *_end;
DEBUG (g_print ("---\n"));
DEBUG (gtk_text_region_debug_print (region));
DEBUG (gedit_text_region_debug_print (region));
DEBUG (g_message ("region_substract (%d, %d)",
gtk_text_iter_get_offset (&start),
gtk_text_iter_get_offset (&end)));
......@@ -338,12 +337,10 @@ gtk_text_region_subtract (GtkTextRegion *region,
DEBUG (g_message ("subregion splitted"));
return;
} else {
/* the ending point is outside, so just move
the end of the subregion to the starting point */
gtk_text_buffer_move_mark (region->buffer, sr->end, &start);
}
} else {
/* the starting point is outside (and so to the left)
......@@ -351,7 +348,6 @@ gtk_text_region_subtract (GtkTextRegion *region,
DEBUG (g_message ("start is outside"));
start_is_outside = TRUE;
}
/* deal with the end point */
......@@ -395,14 +391,19 @@ gtk_text_region_subtract (GtkTextRegion *region,
node = l;
}
}
++region->time_stamp;
DEBUG (gtk_text_region_debug_print (region));
DEBUG (gedit_text_region_debug_print (region));
/* now get rid of empty subregions */
gedit_text_region_clear_zero_length_subregions (region);
DEBUG (gedit_text_region_debug_print (region));
}
gint
gtk_text_region_subregions (GtkTextRegion *region)
gedit_text_region_subregions (GeditTextRegion *region)
{
g_return_val_if_fail (region != NULL, 0);
......@@ -410,7 +411,7 @@ gtk_text_region_subregions (GtkTextRegion *region)
}
gboolean
gtk_text_region_nth_subregion (GtkTextRegion *region,
gedit_text_region_nth_subregion (GeditTextRegion *region,
guint subregion,
GtkTextIter *start,
GtkTextIter *end)
......@@ -431,8 +432,8 @@ gtk_text_region_nth_subregion (GtkTextRegion *region,
return TRUE;
}
GtkTextRegion *
gtk_text_region_intersect (GtkTextRegion *region,
GeditTextRegion *
gedit_text_region_intersect (GeditTextRegion *region,
const GtkTextIter *_start,
const GtkTextIter *_end)
{
......@@ -440,7 +441,7 @@ gtk_text_region_intersect (GtkTextRegion *region,
GtkTextIter sr_start_iter, sr_end_iter;
Subregion *sr, *new_sr;
gboolean done;
GtkTextRegion *new_region;
GeditTextRegion *new_region;
GtkTextIter start, end;
g_return_val_if_fail (region != NULL && _start != NULL && _end != NULL, NULL);
......@@ -458,7 +459,7 @@ gtk_text_region_intersect (GtkTextRegion *region,
if (start_node == NULL || end_node == NULL || end_node == start_node->prev)
return NULL;
new_region = gtk_text_region_new (region->buffer);
new_region = gedit_text_region_new (region->buffer);
done = FALSE;
sr = start_node->data;
......@@ -534,9 +535,8 @@ gtk_text_region_intersect (GtkTextRegion *region,
}
static gboolean
check_iterator (GtkTextRegionIteratorReal *real)
check_iterator (GeditTextRegionIteratorReal *real)
{
if ((real->region == NULL) ||
(real->region_time_stamp != real->region->time_stamp))
{
......@@ -547,81 +547,85 @@ check_iterator (GtkTextRegionIteratorReal *real)
return FALSE;
}
return TRUE;
}
/* Returns TRUE if start is less than the number of subregions */
gboolean
gtk_text_region_get_iterator (GtkTextRegion *region,
GtkTextRegionIterator *iter,
void
gedit_text_region_get_iterator (GeditTextRegion *region,
GeditTextRegionIterator *iter,
guint start)
{
GtkTextRegionIteratorReal *real;
g_return_val_if_fail (region != NULL, FALSE);
g_return_val_if_fail (iter != NULL, FALSE);
g_return_val_if_fail (region->subregions != NULL, FALSE);
real = (GtkTextRegionIteratorReal *)iter;
real->subregions = g_list_nth (region->subregions, start);
if (real->subregions == NULL)
return FALSE;
GeditTextRegionIteratorReal *real;
g_return_if_fail (region != NULL);
g_return_if_fail (iter != NULL);
real = (GeditTextRegionIteratorReal *)iter;
/* region->subregions may be NULL, -> end iter */
real->region = region;
real->subregions = g_list_nth (region->subregions, start);
real->region_time_stamp = region->time_stamp;
return TRUE;
}
/* Returns TRUE if the iteration has more elements.
* In other words, returns TRUE if gtk_text_region_iterator_has_next would
* return a subregion rather than FALSE.
*/
gboolean
gtk_text_region_iterator_has_next (GtkTextRegionIterator *iter)
gboolean
gedit_text_region_iterator_is_end (GeditTextRegionIterator *iter)
{
GtkTextRegionIteratorReal *real;
GeditTextRegionIteratorReal *real;
g_return_val_if_fail (iter != NULL, FALSE);
real = (GtkTextRegionIteratorReal *)iter;
real = (GeditTextRegionIteratorReal *)iter;
g_return_val_if_fail (check_iterator (real), FALSE);
return (real->subregions != NULL);
return (real->subregions == NULL);
}
/* Returns FALSE if iterator has no more elements otherwise returns TRUE and set start/end with the next subregion */
gboolean
gtk_text_region_iterator_next (GtkTextRegionIterator *iter,
GtkTextIter *start,
GtkTextIter *end)
gboolean
gedit_text_region_iterator_next (GeditTextRegionIterator *iter)
{
GtkTextRegionIteratorReal *real;
Subregion *sr;
GeditTextRegionIteratorReal *real;
g_return_val_if_fail (iter != NULL, FALSE);
g_return_val_if_fail (iter != NULL, FALSE);
real = (GtkTextRegionIteratorReal *)iter;
real = (GeditTextRegionIteratorReal *)iter;
g_return_val_if_fail (check_iterator (real), FALSE);
if (real->subregions == NULL)
if (real->subregions != NULL) {
real->subregions = g_list_next (real->subregions);
return TRUE;
}
else
return FALSE;
}
void
gedit_text_region_iterator_get_subregion (GeditTextRegionIterator *iter,
GtkTextIter *start,
GtkTextIter *end)
{
GeditTextRegionIteratorReal *real;
Subregion *sr;
g_return_if_fail (iter != NULL);
real = (GeditTextRegionIteratorReal *)iter;
g_return_if_fail (check_iterator (real));
g_return_if_fail (real->subregions != NULL);
sr = (Subregion*)real->subregions->data;
g_return_val_if_fail (sr != NULL, FALSE);
g_return_if_fail (sr != NULL);
if (start)
gtk_text_buffer_get_iter_at_mark (real->region->buffer, start, sr->start);
if (end)
gtk_text_buffer_get_iter_at_mark (real->region->buffer, end, sr->end);
return TRUE;
}
void
gtk_text_region_debug_print (GtkTextRegion *region)
gedit_text_region_debug_print (GeditTextRegion *region)
{
GList *l;
......
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* gtktextregion.h - GtkTextMark based region utility functions
* gedittextregion.h - GtkTextMark based region utility functions
*
* This file is part of the GtkSourceView widget
*
......@@ -22,19 +22,19 @@
* Boston, MA 02111-1307, USA.
*/
#ifndef __GTK_TEXT_REGION_H__
#define __GTK_TEXT_REGION_H__
#ifndef __GEDIT_TEXT_REGION_H__
#define __GEDIT_TEXT_REGION_H__
#include <gtk/gtktextbuffer.h>
G_BEGIN_DECLS
typedef struct _GtkTextRegion GtkTextRegion;
typedef struct _GtkTextRegionIterator GtkTextRegionIterator;
typedef struct _GeditTextRegion GeditTextRegion;
typedef struct _GeditTextRegionIterator GeditTextRegionIterator;
struct _GtkTextRegionIterator {
/* GtkTextRegionIterator is an opaque datatype; ignore all these fields.
* Initialize the iter with gtk_text_region_get_iterator
struct _GeditTextRegionIterator {
/* GeditTextRegionIterator is an opaque datatype; ignore all these fields.
* Initialize the iter with gedit_text_region_get_iterator
* function
*/
/*< private >*/
......@@ -43,51 +43,46 @@ struct _GtkTextRegionIterator {
gpointer dummy3;
};
GtkTextRegion *gtk_text_region_new (GtkTextBuffer *buffer);
void gtk_text_region_destroy (GtkTextRegion *region,
GeditTextRegion *gedit_text_region_new (GtkTextBuffer *buffer);
void gedit_text_region_destroy (GeditTextRegion *region,
gboolean delete_marks);
GtkTextBuffer *gtk_text_region_get_buffer (GtkTextRegion *region);
GtkTextBuffer *gedit_text_region_get_buffer (GeditTextRegion *region);
void gtk_text_region_clear_zero_length_subregions (GtkTextRegion *region);
void gtk_text_region_add (GtkTextRegion *region,
void gedit_text_region_add (GeditTextRegion *region,
const GtkTextIter *_start,
const GtkTextIter *_end);
void gtk_text_region_subtract (GtkTextRegion *region,
void gedit_text_region_subtract (GeditTextRegion *region,
const GtkTextIter *_start,
const GtkTextIter *_end);
gint gtk_text_region_subregions (GtkTextRegion *region);
gint gedit_text_region_subregions (GeditTextRegion *region);
gboolean gtk_text_region_nth_subregion (GtkTextRegion *region,
gboolean gedit_text_region_nth_subregion (GeditTextRegion *region,
guint subregion,
GtkTextIter *start,
GtkTextIter *end);
GtkTextRegion *gtk_text_region_intersect (GtkTextRegion *region,
GeditTextRegion *gedit_text_region_intersect (GeditTextRegion *region,
const GtkTextIter *_start,
const GtkTextIter *_end);
/* Returns TRUE if start is less than the number of subregions */
gboolean gtk_text_region_get_iterator (GtkTextRegion *region,
GtkTextRegionIterator *iter,
void gedit_text_region_get_iterator (GeditTextRegion *region,
GeditTextRegionIterator *iter,
guint start);
/* Returns TRUE if the iteration has more elements.
* In other words, returns TRUE if gtk_text_regione_iterator_has_next would
* return a subregion rather than FALSE.
*/
gboolean gtk_text_region_iterator_has_next (GtkTextRegionIterator *iter);
gboolean gedit_text_region_iterator_is_end (GeditTextRegionIterator *iter);
/* Returns FALSE if iterator is the end iterator */
gboolean gedit_text_region_iterator_next (GeditTextRegionIterator *iter);
/* Returns FALSE if iterator has no more elements otherwise returns TRUE and set start/end with the next subregion */
gboolean gtk_text_region_iterator_next (GtkTextRegionIterator *iter,
void gedit_text_region_iterator_get_subregion (GeditTextRegionIterator *iter,
GtkTextIter *start,
GtkTextIter *end);
GtkTextIter *end);
void gtk_text_region_debug_print (GtkTextRegion *region);
void gedit_text_region_debug_print (GeditTextRegion *region);
G_END_DECLS
#endif /* __GTK_TEXT_REGION_H__ */
#endif /* __GEDIT_TEXT_REGION_H__ */
#!/bin/sh
sed_it () {
sed \
-e 's/gtktextregion/gedittextregion/g' \
-e 's/gtk_text_region/gedit_text_region/g' \
-e 's/GtkTextRegion/GeditTextRegion/g' \
-e 's/GTK_TEXT_REGION/GEDIT_TEXT_REGION/g' \
$1
}
sed_it ../../gtksourceview/gtksourceview/gtktextregion.h > gedittextregion.h
sed_it ../../gtksourceview/gtksourceview/gtktextregion.c > gedittextregion.c
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