[gimp] app: re-add gimp_text_tool_editor_get_text()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: re-add gimp_text_tool_editor_get_text()
- Date: Sat, 20 Feb 2010 18:26:12 +0000 (UTC)
commit c91b0263844a1623b7624494a1bfb2a05db645e1
Author: Michael Natterer <mitch gimp org>
Date: Sat Feb 20 19:25:07 2010 +0100
app: re-add gimp_text_tool_editor_get_text()
Return the entire buffer and use it in even more places than before to
get rid code duplication.
app/tools/gimptexttool-editor.c | 17 ++++++++++++++---
app/tools/gimptexttool-editor.h | 2 ++
app/tools/gimptexttool.c | 29 +++++------------------------
3 files changed, 21 insertions(+), 27 deletions(-)
---
diff --git a/app/tools/gimptexttool-editor.c b/app/tools/gimptexttool-editor.c
index 28fdce0..95eb4dd 100644
--- a/app/tools/gimptexttool-editor.c
+++ b/app/tools/gimptexttool-editor.c
@@ -280,6 +280,17 @@ gimp_text_tool_reset_im_context (GimpTextTool *text_tool)
}
}
+gchar *
+gimp_text_tool_editor_get_text (GimpTextTool *text_tool)
+{
+ GtkTextIter start, end;
+
+ gtk_text_buffer_get_bounds (text_tool->text_buffer, &start, &end);
+
+ return gtk_text_buffer_get_text (text_tool->text_buffer,
+ &start, &end, TRUE);
+}
+
void
gimp_text_tool_editor_get_cursor_rect (GimpTextTool *text_tool,
PangoRectangle *cursor_rect,
@@ -320,7 +331,7 @@ gimp_text_tool_editor_get_cursor_rect (GimpTextTool *text_tool,
gtk_text_buffer_get_iter_at_mark (buffer, &cursor,
gtk_text_buffer_get_insert (buffer));
- string = gtk_text_buffer_get_text (buffer, &start, &cursor, FALSE);
+ string = gtk_text_buffer_get_text (buffer, &start, &cursor, TRUE);
cursor_index = strlen (string);
g_free (string);
@@ -487,7 +498,7 @@ gimp_text_tool_move_cursor (GimpTextTool *text_tool,
gtk_text_buffer_get_bounds (buffer, &start, &end);
- string = gtk_text_buffer_get_text (buffer, &start, &cursor, FALSE);
+ string = gtk_text_buffer_get_text (buffer, &start, &cursor, TRUE);
cursor_index = strlen (string);
g_free (string);
@@ -536,7 +547,7 @@ gimp_text_tool_move_cursor (GimpTextTool *text_tool,
pango_layout_line_x_to_index (layout_line, x_pos,
&cursor_index, &trailing);
- string = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
+ string = gtk_text_buffer_get_text (buffer, &start, &end, TRUE);
string[cursor_index] = '\0';
diff --git a/app/tools/gimptexttool-editor.h b/app/tools/gimptexttool-editor.h
index bb997a5..9ea5f4e 100644
--- a/app/tools/gimptexttool-editor.h
+++ b/app/tools/gimptexttool-editor.h
@@ -39,6 +39,8 @@ gboolean gimp_text_tool_editor_key_release (GimpTextTool *text_tool,
void gimp_text_tool_reset_im_context (GimpTextTool *text_tool);
+gchar * gimp_text_tool_editor_get_text (GimpTextTool *text_tool);
+
void gimp_text_tool_editor_get_cursor_rect (GimpTextTool *text_tool,
PangoRectangle *cursor_rect,
gint *logical_off_x,
diff --git a/app/tools/gimptexttool.c b/app/tools/gimptexttool.c
index 618ddf8..78e3712 100644
--- a/app/tools/gimptexttool.c
+++ b/app/tools/gimptexttool.c
@@ -158,10 +158,10 @@ static gboolean gimp_text_tool_set_drawable (GimpTextTool *text_tool,
GimpDrawable *drawable,
gboolean confirm);
-static void gimp_text_tool_text_buffer_changed (GtkTextBuffer *text_buffer,
+static void gimp_text_tool_text_buffer_changed (GtkTextBuffer *text_buffer,
GimpTextTool *text_tool);
-static gint gimp_text_tool_xy_to_offset (GimpTextTool *text_tool,
+static gint gimp_text_tool_xy_to_offset (GimpTextTool *text_tool,
gdouble x,
gdouble y);
@@ -1397,15 +1397,7 @@ gimp_text_tool_create_layer (GimpTextTool *text_tool,
}
else
{
- GtkTextIter start;
- GtkTextIter end;
- gchar *string;
-
- gtk_text_buffer_get_start_iter (text_tool->text_buffer, &start);
- gtk_text_buffer_get_end_iter (text_tool->text_buffer, &end);
-
- string = gtk_text_buffer_get_text (text_tool->text_buffer,
- &start, &end, FALSE);
+ gchar *string = gimp_text_tool_editor_get_text (text_tool);
g_object_set (text_tool->proxy,
"text", string,
@@ -1690,15 +1682,7 @@ gimp_text_tool_update_proxy (GimpTextTool *text_tool)
{
if (text_tool->text)
{
- GtkTextIter start;
- GtkTextIter end;
- gchar *string;
-
- gtk_text_buffer_get_start_iter (text_tool->text_buffer, &start);
- gtk_text_buffer_get_end_iter (text_tool->text_buffer, &end);
-
- string = gtk_text_buffer_get_text (text_tool->text_buffer,
- &start, &end, FALSE);
+ gchar *string = gimp_text_tool_editor_get_text (text_tool);
g_object_set (text_tool->proxy,
"text", string,
@@ -1735,7 +1719,6 @@ gimp_text_tool_xy_to_offset (GimpTextTool *text_tool,
gdouble x,
gdouble y)
{
- GtkTextIter start, end;
PangoLayout *layout;
PangoRectangle ink_extents;
gchar *string;
@@ -1754,9 +1737,7 @@ gimp_text_tool_xy_to_offset (GimpTextTool *text_tool,
if (ink_extents.y < 0)
y += ink_extents.y;
- gtk_text_buffer_get_bounds (text_tool->text_buffer, &start, &end);
- string = gtk_text_buffer_get_text (text_tool->text_buffer,
- &start, &end, TRUE);
+ string = gimp_text_tool_editor_get_text (text_tool);
pango_layout_xy_to_index (layout,
x * PANGO_SCALE,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]