Commit 32bc599d authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

forgot to declare gimp_color_display_stack_clone().

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

	* libgimpwidgets/gimpcolordisplaystack.h: forgot to declare
	gimp_color_display_stack_clone().

	* app/display/gimpdisplayshell.[ch]: replaced the GList of
	GimpColorDisplays by a single GimpColorDisplayStack.

	* app/display/gimpdisplayshell-render.c
	(gimp_display_shell_render): changed accordingly.

	* app/display/gimpdisplayshell-filter.[ch]: reduced API to a
	single function, gimp_display_shell_filter_set(), which exchanges
	the whole filter stack. Idle update the display on
	GimpColorDisplayStack::update().

	* app/display/gimpdisplayshell-filter-dialog.[ch]: changed
	accordingly.  Return the created dialog instead of assigning
	shell->filters_dialog.

	* app/gui/view-commands.c (view_display_filters_cmd_callback): set
	shell->filters_dialog here and raise it it if already
	exists. Don't use the dialog factory to create it because it's a
	transient dialog for the display which does not need to be session
	managed.

	* app/gui/dialogs-constructors.[ch]
	* app/gui/dialogs.c: removed display filter dialog stuff.
parent f5162930
2003-11-21 Michael Natterer <mitch@gimp.org>
* libgimpwidgets/gimpcolordisplaystack.h: forgot to declare
gimp_color_display_stack_clone().
* app/display/gimpdisplayshell.[ch]: replaced the GList of
GimpColorDisplays by a single GimpColorDisplayStack.
* app/display/gimpdisplayshell-render.c
(gimp_display_shell_render): changed accordingly.
* app/display/gimpdisplayshell-filter.[ch]: reduced API to a
single function, gimp_display_shell_filter_set(), which exchanges
the whole filter stack. Idle update the display on
GimpColorDisplayStack::update().
* app/display/gimpdisplayshell-filter-dialog.[ch]: changed
accordingly. Return the created dialog instead of assigning
shell->filters_dialog.
* app/gui/view-commands.c (view_display_filters_cmd_callback): set
shell->filters_dialog here and raise it it if already
exists. Don't use the dialog factory to create it because it's a
transient dialog for the display which does not need to be session
managed.
* app/gui/dialogs-constructors.[ch]
* app/gui/dialogs.c: removed display filter dialog stuff.
2003-11-21 Michael Natterer <mitch@gimp.org>
* libgimpwidgets/Makefile.am
......@@ -34,6 +34,7 @@
#include "display/gimpdisplay-foreach.h"
#include "display/gimpdisplayshell.h"
#include "display/gimpdisplayshell-appearance.h"
#include "display/gimpdisplayshell-filter-dialog.h"
#include "display/gimpdisplayshell-scale.h"
#include "widgets/gimpdialogfactory.h"
......@@ -205,9 +206,16 @@ view_display_filters_cmd_callback (GtkWidget *widget,
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
gimp_dialog_factory_dialog_new (global_dialog_factory,
gtk_widget_get_screen (widget),
"gimp-display-filters-dialog", -1);
if (! shell->filters_dialog)
{
shell->filters_dialog = gimp_display_shell_filter_dialog_new (shell);
g_signal_connect (shell->filters_dialog, "destroy",
G_CALLBACK (gtk_widget_destroyed),
&shell->filters_dialog);
}
gtk_window_present (GTK_WINDOW (shell->filters_dialog));
}
void
......
......@@ -66,7 +66,6 @@
#include "display/gimpdisplay.h"
#include "display/gimpdisplayshell.h"
#include "display/gimpdisplayshell-filter-dialog.h"
#include "display/gimpnavigationview.h"
#include "about-dialog.h"
......@@ -128,30 +127,6 @@ dialogs_module_browser_get (GimpDialogFactory *factory,
return module_browser_new (context->gimp);
}
GtkWidget *
dialogs_display_filters_get (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size)
{
GimpDisplay *gdisp;
gdisp = gimp_context_get_display (context);
if (gdisp)
{
GimpDisplayShell *shell;
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
if (! shell->filters_dialog)
gimp_display_shell_filter_dialog_new (shell);
return shell->filters_dialog;
}
return NULL;
}
GtkWidget *
dialogs_tips_get (GimpDialogFactory *factory,
GimpContext *context,
......
......@@ -31,9 +31,6 @@ GtkWidget * dialogs_preferences_get (GimpDialogFactory *factory,
GtkWidget * dialogs_module_browser_get (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
GtkWidget * dialogs_display_filters_get (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
GtkWidget * dialogs_tips_get (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
......
......@@ -94,8 +94,6 @@ static const GimpDialogFactoryEntry toplevel_entries[] =
/* ordinary toplevels */
{ "gimp-file-new-dialog", dialogs_file_new_new,
0, FALSE, TRUE, FALSE, FALSE },
{ "gimp-display-filters-dialog", dialogs_display_filters_get,
0, FALSE, TRUE, FALSE, FALSE },
/* singleton toplevels */
{ "gimp-preferences-dialog", dialogs_preferences_get,
......
......@@ -270,7 +270,8 @@ gimp_display_shell_init (GimpDisplayShell *shell)
shell->nav_popup = NULL;
shell->grid_dialog = NULL;
shell->filters = NULL;
shell->filter_stack = NULL;
shell->filter_idle_id = 0;
shell->filters_dialog = NULL;
shell->window_state = 0;
......@@ -385,7 +386,14 @@ gimp_display_shell_destroy (GtkObject *object)
shell->select = NULL;
}
gimp_display_shell_filter_detach_all (shell);
if (shell->filter_stack)
gimp_display_shell_filter_set (shell, NULL);
if (shell->filter_idle_id)
{
g_source_remove (shell->filter_idle_id);
shell->filter_idle_id = NULL;
}
if (shell->render_buf)
{
......
......@@ -137,8 +137,9 @@ struct _GimpDisplayShell
GtkWidget *nav_popup; /* navigation popup */
GtkWidget *grid_dialog; /* grid configuration dialog */
GList *filters; /* color display conversion stuff */
GtkWidget *filters_dialog; /* color display filter dialog */
GimpColorDisplayStack *filter_stack; /* color display conversion stuff */
guint filter_idle_id;
GtkWidget *filters_dialog;/* color display filter dialog */
GdkWindowState window_state; /* for fullscreen display */
......
......@@ -41,45 +41,40 @@
#define LIST_WIDTH 150
#define LIST_HEIGHT 100
#define UPDATE_DISPLAY(cdd) G_STMT_START \
{ \
gimp_display_shell_expose_full ((cdd)->shell); \
} G_STMT_END
typedef struct _ColorDisplayDialog ColorDisplayDialog;
struct _ColorDisplayDialog
{
GimpDisplayShell *shell;
GtkWidget *dialog;
GimpDisplayShell *shell;
GtkTreeStore *src;
GtkTreeStore *dest;
GtkWidget *dialog;
GtkTreeSelection *src_sel;
GtkTreeSelection *dest_sel;
GtkTreeStore *src;
GtkTreeStore *dest;
GimpColorDisplay *selected;
GtkTreeSelection *src_sel;
GtkTreeSelection *dest_sel;
gboolean modified;
GimpColorDisplay *selected;
GList *old_nodes;
GimpColorDisplayStack *old_stack;
GtkWidget *add_button;
GtkWidget *remove_button;
GtkWidget *up_button;
GtkWidget *down_button;
GtkWidget *add_button;
GtkWidget *remove_button;
GtkWidget *up_button;
GtkWidget *down_button;
GtkWidget *config_frame;
GtkWidget *config_box;
GtkWidget *config_widget;
GtkWidget *config_frame;
GtkWidget *config_box;
GtkWidget *config_widget;
GtkWidget *reset_button;
GtkWidget *reset_button;
};
/* local function prototypes */
static void color_display_dialog_create (ColorDisplayDialog *cdd);
static void color_display_response (GtkWidget *widget,
......@@ -94,22 +89,57 @@ static void color_display_up_callback (GtkWidget *widget,
static void color_display_down_callback (GtkWidget *widget,
ColorDisplayDialog *cdd);
static void dest_list_populate (GList *node_list,
GtkTreeStore *dest);
static void src_list_populate (GtkTreeStore *src);
static void dest_list_populate (GimpColorDisplayStack *stack,
GtkTreeStore *dest);
static void src_selection_changed (GtkTreeSelection *sel,
ColorDisplayDialog *cdd);
static void dest_selection_changed (GtkTreeSelection *sel,
ColorDisplayDialog *cdd);
static void selected_filter_changed (GimpColorDisplay *filter,
ColorDisplayDialog *cdd);
static void selected_filter_reset (GtkWidget *widget,
ColorDisplayDialog *cdd);
static void color_display_update_up_and_down (ColorDisplayDialog *cdd);
/* public functions */
GtkWidget *
gimp_display_shell_filter_dialog_new (GimpDisplayShell *shell)
{
ColorDisplayDialog *cdd;
g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), NULL);
cdd = g_new0 (ColorDisplayDialog, 1);
cdd->shell = shell;
color_display_dialog_create (cdd);
if (shell->filter_stack)
{
cdd->old_stack = gimp_color_display_stack_clone (shell->filter_stack);
}
else
{
GimpColorDisplayStack *stack = gimp_color_display_stack_new ();
gimp_display_shell_filter_set (shell, stack);
g_object_unref (stack);
}
src_list_populate (cdd->src);
dest_list_populate (shell->filter_stack, cdd->dest);
return cdd->dialog;
}
/* private functions */
static void
color_display_dialog_create (ColorDisplayDialog *cdd)
{
......@@ -305,44 +335,16 @@ color_display_response (GtkWidget *widget,
gint response_id,
ColorDisplayDialog *cdd)
{
gtk_widget_destroy (GTK_WIDGET (cdd->dialog));
cdd->shell->filters_dialog = NULL;
if (cdd->modified)
{
GList *list;
if (response_id == GTK_RESPONSE_OK)
{
for (list = cdd->old_nodes; list; list = g_list_next (list))
{
if (! g_list_find (cdd->shell->filters, list->data))
gimp_display_shell_filter_detach_destroy (cdd->shell,
list->data);
}
g_list_free (cdd->old_nodes);
}
else
{
list = cdd->shell->filters;
cdd->shell->filters = cdd->old_nodes;
if (response_id != GTK_RESPONSE_OK)
gimp_display_shell_filter_set (cdd->shell, cdd->old_stack);
while (list)
{
GList *next = list->next;
if (cdd->old_stack)
g_object_unref (cdd->old_stack);
if (! g_list_find (cdd->old_nodes, list->data))
gimp_display_shell_filter_detach_destroy (cdd->shell,
list->data);
list = next;
}
}
UPDATE_DISPLAY (cdd);
}
g_free (cdd);
}
static void
......@@ -362,7 +364,7 @@ color_display_update_up_and_down (ColorDisplayDialog *cdd)
indices = gtk_tree_path_get_indices (path);
up_sensitive = indices[0] > 0;
down_sensitive = indices[0] < (g_list_length (cdd->shell->filters) - 1);
down_sensitive = indices[0] < (g_list_length (cdd->shell->filter_stack->filters) - 1);
gtk_tree_path_free (path);
}
......@@ -385,23 +387,24 @@ color_display_add_callback (GtkWidget *widget,
gtk_tree_model_get_value (model, &iter, 1, &val);
filter = gimp_display_shell_filter_attach (cdd->shell,
(GType) g_value_get_pointer (&val));
filter = gimp_color_display_new ((GType) g_value_get_pointer (&val));
g_value_unset (&val);
gtk_tree_store_append (cdd->dest, &iter, NULL);
if (filter)
{
gimp_color_display_stack_add (cdd->shell->filter_stack, filter);
g_object_unref (filter);
gtk_tree_store_set (cdd->dest, &iter,
0, GIMP_COLOR_DISPLAY_GET_CLASS (filter)->name,
1, filter,
-1);
gtk_tree_store_append (cdd->dest, &iter, NULL);
cdd->modified = TRUE;
gtk_tree_store_set (cdd->dest, &iter,
0, GIMP_COLOR_DISPLAY_GET_CLASS (filter)->name,
1, filter,
-1);
color_display_update_up_and_down (cdd);
UPDATE_DISPLAY (cdd);
color_display_update_up_and_down (cdd);
}
}
}
......@@ -425,16 +428,9 @@ color_display_remove_callback (GtkWidget *widget,
gtk_tree_store_remove (cdd->dest, &iter);
cdd->modified = TRUE;
if (g_list_find (cdd->old_nodes, filter))
gimp_display_shell_filter_detach (cdd->shell, filter);
else
gimp_display_shell_filter_detach_destroy (cdd->shell, filter);
gimp_color_display_stack_remove (cdd->shell->filter_stack, filter);
color_display_update_up_and_down (cdd);
UPDATE_DISPLAY (cdd);
}
}
......@@ -469,13 +465,9 @@ color_display_up_callback (GtkWidget *widget,
1, filter1,
-1);
gimp_display_shell_filter_reorder_up (cdd->shell, filter1);
cdd->modified = TRUE;
gimp_color_display_stack_reorder_up (cdd->shell->filter_stack, filter1);
gtk_tree_selection_select_iter (cdd->dest_sel, &iter2);
UPDATE_DISPLAY (cdd);
}
}
......@@ -510,29 +502,18 @@ color_display_down_callback (GtkWidget *widget,
1, filter1,
-1);
gimp_display_shell_filter_reorder_down (cdd->shell, filter1);
cdd->modified = TRUE;
gimp_color_display_stack_reorder_down (cdd->shell->filter_stack, filter1);
gtk_tree_selection_select_iter (cdd->dest_sel, &iter2);
UPDATE_DISPLAY (cdd);
}
}
void
gimp_display_shell_filter_dialog_new (GimpDisplayShell *shell)
static void
src_list_populate (GtkTreeStore *src)
{
ColorDisplayDialog *cdd;
GType *filter_types;
guint n_filter_types;
gint i;
cdd = g_new0 (ColorDisplayDialog, 1);
cdd->shell = shell;
color_display_dialog_create (cdd);
GType *filter_types;
guint n_filter_types;
gint i;
filter_types = g_type_children (GIMP_TYPE_COLOR_DISPLAY, &n_filter_types);
......@@ -543,9 +524,9 @@ gimp_display_shell_filter_dialog_new (GimpDisplayShell *shell)
filter_class = g_type_class_ref (filter_types[i]);
gtk_tree_store_append (cdd->src, &iter, NULL);
gtk_tree_store_append (src, &iter, NULL);
gtk_tree_store_set (cdd->src, &iter,
gtk_tree_store_set (src, &iter,
0, filter_class->name,
1, filter_types[i],
-1);
......@@ -554,25 +535,18 @@ gimp_display_shell_filter_dialog_new (GimpDisplayShell *shell)
}
g_free (filter_types);
cdd->old_nodes = shell->filters;
dest_list_populate (shell->filters, cdd->dest);
shell->filters = g_list_copy (cdd->old_nodes);
shell->filters_dialog = cdd->dialog;
}
static void
dest_list_populate (GList *node_list,
GtkTreeStore *dest)
dest_list_populate (GimpColorDisplayStack *stack,
GtkTreeStore *dest)
{
GimpColorDisplay *filter;
GList *list;
GtkTreeIter iter;
GList *list;
for (list = node_list; list; list = g_list_next (list))
for (list = stack->filters; list; list = g_list_next (list))
{
filter = (GimpColorDisplay *) list->data;
GimpColorDisplay *filter = list->data;
GtkTreeIter iter;
gtk_tree_store_append (dest, &iter, NULL);
......@@ -615,9 +589,6 @@ dest_selection_changed (GtkTreeSelection *sel,
if (cdd->selected)
{
g_signal_handlers_disconnect_by_func (cdd->selected,
selected_filter_changed,
cdd);
g_object_remove_weak_pointer (G_OBJECT (cdd->selected),
(gpointer) &cdd->selected);
cdd->selected = NULL;
......@@ -647,9 +618,6 @@ dest_selection_changed (GtkTreeSelection *sel,
cdd->selected = filter;
g_object_add_weak_pointer (G_OBJECT (filter), (gpointer) &cdd->selected);
g_signal_connect (cdd->selected, "changed",
G_CALLBACK (selected_filter_changed),
cdd);
cdd->config_widget = gimp_color_display_configure (filter);
......@@ -680,13 +648,6 @@ dest_selection_changed (GtkTreeSelection *sel,
color_display_update_up_and_down (cdd);
}
static void
selected_filter_changed (GimpColorDisplay *filter,
ColorDisplayDialog *cdd)
{
UPDATE_DISPLAY (cdd);
}
static void
selected_filter_reset (GtkWidget *widget,
ColorDisplayDialog *cdd)
......
......@@ -20,7 +20,7 @@
#define __GIMP_DISPLAY_SHELL_FILTER_DIALOG_H__
void gimp_display_shell_filter_dialog_new (GimpDisplayShell *shell);
GtkWidget * gimp_display_shell_filter_dialog_new (GimpDisplayShell *shell);
#endif /* __GIMP_DISPLAY_SHELL_FILTER_DIALOG_H__ */
......@@ -18,133 +18,80 @@
#include "config.h"
#include <string.h>
#include <gmodule.h>
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "display-types.h"
#include "core/gimpimage.h"
#include "gimpdisplay.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-filter.h"
GimpColorDisplay *
gimp_display_shell_filter_attach (GimpDisplayShell *shell,
GType type)
{
GimpColorDisplay *filter;
g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), NULL);
g_return_val_if_fail (g_type_is_a (type, GIMP_TYPE_COLOR_DISPLAY), NULL);
filter = gimp_color_display_new (type);
/* local function prototypes */
if (filter)
{
shell->filters = g_list_append (shell->filters, filter);
static void gimp_display_shell_filter_changed (GimpColorDisplayStack *stack,
GimpDisplayShell *shell);
return filter;
}
else
g_warning ("Tried to attach a nonexistant color display");
return NULL;
}
/* public functions */
GimpColorDisplay *
gimp_display_shell_filter_attach_clone (GimpDisplayShell *shell,
GimpColorDisplay *filter)
void
gimp_display_shell_filter_set (GimpDisplayShell *shell,
GimpColorDisplayStack *stack)
{
GimpColorDisplay *clone;
g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), NULL);
g_return_val_if_fail (GIMP_IS_COLOR_DISPLAY (filter), NULL);
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_return_if_fail (stack == NULL || GIMP_IS_COLOR_DISPLAY_STACK (stack));
clone = gimp_color_display_clone (filter);
if (stack == shell->filter_stack)
return;
if (clone)
if (shell->filter_stack)
{
shell->filters = g_list_append (shell->filters, clone);
g_signal_handlers_disconnect_by_func (shell->filter_stack,
gimp_display_shell_filter_changed,
shell);
return clone;
g_object_unref (shell->filter_stack);
}
else
g_warning ("Tried to clone a nonexistant color display");
return NULL;
}
shell->filter_stack = stack;
void
gimp_display_shell_filter_detach (GimpDisplayShell *shell,
GimpColorDisplay *filter)
{
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_return_if_fail (GIMP_IS_COLOR_DISPLAY (filter));
shell->filters = g_list_remove (shell->filters, filter);
}
void
gimp_display_shell_filter_detach_destroy (GimpDisplayShell *shell,
GimpColorDisplay *filter)
{
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_return_if_fail (GIMP_IS_COLOR_DISPLAY (filter));
if (shell->filter_stack)
{
g_object_ref (shell->filter_stack);
g_object_unref (filter);
g_signal_connect (shell->filter_stack, "changed",
G_CALLBACK (gimp_display_shell_filter_changed),
shell);
}
shell->filters = g_list_remove (shell->filters, filter);
gimp_display_shell_filter_changed (NULL, shell);
}
void
gimp_display_shell_filter_detach_all (GimpDisplayShell *shell)
{
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_list_foreach (shell->filters, (GFunc) g_object_unref, NULL);
g_list_free (shell->filters);
shell->filters = NULL;
}
/* private functions */
void
gimp_display_shell_filter_reorder_up (GimpDisplayShell *shell,
GimpColorDisplay *filter)
static gboolean
gimp_display_shell_filter_changed_idle (gpointer data)
{
GList *node_list;
GimpDisplayShell *shell = data;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_return_if_fail (GIMP_IS_COLOR_DISPLAY (filter));
gimp_display_shell_expose_full (shell);
shell->filter_idle_id = 0;
node_list = g_list_find (shell->filters, filter);
if (node_list->prev)
{
node_list->data = node_list->prev->data;
node_list->prev->data = filter;
}
return FALSE;
}
void
gimp_display_shell_filter_reorder_down (GimpDisplayShell *shell,
GimpColorDisplay *filter)
static void
gimp_display_shell_filter_changed (GimpColorDisplayStack *stack,
GimpDisplayShell *shell)
{
GList *node_list;
if (shell->filter_idle_id)
g_source_remove (shell->filter_idle_id);
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_return_if_fail (GIMP_IS_COLOR_DISPLAY (filter));
node_list = g_list_find (shell->filters, filter);
if (node_list->next)
{
node_list->data = node_list->next->data;
node_list->next->data = filter;
}
shell->filter_idle_id =
g_idle_add_full (G_PRIORITY_LOW,
gimp_display_shell_filter_changed_idle,
shell, NULL);
}
......@@ -20,21 +20,8 @@
#define __GIMP_DISPLAY_SHELL_FILTER_H__
GimpColorDisplay *
gimp_display_shell_filter_attach (GimpDisplayShell *shell,
GType type);
GimpColorDisplay *
gimp_display_shell_filter_attach_clone (GimpDisplayShell *shell,
GimpColorDisplay *filter);
void gimp_display_shell_filter_detach (GimpDisplayShell *shell,
GimpColorDisplay *filter);
void gimp_display_shell_filter_detach_destroy (GimpDisplayShell *shell,
GimpColorDisplay *filter);
void gimp_display_shell_filter_detach_all (GimpDisplayShell *shell);
void gimp_display_shell_filter_reorder_up (GimpDisplayShell *shell,
GimpColorDisplay *filter);
void gimp_display_shell_filter_reorder_down (GimpDisplayShell *shell,