mirror of https://github.com/GNOME/gimp.git
added GIMP_UNDO_TEXT_LAYER to GimpUndoType enum.
2004-01-05 Sven Neumann <sven@gimp.org> * app/core/core-enums.[ch]: added GIMP_UNDO_TEXT_LAYER to GimpUndoType enum. * app/core/gimpimage-undo-push.[ch]: added new undo function gimp_image_undo_push_text_layer(). * app/text/gimptextlayer.[ch]: renamed gimp_text_layer_render() to gimp_layer_text_layer_flush(). Added new function gimp_text_layer_discard(). * app/text/gimptextlayer-transform.c: changed accordingly. * app/gui/image-menu.c * app/gui/layers-commands.[ch] * app/gui/layers-menu.c: added menu entries that allow to discard the text information of a text layer (bug #118547). * app/widgets/gimppreviewrendererlayer.c (gimp_preview_renderer_layer_render): treat text layers without a text object like ordinary layers. * app/widgets/gimppreviewrenderer-utils.c: include gimplayer.h instead of gimptextlayer.h.
This commit is contained in:
parent
985583f1c9
commit
3451c82f4f
26
ChangeLog
26
ChangeLog
|
@ -1,3 +1,29 @@
|
|||
2004-01-05 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/core/core-enums.[ch]: added GIMP_UNDO_TEXT_LAYER to
|
||||
GimpUndoType enum.
|
||||
|
||||
* app/core/gimpimage-undo-push.[ch]: added new undo function
|
||||
gimp_image_undo_push_text_layer().
|
||||
|
||||
* app/text/gimptextlayer.[ch]: renamed gimp_text_layer_render() to
|
||||
gimp_layer_text_layer_flush().
|
||||
Added new function gimp_text_layer_discard().
|
||||
|
||||
* app/text/gimptextlayer-transform.c: changed accordingly.
|
||||
|
||||
* app/gui/image-menu.c
|
||||
* app/gui/layers-commands.[ch]
|
||||
* app/gui/layers-menu.c: added menu entries that allow to discard
|
||||
the text information of a text layer (bug #118547).
|
||||
|
||||
* app/widgets/gimppreviewrendererlayer.c
|
||||
(gimp_preview_renderer_layer_render): treat text layers without a
|
||||
text object like ordinary layers.
|
||||
|
||||
* app/widgets/gimppreviewrenderer-utils.c: include gimplayer.h
|
||||
instead of gimptextlayer.h.
|
||||
|
||||
2004-01-04 Ville Pätsi <drc@gimp.org>
|
||||
|
||||
* gimp.spec.in: Remove last hardcoded -1.3's.
|
||||
|
|
|
@ -39,6 +39,8 @@
|
|||
#include "core/gimplayermask.h"
|
||||
#include "core/gimplist.h"
|
||||
|
||||
#include "text/gimptextlayer.h"
|
||||
|
||||
#include "pdb/procedural_db.h"
|
||||
|
||||
#include "widgets/gimpenummenu.h"
|
||||
|
@ -297,6 +299,18 @@ layers_delete_cmd_callback (GtkWidget *widget,
|
|||
gimp_image_flush (gimage);
|
||||
}
|
||||
|
||||
void
|
||||
layers_text_discard_cmd_callback (GtkWidget *widet,
|
||||
gpointer data)
|
||||
{
|
||||
GimpImage *gimage;
|
||||
GimpLayer *active_layer;
|
||||
return_if_no_layer (gimage, active_layer, data);
|
||||
|
||||
if (GIMP_IS_TEXT_LAYER (active_layer))
|
||||
gimp_text_layer_discard (GIMP_TEXT_LAYER (active_layer));
|
||||
}
|
||||
|
||||
void
|
||||
layers_resize_cmd_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
|
|
|
@ -48,6 +48,8 @@ void layers_merge_down_cmd_callback (GtkWidget *widet,
|
|||
gpointer data);
|
||||
void layers_delete_cmd_callback (GtkWidget *widet,
|
||||
gpointer data);
|
||||
void layers_text_discard_cmd_callback (GtkWidget *widet,
|
||||
gpointer data);
|
||||
|
||||
void layers_resize_cmd_callback (GtkWidget *widet,
|
||||
gpointer data);
|
||||
|
|
|
@ -634,6 +634,7 @@ static const GEnumValue gimp_undo_type_enum_values[] =
|
|||
{ GIMP_UNDO_LAYER_MODE, N_("Set Layer Mode"), "layer-mode" },
|
||||
{ GIMP_UNDO_LAYER_OPACITY, N_("Set Layer Opacity"), "layer-opacity" },
|
||||
{ GIMP_UNDO_LAYER_PRESERVE_TRANS, N_("Set Preserve Trans"), "layer-preserve-trans" },
|
||||
{ GIMP_UNDO_TEXT_LAYER, N_("Text"), "text-layer" },
|
||||
{ GIMP_UNDO_CHANNEL_ADD, N_("New Channel"), "channel-add" },
|
||||
{ GIMP_UNDO_CHANNEL_REMOVE, N_("Delete Channel"), "channel-remove" },
|
||||
{ GIMP_UNDO_CHANNEL_MOD, N_("Channel Mod"), "channel-mod" },
|
||||
|
|
|
@ -470,6 +470,7 @@ typedef enum /*< pdb-skip >*/
|
|||
GIMP_UNDO_LAYER_MODE, /*< desc="Set Layer Mode" >*/
|
||||
GIMP_UNDO_LAYER_OPACITY, /*< desc="Set Layer Opacity" >*/
|
||||
GIMP_UNDO_LAYER_PRESERVE_TRANS, /*< desc="Set Preserve Trans" >*/
|
||||
GIMP_UNDO_TEXT_LAYER, /*< desc="Text" >*/
|
||||
GIMP_UNDO_CHANNEL_ADD, /*< desc="New Channel" >*/
|
||||
GIMP_UNDO_CHANNEL_REMOVE, /*< desc="Delete Channel" >*/
|
||||
GIMP_UNDO_CHANNEL_MOD, /*< desc="Channel Mod" >*/
|
||||
|
|
|
@ -57,6 +57,8 @@
|
|||
|
||||
#include "paint/gimppaintcore.h"
|
||||
|
||||
#include "text/gimptextlayer.h"
|
||||
|
||||
#include "vectors/gimpvectors.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
@ -2078,6 +2080,94 @@ undo_free_layer_properties (GimpUndo *undo,
|
|||
}
|
||||
|
||||
|
||||
/*********************/
|
||||
/* Text Layer Undo */
|
||||
/*********************/
|
||||
|
||||
typedef struct _TextUndo TextUndo;
|
||||
|
||||
struct _TextUndo
|
||||
{
|
||||
GimpText *text;
|
||||
};
|
||||
|
||||
static gboolean undo_pop_text_layer (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode,
|
||||
GimpUndoAccumulator *accum);
|
||||
static void undo_free_text_layer (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode);
|
||||
|
||||
|
||||
gboolean
|
||||
gimp_image_undo_push_text_layer (GimpImage *gimage,
|
||||
const gchar *undo_desc,
|
||||
GimpTextLayer *layer)
|
||||
{
|
||||
GimpUndo *undo;
|
||||
gssize size = 0;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
||||
g_return_val_if_fail (GIMP_IS_TEXT_LAYER (layer), FALSE);
|
||||
|
||||
if (layer->text)
|
||||
size += gimp_object_get_memsize (GIMP_OBJECT (layer->text), NULL);
|
||||
|
||||
undo = gimp_image_undo_push_item (gimage, GIMP_ITEM (layer),
|
||||
sizeof (TextUndo) + size,
|
||||
sizeof (TextUndo),
|
||||
GIMP_UNDO_TEXT_LAYER, undo_desc,
|
||||
TRUE,
|
||||
undo_pop_text_layer,
|
||||
undo_free_text_layer);
|
||||
|
||||
if (undo)
|
||||
{
|
||||
TextUndo *tu = undo->data;
|
||||
|
||||
tu->text = (layer->text ?
|
||||
gimp_config_duplicate (GIMP_CONFIG (layer->text)) : NULL);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
undo_pop_text_layer (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode,
|
||||
GimpUndoAccumulator *accum)
|
||||
{
|
||||
GimpTextLayer *layer = GIMP_TEXT_LAYER (GIMP_ITEM_UNDO (undo)->item);
|
||||
TextUndo *tu = undo->data;
|
||||
GimpText *text;
|
||||
|
||||
text = (layer->text ?
|
||||
gimp_config_duplicate (GIMP_CONFIG (layer->text)) : NULL);
|
||||
|
||||
gimp_text_layer_set_text (layer, tu->text);
|
||||
|
||||
if (tu->text)
|
||||
g_object_unref (tu->text);
|
||||
|
||||
tu->text = text;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
undo_free_text_layer (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode)
|
||||
{
|
||||
TextUndo *tu = undo->data;
|
||||
|
||||
if (tu->text)
|
||||
g_object_unref (tu->text);
|
||||
|
||||
g_free (tu);
|
||||
}
|
||||
|
||||
|
||||
/*****************************/
|
||||
/* Add/Remove Channel Undo */
|
||||
/*****************************/
|
||||
|
|
|
@ -115,6 +115,10 @@ gboolean gimp_image_undo_push_layer_preserve_trans (GimpImage *gimage,
|
|||
const gchar *undo_desc,
|
||||
GimpLayer *layer);
|
||||
|
||||
/* text layer undo */
|
||||
gboolean gimp_image_undo_push_text_layer (GimpImage *gimage,
|
||||
const gchar *undo_desc,
|
||||
GimpTextLayer *layer);
|
||||
|
||||
/* channel undos */
|
||||
|
||||
|
|
|
@ -37,6 +37,8 @@
|
|||
|
||||
#include "plug-in/plug-ins.h"
|
||||
|
||||
#include "text/gimptextlayer.h"
|
||||
|
||||
#include "widgets/gimphelp-ids.h"
|
||||
#include "widgets/gimpitemfactory.h"
|
||||
|
||||
|
@ -619,6 +621,11 @@ GimpItemFactoryEntry image_menu_entries[] =
|
|||
"<StockItem>", GTK_STOCK_DELETE },
|
||||
NULL,
|
||||
GIMP_HELP_LAYER_DELETE, NULL },
|
||||
{ { N_("/Layer/Discard _Text Information"), NULL,
|
||||
layers_text_discard_cmd_callback, 0,
|
||||
"<StockItem>", GIMP_STOCK_TOOL_TEXT },
|
||||
NULL,
|
||||
GIMP_HELP_LAYER_TEXT_DISCARD, NULL },
|
||||
|
||||
MENU_SEPARATOR ("/Layer/---"),
|
||||
|
||||
|
@ -1323,6 +1330,7 @@ image_menu_update (GtkItemFactory *item_factory,
|
|||
gboolean lp = FALSE;
|
||||
gboolean sel = FALSE;
|
||||
gboolean alpha = FALSE;
|
||||
gboolean text_layer = FALSE;
|
||||
gint lind = -1;
|
||||
gint lnum = -1;
|
||||
gboolean fullscreen = FALSE;
|
||||
|
@ -1366,6 +1374,9 @@ image_menu_update (GtkItemFactory *item_factory,
|
|||
lm = gimp_layer_get_mask (layer) ? TRUE : FALSE;
|
||||
alpha = gimp_drawable_has_alpha (GIMP_DRAWABLE (layer));
|
||||
lind = gimp_image_get_layer_index (gimage, layer);
|
||||
|
||||
text_layer = (GIMP_IS_TEXT_LAYER (layer) &&
|
||||
GIMP_TEXT_LAYER (layer)->text);
|
||||
}
|
||||
|
||||
lnum = gimp_container_num_children (gimage->layers);
|
||||
|
@ -1543,11 +1554,12 @@ image_menu_update (GtkItemFactory *item_factory,
|
|||
|
||||
/* Layer */
|
||||
|
||||
SET_SENSITIVE ("/Layer/New Layer...", gdisp);
|
||||
SET_SENSITIVE ("/Layer/Duplicate Layer", lp && !fs && !aux);
|
||||
SET_SENSITIVE ("/Layer/Anchor Layer", lp && fs && !aux);
|
||||
SET_SENSITIVE ("/Layer/Merge Down", lp && !fs && !aux);
|
||||
SET_SENSITIVE ("/Layer/Delete Layer", lp && !aux);
|
||||
SET_SENSITIVE ("/Layer/New Layer...", gdisp);
|
||||
SET_SENSITIVE ("/Layer/Duplicate Layer", lp && !fs && !aux);
|
||||
SET_SENSITIVE ("/Layer/Anchor Layer", lp && fs && !aux);
|
||||
SET_SENSITIVE ("/Layer/Merge Down", lp && !fs && !aux);
|
||||
SET_SENSITIVE ("/Layer/Delete Layer", lp && !aux);
|
||||
SET_VISIBLE ("/Layer/Discard Text Information", text_layer && !aux);
|
||||
|
||||
SET_SENSITIVE ("/Layer/Layer Boundary Size...", lp && !aux);
|
||||
SET_SENSITIVE ("/Layer/Layer to Image Size", lp && !aux);
|
||||
|
|
|
@ -39,6 +39,8 @@
|
|||
#include "core/gimplayermask.h"
|
||||
#include "core/gimplist.h"
|
||||
|
||||
#include "text/gimptextlayer.h"
|
||||
|
||||
#include "pdb/procedural_db.h"
|
||||
|
||||
#include "widgets/gimpenummenu.h"
|
||||
|
@ -297,6 +299,18 @@ layers_delete_cmd_callback (GtkWidget *widget,
|
|||
gimp_image_flush (gimage);
|
||||
}
|
||||
|
||||
void
|
||||
layers_text_discard_cmd_callback (GtkWidget *widet,
|
||||
gpointer data)
|
||||
{
|
||||
GimpImage *gimage;
|
||||
GimpLayer *active_layer;
|
||||
return_if_no_layer (gimage, active_layer, data);
|
||||
|
||||
if (GIMP_IS_TEXT_LAYER (active_layer))
|
||||
gimp_text_layer_discard (GIMP_TEXT_LAYER (active_layer));
|
||||
}
|
||||
|
||||
void
|
||||
layers_resize_cmd_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
|
|
|
@ -48,6 +48,8 @@ void layers_merge_down_cmd_callback (GtkWidget *widet,
|
|||
gpointer data);
|
||||
void layers_delete_cmd_callback (GtkWidget *widet,
|
||||
gpointer data);
|
||||
void layers_text_discard_cmd_callback (GtkWidget *widet,
|
||||
gpointer data);
|
||||
|
||||
void layers_resize_cmd_callback (GtkWidget *widet,
|
||||
gpointer data);
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
#include "core/gimplayer.h"
|
||||
#include "core/gimplist.h"
|
||||
|
||||
#include "text/gimptextlayer.h"
|
||||
|
||||
#include "widgets/gimphelp-ids.h"
|
||||
#include "widgets/gimpitemfactory.h"
|
||||
#include "widgets/gimpitemtreeview.h"
|
||||
|
@ -96,6 +98,11 @@ GimpItemFactoryEntry layers_menu_entries[] =
|
|||
"<StockItem>", GTK_STOCK_DELETE },
|
||||
NULL,
|
||||
GIMP_HELP_LAYER_DELETE, NULL },
|
||||
{ { N_("/_Discard Text Information"), NULL,
|
||||
layers_text_discard_cmd_callback, 0,
|
||||
"<StockItem>", GIMP_STOCK_TOOL_TEXT },
|
||||
NULL,
|
||||
GIMP_HELP_LAYER_TEXT_DISCARD, NULL },
|
||||
|
||||
MENU_SEPARATOR ("/---"),
|
||||
|
||||
|
@ -178,6 +185,7 @@ layers_menu_update (GtkItemFactory *factory,
|
|||
gboolean alpha = FALSE; /* alpha channel present */
|
||||
gboolean indexed = FALSE; /* is indexed */
|
||||
gboolean next_alpha = FALSE;
|
||||
gboolean text_layer = FALSE;
|
||||
GList *next = NULL;
|
||||
GList *prev = NULL;
|
||||
|
||||
|
@ -215,10 +223,16 @@ layers_menu_update (GtkItemFactory *factory,
|
|||
next_alpha = gimp_drawable_has_alpha (GIMP_DRAWABLE (next->data));
|
||||
else
|
||||
next_alpha = FALSE;
|
||||
|
||||
text_layer = (layer &&
|
||||
GIMP_IS_TEXT_LAYER (layer) &&
|
||||
GIMP_TEXT_LAYER (layer)->text);
|
||||
}
|
||||
|
||||
#define SET_SENSITIVE(menu,condition) \
|
||||
gimp_item_factory_set_sensitive (factory, menu, (condition) != 0)
|
||||
#define SET_VISIBLE(menu,condition) \
|
||||
gimp_item_factory_set_visible (factory, menu, (condition) != 0)
|
||||
|
||||
SET_SENSITIVE ("/Edit Layer Attributes...", layer && !fs && !ac);
|
||||
|
||||
|
@ -234,6 +248,7 @@ layers_menu_update (GtkItemFactory *factory,
|
|||
SET_SENSITIVE ("/Anchor Layer", layer && fs && !ac);
|
||||
SET_SENSITIVE ("/Merge Down", layer && !fs && !ac && next);
|
||||
SET_SENSITIVE ("/Delete Layer", layer && !ac);
|
||||
SET_VISIBLE ("/Discard Text Information", text_layer && !ac);
|
||||
|
||||
SET_SENSITIVE ("/Layer Boundary Size...", layer && !ac);
|
||||
SET_SENSITIVE ("/Layer to Image Size", layer && !ac);
|
||||
|
|
|
@ -37,6 +37,8 @@
|
|||
|
||||
#include "plug-in/plug-ins.h"
|
||||
|
||||
#include "text/gimptextlayer.h"
|
||||
|
||||
#include "widgets/gimphelp-ids.h"
|
||||
#include "widgets/gimpitemfactory.h"
|
||||
|
||||
|
@ -619,6 +621,11 @@ GimpItemFactoryEntry image_menu_entries[] =
|
|||
"<StockItem>", GTK_STOCK_DELETE },
|
||||
NULL,
|
||||
GIMP_HELP_LAYER_DELETE, NULL },
|
||||
{ { N_("/Layer/Discard _Text Information"), NULL,
|
||||
layers_text_discard_cmd_callback, 0,
|
||||
"<StockItem>", GIMP_STOCK_TOOL_TEXT },
|
||||
NULL,
|
||||
GIMP_HELP_LAYER_TEXT_DISCARD, NULL },
|
||||
|
||||
MENU_SEPARATOR ("/Layer/---"),
|
||||
|
||||
|
@ -1323,6 +1330,7 @@ image_menu_update (GtkItemFactory *item_factory,
|
|||
gboolean lp = FALSE;
|
||||
gboolean sel = FALSE;
|
||||
gboolean alpha = FALSE;
|
||||
gboolean text_layer = FALSE;
|
||||
gint lind = -1;
|
||||
gint lnum = -1;
|
||||
gboolean fullscreen = FALSE;
|
||||
|
@ -1366,6 +1374,9 @@ image_menu_update (GtkItemFactory *item_factory,
|
|||
lm = gimp_layer_get_mask (layer) ? TRUE : FALSE;
|
||||
alpha = gimp_drawable_has_alpha (GIMP_DRAWABLE (layer));
|
||||
lind = gimp_image_get_layer_index (gimage, layer);
|
||||
|
||||
text_layer = (GIMP_IS_TEXT_LAYER (layer) &&
|
||||
GIMP_TEXT_LAYER (layer)->text);
|
||||
}
|
||||
|
||||
lnum = gimp_container_num_children (gimage->layers);
|
||||
|
@ -1543,11 +1554,12 @@ image_menu_update (GtkItemFactory *item_factory,
|
|||
|
||||
/* Layer */
|
||||
|
||||
SET_SENSITIVE ("/Layer/New Layer...", gdisp);
|
||||
SET_SENSITIVE ("/Layer/Duplicate Layer", lp && !fs && !aux);
|
||||
SET_SENSITIVE ("/Layer/Anchor Layer", lp && fs && !aux);
|
||||
SET_SENSITIVE ("/Layer/Merge Down", lp && !fs && !aux);
|
||||
SET_SENSITIVE ("/Layer/Delete Layer", lp && !aux);
|
||||
SET_SENSITIVE ("/Layer/New Layer...", gdisp);
|
||||
SET_SENSITIVE ("/Layer/Duplicate Layer", lp && !fs && !aux);
|
||||
SET_SENSITIVE ("/Layer/Anchor Layer", lp && fs && !aux);
|
||||
SET_SENSITIVE ("/Layer/Merge Down", lp && !fs && !aux);
|
||||
SET_SENSITIVE ("/Layer/Delete Layer", lp && !aux);
|
||||
SET_VISIBLE ("/Layer/Discard Text Information", text_layer && !aux);
|
||||
|
||||
SET_SENSITIVE ("/Layer/Layer Boundary Size...", lp && !aux);
|
||||
SET_SENSITIVE ("/Layer/Layer to Image Size", lp && !aux);
|
||||
|
|
|
@ -70,7 +70,7 @@ gimp_text_layer_flip (GimpItem *item,
|
|||
case GIMP_ORIENTATION_HORIZONTAL:
|
||||
trafo.coeff[0][0] = - 1.0;
|
||||
break;
|
||||
|
||||
|
||||
case GIMP_ORIENTATION_VERTICAL:
|
||||
trafo.coeff[1][1] = - 1.0;
|
||||
break;
|
||||
|
@ -81,7 +81,7 @@ gimp_text_layer_flip (GimpItem *item,
|
|||
|
||||
gimp_matrix2_mult (&trafo, &text->transformation);
|
||||
g_object_notify (G_OBJECT (text), "transformation");
|
||||
gimp_text_layer_render (GIMP_TEXT_LAYER (item));
|
||||
gimp_text_layer_flush (GIMP_TEXT_LAYER (item));
|
||||
}
|
||||
|
||||
/* If there is a layer mask, make sure it gets flipped as well */
|
||||
|
@ -140,7 +140,7 @@ gimp_text_layer_rotate (GimpItem *item,
|
|||
|
||||
gimp_matrix2_mult (&trafo, &text->transformation);
|
||||
g_object_notify (G_OBJECT (text), "transformation");
|
||||
gimp_text_layer_render (GIMP_TEXT_LAYER (item));
|
||||
gimp_text_layer_flush (GIMP_TEXT_LAYER (item));
|
||||
}
|
||||
|
||||
/* If there is a layer mask, make sure it gets rotates as well */
|
||||
|
@ -163,5 +163,5 @@ gimp_text_layer_transform (GimpItem *item,
|
|||
GimpProgressFunc progress_callback,
|
||||
gpointer progress_data)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* GimpTextLayer
|
||||
* Copyright (C) 2002-2003 Sven Neumann <sven@gimp.org>
|
||||
* Copyright (C) 2002-2004 Sven Neumann <sven@gimp.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -40,6 +40,7 @@
|
|||
#include "core/gimp.h"
|
||||
#include "core/gimpcontainer.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpimage-undo-push.h"
|
||||
#include "core/gimpparasitelist.h"
|
||||
|
||||
#include "gimptext.h"
|
||||
|
@ -60,9 +61,6 @@ static void gimp_text_layer_finalize (GObject *object);
|
|||
|
||||
static gint64 gimp_text_layer_get_memsize (GimpObject *object,
|
||||
gint64 *gui_size);
|
||||
static TempBuf * gimp_text_layer_get_preview (GimpViewable *viewable,
|
||||
gint width,
|
||||
gint height);
|
||||
|
||||
static GimpItem * gimp_text_layer_duplicate (GimpItem *item,
|
||||
GType new_type,
|
||||
|
@ -130,7 +128,6 @@ gimp_text_layer_class_init (GimpTextLayerClass *klass)
|
|||
gimp_object_class->get_memsize = gimp_text_layer_get_memsize;
|
||||
|
||||
viewable_class->default_stock_id = "gimp-text-layer";
|
||||
viewable_class->get_preview = gimp_text_layer_get_preview;
|
||||
|
||||
item_class->default_name = _("Text Layer");
|
||||
item_class->duplicate = gimp_text_layer_duplicate;
|
||||
|
@ -198,15 +195,6 @@ gimp_text_layer_get_memsize (GimpObject *object,
|
|||
gui_size);
|
||||
}
|
||||
|
||||
static TempBuf *
|
||||
gimp_text_layer_get_preview (GimpViewable *viewable,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
return GIMP_VIEWABLE_CLASS (parent_class)->get_preview (viewable,
|
||||
width, height);
|
||||
}
|
||||
|
||||
static GimpItem *
|
||||
gimp_text_layer_duplicate (GimpItem *item,
|
||||
GType new_type,
|
||||
|
@ -227,12 +215,17 @@ gimp_text_layer_duplicate (GimpItem *item,
|
|||
text_layer = GIMP_TEXT_LAYER (item);
|
||||
new_text_layer = GIMP_TEXT_LAYER (new_item);
|
||||
|
||||
new_text_layer->text = gimp_config_duplicate (GIMP_CONFIG (text_layer->text));
|
||||
new_text_layer->text_parasite = text_layer->text_parasite;
|
||||
if (text_layer->text)
|
||||
{
|
||||
new_text_layer->text =
|
||||
gimp_config_duplicate (GIMP_CONFIG (text_layer->text));
|
||||
|
||||
g_signal_connect_object (new_text_layer->text, "notify",
|
||||
G_CALLBACK (gimp_text_layer_text_notify),
|
||||
new_text_layer, G_CONNECT_SWAPPED);
|
||||
g_signal_connect_object (new_text_layer->text, "notify",
|
||||
G_CALLBACK (gimp_text_layer_text_notify),
|
||||
new_text_layer, G_CONNECT_SWAPPED);
|
||||
}
|
||||
|
||||
new_text_layer->text_parasite = text_layer->text_parasite;
|
||||
|
||||
return new_item;
|
||||
}
|
||||
|
@ -292,13 +285,33 @@ gimp_text_layer_set_text (GimpTextLayer *layer,
|
|||
GimpText *text)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_TEXT_LAYER (layer));
|
||||
g_return_if_fail (GIMP_IS_TEXT (text));
|
||||
g_return_if_fail (layer->text == NULL);
|
||||
g_return_if_fail (text == NULL || GIMP_IS_TEXT (text));
|
||||
|
||||
layer->text = g_object_ref (text);
|
||||
g_signal_connect_object (text, "notify",
|
||||
G_CALLBACK (gimp_text_layer_text_notify),
|
||||
layer, G_CONNECT_SWAPPED);
|
||||
if (layer->text == text)
|
||||
return;
|
||||
|
||||
if (layer->text)
|
||||
{
|
||||
gimp_text_layer_flush (layer);
|
||||
|
||||
g_signal_handlers_disconnect_by_func (layer->text,
|
||||
G_CALLBACK (gimp_text_layer_text_notify),
|
||||
layer);
|
||||
|
||||
g_object_unref (layer->text);
|
||||
layer->text = NULL;
|
||||
}
|
||||
|
||||
if (text)
|
||||
{
|
||||
layer->text = g_object_ref (text);
|
||||
|
||||
g_signal_connect_object (text, "notify",
|
||||
G_CALLBACK (gimp_text_layer_text_notify),
|
||||
layer, G_CONNECT_SWAPPED);
|
||||
}
|
||||
|
||||
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (layer));
|
||||
}
|
||||
|
||||
GimpText *
|
||||
|
@ -309,12 +322,42 @@ gimp_text_layer_get_text (GimpTextLayer *layer)
|
|||
return layer->text;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_text_layer_discard:
|
||||
* @layer: a #GimpTextLayer
|
||||
*
|
||||
* Discards the text information. This makes @layer behave like a
|
||||
* normal layer.
|
||||
*/
|
||||
void
|
||||
gimp_text_layer_render (GimpTextLayer *layer)
|
||||
gimp_text_layer_discard (GimpTextLayer *layer)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_TEXT_LAYER (layer));
|
||||
|
||||
gimp_text_layer_render_now (layer);
|
||||
if (! layer->text)
|
||||
return;
|
||||
|
||||
gimp_image_undo_push_text_layer (gimp_item_get_image (GIMP_ITEM (layer)),
|
||||
_("Discard Text Information"),
|
||||
layer);
|
||||
|
||||
gimp_text_layer_set_text (layer, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_text_layer_flush:
|
||||
* @layer: a #GimpTextLayer
|
||||
*
|
||||
* Flushes pending changes to the text layer that would otherwise be
|
||||
* performed in an idle handler.
|
||||
*/
|
||||
void
|
||||
gimp_text_layer_flush (GimpTextLayer *layer)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_TEXT_LAYER (layer));
|
||||
|
||||
if (layer->idle_render_id)
|
||||
gimp_text_layer_render_now (layer);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -365,6 +408,9 @@ gimp_text_layer_render_now (GimpTextLayer *layer)
|
|||
layer->idle_render_id = 0;
|
||||
}
|
||||
|
||||
if (! layer->text)
|
||||
return FALSE;
|
||||
|
||||
drawable = GIMP_DRAWABLE (layer);
|
||||
item = GIMP_ITEM (layer);
|
||||
image = gimp_item_get_image (item);
|
||||
|
|
|
@ -62,7 +62,8 @@ GimpLayer * gimp_text_layer_new (GimpImage *image,
|
|||
GimpText * gimp_text_layer_get_text (GimpTextLayer *layer);
|
||||
void gimp_text_layer_set_text (GimpTextLayer *layer,
|
||||
GimpText *text);
|
||||
void gimp_text_layer_render (GimpTextLayer *layer);
|
||||
void gimp_text_layer_discard (GimpTextLayer *layer);
|
||||
void gimp_text_layer_flush (GimpTextLayer *layer);
|
||||
|
||||
|
||||
#endif /* __GIMP_TEXT_LAYER_H__ */
|
||||
|
|
|
@ -128,6 +128,7 @@
|
|||
#define GIMP_HELP_LAYER_ANCHOR "gimp-layer-anchor"
|
||||
#define GIMP_HELP_LAYER_MERGE_DOWN "gimp-layer-merge-down"
|
||||
#define GIMP_HELP_LAYER_DELETE "gimp-layer-delete"
|
||||
#define GIMP_HELP_LAYER_TEXT_DISCARD "gimp-layer-text-discard"
|
||||
#define GIMP_HELP_LAYER_PREVIOUS "gimp-layer-previous"
|
||||
#define GIMP_HELP_LAYER_NEXT "gimp-layer-next"
|
||||
#define GIMP_HELP_LAYER_TOP "gimp-layer-top"
|
||||
|
|
|
@ -28,8 +28,8 @@
|
|||
#include "core/gimpbrush.h"
|
||||
#include "core/gimpdrawable.h"
|
||||
#include "core/gimpgradient.h"
|
||||
#include "core/gimplayer.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "text/gimptextlayer.h"
|
||||
#include "vectors/gimpvectors.h"
|
||||
|
||||
#include "gimppreviewrendererbrush.h"
|
||||
|
|
|
@ -91,7 +91,8 @@ gimp_preview_renderer_layer_render (GimpPreviewRenderer *renderer,
|
|||
{
|
||||
stock_id = GIMP_STOCK_FLOATING_SELECTION;
|
||||
}
|
||||
else if (GIMP_IS_TEXT_LAYER (renderer->viewable))
|
||||
else if (GIMP_IS_TEXT_LAYER (renderer->viewable) &&
|
||||
GIMP_TEXT_LAYER (renderer->viewable)->text)
|
||||
{
|
||||
stock_id = gimp_viewable_get_stock_id (renderer->viewable);
|
||||
}
|
||||
|
|
|
@ -28,8 +28,8 @@
|
|||
#include "core/gimpbrush.h"
|
||||
#include "core/gimpdrawable.h"
|
||||
#include "core/gimpgradient.h"
|
||||
#include "core/gimplayer.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "text/gimptextlayer.h"
|
||||
#include "vectors/gimpvectors.h"
|
||||
|
||||
#include "gimppreviewrendererbrush.h"
|
||||
|
|
|
@ -91,7 +91,8 @@ gimp_preview_renderer_layer_render (GimpPreviewRenderer *renderer,
|
|||
{
|
||||
stock_id = GIMP_STOCK_FLOATING_SELECTION;
|
||||
}
|
||||
else if (GIMP_IS_TEXT_LAYER (renderer->viewable))
|
||||
else if (GIMP_IS_TEXT_LAYER (renderer->viewable) &&
|
||||
GIMP_TEXT_LAYER (renderer->viewable)->text)
|
||||
{
|
||||
stock_id = gimp_viewable_get_stock_id (renderer->viewable);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue