diff options
author | Havoc Pennington <hp@redhat.com> | 2000-10-18 18:42:54 +0000 |
---|---|---|
committer | Havoc Pennington <hp@src.gnome.org> | 2000-10-18 18:42:54 +0000 |
commit | 7a4c68938789206bfec3c6d15cc4bb922daf6443 (patch) | |
tree | e5f031fc609e50a8b7b12e7d6abf63cc78cc88e7 /gtk | |
parent | 7420908815651a1ff2ceb1c0fb5e92fe9b260619 (diff) | |
download | gtk+-7a4c68938789206bfec3c6d15cc4bb922daf6443.tar.gz |
Some updates
2000-10-18 Havoc Pennington <hp@redhat.com>
* gtk/gtk-sections.txt: Some updates
* gdk/gdk-sections.txt: remove GdkPixbufAlphaMode
* gdk-pixbuf/gdk-pixbuf-sections.txt: Add new API, remove
GdkPixbufClass/GdkAnimationClass since those are private
* gdk-pixbuf/Makefile.am (IGNORE_HFILES): ignore more headers
2000-10-18 Havoc Pennington <hp@redhat.com>
* gtk/gtktextiter.c (gtk_text_iter_forward_to_newline): Fix a bug
where any number of empty lines would get skipped
* gtk/gtktextiter.h: Remove padding from GtkTextIter; live on the
edge.
* gtk/gtktextiter.c (gtk_text_iter_make_surreal): enhance the
warning about invalid iterators (explain more thoroughly)
(gtk_text_iter_in_region): rename gtk_text_iter_in_range
* gtk/gtktextview.c (FOCUS_EDGE_WIDTH): Make focus rectangle less
big
* demos/*.c: Add error handling
* gtk/gtktextbuffer.c: don't modify const iterators
* gtk/gdk-pixbuf-loader.c: Add full error handling here
* gtk/gtkimage.c (gtk_image_set_from_file): ignore errors
on file load
* gtk/gtkiconfactory.c: Update to reflect addition of error
handling to gdk-pixbuf loaders
2000-10-16 Havoc Pennington <hp@redhat.com>
* gdk-pixbuf-io.c (gdk_pixbuf_get_module)
(gdk_pixbuf_get_named_module) (gdk_pixbuf_load_module):
add error reporting here also
* make-inline-pixbuf.c (main): use GError
* io-xpm.c: include unistd.h
* gdk-pixbuf-util.c: include string.h
* io-*.c: add error reporting
* gdk-pixbuf-animation.c (gdk_pixbuf_animation_new_from_file): add
error reporting
* gdk-pixbuf-io.c (gdk_pixbuf_new_from_file): Add error reporting
* gdk-pixbuf-io.h: Add GError** to load_increment and load
methods
* gdk-pixbuf-io.c (gdk_pixbuf_save) (gdk_pixbuf_savev): return
a G_FILE_ERROR if we fail to write or close the file.
* gdk-pixbuf.h: remove GDK_PIXBUF_ERROR_IO, instead we'll use
G_FILE_ERROR_*. Rename enum to GdkPixbufError, properly following
the GError naming rules. Add GError** to load functions.
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/gdk-pixbuf-loader.c | 114 | ||||
-rw-r--r-- | gtk/gdk-pixbuf-loader.h | 6 | ||||
-rw-r--r-- | gtk/gtkiconfactory.c | 14 | ||||
-rw-r--r-- | gtk/gtkimage.c | 2 | ||||
-rw-r--r-- | gtk/gtktextbuffer.c | 11 | ||||
-rw-r--r-- | gtk/gtktextiter.c | 156 | ||||
-rw-r--r-- | gtk/gtktextiter.h | 26 | ||||
-rw-r--r-- | gtk/gtktextview.c | 6 | ||||
-rw-r--r-- | gtk/testtext.c | 21 |
9 files changed, 264 insertions, 92 deletions
diff --git a/gtk/gdk-pixbuf-loader.c b/gtk/gdk-pixbuf-loader.c index 5f4320f22f..42aec5d4c7 100644 --- a/gtk/gdk-pixbuf-loader.c +++ b/gtk/gdk-pixbuf-loader.c @@ -338,20 +338,32 @@ gdk_pixbuf_loader_animation_done (GdkPixbuf *pixbuf, } static gint -gdk_pixbuf_loader_load_module (GdkPixbufLoader *loader, const char *image_type) +gdk_pixbuf_loader_load_module (GdkPixbufLoader *loader, + const char *image_type, + GError **error) { GdkPixbufLoaderPrivate *priv = loader->private; - if(image_type) - priv->image_module = gdk_pixbuf_get_named_module (image_type); + if (image_type) + { + priv->image_module = gdk_pixbuf_get_named_module (image_type, + error); + } else - priv->image_module = gdk_pixbuf_get_module (priv->header_buf, priv->header_buf_offset); + { + g_return_val_if_fail (priv->header_buf_offset > 0, 0); + priv->image_module = gdk_pixbuf_get_module (priv->header_buf, + priv->header_buf_offset, + NULL, + error); + } if (priv->image_module == NULL) return 0; if (priv->image_module->module == NULL) - gdk_pixbuf_load_module (priv->image_module); + if (!gdk_pixbuf_load_module (priv->image_module, error)) + return 0; if (priv->image_module->module == NULL) return 0; @@ -360,8 +372,12 @@ gdk_pixbuf_loader_load_module (GdkPixbufLoader *loader, const char *image_type) (priv->image_module->stop_load == NULL) || (priv->image_module->load_increment == NULL)) { - g_warning (G_STRLOC ": module %s does not support incremental loading.\n", - priv->image_module->module_name); + g_set_error (error, + GDK_PIXBUF_ERROR, + GDK_PIXBUF_ERROR_UNSUPPORTED_OPERATION, + _("Incremental loading of image type '%s' is not supported"), + image_type); + return 0; } @@ -369,16 +385,33 @@ gdk_pixbuf_loader_load_module (GdkPixbufLoader *loader, const char *image_type) gdk_pixbuf_loader_update, gdk_pixbuf_loader_frame_done, gdk_pixbuf_loader_animation_done, - loader); + loader, + error); if (priv->context == NULL) { - g_warning (G_STRLOC ": Failed to begin progressive load"); + /* Defense against broken loaders; DO NOT take this as a GError + * example + */ + if (error && *error == NULL) + { + g_warning ("Bug! loader '%s' didn't set an error on failure", + priv->image_module->module_name); + g_set_error (error, + GDK_PIXBUF_ERROR, + GDK_PIXBUF_ERROR_FAILED, + _("Internal error: Image loader module '%s'" + " failed to begin loading an image, but didn't" + " give a reason for the failure"), + priv->image_module->module_name); + + } + return 0; } if (priv->header_buf_offset - && priv->image_module->load_increment (priv->context, priv->header_buf, priv->header_buf_offset)) + && priv->image_module->load_increment (priv->context, priv->header_buf, priv->header_buf_offset, error)) return priv->header_buf_offset; return 0; @@ -387,7 +420,8 @@ gdk_pixbuf_loader_load_module (GdkPixbufLoader *loader, const char *image_type) static int gdk_pixbuf_loader_eat_header_write (GdkPixbufLoader *loader, const guchar *buf, - gsize count) + gsize count, + GError **error) { gint n_bytes; GdkPixbufLoaderPrivate *priv = loader->private; @@ -399,7 +433,7 @@ gdk_pixbuf_loader_eat_header_write (GdkPixbufLoader *loader, if (priv->header_buf_offset >= LOADER_HEADER_SIZE) { - if (gdk_pixbuf_loader_load_module (loader, NULL) == 0) + if (gdk_pixbuf_loader_load_module (loader, NULL, error) == 0) return 0; } @@ -411,11 +445,14 @@ gdk_pixbuf_loader_eat_header_write (GdkPixbufLoader *loader, * @loader: A pixbuf loader. * @buf: Pointer to image data. * @count: Length of the @buf buffer in bytes. + * @error: return location for errors * - * This will cause a pixbuf loader to parse the next @count bytes of an image. - * It will return TRUE if the data was loaded successfully, and FALSE if an - * error occurred. In the latter case, the loader will be closed, and will not - * accept further writes. + * This will cause a pixbuf loader to parse the next @count bytes of + * an image. It will return TRUE if the data was loaded successfully, + * and FALSE if an error occurred. In the latter case, the loader + * will be closed, and will not accept further writes. If FALSE is + * returned, @error will be set to an error from the #GDK_PIXBUF_ERROR + * domain. * * Return value: #TRUE if the write was successful, or #FALSE if the loader * cannot parse the buffer. @@ -423,7 +460,8 @@ gdk_pixbuf_loader_eat_header_write (GdkPixbufLoader *loader, gboolean gdk_pixbuf_loader_write (GdkPixbufLoader *loader, const guchar *buf, - gsize count) + gsize count, + GError **error) { GdkPixbufLoaderPrivate *priv; @@ -442,7 +480,7 @@ gdk_pixbuf_loader_write (GdkPixbufLoader *loader, { gint eaten; - eaten = gdk_pixbuf_loader_eat_header_write(loader, buf, count); + eaten = gdk_pixbuf_loader_eat_header_write(loader, buf, count, error); if (eaten <= 0) return FALSE; @@ -451,8 +489,27 @@ gdk_pixbuf_loader_write (GdkPixbufLoader *loader, } if (count > 0 && priv->image_module->load_increment) - return priv->image_module->load_increment (priv->context, buf, count); - + { + gboolean retval; + retval = priv->image_module->load_increment (priv->context, buf, count, + error); + if (!retval && error && *error == NULL) + { + /* Fix up busted image loader */ + g_warning ("Bug! loader '%s' didn't set an error on failure", + priv->image_module->module_name); + g_set_error (error, + GDK_PIXBUF_ERROR, + GDK_PIXBUF_ERROR_FAILED, + _("Internal error: Image loader module '%s'" + " failed to begin loading an image, but didn't" + " give a reason for the failure"), + priv->image_module->module_name); + } + + return retval; + } + return TRUE; } @@ -477,13 +534,22 @@ gdk_pixbuf_loader_new (void) * Return value: A newly-created pixbuf loader. **/ GdkPixbufLoader * -gdk_pixbuf_loader_new_with_type (const char *image_type) +gdk_pixbuf_loader_new_with_type (const char *image_type, + GError **error) { GdkPixbufLoader *retval; - + GError *tmp; + retval = g_object_new (GDK_TYPE_PIXBUF_LOADER, NULL); - gdk_pixbuf_loader_load_module(retval, image_type); + tmp = NULL; + gdk_pixbuf_loader_load_module(retval, image_type, &tmp); + if (tmp != NULL) + { + g_propagate_error (error, tmp); + g_object_unref (G_OBJECT (retval)); + return NULL; + } return retval; } @@ -579,7 +645,7 @@ gdk_pixbuf_loader_close (GdkPixbufLoader *loader) /* We have less the 128 bytes in the image. Flush it, and keep going. */ if (priv->image_module == NULL) - gdk_pixbuf_loader_load_module (loader, NULL); + gdk_pixbuf_loader_load_module (loader, NULL, NULL); if (priv->image_module && priv->image_module->stop_load) priv->image_module->stop_load (priv->context); diff --git a/gtk/gdk-pixbuf-loader.h b/gtk/gdk-pixbuf-loader.h index c3d6d6f95b..402b697256 100644 --- a/gtk/gdk-pixbuf-loader.h +++ b/gtk/gdk-pixbuf-loader.h @@ -72,10 +72,12 @@ struct _GdkPixbufLoaderClass GtkType gdk_pixbuf_loader_get_type (void) G_GNUC_CONST; GdkPixbufLoader * gdk_pixbuf_loader_new (void); -GdkPixbufLoader * gdk_pixbuf_loader_new_with_type (const char *image_type); +GdkPixbufLoader * gdk_pixbuf_loader_new_with_type (const char *image_type, + GError **error); gboolean gdk_pixbuf_loader_write (GdkPixbufLoader *loader, const guchar *buf, - gsize count); + gsize count, + GError **error); GdkPixbuf * gdk_pixbuf_loader_get_pixbuf (GdkPixbufLoader *loader); GdkPixbufAnimation * gdk_pixbuf_loader_get_animation (GdkPixbufLoader *loader); void gdk_pixbuf_loader_close (GdkPixbufLoader *loader); diff --git a/gtk/gtkiconfactory.c b/gtk/gtkiconfactory.c index 249568ce50..f6541a3d3e 100644 --- a/gtk/gtkiconfactory.c +++ b/gtk/gtkiconfactory.c @@ -27,6 +27,7 @@ #include "gtkiconfactory.h" #include "stock-icons/gtkstockpixbufs.h" #include "gtkstock.h" +#include "gtkintl.h" #include <stdlib.h> #include <errno.h> #include <ctype.h> @@ -214,7 +215,7 @@ sized_icon_set_from_inline (const guchar *inline_data, set = gtk_icon_set_new (); - source.pixbuf = gdk_pixbuf_new_from_inline (inline_data, FALSE, -1); + source.pixbuf = gdk_pixbuf_new_from_inline (inline_data, FALSE, -1, NULL); g_assert (source.pixbuf); @@ -236,7 +237,7 @@ unsized_icon_set_from_inline (const guchar *inline_data) set = gtk_icon_set_new (); - source.pixbuf = gdk_pixbuf_new_from_inline (inline_data, FALSE, -1); + source.pixbuf = gdk_pixbuf_new_from_inline (inline_data, FALSE, -1, NULL); g_assert (source.pixbuf); @@ -651,6 +652,7 @@ find_and_prep_icon_source (GtkIconSet *icon_set, if (source->pixbuf == NULL) { + GError *error; gchar *full; g_assert (source->filename); @@ -659,8 +661,9 @@ find_and_prep_icon_source (GtkIconSet *icon_set, full = gtk_rc_find_pixmap_in_path (NULL, source->filename); else full = g_strdup (source->filename); - - source->pixbuf = gdk_pixbuf_new_from_file (full); + + error = NULL; + source->pixbuf = gdk_pixbuf_new_from_file (full, &error); g_free (full); @@ -669,7 +672,8 @@ find_and_prep_icon_source (GtkIconSet *icon_set, /* Remove this icon source so we don't keep trying to * load it. */ - g_warning ("Failed to load icon '%s'", source->filename); + g_warning (_("Error loading icon: %s"), error->message); + g_error_free (error); icon_set->sources = g_slist_remove (icon_set->sources, source); diff --git a/gtk/gtkimage.c b/gtk/gtkimage.c index 504b2a2e11..a4de696dd0 100644 --- a/gtk/gtkimage.c +++ b/gtk/gtkimage.c @@ -255,7 +255,7 @@ gtk_image_set_from_file (GtkImage *image, if (filename == NULL) return; - pixbuf = gdk_pixbuf_new_from_file (filename); + pixbuf = gdk_pixbuf_new_from_file (filename, NULL); if (pixbuf == NULL) return; diff --git a/gtk/gtktextbuffer.c b/gtk/gtktextbuffer.c index 627341f431..143f822f32 100644 --- a/gtk/gtktextbuffer.c +++ b/gtk/gtktextbuffer.c @@ -1508,16 +1508,19 @@ gtk_text_buffer_emit_tag(GtkTextBuffer *buffer, const GtkTextIter *start, const GtkTextIter *end) { + GtkTextIter start_tmp = *start; + GtkTextIter end_tmp = *end; + g_return_if_fail(tag != NULL); - - gtk_text_iter_reorder (start, end); + + gtk_text_iter_reorder (&start_tmp, &end_tmp); if (apply) gtk_signal_emit (GTK_OBJECT(buffer), signals[APPLY_TAG], - tag, start, end); + tag, &start_tmp, &end_tmp); else gtk_signal_emit (GTK_OBJECT(buffer), signals[REMOVE_TAG], - tag, start, end); + tag, &start_tmp, &end_tmp); } diff --git a/gtk/gtktextiter.c b/gtk/gtktextiter.c index e061e1978e..70ac5f19e8 100644 --- a/gtk/gtktextiter.c +++ b/gtk/gtktextiter.c @@ -62,9 +62,6 @@ struct _GtkTextRealIter and ditto for char offsets. */ gint segment_byte_offset; gint segment_char_offset; - /* Pads are here for binary-compatible expansion space. */ - gpointer pad1; - guint pad2; }; /* These "set" functions should not assume any fields @@ -158,7 +155,10 @@ gtk_text_iter_make_surreal(const GtkTextIter *_iter) "was created.\nYou must use marks, character numbers, " "or line numbers to preserve a position across buffer " "modifications.\nYou can apply tags and insert marks " - "without invalidating your iterators, however."); + "without invalidating your iterators,\n" + "but any mutation that affects 'indexable' buffer contents " + "(contents that can be referred to by character offset)\n" + "will invalidate all outstanding iterators"); return NULL; } @@ -2048,6 +2048,55 @@ gtk_text_iter_backward_chars(GtkTextIter *iter, gint count) } } +#if 0 + +/* These two can't be implemented efficiently (always have to use + * a linear scan, since that's the only way to find all the non-text + * segments) + */ + +/** + * gtk_text_iter_forward_text_chars: + * @iter: a #GtkTextIter + * @count: number of chars to move + * + * Moves forward by @count text characters (pixbufs, widgets, + * etc. do not count as characters for this). Equivalent to moving + * through the results of gtk_text_iter_get_text(), rather than + * gtk_text_iter_get_slice(). + * + * Return value: whether @iter moved and is dereferenceable + **/ +gboolean +gtk_text_iter_forward_text_chars (GtkTextIter *iter, + gint count) +{ + + + +} + +/** + * gtk_text_iter_forward_text_chars: + * @iter: a #GtkTextIter + * @count: number of chars to move + * + * Moves backward by @count text characters (pixbufs, widgets, + * etc. do not count as characters for this). Equivalent to moving + * through the results of gtk_text_iter_get_text(), rather than + * gtk_text_iter_get_slice(). + * + * Return value: whether @iter moved and is dereferenceable + **/ +gboolean +gtk_text_iter_backward_text_chars (GtkTextIter *iter, + gint count) +{ + + +} +#endif + /** * gtk_text_iter_forward_line: * @iter: an iterator @@ -2527,7 +2576,11 @@ gtk_text_iter_forward_to_newline(GtkTextIter *iter) /* Move to end of next line. */ if (gtk_text_iter_forward_line(iter)) { - gtk_text_iter_forward_to_newline(iter); + /* We don't want to move past all + * empty lines. + */ + if (gtk_text_iter_get_char (iter) != '\n') + gtk_text_iter_forward_to_newline(iter); return TRUE; } else @@ -2760,12 +2813,46 @@ gtk_text_iter_backward_find_char (GtkTextIter *iter, return FALSE; } +static void +forward_chars_with_skipping (GtkTextIter *iter, + gint count, + gboolean skip_invisible, + gboolean skip_nontext) +{ + + gint i; + + g_return_if_fail (count >= 0); + + i = count; + + while (i > 0) + { + gboolean ignored = FALSE; + + if (skip_nontext && + gtk_text_iter_get_char (iter) == gtk_text_unknown_char) + ignored = TRUE; + + if (!ignored && + skip_invisible && + gtk_text_btree_char_is_invisible (iter)) + ignored = TRUE; + + gtk_text_iter_next_char (iter); + + if (!ignored) + --i; + } +} + static gboolean lines_match (const GtkTextIter *start, const gchar **lines, gboolean visible_only, gboolean slice, - GtkTextIter *match_start) + GtkTextIter *match_start, + GtkTextIter *match_end) { GtkTextIter next; gchar *line_text; @@ -2773,13 +2860,14 @@ lines_match (const GtkTextIter *start, gint offset; if (*lines == NULL || **lines == '\0') - return TRUE; + { + if (match_end) + *match_end = *start; + return TRUE; + } next = *start; gtk_text_iter_forward_line (&next); - - gtk_text_iter_spew (start, "start"); - gtk_text_iter_spew (&next, "next"); /* No more text in buffer, but *lines is nonempty */ if (gtk_text_iter_equal (start, &next)) @@ -2795,9 +2883,7 @@ lines_match (const GtkTextIter *start, line_text = gtk_text_iter_get_slice (start, &next); } else - { - /* FIXME */ - g_warning ("Searching for non-slice text is currently broken (you must include 'unknown char' for pixmaps in order to match them)"); + { if (visible_only) line_text = gtk_text_iter_get_visible_text (start, &next); else @@ -2834,22 +2920,28 @@ lines_match (const GtkTextIter *start, if (match_start) { *match_start = next; - gtk_text_iter_forward_chars (match_start, offset); + + forward_chars_with_skipping (match_start, offset, + visible_only, !slice); } /* Go to end of search string */ offset += g_utf8_strlen (*lines, -1); - gtk_text_iter_forward_chars (&next, offset); + forward_chars_with_skipping (&next, offset, + visible_only, !slice); g_free (line_text); ++lines; + if (match_end) + *match_end = next; + /* pass NULL for match_start, since we don't need to find the * start again. */ - return lines_match (&next, lines, visible_only, slice, NULL); + return lines_match (&next, lines, visible_only, slice, NULL, match_end); } /* strsplit() that retains the delimiter as part of the string. */ @@ -2909,10 +3001,12 @@ strbreakup (const char *string, } gboolean -gtk_text_iter_forward_search (GtkTextIter *iter, - const char *str, - gboolean visible_only, - gboolean slice) +gtk_text_iter_forward_search (const GtkTextIter *iter, + const gchar *str, + gboolean visible_only, + gboolean slice, + GtkTextIter *match_start, + GtkTextIter *match_end) { gchar **lines = NULL; GtkTextIter match; @@ -2937,12 +3031,18 @@ gtk_text_iter_forward_search (GtkTextIter *iter, * gtk_text_iter_get_text() is called repeatedly on * a single line. */ + GtkTextIter end; + if (lines_match (&search, (const gchar**)lines, - visible_only, slice, &match)) + visible_only, slice, &match, &end)) { retval = TRUE; - *iter = match; + if (match_start) + *match_start = match; + + if (match_end) + *match_end = end; break; } @@ -2963,8 +3063,8 @@ gtk_text_iter_backward_search (GtkTextIter *iter, g_return_val_if_fail (iter != NULL, FALSE); g_return_val_if_fail (str != NULL, FALSE); - - + + } /* @@ -3057,9 +3157,9 @@ gtk_text_iter_compare(const GtkTextIter *lhs, const GtkTextIter *rhs) } gboolean -gtk_text_iter_in_region (const GtkTextIter *iter, - const GtkTextIter *start, - const GtkTextIter *end) +gtk_text_iter_in_range (const GtkTextIter *iter, + const GtkTextIter *start, + const GtkTextIter *end) { return gtk_text_iter_compare(iter, start) >= 0 && gtk_text_iter_compare(iter, end) < 0; @@ -3313,6 +3413,8 @@ gtk_text_iter_check (const GtkTextIter *iter) /* We are going to check our class invariants for the Iter class. */ + g_assert (sizeof (GtkTextIter) == sizeof (GtkTextRealIter)); + if (real->chars_changed_stamp != gtk_text_btree_get_chars_changed_stamp(real->tree)) g_error("iterator check failed: invalid iterator"); diff --git a/gtk/gtktextiter.h b/gtk/gtktextiter.h index 45dde30b29..8e6eeaecdd 100644 --- a/gtk/gtktextiter.h +++ b/gtk/gtktextiter.h @@ -46,15 +46,14 @@ struct _GtkTextIter { gpointer dummy2; gint dummy3; gint dummy4; - gint dummy10; - gint dummy11; gint dummy5; gint dummy6; - gpointer dummy7; - gpointer dummy8; - gint dummy9; - gpointer pad1; - guint pad2; + gint dummy7; + gint dummy8; + gpointer dummy9; + gpointer dummy10; + gint dummy11; + gint dummy12; }; @@ -164,6 +163,7 @@ void gtk_text_iter_set_line_offset (GtkTextIter *iter, void gtk_text_iter_forward_to_end (GtkTextIter *iter); gboolean gtk_text_iter_forward_to_newline (GtkTextIter *iter); + /* returns TRUE if a toggle was found; NULL for the tag pointer means "any tag toggle", otherwise the next toggle of the specified tag is located. */ @@ -183,10 +183,12 @@ gboolean gtk_text_iter_backward_find_char (GtkTextIter *iter, GtkTextCharPredicate pred, gpointer user_data); -gboolean gtk_text_iter_forward_search (GtkTextIter *iter, - const char *str, - gboolean visible_only, - gboolean slice); +gboolean gtk_text_iter_forward_search (const GtkTextIter *iter, + const gchar *str, + gboolean visible_only, + gboolean slice, + GtkTextIter *match_start, + GtkTextIter *match_end); gboolean gtk_text_iter_backward_search (GtkTextIter *iter, const char *str, @@ -200,7 +202,7 @@ gboolean gtk_text_iter_equal (const GtkTextIter *lhs, const GtkTextIter *rhs); gint gtk_text_iter_compare (const GtkTextIter *lhs, const GtkTextIter *rhs); -gboolean gtk_text_iter_in_region (const GtkTextIter *iter, +gboolean gtk_text_iter_in_range (const GtkTextIter *iter, const GtkTextIter *start, const GtkTextIter *end); diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c index 6e5b661084..9bec94ce6e 100644 --- a/gtk/gtktextview.c +++ b/gtk/gtktextview.c @@ -38,7 +38,7 @@ #include "gtktexttypes.h" #include <string.h> -#define FOCUS_EDGE_WIDTH 25 +#define FOCUS_EDGE_WIDTH 1 #define DRAG_THRESHOLD 8 #define SCREEN_WIDTH(widget) text_window_get_width (GTK_TEXT_VIEW (widget)->text_window) @@ -1906,7 +1906,7 @@ gtk_text_view_button_press_event (GtkWidget *widget, GdkEventButton *event) if (gtk_text_buffer_get_selection_bounds (text_view->buffer, &start, &end) && - gtk_text_iter_in_region (&iter, &start, &end)) + gtk_text_iter_in_range (&iter, &start, &end)) { text_view->drag_start_x = event->x; text_view->drag_start_y = event->y; @@ -3202,7 +3202,7 @@ gtk_text_view_drag_motion (GtkWidget *widget, if (gtk_text_buffer_get_selection_bounds (text_view->buffer, &start, &end) && - gtk_text_iter_in_region (&newplace, &start, &end)) + gtk_text_iter_in_range (&newplace, &start, &end)) { /* We're inside the selection. */ gdk_drag_status (context, 0, time); diff --git a/gtk/testtext.c b/gtk/testtext.c index 16e7172b76..a362fd9be1 100644 --- a/gtk/testtext.c +++ b/gtk/testtext.c @@ -1299,8 +1299,6 @@ buffer_search_forward (Buffer *buffer, const char *str, { GtkTextIter iter; GtkTextIter start, end; - gint char_len; - int i = 0; GtkWidget *dialog; /* remove tag from whole buffer */ @@ -1313,22 +1311,17 @@ buffer_search_forward (Buffer *buffer, const char *str, "insert")); - char_len = g_utf8_strlen (str, -1); - - if (char_len > 0) + if (*str != '\0') { - while (gtk_text_iter_forward_search (&iter, str, TRUE, FALSE)) + GtkTextIter match_start, match_end; + + while (gtk_text_iter_forward_search (&iter, str, TRUE, FALSE, + &match_start, &match_end)) { - GtkTextIter end = iter; - - gtk_text_iter_forward_chars (&end, char_len); - gtk_text_buffer_apply_tag (buffer->buffer, buffer->found_text_tag, - &iter, &end); + &match_start, &match_end); - iter = end; - - ++i; + iter = match_end; } } |