Commit cea01088 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

added new signal "enabled_changed"...

2003-11-23  Michael Natterer  <mitch@gimp.org>

	* libgimpwidgets/gimpcolordisplay.[ch]: added new signal
	"enabled_changed"...

	* libgimpwidgets/gimpcolordisplaystack.c: ...which enables optimizing
	away "changed" signals of disabled filters.

	* app/widgets/gimpcolordisplayeditor.c: connect to "enabled_changed"
	instead of "changed" to update the toggle column.
parent 7acf8acc
2003-11-23 Michael Natterer <mitch@convergence.de>
2003-11-23 Michael Natterer <mitch@gimp.org>
* libgimpwidgets/gimpcolordisplay.[ch]: added new signal
"enabled_changed"...
* libgimpwidgets/gimpcolordisplaystack.c: ...which enables optimizing
away "changed" signals of disabled filters.
* app/widgets/gimpcolordisplayeditor.c: connect to "enabled_changed"
instead of "changed" to update the toggle column.
2003-11-23 Michael Natterer <mitch@gimp.org>
* libgimpwidgets/gimpcolordisplay.c (gimp_color_display_clone):
also clone the "enabled" property.
......@@ -85,7 +85,7 @@ static void gimp_color_display_editor_reordered (GimpColorDisplayStack *
gint position,
GimpColorDisplayEditor *editor);
static void gimp_color_display_editor_changed (GimpColorDisplay *display,
static void gimp_color_display_editor_enabled (GimpColorDisplay *display,
GimpColorDisplayEditor *editor);
static void gimp_color_display_editor_enable_toggled (GtkCellRendererToggle *toggle,
const gchar *path,
......@@ -399,8 +399,8 @@ gimp_color_display_editor_new (GimpColorDisplayStack *stack)
DEST_COLUMN_FILTER, display,
-1);
g_signal_connect_object (display, "changed",
G_CALLBACK (gimp_color_display_editor_changed),
g_signal_connect_object (display, "enabled_changed",
G_CALLBACK (gimp_color_display_editor_enabled),
G_OBJECT (editor), 0);
}
......@@ -590,8 +590,8 @@ gimp_color_display_editor_added (GimpColorDisplayStack *stack,
DEST_COLUMN_FILTER, display,
-1);
g_signal_connect_object (display, "changed",
G_CALLBACK (gimp_color_display_editor_changed),
g_signal_connect_object (display, "enabled_changed",
G_CALLBACK (gimp_color_display_editor_enabled),
G_OBJECT (editor), 0);
gimp_color_display_editor_update_buttons (editor);
......@@ -622,7 +622,7 @@ gimp_color_display_editor_removed (GimpColorDisplayStack *stack,
if (display == display2)
{
g_signal_handlers_disconnect_by_func (display,
gimp_color_display_editor_changed,
gimp_color_display_editor_enabled,
editor);
gtk_list_store_remove (editor->dest, &iter);
......@@ -699,7 +699,7 @@ gimp_color_display_editor_reordered (GimpColorDisplayStack *stack,
}
static void
gimp_color_display_editor_changed (GimpColorDisplay *display,
gimp_color_display_editor_enabled (GimpColorDisplay *display,
GimpColorDisplayEditor *editor)
{
GtkTreeIter iter;
......@@ -712,21 +712,22 @@ gimp_color_display_editor_changed (GimpColorDisplay *display,
&iter))
{
GimpColorDisplay *display2;
gboolean enabled;
gtk_tree_model_get (GTK_TREE_MODEL (editor->dest), &iter,
DEST_COLUMN_FILTER, &display2,
DEST_COLUMN_ENABLED, &enabled,
-1);
g_object_unref (display2);
if (display == display2)
{
if (enabled != gimp_color_display_get_enabled (display))
gtk_list_store_set (editor->dest, &iter,
DEST_COLUMN_ENABLED, ! enabled,
-1);
gboolean enabled;
enabled = gimp_color_display_get_enabled (display);
gtk_list_store_set (editor->dest, &iter,
DEST_COLUMN_ENABLED, enabled,
-1);
break;
}
......
......@@ -33,6 +33,7 @@
enum
{
CHANGED,
ENABLED_CHANGED,
LAST_SIGNAL
};
......@@ -88,6 +89,15 @@ gimp_color_display_class_init (GimpColorDisplayClass *klass)
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
display_signals[ENABLED_CHANGED] =
g_signal_new ("enabled_changed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpColorDisplayClass, enabled_changed),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
klass->name = "Unnamed";
klass->help_id = NULL;
......@@ -139,28 +149,6 @@ gimp_color_display_clone (GimpColorDisplay *display)
return NULL;
}
void
gimp_color_display_set_enabled (GimpColorDisplay *display,
gboolean enabled)
{
g_return_if_fail (GIMP_IS_COLOR_DISPLAY (display));
if (enabled != display->enabled)
{
display->enabled = enabled ? TRUE : FALSE;
gimp_color_display_changed (display);
}
}
gboolean
gimp_color_display_get_enabled (GimpColorDisplay *display)
{
g_return_val_if_fail (GIMP_IS_COLOR_DISPLAY (display), FALSE);
return display->enabled;
}
void
gimp_color_display_convert (GimpColorDisplay *display,
guchar *buf,
......@@ -226,3 +214,34 @@ gimp_color_display_changed (GimpColorDisplay *display)
g_signal_emit (display, display_signals[CHANGED], 0);
}
void
gimp_color_display_enabled_changed (GimpColorDisplay *display)
{
g_return_if_fail (GIMP_IS_COLOR_DISPLAY (display));
g_signal_emit (display, display_signals[ENABLED_CHANGED], 0);
}
void
gimp_color_display_set_enabled (GimpColorDisplay *display,
gboolean enabled)
{
g_return_if_fail (GIMP_IS_COLOR_DISPLAY (display));
if (enabled != display->enabled)
{
display->enabled = enabled ? TRUE : FALSE;
gimp_color_display_enabled_changed (display);
}
}
gboolean
gimp_color_display_get_enabled (GimpColorDisplay *display)
{
g_return_val_if_fail (GIMP_IS_COLOR_DISPLAY (display), FALSE);
return display->enabled;
}
......@@ -64,6 +64,7 @@ struct _GimpColorDisplayClass
/* signals */
void (* changed) (GimpColorDisplay *display);
void (* enabled_changed) (GimpColorDisplay *display);
};
......@@ -71,10 +72,6 @@ GType gimp_color_display_get_type (void) G_GNUC_CONST;
GimpColorDisplay * gimp_color_display_new (GType display_type);
GimpColorDisplay * gimp_color_display_clone (GimpColorDisplay *display);
void gimp_color_display_set_enabled (GimpColorDisplay *display,
gboolean enabled);
gboolean gimp_color_display_get_enabled (GimpColorDisplay *display);
void gimp_color_display_convert (GimpColorDisplay *display,
guchar *buf,
gint width,
......@@ -88,6 +85,11 @@ GtkWidget * gimp_color_display_configure (GimpColorDisplay *display);
void gimp_color_display_configure_reset (GimpColorDisplay *display);
void gimp_color_display_changed (GimpColorDisplay *display);
void gimp_color_display_enabled_changed (GimpColorDisplay *display);
void gimp_color_display_set_enabled (GimpColorDisplay *display,
gboolean enabled);
gboolean gimp_color_display_get_enabled (GimpColorDisplay *display);
G_END_DECLS
......
......@@ -45,7 +45,13 @@ enum
static void gimp_color_display_stack_class_init (GimpColorDisplayStackClass *klass);
static void gimp_color_display_stack_init (GimpColorDisplayStack *stack);
static void gimp_color_display_stack_finalize (GObject *object);
static void gimp_color_display_stack_finalize (GObject *object);
static void gimp_color_display_stack_display_changed (GimpColorDisplay *display,
GimpColorDisplayStack *stack);
static void gimp_color_display_stack_display_enabled (GimpColorDisplay *display,
GimpColorDisplayStack *stack);
static GObjectClass *parent_class = NULL;
......@@ -211,9 +217,11 @@ gimp_color_display_stack_add (GimpColorDisplayStack *stack,
stack->filters = g_list_append (stack->filters, g_object_ref (display));
g_signal_connect_object (display, "changed",
G_CALLBACK (gimp_color_display_stack_changed),
G_OBJECT (stack),
G_CONNECT_SWAPPED);
G_CALLBACK (gimp_color_display_stack_display_changed),
G_OBJECT (stack), 0);
g_signal_connect_object (display, "enabled_changed",
G_CALLBACK (gimp_color_display_stack_display_enabled),
G_OBJECT (stack), 0);
g_signal_emit (stack, stack_signals[ADDED], 0,
display, g_list_length (stack->filters) - 1);
......@@ -230,7 +238,10 @@ gimp_color_display_stack_remove (GimpColorDisplayStack *stack,
g_return_if_fail (g_list_find (stack->filters, display) != NULL);
g_signal_handlers_disconnect_by_func (display,
gimp_color_display_stack_changed,
gimp_color_display_stack_display_changed,
stack);
g_signal_handlers_disconnect_by_func (display,
gimp_color_display_stack_display_enabled,
stack);
stack->filters = g_list_remove (stack->filters, display);
......@@ -311,3 +322,21 @@ gimp_color_display_stack_convert (GimpColorDisplayStack *stack,
gimp_color_display_convert (display, buf, width, height, bpp, bpl);
}
}
/* private functions */
static void
gimp_color_display_stack_display_changed (GimpColorDisplay *display,
GimpColorDisplayStack *stack)
{
if (display->enabled)
gimp_color_display_stack_changed (stack);
}
static void
gimp_color_display_stack_display_enabled (GimpColorDisplay *display,
GimpColorDisplayStack *stack)
{
gimp_color_display_stack_changed (stack);
}
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