[gimp] app: do the setting of the text box mode properly
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: do the setting of the text box mode properly
- Date: Wed, 17 Feb 2010 19:29:06 +0000 (UTC)
commit 31659758d1b8b78b7b8b28df581444732a2b4571
Author: Michael Natterer <mitch gimp org>
Date: Wed Feb 17 20:23:58 2010 +0100
app: do the setting of the text box mode properly
- remove the button again.
- add a "box-mode" property to GimpTextOptions and a combo box.
- let the normal options -> proxy -> text mechanism do the setting.
- make sure we update the rectangle in some more situations.
- add utility function gimp_text_tool_frame_item().
app/tools/gimptextoptions.c | 24 +++++++--
app/tools/gimptextoptions.h | 2 +-
app/tools/gimptexttool.c | 119 ++++++++++++-------------------------------
3 files changed, 52 insertions(+), 93 deletions(-)
---
diff --git a/app/tools/gimptextoptions.c b/app/tools/gimptextoptions.c
index 92236d2..a8f85f4 100644
--- a/app/tools/gimptextoptions.c
+++ b/app/tools/gimptextoptions.c
@@ -60,6 +60,8 @@ enum
PROP_INDENTATION,
PROP_LINE_SPACING,
PROP_LETTER_SPACING,
+ PROP_BOX_MODE,
+
PROP_USE_EDITOR,
PROP_FONT_VIEW_TYPE,
@@ -167,6 +169,12 @@ gimp_text_options_class_init (GimpTextOptionsClass *klass)
-8192.0, 8192.0, 0.0,
GIMP_PARAM_STATIC_STRINGS |
GIMP_CONFIG_PARAM_DEFAULTS);
+ GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_BOX_MODE,
+ "box-mode",
+ N_("Text box resize mode"),
+ GIMP_TYPE_TEXT_BOX_MODE,
+ GIMP_TEXT_BOX_DYNAMIC,
+ GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_USE_EDITOR,
"use-editor",
@@ -237,6 +245,9 @@ gimp_text_options_get_property (GObject *object,
case PROP_LETTER_SPACING:
g_value_set_double (value, options->letter_spacing);
break;
+ case PROP_BOX_MODE:
+ g_value_set_enum (value, options->box_mode);
+ break;
case PROP_USE_EDITOR:
g_value_set_boolean (value, options->use_editor);
@@ -296,6 +307,9 @@ gimp_text_options_set_property (GObject *object,
case PROP_LETTER_SPACING:
options->letter_spacing = g_value_get_double (value);
break;
+ case PROP_BOX_MODE:
+ options->box_mode = g_value_get_enum (value);
+ break;
case PROP_USE_EDITOR:
options->use_editor = g_value_get_boolean (value);
@@ -433,6 +447,7 @@ gimp_text_options_gui (GimpToolOptions *tool_options)
GtkWidget *box;
GtkWidget *label;
GtkWidget *spinbutton;
+ GtkWidget *combo;
GtkSizeGroup *size_group;
gint row = 0;
@@ -517,11 +532,10 @@ gimp_text_options_gui (GimpToolOptions *tool_options)
gimp_table_attach_stock (GTK_TABLE (table), row++,
GIMP_STOCK_LETTER_SPACING, spinbutton, 1, TRUE);
- options->dynamic_box_button = button =
- gtk_button_new_with_label (_("Dynamic Text Box"));
- gtk_widget_set_sensitive (button, FALSE);
- gtk_box_pack_start (GTK_BOX (main_vbox), button, FALSE, FALSE, 0);
- gtk_widget_show (button);
+ combo = gimp_prop_enum_combo_box_new (config, "box-mode", 0, 0);
+ gimp_table_attach_aligned (GTK_TABLE (table), 0, row++,
+ _("Box:"), 0.0, 0.5,
+ combo, 1, TRUE);
/* Only add the language entry if the iso-codes package is available. */
diff --git a/app/tools/gimptextoptions.h b/app/tools/gimptextoptions.h
index e656015..71328dc 100644
--- a/app/tools/gimptextoptions.h
+++ b/app/tools/gimptextoptions.h
@@ -47,6 +47,7 @@ struct _GimpTextOptions
gdouble indent;
gdouble line_spacing;
gdouble letter_spacing;
+ GimpTextBoxMode box_mode;
GimpViewType font_view_type;
GimpViewSize font_view_size;
@@ -55,7 +56,6 @@ struct _GimpTextOptions
/* options gui */
GtkWidget *size_entry;
- GtkWidget *dynamic_box_button;
};
diff --git a/app/tools/gimptexttool.c b/app/tools/gimptexttool.c
index 07bbeda..8f4ac68 100644
--- a/app/tools/gimptexttool.c
+++ b/app/tools/gimptexttool.c
@@ -126,6 +126,8 @@ static void gimp_text_tool_draw_selection (GimpDrawTool *draw_tool,
gint logical_off_x,
gint logical_off_y);
+static void gimp_text_tool_frame_item (GimpTextTool *text_tool);
+
static gboolean gimp_text_tool_rectangle_change_complete
(GimpRectangleTool *rect_tool);
@@ -153,7 +155,6 @@ static void gimp_text_tool_connect (GimpTextTool *text_tool,
static void gimp_text_tool_options_notify (GimpTextOptions *options,
GParamSpec *pspec,
GimpTextTool *text_tool);
-static void gimp_text_tool_set_dynamic_box (GimpTextTool *text_tool);
static void gimp_text_tool_layer_notify (GimpTextLayer *layer,
GParamSpec *pspec,
GimpTextTool *text_tool);
@@ -506,8 +507,9 @@ gimp_text_tool_button_press (GimpTool *tool,
gimp_rectangle_tool_set_function (rect_tool,
GIMP_RECTANGLE_TOOL_DEAD);
- gimp_rectangle_tool_frame_item (rect_tool,
- GIMP_ITEM (drawable));
+
+ gimp_text_tool_frame_item (text_tool);
+
}
if (press_type == GIMP_BUTTON_PRESS_NORMAL)
@@ -642,12 +644,7 @@ gimp_text_tool_button_release (GimpTool *tool,
gimp_tool_control_halt (tool->control);
- text_tool->handle_rectangle_change_complete = FALSE;
-
- gimp_rectangle_tool_frame_item (rect_tool,
- GIMP_ITEM (text_tool->layer));
-
- text_tool->handle_rectangle_change_complete = TRUE;
+ gimp_text_tool_frame_item (text_tool);
g_signal_handlers_unblock_by_func (text_tool->text_buffer,
gimp_text_tool_text_buffer_mark_set,
@@ -1287,6 +1284,19 @@ gimp_text_tool_draw_selection (GimpDrawTool *draw_tool,
pango_layout_iter_free (line_iter);
}
+static void
+gimp_text_tool_frame_item (GimpTextTool *text_tool)
+{
+ g_return_if_fail (GIMP_IS_LAYER (text_tool->layer));
+
+ text_tool->handle_rectangle_change_complete = FALSE;
+
+ gimp_rectangle_tool_frame_item (GIMP_RECTANGLE_TOOL (text_tool),
+ GIMP_ITEM (text_tool->layer));
+
+ text_tool->handle_rectangle_change_complete = TRUE;
+}
+
static gboolean
gimp_text_tool_rectangle_change_complete (GimpRectangleTool *rect_tool)
{
@@ -1817,8 +1827,7 @@ gimp_text_tool_connect (GimpTextTool *text_tool,
GimpTextLayer *layer,
GimpText *text)
{
- GimpTool *tool = GIMP_TOOL (text_tool);
- GimpTextOptions *options = GIMP_TEXT_TOOL_GET_OPTIONS (text_tool);
+ GimpTool *tool = GIMP_TOOL (text_tool);
g_return_if_fail (text == NULL || (layer != NULL && layer->text == text));
@@ -1860,30 +1869,16 @@ gimp_text_tool_connect (GimpTextTool *text_tool,
if (text_tool->layer != layer)
{
if (text_tool->layer)
- {
- g_signal_handlers_disconnect_by_func (text_tool->layer,
- gimp_text_tool_layer_notify,
- text_tool);
-
- gtk_widget_set_sensitive (options->dynamic_box_button, FALSE);
- g_signal_handlers_disconnect_by_func (options->dynamic_box_button,
- gimp_text_tool_set_dynamic_box,
- text_tool);
- }
+ g_signal_handlers_disconnect_by_func (text_tool->layer,
+ gimp_text_tool_layer_notify,
+ text_tool);
text_tool->layer = layer;
if (layer)
- {
- gtk_widget_set_sensitive (options->dynamic_box_button, TRUE);
- g_signal_connect_swapped (options->dynamic_box_button, "clicked",
- G_CALLBACK (gimp_text_tool_set_dynamic_box),
- text_tool);
-
- g_signal_connect_object (text_tool->layer, "notify::modified",
- G_CALLBACK (gimp_text_tool_layer_notify),
- text_tool, 0);
- }
+ g_signal_connect_object (text_tool->layer, "notify::modified",
+ G_CALLBACK (gimp_text_tool_layer_notify),
+ text_tool, 0);
}
}
@@ -1910,26 +1905,6 @@ gimp_text_tool_options_notify (GimpTextOptions *options,
}
static void
-gimp_text_tool_set_dynamic_box (GimpTextTool *text_tool)
-{
- if (text_tool->layer &&
- text_tool->text &&
- text_tool->text->box_mode == GIMP_TEXT_BOX_FIXED)
- {
- g_object_set (text_tool->proxy,
- "box-mode", GIMP_TEXT_BOX_DYNAMIC,
- NULL);
-
- gimp_image_undo_group_start (text_tool->image, GIMP_UNDO_GROUP_TEXT,
- _("Reshape Text Layer"));
-
- gimp_text_tool_apply (text_tool);
-
- gimp_image_undo_group_end (text_tool->image);
- }
-}
-
-static void
gimp_text_tool_layer_notify (GimpTextLayer *layer,
GParamSpec *pspec,
GimpTextTool *text_tool)
@@ -1992,17 +1967,9 @@ gimp_text_tool_text_notify (GimpText *text,
* the layer has changed, because of an undo for example.
*/
if (strcmp (pspec->name, "box-width") == 0 ||
- strcmp (pspec->name, "box-height") == 0 ||
- text->box_mode == GIMP_TEXT_BOX_DYNAMIC)
+ strcmp (pspec->name, "box-height") == 0)
{
- GimpRectangleTool *rect_tool = GIMP_RECTANGLE_TOOL (text_tool);
-
- text_tool->handle_rectangle_change_complete = FALSE;
-
- gimp_rectangle_tool_frame_item (rect_tool,
- GIMP_ITEM (text_tool->layer));
-
- text_tool->handle_rectangle_change_complete = TRUE;
+ gimp_text_tool_frame_item (text_tool);
}
/* if the text has changed, (probably because of an undo), we put
@@ -2166,18 +2133,7 @@ gimp_text_tool_apply (GimpTextTool *text_tool)
gimp_image_undo_group_end (image);
}
- /* if we're doing dynamic text, we want to update the shape of the
- * rectangle
- */
- if (layer->text->box_mode == GIMP_TEXT_BOX_DYNAMIC)
- {
- text_tool->handle_rectangle_change_complete = FALSE;
-
- gimp_rectangle_tool_frame_item (GIMP_RECTANGLE_TOOL (text_tool),
- GIMP_ITEM (layer));
-
- text_tool->handle_rectangle_change_complete = TRUE;
- }
+ gimp_text_tool_frame_item (text_tool);
gimp_image_flush (image);
gimp_text_tool_update_layout (text_tool);
@@ -2265,12 +2221,7 @@ gimp_text_tool_create_layer (GimpTextTool *text_tool,
}
else
{
- text_tool->handle_rectangle_change_complete = FALSE;
-
- gimp_rectangle_tool_frame_item (GIMP_RECTANGLE_TOOL (text_tool),
- GIMP_ITEM (layer));
-
- text_tool->handle_rectangle_change_complete = TRUE;
+ gimp_text_tool_frame_item (text_tool);
}
gimp_image_undo_group_end (image);
@@ -2495,12 +2446,7 @@ gimp_text_tool_layer_changed (GimpImage *image,
{
if (! gimp_rectangle_tool_rectangle_is_new (rect_tool))
{
- text_tool->handle_rectangle_change_complete = FALSE;
-
- gimp_rectangle_tool_frame_item (rect_tool,
- GIMP_ITEM (text_tool->layer));
-
- text_tool->handle_rectangle_change_complete = TRUE;
+ gimp_text_tool_frame_item (text_tool);
}
}
}
@@ -2800,8 +2746,7 @@ gimp_text_tool_set_layer (GimpTextTool *text_tool,
gimp_draw_tool_start (draw_tool, display);
- gimp_rectangle_tool_frame_item (GIMP_RECTANGLE_TOOL (tool),
- GIMP_ITEM (layer));
+ gimp_text_tool_frame_item (text_tool);
gimp_text_tool_editor (text_tool);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]