app: allow to set the text layer back to dynamic resizing

Add a "Dynamic Text Box" button to the tool options which sets the
text box' mode back to dynamically resizing with the text.  This badly
needs UI review but is at least possible now.
This commit is contained in:
Michael Natterer 2010-02-17 15:50:03 +01:00
parent 9974fe36d1
commit 8574f4c4e8
3 changed files with 49 additions and 7 deletions

View file

@ -517,6 +517,11 @@ 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_box_pack_start (GTK_BOX (main_vbox), button, FALSE, FALSE, 0);
gtk_widget_show (button);
/* Only add the language entry if the iso-codes package is available. */
#ifdef HAVE_ISO_CODES

View file

@ -55,6 +55,7 @@ struct _GimpTextOptions
/* options gui */
GtkWidget *size_entry;
GtkWidget *dynamic_box_button;
};

View file

@ -149,6 +149,7 @@ static void gimp_text_tool_select_all (GimpTextTool *text_tool,
static void gimp_text_tool_connect (GimpTextTool *text_tool,
GimpTextLayer *layer,
GimpText *text);
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);
@ -1815,7 +1816,8 @@ gimp_text_tool_connect (GimpTextTool *text_tool,
GimpTextLayer *layer,
GimpText *text)
{
GimpTool *tool = GIMP_TOOL (text_tool);
GimpTool *tool = GIMP_TOOL (text_tool);
GimpTextOptions *options = GIMP_TEXT_TOOL_GET_OPTIONS (text_tool);
g_return_if_fail (text == NULL || (layer != NULL && layer->text == text));
@ -1857,16 +1859,30 @@ 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);
{
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);
}
text_tool->layer = layer;
if (layer)
g_signal_connect_object (text_tool->layer, "notify::modified",
G_CALLBACK (gimp_text_tool_layer_notify),
text_tool, 0);
{
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);
}
}
}
@ -1887,6 +1903,26 @@ gimp_text_tool_use_editor_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,