added a GimpAnchorItemFunc and use it if it's set.

2002-03-11  Michael Natterer  <mitch@gimp.org>

	* app/widgets/gimplayerlistview.[ch]: added a GimpAnchorItemFunc
	and use it if it's set.

	* app/widgets/gimpitemlistview.c: removed the floating selection
	special case hack from the remove_item callback.

	* app/gui/layers-commands.[ch]: added layers_remove_layer() and
	layers_anchor_layer(). Fixed sensitive setting of the "Anchor"
	menu item.

	* app/gui/dialogs-constructors.c: use the new functions when
	constructing the layers dialog. Makes deleting and anchoring
	floating selections from the layers dialog work without hacking
	or code duplication.

	* app/widgets/gimpdialogfactory.c: added comments about dialog
	destruction in dispose().
This commit is contained in:
Michael Natterer 2002-03-11 12:58:59 +00:00 committed by Michael Natterer
parent 51dbc47865
commit 3e695dd065
14 changed files with 148 additions and 69 deletions

View File

@ -1,3 +1,23 @@
2002-03-11 Michael Natterer <mitch@gimp.org>
* app/widgets/gimplayerlistview.[ch]: added a GimpAnchorItemFunc
and use it if it's set.
* app/widgets/gimpitemlistview.c: removed the floating selection
special case hack from the remove_item callback.
* app/gui/layers-commands.[ch]: added layers_remove_layer() and
layers_anchor_layer(). Fixed sensitive setting of the "Anchor"
menu item.
* app/gui/dialogs-constructors.c: use the new functions when
constructing the layers dialog. Makes deleting and anchoring
floating selections from the layers dialog work without hacking
or code duplication.
* app/widgets/gimpdialogfactory.c: added comments about dialog
destruction in dispose().
2002-03-10 Michael Natterer <mitch@gimp.org>
* libgimpwidgets/gimpwidgets.h: removed type checking casts from

View File

@ -209,11 +209,7 @@ layers_anchor_cmd_callback (GtkWidget *widget,
GimpLayer *active_layer;
return_if_no_layer (gimage, active_layer);
if (gimp_layer_is_floating_sel (active_layer))
{
floating_sel_anchor (active_layer);
gdisplays_flush ();
}
layers_anchor_layer (active_layer);
}
void
@ -384,6 +380,31 @@ layers_edit_attributes_cmd_callback (GtkWidget *widget,
layers_edit_layer_query (active_layer);
}
void
layers_remove_layer (GimpImage *gimage,
GimpLayer *layer)
{
g_return_if_fail (GIMP_IS_IMAGE (gimage));
g_return_if_fail (GIMP_IS_LAYER (layer));
if (gimp_layer_is_floating_sel (layer))
floating_sel_remove (layer);
else
gimp_image_remove_layer (gimage, layer);
}
void
layers_anchor_layer (GimpLayer *layer)
{
g_return_if_fail (GIMP_IS_LAYER (layer));
if (gimp_layer_is_floating_sel (layer))
{
floating_sel_anchor (layer);
gdisplays_flush ();
}
}
/********************************/
/* The new layer query dialog */
@ -1140,30 +1161,27 @@ layers_menu_update (GtkItemFactory *factory,
SET_SENSITIVE ("/New Layer...", gimage);
SET_SENSITIVE ("/Raise Layer", !fs && !ac && gimage && lp && alpha && prev);
SET_SENSITIVE ("/Layer to Top", !fs && !ac && gimage && lp && alpha && prev);
SET_SENSITIVE ("/Raise Layer", !fs && !ac && gimage && lp && alpha && prev);
SET_SENSITIVE ("/Layer to Top", !fs && !ac && gimage && lp && alpha && prev);
SET_SENSITIVE ("/Lower Layer",
!fs && !ac && gimage && lp && next && next_alpha);
SET_SENSITIVE ("/Layer to Bottom",
!fs && !ac && gimage && lp && next && next_alpha);
SET_SENSITIVE ("/Lower Layer", !fs && !ac && gimage && lp && next && next_alpha);
SET_SENSITIVE ("/Layer to Bottom", !fs && !ac && gimage && lp && next && next_alpha);
SET_SENSITIVE ("/Duplicate Layer", !fs && !ac && gimage && lp);
SET_SENSITIVE ("/Anchor Layer", !fs && !ac && gimage && lp);
SET_SENSITIVE ("/Merge Down", !fs && !ac && gimage && lp && next);
SET_SENSITIVE ("/Delete Layer", !ac && gimage && lp);
SET_SENSITIVE ("/Anchor Layer", fs && !ac && gimage && lp);
SET_SENSITIVE ("/Merge Down", !fs && !ac && gimage && lp && next);
SET_SENSITIVE ("/Delete Layer", !ac && gimage && lp);
SET_SENSITIVE ("/Layer Boundary Size...", !ac && gimage && lp);
SET_SENSITIVE ("/Layer to Imagesize", !ac && gimage && lp);
SET_SENSITIVE ("/Scale Layer...", !ac && gimage && lp);
SET_SENSITIVE ("/Layer to Imagesize", !ac && gimage && lp);
SET_SENSITIVE ("/Scale Layer...", !ac && gimage && lp);
SET_SENSITIVE ("/Add Layer Mask...",
!fs && !ac && gimage && !lm && lp && alpha && !indexed);
SET_SENSITIVE ("/Apply Layer Mask", !fs && !ac && gimage && lm && lp);
SET_SENSITIVE ("/Add Layer Mask...", !fs && !ac && gimage && !lm && lp && alpha && !indexed);
SET_SENSITIVE ("/Apply Layer Mask", !fs && !ac && gimage && lm && lp);
SET_SENSITIVE ("/Delete Layer Mask", !fs && !ac && gimage && lm && lp);
SET_SENSITIVE ("/Mask to Selection", !fs && !ac && gimage && lm && lp);
SET_SENSITIVE ("/Add Alpha Channel", !fs && !alpha);
SET_SENSITIVE ("/Add Alpha Channel", !fs && !alpha);
SET_SENSITIVE ("/Alpha to Selection", !fs && !ac && gimage && lp && alpha);
SET_SENSITIVE ("/Edit Layer Attributes...", !fs && !ac && gimage && lp);

View File

@ -70,8 +70,11 @@ void layers_edit_attributes_cmd_callback (GtkWidget *widet,
void layers_menu_update (GtkItemFactory *factory,
gpointer data);
void layers_remove_layer (GimpImage *gimage,
GimpLayer *layer);
void layers_anchor_layer (GimpLayer *layer);
void layers_new_layer_query (GimpImage *gimage,
GimpLayer *tamplate);
GimpLayer *template);
void layers_edit_layer_query (GimpLayer *layer);

View File

@ -52,6 +52,7 @@
#include "widgets/gimpdockbook.h"
#include "widgets/gimpdocumentview.h"
#include "widgets/gimpgradienteditor.h"
#include "widgets/gimplayerlistview.h"
#include "widgets/gimplistitem.h"
#include "widgets/gimppaletteeditor.h"
#include "widgets/gimppreview.h"
@ -636,9 +637,10 @@ dialogs_layer_list_view_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size)
{
GimpImage *gimage;
GtkWidget *view;
GtkWidget *dockable;
GimpImage *gimage;
GimpLayerListView *layer_view;
GtkWidget *view;
GtkWidget *dockable;
gimage = gimp_context_get_image (context);
@ -652,7 +654,7 @@ dialogs_layer_list_view_new (GimpDialogFactory *factory,
(GimpSetItemFunc) gimp_image_set_active_layer,
(GimpReorderItemFunc) gimp_image_position_layer,
(GimpAddItemFunc) gimp_image_add_layer,
(GimpRemoveItemFunc) gimp_image_remove_layer,
(GimpRemoveItemFunc) layers_remove_layer,
(GimpCopyItemFunc) gimp_layer_copy,
(GimpConvertItemFunc) gimp_layer_new_from_drawable,
(GimpNewItemFunc) layers_new_layer_query,
@ -660,6 +662,10 @@ dialogs_layer_list_view_new (GimpDialogFactory *factory,
(GimpActivateItemFunc) layers_edit_layer_query,
gimp_item_factory_from_path ("<Layers>"));
layer_view = GIMP_LAYER_LIST_VIEW (view);
layer_view->anchor_item_func = layers_anchor_layer;
dockable = dialogs_dockable_new (view,
"Layer List", "Layers",
NULL,

View File

@ -52,6 +52,7 @@
#include "widgets/gimpdockbook.h"
#include "widgets/gimpdocumentview.h"
#include "widgets/gimpgradienteditor.h"
#include "widgets/gimplayerlistview.h"
#include "widgets/gimplistitem.h"
#include "widgets/gimppaletteeditor.h"
#include "widgets/gimppreview.h"
@ -636,9 +637,10 @@ dialogs_layer_list_view_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size)
{
GimpImage *gimage;
GtkWidget *view;
GtkWidget *dockable;
GimpImage *gimage;
GimpLayerListView *layer_view;
GtkWidget *view;
GtkWidget *dockable;
gimage = gimp_context_get_image (context);
@ -652,7 +654,7 @@ dialogs_layer_list_view_new (GimpDialogFactory *factory,
(GimpSetItemFunc) gimp_image_set_active_layer,
(GimpReorderItemFunc) gimp_image_position_layer,
(GimpAddItemFunc) gimp_image_add_layer,
(GimpRemoveItemFunc) gimp_image_remove_layer,
(GimpRemoveItemFunc) layers_remove_layer,
(GimpCopyItemFunc) gimp_layer_copy,
(GimpConvertItemFunc) gimp_layer_new_from_drawable,
(GimpNewItemFunc) layers_new_layer_query,
@ -660,6 +662,10 @@ dialogs_layer_list_view_new (GimpDialogFactory *factory,
(GimpActivateItemFunc) layers_edit_layer_query,
gimp_item_factory_from_path ("<Layers>"));
layer_view = GIMP_LAYER_LIST_VIEW (view);
layer_view->anchor_item_func = layers_anchor_layer;
dockable = dialogs_dockable_new (view,
"Layer List", "Layers",
NULL,

View File

@ -209,11 +209,7 @@ layers_anchor_cmd_callback (GtkWidget *widget,
GimpLayer *active_layer;
return_if_no_layer (gimage, active_layer);
if (gimp_layer_is_floating_sel (active_layer))
{
floating_sel_anchor (active_layer);
gdisplays_flush ();
}
layers_anchor_layer (active_layer);
}
void
@ -384,6 +380,31 @@ layers_edit_attributes_cmd_callback (GtkWidget *widget,
layers_edit_layer_query (active_layer);
}
void
layers_remove_layer (GimpImage *gimage,
GimpLayer *layer)
{
g_return_if_fail (GIMP_IS_IMAGE (gimage));
g_return_if_fail (GIMP_IS_LAYER (layer));
if (gimp_layer_is_floating_sel (layer))
floating_sel_remove (layer);
else
gimp_image_remove_layer (gimage, layer);
}
void
layers_anchor_layer (GimpLayer *layer)
{
g_return_if_fail (GIMP_IS_LAYER (layer));
if (gimp_layer_is_floating_sel (layer))
{
floating_sel_anchor (layer);
gdisplays_flush ();
}
}
/********************************/
/* The new layer query dialog */
@ -1140,30 +1161,27 @@ layers_menu_update (GtkItemFactory *factory,
SET_SENSITIVE ("/New Layer...", gimage);
SET_SENSITIVE ("/Raise Layer", !fs && !ac && gimage && lp && alpha && prev);
SET_SENSITIVE ("/Layer to Top", !fs && !ac && gimage && lp && alpha && prev);
SET_SENSITIVE ("/Raise Layer", !fs && !ac && gimage && lp && alpha && prev);
SET_SENSITIVE ("/Layer to Top", !fs && !ac && gimage && lp && alpha && prev);
SET_SENSITIVE ("/Lower Layer",
!fs && !ac && gimage && lp && next && next_alpha);
SET_SENSITIVE ("/Layer to Bottom",
!fs && !ac && gimage && lp && next && next_alpha);
SET_SENSITIVE ("/Lower Layer", !fs && !ac && gimage && lp && next && next_alpha);
SET_SENSITIVE ("/Layer to Bottom", !fs && !ac && gimage && lp && next && next_alpha);
SET_SENSITIVE ("/Duplicate Layer", !fs && !ac && gimage && lp);
SET_SENSITIVE ("/Anchor Layer", !fs && !ac && gimage && lp);
SET_SENSITIVE ("/Merge Down", !fs && !ac && gimage && lp && next);
SET_SENSITIVE ("/Delete Layer", !ac && gimage && lp);
SET_SENSITIVE ("/Anchor Layer", fs && !ac && gimage && lp);
SET_SENSITIVE ("/Merge Down", !fs && !ac && gimage && lp && next);
SET_SENSITIVE ("/Delete Layer", !ac && gimage && lp);
SET_SENSITIVE ("/Layer Boundary Size...", !ac && gimage && lp);
SET_SENSITIVE ("/Layer to Imagesize", !ac && gimage && lp);
SET_SENSITIVE ("/Scale Layer...", !ac && gimage && lp);
SET_SENSITIVE ("/Layer to Imagesize", !ac && gimage && lp);
SET_SENSITIVE ("/Scale Layer...", !ac && gimage && lp);
SET_SENSITIVE ("/Add Layer Mask...",
!fs && !ac && gimage && !lm && lp && alpha && !indexed);
SET_SENSITIVE ("/Apply Layer Mask", !fs && !ac && gimage && lm && lp);
SET_SENSITIVE ("/Add Layer Mask...", !fs && !ac && gimage && !lm && lp && alpha && !indexed);
SET_SENSITIVE ("/Apply Layer Mask", !fs && !ac && gimage && lm && lp);
SET_SENSITIVE ("/Delete Layer Mask", !fs && !ac && gimage && lm && lp);
SET_SENSITIVE ("/Mask to Selection", !fs && !ac && gimage && lm && lp);
SET_SENSITIVE ("/Add Alpha Channel", !fs && !alpha);
SET_SENSITIVE ("/Add Alpha Channel", !fs && !alpha);
SET_SENSITIVE ("/Alpha to Selection", !fs && !ac && gimage && lp && alpha);
SET_SENSITIVE ("/Edit Layer Attributes...", !fs && !ac && gimage && lp);

View File

@ -70,8 +70,11 @@ void layers_edit_attributes_cmd_callback (GtkWidget *widet,
void layers_menu_update (GtkItemFactory *factory,
gpointer data);
void layers_remove_layer (GimpImage *gimage,
GimpLayer *layer);
void layers_anchor_layer (GimpLayer *layer);
void layers_new_layer_query (GimpImage *gimage,
GimpLayer *tamplate);
GimpLayer *template);
void layers_edit_layer_query (GimpLayer *layer);

View File

@ -156,6 +156,10 @@ gimp_dialog_factory_dispose (GObject *object)
factory = GIMP_DIALOG_FACTORY (object);
/* start iterating from the beginning each time we destroyed a
* toplevel because destroying a dock may cause lots of items
* to be removed from factory->open_dialogs
*/
while (factory->open_dialogs)
{
for (list = factory->open_dialogs; list; list = g_list_next (list))
@ -167,9 +171,12 @@ gimp_dialog_factory_dispose (GObject *object)
}
}
/* the list being non-empty without any toplevel is an error,
* so eek and chain up
*/
if (! list)
{
g_warning ("%s: stale entries in factory->open_dialogs",
g_warning ("%s: stale non-toplevel entries in factory->open_dialogs",
G_GNUC_FUNCTION);
break;
}

View File

@ -37,7 +37,6 @@
#include "core/gimpcontainer.h"
#include "core/gimpimage.h"
#include "core/gimplayer.h"
#include "core/gimplayer-floating-sel.h"
#include "core/gimpmarshal.h"
#include "vectors/gimpvectors.h"
@ -701,12 +700,7 @@ gimp_item_list_view_delete_clicked (GtkWidget *widget,
viewable = view->get_item_func (view->gimage);
/* EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEK */
if (GIMP_IS_LAYER (viewable) &&
gimp_layer_is_floating_sel (GIMP_LAYER (viewable)))
floating_sel_remove (GIMP_LAYER (viewable));
else
view->remove_item_func (view->gimage, viewable);
view->remove_item_func (view->gimage, viewable);
gdisplays_flush ();
}

View File

@ -37,7 +37,6 @@
#include "core/gimpcontainer.h"
#include "core/gimpimage.h"
#include "core/gimplayer.h"
#include "core/gimplayer-floating-sel.h"
#include "core/gimpmarshal.h"
#include "vectors/gimpvectors.h"
@ -701,12 +700,7 @@ gimp_item_list_view_delete_clicked (GtkWidget *widget,
viewable = view->get_item_func (view->gimage);
/* EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEK */
if (GIMP_IS_LAYER (viewable) &&
gimp_layer_is_floating_sel (GIMP_LAYER (viewable)))
floating_sel_remove (GIMP_LAYER (viewable));
else
view->remove_item_func (view->gimage, viewable);
view->remove_item_func (view->gimage, viewable);
gdisplays_flush ();
}

View File

@ -340,9 +340,9 @@ gimp_layer_list_view_anchor_clicked (GtkWidget *widget,
layer = (GimpLayer *) item_view->get_item_func (item_view->gimage);
if (GIMP_IS_LAYER (layer))
if (view->anchor_item_func)
{
g_print ("anchor \"%s\"\n", GIMP_OBJECT (layer)->name);
view->anchor_item_func (layer);
}
}

View File

@ -26,6 +26,9 @@
#include "gimpdrawablelistview.h"
typedef void (* GimpAnchorItemFunc) (GimpLayer *layer);
#define GIMP_TYPE_LAYER_LIST_VIEW (gimp_layer_list_view_get_type ())
#define GIMP_LAYER_LIST_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_LAYER_LIST_VIEW, GimpLayerListView))
#define GIMP_LAYER_LIST_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_LAYER_LIST_VIEW, GimpLayerListViewClass))
@ -40,6 +43,8 @@ struct _GimpLayerListView
{
GimpDrawableListView parent_instance;
GimpAnchorItemFunc anchor_item_func;
GtkWidget *options_box;
GtkWidget *paint_mode_menu;

View File

@ -340,9 +340,9 @@ gimp_layer_list_view_anchor_clicked (GtkWidget *widget,
layer = (GimpLayer *) item_view->get_item_func (item_view->gimage);
if (GIMP_IS_LAYER (layer))
if (view->anchor_item_func)
{
g_print ("anchor \"%s\"\n", GIMP_OBJECT (layer)->name);
view->anchor_item_func (layer);
}
}

View File

@ -26,6 +26,9 @@
#include "gimpdrawablelistview.h"
typedef void (* GimpAnchorItemFunc) (GimpLayer *layer);
#define GIMP_TYPE_LAYER_LIST_VIEW (gimp_layer_list_view_get_type ())
#define GIMP_LAYER_LIST_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_LAYER_LIST_VIEW, GimpLayerListView))
#define GIMP_LAYER_LIST_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_LAYER_LIST_VIEW, GimpLayerListViewClass))
@ -40,6 +43,8 @@ struct _GimpLayerListView
{
GimpDrawableListView parent_instance;
GimpAnchorItemFunc anchor_item_func;
GtkWidget *options_box;
GtkWidget *paint_mode_menu;