Allow invoking the text tool by double clicking a text layer in the layers

2004-01-13  Michael Natterer  <mitch@gimp.org>

	Allow invoking the text tool by double clicking a text layer in
	the layers dialog, just like the path tool is invoked when double
	clicking a path.

	* app/tools/gimptexttool.[ch]: added empty
	gimp_text_tool_set_layer() stub. Sven, your turn...

	* app/gui/layers-commands.[ch]: added layers_text_tool() which
	invokes the text tool on text layers and falls back to
	layers_edit_layer_query() otherwise.
	Added layers_text_tool_cmd_callback() for the layers menu.

	* app/gui/layers-menu.c: added "Text Tool" menu item and hide
	it for layers which are no text layers.

	* app/gui/dialogs-constructors.c (dialogs_layer_list_view_new):
	use layers_text_tool() as "activate" function.
This commit is contained in:
Michael Natterer 2004-01-13 19:08:16 +00:00 committed by Michael Natterer
parent a768016ef0
commit 3bee156b6e
10 changed files with 168 additions and 6 deletions

View File

@ -1,3 +1,23 @@
2004-01-13 Michael Natterer <mitch@gimp.org>
Allow invoking the text tool by double clicking a text layer in
the layers dialog, just like the path tool is invoked when double
clicking a path.
* app/tools/gimptexttool.[ch]: added empty
gimp_text_tool_set_layer() stub. Sven, your turn...
* app/gui/layers-commands.[ch]: added layers_text_tool() which
invokes the text tool on text layers and falls back to
layers_edit_layer_query() otherwise.
Added layers_text_tool_cmd_callback() for the layers menu.
* app/gui/layers-menu.c: added "Text Tool" menu item and hide
it for layers which are no text layers.
* app/gui/dialogs-constructors.c (dialogs_layer_list_view_new):
use layers_text_tool() as "activate" function.
2004-01-13 Michael Natterer <mitch@gimp.org>
* app/composite/Makefile.am (AM_CPPFLAGS): G_LOG_DOMAIN should be

View File

@ -38,6 +38,7 @@
#include "core/gimplayer-floating-sel.h"
#include "core/gimplayermask.h"
#include "core/gimplist.h"
#include "core/gimptoolinfo.h"
#include "text/gimptextlayer.h"
@ -50,6 +51,9 @@
#include "display/gimpdisplay.h"
#include "tools/gimptexttool.h"
#include "tools/tool_manager.h"
#include "layers-commands.h"
#include "image-commands.h"
#include "resize-dialog.h"
@ -507,6 +511,17 @@ layers_flatten_image_cmd_callback (GtkWidget *widget,
gimp_image_flush (gimage);
}
void
layers_text_tool_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
GimpLayer *active_layer;
return_if_no_layer (gimage, active_layer, data);
layers_text_tool (active_layer, widget);
}
void
layers_edit_attributes_cmd_callback (GtkWidget *widget,
gpointer data)
@ -518,6 +533,50 @@ layers_edit_attributes_cmd_callback (GtkWidget *widget,
layers_edit_layer_query (active_layer, widget);
}
void
layers_text_tool (GimpLayer *layer,
GtkWidget *parent)
{
GimpImage *gimage;
GimpTool *active_tool;
g_return_if_fail (GIMP_IS_LAYER (layer));
if (! GIMP_IS_TEXT_LAYER (layer))
{
layers_edit_layer_query (layer, parent);
return;
}
gimage = gimp_item_get_image (GIMP_ITEM (layer));
active_tool = tool_manager_get_active (gimage->gimp);
if (! GIMP_IS_TEXT_TOOL (active_tool))
{
GimpContainer *tool_info_list;
GimpToolInfo *tool_info;
tool_info_list = gimage->gimp->tool_info_list;
tool_info = (GimpToolInfo *)
gimp_container_get_child_by_name (tool_info_list,
"gimp-text-tool");
if (GIMP_IS_TOOL_INFO (tool_info))
{
gimp_context_set_tool (gimp_get_current_context (gimage->gimp),
tool_info);
active_tool = tool_manager_get_active (gimage->gimp);
}
}
if (GIMP_IS_TEXT_TOOL (active_tool))
gimp_text_tool_set_layer (GIMP_TEXT_TOOL (active_tool),
GIMP_TEXT_LAYER (layer));
}
/********************************/
/* The new layer query dialog */

View File

@ -81,9 +81,13 @@ void layers_merge_layers_cmd_callback (GtkWidget *widget,
void layers_flatten_image_cmd_callback (GtkWidget *widget,
gpointer data);
void layers_text_tool_cmd_callback (GtkWidget *widet,
gpointer data);
void layers_edit_attributes_cmd_callback (GtkWidget *widet,
gpointer data);
void layers_text_tool (GimpLayer *layer,
GtkWidget *parent);
void layers_new_layer_query (GimpImage *gimage,
GimpLayer *template,
gboolean interactive,

View File

@ -644,7 +644,7 @@ dialogs_layer_list_view_new (GimpDialogFactory *factory,
"active_layer_changed",
(GimpEditItemFunc) layers_edit_layer_query,
(GimpNewItemFunc) layers_new_layer_query,
(GimpActivateItemFunc) layers_edit_layer_query,
(GimpActivateItemFunc) layers_text_tool,
factory->menu_factory, "<Layers>");
dockable = dialogs_dockable_new (view,

View File

@ -644,7 +644,7 @@ dialogs_layer_list_view_new (GimpDialogFactory *factory,
"active_layer_changed",
(GimpEditItemFunc) layers_edit_layer_query,
(GimpNewItemFunc) layers_new_layer_query,
(GimpActivateItemFunc) layers_edit_layer_query,
(GimpActivateItemFunc) layers_text_tool,
factory->menu_factory, "<Layers>");
dockable = dialogs_dockable_new (view,

View File

@ -38,6 +38,7 @@
#include "core/gimplayer-floating-sel.h"
#include "core/gimplayermask.h"
#include "core/gimplist.h"
#include "core/gimptoolinfo.h"
#include "text/gimptextlayer.h"
@ -50,6 +51,9 @@
#include "display/gimpdisplay.h"
#include "tools/gimptexttool.h"
#include "tools/tool_manager.h"
#include "layers-commands.h"
#include "image-commands.h"
#include "resize-dialog.h"
@ -507,6 +511,17 @@ layers_flatten_image_cmd_callback (GtkWidget *widget,
gimp_image_flush (gimage);
}
void
layers_text_tool_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
GimpLayer *active_layer;
return_if_no_layer (gimage, active_layer, data);
layers_text_tool (active_layer, widget);
}
void
layers_edit_attributes_cmd_callback (GtkWidget *widget,
gpointer data)
@ -518,6 +533,50 @@ layers_edit_attributes_cmd_callback (GtkWidget *widget,
layers_edit_layer_query (active_layer, widget);
}
void
layers_text_tool (GimpLayer *layer,
GtkWidget *parent)
{
GimpImage *gimage;
GimpTool *active_tool;
g_return_if_fail (GIMP_IS_LAYER (layer));
if (! GIMP_IS_TEXT_LAYER (layer))
{
layers_edit_layer_query (layer, parent);
return;
}
gimage = gimp_item_get_image (GIMP_ITEM (layer));
active_tool = tool_manager_get_active (gimage->gimp);
if (! GIMP_IS_TEXT_TOOL (active_tool))
{
GimpContainer *tool_info_list;
GimpToolInfo *tool_info;
tool_info_list = gimage->gimp->tool_info_list;
tool_info = (GimpToolInfo *)
gimp_container_get_child_by_name (tool_info_list,
"gimp-text-tool");
if (GIMP_IS_TOOL_INFO (tool_info))
{
gimp_context_set_tool (gimp_get_current_context (gimage->gimp),
tool_info);
active_tool = tool_manager_get_active (gimage->gimp);
}
}
if (GIMP_IS_TEXT_TOOL (active_tool))
gimp_text_tool_set_layer (GIMP_TEXT_TOOL (active_tool),
GIMP_TEXT_LAYER (layer));
}
/********************************/
/* The new layer query dialog */

View File

@ -81,9 +81,13 @@ void layers_merge_layers_cmd_callback (GtkWidget *widget,
void layers_flatten_image_cmd_callback (GtkWidget *widget,
gpointer data);
void layers_text_tool_cmd_callback (GtkWidget *widet,
gpointer data);
void layers_edit_attributes_cmd_callback (GtkWidget *widet,
gpointer data);
void layers_text_tool (GimpLayer *layer,
GtkWidget *parent);
void layers_new_layer_query (GimpImage *gimage,
GimpLayer *template,
gboolean interactive,

View File

@ -43,6 +43,11 @@
GimpItemFactoryEntry layers_menu_entries[] =
{
{ { N_("/Te_xt Tool"), NULL,
layers_text_tool_cmd_callback, 0,
"<StockItem>", GIMP_STOCK_TOOL_TEXT },
NULL,
GIMP_HELP_TOOL_TEXT, NULL },
{ { N_("/_Edit Layer Attributes..."), NULL,
layers_edit_attributes_cmd_callback, 0,
"<StockItem>", GIMP_STOCK_EDIT },
@ -234,6 +239,7 @@ layers_menu_update (GtkItemFactory *factory,
#define SET_VISIBLE(menu,condition) \
gimp_item_factory_set_visible (factory, menu, (condition) != 0)
SET_VISIBLE ("/Text Tool", text_layer && !ac);
SET_SENSITIVE ("/Edit Layer Attributes...", layer && !fs && !ac);
SET_SENSITIVE ("/New Layer...", gimage);

View File

@ -277,7 +277,6 @@ gimp_text_tool_draw (GimpDrawTool *draw_tool)
{
}
static void
gimp_text_tool_create_vectors (GimpTextTool *text_tool)
{
@ -442,3 +441,11 @@ gimp_text_tool_buffer_changed (GtkTextBuffer *buffer,
if (! text_tool->text)
gimp_text_tool_create_layer (text_tool);
}
void
gimp_text_tool_set_layer (GimpTextTool *text_tool,
GimpTextLayer *text_layer)
{
g_return_if_fail (GIMP_IS_TEXT_TOOL (text_tool));
g_return_if_fail (text_layer == NULL || GIMP_IS_TEXT_LAYER (text_layer));
}

View File

@ -54,10 +54,13 @@ struct _GimpTextToolClass
};
void gimp_text_tool_register (GimpToolRegisterCallback callback,
gpointer data);
void gimp_text_tool_register (GimpToolRegisterCallback callback,
gpointer data);
GType gimp_text_tool_get_type (void) G_GNUC_CONST;
GType gimp_text_tool_get_type (void) G_GNUC_CONST;
void gimp_text_tool_set_layer (GimpTextTool *text_tool,
GimpTextLayer *text_layer);
#endif /* __GIMP_TEXT_TOOL_H__ */