gimp/app/gradient_select.c

632 lines
16 KiB
C
Raw Normal View History

/* 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"
app/Makefile.am app/gimphelp.[ch] new files 1999-09-27 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/gimphelp.[ch] * app/gimpui.[ch]: new files * app/interface.[ch] * app/preferences_dialog.[ch] The GIMP Help System part 1: Press "F1" in any dialog to pop up the help page for this dialog. Moved the widget constructors from preferences_dialog.[ch] and the query boxes from interface.[ch] to gimpui.[ch]. The dialog constructors take a help_func and a help_data parameter and install the "F1" accelerator which emits the new "help" signal. The "help" signal callback calls help_func(help_data) which finally has to call gimp_help() which in turn invokes the help browser. Still have to find a proper way to (1) prevent "F1" being assigned to some menu item and (2) to catch "F1" while browsing the menu trees in order to pop up the help for the selected item. * app/menus.c: a <Toolbox>/File/Help... menu item. * app/commands.[ch]: a command callback for the "Help..." menu item. * app/gimprc.[ch]: new boolean gimprc variable "use_help". * app/info_dialog.[ch]: pass a help function and data to the info dialog constructor. * app/tools.[ch]: store the tools help page names in the tool info structure. Export a special tools_help_func() which shows the help page for the active tool. * app/[all files calling a dialog constructor]: pass the dialog's help page to the constructor. Most dialogs are now created by gimp_dialog_new() which also sets up the action_area and the WM delete event callback, so I removed the resp. code from these files. Fixed some minor bugs and did some other stuff but didn't change any logic except dialog creation. * plug-ins/helpbrowser/helpbrowser.c: don't try to call a running help browser and don't install any menu path (all done in app/gimphelp.[ch] now).
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"
app/Makefile.am app/gimphelp.[ch] new files 1999-09-27 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/gimphelp.[ch] * app/gimpui.[ch]: new files * app/interface.[ch] * app/preferences_dialog.[ch] The GIMP Help System part 1: Press "F1" in any dialog to pop up the help page for this dialog. Moved the widget constructors from preferences_dialog.[ch] and the query boxes from interface.[ch] to gimpui.[ch]. The dialog constructors take a help_func and a help_data parameter and install the "F1" accelerator which emits the new "help" signal. The "help" signal callback calls help_func(help_data) which finally has to call gimp_help() which in turn invokes the help browser. Still have to find a proper way to (1) prevent "F1" being assigned to some menu item and (2) to catch "F1" while browsing the menu trees in order to pop up the help for the selected item. * app/menus.c: a <Toolbox>/File/Help... menu item. * app/commands.[ch]: a command callback for the "Help..." menu item. * app/gimprc.[ch]: new boolean gimprc variable "use_help". * app/info_dialog.[ch]: pass a help function and data to the info dialog constructor. * app/tools.[ch]: store the tools help page names in the tool info structure. Export a special tools_help_func() which shows the help page for the active tool. * app/[all files calling a dialog constructor]: pass the dialog's help page to the constructor. Most dialogs are now created by gimp_dialog_new() which also sets up the action_area and the WM delete event callback, so I removed the resp. code from these files. Fixed some minor bugs and did some other stuff but didn't change any logic except dialog creation. * plug-ins/helpbrowser/helpbrowser.c: don't try to call a running help browser and don't install any menu path (all done in app/gimphelp.[ch] now).
1999-09-28 01:58:10 +08:00
#include "gimpui.h"
#include "gradient_header.h"
1999-10-28 23:05:49 +08:00
#include "gradientP.h"
#include "gradient_select.h"
#include "session.h"
#include "libgimp/gimpintl.h"
1999-10-28 23:05:49 +08:00
static void gradient_change_callbacks (GradientSelect *gsp,
gboolean closing);
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);
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]));
1999-10-28 23:05:49 +08:00
/* list of active dialogs */
GSList *gradient_active_dialogs = NULL;
1999-10-28 23:05:49 +08:00
/* the main gradient selection dialog */
GradientSelect *gradient_select_dialog = NULL;
void
1999-10-28 23:05:49 +08:00
gradient_dialog_create (void)
{
1999-10-28 23:05:49 +08:00
if (! gradient_select_dialog)
{
1999-10-28 23:05:49 +08:00
gradient_select_dialog = gradient_select_new (NULL, NULL);
}
1999-10-28 23:05:49 +08:00
else
{
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);
}
}
void
1999-10-28 23:05:49 +08:00
gradient_dialog_free (void)
{
1999-10-28 23:05:49 +08:00
if (gradient_select_dialog)
{
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;
}
1999-10-28 23:05:49 +08:00
gradient_editor_free ();
}
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)
{
GradientSelect *gsp;
1999-10-28 23:05:49 +08:00
GtkWidget *vbox;
GtkWidget *scrolled_win;
GdkColormap *colormap;
gchar *titles[2];
1999-10-28 23:05:49 +08:00
gint select_pos;
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;
1999-10-28 23:05:49 +08:00
gsp = g_new (GradientSelect, 1);
gsp->callback_name = NULL;
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,
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,
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);
}
1999-10-28 23:05:49 +08:00
else
{
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);
}
1999-10-28 23:05:49 +08:00
if (no_data && first_call)
gradients_init (FALSE);
1999-10-28 23:05:49 +08:00
first_call = FALSE;
if (title && initial_gradient && strlen (initial_gradient))
{
1999-10-28 23:05:49 +08:00
active = gradient_list_get_gradient (gradients_list, initial_gradient);
}
1999-10-28 23:05:49 +08:00
else
{
1999-10-28 23:05:49 +08:00
active = gimp_context_get_gradient (gimp_context_get_user ());
}
1999-10-28 23:05:49 +08:00
if (!active)
{
1999-10-28 23:05:49 +08:00
active = gimp_context_get_gradient (gimp_context_get_standard ());
}
1999-10-28 23:05:49 +08:00
if (title)
{
1999-10-28 23:05:49 +08:00
gimp_context_set_gradient (gsp->context, active);
}
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);
1999-10-28 23:05:49 +08:00
/* clist preview of gradients */
scrolled_win = gtk_scrolled_window_new (NULL, NULL);
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
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);
gtk_clist_set_selection_mode (GTK_CLIST (gsp->clist), GTK_SELECTION_BROWSE);
gtk_clist_set_row_height (GTK_CLIST (gsp->clist), 18);
gtk_clist_set_use_drag_icons (GTK_CLIST (gsp->clist), FALSE);
gtk_clist_column_titles_passive (GTK_CLIST (gsp->clist));
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);
1999-10-28 23:05:49 +08:00
gtk_widget_show (gsp->clist);
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);
1999-10-28 23:05:49 +08:00
gtk_widget_realize (gsp->shell);
gsp->gc = gdk_gc_new (gsp->shell->window);
1999-10-28 23:05:49 +08:00
select_pos = gradient_clist_init (gsp->shell, gsp->gc, gsp->clist, active);
1999-10-28 23:05:49 +08:00
/* Now show the dialog */
gtk_widget_show (vbox);
gtk_widget_show (gsp->shell);
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);
1999-10-28 23:05:49 +08:00
gtk_signal_connect (GTK_OBJECT (gsp->context), "gradient_changed",
GTK_SIGNAL_FUNC (gradient_select_gradient_changed),
(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);
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;
}
void
1999-10-28 23:05:49 +08:00
gradient_select_free (GradientSelect *gsp)
{
1999-10-28 23:05:49 +08:00
if (!gsp)
return;
app/Makefile.am app/gimphelp.[ch] new files 1999-09-27 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/gimphelp.[ch] * app/gimpui.[ch]: new files * app/interface.[ch] * app/preferences_dialog.[ch] The GIMP Help System part 1: Press "F1" in any dialog to pop up the help page for this dialog. Moved the widget constructors from preferences_dialog.[ch] and the query boxes from interface.[ch] to gimpui.[ch]. The dialog constructors take a help_func and a help_data parameter and install the "F1" accelerator which emits the new "help" signal. The "help" signal callback calls help_func(help_data) which finally has to call gimp_help() which in turn invokes the help browser. Still have to find a proper way to (1) prevent "F1" being assigned to some menu item and (2) to catch "F1" while browsing the menu trees in order to pop up the help for the selected item. * app/menus.c: a <Toolbox>/File/Help... menu item. * app/commands.[ch]: a command callback for the "Help..." menu item. * app/gimprc.[ch]: new boolean gimprc variable "use_help". * app/info_dialog.[ch]: pass a help function and data to the info dialog constructor. * app/tools.[ch]: store the tools help page names in the tool info structure. Export a special tools_help_func() which shows the help page for the active tool. * app/[all files calling a dialog constructor]: pass the dialog's help page to the constructor. Most dialogs are now created by gimp_dialog_new() which also sets up the action_area and the WM delete event callback, so I removed the resp. code from these files. Fixed some minor bugs and did some other stuff but didn't change any logic except dialog creation. * plug-ins/helpbrowser/helpbrowser.c: don't try to call a running help browser and don't install any menu path (all done in app/gimphelp.[ch] now).
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);
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));
}
1999-10-28 23:05:49 +08:00
g_free (gsp);
}
1999-10-28 23:05:49 +08:00
/* Call this dialog's PDB callback */
static void
1999-10-28 23:05:49 +08:00
gradient_change_callbacks (GradientSelect *gsp,
gboolean closing)
{
gchar * name;
ProcRecord *prec = NULL;
1999-10-28 23:05:49 +08:00
gradient_t *gradient;
gint nreturn_vals;
static gboolean busy = FALSE;
/* Any procs registered to callback? */
Argument *return_vals;
app/Makefile.am app/gimphelp.[ch] new files 1999-09-27 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/gimphelp.[ch] * app/gimpui.[ch]: new files * app/interface.[ch] * app/preferences_dialog.[ch] The GIMP Help System part 1: Press "F1" in any dialog to pop up the help page for this dialog. Moved the widget constructors from preferences_dialog.[ch] and the query boxes from interface.[ch] to gimpui.[ch]. The dialog constructors take a help_func and a help_data parameter and install the "F1" accelerator which emits the new "help" signal. The "help" signal callback calls help_func(help_data) which finally has to call gimp_help() which in turn invokes the help browser. Still have to find a proper way to (1) prevent "F1" being assigned to some menu item and (2) to catch "F1" while browsing the menu trees in order to pop up the help for the selected item. * app/menus.c: a <Toolbox>/File/Help... menu item. * app/commands.[ch]: a command callback for the "Help..." menu item. * app/gimprc.[ch]: new boolean gimprc variable "use_help". * app/info_dialog.[ch]: pass a help function and data to the info dialog constructor. * app/tools.[ch]: store the tools help page names in the tool info structure. Export a special tools_help_func() which shows the help page for the active tool. * app/[all files calling a dialog constructor]: pass the dialog's help page to the constructor. Most dialogs are now created by gimp_dialog_new() which also sets up the action_area and the WM delete event callback, so I removed the resp. code from these files. Fixed some minor bugs and did some other stuff but didn't change any logic except dialog creation. * plug-ins/helpbrowser/helpbrowser.c: don't try to call a running help browser and don't install any menu path (all done in app/gimphelp.[ch] now).
1999-09-28 01:58:10 +08:00
if (!gsp || !gsp->callback_name || busy != 0)
return;
1999-10-28 23:05:49 +08:00
busy = TRUE;
name = gsp->callback_name;
1999-10-28 23:05:49 +08:00
gradient = gimp_context_get_gradient (gsp->context);
1999-10-27 02:27:27 +08:00
/* If its still registered run it */
app/Makefile.am app/gimphelp.[ch] new files 1999-09-27 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/gimphelp.[ch] * app/gimpui.[ch]: new files * app/interface.[ch] * app/preferences_dialog.[ch] The GIMP Help System part 1: Press "F1" in any dialog to pop up the help page for this dialog. Moved the widget constructors from preferences_dialog.[ch] and the query boxes from interface.[ch] to gimpui.[ch]. The dialog constructors take a help_func and a help_data parameter and install the "F1" accelerator which emits the new "help" signal. The "help" signal callback calls help_func(help_data) which finally has to call gimp_help() which in turn invokes the help browser. Still have to find a proper way to (1) prevent "F1" being assigned to some menu item and (2) to catch "F1" while browsing the menu trees in order to pop up the help for the selected item. * app/menus.c: a <Toolbox>/File/Help... menu item. * app/commands.[ch]: a command callback for the "Help..." menu item. * app/gimprc.[ch]: new boolean gimprc variable "use_help". * app/info_dialog.[ch]: pass a help function and data to the info dialog constructor. * app/tools.[ch]: store the tools help page names in the tool info structure. Export a special tools_help_func() which shows the help page for the active tool. * app/[all files calling a dialog constructor]: pass the dialog's help page to the constructor. Most dialogs are now created by gimp_dialog_new() which also sets up the action_area and the WM delete event callback, so I removed the resp. code from these files. Fixed some minor bugs and did some other stuff but didn't change any logic except dialog creation. * plug-ins/helpbrowser/helpbrowser.c: don't try to call a running help browser and don't install any menu path (all done in app/gimphelp.[ch] now).
1999-09-28 01:58:10 +08:00
prec = procedural_db_lookup (name);
1999-10-28 23:05:49 +08:00
if (prec && gradient)
{
gdouble *values, *pv;
double pos, delta;
double r, g, b, a;
int i = gsp->sample_size;
pos = 0.0;
delta = 1.0 / (i - 1);
app/Makefile.am app/gimphelp.[ch] new files 1999-09-27 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/gimphelp.[ch] * app/gimpui.[ch]: new files * app/interface.[ch] * app/preferences_dialog.[ch] The GIMP Help System part 1: Press "F1" in any dialog to pop up the help page for this dialog. Moved the widget constructors from preferences_dialog.[ch] and the query boxes from interface.[ch] to gimpui.[ch]. The dialog constructors take a help_func and a help_data parameter and install the "F1" accelerator which emits the new "help" signal. The "help" signal callback calls help_func(help_data) which finally has to call gimp_help() which in turn invokes the help browser. Still have to find a proper way to (1) prevent "F1" being assigned to some menu item and (2) to catch "F1" while browsing the menu trees in order to pop up the help for the selected item. * app/menus.c: a <Toolbox>/File/Help... menu item. * app/commands.[ch]: a command callback for the "Help..." menu item. * app/gimprc.[ch]: new boolean gimprc variable "use_help". * app/info_dialog.[ch]: pass a help function and data to the info dialog constructor. * app/tools.[ch]: store the tools help page names in the tool info structure. Export a special tools_help_func() which shows the help page for the active tool. * app/[all files calling a dialog constructor]: pass the dialog's help page to the constructor. Most dialogs are now created by gimp_dialog_new() which also sets up the action_area and the WM delete event callback, so I removed the resp. code from these files. Fixed some minor bugs and did some other stuff but didn't change any logic except dialog creation. * plug-ins/helpbrowser/helpbrowser.c: don't try to call a running help browser and don't install any menu path (all done in app/gimphelp.[ch] now).
1999-09-28 01:58:10 +08:00
values = g_new (gdouble, 4 * i);
pv = values;
app/Makefile.am app/gimphelp.[ch] new files 1999-09-27 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/gimphelp.[ch] * app/gimpui.[ch]: new files * app/interface.[ch] * app/preferences_dialog.[ch] The GIMP Help System part 1: Press "F1" in any dialog to pop up the help page for this dialog. Moved the widget constructors from preferences_dialog.[ch] and the query boxes from interface.[ch] to gimpui.[ch]. The dialog constructors take a help_func and a help_data parameter and install the "F1" accelerator which emits the new "help" signal. The "help" signal callback calls help_func(help_data) which finally has to call gimp_help() which in turn invokes the help browser. Still have to find a proper way to (1) prevent "F1" being assigned to some menu item and (2) to catch "F1" while browsing the menu trees in order to pop up the help for the selected item. * app/menus.c: a <Toolbox>/File/Help... menu item. * app/commands.[ch]: a command callback for the "Help..." menu item. * app/gimprc.[ch]: new boolean gimprc variable "use_help". * app/info_dialog.[ch]: pass a help function and data to the info dialog constructor. * app/tools.[ch]: store the tools help page names in the tool info structure. Export a special tools_help_func() which shows the help page for the active tool. * app/[all files calling a dialog constructor]: pass the dialog's help page to the constructor. Most dialogs are now created by gimp_dialog_new() which also sets up the action_area and the WM delete event callback, so I removed the resp. code from these files. Fixed some minor bugs and did some other stuff but didn't change any logic except dialog creation. * plug-ins/helpbrowser/helpbrowser.c: don't try to call a running help browser and don't install any menu path (all done in app/gimphelp.[ch] now).
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);
app/Makefile.am app/gimphelp.[ch] new files 1999-09-27 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/gimphelp.[ch] * app/gimpui.[ch]: new files * app/interface.[ch] * app/preferences_dialog.[ch] The GIMP Help System part 1: Press "F1" in any dialog to pop up the help page for this dialog. Moved the widget constructors from preferences_dialog.[ch] and the query boxes from interface.[ch] to gimpui.[ch]. The dialog constructors take a help_func and a help_data parameter and install the "F1" accelerator which emits the new "help" signal. The "help" signal callback calls help_func(help_data) which finally has to call gimp_help() which in turn invokes the help browser. Still have to find a proper way to (1) prevent "F1" being assigned to some menu item and (2) to catch "F1" while browsing the menu trees in order to pop up the help for the selected item. * app/menus.c: a <Toolbox>/File/Help... menu item. * app/commands.[ch]: a command callback for the "Help..." menu item. * app/gimprc.[ch]: new boolean gimprc variable "use_help". * app/info_dialog.[ch]: pass a help function and data to the info dialog constructor. * app/tools.[ch]: store the tools help page names in the tool info structure. Export a special tools_help_func() which shows the help page for the active tool. * app/[all files calling a dialog constructor]: pass the dialog's help page to the constructor. Most dialogs are now created by gimp_dialog_new() which also sets up the action_area and the WM delete event callback, so I removed the resp. code from these files. Fixed some minor bugs and did some other stuff but didn't change any logic except dialog creation. * plug-ins/helpbrowser/helpbrowser.c: don't try to call a running help browser and don't install any menu path (all done in app/gimphelp.[ch] now).
1999-09-28 01:58:10 +08:00
*pv++ = r;
*pv++ = g;
*pv++ = b;
*pv++ = a;
pos += delta;
}
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,
app/Makefile.am app/gimphelp.[ch] new files 1999-09-27 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/gimphelp.[ch] * app/gimpui.[ch]: new files * app/interface.[ch] * app/preferences_dialog.[ch] The GIMP Help System part 1: Press "F1" in any dialog to pop up the help page for this dialog. Moved the widget constructors from preferences_dialog.[ch] and the query boxes from interface.[ch] to gimpui.[ch]. The dialog constructors take a help_func and a help_data parameter and install the "F1" accelerator which emits the new "help" signal. The "help" signal callback calls help_func(help_data) which finally has to call gimp_help() which in turn invokes the help browser. Still have to find a proper way to (1) prevent "F1" being assigned to some menu item and (2) to catch "F1" while browsing the menu trees in order to pop up the help for the selected item. * app/menus.c: a <Toolbox>/File/Help... menu item. * app/commands.[ch]: a command callback for the "Help..." menu item. * app/gimprc.[ch]: new boolean gimprc variable "use_help". * app/info_dialog.[ch]: pass a help function and data to the info dialog constructor. * app/tools.[ch]: store the tools help page names in the tool info structure. Export a special tools_help_func() which shows the help page for the active tool. * app/[all files calling a dialog constructor]: pass the dialog's help page to the constructor. Most dialogs are now created by gimp_dialog_new() which also sets up the action_area and the WM delete event callback, so I removed the resp. code from these files. Fixed some minor bugs and did some other stuff but didn't change any logic except dialog creation. * plug-ins/helpbrowser/helpbrowser.c: don't try to call a running help browser and don't install any menu path (all done in app/gimphelp.[ch] now).
1999-09-28 01:58:10 +08:00
PDB_FLOATARRAY, values,
1999-10-28 23:05:49 +08:00
PDB_INT32, (gint) closing,
PDB_END);
if (!return_vals || return_vals[0].value.pdb_int != PDB_SUCCESS)
configure.in removed tips files, AC_SUBST GIMP_PLUGINS and GIMP_MODULES so * configure.in * Makefile.am: removed tips files, AC_SUBST GIMP_PLUGINS and GIMP_MODULES so you can easily skip those parts of the build * acinclude.m4 * config.sub * config.guess * ltconfig * ltmain.sh: libtool 1.3.2 * app/fileops.c: shuffle #includes to avoid warning about MIN and MAX [ The following is a big i18n patch from David Monniaux <david.monniaux@ens.fr> ] * tips/gimp_conseils.fr.txt * tips/gimp_tips.txt * tips/Makefile.am * configure.in: moved tips to separate dir * po-plugins: new dir for plug-in translation files * configure.in: add po-plugins dir and POTFILES processing * app/boundary.c * app/brightness_contrast.c * app/by_color_select.c * app/color_balance.c * app/convert.c * app/curves.c * app/free_select.c * app/gdisplay.c * app/gimpimage.c * app/gimpunit.c * app/gradient.c * app/gradient_select.c * app/install.c * app/session.c: various i18n tweaks * app/tips_dialog.c: localize tips filename * libgimp/gimpunit.c * libgimp/gimpunitmenu.c: #include "config.h" * plug-ins/CEL * plug-ins/CML_explorer * plug-ins/Lighting * plug-ins/apply_lens * plug-ins/autostretch_hsv * plug-ins/blur * plug-ins/bmp * plug-ins/borderaverage * plug-ins/bumpmap * plug-ins/bz2 * plug-ins/checkerboard * plug-ins/colorify * plug-ins/compose * plug-ins/convmatrix * plug-ins/cubism * plug-ins/depthmerge * plug-ins/destripe * plug-ins/gif * plug-ins/gifload * plug-ins/jpeg * plug-ins/mail * plug-ins/oilify * plug-ins/png * plug-ins/print * plug-ins/ps * plug-ins/xbm * plug-ins/xpm * plug-ins/xwd: plug-in i18n stuff -Yosh
1999-05-30 00:35:47 +08:00
g_message ("failed to run gradient callback function");
else
procedural_db_destroy_args (return_vals, nreturn_vals);
}
1999-10-28 23:05:49 +08:00
busy = FALSE;
}
1999-10-28 23:05:49 +08:00
/* Close active dialogs that no longer have PDB registered for them */
void
gradients_check_dialogs (void)
{
1999-10-28 23:05:49 +08:00
GradientSelect *gsp;
GSList *list;
gchar *name;
ProcRecord *prec = NULL;
1999-10-28 23:05:49 +08:00
list = gradient_active_dialogs;
1999-10-28 23:05:49 +08:00
while (list)
{
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);
}
}
}
}
1999-10-28 23:05:49 +08:00
void
gradient_select_rename_all (gint n,
gradient_t *gradient)
{
1999-10-28 23:05:49 +08:00
GradientSelect *gsp;
GSList *list;
1999-10-28 23:05:49 +08:00
for (list = gradient_active_dialogs; list; list = g_slist_next (list))
{
1999-10-28 23:05:49 +08:00
gsp = (GradientSelect *) list->data;
gtk_clist_set_text (GTK_CLIST (gsp->clist), n, 1, gradient->name);
}
1999-10-28 23:05:49 +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-10-28 23:05:49 +08:00
for (list = gradient_active_dialogs; list; list = g_slist_next (list))
{
gsp = (GradientSelect *) list->data;
app/Makefile.am app/gimphelp.[ch] new files 1999-09-27 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/gimphelp.[ch] * app/gimpui.[ch]: new files * app/interface.[ch] * app/preferences_dialog.[ch] The GIMP Help System part 1: Press "F1" in any dialog to pop up the help page for this dialog. Moved the widget constructors from preferences_dialog.[ch] and the query boxes from interface.[ch] to gimpui.[ch]. The dialog constructors take a help_func and a help_data parameter and install the "F1" accelerator which emits the new "help" signal. The "help" signal callback calls help_func(help_data) which finally has to call gimp_help() which in turn invokes the help browser. Still have to find a proper way to (1) prevent "F1" being assigned to some menu item and (2) to catch "F1" while browsing the menu trees in order to pop up the help for the selected item. * app/menus.c: a <Toolbox>/File/Help... menu item. * app/commands.[ch]: a command callback for the "Help..." menu item. * app/gimprc.[ch]: new boolean gimprc variable "use_help". * app/info_dialog.[ch]: pass a help function and data to the info dialog constructor. * app/tools.[ch]: store the tools help page names in the tool info structure. Export a special tools_help_func() which shows the help page for the active tool. * app/[all files calling a dialog constructor]: pass the dialog's help page to the constructor. Most dialogs are now created by gimp_dialog_new() which also sets up the action_area and the WM delete event callback, so I removed the resp. code from these files. Fixed some minor bugs and did some other stuff but didn't change any logic except dialog creation. * plug-ins/helpbrowser/helpbrowser.c: don't try to call a running help browser and don't install any menu path (all done in app/gimphelp.[ch] now).
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));
}
}
1999-10-28 23:05:49 +08:00
void
gradient_select_delete_all (gint n)
{
GradientSelect *gsp;
GSList *list;
1999-10-28 23:05:49 +08:00
for (list = gradient_active_dialogs; list; list = g_slist_next (list))
{
gsp = (GradientSelect *) list->data;
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;
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));
}
}
1999-10-28 23:05:49 +08:00
void
gradient_select_refill_all (void)
{
GradientSelect *gsp;
GSList *list;
gint index = -1;
1999-10-28 23:05:49 +08:00
for (list = gradient_active_dialogs; list; list = g_slist_next (list))
{
gsp = (GradientSelect *) list->data;
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;
1999-10-28 23:05:49 +08:00
for (list = gradient_active_dialogs; list; list = g_slist_next (list))
{
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);
}
}
1999-10-28 23:05:49 +08:00
/*
* Local functions
*/
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;
1999-10-28 23:05:49 +08:00
gsp = (GradientSelect *) data;
1999-10-28 23:05:49 +08:00
gimp_context_set_gradient (gsp->context, gradient);
}
1999-10-28 23:05:49 +08:00
static void
gradient_select_gradient_changed (GimpContext *context,
gradient_t *gradient,
GradientSelect *gsp)
{
if (gradient)
{
gradient_select_select (gsp, gradient);
if (gsp->callback_name)
gradient_change_callbacks (gsp, FALSE);
gsp->dnd_gradient = gradient;
}
}
1999-10-28 23:05:49 +08:00
static void
gradient_select_select (GradientSelect *gsp,
gradient_t *gradient)
{
1999-10-28 23:05:49 +08:00
gint index;
index = gradient_list_get_gradient_index (gradients_list, gradient);
if (index != -1)
{
1999-10-28 23:05:49 +08:00
gtk_signal_handler_block_by_data (GTK_OBJECT (gsp->clist), gsp);
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-10-28 23:05:49 +08:00
gtk_signal_handler_unblock_by_data (GTK_OBJECT (gsp->clist), gsp);
}
1999-10-28 23:05:49 +08:00
}
static gint
gradient_select_button_press (GtkWidget *widget,
GdkEventButton *bevent,
gpointer data)
{
GradientSelect *gsp;
gsp = (GradientSelect *) data;
if (bevent->button == 2)
{
app/airbrush.c app/apptypes.h app/brushes_cmds.c 1999-11-14 Michael Natterer <mitch@gimp.org> * app/airbrush.c * app/apptypes.h * app/brushes_cmds.c * tools/pdbgen/pdb/brushes.pdb * app/bucket_fill.c * app/clone.c * app/gimpbrushpipe.c * app/paint_core.c * app/patterns.h * app/patterns_cmds.c * tools/pdbgen/pdb/patterns.pdb: removed the GimpBrushP and GPatternP types and use ordinary pointers instead. The following stuff makes the "no_data" behaviour consistent. As a side-effect it should make the gimp work when there are _really_ no brushes/patterns/gradients. * app/brush_select.c * app/pattern_select.c: set the initial brush/pattern name to "No Brushes/Patterns available" instead of "Active". * app/devices.c: set the device contexts' brush/pattern/gradient names if we started with no_data, so we find them on refresh. * app/gimpbrushlist.c: set the name of the standard_brush to "Standard". * app/gimpcontext.c: don't replace the current brush/pattern/gradient's name if the new one to be set is the standard one. Together with the change in devices.c, this ensures that we get what is set in devicerc. Minor fixes. * app/gradient.c: changed gradients_init() to work like the other data init functions. Only insert a default gradient in the gradients list when the editor is opened (this means that the gradients now behave like brushes/patterns when we start with "no_data"). New function gradient_update() avoids tons of useless redraws of all clist gradient previews whenever the gradient editor wants to update it's large preview. * app/gradient_select.c: don't segfault when the user tries to drag from an empty gradient list. * app/patterns.c: set the index of the standard_pattern to -1 to indicate that it's not part of the pattern list.
1999-11-14 18:50:19 +08:00
GSList *list = NULL;
gint row;
gint column;
gtk_clist_get_selection_info (GTK_CLIST (gsp->clist),
bevent->x, bevent->y,
&row, &column);
app/airbrush.c app/apptypes.h app/brushes_cmds.c 1999-11-14 Michael Natterer <mitch@gimp.org> * app/airbrush.c * app/apptypes.h * app/brushes_cmds.c * tools/pdbgen/pdb/brushes.pdb * app/bucket_fill.c * app/clone.c * app/gimpbrushpipe.c * app/paint_core.c * app/patterns.h * app/patterns_cmds.c * tools/pdbgen/pdb/patterns.pdb: removed the GimpBrushP and GPatternP types and use ordinary pointers instead. The following stuff makes the "no_data" behaviour consistent. As a side-effect it should make the gimp work when there are _really_ no brushes/patterns/gradients. * app/brush_select.c * app/pattern_select.c: set the initial brush/pattern name to "No Brushes/Patterns available" instead of "Active". * app/devices.c: set the device contexts' brush/pattern/gradient names if we started with no_data, so we find them on refresh. * app/gimpbrushlist.c: set the name of the standard_brush to "Standard". * app/gimpcontext.c: don't replace the current brush/pattern/gradient's name if the new one to be set is the standard one. Together with the change in devices.c, this ensures that we get what is set in devicerc. Minor fixes. * app/gradient.c: changed gradients_init() to work like the other data init functions. Only insert a default gradient in the gradients list when the editor is opened (this means that the gradients now behave like brushes/patterns when we start with "no_data"). New function gradient_update() avoids tons of useless redraws of all clist gradient previews whenever the gradient editor wants to update it's large preview. * app/gradient_select.c: don't segfault when the user tries to drag from an empty gradient list. * app/patterns.c: set the index of the standard_pattern to -1 to indicate that it's not part of the pattern list.
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;
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);
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);
}
}