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

added API to enable/disable a filter. A disabled filter has no effect.

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

	* libgimpwidgets/gimpcolordisplay.[ch]: added API to
	enable/disable a filter. A disabled filter has no effect.

	* libgimpmodule/gimpmodule.h: incremented GIMP_MODULE_ABI_VERSION.

	* app/widgets/gimpcolordisplayeditor.c: added a check column to
	the "Active Filters" tree view so the effect of all filters can
	quickly be toggled. Cleanup.

	* modules/cdisplay_colorblind.c: removed "none" from the enum and
	from the GUI because disabling a filter is implemented generically
	now.

	* modules/cdisplay_colorblind.c
	* modules/cdisplay_gamma.c
	* modules/cdisplay_highcontrast.c
	* modules/cdisplay_proof.c: added mnemonics, cleanup.
parent aba3d437
2003-11-23 Michael Natterer <mitch@gimp.org>
* libgimpwidgets/gimpcolordisplay.[ch]: added API to
enable/disable a filter. A disabled filter has no effect.
* libgimpmodule/gimpmodule.h: incremented GIMP_MODULE_ABI_VERSION.
* app/widgets/gimpcolordisplayeditor.c: added a check column to
the "Active Filters" tree view so the effect of all filters can
quickly be toggled. Cleanup.
* modules/cdisplay_colorblind.c: removed "none" from the enum and
from the GUI because disabling a filter is implemented generically
now.
* modules/cdisplay_colorblind.c
* modules/cdisplay_gamma.c
* modules/cdisplay_highcontrast.c
* modules/cdisplay_proof.c: added mnemonics, cleanup.
2003-11-22 Michael Natterer <mitch@gimp.org>
* libgimpwidgets/gimpwidgetsmarshal.list
......@@ -45,6 +45,7 @@ enum
enum
{
DEST_COLUMN_ENABLED,
DEST_COLUMN_NAME,
DEST_COLUMN_FILTER,
N_DEST_COLUMNS
......@@ -84,6 +85,12 @@ static void gimp_color_display_editor_reordered (GimpColorDisplayStack *
gint position,
GimpColorDisplayEditor *editor);
static void gimp_color_display_editor_changed (GimpColorDisplay *display,
GimpColorDisplayEditor *editor);
static void gimp_color_display_editor_enable_toggled (GtkCellRendererToggle *toggle,
const gchar *path,
GimpColorDisplayEditor *editor);
static void gimp_color_display_editor_update_buttons (GimpColorDisplayEditor *editor);
......@@ -133,12 +140,16 @@ gimp_color_display_editor_class_init (GimpColorDisplayEditorClass *klass)
static void
gimp_color_display_editor_init (GimpColorDisplayEditor *editor)
{
GtkWidget *hbox;
GtkWidget *ed;
GtkWidget *scrolled_win;
GtkWidget *tv;
GtkWidget *vbox;
GtkWidget *image;
GtkWidget *hbox;
GtkWidget *ed;
GtkWidget *scrolled_win;
GtkWidget *tv;
GtkWidget *vbox;
GtkWidget *image;
GtkTreeViewColumn *column;
GtkCellRenderer *rend;
gtk_box_set_spacing (GTK_BOX (editor), 6);
hbox = gtk_hbox_new (FALSE, 6);
gtk_box_pack_start (GTK_BOX (editor), hbox, TRUE, TRUE, 0);
......@@ -154,7 +165,8 @@ gimp_color_display_editor_init (GimpColorDisplayEditor *editor)
gtk_widget_show (scrolled_win);
editor->src = gtk_list_store_new (N_SRC_COLUMNS,
G_TYPE_STRING, G_TYPE_POINTER);
G_TYPE_STRING,
G_TYPE_POINTER);
tv = gtk_tree_view_new_with_model (GTK_TREE_MODEL (editor->src));
g_object_unref (editor->src);
......@@ -164,7 +176,8 @@ gimp_color_display_editor_init (GimpColorDisplayEditor *editor)
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tv),
0, _("Available Filters"),
gtk_cell_renderer_text_new (),
"text", 0, NULL);
"text", SRC_COLUMN_NAME,
NULL);
gtk_container_add (GTK_CONTAINER (scrolled_win), tv);
gtk_widget_show (tv);
......@@ -247,17 +260,36 @@ gimp_color_display_editor_init (GimpColorDisplayEditor *editor)
gtk_widget_show (scrolled_win);
editor->dest = gtk_list_store_new (N_DEST_COLUMNS,
G_TYPE_STRING, GIMP_TYPE_COLOR_DISPLAY);
G_TYPE_BOOLEAN,
G_TYPE_STRING,
GIMP_TYPE_COLOR_DISPLAY);
tv = gtk_tree_view_new_with_model (GTK_TREE_MODEL (editor->dest));
g_object_unref (editor->dest);
gtk_widget_set_size_request (tv, LIST_WIDTH, LIST_HEIGHT);
gtk_tree_view_set_headers_clickable (GTK_TREE_VIEW (tv), FALSE);
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tv),
0, _("Active Filters"),
gtk_cell_renderer_text_new (),
"text", 0, NULL);
column = gtk_tree_view_column_new ();
gtk_tree_view_column_set_title (column, _("Active Filters"));
gtk_tree_view_insert_column (GTK_TREE_VIEW (tv), column, 0);
rend = gtk_cell_renderer_toggle_new ();
gtk_tree_view_column_pack_start (column, rend, FALSE);
gtk_tree_view_column_set_attributes (column, rend,
"active", DEST_COLUMN_ENABLED,
NULL);
g_signal_connect (rend, "toggled",
G_CALLBACK (gimp_color_display_editor_enable_toggled),
editor);
rend = gtk_cell_renderer_text_new ();
gtk_tree_view_column_pack_start (column, rend, FALSE);
gtk_tree_view_column_set_attributes (column, rend,
"text", DEST_COLUMN_NAME,
NULL);
gtk_container_add (GTK_CONTAINER (scrolled_win), tv);
gtk_widget_show (tv);
......@@ -315,8 +347,8 @@ GtkWidget *
gimp_color_display_editor_new (GimpColorDisplayStack *stack)
{
GimpColorDisplayEditor *editor;
GType *filter_types;
guint n_filter_types;
GType *display_types;
guint n_display_types;
gint i;
GList *list;
......@@ -326,41 +358,49 @@ gimp_color_display_editor_new (GimpColorDisplayStack *stack)
editor->stack = g_object_ref (stack);
filter_types = g_type_children (GIMP_TYPE_COLOR_DISPLAY, &n_filter_types);
display_types = g_type_children (GIMP_TYPE_COLOR_DISPLAY, &n_display_types);
for (i = 0; i < n_filter_types; i++)
for (i = 0; i < n_display_types; i++)
{
GimpColorDisplayClass *filter_class;
GimpColorDisplayClass *display_class;
GtkTreeIter iter;
filter_class = g_type_class_ref (filter_types[i]);
display_class = g_type_class_ref (display_types[i]);
gtk_list_store_append (editor->src, &iter);
gtk_list_store_set (editor->src, &iter,
SRC_COLUMN_NAME, filter_class->name,
SRC_COLUMN_TYPE, filter_types[i],
SRC_COLUMN_NAME, display_class->name,
SRC_COLUMN_TYPE, display_types[i],
-1);
g_type_class_unref (filter_class);
g_type_class_unref (display_class);
}
g_free (filter_types);
g_free (display_types);
for (list = stack->filters; list; list = g_list_next (list))
{
GimpColorDisplay *filter = list->data;
GimpColorDisplay *display = list->data;
GtkTreeIter iter;
gboolean enabled;
const gchar *name;
name = GIMP_COLOR_DISPLAY_GET_CLASS (filter)->name;
enabled = gimp_color_display_get_enabled (display);
name = GIMP_COLOR_DISPLAY_GET_CLASS (display)->name;
gtk_list_store_append (editor->dest, &iter);
gtk_list_store_set (editor->dest, &iter,
DEST_COLUMN_NAME, name,
DEST_COLUMN_FILTER, filter,
DEST_COLUMN_ENABLED, enabled,
DEST_COLUMN_NAME, name,
DEST_COLUMN_FILTER, display,
-1);
g_signal_connect_object (display, "changed",
G_CALLBACK (gimp_color_display_editor_changed),
G_OBJECT (editor), 0);
}
g_signal_connect_object (stack, "added",
......@@ -388,7 +428,7 @@ gimp_color_display_editor_add_clicked (GtkWidget *widget,
GimpColorDisplay *display;
GValue val = { 0, };
gtk_tree_model_get_value (model, &iter, DEST_COLUMN_FILTER, &val);
gtk_tree_model_get_value (model, &iter, SRC_COLUMN_TYPE, &val);
display = gimp_color_display_new ((GType) g_value_get_pointer (&val));
......@@ -462,7 +502,7 @@ gimp_color_display_editor_dest_changed (GtkTreeSelection *sel,
{
GtkTreeModel *model;
GtkTreeIter iter;
GimpColorDisplay *filter = NULL;
GimpColorDisplay *display = NULL;
if (editor->selected)
{
......@@ -477,31 +517,31 @@ gimp_color_display_editor_dest_changed (GtkTreeSelection *sel,
gtk_tree_model_get_value (model, &iter, DEST_COLUMN_FILTER, &val);
filter = g_value_get_object (&val);
display = g_value_get_object (&val);
g_value_unset (&val);
}
gtk_widget_set_sensitive (editor->remove_button, filter != NULL);
gtk_widget_set_sensitive (editor->reset_button, filter != NULL);
gtk_widget_set_sensitive (editor->remove_button, display != NULL);
gtk_widget_set_sensitive (editor->reset_button, display != NULL);
if (editor->config_widget)
gtk_container_remove (GTK_CONTAINER (editor->config_box),
editor->config_widget);
if (filter)
if (display)
{
gchar *str;
editor->selected = filter;
editor->selected = display;
g_object_add_weak_pointer (G_OBJECT (filter),
g_object_add_weak_pointer (G_OBJECT (display),
(gpointer) &editor->selected);
editor->config_widget = gimp_color_display_configure (filter);
editor->config_widget = gimp_color_display_configure (display);
str = g_strdup_printf (_("Configure Selected Filter: %s"),
GIMP_COLOR_DISPLAY_GET_CLASS (filter)->name);
GIMP_COLOR_DISPLAY_GET_CLASS (display)->name);
gtk_frame_set_label (GTK_FRAME (editor->config_frame), str);
g_free (str);
}
......@@ -534,17 +574,25 @@ gimp_color_display_editor_added (GimpColorDisplayStack *stack,
GimpColorDisplayEditor *editor)
{
GtkTreeIter iter;
gboolean enabled;
const gchar *name;
enabled = gimp_color_display_get_enabled (display);
name = GIMP_COLOR_DISPLAY_GET_CLASS (display)->name;
gtk_list_store_insert (editor->dest, &iter, position);
gtk_list_store_set (editor->dest, &iter,
DEST_COLUMN_NAME, name,
DEST_COLUMN_FILTER, display,
DEST_COLUMN_ENABLED, enabled,
DEST_COLUMN_NAME, name,
DEST_COLUMN_FILTER, display,
-1);
g_signal_connect_object (display, "changed",
G_CALLBACK (gimp_color_display_editor_changed),
G_OBJECT (editor), 0);
gimp_color_display_editor_update_buttons (editor);
}
......@@ -572,6 +620,10 @@ gimp_color_display_editor_removed (GimpColorDisplayStack *stack,
if (display == display2)
{
g_signal_handlers_disconnect_by_func (display,
gimp_color_display_editor_changed,
editor);
gtk_list_store_remove (editor->dest, &iter);
gimp_color_display_editor_update_buttons (editor);
......@@ -647,6 +699,67 @@ gimp_color_display_editor_reordered (GimpColorDisplayStack *stack,
}
}
static void
gimp_color_display_editor_changed (GimpColorDisplay *display,
GimpColorDisplayEditor *editor)
{
GtkTreeIter iter;
gboolean iter_valid;
for (iter_valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (editor->dest),
&iter);
iter_valid;
iter_valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (editor->dest),
&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);
break;
}
}
}
static void
gimp_color_display_editor_enable_toggled (GtkCellRendererToggle *toggle,
const gchar *path_str,
GimpColorDisplayEditor *editor)
{
GtkTreePath *path;
GtkTreeIter iter;
path = gtk_tree_path_new_from_string (path_str);
if (gtk_tree_model_get_iter (GTK_TREE_MODEL (editor->dest), &iter, path))
{
GimpColorDisplay *display;
gboolean enabled;
gtk_tree_model_get (GTK_TREE_MODEL (editor->dest), &iter,
DEST_COLUMN_FILTER, &display,
DEST_COLUMN_ENABLED, &enabled,
-1);
gimp_color_display_set_enabled (display, ! enabled);
}
gtk_tree_path_free (path);
}
static void
gimp_color_display_editor_update_buttons (GimpColorDisplayEditor *editor)
{
......
......@@ -37,7 +37,7 @@ G_BEGIN_DECLS
* - one of the classes implemented by modules (currently GimpColorDisplay
* and GimpColorSelector).
*/
#define GIMP_MODULE_ABI_VERSION 0x0001
#define GIMP_MODULE_ABI_VERSION 0x0002
typedef enum
......
......@@ -103,6 +103,7 @@ gimp_color_display_class_init (GimpColorDisplayClass *klass)
static void
gimp_color_display_init (GimpColorDisplay *display)
{
display->enabled = TRUE;
}
GimpColorDisplay *
......@@ -129,6 +130,28 @@ 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,
......@@ -139,7 +162,7 @@ gimp_color_display_convert (GimpColorDisplay *display,
{
g_return_if_fail (GIMP_IS_COLOR_DISPLAY (display));
if (GIMP_COLOR_DISPLAY_GET_CLASS (display)->convert)
if (display->enabled && GIMP_COLOR_DISPLAY_GET_CLASS (display)->convert)
GIMP_COLOR_DISPLAY_GET_CLASS (display)->convert (display, buf,
width, height,
bpp, bpl);
......
......@@ -37,6 +37,8 @@ typedef struct _GimpColorDisplayClass GimpColorDisplayClass;
struct _GimpColorDisplay
{
GObject parent_instance;
gboolean enabled;
};
struct _GimpColorDisplayClass
......@@ -67,9 +69,12 @@ struct _GimpColorDisplayClass
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,
......
......@@ -43,10 +43,12 @@
typedef enum
{
COLORBLIND_DEFICIENCY_NONE,
COLORBLIND_DEFICIENCY_PROTANOPIA,
COLORBLIND_DEFICIENCY_FIRST,
COLORBLIND_DEFICIENCY_PROTANOPIA = COLORBLIND_DEFICIENCY_FIRST,
COLORBLIND_DEFICIENCY_DEUTERANOPIA,
COLORBLIND_DEFICIENCY_TRITANOPIA,
COLORBLIND_DEFICIENCY_LAST = COLORBLIND_DEFICIENCY_TRITANOPIA
} ColorblindDeficiency;
......@@ -299,9 +301,6 @@ cdisplay_colorblind_convert (GimpColorDisplay *display,
colorblind = CDISPLAY_COLORBLIND (display);
if (colorblind->deficiency == COLORBLIND_DEFICIENCY_NONE)
return;
/* to improve readability, copy the parameters into local variables */
memcpy (rgb2lms, colorblind->rgb2lms, sizeof (rgb2lms));
memcpy (lms2rgb, colorblind->lms2rgb, sizeof (lms2rgb));
......@@ -424,7 +423,7 @@ cdisplay_colorblind_load_state (GimpColorDisplay *display,
if (sscanf (str, "%d", &deficiency) == 1)
{
if (deficiency >= COLORBLIND_DEFICIENCY_NONE &&
if (deficiency >= COLORBLIND_DEFICIENCY_FIRST &&
deficiency <= COLORBLIND_DEFICIENCY_LAST)
{
colorblind->deficiency = deficiency;
......@@ -456,12 +455,13 @@ cdisplay_colorblind_configure (GimpColorDisplay *display)
if (colorblind->hbox)
gtk_widget_destroy (colorblind->hbox);
colorblind->hbox = gtk_hbox_new (FALSE, 2);
colorblind->hbox = gtk_hbox_new (FALSE, 4);
g_signal_connect (colorblind->hbox, "destroy",
G_CALLBACK (gtk_widget_destroyed),
&colorblind->hbox);
label = gtk_label_new ( _("Color Deficiency Type:"));
label = gtk_label_new_with_mnemonic (_("Color _Deficiency Type:"));
gtk_box_pack_start (GTK_BOX (colorblind->hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
......@@ -470,9 +470,6 @@ cdisplay_colorblind_configure (GimpColorDisplay *display)
G_CALLBACK (colorblind_deficiency_callback),
colorblind, colorblind->deficiency,
_("None (normal vision)"),
COLORBLIND_DEFICIENCY_NONE, NULL,
_("Protanopia (insensitivity to red)"),
COLORBLIND_DEFICIENCY_PROTANOPIA, NULL,
......@@ -488,6 +485,8 @@ cdisplay_colorblind_configure (GimpColorDisplay *display)
FALSE, FALSE, 0);
gtk_widget_show (colorblind->optionmenu);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), colorblind->optionmenu);
return colorblind->hbox;
}
......@@ -543,9 +542,6 @@ cdisplay_colorblind_changed (GimpColorDisplay *display)
switch (colorblind->deficiency)
{
case COLORBLIND_DEFICIENCY_NONE:
break;
case COLORBLIND_DEFICIENCY_DEUTERANOPIA:
/* find a,b,c for lam=575nm and lam=475 */
colorblind->a1 = anchor_e[1] * anchor[8] - anchor_e[2] * anchor[7];
......
......@@ -303,11 +303,12 @@ cdisplay_gamma_configure (GimpColorDisplay *display)
gtk_widget_destroy (gamma->hbox);
gamma->hbox = gtk_hbox_new (FALSE, 4);
g_signal_connect (gamma->hbox, "destroy",
G_CALLBACK (gtk_widget_destroyed),
&gamma->hbox);
label = gtk_label_new ( _("Gamma:"));
label = gtk_label_new_with_mnemonic (_("_Gamma:"));
gtk_box_pack_start (GTK_BOX (gamma->hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
......@@ -317,6 +318,8 @@ cdisplay_gamma_configure (GimpColorDisplay *display)
gtk_box_pack_start (GTK_BOX (gamma->hbox), spinbutton, FALSE, FALSE, 0);
gtk_widget_show (spinbutton);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), spinbutton);
g_signal_connect (gamma->adjustment, "value_changed",
G_CALLBACK (gamma_configure_adj_callback),
gamma);
......
......@@ -299,12 +299,13 @@ cdisplay_contrast_configure (GimpColorDisplay *display)
if (contrast->hbox)
gtk_widget_destroy (contrast->hbox);
contrast->hbox = gtk_hbox_new (FALSE, 2);
contrast->hbox = gtk_hbox_new (FALSE, 4);
g_signal_connect (contrast->hbox, "destroy",
G_CALLBACK (gtk_widget_destroyed),
&contrast->hbox);
label = gtk_label_new ( _("Contrast Cycles:"));
label = gtk_label_new_with_mnemonic (_("Contrast C_ycles:"));
gtk_box_pack_start (GTK_BOX (contrast->hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
......@@ -315,6 +316,8 @@ cdisplay_contrast_configure (GimpColorDisplay *display)
gtk_box_pack_start (GTK_BOX (contrast->hbox), spinbutton, FALSE, FALSE, 0);
gtk_widget_show (spinbutton);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), spinbutton);
g_signal_connect (contrast->adjustment, "value_changed",
G_CALLBACK (contrast_configure_adj_callback),
contrast);
......
......@@ -335,7 +335,7 @@ cdisplay_proof_configure (GimpColorDisplay *display)
proof->filename, FALSE, FALSE);
gimp_table_attach_aligned (GTK_TABLE (proof->table), 0, 1,
_("_Profile:"), 1.0, 0.5,
entry, 1, TRUE);
entry, 1, FALSE);
g_signal_connect (entry, "filename-changed",
G_CALLBACK (proof_file_callback),
......
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