1998-11-05 07:30:18 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
* Copyright (C) 1998 Andy Thomas.
|
|
|
|
*
|
|
|
|
* Gradient editor module copyight (C) 1996-1997 Federico Mena Quintero
|
|
|
|
* federico@nuclecu.unam.mx
|
|
|
|
*
|
|
|
|
* 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 PURIGHTE. 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* This is the popup for the gradient selection stuff..
|
|
|
|
* idea is a cut down version of the gradient selection widget
|
|
|
|
* just a clist on which each gradient can be selected.
|
|
|
|
* Of course all the support functions for getting the slected gradient and
|
|
|
|
* setting the slection all need to be done as well.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Main structure for the dialog. There can be multiple of these
|
|
|
|
* so every thing has to go into the strcuture and we have to have a list
|
|
|
|
* the structures so we can find which one we are taking about.
|
|
|
|
*/
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "appenv.h"
|
1999-09-28 01:58:10 +08:00
|
|
|
#include "dialog_handler.h"
|
1999-10-27 02:27:27 +08:00
|
|
|
#include "gimpcontext.h"
|
1999-10-28 23:05:49 +08:00
|
|
|
#include "gimpdnd.h"
|
1999-09-28 01:58:10 +08:00
|
|
|
#include "gimpui.h"
|
1998-11-05 07:30:18 +08:00
|
|
|
#include "gradient_header.h"
|
1999-10-28 23:05:49 +08:00
|
|
|
#include "gradientP.h"
|
|
|
|
#include "gradient_select.h"
|
1998-11-05 07:30:18 +08:00
|
|
|
#include "session.h"
|
|
|
|
|
1998-12-16 08:37:09 +08:00
|
|
|
#include "libgimp/gimpintl.h"
|
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
static void gradient_change_callbacks (GradientSelect *gsp,
|
|
|
|
gboolean closing);
|
1999-11-03 17:58:46 +08:00
|
|
|
static gradient_t * gradient_select_drag_gradient (GtkWidget *widget,
|
|
|
|
gpointer data);
|
1999-10-28 23:05:49 +08:00
|
|
|
static void gradient_select_drop_gradient (GtkWidget *widget,
|
|
|
|
gradient_t *gradient,
|
|
|
|
gpointer data);
|
|
|
|
static void gradient_select_gradient_changed (GimpContext *context,
|
|
|
|
gradient_t *gradient,
|
|
|
|
GradientSelect *gsp);
|
|
|
|
static void gradient_select_select (GradientSelect *gsp,
|
|
|
|
gradient_t *gradient);
|
|
|
|
|
1999-11-03 17:58:46 +08:00
|
|
|
static gint gradient_select_button_press (GtkWidget *widget,
|
|
|
|
GdkEventButton *bevent,
|
|
|
|
gpointer data);
|
1999-10-28 23:05:49 +08:00
|
|
|
static void gradient_select_list_item_update (GtkWidget *widget,
|
|
|
|
gint row,
|
|
|
|
gint column,
|
|
|
|
GdkEventButton *event,
|
|
|
|
gpointer data);
|
|
|
|
|
|
|
|
static void gradient_select_close_callback (GtkWidget *widget,
|
|
|
|
gpointer data);
|
|
|
|
static void gradient_select_edit_callback (GtkWidget *widget,
|
|
|
|
gpointer data);
|
|
|
|
|
|
|
|
/* dnd stuff */
|
|
|
|
static GtkTargetEntry clist_target_table[] =
|
|
|
|
{
|
|
|
|
GIMP_TARGET_GRADIENT
|
|
|
|
};
|
|
|
|
static guint clist_n_targets = (sizeof (clist_target_table) /
|
|
|
|
sizeof (clist_target_table[0]));
|
1998-11-05 07:30:18 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
/* list of active dialogs */
|
|
|
|
GSList *gradient_active_dialogs = NULL;
|
1998-11-05 07:30:18 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
/* the main gradient selection dialog */
|
|
|
|
GradientSelect *gradient_select_dialog = NULL;
|
1998-11-05 07:30:18 +08:00
|
|
|
|
|
|
|
void
|
1999-10-28 23:05:49 +08:00
|
|
|
gradient_dialog_create (void)
|
1998-11-05 07:30:18 +08:00
|
|
|
{
|
1999-10-28 23:05:49 +08:00
|
|
|
if (! gradient_select_dialog)
|
1998-11-05 07:30:18 +08:00
|
|
|
{
|
1999-10-28 23:05:49 +08:00
|
|
|
gradient_select_dialog = gradient_select_new (NULL, NULL);
|
1998-11-05 07:30:18 +08:00
|
|
|
}
|
1999-10-28 23:05:49 +08:00
|
|
|
else
|
1998-11-05 07:30:18 +08:00
|
|
|
{
|
1999-10-28 23:05:49 +08:00
|
|
|
if (!GTK_WIDGET_VISIBLE (gradient_select_dialog->shell))
|
|
|
|
gtk_widget_show (gradient_select_dialog->shell);
|
|
|
|
else
|
|
|
|
gdk_window_raise (gradient_select_dialog->shell->window);
|
1998-11-05 07:30:18 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-10-28 23:05:49 +08:00
|
|
|
gradient_dialog_free (void)
|
1998-11-05 07:30:18 +08:00
|
|
|
{
|
1999-10-28 23:05:49 +08:00
|
|
|
if (gradient_select_dialog)
|
1998-11-05 07:30:18 +08:00
|
|
|
{
|
1999-10-28 23:05:49 +08:00
|
|
|
session_get_window_info (gradient_select_dialog->shell,
|
|
|
|
&gradient_select_session_info);
|
1999-10-27 02:27:27 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
gradient_select_free (gradient_select_dialog);
|
|
|
|
gradient_select_dialog = NULL;
|
1998-11-05 07:30:18 +08:00
|
|
|
|
|
|
|
}
|
1999-10-28 23:05:49 +08:00
|
|
|
|
|
|
|
gradient_editor_free ();
|
1998-11-05 07:30:18 +08:00
|
|
|
}
|
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
/* If title == NULL then it is the main gradient select dialog */
|
|
|
|
GradientSelect *
|
|
|
|
gradient_select_new (gchar *title,
|
|
|
|
gchar *initial_gradient)
|
1998-11-05 07:30:18 +08:00
|
|
|
{
|
1999-12-02 21:00:18 +08:00
|
|
|
GradientSelect *gsp;
|
1999-10-28 23:05:49 +08:00
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *scrolled_win;
|
|
|
|
GdkColormap *colormap;
|
1999-12-02 21:00:18 +08:00
|
|
|
gchar *titles[2];
|
1999-10-28 23:05:49 +08:00
|
|
|
gint select_pos;
|
1998-11-05 07:30:18 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
gradient_t *active = NULL;
|
1999-10-27 02:27:27 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
static gboolean first_call = TRUE;
|
1998-11-05 07:30:18 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
gsp = g_new (GradientSelect, 1);
|
|
|
|
gsp->callback_name = NULL;
|
1999-11-03 17:58:46 +08:00
|
|
|
gsp->dnd_gradient = NULL;
|
1999-10-28 23:05:49 +08:00
|
|
|
|
|
|
|
/* The shell */
|
|
|
|
gsp->shell = gimp_dialog_new (title ? title : _("Gradient Selection"),
|
|
|
|
"gradient_selection",
|
|
|
|
gimp_standard_help_func,
|
|
|
|
"dialogs/gradient_selection.html",
|
|
|
|
GTK_WIN_POS_NONE,
|
|
|
|
FALSE, TRUE, FALSE,
|
1998-11-05 07:30:18 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
_("Edit"), gradient_select_edit_callback,
|
|
|
|
gsp, NULL, FALSE, FALSE,
|
|
|
|
_("Close"), gradient_select_close_callback,
|
|
|
|
gsp, NULL, TRUE, TRUE,
|
1998-11-05 07:30:18 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
NULL);
|
1999-10-27 02:27:27 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
if (title)
|
|
|
|
{
|
|
|
|
gsp->context = gimp_context_new (title, NULL);
|
1998-11-05 07:30:18 +08:00
|
|
|
}
|
1999-10-28 23:05:49 +08:00
|
|
|
else
|
1998-11-05 07:30:18 +08:00
|
|
|
{
|
1999-10-28 23:05:49 +08:00
|
|
|
gsp->context = gimp_context_get_user ();
|
|
|
|
|
|
|
|
session_set_window_geometry (gsp->shell, &gradient_select_session_info,
|
|
|
|
TRUE);
|
|
|
|
dialog_register (gsp->shell);
|
1998-11-05 07:30:18 +08:00
|
|
|
}
|
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
if (no_data && first_call)
|
|
|
|
gradients_init (FALSE);
|
1998-11-05 07:30:18 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
first_call = FALSE;
|
|
|
|
|
|
|
|
if (title && initial_gradient && strlen (initial_gradient))
|
1998-11-05 07:30:18 +08:00
|
|
|
{
|
1999-10-28 23:05:49 +08:00
|
|
|
active = gradient_list_get_gradient (gradients_list, initial_gradient);
|
1998-11-05 07:30:18 +08:00
|
|
|
}
|
1999-10-28 23:05:49 +08:00
|
|
|
else
|
1998-11-05 07:30:18 +08:00
|
|
|
{
|
1999-10-28 23:05:49 +08:00
|
|
|
active = gimp_context_get_gradient (gimp_context_get_user ());
|
1998-11-05 07:30:18 +08:00
|
|
|
}
|
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
if (!active)
|
1998-11-05 07:30:18 +08:00
|
|
|
{
|
1999-10-28 23:05:49 +08:00
|
|
|
active = gimp_context_get_gradient (gimp_context_get_standard ());
|
1998-11-05 07:30:18 +08:00
|
|
|
}
|
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
if (title)
|
1998-11-05 07:30:18 +08:00
|
|
|
{
|
1999-10-28 23:05:49 +08:00
|
|
|
gimp_context_set_gradient (gsp->context, active);
|
1998-11-05 07:30:18 +08:00
|
|
|
}
|
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
vbox = gtk_vbox_new (FALSE, 0);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
|
|
|
|
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (gsp->shell)->vbox), vbox);
|
1998-11-05 07:30:18 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
/* clist preview of gradients */
|
|
|
|
scrolled_win = gtk_scrolled_window_new (NULL, NULL);
|
1999-12-02 21:00:18 +08:00
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
|
|
|
|
GTK_POLICY_AUTOMATIC,
|
|
|
|
GTK_POLICY_ALWAYS);
|
|
|
|
gtk_container_add (GTK_CONTAINER (vbox), scrolled_win);
|
|
|
|
gtk_widget_show (scrolled_win);
|
1999-10-27 02:27:27 +08:00
|
|
|
|
1999-12-02 21:00:18 +08:00
|
|
|
titles[0] = _("Gradient");
|
|
|
|
titles[1] = _("Name");
|
|
|
|
gsp->clist = gtk_clist_new_with_titles (2, titles);
|
1999-10-28 23:05:49 +08:00
|
|
|
gtk_clist_set_shadow_type (GTK_CLIST (gsp->clist), GTK_SHADOW_IN);
|
1999-11-03 17:58:46 +08:00
|
|
|
gtk_clist_set_selection_mode (GTK_CLIST (gsp->clist), GTK_SELECTION_BROWSE);
|
1999-12-02 21:00:18 +08:00
|
|
|
gtk_clist_set_row_height (GTK_CLIST (gsp->clist), 18);
|
1999-11-03 17:58:46 +08:00
|
|
|
gtk_clist_set_use_drag_icons (GTK_CLIST (gsp->clist), FALSE);
|
|
|
|
gtk_clist_column_titles_passive (GTK_CLIST (gsp->clist));
|
1999-12-02 21:00:18 +08:00
|
|
|
gtk_widget_set_usize (gsp->clist, 200, 250);
|
1999-10-28 23:05:49 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (scrolled_win), gsp->clist);
|
1998-11-05 07:30:18 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
gtk_widget_show (gsp->clist);
|
1998-11-05 07:30:18 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
colormap = gtk_widget_get_colormap (gsp->clist);
|
|
|
|
gdk_color_parse ("black", &gsp->black);
|
|
|
|
gdk_color_alloc (colormap, &gsp->black);
|
1998-11-05 07:30:18 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
gtk_widget_realize (gsp->shell);
|
|
|
|
gsp->gc = gdk_gc_new (gsp->shell->window);
|
1998-11-05 07:30:18 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
select_pos = gradient_clist_init (gsp->shell, gsp->gc, gsp->clist, active);
|
1998-11-05 07:30:18 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
/* Now show the dialog */
|
|
|
|
gtk_widget_show (vbox);
|
|
|
|
gtk_widget_show (gsp->shell);
|
1998-11-05 07:30:18 +08:00
|
|
|
|
1999-11-03 17:58:46 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (gsp->clist), "button_press_event",
|
|
|
|
GTK_SIGNAL_FUNC (gradient_select_button_press),
|
|
|
|
(gpointer) gsp);
|
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (gsp->clist), "select_row",
|
|
|
|
GTK_SIGNAL_FUNC (gradient_select_list_item_update),
|
|
|
|
(gpointer) gsp);
|
1998-11-05 07:30:18 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (gsp->context), "gradient_changed",
|
|
|
|
GTK_SIGNAL_FUNC (gradient_select_gradient_changed),
|
1999-11-03 17:58:46 +08:00
|
|
|
(gpointer) gsp);
|
|
|
|
|
|
|
|
/* dnd stuff */
|
|
|
|
gtk_drag_source_set (gsp->clist,
|
|
|
|
GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
|
|
|
|
clist_target_table, clist_n_targets,
|
|
|
|
GDK_ACTION_COPY);
|
|
|
|
gimp_dnd_gradient_source_set (gsp->clist, gradient_select_drag_gradient, gsp);
|
|
|
|
|
|
|
|
gtk_drag_dest_set (gsp->clist,
|
|
|
|
GTK_DEST_DEFAULT_ALL,
|
|
|
|
clist_target_table, clist_n_targets,
|
|
|
|
GDK_ACTION_COPY);
|
|
|
|
gimp_dnd_gradient_dest_set (gsp->clist, gradient_select_drop_gradient, gsp);
|
1998-11-05 07:30:18 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
if (active)
|
|
|
|
gradient_select_select (gsp, active);
|
|
|
|
|
|
|
|
/* Add to active gradient dialogs list */
|
|
|
|
gradient_active_dialogs = g_slist_append (gradient_active_dialogs, gsp);
|
|
|
|
|
|
|
|
return gsp;
|
1998-11-05 07:30:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-10-28 23:05:49 +08:00
|
|
|
gradient_select_free (GradientSelect *gsp)
|
1998-11-05 07:30:18 +08:00
|
|
|
{
|
1999-10-28 23:05:49 +08:00
|
|
|
if (!gsp)
|
|
|
|
return;
|
1999-09-28 01:58:10 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
/* remove from active list */
|
|
|
|
gradient_active_dialogs = g_slist_remove (gradient_active_dialogs, gsp);
|
1998-11-05 07:30:18 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
gtk_signal_disconnect_by_data (GTK_OBJECT (gsp->context), gsp);
|
1999-10-27 02:27:27 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
if (gsp->callback_name)
|
|
|
|
{
|
|
|
|
g_free (gsp->callback_name);
|
|
|
|
gtk_object_unref (GTK_OBJECT (gsp->context));
|
1998-11-05 07:30:18 +08:00
|
|
|
}
|
1999-10-28 23:05:49 +08:00
|
|
|
|
|
|
|
g_free (gsp);
|
1998-11-05 07:30:18 +08:00
|
|
|
}
|
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
/* Call this dialog's PDB callback */
|
|
|
|
|
1998-11-05 07:30:18 +08:00
|
|
|
static void
|
1999-10-28 23:05:49 +08:00
|
|
|
gradient_change_callbacks (GradientSelect *gsp,
|
|
|
|
gboolean closing)
|
1998-11-05 07:30:18 +08:00
|
|
|
{
|
|
|
|
gchar * name;
|
|
|
|
ProcRecord *prec = NULL;
|
1999-10-28 23:05:49 +08:00
|
|
|
gradient_t *gradient;
|
|
|
|
gint nreturn_vals;
|
|
|
|
static gboolean busy = FALSE;
|
1998-11-05 07:30:18 +08:00
|
|
|
|
|
|
|
/* Any procs registered to callback? */
|
|
|
|
Argument *return_vals;
|
1999-09-28 01:58:10 +08:00
|
|
|
|
|
|
|
if (!gsp || !gsp->callback_name || busy != 0)
|
1998-11-05 07:30:18 +08:00
|
|
|
return;
|
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
busy = TRUE;
|
1998-11-05 07:30:18 +08:00
|
|
|
name = gsp->callback_name;
|
1999-10-28 23:05:49 +08:00
|
|
|
gradient = gimp_context_get_gradient (gsp->context);
|
1998-11-05 07:30:18 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
/* If its still registered run it */
|
1999-09-28 01:58:10 +08:00
|
|
|
prec = procedural_db_lookup (name);
|
1998-11-05 07:30:18 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
if (prec && gradient)
|
1998-11-05 07:30:18 +08:00
|
|
|
{
|
|
|
|
gdouble *values, *pv;
|
|
|
|
double pos, delta;
|
|
|
|
double r, g, b, a;
|
|
|
|
int i = gsp->sample_size;
|
|
|
|
pos = 0.0;
|
|
|
|
delta = 1.0 / (i - 1);
|
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
values = g_new (gdouble, 4 * i);
|
1998-11-05 07:30:18 +08:00
|
|
|
pv = values;
|
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
while (i--)
|
|
|
|
{
|
1999-10-28 23:05:49 +08:00
|
|
|
gradient_get_color_at (gradient, pos, &r, &g, &b, &a);
|
1999-09-28 01:58:10 +08:00
|
|
|
|
|
|
|
*pv++ = r;
|
|
|
|
*pv++ = g;
|
|
|
|
*pv++ = b;
|
|
|
|
*pv++ = a;
|
|
|
|
|
|
|
|
pos += delta;
|
|
|
|
}
|
1998-11-05 07:30:18 +08:00
|
|
|
|
|
|
|
return_vals = procedural_db_run_proc (name,
|
|
|
|
&nreturn_vals,
|
1999-10-28 23:05:49 +08:00
|
|
|
PDB_STRING, gradient->name,
|
|
|
|
PDB_INT32, gsp->sample_size * 4,
|
1999-09-28 01:58:10 +08:00
|
|
|
PDB_FLOATARRAY, values,
|
1999-10-28 23:05:49 +08:00
|
|
|
PDB_INT32, (gint) closing,
|
1998-11-05 07:30:18 +08:00
|
|
|
PDB_END);
|
|
|
|
|
|
|
|
if (!return_vals || return_vals[0].value.pdb_int != PDB_SUCCESS)
|
1999-05-30 00:35:47 +08:00
|
|
|
g_message ("failed to run gradient callback function");
|
1998-11-05 07:30:18 +08:00
|
|
|
else
|
|
|
|
procedural_db_destroy_args (return_vals, nreturn_vals);
|
|
|
|
}
|
1999-10-28 23:05:49 +08:00
|
|
|
busy = FALSE;
|
1998-11-05 07:30:18 +08:00
|
|
|
}
|
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
/* Close active dialogs that no longer have PDB registered for them */
|
|
|
|
|
|
|
|
void
|
|
|
|
gradients_check_dialogs (void)
|
1998-11-05 07:30:18 +08:00
|
|
|
{
|
1999-10-28 23:05:49 +08:00
|
|
|
GradientSelect *gsp;
|
|
|
|
GSList *list;
|
|
|
|
gchar *name;
|
|
|
|
ProcRecord *prec = NULL;
|
1998-11-05 07:30:18 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
list = gradient_active_dialogs;
|
1998-11-05 07:30:18 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
while (list)
|
1998-11-05 07:30:18 +08:00
|
|
|
{
|
1999-10-28 23:05:49 +08:00
|
|
|
gsp = (GradientSelect *) list->data;
|
|
|
|
list = g_slist_next (list);
|
|
|
|
|
|
|
|
name = gsp->callback_name;
|
|
|
|
|
|
|
|
if (name)
|
|
|
|
{
|
|
|
|
prec = procedural_db_lookup (name);
|
|
|
|
|
|
|
|
if (!prec)
|
|
|
|
{
|
|
|
|
/* Can alter gradient_active_dialogs list */
|
|
|
|
gradient_select_close_callback (NULL, gsp);
|
|
|
|
}
|
|
|
|
}
|
1998-11-05 07:30:18 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
void
|
|
|
|
gradient_select_rename_all (gint n,
|
|
|
|
gradient_t *gradient)
|
1998-11-05 07:30:18 +08:00
|
|
|
{
|
1999-10-28 23:05:49 +08:00
|
|
|
GradientSelect *gsp;
|
|
|
|
GSList *list;
|
1998-11-05 07:30:18 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
for (list = gradient_active_dialogs; list; list = g_slist_next (list))
|
1998-11-05 07:30:18 +08:00
|
|
|
{
|
1999-10-28 23:05:49 +08:00
|
|
|
gsp = (GradientSelect *) list->data;
|
|
|
|
|
|
|
|
gtk_clist_set_text (GTK_CLIST (gsp->clist), n, 1, gradient->name);
|
1998-11-05 07:30:18 +08:00
|
|
|
}
|
1999-10-28 23:05:49 +08:00
|
|
|
}
|
1998-11-05 07:30:18 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
void
|
|
|
|
gradient_select_insert_all (gint pos,
|
|
|
|
gradient_t *gradient)
|
|
|
|
{
|
|
|
|
GradientSelect *gsp;
|
|
|
|
GSList *list;
|
1999-01-11 07:20:33 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
for (list = gradient_active_dialogs; list; list = g_slist_next (list))
|
|
|
|
{
|
|
|
|
gsp = (GradientSelect *) list->data;
|
1999-09-28 01:58:10 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
gtk_clist_freeze (GTK_CLIST (gsp->clist));
|
|
|
|
gradient_clist_insert (gsp->shell, gsp->gc, gsp->clist,
|
|
|
|
gradient, pos, FALSE);
|
|
|
|
gtk_clist_thaw (GTK_CLIST (gsp->clist));
|
|
|
|
}
|
|
|
|
}
|
1998-11-05 07:30:18 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
void
|
|
|
|
gradient_select_delete_all (gint n)
|
|
|
|
{
|
|
|
|
GradientSelect *gsp;
|
|
|
|
GSList *list;
|
1998-11-05 07:30:18 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
for (list = gradient_active_dialogs; list; list = g_slist_next (list))
|
|
|
|
{
|
|
|
|
gsp = (GradientSelect *) list->data;
|
1998-11-06 07:10:31 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
gtk_clist_remove (GTK_CLIST (gsp->clist), n);
|
|
|
|
}
|
|
|
|
}
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
void
|
|
|
|
gradient_select_free_all (void)
|
|
|
|
{
|
|
|
|
GradientSelect *gsp;
|
|
|
|
GSList *list;
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
for (list = gradient_active_dialogs; list; list = g_slist_next (list))
|
|
|
|
{
|
|
|
|
gsp = (GradientSelect *) list->data;
|
1998-11-05 07:30:18 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
gtk_clist_freeze (GTK_CLIST (gsp->clist));
|
|
|
|
gtk_clist_clear (GTK_CLIST (gsp->clist));
|
|
|
|
gtk_clist_thaw (GTK_CLIST (gsp->clist));
|
|
|
|
}
|
|
|
|
}
|
1998-11-06 07:10:31 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
void
|
|
|
|
gradient_select_refill_all (void)
|
|
|
|
{
|
|
|
|
GradientSelect *gsp;
|
|
|
|
GSList *list;
|
|
|
|
gint index = -1;
|
1998-11-05 07:30:18 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
for (list = gradient_active_dialogs; list; list = g_slist_next (list))
|
|
|
|
{
|
|
|
|
gsp = (GradientSelect *) list->data;
|
1998-11-05 07:30:18 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
index = gradient_clist_init (gsp->shell, gsp->gc, gsp->clist,
|
|
|
|
gimp_context_get_gradient (gsp->context));
|
|
|
|
|
|
|
|
if (index != -1)
|
|
|
|
gradient_select_select (gsp, gimp_context_get_gradient (gsp->context));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gradient_select_update_all (gint row,
|
|
|
|
gradient_t *gradient)
|
|
|
|
{
|
|
|
|
GSList *list;
|
|
|
|
GradientSelect *gsp;
|
1998-11-05 07:30:18 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
for (list = gradient_active_dialogs; list; list = g_slist_next (list))
|
1998-11-05 07:30:18 +08:00
|
|
|
{
|
1999-10-28 23:05:49 +08:00
|
|
|
gsp = (GradientSelect *) list->data;
|
1999-10-27 02:27:27 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
gtk_clist_set_text (GTK_CLIST (gsp->clist), row, 1, gradient->name);
|
|
|
|
}
|
|
|
|
}
|
1998-11-05 07:30:18 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
/*
|
|
|
|
* Local functions
|
|
|
|
*/
|
1998-11-05 07:30:18 +08:00
|
|
|
|
1999-11-03 17:58:46 +08:00
|
|
|
static gradient_t *
|
|
|
|
gradient_select_drag_gradient (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GradientSelect *gsp;
|
|
|
|
|
|
|
|
gsp = (GradientSelect *) data;
|
|
|
|
|
|
|
|
return gsp->dnd_gradient;
|
|
|
|
}
|
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
static void
|
|
|
|
gradient_select_drop_gradient (GtkWidget *widget,
|
|
|
|
gradient_t *gradient,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GradientSelect *gsp;
|
1998-11-05 07:30:18 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
gsp = (GradientSelect *) data;
|
1998-11-05 07:30:18 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
gimp_context_set_gradient (gsp->context, gradient);
|
|
|
|
}
|
1998-11-05 07:30:18 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
static void
|
|
|
|
gradient_select_gradient_changed (GimpContext *context,
|
|
|
|
gradient_t *gradient,
|
|
|
|
GradientSelect *gsp)
|
|
|
|
{
|
|
|
|
if (gradient)
|
1999-10-29 22:15:55 +08:00
|
|
|
{
|
|
|
|
gradient_select_select (gsp, gradient);
|
|
|
|
|
|
|
|
if (gsp->callback_name)
|
|
|
|
gradient_change_callbacks (gsp, FALSE);
|
1999-11-03 17:58:46 +08:00
|
|
|
|
|
|
|
gsp->dnd_gradient = gradient;
|
1999-10-29 22:15:55 +08:00
|
|
|
}
|
1998-11-05 07:30:18 +08:00
|
|
|
}
|
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
static void
|
|
|
|
gradient_select_select (GradientSelect *gsp,
|
|
|
|
gradient_t *gradient)
|
1998-11-05 07:30:18 +08:00
|
|
|
{
|
1999-10-28 23:05:49 +08:00
|
|
|
gint index;
|
|
|
|
|
|
|
|
index = gradient_list_get_gradient_index (gradients_list, gradient);
|
|
|
|
|
|
|
|
if (index != -1)
|
1998-11-05 07:30:18 +08:00
|
|
|
{
|
1999-10-28 23:05:49 +08:00
|
|
|
gtk_signal_handler_block_by_data (GTK_OBJECT (gsp->clist), gsp);
|
1999-01-11 07:20:33 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
gtk_clist_select_row (GTK_CLIST (gsp->clist), index, -1);
|
|
|
|
gtk_clist_moveto (GTK_CLIST (gsp->clist), index, 0, 0.5, 0.0);
|
1999-01-11 07:20:33 +08:00
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
gtk_signal_handler_unblock_by_data (GTK_OBJECT (gsp->clist), gsp);
|
1998-11-05 07:30:18 +08:00
|
|
|
}
|
1999-10-28 23:05:49 +08:00
|
|
|
}
|
|
|
|
|
1999-11-03 17:58:46 +08:00
|
|
|
static gint
|
|
|
|
gradient_select_button_press (GtkWidget *widget,
|
|
|
|
GdkEventButton *bevent,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GradientSelect *gsp;
|
|
|
|
|
|
|
|
gsp = (GradientSelect *) data;
|
|
|
|
|
|
|
|
if (bevent->button == 2)
|
|
|
|
{
|
1999-11-14 18:50:19 +08:00
|
|
|
GSList *list = NULL;
|
1999-11-03 17:58:46 +08:00
|
|
|
gint row;
|
|
|
|
gint column;
|
|
|
|
|
|
|
|
gtk_clist_get_selection_info (GTK_CLIST (gsp->clist),
|
|
|
|
bevent->x, bevent->y,
|
|
|
|
&row, &column);
|
|
|
|
|
1999-11-14 18:50:19 +08:00
|
|
|
if (gradients_list)
|
|
|
|
list = g_slist_nth (gradients_list, row);
|
|
|
|
|
|
|
|
if (list)
|
|
|
|
gsp->dnd_gradient = (gradient_t *) list->data;
|
|
|
|
else
|
|
|
|
gsp->dnd_gradient = NULL;
|
1999-11-03 17:58:46 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
static void
|
|
|
|
gradient_select_list_item_update (GtkWidget *widget,
|
|
|
|
gint row,
|
|
|
|
gint column,
|
|
|
|
GdkEventButton *event,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GradientSelect *gsp;
|
|
|
|
GSList *list;
|
|
|
|
|
|
|
|
gsp = (GradientSelect *) data;
|
|
|
|
list = g_slist_nth (gradients_list, row);
|
|
|
|
|
|
|
|
gtk_signal_handler_block_by_data (GTK_OBJECT (gsp->context), gsp);
|
|
|
|
|
|
|
|
gimp_context_set_gradient (gsp->context, (gradient_t *) list->data);
|
|
|
|
|
|
|
|
gtk_signal_handler_unblock_by_data (GTK_OBJECT (gsp->context), gsp);
|
1999-11-03 17:58:46 +08:00
|
|
|
|
|
|
|
gsp->dnd_gradient = (gradient_t *) list->data;
|
|
|
|
|
|
|
|
if (gsp->callback_name)
|
|
|
|
gradient_change_callbacks (gsp, FALSE);
|
1999-10-28 23:05:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gradient_select_edit_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GradientSelect *gsp;
|
|
|
|
|
|
|
|
gsp = (GradientSelect *) data;
|
|
|
|
|
|
|
|
gradient_editor_create ();
|
|
|
|
|
|
|
|
if (gsp)
|
|
|
|
gradient_editor_set_gradient (gimp_context_get_gradient (gsp->context));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gradient_select_close_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GradientSelect *gsp;
|
|
|
|
|
|
|
|
gsp = (GradientSelect *) data;
|
|
|
|
|
|
|
|
if (GTK_WIDGET_VISIBLE (gsp->shell))
|
|
|
|
gtk_widget_hide (gsp->shell);
|
|
|
|
|
|
|
|
/* Free memory if poping down dialog which is not the main one */
|
|
|
|
if (gsp != gradient_select_dialog)
|
|
|
|
{
|
|
|
|
gradient_change_callbacks (gsp, TRUE);
|
|
|
|
gtk_widget_destroy (gsp->shell);
|
|
|
|
gradient_select_free (gsp);
|
1998-11-05 07:30:18 +08:00
|
|
|
}
|
|
|
|
}
|