Commit 31bf3c90 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

added GimpDrawable::alpha_changed() signal.

2003-05-21  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpdrawable.[ch]: added GimpDrawable::alpha_changed()
	signal.

	* app/core/gimpimage-undo-push.c
	* app/core/gimplayer.c: emit it when alpha is removed from or
	added to a layer.

	* app/widgets/gimpcontainertreeview.[ch]: added a
	"name_attributes" column to the list store which provides a
	PangoAttrList for the name column.

	* app/widgets/gimplayertreeview.[ch]: connect to all layers'
	"alpha_changed" and set the BG layer's name to bold.

	* app/widgets/gimpdrawabletreeview.c: removed redundant assertions.
parent 46033caa
2003-05-21 Michael Natterer <mitch@gimp.org>
* app/core/gimpdrawable.[ch]: added GimpDrawable::alpha_changed()
signal.
* app/core/gimpimage-undo-push.c
* app/core/gimplayer.c: emit it when alpha is removed from or
added to a layer.
* app/widgets/gimpcontainertreeview.[ch]: added a
"name_attributes" column to the list store which provides a
PangoAttrList for the name column.
* app/widgets/gimplayertreeview.[ch]: connect to all layers'
"alpha_changed" and set the BG layer's name to bold.
* app/widgets/gimpdrawabletreeview.c: removed redundant assertions.
2003-05-21 Simon Budig <simon@gimp.org>
* app/core/gimpscanconvert.[ch]: Extended to be able to handle
......@@ -58,6 +58,7 @@
enum
{
VISIBILITY_CHANGED,
ALPHA_CHANGED,
LAST_SIGNAL
};
......@@ -164,6 +165,15 @@ gimp_drawable_class_init (GimpDrawableClass *klass)
gimp_marshal_VOID__VOID,
G_TYPE_NONE, 0);
gimp_drawable_signals[ALPHA_CHANGED] =
g_signal_new ("alpha_changed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpDrawableClass, alpha_changed),
NULL, NULL,
gimp_marshal_VOID__VOID,
G_TYPE_NONE, 0);
object_class->finalize = gimp_drawable_finalize;
gimp_object_class->get_memsize = gimp_drawable_get_memsize;
......@@ -181,6 +191,7 @@ gimp_drawable_class_init (GimpDrawableClass *klass)
item_class->transform = gimp_drawable_transform;
klass->visibility_changed = NULL;
klass->alpha_changed = NULL;
}
static void
......@@ -932,6 +943,14 @@ gimp_drawable_set_visible (GimpDrawable *drawable,
}
}
void
gimp_drawable_alpha_changed (GimpDrawable *drawable)
{
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_signal_emit (drawable, gimp_drawable_signals[ALPHA_CHANGED], 0);
}
guchar *
gimp_drawable_cmap (const GimpDrawable *drawable)
{
......
......@@ -54,6 +54,7 @@ struct _GimpDrawableClass
GimpItemClass parent_class;
void (* visibility_changed) (GimpDrawable *drawable);
void (* alpha_changed) (GimpDrawable *drawable);
};
......@@ -117,6 +118,8 @@ void gimp_drawable_set_visible (GimpDrawable *drawable,
gboolean visible,
gboolean push_undo);
void gimp_drawable_alpha_changed (GimpDrawable *drawable);
guchar * gimp_drawable_cmap (const GimpDrawable *drawable);
guchar * gimp_drawable_get_color_at (GimpDrawable *drawable,
......
......@@ -1632,10 +1632,12 @@ undo_pop_layer_mod (GimpUndo *undo,
}
if (GIMP_IMAGE_TYPE_HAS_ALPHA (GIMP_DRAWABLE (layer)->type) !=
GIMP_IMAGE_TYPE_HAS_ALPHA (lmu->type) &&
undo->gimage->layers->num_children == 1)
GIMP_IMAGE_TYPE_HAS_ALPHA (lmu->type))
{
gimp_image_alpha_changed (undo->gimage);
gimp_drawable_alpha_changed (GIMP_DRAWABLE (layer));
if (undo->gimage->layers->num_children == 1)
gimp_image_alpha_changed (undo->gimage);
}
if (GIMP_ITEM (layer)->width != tile_manager_width (lmu->tiles) ||
......
......@@ -1179,6 +1179,8 @@ gimp_layer_add_alpha (GimpLayer *layer)
GIMP_DRAWABLE (layer)->has_alpha = GIMP_IMAGE_TYPE_HAS_ALPHA (type);
GIMP_DRAWABLE (layer)->preview_valid = FALSE;
gimp_drawable_alpha_changed (GIMP_DRAWABLE (layer));
gimage = gimp_item_get_image (GIMP_ITEM (layer));
if (gimp_container_num_children (gimage->layers) == 1)
......
......@@ -46,6 +46,7 @@ enum
{
COLUMN_RENDERER,
COLUMN_NAME,
COLUMN_NAME_ATTRIBUTES,
NUM_COLUMNS
};
......@@ -156,11 +157,13 @@ gimp_container_tree_view_init (GimpContainerTreeView *tree_view)
tree_view->n_model_columns = NUM_COLUMNS;
tree_view->model_columns[COLUMN_RENDERER] = GIMP_TYPE_PREVIEW_RENDERER;
tree_view->model_columns[COLUMN_NAME] = G_TYPE_STRING;
tree_view->model_columns[COLUMN_RENDERER] = GIMP_TYPE_PREVIEW_RENDERER;
tree_view->model_columns[COLUMN_NAME] = G_TYPE_STRING;
tree_view->model_columns[COLUMN_NAME_ATTRIBUTES] = PANGO_TYPE_ATTR_LIST;
tree_view->model_column_renderer = COLUMN_RENDERER;
tree_view->model_column_name = COLUMN_NAME;
tree_view->model_column_renderer = COLUMN_RENDERER;
tree_view->model_column_name = COLUMN_NAME;
tree_view->model_column_name_attributes = COLUMN_NAME_ATTRIBUTES;
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (view->scrolled_win),
GTK_SHADOW_IN);
......@@ -219,7 +222,8 @@ gimp_container_tree_view_constructor (GType type,
gtk_tree_view_column_set_attributes (tree_view->main_column,
tree_view->name_cell,
"text", COLUMN_NAME,
"text", COLUMN_NAME,
"attributes", COLUMN_NAME_ATTRIBUTES,
NULL);
tree_view->renderer_cells = g_list_prepend (tree_view->renderer_cells,
......
......@@ -46,6 +46,7 @@ struct _GimpContainerTreeView
gint model_column_renderer;
gint model_column_name;
gint model_column_name_attributes;
GtkTreeView *view;
GtkTreeSelection *selection;
......
......@@ -283,9 +283,6 @@ gimp_drawable_tree_view_set_image (GimpItemTreeView *item_view,
{
GimpDrawableTreeView *view;
g_return_if_fail (GIMP_IS_DRAWABLE_TREE_VIEW (item_view));
g_return_if_fail (! gimage || GIMP_IS_IMAGE (gimage));
view = GIMP_DRAWABLE_TREE_VIEW (item_view);
if (item_view->gimage)
......
......@@ -64,13 +64,13 @@ static gpointer gimp_layer_tree_view_insert_item (GimpContainerView *view,
static gboolean gimp_layer_tree_view_select_item (GimpContainerView *view,
GimpViewable *item,
gpointer insert_data);
static void gimp_layer_tree_view_set_preview_size (GimpContainerView *view);
static void gimp_layer_tree_view_set_preview_size (GimpContainerView *view);
static gboolean gimp_layer_tree_view_drop_possible (GimpContainerTreeView *view,
GimpViewable *src_viewable,
GimpViewable *dest_viewable,
GtkTreeViewDropPosition drop_pos,
GdkDragAction *drag_action);
static gboolean gimp_layer_tree_view_drop_possible(GimpContainerTreeView *view,
GimpViewable *src_viewable,
GimpViewable *dest_viewable,
GtkTreeViewDropPosition drop_pos,
GdkDragAction *drag_action);
static void gimp_layer_tree_view_remove_item (GimpImage *gimage,
GimpItem *layer);
......@@ -115,6 +115,12 @@ static void gimp_layer_tree_view_mask_clicked (GimpCellRendererViewable *cel
GdkModifierType state,
GimpLayerTreeView *view);
static void gimp_layer_tree_view_alpha_update (GimpLayerTreeView *view,
GtkTreeIter *iter,
GimpLayer *layer);
static void gimp_layer_tree_view_alpha_changed (GimpLayer *layer,
GimpLayerTreeView *view);
static GimpDrawableTreeViewClass *parent_class = NULL;
......@@ -386,6 +392,8 @@ gimp_layer_tree_view_set_container (GimpContainerView *view,
layer_view->preserve_trans_changed_handler_id);
gimp_container_remove_handler (view->container,
layer_view->mask_changed_handler_id);
gimp_container_remove_handler (view->container,
layer_view->alpha_changed_handler_id);
}
GIMP_CONTAINER_VIEW_CLASS (parent_class)->set_container (view, container);
......@@ -408,6 +416,10 @@ gimp_layer_tree_view_set_container (GimpContainerView *view,
gimp_container_add_handler (view->container, "mask_changed",
G_CALLBACK (gimp_layer_tree_view_mask_changed),
view);
layer_view->alpha_changed_handler_id =
gimp_container_add_handler (view->container, "alpha_changed",
G_CALLBACK (gimp_layer_tree_view_alpha_changed),
view);
}
}
......@@ -429,6 +441,9 @@ gimp_layer_tree_view_insert_item (GimpContainerView *view,
layer = GIMP_LAYER (viewable);
if (! gimp_drawable_has_alpha (GIMP_DRAWABLE (layer)))
gimp_layer_tree_view_alpha_update (layer_view, iter, layer);
gimp_layer_tree_view_mask_update (layer_view, iter, layer);
return iter;
......@@ -1026,3 +1041,50 @@ gimp_layer_tree_view_mask_clicked (GimpCellRendererViewable *cell,
gtk_tree_path_free (path);
}
/* GimpDrawable alpha callbacks */
static void
gimp_layer_tree_view_alpha_update (GimpLayerTreeView *view,
GtkTreeIter *iter,
GimpLayer *layer)
{
GimpContainerTreeView *tree_view;
static PangoAttrList *attrs = NULL;
tree_view = GIMP_CONTAINER_TREE_VIEW (view);
if (! attrs)
{
PangoAttribute *attr;
attrs = pango_attr_list_new ();
attr = pango_attr_weight_new (PANGO_WEIGHT_BOLD);
attr->start_index = 0;
attr->end_index = -1;
pango_attr_list_insert (attrs, attr);
}
gtk_list_store_set (GTK_LIST_STORE (tree_view->model), iter,
tree_view->model_column_name_attributes,
gimp_drawable_has_alpha (GIMP_DRAWABLE (layer)) ?
NULL : attrs,
-1);
}
static void
gimp_layer_tree_view_alpha_changed (GimpLayer *layer,
GimpLayerTreeView *layer_view)
{
GimpContainerView *view;
GtkTreeIter *iter;
view = GIMP_CONTAINER_VIEW (layer_view);
iter = g_hash_table_lookup (view->hash_table, layer);
if (iter)
gimp_layer_tree_view_alpha_update (layer_view, iter, layer);
}
......@@ -56,8 +56,8 @@ struct _GimpLayerTreeView
GQuark mode_changed_handler_id;
GQuark opacity_changed_handler_id;
GQuark preserve_trans_changed_handler_id;
GQuark linked_changed_handler_id;
GQuark mask_changed_handler_id;
GQuark alpha_changed_handler_id;
};
struct _GimpLayerTreeViewClass
......
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