[gimp] app: fix coding style for and factorize MR !269.
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: fix coding style for and factorize MR !269.
- Date: Fri, 25 Mar 2022 21:10:10 +0000 (UTC)
commit 2748dfe83cc25a03bb97669f199c8f7b1155b4b7
Author: Jehan <jehan girinstud io>
Date: Fri Mar 25 20:24:28 2022 +0100
app: fix coding style for and factorize MR !269.
Fixing broken coding style and factorize the code to avoid redundant
calls, in a separate commit as the contributor hasn't responded for
nearly 2 years. Also no need to get the character count as -1 offset is
equivalent to point after last character (or alternatively we could have
used gtk_text_buffer_get_end_iter()).
I had raised some more questions on a possible better implementation (or
maybe not), but since the discussion never happened, let's just push
as-is. It still improves things and the whole text editor should be
revamped some day anyway.
The MR commit (i.e. previous commit) fixes the specific case when
changing font size with no text selected (changing the size of the whole
text).
app/widgets/gimptextstyleeditor.c | 30 ++++++++++--------------------
1 file changed, 10 insertions(+), 20 deletions(-)
---
diff --git a/app/widgets/gimptextstyleeditor.c b/app/widgets/gimptextstyleeditor.c
index d090aa1380..09aff50f4b 100644
--- a/app/widgets/gimptextstyleeditor.c
+++ b/app/widgets/gimptextstyleeditor.c
@@ -848,35 +848,25 @@ gimp_text_style_editor_size_changed (GimpSizeEntry *entry,
GtkTextBuffer *buffer = GTK_TEXT_BUFFER (editor->buffer);
GList *insert_tags;
GList *remove_tags;
+ GtkTextIter start, end;
+ gdouble points;
+
+ points = gimp_units_to_points (gimp_size_entry_get_refval (entry, 0),
+ GIMP_UNIT_PIXEL, editor->resolution_y);
if (gtk_text_buffer_get_has_selection (buffer))
{
- GtkTextIter start, end;
- gdouble points;
-
gtk_text_buffer_get_selection_bounds (buffer, &start, &end);
-
- 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);
}
else
{
- GtkTextIter start, end;
- gdouble points;
- gint size;
- size = gtk_text_buffer_get_char_count(buffer);
- points = gimp_units_to_points (gimp_size_entry_get_refval (entry, 0),
- GIMP_UNIT_PIXEL,
- editor->resolution_y);
- gtk_text_buffer_get_iter_at_offset(buffer, &start, 0);
- gtk_text_buffer_get_iter_at_offset(buffer, &end, size);
- gimp_text_buffer_set_size (editor->buffer, &start, &end, PANGO_SCALE * points);
+ gtk_text_buffer_get_iter_at_offset (buffer, &start, 0);
+ gtk_text_buffer_get_iter_at_offset (buffer, &end, -1);
}
+ gimp_text_buffer_set_size (editor->buffer, &start, &end,
+ PANGO_SCALE * points);
+
insert_tags = gimp_text_style_editor_list_tags (editor, &remove_tags);
gimp_text_buffer_set_insert_tags (editor->buffer, insert_tags, remove_tags);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]