[gimp] app: enable editing text styles
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: enable editing text styles
- Date: Fri, 26 Feb 2010 00:39:10 +0000 (UTC)
commit 9cff2365b10da6f68d8f5cc93bc2127a53223161
Author: Michael Natterer <mitch gimp org>
Date: Fri Feb 26 01:36:31 2010 +0100
app: enable editing text styles
- create a GimpTextStyleEditor on the canvas when editing text.
- sync "text" and "markup" between proxy and text, not only "text.
- connect to chages to text marks on the buffer.
app/tools/gimptexttool-editor.c | 41 +++++++++++++++++++++++
app/tools/gimptexttool.c | 70 ++++++++++++++++++++++++++++++++------
app/tools/gimptexttool.h | 3 ++
3 files changed, 103 insertions(+), 11 deletions(-)
---
diff --git a/app/tools/gimptexttool-editor.c b/app/tools/gimptexttool-editor.c
index 6d39dba..4b5d6b3 100644
--- a/app/tools/gimptexttool-editor.c
+++ b/app/tools/gimptexttool-editor.c
@@ -38,6 +38,7 @@
#include "widgets/gimptextbuffer.h"
#include "widgets/gimptexteditor.h"
#include "widgets/gimptextproxy.h"
+#include "widgets/gimptextstyleeditor.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplayshell.h"
@@ -133,6 +134,8 @@ gimp_text_tool_editor_start (GimpTextTool *text_tool)
GimpTool *tool = GIMP_TOOL (text_tool);
GimpTextOptions *options = GIMP_TEXT_TOOL_GET_OPTIONS (text_tool);
GimpDisplayShell *shell = gimp_display_get_shell (tool->display);
+ GtkRequisition requisition;
+ gint x, y;
gtk_im_context_set_client_window (text_tool->im_context,
gtk_widget_get_window (shell->canvas));
@@ -148,6 +151,37 @@ gimp_text_tool_editor_start (GimpTextTool *text_tool)
g_signal_connect (options, "notify::use-editor",
G_CALLBACK (gimp_text_tool_options_notify),
text_tool);
+
+ if (! text_tool->style_overlay)
+ {
+ text_tool->style_overlay = gtk_frame_new (NULL);
+ gtk_frame_set_shadow_type (GTK_FRAME (text_tool->style_overlay),
+ GTK_SHADOW_OUT);
+ gimp_display_shell_add_overlay (shell,
+ text_tool->style_overlay,
+ 0, 0);
+ gimp_overlay_box_set_child_opacity (GIMP_OVERLAY_BOX (shell->canvas),
+ text_tool->style_overlay, 0.7);
+
+ text_tool->style_editor = gimp_text_style_editor_new (text_tool->buffer);
+ gtk_container_add (GTK_CONTAINER (text_tool->style_overlay),
+ text_tool->style_editor);
+ gtk_widget_show (text_tool->style_editor);
+ }
+
+ gtk_widget_size_request (text_tool->style_overlay, &requisition);
+
+ g_object_get (text_tool,
+ "x1", &x,
+ "y1", &y,
+ NULL);
+
+ gimp_display_shell_move_overlay (shell,
+ text_tool->style_overlay,
+ x,
+ y - requisition.height - 6);
+
+ gtk_widget_show (text_tool->style_overlay);
}
void
@@ -155,6 +189,13 @@ gimp_text_tool_editor_halt (GimpTextTool *text_tool)
{
GimpTextOptions *options = GIMP_TEXT_TOOL_GET_OPTIONS (text_tool);
+ if (text_tool->style_overlay)
+ {
+ gtk_widget_destroy (text_tool->style_overlay);
+ text_tool->style_overlay = NULL;
+ text_tool->style_editor = NULL;
+ }
+
g_signal_handlers_disconnect_by_func (options,
gimp_text_tool_options_notify,
text_tool);
diff --git a/app/tools/gimptexttool.c b/app/tools/gimptexttool.c
index f01a9e5..d7a5ba7 100644
--- a/app/tools/gimptexttool.c
+++ b/app/tools/gimptexttool.c
@@ -160,7 +160,12 @@ static gboolean gimp_text_tool_set_drawable (GimpTextTool *text_tool,
GimpDrawable *drawable,
gboolean confirm);
-static void gimp_text_tool_buffer_changed (GtkTextBuffer *text_buffer,
+static void gimp_text_tool_buffer_changed (GtkTextBuffer *buffer,
+ GimpTextTool *text_tool);
+void gimp_text_tool_buffer_tagged (GtkTextBuffer *buffer,
+ GtkTextTag *tag,
+ GtkTextIter *start,
+ GtkTextIter *end,
GimpTextTool *text_tool);
@@ -246,6 +251,12 @@ gimp_text_tool_init (GimpTextTool *text_tool)
g_signal_connect (text_tool->buffer, "changed",
G_CALLBACK (gimp_text_tool_buffer_changed),
text_tool);
+ g_signal_connect_after (text_tool->buffer, "apply-tag",
+ G_CALLBACK (gimp_text_tool_buffer_tagged),
+ text_tool);
+ g_signal_connect_after (text_tool->buffer, "remove-tag",
+ G_CALLBACK (gimp_text_tool_buffer_tagged),
+ text_tool);
text_tool->handle_rectangle_change_complete = TRUE;
@@ -908,6 +919,9 @@ gimp_text_tool_connect (GimpTextTool *text_tool,
g_signal_handlers_block_by_func (text_tool->buffer,
gimp_text_tool_buffer_changed,
text_tool);
+ g_signal_handlers_block_by_func (text_tool->buffer,
+ gimp_text_tool_buffer_tagged,
+ text_tool);
if (text_tool->text)
{
@@ -921,8 +935,12 @@ gimp_text_tool_connect (GimpTextTool *text_tool,
g_object_unref (text_tool->text);
text_tool->text = NULL;
- g_object_set (text_tool->proxy, "text", NULL, NULL);
+ g_object_set (text_tool->proxy,
+ "text", NULL,
+ "markup", NULL,
+ NULL);
gimp_text_buffer_set_text (text_tool->buffer, NULL);
+ gimp_text_buffer_set_markup (text_tool->buffer, NULL);
gimp_text_tool_clear_layout (text_tool);
}
@@ -935,6 +953,7 @@ gimp_text_tool_connect (GimpTextTool *text_tool,
{
gimp_config_sync (G_OBJECT (text), G_OBJECT (text_tool->proxy), 0);
gimp_text_buffer_set_text (text_tool->buffer, text->text);
+ gimp_text_buffer_set_markup (text_tool->buffer, text->markup);
gimp_text_tool_clear_layout (text_tool);
@@ -946,6 +965,9 @@ gimp_text_tool_connect (GimpTextTool *text_tool,
}
g_signal_handlers_unblock_by_func (text_tool->buffer,
+ gimp_text_tool_buffer_tagged,
+ text_tool);
+ g_signal_handlers_unblock_by_func (text_tool->buffer,
gimp_text_tool_buffer_changed,
text_tool);
}
@@ -1036,15 +1058,25 @@ gimp_text_tool_text_notify (GimpText *text,
/* if the text has changed, (probably because of an undo), we put
* the new text into the text buffer
*/
- if (strcmp (pspec->name, "text") == 0)
+ if (strcmp (pspec->name, "text") == 0 ||
+ strcmp (pspec->name, "markup") == 0)
{
g_signal_handlers_block_by_func (text_tool->buffer,
gimp_text_tool_buffer_changed,
text_tool);
+ g_signal_handlers_block_by_func (text_tool->buffer,
+ gimp_text_tool_buffer_tagged,
+ text_tool);
- gimp_text_buffer_set_text (text_tool->buffer, text->text);
+ if (pspec->name[0] == 't')
+ gimp_text_buffer_set_text (text_tool->buffer, text->text);
+ else
+ gimp_text_buffer_set_markup (text_tool->buffer, text->markup);
g_signal_handlers_unblock_by_func (text_tool->buffer,
+ gimp_text_tool_buffer_tagged,
+ text_tool);
+ g_signal_handlers_unblock_by_func (text_tool->buffer,
gimp_text_tool_buffer_changed,
text_tool);
}
@@ -1225,13 +1257,16 @@ gimp_text_tool_create_layer (GimpTextTool *text_tool,
else
{
gchar *string = gimp_text_buffer_get_text (text_tool->buffer);
+ gchar *markup = gimp_text_buffer_get_markup (text_tool->buffer);
g_object_set (text_tool->proxy,
"text", string,
+ "markup", markup,
"box-mode", GIMP_TEXT_BOX_DYNAMIC,
NULL);
g_free (string);
+ g_free (markup);
text = gimp_config_duplicate (GIMP_CONFIG (text_tool->proxy));
}
@@ -1324,7 +1359,7 @@ gimp_text_tool_confirm_response (GtkWidget *widget,
gimp_text_tool_connect (text_tool, layer, layer->text);
/* cause the text layer to be rerendered */
- g_object_notify (G_OBJECT (text_tool->proxy), "text");
+ g_object_notify (G_OBJECT (text_tool->proxy), "markup");
gimp_text_tool_editor_start (text_tool);
break;
@@ -1510,13 +1545,16 @@ gimp_text_tool_buffer_changed (GtkTextBuffer *buffer,
{
if (text_tool->text)
{
- gchar *string = gimp_text_buffer_get_text (GIMP_TEXT_BUFFER (buffer));
+ gchar *text = gimp_text_buffer_get_text (GIMP_TEXT_BUFFER (buffer));
+ gchar *markup = gimp_text_buffer_get_markup (GIMP_TEXT_BUFFER (buffer));
g_object_set (text_tool->proxy,
- "text", string,
+ "text", text,
+ "markup", markup,
NULL);
- g_free (string);
+ g_free (text);
+ g_free (markup);
}
else
{
@@ -1525,6 +1563,19 @@ gimp_text_tool_buffer_changed (GtkTextBuffer *buffer,
}
void
+gimp_text_tool_buffer_tagged (GtkTextBuffer *buffer,
+ GtkTextTag *tag,
+ GtkTextIter *start,
+ GtkTextIter *end,
+ GimpTextTool *text_tool)
+{
+ gimp_text_tool_buffer_changed (buffer, text_tool);
+}
+
+
+/* public functions */
+
+void
gimp_text_tool_clear_layout (GimpTextTool *text_tool)
{
if (text_tool->layout)
@@ -1545,9 +1596,6 @@ gimp_text_tool_ensure_layout (GimpTextTool *text_tool)
}
}
-
-/* public functions */
-
void
gimp_text_tool_set_layer (GimpTextTool *text_tool,
GimpLayer *layer)
diff --git a/app/tools/gimptexttool.h b/app/tools/gimptexttool.h
index 5c3b385..4b2c262 100644
--- a/app/tools/gimptexttool.h
+++ b/app/tools/gimptexttool.h
@@ -65,6 +65,9 @@ struct _GimpTextTool
/* text editor state: */
+ GtkWidget *style_overlay;
+ GtkWidget *style_editor;
+
gboolean selecting;
gint select_start_offset;
gboolean select_words;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]