[gimp] Bug 683011 - Text tool discards text attributes in the on-canvas dialog...
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Bug 683011 - Text tool discards text attributes in the on-canvas dialog...
- Date: Fri, 9 Nov 2012 22:09:13 +0000 (UTC)
commit abd2e78bdf47f157bcab13587c040d08c89a2fc1
Author: Michael Natterer <mitch gimp org>
Date: Fri Nov 9 23:05:04 2012 +0100
Bug 683011 - Text tool discards text attributes in the on-canvas dialog...
When font, size or color were changed, set the text buffer's current
insert_tags just as we already do for the bold, italic etc. toggle
buttons. Changed gimp_text_style_editor_list_tags() to also return
the tags for font, size or color.
app/widgets/gimptextbuffer.c | 6 +-
app/widgets/gimptextbuffer.h | 6 ++
app/widgets/gimptextstyleeditor.c | 142 ++++++++++++++++++++++++++++--------
3 files changed, 119 insertions(+), 35 deletions(-)
---
diff --git a/app/widgets/gimptextbuffer.c b/app/widgets/gimptextbuffer.c
index 6a4cfad..7f41ceb 100644
--- a/app/widgets/gimptextbuffer.c
+++ b/app/widgets/gimptextbuffer.c
@@ -357,7 +357,7 @@ gimp_text_buffer_get_iter_size (GimpTextBuffer *buffer,
return NULL;
}
-static GtkTextTag *
+GtkTextTag *
gimp_text_buffer_get_size_tag (GimpTextBuffer *buffer,
gint size)
{
@@ -837,7 +837,7 @@ gimp_text_buffer_get_iter_font (GimpTextBuffer *buffer,
return NULL;
}
-static GtkTextTag *
+GtkTextTag *
gimp_text_buffer_get_font_tag (GimpTextBuffer *buffer,
const gchar *font)
{
@@ -931,7 +931,7 @@ gimp_text_buffer_get_iter_color (GimpTextBuffer *buffer,
return NULL;
}
-static GtkTextTag *
+GtkTextTag *
gimp_text_buffer_get_color_tag (GimpTextBuffer *buffer,
const GimpRGB *color)
{
diff --git a/app/widgets/gimptextbuffer.h b/app/widgets/gimptextbuffer.h
index 11ae4f5..410eed2 100644
--- a/app/widgets/gimptextbuffer.h
+++ b/app/widgets/gimptextbuffer.h
@@ -76,6 +76,8 @@ gboolean gimp_text_buffer_has_markup (GimpTextBuffer *buffer);
GtkTextTag * gimp_text_buffer_get_iter_size (GimpTextBuffer *buffer,
const GtkTextIter *iter,
gint *size);
+GtkTextTag * gimp_text_buffer_get_size_tag (GimpTextBuffer *buffer,
+ gint size);
void gimp_text_buffer_set_size (GimpTextBuffer *buffer,
const GtkTextIter *start,
const GtkTextIter *end,
@@ -112,6 +114,8 @@ void gimp_text_buffer_change_kerning (GimpTextBuffer *buffer,
GtkTextTag * gimp_text_buffer_get_iter_font (GimpTextBuffer *buffer,
const GtkTextIter *iter,
gchar **font);
+GtkTextTag * gimp_text_buffer_get_font_tag (GimpTextBuffer *buffer,
+ const gchar *font);
void gimp_text_buffer_set_font (GimpTextBuffer *buffer,
const GtkTextIter *start,
const GtkTextIter *end,
@@ -120,6 +124,8 @@ void gimp_text_buffer_set_font (GimpTextBuffer *buffer,
GtkTextTag * gimp_text_buffer_get_iter_color (GimpTextBuffer *buffer,
const GtkTextIter *iter,
GimpRGB *color);
+GtkTextTag * gimp_text_buffer_get_color_tag (GimpTextBuffer *buffer,
+ const GimpRGB *color);
void gimp_text_buffer_set_color (GimpTextBuffer *buffer,
const GtkTextIter *start,
const GtkTextIter *end,
diff --git a/app/widgets/gimptextstyleeditor.c b/app/widgets/gimptextstyleeditor.c
index 1f8da6e..2ef54bb 100644
--- a/app/widgets/gimptextstyleeditor.c
+++ b/app/widgets/gimptextstyleeditor.c
@@ -57,17 +57,17 @@ enum
};
-static void gimp_text_style_editor_constructed (GObject *object);
-static void gimp_text_style_editor_dispose (GObject *object);
-static void gimp_text_style_editor_finalize (GObject *object);
-static void gimp_text_style_editor_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gimp_text_style_editor_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
+static void gimp_text_style_editor_constructed (GObject *object);
+static void gimp_text_style_editor_dispose (GObject *object);
+static void gimp_text_style_editor_finalize (GObject *object);
+static void gimp_text_style_editor_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gimp_text_style_editor_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
static GtkWidget * gimp_text_style_editor_create_toggle (GimpTextStyleEditor *editor,
GtkTextTag *tag,
@@ -559,6 +559,54 @@ gimp_text_style_editor_list_tags (GimpTextStyleEditor *editor,
}
}
+ {
+ GtkTextTag *tag;
+ GList *list;
+ gdouble pixels;
+ gdouble points;
+
+ for (list = editor->buffer->size_tags; list; list = g_list_next (list))
+ *remove_tags = g_list_prepend (*remove_tags, list->data);
+
+ pixels = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (editor->size_entry), 0);
+ points = gimp_units_to_points (pixels,
+ GIMP_UNIT_PIXEL,
+ editor->resolution_y);
+ tag = gimp_text_buffer_get_size_tag (editor->buffer,
+ PANGO_SCALE * points);
+
+ tags = g_list_prepend (tags, tag);
+ }
+
+ {
+ GtkTextTag *tag;
+ GList *list;
+ const gchar *font_name;
+
+ for (list = editor->buffer->font_tags; list; list = g_list_next (list))
+ *remove_tags = g_list_prepend (*remove_tags, list->data);
+
+ font_name = gimp_context_get_font_name (editor->context);
+ tag = gimp_text_buffer_get_font_tag (editor->buffer, font_name);
+
+ tags = g_list_prepend (tags, tag);
+ }
+
+ {
+ GtkTextTag *tag;
+ GList *list;
+ GimpRGB color;
+
+ for (list = editor->buffer->color_tags; list; list = g_list_next (list))
+ *remove_tags = g_list_prepend (*remove_tags, list->data);
+
+ gimp_color_button_get_color (GIMP_COLOR_BUTTON (editor->color_button),
+ &color);
+ tag = gimp_text_buffer_get_color_tag (editor->buffer, &color);
+
+ tags = g_list_prepend (tags, tag);
+ }
+
*remove_tags = g_list_reverse (*remove_tags);
return g_list_reverse (tags);
@@ -623,15 +671,25 @@ gimp_text_style_editor_font_changed (GimpContext *context,
GimpTextStyleEditor *editor)
{
GtkTextBuffer *buffer = GTK_TEXT_BUFFER (editor->buffer);
- GtkTextIter start, end;
+ GList *insert_tags;
+ GList *remove_tags;
- if (! gtk_text_buffer_get_selection_bounds (buffer, &start, &end))
+ if (gtk_text_buffer_get_has_selection (buffer))
{
- return;
+ GtkTextIter start, end;
+
+ gtk_text_buffer_get_selection_bounds (buffer, &start, &end);
+
+ gtk_text_buffer_begin_user_action (buffer);
+
+ gimp_text_buffer_set_font (editor->buffer, &start, &end,
+ gimp_context_get_font_name (context));
+
+ gtk_text_buffer_end_user_action (buffer);
}
- gimp_text_buffer_set_font (editor->buffer, &start, &end,
- gimp_context_get_font_name (context));
+ insert_tags = gimp_text_style_editor_list_tags (editor, &remove_tags);
+ gimp_text_buffer_set_insert_tags (editor->buffer, insert_tags, remove_tags);
}
static void
@@ -675,16 +733,26 @@ gimp_text_style_editor_color_changed (GimpColorButton *button,
GimpTextStyleEditor *editor)
{
GtkTextBuffer *buffer = GTK_TEXT_BUFFER (editor->buffer);
- GtkTextIter start, end;
- GimpRGB color;
+ GList *insert_tags;
+ GList *remove_tags;
- if (! gtk_text_buffer_get_selection_bounds (buffer, &start, &end))
+ if (gtk_text_buffer_get_has_selection (buffer))
{
- return;
+ GtkTextIter start, end;
+ GimpRGB color;
+
+ gtk_text_buffer_get_selection_bounds (buffer, &start, &end);
+
+ gtk_text_buffer_begin_user_action (buffer);
+
+ gimp_color_button_get_color (button, &color);
+ gimp_text_buffer_set_color (editor->buffer, &start, &end, &color);
+
+ gtk_text_buffer_end_user_action (buffer);
}
- gimp_color_button_get_color (button, &color);
- gimp_text_buffer_set_color (editor->buffer, &start, &end, &color);
+ insert_tags = gimp_text_style_editor_list_tags (editor, &remove_tags);
+ gimp_text_buffer_set_insert_tags (editor->buffer, insert_tags, remove_tags);
}
static void
@@ -779,20 +847,30 @@ gimp_text_style_editor_size_changed (GimpSizeEntry *entry,
GimpTextStyleEditor *editor)
{
GtkTextBuffer *buffer = GTK_TEXT_BUFFER (editor->buffer);
- GtkTextIter start, end;
- gdouble points;
+ GList *insert_tags;
+ GList *remove_tags;
- if (! gtk_text_buffer_get_selection_bounds (buffer, &start, &end))
+ if (gtk_text_buffer_get_has_selection (buffer))
{
- return;
- }
+ GtkTextIter start, end;
+ gdouble points;
- points = gimp_units_to_points (gimp_size_entry_get_refval (entry, 0),
- GIMP_UNIT_PIXEL,
- editor->resolution_y);
+ gtk_text_buffer_get_selection_bounds (buffer, &start, &end);
+
+ gtk_text_buffer_begin_user_action (buffer);
- gimp_text_buffer_set_size (editor->buffer, &start, &end,
- PANGO_SCALE * points);
+ points = gimp_units_to_points (gimp_size_entry_get_refval (entry, 0),
+ GIMP_UNIT_PIXEL,
+ editor->resolution_y);
+
+ gimp_text_buffer_set_size (editor->buffer, &start, &end,
+ PANGO_SCALE * points);
+
+ gtk_text_buffer_end_user_action (buffer);
+ }
+
+ insert_tags = gimp_text_style_editor_list_tags (editor, &remove_tags);
+ gimp_text_buffer_set_insert_tags (editor->buffer, insert_tags, remove_tags);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]