mirror of https://github.com/GNOME/gimp.git
libgimpwidgets/gimpwidgetsmarshal.list added signals ::added(),
2003-11-22 Michael Natterer <mitch@gimp.org> * libgimpwidgets/gimpwidgetsmarshal.list * libgimpwidgets/gimpcolordisplaystack.[ch]: added signals ::added(), ::removed() and ::reordered() and emit them in the resp. functions. * app/widgets/Makefile.am * app/widgets/widgets-types.h * app/widgets/gimpcolordisplayeditor.[ch]: new widget implementing an editable view on a GimpColorDisplayStack. Most code taken from below... * app/display/gimpdisplayshell-filter-dialog.c: ...and removed here. Only creates a GimpDialog around a GimpColorDisplayEditor now.
This commit is contained in:
parent
c105447b42
commit
06c12d9727
17
ChangeLog
17
ChangeLog
|
@ -1,3 +1,20 @@
|
|||
2003-11-22 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* libgimpwidgets/gimpwidgetsmarshal.list
|
||||
* libgimpwidgets/gimpcolordisplaystack.[ch]: added signals
|
||||
::added(), ::removed() and ::reordered() and emit them in the
|
||||
resp. functions.
|
||||
|
||||
* app/widgets/Makefile.am
|
||||
* app/widgets/widgets-types.h
|
||||
* app/widgets/gimpcolordisplayeditor.[ch]: new widget implementing
|
||||
an editable view on a GimpColorDisplayStack. Most code taken from
|
||||
below...
|
||||
|
||||
* app/display/gimpdisplayshell-filter-dialog.c: ...and removed
|
||||
here. Only creates a GimpDialog around a GimpColorDisplayEditor
|
||||
now.
|
||||
|
||||
2003-11-22 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/paint-funcs/paint-funcs.c (color_erase_inten_pixels): handle
|
||||
|
|
|
@ -20,17 +20,13 @@
|
|||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpbase/gimpbase.h"
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "display-types.h"
|
||||
|
||||
#include "core/gimpimage.h"
|
||||
|
||||
#include "widgets/gimpeditor.h"
|
||||
#include "widgets/gimpcolordisplayeditor.h"
|
||||
#include "widgets/gimphelp-ids.h"
|
||||
|
||||
#include "gimpdisplay.h"
|
||||
#include "gimpdisplayshell.h"
|
||||
#include "gimpdisplayshell-filter.h"
|
||||
#include "gimpdisplayshell-filter-dialog.h"
|
||||
|
@ -38,70 +34,22 @@
|
|||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
#define LIST_WIDTH 150
|
||||
#define LIST_HEIGHT 100
|
||||
|
||||
|
||||
typedef struct _ColorDisplayDialog ColorDisplayDialog;
|
||||
|
||||
struct _ColorDisplayDialog
|
||||
{
|
||||
GimpDisplayShell *shell;
|
||||
|
||||
GtkWidget *dialog;
|
||||
|
||||
GtkTreeStore *src;
|
||||
GtkTreeStore *dest;
|
||||
|
||||
GtkTreeSelection *src_sel;
|
||||
GtkTreeSelection *dest_sel;
|
||||
|
||||
GimpColorDisplay *selected;
|
||||
|
||||
GimpColorDisplayStack *old_stack;
|
||||
|
||||
GtkWidget *add_button;
|
||||
GtkWidget *remove_button;
|
||||
GtkWidget *up_button;
|
||||
GtkWidget *down_button;
|
||||
|
||||
GtkWidget *config_frame;
|
||||
GtkWidget *config_box;
|
||||
GtkWidget *config_widget;
|
||||
|
||||
GtkWidget *reset_button;
|
||||
};
|
||||
|
||||
|
||||
/* local function prototypes */
|
||||
|
||||
static void color_display_dialog_create (ColorDisplayDialog *cdd);
|
||||
|
||||
static void color_display_response (GtkWidget *widget,
|
||||
gint response_id,
|
||||
ColorDisplayDialog *cdd);
|
||||
static void color_display_add_callback (GtkWidget *widget,
|
||||
ColorDisplayDialog *cdd);
|
||||
static void color_display_remove_callback (GtkWidget *widget,
|
||||
ColorDisplayDialog *cdd);
|
||||
static void color_display_up_callback (GtkWidget *widget,
|
||||
ColorDisplayDialog *cdd);
|
||||
static void color_display_down_callback (GtkWidget *widget,
|
||||
ColorDisplayDialog *cdd);
|
||||
|
||||
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_reset (GtkWidget *widget,
|
||||
ColorDisplayDialog *cdd);
|
||||
|
||||
static void color_display_update_up_and_down (ColorDisplayDialog *cdd);
|
||||
static void gimp_display_shell_filter_dialog_response (GtkWidget *widget,
|
||||
gint response_id,
|
||||
ColorDisplayDialog *cdd);
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
@ -110,50 +58,15 @@ GtkWidget *
|
|||
gimp_display_shell_filter_dialog_new (GimpDisplayShell *shell)
|
||||
{
|
||||
ColorDisplayDialog *cdd;
|
||||
GtkWidget *editor;
|
||||
|
||||
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)
|
||||
{
|
||||
GtkWidget *main_vbox;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *editor;
|
||||
GtkWidget *scrolled_win;
|
||||
GtkWidget *tv;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *image;
|
||||
|
||||
g_return_if_fail (GTK_IS_WINDOW (cdd->shell));
|
||||
|
||||
cdd->dialog = gimp_dialog_new (_("Color Display Filters"), "display_filters",
|
||||
cdd->shell = shell;
|
||||
cdd->dialog = gimp_dialog_new (_("Color Display Filters"),
|
||||
"gimp-display-filters",
|
||||
GTK_WIDGET (cdd->shell),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
gimp_standard_help_func,
|
||||
|
@ -164,494 +77,45 @@ color_display_dialog_create (ColorDisplayDialog *cdd)
|
|||
|
||||
NULL);
|
||||
|
||||
g_object_weak_ref (G_OBJECT (cdd->dialog), (GWeakNotify) g_free, cdd);
|
||||
|
||||
g_signal_connect (cdd->dialog, "response",
|
||||
G_CALLBACK (color_display_response),
|
||||
G_CALLBACK (gimp_display_shell_filter_dialog_response),
|
||||
cdd);
|
||||
|
||||
main_vbox = gtk_vbox_new (FALSE, 6);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 6);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (cdd->dialog)->vbox), main_vbox,
|
||||
TRUE, TRUE, 0);
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 6);
|
||||
gtk_box_pack_start (GTK_BOX (main_vbox), hbox, TRUE, TRUE, 0);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
scrolled_win = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_win),
|
||||
GTK_SHADOW_IN);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), scrolled_win, TRUE, TRUE, 0);
|
||||
gtk_widget_show (scrolled_win);
|
||||
|
||||
cdd->src = gtk_tree_store_new (2, G_TYPE_STRING, G_TYPE_POINTER);
|
||||
tv = gtk_tree_view_new_with_model (GTK_TREE_MODEL (cdd->src));
|
||||
g_object_unref (cdd->src);
|
||||
|
||||
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, _("Available Filters"),
|
||||
gtk_cell_renderer_text_new (),
|
||||
"text", 0, NULL);
|
||||
gtk_container_add (GTK_CONTAINER (scrolled_win), tv);
|
||||
gtk_widget_show (tv);
|
||||
|
||||
cdd->src_sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (tv));
|
||||
|
||||
g_signal_connect (cdd->src_sel, "changed",
|
||||
G_CALLBACK (src_selection_changed),
|
||||
cdd);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
cdd->add_button = gtk_button_new ();
|
||||
gtk_box_pack_start (GTK_BOX (vbox), cdd->add_button, FALSE, FALSE, 16);
|
||||
gtk_widget_set_sensitive (cdd->add_button, FALSE);
|
||||
gtk_widget_show (cdd->add_button);
|
||||
|
||||
image = gtk_image_new_from_stock (GTK_STOCK_GO_FORWARD, GTK_ICON_SIZE_BUTTON);
|
||||
gtk_container_add (GTK_CONTAINER (cdd->add_button), image);
|
||||
gtk_widget_show (image);
|
||||
|
||||
gimp_help_set_help_data (cdd->add_button,
|
||||
_("Add the selected filter to the list of "
|
||||
"active filters."), NULL);
|
||||
|
||||
g_signal_connect (cdd->add_button, "clicked",
|
||||
G_CALLBACK (color_display_add_callback),
|
||||
cdd);
|
||||
|
||||
cdd->remove_button = gtk_button_new ();
|
||||
gtk_box_pack_start (GTK_BOX (vbox), cdd->remove_button, FALSE, FALSE, 0);
|
||||
gtk_widget_set_sensitive (cdd->remove_button, FALSE);
|
||||
gtk_widget_show (cdd->remove_button);
|
||||
|
||||
image = gtk_image_new_from_stock (GTK_STOCK_GO_BACK, GTK_ICON_SIZE_BUTTON);
|
||||
gtk_container_add (GTK_CONTAINER (cdd->remove_button), image);
|
||||
gtk_widget_show (image);
|
||||
|
||||
gimp_help_set_help_data (cdd->remove_button,
|
||||
_("Remove the selected filter from the list of "
|
||||
"active filters."), NULL);
|
||||
|
||||
g_signal_connect (cdd->remove_button, "clicked",
|
||||
G_CALLBACK (color_display_remove_callback),
|
||||
cdd);
|
||||
|
||||
editor = gimp_editor_new ();
|
||||
gtk_box_pack_start (GTK_BOX (hbox), editor, TRUE, TRUE, 0);
|
||||
gtk_widget_show (editor);
|
||||
|
||||
cdd->up_button =
|
||||
gimp_editor_add_button (GIMP_EDITOR (editor),
|
||||
GTK_STOCK_GO_UP,
|
||||
_("Move the selected filter up"),
|
||||
NULL,
|
||||
G_CALLBACK (color_display_up_callback),
|
||||
NULL,
|
||||
cdd);
|
||||
|
||||
cdd->down_button =
|
||||
gimp_editor_add_button (GIMP_EDITOR (editor),
|
||||
GTK_STOCK_GO_DOWN,
|
||||
_("Move the selected filter down"),
|
||||
NULL,
|
||||
G_CALLBACK (color_display_down_callback),
|
||||
NULL,
|
||||
cdd);
|
||||
|
||||
gtk_widget_set_sensitive (cdd->up_button, FALSE);
|
||||
gtk_widget_set_sensitive (cdd->down_button, FALSE);
|
||||
|
||||
scrolled_win = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_win),
|
||||
GTK_SHADOW_IN);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
gtk_container_add (GTK_CONTAINER (editor), scrolled_win);
|
||||
gtk_widget_show (scrolled_win);
|
||||
|
||||
cdd->dest = gtk_tree_store_new (2, G_TYPE_STRING, G_TYPE_POINTER);
|
||||
tv = gtk_tree_view_new_with_model (GTK_TREE_MODEL (cdd->dest));
|
||||
g_object_unref (cdd->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);
|
||||
gtk_container_add (GTK_CONTAINER (scrolled_win), tv);
|
||||
gtk_widget_show (tv);
|
||||
|
||||
cdd->dest_sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (tv));
|
||||
|
||||
g_signal_connect (cdd->dest_sel, "changed",
|
||||
G_CALLBACK (dest_selection_changed),
|
||||
cdd);
|
||||
|
||||
/* the config frame */
|
||||
|
||||
cdd->config_frame = gtk_frame_new (NULL);
|
||||
gtk_box_pack_start (GTK_BOX (main_vbox), cdd->config_frame, FALSE, FALSE, 0);
|
||||
gtk_widget_show (cdd->config_frame);
|
||||
|
||||
cdd->config_box = gtk_vbox_new (FALSE, 4);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (cdd->config_box), 4);
|
||||
gtk_container_add (GTK_CONTAINER (cdd->config_frame), cdd->config_box);
|
||||
gtk_widget_show (cdd->config_box);
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 0);
|
||||
gtk_box_pack_end (GTK_BOX (cdd->config_box), hbox, FALSE, FALSE, 0);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
cdd->reset_button = gtk_button_new_from_stock (GIMP_STOCK_RESET);
|
||||
gtk_box_pack_end (GTK_BOX (hbox), cdd->reset_button, FALSE, FALSE, 0);
|
||||
gtk_widget_show (cdd->reset_button);
|
||||
|
||||
gimp_help_set_help_data (cdd->reset_button,
|
||||
_("Reset the selected filter to default values"),
|
||||
NULL);
|
||||
|
||||
g_signal_connect (cdd->reset_button, "clicked",
|
||||
G_CALLBACK (selected_filter_reset),
|
||||
cdd);
|
||||
|
||||
dest_selection_changed (cdd->dest_sel, cdd);
|
||||
|
||||
gtk_widget_show (main_vbox);
|
||||
}
|
||||
|
||||
static void
|
||||
color_display_response (GtkWidget *widget,
|
||||
gint response_id,
|
||||
ColorDisplayDialog *cdd)
|
||||
{
|
||||
gtk_widget_destroy (GTK_WIDGET (cdd->dialog));
|
||||
cdd->shell->filters_dialog = NULL;
|
||||
|
||||
if (response_id != GTK_RESPONSE_OK)
|
||||
gimp_display_shell_filter_set (cdd->shell, cdd->old_stack);
|
||||
|
||||
if (cdd->old_stack)
|
||||
g_object_unref (cdd->old_stack);
|
||||
|
||||
g_free (cdd);
|
||||
}
|
||||
|
||||
static void
|
||||
color_display_update_up_and_down (ColorDisplayDialog *cdd)
|
||||
{
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
gboolean up_sensitive = FALSE;
|
||||
gboolean down_sensitive = FALSE;
|
||||
|
||||
if (gtk_tree_selection_get_selected (cdd->dest_sel, &model, &iter))
|
||||
if (shell->filter_stack)
|
||||
{
|
||||
GtkTreePath *path;
|
||||
gint *indices;
|
||||
cdd->old_stack = gimp_color_display_stack_clone (shell->filter_stack);
|
||||
|
||||
path = gtk_tree_model_get_path (model, &iter);
|
||||
indices = gtk_tree_path_get_indices (path);
|
||||
|
||||
up_sensitive = indices[0] > 0;
|
||||
down_sensitive = indices[0] < (g_list_length (cdd->shell->filter_stack->filters) - 1);
|
||||
|
||||
gtk_tree_path_free (path);
|
||||
}
|
||||
|
||||
gtk_widget_set_sensitive (cdd->up_button, up_sensitive);
|
||||
gtk_widget_set_sensitive (cdd->down_button, down_sensitive);
|
||||
}
|
||||
|
||||
static void
|
||||
color_display_add_callback (GtkWidget *widget,
|
||||
ColorDisplayDialog *cdd)
|
||||
{
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
|
||||
if (gtk_tree_selection_get_selected (cdd->src_sel, &model, &iter))
|
||||
{
|
||||
GimpColorDisplay *filter;
|
||||
GValue val = { 0, };
|
||||
|
||||
gtk_tree_model_get_value (model, &iter, 1, &val);
|
||||
|
||||
filter = gimp_color_display_new ((GType) g_value_get_pointer (&val));
|
||||
|
||||
g_value_unset (&val);
|
||||
|
||||
if (filter)
|
||||
{
|
||||
gimp_color_display_stack_add (cdd->shell->filter_stack, filter);
|
||||
g_object_unref (filter);
|
||||
|
||||
gtk_tree_store_append (cdd->dest, &iter, NULL);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
color_display_remove_callback (GtkWidget *widget,
|
||||
ColorDisplayDialog *cdd)
|
||||
{
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
|
||||
if (gtk_tree_selection_get_selected (cdd->dest_sel, &model, &iter))
|
||||
{
|
||||
GimpColorDisplay *filter;
|
||||
GValue val = { 0, };
|
||||
|
||||
gtk_tree_model_get_value (model, &iter, 1, &val);
|
||||
|
||||
filter = g_value_get_pointer (&val);
|
||||
|
||||
g_value_unset (&val);
|
||||
|
||||
gtk_tree_store_remove (cdd->dest, &iter);
|
||||
|
||||
gimp_color_display_stack_remove (cdd->shell->filter_stack, filter);
|
||||
|
||||
color_display_update_up_and_down (cdd);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
color_display_up_callback (GtkWidget *widget,
|
||||
ColorDisplayDialog *cdd)
|
||||
{
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter1;
|
||||
GtkTreeIter iter2;
|
||||
|
||||
if (gtk_tree_selection_get_selected (cdd->dest_sel, &model, &iter1))
|
||||
{
|
||||
GtkTreePath *path;
|
||||
GimpColorDisplay *filter1;
|
||||
GimpColorDisplay *filter2;
|
||||
|
||||
path = gtk_tree_model_get_path (model, &iter1);
|
||||
gtk_tree_path_prev (path);
|
||||
gtk_tree_model_get_iter (model, &iter2, path);
|
||||
gtk_tree_path_free (path);
|
||||
|
||||
gtk_tree_model_get (model, &iter1, 1, &filter1, -1);
|
||||
gtk_tree_model_get (model, &iter2, 1, &filter2, -1);
|
||||
|
||||
gtk_tree_store_set (GTK_TREE_STORE (model), &iter1,
|
||||
0, GIMP_COLOR_DISPLAY_GET_CLASS (filter2)->name,
|
||||
1, filter2,
|
||||
-1);
|
||||
gtk_tree_store_set (GTK_TREE_STORE (model), &iter2,
|
||||
0, GIMP_COLOR_DISPLAY_GET_CLASS (filter1)->name,
|
||||
1, filter1,
|
||||
-1);
|
||||
|
||||
gimp_color_display_stack_reorder_up (cdd->shell->filter_stack, filter1);
|
||||
|
||||
gtk_tree_selection_select_iter (cdd->dest_sel, &iter2);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
color_display_down_callback (GtkWidget *widget,
|
||||
ColorDisplayDialog *cdd)
|
||||
{
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter1;
|
||||
GtkTreeIter iter2;
|
||||
|
||||
if (gtk_tree_selection_get_selected (cdd->dest_sel, &model, &iter1))
|
||||
{
|
||||
GtkTreePath *path;
|
||||
GimpColorDisplay *filter1;
|
||||
GimpColorDisplay *filter2;
|
||||
|
||||
path = gtk_tree_model_get_path (model, &iter1);
|
||||
gtk_tree_path_next (path);
|
||||
gtk_tree_model_get_iter (model, &iter2, path);
|
||||
gtk_tree_path_free (path);
|
||||
|
||||
gtk_tree_model_get (model, &iter1, 1, &filter1, -1);
|
||||
gtk_tree_model_get (model, &iter2, 1, &filter2, -1);
|
||||
|
||||
gtk_tree_store_set (GTK_TREE_STORE (model), &iter1,
|
||||
0, GIMP_COLOR_DISPLAY_GET_CLASS (filter2)->name,
|
||||
1, filter2,
|
||||
-1);
|
||||
gtk_tree_store_set (GTK_TREE_STORE (model), &iter2,
|
||||
0, GIMP_COLOR_DISPLAY_GET_CLASS (filter1)->name,
|
||||
1, filter1,
|
||||
-1);
|
||||
|
||||
gimp_color_display_stack_reorder_down (cdd->shell->filter_stack, filter1);
|
||||
|
||||
gtk_tree_selection_select_iter (cdd->dest_sel, &iter2);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
src_list_populate (GtkTreeStore *src)
|
||||
{
|
||||
GType *filter_types;
|
||||
guint n_filter_types;
|
||||
gint i;
|
||||
|
||||
filter_types = g_type_children (GIMP_TYPE_COLOR_DISPLAY, &n_filter_types);
|
||||
|
||||
for (i = 0; i < n_filter_types; i++)
|
||||
{
|
||||
GimpColorDisplayClass *filter_class;
|
||||
GtkTreeIter iter;
|
||||
|
||||
filter_class = g_type_class_ref (filter_types[i]);
|
||||
|
||||
gtk_tree_store_append (src, &iter, NULL);
|
||||
|
||||
gtk_tree_store_set (src, &iter,
|
||||
0, filter_class->name,
|
||||
1, filter_types[i],
|
||||
-1);
|
||||
|
||||
g_type_class_unref (filter_class);
|
||||
}
|
||||
|
||||
g_free (filter_types);
|
||||
}
|
||||
|
||||
static void
|
||||
dest_list_populate (GimpColorDisplayStack *stack,
|
||||
GtkTreeStore *dest)
|
||||
{
|
||||
GList *list;
|
||||
|
||||
for (list = stack->filters; list; list = g_list_next (list))
|
||||
{
|
||||
GimpColorDisplay *filter = list->data;
|
||||
GtkTreeIter iter;
|
||||
|
||||
gtk_tree_store_append (dest, &iter, NULL);
|
||||
|
||||
gtk_tree_store_set (dest, &iter,
|
||||
0, GIMP_COLOR_DISPLAY_GET_CLASS (filter)->name,
|
||||
1, filter,
|
||||
-1);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
src_selection_changed (GtkTreeSelection *sel,
|
||||
ColorDisplayDialog *cdd)
|
||||
{
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
const gchar *name = NULL;
|
||||
|
||||
if (gtk_tree_selection_get_selected (sel, &model, &iter))
|
||||
{
|
||||
GValue val = { 0, };
|
||||
|
||||
gtk_tree_model_get_value (model, &iter, 0, &val);
|
||||
|
||||
name = g_value_get_string (&val);
|
||||
|
||||
g_value_unset (&val);
|
||||
}
|
||||
|
||||
gtk_widget_set_sensitive (cdd->add_button, (name != NULL));
|
||||
}
|
||||
|
||||
static void
|
||||
dest_selection_changed (GtkTreeSelection *sel,
|
||||
ColorDisplayDialog *cdd)
|
||||
{
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
GimpColorDisplay *filter = NULL;
|
||||
|
||||
if (cdd->selected)
|
||||
{
|
||||
g_object_remove_weak_pointer (G_OBJECT (cdd->selected),
|
||||
(gpointer) &cdd->selected);
|
||||
cdd->selected = NULL;
|
||||
}
|
||||
|
||||
if (gtk_tree_selection_get_selected (sel, &model, &iter))
|
||||
{
|
||||
GValue val = { 0, };
|
||||
|
||||
gtk_tree_model_get_value (model, &iter, 1, &val);
|
||||
|
||||
filter = g_value_get_pointer (&val);
|
||||
|
||||
g_value_unset (&val);
|
||||
}
|
||||
|
||||
gtk_widget_set_sensitive (cdd->remove_button, (filter != NULL));
|
||||
gtk_widget_set_sensitive (cdd->reset_button, (filter != NULL));
|
||||
|
||||
if (cdd->config_widget)
|
||||
gtk_container_remove (GTK_CONTAINER (cdd->config_box), cdd->config_widget);
|
||||
|
||||
if (filter)
|
||||
{
|
||||
gchar *str;
|
||||
|
||||
cdd->selected = filter;
|
||||
|
||||
g_object_add_weak_pointer (G_OBJECT (filter), (gpointer) &cdd->selected);
|
||||
|
||||
cdd->config_widget = gimp_color_display_configure (filter);
|
||||
|
||||
str = g_strdup_printf (_("Configure Selected Filter: %s"),
|
||||
GIMP_COLOR_DISPLAY_GET_CLASS (filter)->name);
|
||||
gtk_frame_set_label (GTK_FRAME (cdd->config_frame), str);
|
||||
g_free (str);
|
||||
g_object_weak_ref (G_OBJECT (cdd->dialog),
|
||||
(GWeakNotify) g_object_unref, cdd->old_stack);
|
||||
}
|
||||
else
|
||||
{
|
||||
cdd->config_widget = gtk_label_new (_("No Filter Selected"));
|
||||
gtk_widget_set_sensitive (cdd->config_widget, FALSE);
|
||||
GimpColorDisplayStack *stack = gimp_color_display_stack_new ();
|
||||
|
||||
gtk_frame_set_label (GTK_FRAME (cdd->config_frame),
|
||||
_("Configure Selected Filter"));
|
||||
gimp_display_shell_filter_set (shell, stack);
|
||||
g_object_unref (stack);
|
||||
}
|
||||
|
||||
if (cdd->config_widget)
|
||||
{
|
||||
gtk_box_pack_start (GTK_BOX (cdd->config_box), cdd->config_widget,
|
||||
FALSE, FALSE, 0);
|
||||
gtk_widget_show (cdd->config_widget);
|
||||
editor = gimp_color_display_editor_new (shell->filter_stack);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (editor), 6);
|
||||
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (cdd->dialog)->vbox), editor);
|
||||
gtk_widget_show (editor);
|
||||
|
||||
g_object_add_weak_pointer (G_OBJECT (cdd->config_widget),
|
||||
(gpointer) &cdd->config_widget);
|
||||
}
|
||||
|
||||
color_display_update_up_and_down (cdd);
|
||||
return cdd->dialog;
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
static void
|
||||
selected_filter_reset (GtkWidget *widget,
|
||||
ColorDisplayDialog *cdd)
|
||||
gimp_display_shell_filter_dialog_response (GtkWidget *widget,
|
||||
gint response_id,
|
||||
ColorDisplayDialog *cdd)
|
||||
{
|
||||
if (cdd->selected)
|
||||
gimp_color_display_configure_reset (cdd->selected);
|
||||
if (response_id != GTK_RESPONSE_OK)
|
||||
gimp_display_shell_filter_set (cdd->shell, cdd->old_stack);
|
||||
|
||||
gtk_widget_destroy (GTK_WIDGET (cdd->dialog));
|
||||
}
|
||||
|
|
|
@ -31,6 +31,8 @@ libappwidgets_a_sources = \
|
|||
gimpcellrendererviewable.h \
|
||||
gimpchanneltreeview.c \
|
||||
gimpchanneltreeview.h \
|
||||
gimpcolordisplayeditor.c \
|
||||
gimpcolordisplayeditor.h \
|
||||
gimpcoloreditor.c \
|
||||
gimpcoloreditor.h \
|
||||
gimpcolorframe.c \
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,77 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimpcolordisplayeditor.h
|
||||
* Copyright (C) 2003 Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_COLOR_DISPLAY_EDITOR_H__
|
||||
#define __GIMP_COLOR_DISPLAY_EDITOR_H__
|
||||
|
||||
|
||||
#include "gimpeditor.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_COLOR_DISPLAY_EDITOR (gimp_color_display_editor_get_type ())
|
||||
#define GIMP_COLOR_DISPLAY_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_COLOR_DISPLAY_EDITOR, GimpColorDisplayEditor))
|
||||
#define GIMP_COLOR_DISPLAY_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_COLOR_DISPLAY_EDITOR, GimpColorDisplayEditorClass))
|
||||
#define GIMP_IS_COLOR_DISPLAY_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_COLOR_DISPLAY_EDITOR))
|
||||
#define GIMP_IS_COLOR_DISPLAY_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_COLOR_DISPLAY_EDITOR))
|
||||
#define GIMP_COLOR_DISPLAY_EDITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_COLOR_DISPLAY_EDITOR, GimpColorDisplayEditorClass))
|
||||
|
||||
|
||||
typedef struct _GimpColorDisplayEditorClass GimpColorDisplayEditorClass;
|
||||
|
||||
struct _GimpColorDisplayEditor
|
||||
{
|
||||
GtkVBox parent_instance;
|
||||
|
||||
GimpColorDisplayStack *stack;
|
||||
|
||||
GtkListStore *src;
|
||||
GtkListStore *dest;
|
||||
|
||||
GtkTreeSelection *src_sel;
|
||||
GtkTreeSelection *dest_sel;
|
||||
|
||||
GimpColorDisplay *selected;
|
||||
|
||||
GtkWidget *add_button;
|
||||
|
||||
GtkWidget *remove_button;
|
||||
GtkWidget *up_button;
|
||||
GtkWidget *down_button;
|
||||
|
||||
GtkWidget *config_frame;
|
||||
GtkWidget *config_box;
|
||||
GtkWidget *config_widget;
|
||||
|
||||
GtkWidget *reset_button;
|
||||
};
|
||||
|
||||
struct _GimpColorDisplayEditorClass
|
||||
{
|
||||
GtkVBoxClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
GType gimp_color_display_editor_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget * gimp_color_display_editor_new (GimpColorDisplayStack *stack);
|
||||
|
||||
|
||||
#endif /* __GIMP_COLOR_DISPLAY_EDITOR_H__ */
|
|
@ -111,6 +111,7 @@ typedef struct _GimpHistogramBox GimpHistogramBox;
|
|||
typedef struct _GimpHistogramEditor GimpHistogramEditor;
|
||||
|
||||
typedef struct _GimpTextEditor GimpTextEditor;
|
||||
typedef struct _GimpColorDisplayEditor GimpColorDisplayEditor;
|
||||
|
||||
|
||||
/* structs */
|
||||
|
|
|
@ -29,11 +29,15 @@
|
|||
|
||||
#include "gimpcolordisplay.h"
|
||||
#include "gimpcolordisplaystack.h"
|
||||
#include "gimpwidgetsmarshal.h"
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
CHANGED,
|
||||
ADDED,
|
||||
REMOVED,
|
||||
REORDERED,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
|
@ -94,9 +98,44 @@ gimp_color_display_stack_class_init (GimpColorDisplayStackClass *klass)
|
|||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
stack_signals[ADDED] =
|
||||
g_signal_new ("added",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GimpColorDisplayStackClass, added),
|
||||
NULL, NULL,
|
||||
_gimp_widgets_marshal_VOID__OBJECT_INT,
|
||||
G_TYPE_NONE, 2,
|
||||
GIMP_TYPE_COLOR_DISPLAY,
|
||||
G_TYPE_INT);
|
||||
|
||||
stack_signals[REMOVED] =
|
||||
g_signal_new ("removed",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GimpColorDisplayStackClass, removed),
|
||||
NULL, NULL,
|
||||
_gimp_widgets_marshal_VOID__OBJECT,
|
||||
G_TYPE_NONE, 1,
|
||||
GIMP_TYPE_COLOR_DISPLAY);
|
||||
|
||||
stack_signals[REORDERED] =
|
||||
g_signal_new ("reordered",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GimpColorDisplayStackClass, reordered),
|
||||
NULL, NULL,
|
||||
_gimp_widgets_marshal_VOID__OBJECT_INT,
|
||||
G_TYPE_NONE, 2,
|
||||
GIMP_TYPE_COLOR_DISPLAY,
|
||||
G_TYPE_INT);
|
||||
|
||||
object_class->finalize = gimp_color_display_stack_finalize;
|
||||
|
||||
klass->changed = NULL;
|
||||
klass->added = NULL;
|
||||
klass->removed = NULL;
|
||||
klass->reordered = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -176,6 +215,9 @@ gimp_color_display_stack_add (GimpColorDisplayStack *stack,
|
|||
G_OBJECT (stack),
|
||||
G_CONNECT_SWAPPED);
|
||||
|
||||
g_signal_emit (stack, stack_signals[ADDED], 0,
|
||||
display, g_list_length (stack->filters) - 1);
|
||||
|
||||
gimp_color_display_stack_changed (stack);
|
||||
}
|
||||
|
||||
|
@ -192,9 +234,12 @@ gimp_color_display_stack_remove (GimpColorDisplayStack *stack,
|
|||
stack);
|
||||
|
||||
stack->filters = g_list_remove (stack->filters, display);
|
||||
g_object_unref (display);
|
||||
|
||||
g_signal_emit (stack, stack_signals[REMOVED], 0, display);
|
||||
|
||||
gimp_color_display_stack_changed (stack);
|
||||
|
||||
g_object_unref (display);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -215,6 +260,9 @@ gimp_color_display_stack_reorder_up (GimpColorDisplayStack *stack,
|
|||
list->data = list->prev->data;
|
||||
list->prev->data = display;
|
||||
|
||||
g_signal_emit (stack, stack_signals[REORDERED], 0,
|
||||
display, g_list_position (stack->filters, list->prev));
|
||||
|
||||
gimp_color_display_stack_changed (stack);
|
||||
}
|
||||
}
|
||||
|
@ -237,6 +285,9 @@ gimp_color_display_stack_reorder_down (GimpColorDisplayStack *stack,
|
|||
list->data = list->next->data;
|
||||
list->next->data = display;
|
||||
|
||||
g_signal_emit (stack, stack_signals[REORDERED], 0,
|
||||
display, g_list_position (stack->filters, list->next));
|
||||
|
||||
gimp_color_display_stack_changed (stack);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,16 @@ struct _GimpColorDisplayStackClass
|
|||
{
|
||||
GObjectClass parent_class;
|
||||
|
||||
void (* changed) (GimpColorDisplayStack *stack);
|
||||
void (* changed) (GimpColorDisplayStack *stack);
|
||||
|
||||
void (* added) (GimpColorDisplayStack *stack,
|
||||
GimpColorDisplay *display,
|
||||
gint position);
|
||||
void (* removed) (GimpColorDisplayStack *stack,
|
||||
GimpColorDisplay *display);
|
||||
void (* reordered) (GimpColorDisplayStack *stack,
|
||||
GimpColorDisplay *display,
|
||||
gint position);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -24,4 +24,6 @@
|
|||
|
||||
VOID: INT
|
||||
VOID: INT, INT
|
||||
VOID: OBJECT
|
||||
VOID: OBJECT, INT
|
||||
VOID: POINTER, POINTER
|
||||
|
|
Loading…
Reference in New Issue