Commit 8d9580fd authored by Ell's avatar Ell
Browse files

app: update layers-dialog floating-sel attrs/highlight when image changes

Move the button-highlight update to its own function, and call it
when the active image changes, as well as when its floating
selection changes.

Call the floating-selection-changed signal handler when the active
image changes, so that we correctly update its row's attributes.
parent b1266b2c
......@@ -151,6 +151,7 @@ static void gimp_layer_tree_view_update_options (GimpLayerTree
GimpLayer *layer);
static void gimp_layer_tree_view_update_menu (GimpLayerTreeView *view,
GimpLayer *layer);
static void gimp_layer_tree_view_update_highlight (GimpLayerTreeView *view);
static void gimp_layer_tree_view_mask_update (GimpLayerTreeView *view,
GtkTreeIter *iter,
GimpLayer *layer);
......@@ -843,18 +844,33 @@ static void
gimp_layer_tree_view_set_image (GimpItemTreeView *view,
GimpImage *image)
{
GimpLayerTreeView *layer_view = GIMP_LAYER_TREE_VIEW (view);
if (gimp_item_tree_view_get_image (view))
g_signal_handlers_disconnect_by_func (gimp_item_tree_view_get_image (view),
gimp_layer_tree_view_floating_selection_changed,
view);
{
g_signal_handlers_disconnect_by_func (gimp_item_tree_view_get_image (view),
gimp_layer_tree_view_floating_selection_changed,
view);
}
GIMP_ITEM_TREE_VIEW_CLASS (parent_class)->set_image (view, image);
if (gimp_item_tree_view_get_image (view))
g_signal_connect (gimp_item_tree_view_get_image (view),
"floating-selection-changed",
G_CALLBACK (gimp_layer_tree_view_floating_selection_changed),
view);
{
g_signal_connect (gimp_item_tree_view_get_image (view),
"floating-selection-changed",
G_CALLBACK (gimp_layer_tree_view_floating_selection_changed),
view);
/* call gimp_layer_tree_view_floating_selection_changed() now, to update
* the floating selection's row attributes.
*/
gimp_layer_tree_view_floating_selection_changed (
gimp_item_tree_view_get_image (view),
layer_view);
}
gimp_layer_tree_view_update_highlight (layer_view);
}
static GimpItem *
......@@ -888,7 +904,6 @@ static void
gimp_layer_tree_view_floating_selection_changed (GimpImage *image,
GimpLayerTreeView *layer_view)
{
GimpItemTreeView *item_view = GIMP_ITEM_TREE_VIEW (layer_view);
GimpContainerTreeView *tree_view = GIMP_CONTAINER_TREE_VIEW (layer_view);
GimpContainerView *view = GIMP_CONTAINER_VIEW (layer_view);
GimpLayer *floating_sel;
......@@ -930,16 +945,7 @@ gimp_layer_tree_view_floating_selection_changed (GimpImage *image,
g_list_free (all_layers);
}
gimp_highlightable_button_set_highlight (
GIMP_HIGHLIGHTABLE_BUTTON (gimp_item_tree_view_get_new_button (item_view)),
floating_sel != NULL &&
! GIMP_IS_CHANNEL (gimp_layer_get_floating_sel_drawable (floating_sel)));
gimp_highlightable_button_set_highlight (
GIMP_HIGHLIGHTABLE_BUTTON (gimp_item_tree_view_get_delete_button (item_view)),
floating_sel != NULL);
gimp_highlightable_button_set_highlight (
GIMP_HIGHLIGHTABLE_BUTTON (layer_view->priv->anchor_button),
floating_sel != NULL);
gimp_layer_tree_view_update_highlight (layer_view);
}
......@@ -1182,6 +1188,30 @@ gimp_layer_tree_view_update_menu (GimpLayerTreeView *layer_view,
gimp_layer_get_edit_mask (layer));
}
static void
gimp_layer_tree_view_update_highlight (GimpLayerTreeView *layer_view)
{
GimpItemTreeView *item_view = GIMP_ITEM_TREE_VIEW (layer_view);
GimpImage *image = gimp_item_tree_view_get_image (item_view);
GimpLayer *floating_sel = NULL;
if (image)
floating_sel = gimp_image_get_floating_selection (image);
gimp_highlightable_button_set_highlight (
GIMP_HIGHLIGHTABLE_BUTTON (gimp_item_tree_view_get_new_button (item_view)),
floating_sel != NULL &&
! GIMP_IS_CHANNEL (gimp_layer_get_floating_sel_drawable (floating_sel)));
gimp_highlightable_button_set_highlight (
GIMP_HIGHLIGHTABLE_BUTTON (gimp_item_tree_view_get_delete_button (item_view)),
floating_sel != NULL);
gimp_highlightable_button_set_highlight (
GIMP_HIGHLIGHTABLE_BUTTON (layer_view->priv->anchor_button),
floating_sel != NULL);
}
/* Layer Mask callbacks */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment