More context & dnd stuff...

This commit is contained in:
Michael Natterer 1999-10-28 15:05:49 +00:00
parent d518393284
commit 79e27e984a
114 changed files with 7767 additions and 4890 deletions

View File

@ -1,3 +1,68 @@
1999-10-28 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/Makefile.am
* app/gradient_select.h
* app/gradientP.h: new files. Put the function prototypes from
gradient_header.h there and renamed them to match the naming
scheme used elsewhere.
* app/gradient.[ch]
* app/gradient_cmds.c
* app/gradient_header.h
* app/gradient_select.c
* app/gradient_select_cmds.c
* tools/pdbgen/pdb/gradient.pdb
* tools/pdbgen/pdb/gradient_select.pdb: separated the gradient
editor and the selections (no more common variables used).
Allocate own contexts for each gradient selection. Tweaked the
code and function names to match the brush and pattern selection.
Enabled dropping gradients to the editor and the selections.
Renamed all public functions of the gradient editor (see above).
* app/app_procs.c
* app/commands.[ch]
* app/menus.c
* app/plug_in.c
* app/session.c: changed according to the new gradient function
names and includes.
* app/brush_select.[ch]
* app/pattern_select.[ch]: scroll to active brush/pattern if it's
outside the preview area. Minor fixes/cleanups. Allow dropping a
brush/pattern.
* app/color_select.c: prefixed all enum constants with
COLOR_SELECT_* due to a name clash with the new gradient header
structure (HUE_SATURATION was defined in both places).
* app/convert.[ch]
* app/convert_cmds.c
* tools/pdbgen/pdb/convert.pdb
* app/palette.c
* app/palette_entries.h
* app/palette_select.[ch]: removed the special
Palette[Entries|Entry]P poiner type.
* app/devices.c: added gradients to the device status dialog.
* app/disp_callbacks.[ch]
* app/gimpcontext.c
* app/gimpcontextpreview.[ch]
* app/gimpdnd.[ch]
* app/indicator_area.c
* app/interface.c: moved the whole tool/brush/pattern/gradient dnd
stuff to gimpdnd.[ch] and provide simple functions to connect dnd
callbacks. All those types are passed as real (cross-application)
GtkSelections now, so the app-side of gimp<->plugin dnd is done.
Added dnd for tools.
* app/tools.[ch]: added a tooltip for all non-toolbox tools
because the device status dialog displays tooltips for all tools.
Use the ToolType enum instead of int in the ToolInfo structure.
* libgimp/gimplimits.h: put the size and color of the transparency
checks here (rename the file to gimpconstants.h ??)
Thu Oct 28 11:45:29 1999 ape@gandalf.spacetec.no (Asbjorn Pettersen)
* app/datafiles.h: include <time.h> for time_t.

View File

@ -228,7 +228,9 @@ gimp_SOURCES = \
global_edit.c \
global_edit.h \
gradient.c \
gradientP.h \
gradient_header.h \
gradient_select.h \
gradient_select.c \
gradient_select_cmds.c \
gradient.h \

View File

@ -39,7 +39,7 @@
#include "gimprc.h"
#include "gimpui.h"
#include "global_edit.h"
#include "gradient.h"
#include "gradient_select.h"
#include "image_render.h"
#include "info_window.h"
#include "nav_window.h"
@ -1103,10 +1103,10 @@ dialogs_palette_cmd_callback (GtkWidget *widget,
}
void
dialogs_gradient_editor_cmd_callback (GtkWidget *widget,
gpointer client_data)
dialogs_gradient_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
grad_create_gradient_editor ();
gradient_dialog_create ();
}
void

View File

@ -99,7 +99,7 @@ void filters_repeat_cmd_callback (GtkWidget *widget,
void dialogs_brushes_cmd_callback (GtkWidget *, gpointer);
void dialogs_patterns_cmd_callback (GtkWidget *, gpointer);
void dialogs_palette_cmd_callback (GtkWidget *, gpointer);
void dialogs_gradient_editor_cmd_callback (GtkWidget *, gpointer);
void dialogs_gradient_cmd_callback (GtkWidget *, gpointer);
void dialogs_lc_cmd_callback (GtkWidget *, gpointer);
void dialogs_indexed_palette_cmd_callback (GtkWidget *, gpointer);
void dialogs_tools_options_cmd_callback (GtkWidget *, gpointer);

View File

@ -94,7 +94,7 @@
#include "general.h"
#include "gimage.h"
#include "gimprc.h"
#include "gradient.h"
#include "gradient_select.h"
#include "interface.h"
#include "menus.h"
#include "pattern_select.h" /* Needed for closing pattern dialogs */

View File

@ -61,6 +61,7 @@
#include "gimpset.h"
#include "gimpui.h"
#include "global_edit.h"
#include "gradient_select.h"
#include "gradient.h"
#include "gximage.h"
#include "hue_saturation.h"
@ -665,7 +666,7 @@ app_exit_finish (void)
patterns_free ();
palette_dialog_free ();
palettes_free ();
grad_free_gradient_editor ();
gradient_dialog_free ();
gradients_free ();
context_manager_free ();
hue_saturation_free ();

View File

@ -27,6 +27,7 @@
#include "gimpbrushpipe.h"
#include "gimpbrushpipeP.h"
#include "gimpcontext.h"
#include "gimpdnd.h"
#include "gimplist.h"
#include "gimprc.h"
#include "gimpui.h"
@ -63,41 +64,13 @@
#define BLK { 0, 0, 0}
#define RED {255, 127, 127}
static unsigned char scale_indicator_bits[7][7][3] =
{
{ WHT, WHT, WHT, WHT, WHT, WHT, WHT },
{ WHT, WHT, WHT, BLK, WHT, WHT, WHT },
{ WHT, WHT, WHT, BLK, WHT, WHT, WHT },
{ WHT, BLK, BLK, BLK, BLK, BLK, WHT },
{ WHT, WHT, WHT, BLK, WHT, WHT, WHT },
{ WHT, WHT, WHT, BLK, WHT, WHT, WHT },
{ WHT, WHT, WHT, WHT, WHT, WHT, WHT }
};
static unsigned char pipe_indicator_bits[7][7][3] =
{
{ WHT, WHT, WHT, WHT, WHT, WHT, WHT },
{ WHT, WHT, WHT, WHT, WHT, WHT, RED },
{ WHT, WHT, WHT, WHT, WHT, RED, RED },
{ WHT, WHT, WHT, WHT, RED, RED, RED },
{ WHT, WHT, WHT, RED, RED, RED, RED },
{ WHT, WHT, RED, RED, RED, RED, RED },
{ WHT, RED, RED, RED, RED, RED, RED }
};
static unsigned char scale_pipe_indicator_bits[7][7][3] =
{
{ WHT, WHT, WHT, WHT, WHT, WHT, WHT },
{ WHT, WHT, WHT, BLK, WHT, WHT, RED },
{ WHT, WHT, WHT, BLK, WHT, RED, RED },
{ WHT, BLK, BLK, BLK, BLK, BLK, RED },
{ WHT, WHT, WHT, BLK, RED, RED, RED },
{ WHT, WHT, RED, BLK, RED, RED, RED },
{ WHT, RED, RED, RED, RED, RED, RED }
};
/* local function prototypes */
static void brush_change_callbacks (BrushSelect *bsp,
gboolean closing);
static void brush_select_drop_brush (GtkWidget *widget,
GimpBrush *brush,
gpointer data);
static void brush_select_brush_changed (GimpContext *context,
GimpBrush *brush,
BrushSelect *bsp);
@ -162,6 +135,47 @@ static void brush_select_new_brush_callback (GtkWidget *, gpointer);
static void brush_select_edit_brush_callback (GtkWidget *, gpointer);
static void brush_select_delete_brush_callback (GtkWidget *, gpointer);
static unsigned char scale_indicator_bits[7][7][3] =
{
{ WHT, WHT, WHT, WHT, WHT, WHT, WHT },
{ WHT, WHT, WHT, BLK, WHT, WHT, WHT },
{ WHT, WHT, WHT, BLK, WHT, WHT, WHT },
{ WHT, BLK, BLK, BLK, BLK, BLK, WHT },
{ WHT, WHT, WHT, BLK, WHT, WHT, WHT },
{ WHT, WHT, WHT, BLK, WHT, WHT, WHT },
{ WHT, WHT, WHT, WHT, WHT, WHT, WHT }
};
static unsigned char pipe_indicator_bits[7][7][3] =
{
{ WHT, WHT, WHT, WHT, WHT, WHT, WHT },
{ WHT, WHT, WHT, WHT, WHT, WHT, RED },
{ WHT, WHT, WHT, WHT, WHT, RED, RED },
{ WHT, WHT, WHT, WHT, RED, RED, RED },
{ WHT, WHT, WHT, RED, RED, RED, RED },
{ WHT, WHT, RED, RED, RED, RED, RED },
{ WHT, RED, RED, RED, RED, RED, RED }
};
static unsigned char scale_pipe_indicator_bits[7][7][3] =
{
{ WHT, WHT, WHT, WHT, WHT, WHT, WHT },
{ WHT, WHT, WHT, BLK, WHT, WHT, RED },
{ WHT, WHT, WHT, BLK, WHT, RED, RED },
{ WHT, BLK, BLK, BLK, BLK, BLK, RED },
{ WHT, WHT, WHT, BLK, RED, RED, RED },
{ WHT, WHT, RED, BLK, RED, RED, RED },
{ WHT, RED, RED, RED, RED, RED, RED }
};
/* dnd stuff */
static GtkTargetEntry preview_target_table[] =
{
GIMP_TARGET_BRUSH
};
static guint preview_n_targets = (sizeof (preview_target_table) /
sizeof (preview_target_table[0]));
/* The main brush selection dialog */
BrushSelect *brush_select_dialog = NULL;
@ -178,21 +192,15 @@ brush_dialog_create (void)
{
if (! brush_select_dialog)
{
/* Create the dialog... */
brush_select_dialog = brush_select_new (NULL, NULL, 0.0, 0, 0);
/* register this one only */
dialog_register (brush_select_dialog->shell);
}
else
{
/* Popup the dialog */
if (!GTK_WIDGET_VISIBLE (brush_select_dialog->shell))
gtk_widget_show (brush_select_dialog->shell);
else
gdk_window_raise (brush_select_dialog->shell->window);
}
}
void
@ -200,6 +208,15 @@ brush_dialog_free ()
{
if (brush_select_dialog)
{
session_get_window_info (brush_select_dialog->shell,
&brush_select_session_info);
/* save the size of the preview */
brush_select_session_info.width =
brush_select_dialog->preview->allocation.width;
brush_select_session_info.height =
brush_select_dialog->preview->allocation.height;
brush_select_free (brush_select_dialog);
brush_select_dialog = NULL;
}
@ -231,7 +248,7 @@ brush_select_new (gchar *title,
GimpBrush *active = NULL;
/* gboolean gotinitbrush = FALSE; */
static gboolean first_call = TRUE;
bsp = g_new (BrushSelect, 1);
bsp->callback_name = NULL;
@ -267,14 +284,18 @@ brush_select_new (gchar *title,
}
else
{
bsp->context = gimp_context_get_user ();
session_set_window_geometry (bsp->shell, &brush_select_session_info,
FALSE);
bsp->context = gimp_context_get_user ();
dialog_register (bsp->shell);
}
if (no_data)
if (no_data && first_call)
brushes_init (FALSE);
first_call = FALSE;
if (title && init_name && strlen (init_name))
{
active = gimp_brush_list_get_brush (brush_list, init_name);
@ -349,6 +370,13 @@ brush_select_new (gchar *title,
GTK_SIGNAL_FUNC (brush_select_resize),
bsp);
/* dnd stuff */
gtk_drag_dest_set (bsp->preview,
GTK_DEST_DEFAULT_ALL,
preview_target_table, preview_n_targets,
GDK_ACTION_COPY);
gimp_dnd_brush_dest_set (bsp->preview, brush_select_drop_brush, bsp);
gtk_container_add (GTK_CONTAINER (frame), bsp->preview);
gtk_widget_show (bsp->preview);
@ -535,15 +563,6 @@ brush_select_free (BrushSelect *bsp)
/* remove from active list */
brush_active_dialogs = g_slist_remove (brush_active_dialogs, bsp);
/* Only main one is saved */
if (bsp == brush_select_dialog)
{
session_get_window_info (bsp->shell, &brush_select_session_info);
/* save the size of the preview */
brush_select_session_info.width = bsp->preview->allocation.width;
brush_select_session_info.height = bsp->preview->allocation.height;
}
gtk_signal_disconnect_by_data (GTK_OBJECT (bsp->context), bsp);
if (bsp->brush_popup != NULL)
@ -576,6 +595,7 @@ brush_select_freeze_all (void)
bsp->freeze = TRUE;
}
}
void
brush_select_thaw_all (void)
{
@ -633,9 +653,9 @@ brush_select_show_paint_options (BrushSelect *bsp,
/* call this dialog's PDB callback */
void
static void
brush_change_callbacks (BrushSelect *bsp,
gint closing)
gboolean closing)
{
gchar *name;
ProcRecord *prec = NULL;
@ -661,15 +681,15 @@ brush_change_callbacks (BrushSelect *bsp,
return_vals =
procedural_db_run_proc (name,
&nreturn_vals,
PDB_STRING, brush->name,
PDB_FLOAT, gimp_context_get_opacity (bsp->context),
PDB_INT32, bsp->spacing_value,
PDB_INT32, (gint)gimp_context_get_paint_mode (bsp->context),
PDB_INT32, brush->mask->width,
PDB_INT32, brush->mask->height,
PDB_INT32, brush->mask->width * brush->mask->height,
PDB_STRING, brush->name,
PDB_FLOAT, gimp_context_get_opacity (bsp->context),
PDB_INT32, bsp->spacing_value,
PDB_INT32, (gint) gimp_context_get_paint_mode (bsp->context),
PDB_INT32, brush->mask->width,
PDB_INT32, brush->mask->height,
PDB_INT32, brush->mask->width * brush->mask->height,
PDB_INT8ARRAY, temp_buf_data (brush->mask),
PDB_INT32, closing,
PDB_INT32, (gint) closing,
PDB_END);
if (!return_vals || return_vals[0].value.pdb_int != PDB_SUCCESS)
@ -695,7 +715,7 @@ brushes_check_dialogs (void)
while (list)
{
bsp = (BrushSelect *) list->data;
list = list->next;
list = g_slist_next (list);
name = bsp->callback_name;
@ -716,6 +736,18 @@ brushes_check_dialogs (void)
* Local functions
*/
static void
brush_select_drop_brush (GtkWidget *widget,
GimpBrush *brush,
gpointer data)
{
BrushSelect *bsp;
bsp = (BrushSelect *) data;
gimp_context_set_brush (bsp->context, brush);
}
static void
brush_select_brush_changed (GimpContext *context,
GimpBrush *brush,
@ -752,12 +784,14 @@ brush_select_select (BrushSelect *bsp,
{
gint index;
gint row, col;
gint scroll_offset = 0;
index = gimp_brush_list_get_brush_index (brush_list, brush);
if (index >= gimp_brush_list_length (brush_list))
index = gimp_brush_list_length (brush_list) - 1;
if (index < 0 || index >= gimp_brush_list_length (brush_list))
if (index < 0)
return;
if (GIMP_IS_BRUSH_GENERATED (brush))
@ -776,7 +810,23 @@ brush_select_select (BrushSelect *bsp,
row = index / bsp->NUM_BRUSH_COLUMNS;
col = index - row * (bsp->NUM_BRUSH_COLUMNS);
brush_select_show_selected (bsp, row, col);
/* check if the new active brush is already in the preview */
if (((row + 1) * bsp->cell_height) >
(bsp->preview->allocation.height + bsp->scroll_offset))
{
scroll_offset = (((row + 1) * bsp->cell_height) -
(bsp->scroll_offset + bsp->preview->allocation.height));
}
else if ((row * bsp->cell_height) < bsp->scroll_offset)
{
scroll_offset = (row * bsp->cell_height) - bsp->scroll_offset;
}
else
{
brush_select_show_selected (bsp, row, col);
}
gtk_adjustment_set_value (bsp->sbar_data, bsp->scroll_offset + scroll_offset);
}
static void
@ -1373,6 +1423,7 @@ preview_calc_scrollbar (BrushSelect *bsp)
bsp->sbar_data->page_increment = (page_size >> 1);
bsp->sbar_data->step_increment = bsp->cell_width;
gtk_signal_emit_by_name (GTK_OBJECT (bsp->sbar_data), "changed");
gtk_signal_emit_by_name (GTK_OBJECT (bsp->sbar_data), "value_changed");
}
@ -1507,8 +1558,8 @@ brush_select_events (GtkWidget *widget,
/* Close the brush popup window */
brush_popup_close (bsp);
/* Call any callbacks registered */
brush_change_callbacks (bsp, 0);
/* Call any callbacks registered */
brush_change_callbacks (bsp, FALSE);
}
break;
@ -1593,7 +1644,7 @@ opacity_scale_update (GtkAdjustment *adjustment,
if (bsp != brush_select_dialog)
{
brush_change_callbacks (bsp, 0);
brush_change_callbacks (bsp, FALSE);
}
}
@ -1609,7 +1660,7 @@ paint_mode_menu_callback (GtkWidget *widget,
if (bsp != brush_select_dialog)
{
brush_change_callbacks (bsp, 0);
brush_change_callbacks (bsp, FALSE);
}
}
@ -1631,7 +1682,7 @@ spacing_scale_update (GtkAdjustment *adjustment,
if (bsp->spacing_value != adjustment->value)
{
bsp->spacing_value = adjustment->value;
brush_change_callbacks (bsp, 0);
brush_change_callbacks (bsp, FALSE);
}
}
}
@ -1651,7 +1702,7 @@ brush_select_close_callback (GtkWidget *widget,
if (bsp != brush_select_dialog)
{
/* Send data back */
brush_change_callbacks (bsp, 1);
brush_change_callbacks (bsp, TRUE);
gtk_widget_destroy (bsp->shell);
brush_select_free (bsp);
}

View File

@ -96,8 +96,6 @@ void brush_select_free (BrushSelect *bsp);
void brush_select_freeze_all (void);
void brush_select_thaw_all (void);
void brush_change_callbacks (BrushSelect *bsp,
gint closing);
void brushes_check_dialogs (void);
/* show/hide paint options (main brush dialog if bsp == NULL) */

View File

@ -54,18 +54,18 @@ typedef enum
typedef enum
{
HUE = 0,
SATURATION,
VALUE,
RED,
GREEN,
BLUE,
HUE_SATURATION,
HUE_VALUE,
SATURATION_VALUE,
RED_GREEN,
RED_BLUE,
GREEN_BLUE
COLOR_SELECT_HUE = 0,
COLOR_SELECT_SATURATION,
COLOR_SELECT_VALUE,
COLOR_SELECT_RED,
COLOR_SELECT_GREEN,
COLOR_SELECT_BLUE,
COLOR_SELECT_HUE_SATURATION,
COLOR_SELECT_HUE_VALUE,
COLOR_SELECT_SATURATION_VALUE,
COLOR_SELECT_RED_GREEN,
COLOR_SELECT_RED_BLUE,
COLOR_SELECT_GREEN_BLUE
} ColorSelectFillType;
typedef enum
@ -452,9 +452,9 @@ color_select_drag_new_color (GtkWidget *widget,
csp = (ColorSelect *) data;
*r = (guchar) csp->values[RED];
*g = (guchar) csp->values[GREEN];
*b = (guchar) csp->values[BLUE];
*r = (guchar) csp->values[COLOR_SELECT_RED];
*g = (guchar) csp->values[COLOR_SELECT_GREEN];
*b = (guchar) csp->values[COLOR_SELECT_BLUE];
}
static void
@ -468,9 +468,9 @@ color_select_drop_new_color (GtkWidget *widget,
csp = (ColorSelect *) data;
csp->values[RED] = (gint) r;
csp->values[GREEN] = (gint) g;
csp->values[BLUE] = (gint) b;
csp->values[COLOR_SELECT_RED] = (gint) r;
csp->values[COLOR_SELECT_GREEN] = (gint) g;
csp->values[COLOR_SELECT_BLUE] = (gint) b;
color_select_update_hsv_values (csp);
color_select_update_pos (csp);
@ -515,9 +515,9 @@ color_select_set_color (ColorSelect *csp,
if (set_current)
{
csp->values[RED] = r;
csp->values[GREEN] = g;
csp->values[BLUE] = b;
csp->values[COLOR_SELECT_RED] = r;
csp->values[COLOR_SELECT_GREEN] = g;
csp->values[COLOR_SELECT_BLUE] = b;
color_select_update_hsv_values (csp);
color_select_update_pos (csp);
@ -578,9 +578,9 @@ color_select_update_caller (ColorSelect *csp)
{
if (csp && csp->wants_updates && csp->callback)
{
(* csp->callback) (csp->values[RED],
csp->values[GREEN],
csp->values[BLUE],
(* csp->callback) (csp->values[COLOR_SELECT_RED],
csp->values[COLOR_SELECT_GREEN],
csp->values[COLOR_SELECT_BLUE],
COLOR_SELECT_UPDATE,
csp->client_data);
}
@ -593,48 +593,48 @@ color_select_update_values (ColorSelect *csp)
{
switch (csp->z_color_fill)
{
case RED:
csp->values[BLUE] = csp->pos[0];
csp->values[GREEN] = csp->pos[1];
csp->values[RED] = csp->pos[2];
case COLOR_SELECT_RED:
csp->values[COLOR_SELECT_BLUE] = csp->pos[0];
csp->values[COLOR_SELECT_GREEN] = csp->pos[1];
csp->values[COLOR_SELECT_RED] = csp->pos[2];
break;
case GREEN:
csp->values[BLUE] = csp->pos[0];
csp->values[RED] = csp->pos[1];
csp->values[GREEN] = csp->pos[2];
case COLOR_SELECT_GREEN:
csp->values[COLOR_SELECT_BLUE] = csp->pos[0];
csp->values[COLOR_SELECT_RED] = csp->pos[1];
csp->values[COLOR_SELECT_GREEN] = csp->pos[2];
break;
case BLUE:
csp->values[GREEN] = csp->pos[0];
csp->values[RED] = csp->pos[1];
csp->values[BLUE] = csp->pos[2];
case COLOR_SELECT_BLUE:
csp->values[COLOR_SELECT_GREEN] = csp->pos[0];
csp->values[COLOR_SELECT_RED] = csp->pos[1];
csp->values[COLOR_SELECT_BLUE] = csp->pos[2];
break;
case HUE:
csp->values[VALUE] = csp->pos[0] * 100 / 255;
csp->values[SATURATION] = csp->pos[1] * 100 / 255;
csp->values[HUE] = csp->pos[2] * 360 / 255;
case COLOR_SELECT_HUE:
csp->values[COLOR_SELECT_VALUE] = csp->pos[0] * 100 / 255;
csp->values[COLOR_SELECT_SATURATION] = csp->pos[1] * 100 / 255;
csp->values[COLOR_SELECT_HUE] = csp->pos[2] * 360 / 255;
break;
case SATURATION:
csp->values[VALUE] = csp->pos[0] * 100 / 255;
csp->values[HUE] = csp->pos[1] * 360 / 255;
csp->values[SATURATION] = csp->pos[2] * 100 / 255;
case COLOR_SELECT_SATURATION:
csp->values[COLOR_SELECT_VALUE] = csp->pos[0] * 100 / 255;
csp->values[COLOR_SELECT_HUE] = csp->pos[1] * 360 / 255;
csp->values[COLOR_SELECT_SATURATION] = csp->pos[2] * 100 / 255;
break;
case VALUE:
csp->values[SATURATION] = csp->pos[0] * 100 / 255;
csp->values[HUE] = csp->pos[1] * 360 / 255;
csp->values[VALUE] = csp->pos[2] * 100 / 255;
case COLOR_SELECT_VALUE:
csp->values[COLOR_SELECT_SATURATION] = csp->pos[0] * 100 / 255;
csp->values[COLOR_SELECT_HUE] = csp->pos[1] * 360 / 255;
csp->values[COLOR_SELECT_VALUE] = csp->pos[2] * 100 / 255;
break;
}
switch (csp->z_color_fill)
{
case RED:
case GREEN:
case BLUE:
case COLOR_SELECT_RED:
case COLOR_SELECT_GREEN:
case COLOR_SELECT_BLUE:
color_select_update_hsv_values (csp);
break;
case HUE:
case SATURATION:
case VALUE:
case COLOR_SELECT_HUE:
case COLOR_SELECT_SATURATION:
case COLOR_SELECT_VALUE:
color_select_update_rgb_values (csp);
break;
}
@ -649,15 +649,15 @@ color_select_update_rgb_values (ColorSelect *csp)
if (csp)
{
h = csp->values[HUE];
s = csp->values[SATURATION] / 100.0;
v = csp->values[VALUE] / 100.0;
h = csp->values[COLOR_SELECT_HUE];
s = csp->values[COLOR_SELECT_SATURATION] / 100.0;
v = csp->values[COLOR_SELECT_VALUE] / 100.0;
if (s == 0)
{
csp->values[RED] = v * 255;
csp->values[GREEN] = v * 255;
csp->values[BLUE] = v * 255;
csp->values[COLOR_SELECT_RED] = v * 255;
csp->values[COLOR_SELECT_GREEN] = v * 255;
csp->values[COLOR_SELECT_BLUE] = v * 255;
}
else
{
@ -673,34 +673,34 @@ color_select_update_rgb_values (ColorSelect *csp)
switch ((int) h)
{
case 0:
csp->values[RED] = v * 255;
csp->values[GREEN] = t * 255;
csp->values[BLUE] = p * 255;
csp->values[COLOR_SELECT_RED] = v * 255;
csp->values[COLOR_SELECT_GREEN] = t * 255;
csp->values[COLOR_SELECT_BLUE] = p * 255;
break;
case 1:
csp->values[RED] = q * 255;
csp->values[GREEN] = v * 255;
csp->values[BLUE] = p * 255;
csp->values[COLOR_SELECT_RED] = q * 255;
csp->values[COLOR_SELECT_GREEN] = v * 255;
csp->values[COLOR_SELECT_BLUE] = p * 255;
break;
case 2:
csp->values[RED] = p * 255;
csp->values[GREEN] = v * 255;
csp->values[BLUE] = t * 255;
csp->values[COLOR_SELECT_RED] = p * 255;
csp->values[COLOR_SELECT_GREEN] = v * 255;
csp->values[COLOR_SELECT_BLUE] = t * 255;
break;
case 3:
csp->values[RED] = p * 255;
csp->values[GREEN] = q * 255;
csp->values[BLUE] = v * 255;
csp->values[COLOR_SELECT_RED] = p * 255;
csp->values[COLOR_SELECT_GREEN] = q * 255;
csp->values[COLOR_SELECT_BLUE] = v * 255;
break;
case 4:
csp->values[RED] = t * 255;
csp->values[GREEN] = p * 255;
csp->values[BLUE] = v * 255;
csp->values[COLOR_SELECT_RED] = t * 255;
csp->values[COLOR_SELECT_GREEN] = p * 255;
csp->values[COLOR_SELECT_BLUE] = v * 255;
break;
case 5:
csp->values[RED] = v * 255;
csp->values[GREEN] = p * 255;
csp->values[BLUE] = q * 255;
csp->values[COLOR_SELECT_RED] = v * 255;
csp->values[COLOR_SELECT_GREEN] = p * 255;
csp->values[COLOR_SELECT_BLUE] = q * 255;
break;
}
}
@ -717,9 +717,9 @@ color_select_update_hsv_values (ColorSelect *csp)
if (csp)
{
r = csp->values[RED];
g = csp->values[GREEN];
b = csp->values[BLUE];
r = csp->values[COLOR_SELECT_RED];
g = csp->values[COLOR_SELECT_GREEN];
b = csp->values[COLOR_SELECT_BLUE];
if (r > g)
{
@ -771,9 +771,9 @@ color_select_update_hsv_values (ColorSelect *csp)
h += 360;
}
csp->values[HUE] = h;
csp->values[SATURATION] = s * 100;
csp->values[VALUE] = v * 100 / 255;
csp->values[COLOR_SELECT_HUE] = h;
csp->values[COLOR_SELECT_SATURATION] = s * 100;
csp->values[COLOR_SELECT_VALUE] = v * 100 / 255;
}
}
@ -784,35 +784,35 @@ color_select_update_pos (ColorSelect *csp)
{
switch (csp->z_color_fill)
{
case RED:
csp->pos[0] = csp->values[BLUE];
csp->pos[1] = csp->values[GREEN];
csp->pos[2] = csp->values[RED];
case COLOR_SELECT_RED:
csp->pos[0] = csp->values[COLOR_SELECT_BLUE];
csp->pos[1] = csp->values[COLOR_SELECT_GREEN];
csp->pos[2] = csp->values[COLOR_SELECT_RED];
break;
case GREEN:
csp->pos[0] = csp->values[BLUE];
csp->pos[1] = csp->values[RED];
csp->pos[2] = csp->values[GREEN];
case COLOR_SELECT_GREEN:
csp->pos[0] = csp->values[COLOR_SELECT_BLUE];
csp->pos[1] = csp->values[COLOR_SELECT_RED];
csp->pos[2] = csp->values[COLOR_SELECT_GREEN];
break;
case BLUE:
csp->pos[0] = csp->values[GREEN];
csp->pos[1] = csp->values[RED];
csp->pos[2] = csp->values[BLUE];
case COLOR_SELECT_BLUE:
csp->pos[0] = csp->values[COLOR_SELECT_GREEN];
csp->pos[1] = csp->values[COLOR_SELECT_RED];
csp->pos[2] = csp->values[COLOR_SELECT_BLUE];
break;
case HUE:
csp->pos[0] = csp->values[VALUE] * 255 / 100;
csp->pos[1] = csp->values[SATURATION] * 255 / 100;
csp->pos[2] = csp->values[HUE] * 255 / 360;
case COLOR_SELECT_HUE:
csp->pos[0] = csp->values[COLOR_SELECT_VALUE] * 255 / 100;
csp->pos[1] = csp->values[COLOR_SELECT_SATURATION] * 255 / 100;
csp->pos[2] = csp->values[COLOR_SELECT_HUE] * 255 / 360;
break;
case SATURATION:
csp->pos[0] = csp->values[VALUE] * 255 / 100;
csp->pos[1] = csp->values[HUE] * 255 / 360;
csp->pos[2] = csp->values[SATURATION] * 255 / 100;
case COLOR_SELECT_SATURATION:
csp->pos[0] = csp->values[COLOR_SELECT_VALUE] * 255 / 100;
csp->pos[1] = csp->values[COLOR_SELECT_HUE] * 255 / 360;
csp->pos[2] = csp->values[COLOR_SELECT_SATURATION] * 255 / 100;
break;
case VALUE:
csp->pos[0] = csp->values[SATURATION] * 255 / 100;
csp->pos[1] = csp->values[HUE] * 255 / 360;
csp->pos[2] = csp->values[VALUE] * 255 / 100;
case COLOR_SELECT_VALUE:
csp->pos[0] = csp->values[COLOR_SELECT_SATURATION] * 255 / 100;
csp->pos[1] = csp->values[COLOR_SELECT_HUE] * 255 / 360;
csp->pos[2] = csp->values[COLOR_SELECT_VALUE] * 255 / 100;
break;
}
}
@ -858,9 +858,9 @@ color_select_update_entries (ColorSelect *csp,
}
g_snprintf (buffer, sizeof (buffer), "#%.2x%.2x%.2x",
csp->values[RED],
csp->values[GREEN],
csp->values[BLUE]);
csp->values[COLOR_SELECT_RED],
csp->values[COLOR_SELECT_GREEN],
csp->values[COLOR_SELECT_BLUE]);
gtk_entry_set_text (GTK_ENTRY (csp->hex_entry), buffer);
}
}
@ -888,9 +888,9 @@ color_select_update_colors (ColorSelect *csp,
{
window = csp->new_color->window;
color.pixel = new_color_pixel;
red = csp->values[RED];
green = csp->values[GREEN];
blue = csp->values[BLUE];
red = csp->values[COLOR_SELECT_RED];
green = csp->values[COLOR_SELECT_GREEN];
blue = csp->values[COLOR_SELECT_BLUE];
}
/* if we haven't yet been realised, there's no need to redraw
@ -1165,9 +1165,9 @@ color_select_slider_update (GtkAdjustment *adjustment,
csp->values[i] = (int) adjustment->value;
if ((i >= HUE) && (i <= VALUE))
if ((i >= COLOR_SELECT_HUE) && (i <= COLOR_SELECT_VALUE))
color_select_update_rgb_values (csp);
else if ((i >= RED) && (i <= BLUE))
else if ((i >= COLOR_SELECT_RED) && (i <= COLOR_SELECT_BLUE))
color_select_update_hsv_values (csp);
color_select_update_sliders (csp, i);
color_select_update_entries (csp, -1);
@ -1238,9 +1238,9 @@ color_select_entry_update (GtkWidget *widget,
if (csp->values[i] == old_values[i])
return;
if ((i >= HUE) && (i <= VALUE))
if ((i >= COLOR_SELECT_HUE) && (i <= COLOR_SELECT_VALUE))
color_select_update_rgb_values (csp);
else if ((i >= RED) && (i <= BLUE))
else if ((i >= COLOR_SELECT_RED) && (i <= COLOR_SELECT_BLUE))
color_select_update_hsv_values (csp);
color_select_update_entries (csp, i);
color_select_update_sliders (csp, -1);
@ -1291,7 +1291,7 @@ color_select_toggle_update (GtkWidget *widget,
gpointer data)
{
ColorSelect *csp;
ColorSelectFillType type = HUE;
ColorSelectFillType type = COLOR_SELECT_HUE;
gint i;
if (!GTK_TOGGLE_BUTTON (widget)->active)
@ -1307,29 +1307,29 @@ color_select_toggle_update (GtkWidget *widget,
switch (type)
{
case HUE:
csp->z_color_fill = HUE;
csp->xy_color_fill = SATURATION_VALUE;
case COLOR_SELECT_HUE:
csp->z_color_fill = COLOR_SELECT_HUE;
csp->xy_color_fill = COLOR_SELECT_SATURATION_VALUE;
break;
case SATURATION:
csp->z_color_fill = SATURATION;
csp->xy_color_fill = HUE_VALUE;
case COLOR_SELECT_SATURATION:
csp->z_color_fill = COLOR_SELECT_SATURATION;
csp->xy_color_fill = COLOR_SELECT_HUE_VALUE;
break;
case VALUE:
csp->z_color_fill = VALUE;
csp->xy_color_fill = HUE_SATURATION;
case COLOR_SELECT_VALUE:
csp->z_color_fill = COLOR_SELECT_VALUE;
csp->xy_color_fill = COLOR_SELECT_HUE_SATURATION;
break;
case RED:
csp->z_color_fill = RED;
csp->xy_color_fill = GREEN_BLUE;
case COLOR_SELECT_RED:
csp->z_color_fill = COLOR_SELECT_RED;
csp->xy_color_fill = COLOR_SELECT_GREEN_BLUE;
break;
case GREEN:
csp->z_color_fill = GREEN;
csp->xy_color_fill = RED_BLUE;
case COLOR_SELECT_GREEN:
csp->z_color_fill = COLOR_SELECT_GREEN;
csp->xy_color_fill = COLOR_SELECT_RED_BLUE;
break;
case BLUE:
csp->z_color_fill = BLUE;
csp->xy_color_fill = RED_GREEN;
case COLOR_SELECT_BLUE:
csp->z_color_fill = COLOR_SELECT_BLUE;
csp->xy_color_fill = COLOR_SELECT_RED_GREEN;
break;
default:
break;
@ -1357,9 +1357,9 @@ color_select_hex_entry_leave (GtkWidget *widget,
hex_color = g_strdup (gtk_entry_get_text (GTK_ENTRY (csp->hex_entry)));
g_snprintf(buffer, sizeof (buffer), "#%.2x%.2x%.2x",
csp->values[RED],
csp->values[GREEN],
csp->values[BLUE]);
csp->values[COLOR_SELECT_RED],
csp->values[COLOR_SELECT_GREEN],
csp->values[COLOR_SELECT_BLUE]);
if ((strlen (hex_color) == 7) &&
(g_strcasecmp (buffer, hex_color) != 0))
@ -1688,7 +1688,7 @@ color_select_update_red_green (ColorSelectFill *csf)
p = csf->buffer;
csf->y += 1;
b = csf->values[BLUE];
b = csf->values[COLOR_SELECT_BLUE];
r = (csf->height - csf->y + 1) * 255 / csf->height;
if (r < 0)
@ -1719,7 +1719,7 @@ color_select_update_red_blue (ColorSelectFill *csf)
p = csf->buffer;
csf->y += 1;
g = csf->values[GREEN];
g = csf->values[COLOR_SELECT_GREEN];
r = (csf->height - csf->y + 1) * 255 / csf->height;
if (r < 0)
@ -1750,7 +1750,7 @@ color_select_update_green_blue (ColorSelectFill *csf)
p = csf->buffer;
csf->y += 1;
r = csf->values[RED];
r = csf->values[COLOR_SELECT_RED];
g = (csf->height - csf->y + 1) * 255 / csf->height;
if (g < 0)
@ -1795,7 +1795,7 @@ color_select_update_hue_saturation (ColorSelectFill *csf)
s = 0;
ds = 1.0 / csf->width;
v = csf->values[VALUE] / 100.0;
v = csf->values[COLOR_SELECT_VALUE] / 100.0;
switch ((int) h)
{
@ -1886,7 +1886,7 @@ color_select_update_hue_value (ColorSelectFill *csf)
v = 0;
dv = 1.0 / csf->width;
s = csf->values[SATURATION] / 100.0;
s = csf->values[COLOR_SELECT_SATURATION] / 100.0;
switch ((int) h)
{
@ -1973,7 +1973,7 @@ color_select_update_saturation_value (ColorSelectFill *csf)
s = 1 - s;
h = (float) csf->values[HUE];
h = (float) csf->values[COLOR_SELECT_HUE];
if (h >= 360)
h -= 360;
h /= 60;
@ -2081,14 +2081,14 @@ color_select_notebook_new (gint r,
csp->callback = color_select_notebook_update_callback;
csp->client_data = glue;
csp->z_color_fill = HUE;
csp->xy_color_fill = SATURATION_VALUE;
csp->z_color_fill = COLOR_SELECT_HUE;
csp->xy_color_fill = COLOR_SELECT_SATURATION_VALUE;
csp->gc = NULL;
csp->wants_updates = TRUE;
csp->values[RED] = csp->orig_values[0] = r;
csp->values[GREEN] = csp->orig_values[1] = g;
csp->values[BLUE] = csp->orig_values[2] = b;
csp->values[COLOR_SELECT_RED] = csp->orig_values[0] = r;
csp->values[COLOR_SELECT_GREEN] = csp->orig_values[1] = g;
csp->values[COLOR_SELECT_BLUE] = csp->orig_values[2] = b;
color_select_update_hsv_values (csp);
color_select_update_pos (csp);

View File

@ -39,7 +39,7 @@
#include "gimprc.h"
#include "gimpui.h"
#include "global_edit.h"
#include "gradient.h"
#include "gradient_select.h"
#include "image_render.h"
#include "info_window.h"
#include "nav_window.h"
@ -1103,10 +1103,10 @@ dialogs_palette_cmd_callback (GtkWidget *widget,
}
void
dialogs_gradient_editor_cmd_callback (GtkWidget *widget,
gpointer client_data)
dialogs_gradient_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
grad_create_gradient_editor ();
gradient_dialog_create ();
}
void

View File

@ -99,7 +99,7 @@ void filters_repeat_cmd_callback (GtkWidget *widget,
void dialogs_brushes_cmd_callback (GtkWidget *, gpointer);
void dialogs_patterns_cmd_callback (GtkWidget *, gpointer);
void dialogs_palette_cmd_callback (GtkWidget *, gpointer);
void dialogs_gradient_editor_cmd_callback (GtkWidget *, gpointer);
void dialogs_gradient_cmd_callback (GtkWidget *, gpointer);
void dialogs_lc_cmd_callback (GtkWidget *, gpointer);
void dialogs_indexed_palette_cmd_callback (GtkWidget *, gpointer);
void dialogs_tools_options_cmd_callback (GtkWidget *, gpointer);

View File

@ -424,7 +424,7 @@ static GtkWidget *build_palette_menu(int *default_palette);
static void palette_entries_callback(GtkWidget *w, gpointer client_data);
static gboolean UserHasWebPal = FALSE;
PaletteEntriesP theCustomPalette = NULL;
PaletteEntries *theCustomPalette = NULL;
/* Defaults */
@ -802,7 +802,7 @@ build_palette_menu (int *default_palette)
GtkWidget *menu;
GtkWidget *menu_item;
GSList *list;
PaletteEntriesP entries;
PaletteEntries *entries;
int i, item;
UserHasWebPal = FALSE;
@ -823,7 +823,7 @@ build_palette_menu (int *default_palette)
list;
i++, list = g_slist_next (list))
{
entries = (PaletteEntriesP) list->data;
entries = (PaletteEntries *) list->data;
/* Preferentially, the initial default is 'Web' if available */
if (*default_palette==-1 &&
@ -853,7 +853,7 @@ build_palette_menu (int *default_palette)
/* default to first one (only used if 'web' palette not avail.) */
if (*default_palette==-1)
{
theCustomPalette = (PaletteEntriesP) palette_entries_list->data;
theCustomPalette = (PaletteEntries *) palette_entries_list->data;
*default_palette = 0;
}
return menu;
@ -863,7 +863,7 @@ static void
palette_entries_callback (GtkWidget *widget,
gpointer data)
{
theCustomPalette = (PaletteEntriesP) data;
theCustomPalette = (PaletteEntries *) data;
}
static void
@ -2958,7 +2958,7 @@ custompal_pass1 (QuantizeObj *quantobj)
{
int i;
GSList *list;
PaletteEntryP entry;
PaletteEntry *entry;
/* fprintf(stderr, "custompal_pass1: using (theCustomPalette %s) from (file %s)\n",
theCustomPalette->name, theCustomPalette->filename);*/
@ -2967,7 +2967,7 @@ custompal_pass1 (QuantizeObj *quantobj)
list;
i++,list=g_slist_next(list))
{
entry=(PaletteEntryP)list->data;
entry = (PaletteEntry *) list->data;
quantobj->cmap[i].red = entry->color[0];
quantobj->cmap[i].green = entry->color[1];
quantobj->cmap[i].blue = entry->color[2];

View File

@ -24,7 +24,8 @@
#include "palette_entries.h"
/* adam's extra palette stuff */
typedef enum {
typedef enum
{
MAKE_PALETTE = 0,
REUSE_PALETTE = 1,
WEB_PALETTE = 2,
@ -33,7 +34,8 @@ typedef enum {
} ConvertPaletteType;
/* adam's extra dither stuff */
typedef enum {
typedef enum
{
NO_DITHER = 0,
FS_DITHER = 1,
FSLOWBLEED_DITHER = 2,
@ -51,12 +53,12 @@ void convert_to_indexed (GimpImage *);
void convert_image (GimpImage *,
GimpImageBaseType,
int num_cols,
gint num_cols,
ConvertDitherType,
int alpha_dither,
int remdups,
gint alpha_dither,
gint remdups,
ConvertPaletteType);
extern PaletteEntriesP theCustomPalette;
extern PaletteEntries *theCustomPalette;
#endif /* __CONVERT_H__ */

View File

@ -158,7 +158,8 @@ convert_indexed_invoker (Argument *args)
{
if ((success = (gimage_base_type (gimage) != INDEXED)))
{
PaletteEntriesP entries, the_palette = NULL;
PaletteEntries *entries;
PaletteEntries *the_palette = NULL;
GSList *list;
switch (dither_type)
@ -191,7 +192,7 @@ convert_indexed_invoker (Argument *args)
for (list = palette_entries_list; list; list = list->next)
{
entries = (PaletteEntriesP) list->data;
entries = (PaletteEntries *) list->data;
if (!strcmp (palette_name, entries->name))
{
the_palette = entries;

View File

@ -1680,23 +1680,18 @@ gimp_context_refresh_gradient (GimpContext *context,
gpointer data)
{
gradient_t *gradient;
GSList *list;
if (! context->gradient_name)
context->gradient_name = g_strdup (default_gradient);
for (list = gradients_list; list; list = g_slist_next (list))
if ((gradient = gradient_list_get_gradient (gradients_list,
context->gradient_name)))
{
gradient = (gradient_t *) list->data;
if (strcmp (gradient->name, context->gradient_name) == 0)
{
context->gradient = gradient;
gtk_signal_emit (GTK_OBJECT (context),
gimp_context_signals[GRADIENT_CHANGED],
gradient);
return;
}
context->gradient = gradient;
gtk_signal_emit (GTK_OBJECT (context),
gimp_context_signals[GRADIENT_CHANGED],
gradient);
return;
}
g_free (context->gradient_name);

View File

@ -424,7 +424,7 @@ static GtkWidget *build_palette_menu(int *default_palette);
static void palette_entries_callback(GtkWidget *w, gpointer client_data);
static gboolean UserHasWebPal = FALSE;
PaletteEntriesP theCustomPalette = NULL;
PaletteEntries *theCustomPalette = NULL;
/* Defaults */
@ -802,7 +802,7 @@ build_palette_menu (int *default_palette)
GtkWidget *menu;
GtkWidget *menu_item;
GSList *list;
PaletteEntriesP entries;
PaletteEntries *entries;
int i, item;
UserHasWebPal = FALSE;
@ -823,7 +823,7 @@ build_palette_menu (int *default_palette)
list;
i++, list = g_slist_next (list))
{
entries = (PaletteEntriesP) list->data;
entries = (PaletteEntries *) list->data;
/* Preferentially, the initial default is 'Web' if available */
if (*default_palette==-1 &&
@ -853,7 +853,7 @@ build_palette_menu (int *default_palette)
/* default to first one (only used if 'web' palette not avail.) */
if (*default_palette==-1)
{
theCustomPalette = (PaletteEntriesP) palette_entries_list->data;
theCustomPalette = (PaletteEntries *) palette_entries_list->data;
*default_palette = 0;
}
return menu;
@ -863,7 +863,7 @@ static void
palette_entries_callback (GtkWidget *widget,
gpointer data)
{
theCustomPalette = (PaletteEntriesP) data;
theCustomPalette = (PaletteEntries *) data;
}
static void
@ -2958,7 +2958,7 @@ custompal_pass1 (QuantizeObj *quantobj)
{
int i;
GSList *list;
PaletteEntryP entry;
PaletteEntry *entry;
/* fprintf(stderr, "custompal_pass1: using (theCustomPalette %s) from (file %s)\n",
theCustomPalette->name, theCustomPalette->filename);*/
@ -2967,7 +2967,7 @@ custompal_pass1 (QuantizeObj *quantobj)
list;
i++,list=g_slist_next(list))
{
entry=(PaletteEntryP)list->data;
entry = (PaletteEntry *) list->data;
quantobj->cmap[i].red = entry->color[0];
quantobj->cmap[i].green = entry->color[1];
quantobj->cmap[i].blue = entry->color[2];

View File

@ -24,7 +24,8 @@
#include "palette_entries.h"
/* adam's extra palette stuff */
typedef enum {
typedef enum
{
MAKE_PALETTE = 0,
REUSE_PALETTE = 1,
WEB_PALETTE = 2,
@ -33,7 +34,8 @@ typedef enum {
} ConvertPaletteType;
/* adam's extra dither stuff */
typedef enum {
typedef enum
{
NO_DITHER = 0,
FS_DITHER = 1,
FSLOWBLEED_DITHER = 2,
@ -51,12 +53,12 @@ void convert_to_indexed (GimpImage *);
void convert_image (GimpImage *,
GimpImageBaseType,
int num_cols,
gint num_cols,
ConvertDitherType,
int alpha_dither,
int remdups,
gint alpha_dither,
gint remdups,
ConvertPaletteType);
extern PaletteEntriesP theCustomPalette;
extern PaletteEntries *theCustomPalette;
#endif /* __CONVERT_H__ */

View File

@ -29,6 +29,7 @@
#include "gimpcontext.h"
#include "gimprc.h"
#include "gimpui.h"
#include "gradient.h"
#include "gradient_header.h"
#include "session.h"
#include "tools.h"
@ -47,7 +48,8 @@
#define DEVICE_CONTEXT_MASK GIMP_CONTEXT_TOOL_MASK | \
GIMP_CONTEXT_FOREGROUND_MASK | \
GIMP_CONTEXT_BRUSH_MASK | \
GIMP_CONTEXT_PATTERN_MASK
GIMP_CONTEXT_PATTERN_MASK | \
GIMP_CONTEXT_GRADIENT_MASK
typedef struct _DeviceInfo DeviceInfo;
@ -86,47 +88,57 @@ struct _DeviceInfoDialog
GtkWidget **colors;
GtkWidget **brushes;
GtkWidget **patterns;
GtkWidget **gradients;
GtkWidget **eventboxes;
};
/* local functions */
static void input_dialog_destroy_callback (GtkWidget *, gpointer);
static void input_dialog_able_callback (GtkWidget *w, guint32 deviceid,
gpointer data);
static void input_dialog_destroy_callback (GtkWidget *, gpointer);
static void input_dialog_able_callback (GtkWidget *w, guint32 deviceid,
gpointer data);
static void devices_write_rc_device (DeviceInfo *device_info, FILE *fp);
static void devices_write_rc (void);
static void devices_write_rc_device (DeviceInfo *device_info,
FILE *fp);
static void devices_write_rc (void);
static void device_status_destroy_callback (void);
static void devices_close_callback (GtkWidget *, gpointer);
static void device_status_destroy_callback (void);
static void devices_close_callback (GtkWidget *, gpointer);
static void device_status_update (guint32 deviceid);
static void device_status_update_current (void);
static void device_status_update (guint32 deviceid);
static void device_status_update_current (void);
static void device_status_drag_color (GtkWidget *,
guchar *, guchar *, guchar *,
gpointer);
static void device_status_drop_color (GtkWidget *,
guchar, guchar, guchar,
gpointer);
static void device_status_drop_brush (GtkWidget *,
GdkDragContext *,
gint, gint, guint, gpointer);
static void device_status_drop_pattern (GtkWidget *,
GdkDragContext *,
gint, gint, guint, gpointer);
static ToolType device_status_drag_tool (GtkWidget *,
gpointer);
static void device_status_drop_tool (GtkWidget *,
ToolType,
gpointer);
static void device_status_drag_color (GtkWidget *,
guchar *, guchar *, guchar *,
gpointer);
static void device_status_drop_color (GtkWidget *,
guchar, guchar, guchar,
gpointer);
static void device_status_drop_brush (GtkWidget *,
GimpBrush *,
gpointer);
static void device_status_drop_pattern (GtkWidget *,
GPattern *,
gpointer);
static void device_status_drop_gradient (GtkWidget *,
gradient_t *,
gpointer);
static void device_status_color_changed (GimpContext *context,
gint r,
gint g,
gint b,
gpointer data);
static void device_status_data_changed (GimpContext *context,
gpointer dummy,
gpointer data);
static void device_status_color_changed (GimpContext *context,
gint r,
gint g,
gint b,
gpointer data);
static void device_status_data_changed (GimpContext *context,
gpointer dummy,
gpointer data);
static void device_status_context_connect (GimpContext *context,
guint32 deviceid);
static void device_status_context_connect (GimpContext *context,
guint32 deviceid);
/* global data */
gint current_device = GDK_CORE_POINTER;
@ -139,6 +151,13 @@ static DeviceInfoDialog *deviceD = NULL;
static gboolean suppress_update = FALSE;
/* dnd stuff */
static GtkTargetEntry tool_target_table[] =
{
GIMP_TARGET_TOOL
};
static guint n_tool_targets = (sizeof (tool_target_table) /
sizeof (tool_target_table[0]));
static GtkTargetEntry color_area_target_table[] =
{
GIMP_TARGET_COLOR
@ -146,20 +165,6 @@ static GtkTargetEntry color_area_target_table[] =
static guint n_color_area_targets = (sizeof (color_area_target_table) /
sizeof (color_area_target_table[0]));
static GtkTargetEntry brush_area_target_table[] =
{
GIMP_TARGET_BRUSH
};
static guint n_brush_area_targets = (sizeof (brush_area_target_table) /
sizeof (brush_area_target_table[0]));
static GtkTargetEntry pattern_area_target_table[] =
{
GIMP_TARGET_PATTERN
};
static guint n_pattern_area_targets = (sizeof (pattern_area_target_table) /
sizeof (pattern_area_target_table[0]));
/* utility functions for the device lists */
static GdkDeviceInfo *
@ -487,19 +492,9 @@ devices_rc_update (gchar *name,
if (values & DEVICE_GRADIENT)
{
gradient_t *gradient;
GSList *list;
for (list = gradients_list; list; list = g_slist_next (list))
{
gradient = (gradient_t *) list->data;
if (! strcmp (gradient->name, gradient_name))
{
gimp_context_set_gradient (device_info->context, gradient);
break;
}
}
gimp_context_set_gradient (device_info->context,
gradient_list_get_gradient (gradients_list,
gradient_name));
}
}
@ -686,6 +681,12 @@ devices_write_rc_device (DeviceInfo *device_info,
gimp_context_get_pattern (device_info->context)->name);
}
if (gimp_context_get_gradient (device_info->context))
{
fprintf (fp, "\n (gradient \"%s\")",
gimp_context_get_gradient (device_info->context)->name);
}
fprintf(fp,")\n");
}
@ -750,7 +751,7 @@ device_status_create (void)
}
/* devices table */
deviceD->table = gtk_table_new (deviceD->num_devices, 5, FALSE);
deviceD->table = gtk_table_new (deviceD->num_devices, 6, FALSE);
gtk_container_set_border_width (GTK_CONTAINER (deviceD->table), 3);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (deviceD->shell)->vbox),
deviceD->table);
@ -763,6 +764,7 @@ device_status_create (void)
deviceD->colors = g_new (GtkWidget *, deviceD->num_devices);
deviceD->brushes = g_new (GtkWidget *, deviceD->num_devices);
deviceD->patterns = g_new (GtkWidget *, deviceD->num_devices);
deviceD->gradients = g_new (GtkWidget *, deviceD->num_devices);
deviceD->eventboxes = g_new (GtkWidget *, deviceD->num_devices);
for (list = device_info_list, i = 0; list; list = g_list_next (list), i++)
@ -792,14 +794,27 @@ device_status_create (void)
/* the tool */
deviceD->eventboxes[i] = gtk_event_box_new();
deviceD->tools[i] =
gtk_pixmap_new (create_tool_pixmap (deviceD->table, RECT_SELECT),
NULL);
gtk_drag_source_set (deviceD->eventboxes[i],
GDK_BUTTON1_MASK,
tool_target_table, n_tool_targets,
GDK_ACTION_COPY);
gimp_dnd_tool_source_set (deviceD->eventboxes[i],
device_status_drag_tool,
GUINT_TO_POINTER (device_info->device));
gtk_drag_dest_set (deviceD->eventboxes[i],
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
tool_target_table, n_tool_targets,
GDK_ACTION_COPY);
gimp_dnd_tool_dest_set (deviceD->eventboxes[i],
device_status_drop_tool,
GUINT_TO_POINTER (device_info->device));
gtk_container_add (GTK_CONTAINER (deviceD->eventboxes[i]),
deviceD->tools[i]);
gtk_table_attach (GTK_TABLE (deviceD->table), deviceD->eventboxes[i],
1, 2, i, i+1,
0, 0, 2, 2);
@ -831,40 +846,40 @@ device_status_create (void)
/* the brush */
deviceD->brushes[i] = gimp_context_preview_new (GCP_BRUSH,
CELL_SIZE, CELL_SIZE,
FALSE, TRUE, TRUE);
gtk_drag_dest_set (deviceD->brushes[i],
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
brush_area_target_table, n_brush_area_targets,
GDK_ACTION_COPY);
gtk_signal_connect (GTK_OBJECT (deviceD->brushes[i]), "drag_drop",
GTK_SIGNAL_FUNC (device_status_drop_brush),
GUINT_TO_POINTER (device_info->device));
deviceD->brushes[i] =
gimp_context_preview_new (GCP_BRUSH,
CELL_SIZE, CELL_SIZE,
FALSE, TRUE, TRUE,
GTK_SIGNAL_FUNC (device_status_drop_brush),
GUINT_TO_POINTER (device_info->device));
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->brushes[i],
3, 4, i, i+1,
0, 0, 2, 2);
/* the pattern */
deviceD->patterns[i] = gimp_context_preview_new (GCP_PATTERN,
CELL_SIZE, CELL_SIZE,
FALSE, TRUE, TRUE);
gtk_drag_dest_set (deviceD->patterns[i],
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
pattern_area_target_table, n_pattern_area_targets,
GDK_ACTION_COPY);
gtk_signal_connect (GTK_OBJECT (deviceD->patterns[i]), "drag_drop",
GTK_SIGNAL_FUNC (device_status_drop_pattern),
GUINT_TO_POINTER (device_info->device));
deviceD->patterns[i] =
gimp_context_preview_new (GCP_PATTERN,
CELL_SIZE, CELL_SIZE,
FALSE, TRUE, TRUE,
GTK_SIGNAL_FUNC (device_status_drop_pattern),
GUINT_TO_POINTER (device_info->device));
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->patterns[i],
4, 5, i, i+1,
0, 0, 2, 2);
/* the gradient */
deviceD->gradients[i] =
gimp_context_preview_new (GCP_GRADIENT,
CELL_SIZE * 2, CELL_SIZE,
FALSE, TRUE, TRUE,
GTK_SIGNAL_FUNC (device_status_drop_gradient),
GUINT_TO_POINTER (device_info->device));
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->gradients[i],
5, 6, i, i+1,
0, 0, 2, 2);
device_status_update (device_info->device);
}
@ -896,6 +911,7 @@ device_status_destroy_callback (void)
g_free (deviceD->colors);
g_free (deviceD->brushes);
g_free (deviceD->patterns);
g_free (deviceD->gradients);
g_free (deviceD);
deviceD = NULL;
@ -977,6 +993,7 @@ device_status_update (guint32 deviceid)
gtk_widget_hide (deviceD->colors[i]);
gtk_widget_hide (deviceD->brushes[i]);
gtk_widget_hide (deviceD->patterns[i]);
gtk_widget_hide (deviceD->gradients[i]);
}
else
{
@ -1033,11 +1050,52 @@ device_status_update (guint32 deviceid)
gimp_context_get_pattern (device_info->context));
gtk_widget_show (deviceD->patterns[i]);
}
if (gimp_context_get_gradient (device_info->context))
{
gimp_context_preview_update
(GIMP_CONTEXT_PREVIEW (deviceD->gradients[i]),
gimp_context_get_gradient (device_info->context));
gtk_widget_show (deviceD->gradients[i]);
}
}
}
/* dnd stuff */
static ToolType
device_status_drag_tool (GtkWidget *widget,
gpointer data)
{
DeviceInfo *device_info;
device_info = device_info_get_by_id (GPOINTER_TO_UINT (data));
if (device_info)
{
return gimp_context_get_tool (device_info->context);
}
else
{
return RECT_SELECT;
}
}
static void
device_status_drop_tool (GtkWidget *widget,
ToolType tool,
gpointer data)
{
DeviceInfo *device_info;
device_info = device_info_get_by_id (GPOINTER_TO_UINT (data));
if (device_info && device_info->is_present)
{
gimp_context_set_tool (device_info->context, tool);
}
}
static void
device_status_drag_color (GtkWidget *widget,
guchar *r,
@ -1077,24 +1135,11 @@ device_status_drop_color (GtkWidget *widget,
}
static void
device_status_drop_brush (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time,
gpointer data)
device_status_drop_brush (GtkWidget *widget,
GimpBrush *brush,
gpointer data)
{
DeviceInfo *device_info;
GtkWidget *src;
GimpBrush *brush = NULL;
src = gtk_drag_get_source_widget (context);
if (!src)
return;
brush = (GimpBrush *) gtk_object_get_data (GTK_OBJECT (src), "gimp_brush");
if (!brush)
return;
device_info = device_info_get_by_id (GPOINTER_TO_UINT (data));
@ -1105,24 +1150,11 @@ device_status_drop_brush (GtkWidget *widget,
}
static void
device_status_drop_pattern (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time,
gpointer data)
device_status_drop_pattern (GtkWidget *widget,
GPattern *pattern,
gpointer data)
{
DeviceInfo *device_info;
GtkWidget *src;
GPattern *pattern = NULL;
src = gtk_drag_get_source_widget (context);
if (!src)
return;
pattern = (GPattern *) gtk_object_get_data (GTK_OBJECT (src), "gimp_pattern");
if (!pattern)
return;
device_info = device_info_get_by_id (GPOINTER_TO_UINT (data));
@ -1132,6 +1164,21 @@ device_status_drop_pattern (GtkWidget *widget,
}
}
static void
device_status_drop_gradient (GtkWidget *widget,
gradient_t *gradient,
gpointer data)
{
DeviceInfo *device_info;
device_info = device_info_get_by_id (GPOINTER_TO_UINT (data));
if (device_info && device_info->is_present)
{
gimp_context_set_gradient (device_info->context, gradient);
}
}
/* context callbacks */
static void
@ -1176,4 +1223,7 @@ device_status_context_connect (GimpContext *context,
gtk_signal_connect (GTK_OBJECT (context), "pattern_changed",
GTK_SIGNAL_FUNC (device_status_data_changed),
(gpointer) deviceid);
gtk_signal_connect (GTK_OBJECT (context), "gradient_changed",
GTK_SIGNAL_FUNC (device_status_data_changed),
(gpointer) deviceid);
}

View File

@ -15,7 +15,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <stdlib.h>
@ -640,7 +639,6 @@ gdisplay_drag_drop (GtkWidget *widget,
Channel *channel = NULL;
LayerMask *layer_mask = NULL;
GImage *component = NULL;
GPattern *pattern = NULL;
ChannelType component_type = -1;
layer = (Layer *) gtk_object_get_data (GTK_OBJECT (src_widget),
@ -651,8 +649,6 @@ gdisplay_drag_drop (GtkWidget *widget,
"gimp_layer_mask");
component = (GImage *) gtk_object_get_data (GTK_OBJECT (src_widget),
"gimp_component");
pattern = (GPattern *) gtk_object_get_data (GTK_OBJECT (src_widget),
"gimp_pattern");
if (layer)
{
@ -762,58 +758,6 @@ gdisplay_drag_drop (GtkWidget *widget,
undo_push_group_end (dest_gimage);
}
}
if (pattern)
{
GimpImage *gimage;
GimpDrawable *drawable;
GimpContext *fill_context;
TileManager *buf_tiles;
PixelRegion bufPR;
gint x1, x2, y1, y2;
gint bytes;
gboolean has_alpha;
gimage = gdisp->gimage;
drawable = gimage_active_drawable (gimage);
if (drawable)
{
gimp_add_busy_cursors ();
/* Get the fill parameters */
if (gimp_context_get_current () == gimp_context_get_user () &&
! global_paint_options)
fill_context = tool_info[BUCKET_FILL].tool_context;
else
fill_context = gimp_context_get_current ();
drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
bytes = drawable_bytes (drawable);
has_alpha = drawable_has_alpha (drawable);
/* Fill the region */
buf_tiles = tile_manager_new ((x2 - x1), (y2 - y1), bytes);
pixel_region_init (&bufPR, buf_tiles, 0, 0, (x2 - x1), (y2 - y1), TRUE);
bucket_fill_region (PATTERN_BUCKET_FILL, &bufPR, NULL,
NULL, pattern->mask, x1, y1, has_alpha);
/* Apply it to the image */
pixel_region_init (&bufPR, buf_tiles, 0, 0, (x2 - x1), (y2 - y1), FALSE);
gimage_apply_image (gimage, drawable, &bufPR, TRUE,
gimp_context_get_opacity (fill_context) * 255,
gimp_context_get_paint_mode (fill_context),
NULL, x1, y1);
tile_manager_destroy (buf_tiles);
/* Update the displays */
drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1));
gdisplays_flush ();
gimp_remove_busy_cursors (NULL);
return_val = TRUE;
}
}
}
gtk_drag_finish (context, return_val, FALSE, time);
@ -824,12 +768,12 @@ gdisplay_drag_drop (GtkWidget *widget,
return return_val;
}
void
gdisplay_set_color (GtkWidget *widget,
guchar r,
guchar g,
guchar b,
gpointer data)
static void
gdisplay_bucket_fill (GtkWidget *widget,
BucketFillMode fill_mode,
guchar color[],
TempBuf *pat_buf,
gpointer data)
{
GimpImage *gimage;
GimpDrawable *drawable;
@ -839,7 +783,6 @@ gdisplay_set_color (GtkWidget *widget,
gint x1, x2, y1, y2;
gint bytes;
gboolean has_alpha;
guchar col[3];
gimage = ((GDisplay *) data)->gimage;
drawable = gimage_active_drawable (gimage);
@ -848,27 +791,21 @@ gdisplay_set_color (GtkWidget *widget,
gimp_add_busy_cursors ();
/* Get the fill parameters */
if (gimp_context_get_current () == gimp_context_get_user () &&
! global_paint_options)
/* Get the bucket fill context */
if (! global_paint_options)
context = tool_info[BUCKET_FILL].tool_context;
else
context = gimp_context_get_current ();
context = gimp_context_get_user ();
drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
bytes = drawable_bytes (drawable);
has_alpha = drawable_has_alpha (drawable);
col[0] = r;
col[1] = g;
col[2] = b;
/* Fill the region */
buf_tiles = tile_manager_new ((x2 - x1), (y2 - y1), bytes);
pixel_region_init (&bufPR, buf_tiles, 0, 0, (x2 - x1), (y2 - y1), TRUE);
bucket_fill_region (FG_BUCKET_FILL, &bufPR, NULL,
col, NULL, x1, y1, has_alpha);
bucket_fill_region (fill_mode, &bufPR, NULL,
color, pat_buf, x1, y1, has_alpha);
/* Apply it to the image */
pixel_region_init (&bufPR, buf_tiles, 0, 0, (x2 - x1), (y2 - y1), FALSE);
@ -884,3 +821,27 @@ gdisplay_set_color (GtkWidget *widget,
gimp_remove_busy_cursors (NULL);
}
void
gdisplay_drop_color (GtkWidget *widget,
guchar r,
guchar g,
guchar b,
gpointer data)
{
guchar color[3];
color[0] = r;
color[1] = g;
color[2] = b;
gdisplay_bucket_fill (widget, FG_BUCKET_FILL, color, NULL, data);
}
void
gdisplay_drop_pattern (GtkWidget *widget,
GPattern *pattern,
gpointer data)
{
gdisplay_bucket_fill (widget, PATTERN_BUCKET_FILL, NULL, pattern->mask, data);
}

View File

@ -19,6 +19,7 @@
#define __DISP_CALLBACKS_H__
#include "gdisplay.h"
#include "patterns.h"
#define CANVAS_EVENT_MASK GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | \
GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | \
@ -34,16 +35,19 @@ gint gdisplay_hruler_button_press (GtkWidget *, GdkEventButton *, gpointer);
gint gdisplay_vruler_button_press (GtkWidget *, GdkEventButton *, gpointer);
gint gdisplay_origin_button_press (GtkWidget *, GdkEventButton *, gpointer);
gboolean gdisplay_drag_drop (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time,
gpointer data);
void gdisplay_set_color (GtkWidget *widget,
guchar r,
guchar g,
guchar b,
gpointer data);
gboolean gdisplay_drag_drop (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time,
gpointer data);
void gdisplay_drop_color (GtkWidget *widget,
guchar r,
guchar g,
guchar b,
gpointer data);
void gdisplay_drop_pattern (GtkWidget *widget,
GPattern *pattern,
gpointer data);
#endif /* __DISP_CALLBACKS_H__ */

View File

@ -15,7 +15,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <stdlib.h>
@ -640,7 +639,6 @@ gdisplay_drag_drop (GtkWidget *widget,
Channel *channel = NULL;
LayerMask *layer_mask = NULL;
GImage *component = NULL;
GPattern *pattern = NULL;
ChannelType component_type = -1;
layer = (Layer *) gtk_object_get_data (GTK_OBJECT (src_widget),
@ -651,8 +649,6 @@ gdisplay_drag_drop (GtkWidget *widget,
"gimp_layer_mask");
component = (GImage *) gtk_object_get_data (GTK_OBJECT (src_widget),
"gimp_component");
pattern = (GPattern *) gtk_object_get_data (GTK_OBJECT (src_widget),
"gimp_pattern");
if (layer)
{
@ -762,58 +758,6 @@ gdisplay_drag_drop (GtkWidget *widget,
undo_push_group_end (dest_gimage);
}
}
if (pattern)
{
GimpImage *gimage;
GimpDrawable *drawable;
GimpContext *fill_context;
TileManager *buf_tiles;
PixelRegion bufPR;
gint x1, x2, y1, y2;
gint bytes;
gboolean has_alpha;
gimage = gdisp->gimage;
drawable = gimage_active_drawable (gimage);
if (drawable)
{
gimp_add_busy_cursors ();
/* Get the fill parameters */
if (gimp_context_get_current () == gimp_context_get_user () &&
! global_paint_options)
fill_context = tool_info[BUCKET_FILL].tool_context;
else
fill_context = gimp_context_get_current ();
drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
bytes = drawable_bytes (drawable);
has_alpha = drawable_has_alpha (drawable);
/* Fill the region */
buf_tiles = tile_manager_new ((x2 - x1), (y2 - y1), bytes);
pixel_region_init (&bufPR, buf_tiles, 0, 0, (x2 - x1), (y2 - y1), TRUE);
bucket_fill_region (PATTERN_BUCKET_FILL, &bufPR, NULL,
NULL, pattern->mask, x1, y1, has_alpha);
/* Apply it to the image */
pixel_region_init (&bufPR, buf_tiles, 0, 0, (x2 - x1), (y2 - y1), FALSE);
gimage_apply_image (gimage, drawable, &bufPR, TRUE,
gimp_context_get_opacity (fill_context) * 255,
gimp_context_get_paint_mode (fill_context),
NULL, x1, y1);
tile_manager_destroy (buf_tiles);
/* Update the displays */
drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1));
gdisplays_flush ();
gimp_remove_busy_cursors (NULL);
return_val = TRUE;
}
}
}
gtk_drag_finish (context, return_val, FALSE, time);
@ -824,12 +768,12 @@ gdisplay_drag_drop (GtkWidget *widget,
return return_val;
}
void
gdisplay_set_color (GtkWidget *widget,
guchar r,
guchar g,
guchar b,
gpointer data)
static void
gdisplay_bucket_fill (GtkWidget *widget,
BucketFillMode fill_mode,
guchar color[],
TempBuf *pat_buf,
gpointer data)
{
GimpImage *gimage;
GimpDrawable *drawable;
@ -839,7 +783,6 @@ gdisplay_set_color (GtkWidget *widget,
gint x1, x2, y1, y2;
gint bytes;
gboolean has_alpha;
guchar col[3];
gimage = ((GDisplay *) data)->gimage;
drawable = gimage_active_drawable (gimage);
@ -848,27 +791,21 @@ gdisplay_set_color (GtkWidget *widget,
gimp_add_busy_cursors ();
/* Get the fill parameters */
if (gimp_context_get_current () == gimp_context_get_user () &&
! global_paint_options)
/* Get the bucket fill context */
if (! global_paint_options)
context = tool_info[BUCKET_FILL].tool_context;
else
context = gimp_context_get_current ();
context = gimp_context_get_user ();
drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
bytes = drawable_bytes (drawable);
has_alpha = drawable_has_alpha (drawable);
col[0] = r;
col[1] = g;
col[2] = b;
/* Fill the region */
buf_tiles = tile_manager_new ((x2 - x1), (y2 - y1), bytes);
pixel_region_init (&bufPR, buf_tiles, 0, 0, (x2 - x1), (y2 - y1), TRUE);
bucket_fill_region (FG_BUCKET_FILL, &bufPR, NULL,
col, NULL, x1, y1, has_alpha);
bucket_fill_region (fill_mode, &bufPR, NULL,
color, pat_buf, x1, y1, has_alpha);
/* Apply it to the image */
pixel_region_init (&bufPR, buf_tiles, 0, 0, (x2 - x1), (y2 - y1), FALSE);
@ -884,3 +821,27 @@ gdisplay_set_color (GtkWidget *widget,
gimp_remove_busy_cursors (NULL);
}
void
gdisplay_drop_color (GtkWidget *widget,
guchar r,
guchar g,
guchar b,
gpointer data)
{
guchar color[3];
color[0] = r;
color[1] = g;
color[2] = b;
gdisplay_bucket_fill (widget, FG_BUCKET_FILL, color, NULL, data);
}
void
gdisplay_drop_pattern (GtkWidget *widget,
GPattern *pattern,
gpointer data)
{
gdisplay_bucket_fill (widget, PATTERN_BUCKET_FILL, NULL, pattern->mask, data);
}

View File

@ -19,6 +19,7 @@
#define __DISP_CALLBACKS_H__
#include "gdisplay.h"
#include "patterns.h"
#define CANVAS_EVENT_MASK GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | \
GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | \
@ -34,16 +35,19 @@ gint gdisplay_hruler_button_press (GtkWidget *, GdkEventButton *, gpointer);
gint gdisplay_vruler_button_press (GtkWidget *, GdkEventButton *, gpointer);
gint gdisplay_origin_button_press (GtkWidget *, GdkEventButton *, gpointer);
gboolean gdisplay_drag_drop (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time,
gpointer data);
void gdisplay_set_color (GtkWidget *widget,
guchar r,
guchar g,
guchar b,
gpointer data);
gboolean gdisplay_drag_drop (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time,
gpointer data);
void gdisplay_drop_color (GtkWidget *widget,
guchar r,
guchar g,
guchar b,
gpointer data);
void gdisplay_drop_pattern (GtkWidget *widget,
GPattern *pattern,
gpointer data);
#endif /* __DISP_CALLBACKS_H__ */

View File

@ -15,7 +15,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <stdlib.h>
@ -640,7 +639,6 @@ gdisplay_drag_drop (GtkWidget *widget,
Channel *channel = NULL;
LayerMask *layer_mask = NULL;
GImage *component = NULL;
GPattern *pattern = NULL;
ChannelType component_type = -1;
layer = (Layer *) gtk_object_get_data (GTK_OBJECT (src_widget),
@ -651,8 +649,6 @@ gdisplay_drag_drop (GtkWidget *widget,
"gimp_layer_mask");
component = (GImage *) gtk_object_get_data (GTK_OBJECT (src_widget),
"gimp_component");
pattern = (GPattern *) gtk_object_get_data (GTK_OBJECT (src_widget),
"gimp_pattern");
if (layer)
{
@ -762,58 +758,6 @@ gdisplay_drag_drop (GtkWidget *widget,
undo_push_group_end (dest_gimage);
}
}
if (pattern)
{
GimpImage *gimage;
GimpDrawable *drawable;
GimpContext *fill_context;
TileManager *buf_tiles;
PixelRegion bufPR;
gint x1, x2, y1, y2;
gint bytes;
gboolean has_alpha;
gimage = gdisp->gimage;
drawable = gimage_active_drawable (gimage);
if (drawable)
{
gimp_add_busy_cursors ();
/* Get the fill parameters */
if (gimp_context_get_current () == gimp_context_get_user () &&
! global_paint_options)
fill_context = tool_info[BUCKET_FILL].tool_context;
else
fill_context = gimp_context_get_current ();
drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
bytes = drawable_bytes (drawable);
has_alpha = drawable_has_alpha (drawable);
/* Fill the region */
buf_tiles = tile_manager_new ((x2 - x1), (y2 - y1), bytes);
pixel_region_init (&bufPR, buf_tiles, 0, 0, (x2 - x1), (y2 - y1), TRUE);
bucket_fill_region (PATTERN_BUCKET_FILL, &bufPR, NULL,
NULL, pattern->mask, x1, y1, has_alpha);
/* Apply it to the image */
pixel_region_init (&bufPR, buf_tiles, 0, 0, (x2 - x1), (y2 - y1), FALSE);
gimage_apply_image (gimage, drawable, &bufPR, TRUE,
gimp_context_get_opacity (fill_context) * 255,
gimp_context_get_paint_mode (fill_context),
NULL, x1, y1);
tile_manager_destroy (buf_tiles);
/* Update the displays */
drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1));
gdisplays_flush ();
gimp_remove_busy_cursors (NULL);
return_val = TRUE;
}
}
}
gtk_drag_finish (context, return_val, FALSE, time);
@ -824,12 +768,12 @@ gdisplay_drag_drop (GtkWidget *widget,
return return_val;
}
void
gdisplay_set_color (GtkWidget *widget,
guchar r,
guchar g,
guchar b,
gpointer data)
static void
gdisplay_bucket_fill (GtkWidget *widget,
BucketFillMode fill_mode,
guchar color[],
TempBuf *pat_buf,
gpointer data)
{
GimpImage *gimage;
GimpDrawable *drawable;
@ -839,7 +783,6 @@ gdisplay_set_color (GtkWidget *widget,
gint x1, x2, y1, y2;
gint bytes;
gboolean has_alpha;
guchar col[3];
gimage = ((GDisplay *) data)->gimage;
drawable = gimage_active_drawable (gimage);
@ -848,27 +791,21 @@ gdisplay_set_color (GtkWidget *widget,
gimp_add_busy_cursors ();
/* Get the fill parameters */
if (gimp_context_get_current () == gimp_context_get_user () &&
! global_paint_options)
/* Get the bucket fill context */
if (! global_paint_options)
context = tool_info[BUCKET_FILL].tool_context;
else
context = gimp_context_get_current ();
context = gimp_context_get_user ();
drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
bytes = drawable_bytes (drawable);
has_alpha = drawable_has_alpha (drawable);
col[0] = r;
col[1] = g;
col[2] = b;
/* Fill the region */
buf_tiles = tile_manager_new ((x2 - x1), (y2 - y1), bytes);
pixel_region_init (&bufPR, buf_tiles, 0, 0, (x2 - x1), (y2 - y1), TRUE);
bucket_fill_region (FG_BUCKET_FILL, &bufPR, NULL,
col, NULL, x1, y1, has_alpha);
bucket_fill_region (fill_mode, &bufPR, NULL,
color, pat_buf, x1, y1, has_alpha);
/* Apply it to the image */
pixel_region_init (&bufPR, buf_tiles, 0, 0, (x2 - x1), (y2 - y1), FALSE);
@ -884,3 +821,27 @@ gdisplay_set_color (GtkWidget *widget,
gimp_remove_busy_cursors (NULL);
}
void
gdisplay_drop_color (GtkWidget *widget,
guchar r,
guchar g,
guchar b,
gpointer data)
{
guchar color[3];
color[0] = r;
color[1] = g;
color[2] = b;
gdisplay_bucket_fill (widget, FG_BUCKET_FILL, color, NULL, data);
}
void
gdisplay_drop_pattern (GtkWidget *widget,
GPattern *pattern,
gpointer data)
{
gdisplay_bucket_fill (widget, PATTERN_BUCKET_FILL, NULL, pattern->mask, data);
}

View File

@ -19,6 +19,7 @@
#define __DISP_CALLBACKS_H__
#include "gdisplay.h"
#include "patterns.h"
#define CANVAS_EVENT_MASK GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | \
GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | \
@ -34,16 +35,19 @@ gint gdisplay_hruler_button_press (GtkWidget *, GdkEventButton *, gpointer);
gint gdisplay_vruler_button_press (GtkWidget *, GdkEventButton *, gpointer);
gint gdisplay_origin_button_press (GtkWidget *, GdkEventButton *, gpointer);
gboolean gdisplay_drag_drop (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time,
gpointer data);
void gdisplay_set_color (GtkWidget *widget,
guchar r,
guchar g,
guchar b,
gpointer data);
gboolean gdisplay_drag_drop (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time,
gpointer data);
void gdisplay_drop_color (GtkWidget *widget,
guchar r,
guchar g,
guchar b,
gpointer data);
void gdisplay_drop_pattern (GtkWidget *widget,
GPattern *pattern,
gpointer data);
#endif /* __DISP_CALLBACKS_H__ */

View File

@ -90,6 +90,9 @@ static gboolean toolbox_drag_drop (GtkWidget *,
gint,
gint,
guint);
static void toolbox_drop_tool (GtkWidget *,
ToolType,
gpointer);
static void gimp_dnd_open_files (gchar *);
static int pixmap_colors[8][3] =
@ -122,7 +125,8 @@ static GtkTargetEntry toolbox_target_table[] =
GIMP_TARGET_NETSCAPE_URL,
GIMP_TARGET_LAYER,
GIMP_TARGET_CHANNEL,
GIMP_TARGET_LAYER_MASK
GIMP_TARGET_LAYER_MASK,
GIMP_TARGET_TOOL
};
static guint toolbox_n_targets = (sizeof (toolbox_target_table) /
sizeof (toolbox_target_table[0]));
@ -709,7 +713,8 @@ create_display_shell (GDisplay* gdisp,
gtk_signal_connect (GTK_OBJECT (gdisp->shell), "drag_drop",
GTK_SIGNAL_FUNC (gdisplay_drag_drop),
gdisp);
gimp_dnd_color_dest_set (gdisp->shell, gdisplay_set_color, gdisp);
gimp_dnd_color_dest_set (gdisp->shell, gdisplay_drop_color, gdisp);
gimp_dnd_pattern_dest_set (gdisp->shell, gdisplay_drop_pattern, gdisp);
/* the vbox, table containing all widgets */
vbox = gtk_vbox_new (FALSE, 2);
@ -997,6 +1002,8 @@ toolbox_set_drag_dest (GtkWidget *object)
gtk_signal_connect (GTK_OBJECT (object), "drag_drop",
GTK_SIGNAL_FUNC (toolbox_drag_drop),
NULL);
gimp_dnd_tool_dest_set (object, toolbox_drop_tool, NULL);
}
static void
@ -1171,6 +1178,14 @@ toolbox_drag_drop (GtkWidget *widget,
return return_val;
}
static void
toolbox_drop_tool (GtkWidget *widget,
ToolType tool,
gpointer data)
{
gimp_context_set_tool (gimp_context_get_user (), tool);
}
static void
gimp_dnd_open_files (gchar *buffer)
{

View File

@ -90,6 +90,9 @@ static gboolean toolbox_drag_drop (GtkWidget *,
gint,
gint,
guint);
static void toolbox_drop_tool (GtkWidget *,
ToolType,
gpointer);
static void gimp_dnd_open_files (gchar *);
static int pixmap_colors[8][3] =
@ -122,7 +125,8 @@ static GtkTargetEntry toolbox_target_table[] =
GIMP_TARGET_NETSCAPE_URL,
GIMP_TARGET_LAYER,
GIMP_TARGET_CHANNEL,
GIMP_TARGET_LAYER_MASK
GIMP_TARGET_LAYER_MASK,
GIMP_TARGET_TOOL
};
static guint toolbox_n_targets = (sizeof (toolbox_target_table) /
sizeof (toolbox_target_table[0]));
@ -709,7 +713,8 @@ create_display_shell (GDisplay* gdisp,
gtk_signal_connect (GTK_OBJECT (gdisp->shell), "drag_drop",
GTK_SIGNAL_FUNC (gdisplay_drag_drop),
gdisp);
gimp_dnd_color_dest_set (gdisp->shell, gdisplay_set_color, gdisp);
gimp_dnd_color_dest_set (gdisp->shell, gdisplay_drop_color, gdisp);
gimp_dnd_pattern_dest_set (gdisp->shell, gdisplay_drop_pattern, gdisp);
/* the vbox, table containing all widgets */
vbox = gtk_vbox_new (FALSE, 2);
@ -997,6 +1002,8 @@ toolbox_set_drag_dest (GtkWidget *object)
gtk_signal_connect (GTK_OBJECT (object), "drag_drop",
GTK_SIGNAL_FUNC (toolbox_drag_drop),
NULL);
gimp_dnd_tool_dest_set (object, toolbox_drop_tool, NULL);
}
static void
@ -1171,6 +1178,14 @@ toolbox_drag_drop (GtkWidget *widget,
return return_val;
}
static void
toolbox_drop_tool (GtkWidget *widget,
ToolType tool,
gpointer data)
{
gimp_context_set_tool (gimp_context_get_user (), tool);
}
static void
gimp_dnd_open_files (gchar *buffer)
{

View File

@ -1680,23 +1680,18 @@ gimp_context_refresh_gradient (GimpContext *context,
gpointer data)
{
gradient_t *gradient;
GSList *list;
if (! context->gradient_name)
context->gradient_name = g_strdup (default_gradient);
for (list = gradients_list; list; list = g_slist_next (list))
if ((gradient = gradient_list_get_gradient (gradients_list,
context->gradient_name)))
{
gradient = (gradient_t *) list->data;
if (strcmp (gradient->name, context->gradient_name) == 0)
{
context->gradient = gradient;
gtk_signal_emit (GTK_OBJECT (context),
gimp_context_signals[GRADIENT_CHANGED],
gradient);
return;
}
context->gradient = gradient;
gtk_signal_emit (GTK_OBJECT (context),
gimp_context_signals[GRADIENT_CHANGED],
gradient);
return;
}
g_free (context->gradient_name);

View File

@ -29,12 +29,13 @@
#include "gimpbrushpipeP.h"
#include "gimpcontextpreview.h"
#include "gimpdnd.h"
#include "gradient.h"
#include "gradient_header.h"
#include "interface.h" /* for tool_tips */
#include "patterns.h"
#include "temp_buf.h"
#include "libgimp/gimplimits.h"
/* the pixmaps for the [scale|pipe]_indicators */
#define indicator_width 7
#define indicator_height 7
@ -96,9 +97,6 @@ static guint gcp_pipe_timer = 0;
static guint gcp_pipe_index = 0;
/* dnd stuff */
static GtkWidget *gcp_drag_window = NULL;
static GtkWidget *gcp_drag_preview = NULL;
static GtkTargetEntry context_preview_target_table[3][1] =
{
{ GIMP_TARGET_BRUSH },
@ -107,22 +105,9 @@ static GtkTargetEntry context_preview_target_table[3][1] =
};
static guint n_targets = 1;
static gchar* context_preview_drag_window_name[3] =
{
"gimp-brush-drag-window",
"gimp-pattern-drag-window",
"gimp-gradient-drag-window"
};
static gchar* context_preview_drag_type[3] =
{
"gimp_brush",
"gimp_pattern",
"gimp_gradient"
};
/* signals */
enum {
enum
{
CLICKED,
LAST_SIGNAL
};
@ -130,34 +115,27 @@ enum {
static guint gimp_context_preview_signals[LAST_SIGNAL] = { 0 };
static GtkPreviewClass *parent_class = NULL;
static gpointer gimp_context_preview_get_data (GimpContextPreview *,
gpointer);
static gint gimp_context_preview_button_press_event (GtkWidget *,
GdkEventButton *);
static gint gimp_context_preview_button_release_event (GtkWidget *,
GdkEventButton *);
static void gimp_context_preview_popup_open (GimpContextPreview *,
gint, gint);
static void gimp_context_preview_popup_close ();
static void gimp_context_preview_popup_close (void);
static gboolean gimp_context_preview_data_matches_type (GimpContextPreview *,
gpointer);
static void gimp_context_preview_drag_begin (GtkWidget *,
GdkDragContext *);
static void gimp_context_preview_draw_brush (GimpContextPreview *);
static void gimp_context_preview_draw_brush_popup (GimpContextPreview *);
static void gimp_context_preview_draw_brush_drag (GimpContextPreview *);
static gint gimp_context_preview_animate_pipe (GimpContextPreview *);
static void gimp_context_preview_draw_pattern (GimpContextPreview *);
static void gimp_context_preview_draw_pattern_popup (GimpContextPreview *);
static void gimp_context_preview_draw_pattern_drag (GimpContextPreview *);
static void gimp_context_preview_draw_gradient (GimpContextPreview *);
static void gimp_context_preview_draw_gradient_popup (GimpContextPreview *);
static void gimp_context_preview_draw_gradient_drag (GimpContextPreview *);
static gint brush_dirty_callback (GimpBrush *, GimpContextPreview *);
static gint brush_rename_callback (GimpBrush *, GimpContextPreview *);
static void draw_brush (GtkPreview *, GimpBrush*, int, int, gboolean);
static void draw_pattern (GtkPreview *, GPattern*, int, int);
static void draw_gradient (GtkPreview *, gradient_t*, int, int);
static void
gimp_context_preview_destroy (GtkObject *object)
@ -192,7 +170,6 @@ gimp_context_preview_class_init (GimpContextPreviewClass *class)
widget_class->button_press_event = gimp_context_preview_button_press_event;
widget_class->button_release_event = gimp_context_preview_button_release_event;
widget_class->drag_begin = gimp_context_preview_drag_begin;
object_class->destroy = gimp_context_preview_destroy;
}
@ -200,24 +177,25 @@ gimp_context_preview_class_init (GimpContextPreviewClass *class)
static void
gimp_context_preview_init (GimpContextPreview *gcp)
{
gcp->data = NULL;
gcp->type = GCP_LAST;
gcp->width = 0;
gcp->height = 0;
gcp->popup_width = 0;
gcp->popup_height = 0;
gcp->show_popup = FALSE;
gcp->data = NULL;
gcp->type = GCP_LAST;
gcp->width = 0;
gcp->height = 0;
gcp->popup_width = 0;
gcp->popup_height = 0;
gcp->show_popup = FALSE;
gcp->show_tooltips = FALSE;
gcp->drag_source = FALSE;
GTK_PREVIEW (gcp)->type = GTK_PREVIEW_COLOR;
GTK_PREVIEW (gcp)->bpp = 3;
gcp->drag_source = FALSE;
GTK_PREVIEW (gcp)->type = GTK_PREVIEW_COLOR;
GTK_PREVIEW (gcp)->bpp = 3;
GTK_PREVIEW (gcp)->dither = GDK_RGB_DITHER_NORMAL;
gtk_widget_set_events (GTK_WIDGET (gcp), CONTEXT_PREVIEW_EVENT_MASK);
}
GtkType
gimp_context_preview_get_type ()
gimp_context_preview_get_type (void)
{
static GtkType gcp_type = 0;
@ -241,13 +219,15 @@ gimp_context_preview_get_type ()
return gcp_type;
}
GtkWidget*
gimp_context_preview_new (GimpContextPreviewType type,
gint width,
gint height,
gboolean show_popup,
gboolean show_tooltips,
gboolean drag_source)
GtkWidget *
gimp_context_preview_new (GimpContextPreviewType type,
gint width,
gint height,
gboolean show_popup,
gboolean show_tooltips,
gboolean drag_source,
GtkSignalFunc drop_data_callback,
gpointer drop_data_data)
{
GimpContextPreview *gcp;
@ -265,6 +245,35 @@ gimp_context_preview_new (GimpContextPreviewType type,
gtk_preview_size (GTK_PREVIEW (gcp), width, height);
/* drag dest */
gtk_drag_dest_set (GTK_WIDGET (gcp),
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
context_preview_target_table[type], n_targets,
GDK_ACTION_COPY);
switch (type)
{
case GCP_BRUSH:
gimp_dnd_brush_dest_set (GTK_WIDGET (gcp),
(GimpDndDropBrushFunc) drop_data_callback,
drop_data_data);
break;
case GCP_PATTERN:
gimp_dnd_pattern_dest_set (GTK_WIDGET (gcp),
(GimpDndDropPatternFunc) drop_data_callback,
drop_data_data);
break;
case GCP_GRADIENT:
gimp_dnd_gradient_dest_set (GTK_WIDGET (gcp),
(GimpDndDropGradientFunc) drop_data_callback,
drop_data_data);
break;
default:
break;
}
return GTK_WIDGET (gcp);
}
@ -281,9 +290,31 @@ gimp_context_preview_update (GimpContextPreview *gcp,
GDK_BUTTON1_MASK,
context_preview_target_table[gcp->type], n_targets,
GDK_ACTION_COPY);
switch (gcp->type)
{
case GCP_BRUSH:
gimp_dnd_brush_source_set
(GTK_WIDGET (gcp),
(GimpDndDragBrushFunc) gimp_context_preview_get_data,
NULL);
break;
case GCP_PATTERN:
gimp_dnd_pattern_source_set
(GTK_WIDGET (gcp),
(GimpDndDragPatternFunc) gimp_context_preview_get_data,
NULL);
break;
case GCP_GRADIENT:
gimp_dnd_gradient_source_set
(GTK_WIDGET (gcp),
(GimpDndDragGradientFunc) gimp_context_preview_get_data,
NULL);
break;
default:
break;
}
}
gtk_object_set_data (GTK_OBJECT (gcp),
context_preview_drag_type[gcp->type], data);
if (gcp->data && gcp->type == GCP_BRUSH)
gtk_signal_disconnect_by_data (GTK_OBJECT (gcp->data), gcp);
@ -293,54 +324,63 @@ gimp_context_preview_update (GimpContextPreview *gcp,
gtk_signal_connect (GTK_OBJECT (gcp->data), "destroy",
gtk_widget_destroyed, &gcp->data);
switch (gcp->type)
{
case GCP_BRUSH:
gimp_context_preview_draw_brush (gcp);
gtk_signal_connect (GTK_OBJECT (gcp->data), "dirty",
GTK_SIGNAL_FUNC (brush_dirty_callback), gcp);
gtk_signal_connect (GTK_OBJECT (gcp->data), "rename",
GTK_SIGNAL_FUNC (brush_rename_callback), gcp);
break;
case GCP_PATTERN:
gimp_context_preview_draw_pattern (gcp);
break;
case GCP_GRADIENT:
gimp_context_preview_draw_gradient (gcp);
break;
default:
break;
}
{
case GCP_BRUSH:
gimp_context_preview_draw_brush (gcp);
gtk_signal_connect (GTK_OBJECT (gcp->data), "dirty",
GTK_SIGNAL_FUNC (brush_dirty_callback), gcp);
gtk_signal_connect (GTK_OBJECT (gcp->data), "rename",
GTK_SIGNAL_FUNC (brush_rename_callback), gcp);
break;
case GCP_PATTERN:
gimp_context_preview_draw_pattern (gcp);
break;
case GCP_GRADIENT:
gimp_context_preview_draw_gradient (gcp);
break;
default:
break;
}
gtk_widget_queue_draw (GTK_WIDGET (gcp));
if (gcp->show_tooltips)
{
gchar *name = NULL;
switch (gcp->type)
{
case GCP_BRUSH:
{
GimpBrush *brush = GIMP_BRUSH (gcp->data);
name = brush->name;
}
break;
case GCP_PATTERN:
{
GPattern *pattern = (GPattern *)(gcp->data);
name = pattern->name;
}
break;
case GCP_GRADIENT:
{
gradient_t *gradient = (gradient_t *)(gcp->data);
name = gradient->name;
}
break;
default:
break;
gchar *name = NULL;
switch (gcp->type)
{
case GCP_BRUSH:
{
GimpBrush *brush = GIMP_BRUSH (gcp->data);
name = brush->name;
}
break;
case GCP_PATTERN:
{
GPattern *pattern = (GPattern *) (gcp->data);
name = pattern->name;
}
break;
case GCP_GRADIENT:
{
gradient_t *gradient = (gradient_t *) (gcp->data);
name = gradient->name;
}
break;
default:
break;
}
gtk_tooltips_set_tip (tool_tips, GTK_WIDGET (gcp), name, NULL);
}
gtk_tooltips_set_tip (tool_tips, GTK_WIDGET (gcp), name, NULL);
}
}
static gpointer
gimp_context_preview_get_data (GimpContextPreview *gcp,
gpointer data)
{
g_return_val_if_fail (GIMP_IS_CONTEXT_PREVIEW (gcp), NULL);
return gcp->data;
}
static gint
@ -521,57 +561,14 @@ gimp_context_preview_data_matches_type (GimpContextPreview *gcp,
return (match);
}
static void
gimp_context_preview_drag_begin (GtkWidget *widget,
GdkDragContext *context)
{
GimpContextPreview *gcp;
gcp = GIMP_CONTEXT_PREVIEW (widget);
if (!gcp_drag_window)
{
gcp_drag_window = gtk_window_new (GTK_WINDOW_POPUP);
gtk_widget_set_app_paintable (GTK_WIDGET (gcp_drag_window), TRUE);
gtk_window_set_policy (GTK_WINDOW (gcp_drag_window), FALSE, FALSE, TRUE);
gtk_widget_realize (gcp_drag_window);
gtk_object_set_data_full (GTK_OBJECT (gcp_drag_window),
context_preview_drag_window_name[gcp->type],
gcp_drag_window,
(GtkDestroyNotify) gtk_widget_destroy);
gcp_drag_preview = gtk_preview_new (GTK_PREVIEW_COLOR);
gtk_signal_connect (GTK_OBJECT (gcp_drag_preview), "destroy",
gtk_widget_destroyed, &gcp_drag_preview);
gtk_container_add (GTK_CONTAINER (gcp_drag_window), gcp_drag_preview);
gtk_widget_show (gcp_drag_preview);
}
switch (gcp->type)
{
case GCP_BRUSH:
gimp_context_preview_draw_brush_drag (gcp);
break;
case GCP_PATTERN:
gimp_context_preview_draw_pattern_drag (gcp);
break;
case GCP_GRADIENT:
gimp_context_preview_draw_gradient_drag (gcp);
break;
default:
break;
}
gtk_widget_queue_draw (gcp_drag_preview);
gtk_drag_set_icon_widget (context, gcp_drag_window, -2, -2);
}
/* brush draw functions */
static void draw_brush (GtkPreview *preview,
GimpBrush *brush,
gint width,
gint height,
gboolean is_popup)
void
draw_brush (GtkPreview *preview,
GimpBrush *brush,
gint width,
gint height,
gboolean is_popup)
{
gboolean scale = FALSE;
gint brush_width, brush_height;
@ -693,20 +690,6 @@ gimp_context_preview_draw_brush_popup (GimpContextPreview *gcp)
gcp->popup_width, gcp->popup_height, TRUE);
}
static void
gimp_context_preview_draw_brush_drag (GimpContextPreview *gcp)
{
GimpBrush *brush;
g_return_if_fail (gcp != NULL && GIMP_IS_BRUSH (gcp->data));
brush = GIMP_BRUSH (gcp->data);
gtk_preview_size (GTK_PREVIEW (gcp_drag_preview),
DRAG_PREVIEW_SIZE, DRAG_PREVIEW_SIZE);
draw_brush (GTK_PREVIEW (gcp_drag_preview), brush,
DRAG_PREVIEW_SIZE, DRAG_PREVIEW_SIZE, FALSE);
}
static void
gimp_context_preview_draw_brush (GimpContextPreview *gcp)
{
@ -767,7 +750,7 @@ brush_rename_callback (GimpBrush *brush,
/* pattern draw functions */
static void
void
draw_pattern (GtkPreview *preview,
GPattern *pattern,
gint width,
@ -825,20 +808,6 @@ gimp_context_preview_draw_pattern_popup (GimpContextPreview *gcp)
gcp->popup_width, gcp->popup_height);
}
static void
gimp_context_preview_draw_pattern_drag (GimpContextPreview *gcp)
{
GPattern *pattern;
g_return_if_fail (gcp != NULL && gcp->data != NULL);
pattern = (GPattern*)(gcp->data);
gtk_preview_size (GTK_PREVIEW (gcp_drag_preview),
DRAG_PREVIEW_SIZE, DRAG_PREVIEW_SIZE);
draw_pattern (GTK_PREVIEW (gcp_drag_preview), pattern,
DRAG_PREVIEW_SIZE, DRAG_PREVIEW_SIZE);
}
static void
gimp_context_preview_draw_pattern (GimpContextPreview *gcp)
{
@ -853,7 +822,7 @@ gimp_context_preview_draw_pattern (GimpContextPreview *gcp)
/* gradient draw functions */
static void
void
draw_gradient (GtkPreview *preview,
gradient_t *gradient,
gint width,
@ -874,15 +843,15 @@ draw_gradient (GtkPreview *preview,
{
gradient_get_color_at (gradient, cur_x, &r, &g, &b, &a);
if ((x / GRAD_CHECK_SIZE_SM) & 1)
if ((x / GIMP_CHECK_SIZE_SM) & 1)
{
c0 = GRAD_CHECK_LIGHT;
c1 = GRAD_CHECK_DARK;
c0 = GIMP_CHECK_LIGHT;
c1 = GIMP_CHECK_DARK;
}
else
{
c0 = GRAD_CHECK_DARK;
c1 = GRAD_CHECK_LIGHT;
c0 = GIMP_CHECK_DARK;
c1 = GIMP_CHECK_LIGHT;
}
*p0++ = (c0 + (r - c0) * a) * 255.0;
@ -898,7 +867,7 @@ draw_gradient (GtkPreview *preview,
for (y = 0; y < height; y++)
{
if ((y / GRAD_CHECK_SIZE_SM) & 1)
if ((y / GIMP_CHECK_SIZE_SM) & 1)
gtk_preview_draw_row (preview, odd, 0, y, width);
else
gtk_preview_draw_row (preview, even, 0, y, width);
@ -920,20 +889,6 @@ gimp_context_preview_draw_gradient_popup (GimpContextPreview *gcp)
gcp->popup_width, gcp->popup_height);
}
static void
gimp_context_preview_draw_gradient_drag (GimpContextPreview *gcp)
{
gradient_t *gradient;
g_return_if_fail (gcp != NULL && gcp->data != NULL);
gradient = (gradient_t*)(gcp->data);
gtk_preview_size (GTK_PREVIEW (gcp_drag_preview),
DRAG_PREVIEW_SIZE * 2, DRAG_PREVIEW_SIZE / 2);
draw_gradient (GTK_PREVIEW (gcp_drag_preview), gradient,
DRAG_PREVIEW_SIZE * 2, DRAG_PREVIEW_SIZE / 2);
}
static void
gimp_context_preview_draw_gradient (GimpContextPreview *gcp)
{
@ -944,5 +899,3 @@ gimp_context_preview_draw_gradient (GimpContextPreview *gcp)
gradient = (gradient_t*)(gcp->data);
draw_gradient (GTK_PREVIEW (gcp), gradient, gcp->width, gcp->height);
}

View File

@ -24,6 +24,10 @@
#include <gtk/gtk.h>
#include "gimpbrush.h"
#include "gradient.h"
#include "patterns.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
@ -67,15 +71,39 @@ struct _GimpContextPreviewClass
void (* clicked) (GimpContextPreview *gbp);
};
GtkType gimp_context_preview_get_type (void);
GtkWidget* gimp_context_preview_new (GimpContextPreviewType type,
gint width,
gint height,
gboolean show_popup,
gboolean show_tooltips,
gboolean drag_source);
void gimp_context_preview_update (GimpContextPreview *gcp,
gpointer data);
GtkType gimp_context_preview_get_type (void);
GtkWidget* gimp_context_preview_new (GimpContextPreviewType type,
gint width,
gint height,
gboolean show_popup,
gboolean show_tooltips,
gboolean drag_source,
GtkSignalFunc drop_data_callback,
gpointer drop_data_data);
void gimp_context_preview_update (GimpContextPreview *gcp,
gpointer data);
/* TODO: move to another file (gimpdatapreview.[ch] ??)
*
* finally, the contextpreview and dnd stuff should live in libgimp
* and link to different data drawing functions when used from the
* app and plugins.
*/
void draw_brush (GtkPreview *preview,
GimpBrush *brush,
gint width,
gint height,
gboolean is_popup);
void draw_pattern (GtkPreview *preview,
GPattern *pattern,
gint width,
gint height);
void draw_gradient (GtkPreview *preview,
gradient_t *gradient,
gint width,
gint height);
#ifdef __cplusplus
}

File diff suppressed because it is too large Load Diff

View File

@ -20,7 +20,12 @@
#include <gtk/gtk.h>
#include "gimpbrush.h"
#include "gimpdrawable.h"
#include "palette_entries.h"
#include "patterns.h"
#include "gradient.h"
#include "toolsF.h"
enum
{
@ -36,7 +41,9 @@ enum
GIMP_DND_TYPE_COLOR,
GIMP_DND_TYPE_BRUSH,
GIMP_DND_TYPE_PATTERN,
GIMP_DND_TYPE_GRADIENT
GIMP_DND_TYPE_GRADIENT,
GIMP_DND_TYPE_PALETTE,
GIMP_DND_TYPE_TOOL
};
#define GIMP_TARGET_URI_LIST \
@ -78,6 +85,12 @@ enum
#define GIMP_TARGET_GRADIENT \
{ "GIMP_GRADIENT", 0, GIMP_DND_TYPE_GRADIENT }
#define GIMP_TARGET_PALETTE \
{ "GIMP_PALETTE", 0, GIMP_DND_TYPE_PALETTE }
#define GIMP_TARGET_TOOL \
{ "GIMP_TOOL", GTK_TARGET_SAME_APP, GIMP_DND_TYPE_TOOL }
typedef enum
{
GIMP_DROP_NONE,
@ -94,17 +107,81 @@ void gimp_dnd_set_drawable_preview_icon (GtkWidget *widget,
/* color dnd functions */
typedef void (*GimpDndDropColorFunc) (GtkWidget *,
guchar, guchar, guchar, gpointer);
typedef void (*GimpDndDragColorFunc) (GtkWidget *,
guchar *, guchar *, guchar *, gpointer);
typedef void (* GimpDndDropColorFunc) (GtkWidget *, guchar, guchar, guchar,
gpointer);
typedef void (* GimpDndDragColorFunc) (GtkWidget *, guchar *, guchar *, guchar *,
gpointer);
void gimp_dnd_color_source_set (GtkWidget *widget,
GimpDndDragColorFunc get_color_func,
gpointer data);
void gimp_dnd_color_source_set (GtkWidget *widget,
GimpDndDragColorFunc get_color_func,
gpointer data);
void gimp_dnd_color_dest_set (GtkWidget *widget,
GimpDndDropColorFunc set_color_func,
gpointer data);
void gimp_dnd_color_dest_set (GtkWidget *widget,
GimpDndDropColorFunc set_color_func,
gpointer data);
/* brush dnd functions */
typedef void (* GimpDndDropBrushFunc) (GtkWidget *, GimpBrush *,
gpointer);
typedef GimpBrush * (* GimpDndDragBrushFunc) (GtkWidget *, gpointer);
void gimp_dnd_brush_source_set (GtkWidget *widget,
GimpDndDragBrushFunc get_brush_func,
gpointer data);
void gimp_dnd_brush_dest_set (GtkWidget *widget,
GimpDndDropBrushFunc set_brush_func,
gpointer data);
/* pattern dnd functions */
typedef void (* GimpDndDropPatternFunc) (GtkWidget *, GPattern *,
gpointer);
typedef GPattern * (* GimpDndDragPatternFunc) (GtkWidget *, gpointer);
void gimp_dnd_pattern_source_set (GtkWidget *widget,
GimpDndDragPatternFunc get_pattern_func,
gpointer data);
void gimp_dnd_pattern_dest_set (GtkWidget *widget,
GimpDndDropPatternFunc set_pattern_func,
gpointer data);
/* gradient dnd functions */
typedef void (* GimpDndDropGradientFunc) (GtkWidget *, gradient_t *,
gpointer);
typedef gradient_t * (* GimpDndDragGradientFunc) (GtkWidget *, gpointer);
void gimp_dnd_gradient_source_set (GtkWidget *widget,
GimpDndDragGradientFunc get_gradient_func,
gpointer data);
void gimp_dnd_gradient_dest_set (GtkWidget *widget,
GimpDndDropGradientFunc set_gradient_func,
gpointer data);
/* palette dnd functions */
typedef void (* GimpDndDropPaletteFunc) (GtkWidget *,
PaletteEntries *,
gpointer);
typedef PaletteEntries * (* GimpDndDragPaletteFunc) (GtkWidget *, gpointer);
void gimp_dnd_palette_source_set (GtkWidget *widget,
GimpDndDragPaletteFunc get_palette_func,
gpointer data);
void gimp_dnd_palette_dest_set (GtkWidget *widget,
GimpDndDropPaletteFunc set_palette_func,
gpointer data);
/* tool dnd functions */
typedef void (* GimpDndDropToolFunc) (GtkWidget *, ToolType, gpointer);
typedef ToolType (* GimpDndDragToolFunc) (GtkWidget *, gpointer);
void gimp_dnd_tool_source_set (GtkWidget *widget,
GimpDndDragToolFunc get_tool_func,
gpointer data);
void gimp_dnd_tool_dest_set (GtkWidget *widget,
GimpDndDropToolFunc set_tool_func,
gpointer data);
#endif /* __GIMP_DND_H__ */

View File

@ -424,7 +424,7 @@ static GtkWidget *build_palette_menu(int *default_palette);
static void palette_entries_callback(GtkWidget *w, gpointer client_data);
static gboolean UserHasWebPal = FALSE;
PaletteEntriesP theCustomPalette = NULL;
PaletteEntries *theCustomPalette = NULL;
/* Defaults */
@ -802,7 +802,7 @@ build_palette_menu (int *default_palette)
GtkWidget *menu;
GtkWidget *menu_item;
GSList *list;
PaletteEntriesP entries;
PaletteEntries *entries;
int i, item;
UserHasWebPal = FALSE;
@ -823,7 +823,7 @@ build_palette_menu (int *default_palette)
list;
i++, list = g_slist_next (list))
{
entries = (PaletteEntriesP) list->data;
entries = (PaletteEntries *) list->data;
/* Preferentially, the initial default is 'Web' if available */
if (*default_palette==-1 &&
@ -853,7 +853,7 @@ build_palette_menu (int *default_palette)
/* default to first one (only used if 'web' palette not avail.) */
if (*default_palette==-1)
{
theCustomPalette = (PaletteEntriesP) palette_entries_list->data;
theCustomPalette = (PaletteEntries *) palette_entries_list->data;
*default_palette = 0;
}
return menu;
@ -863,7 +863,7 @@ static void
palette_entries_callback (GtkWidget *widget,
gpointer data)
{
theCustomPalette = (PaletteEntriesP) data;
theCustomPalette = (PaletteEntries *) data;
}
static void
@ -2958,7 +2958,7 @@ custompal_pass1 (QuantizeObj *quantobj)
{
int i;
GSList *list;
PaletteEntryP entry;
PaletteEntry *entry;
/* fprintf(stderr, "custompal_pass1: using (theCustomPalette %s) from (file %s)\n",
theCustomPalette->name, theCustomPalette->filename);*/
@ -2967,7 +2967,7 @@ custompal_pass1 (QuantizeObj *quantobj)
list;
i++,list=g_slist_next(list))
{
entry=(PaletteEntryP)list->data;
entry = (PaletteEntry *) list->data;
quantobj->cmap[i].red = entry->color[0];
quantobj->cmap[i].green = entry->color[1];
quantobj->cmap[i].blue = entry->color[2];

View File

@ -24,7 +24,8 @@
#include "palette_entries.h"
/* adam's extra palette stuff */
typedef enum {
typedef enum
{
MAKE_PALETTE = 0,
REUSE_PALETTE = 1,
WEB_PALETTE = 2,
@ -33,7 +34,8 @@ typedef enum {
} ConvertPaletteType;
/* adam's extra dither stuff */
typedef enum {
typedef enum
{
NO_DITHER = 0,
FS_DITHER = 1,
FSLOWBLEED_DITHER = 2,
@ -51,12 +53,12 @@ void convert_to_indexed (GimpImage *);
void convert_image (GimpImage *,
GimpImageBaseType,
int num_cols,
gint num_cols,
ConvertDitherType,
int alpha_dither,
int remdups,
gint alpha_dither,
gint remdups,
ConvertPaletteType);
extern PaletteEntriesP theCustomPalette;
extern PaletteEntries *theCustomPalette;
#endif /* __CONVERT_H__ */

File diff suppressed because it is too large Load Diff

View File

@ -23,20 +23,25 @@
typedef struct _gradient_t gradient_t;
void gradients_init (gint no_data);
void gradients_free (void);
/* global variables */
extern GSList * gradients_list;
extern gint num_gradients;
gradient_t * gradients_get_standard_gradient (void);
void gradients_init (gint no_data);
void gradients_free (void);
void gradient_get_color_at (gradient_t *gradient,
gdouble pos,
gdouble *r,
gdouble *g,
gdouble *b,
gdouble *a);
gradient_t * gradients_get_standard_gradient (void);
void grad_create_gradient_editor (void);
void grad_free_gradient_editor (void);
void gradients_check_dialogs (void);
gradient_t * gradient_list_get_gradient (GSList *list,
gchar *name);
gint gradient_list_get_gradient_index (GSList *list,
gradient_t *gradient);
void gradient_get_color_at (gradient_t *gradient,
gdouble pos,
gdouble *r,
gdouble *g,
gdouble *b,
gdouble *a);
#endif /* __GRADIENT_H__ */

37
app/gradientP.h Normal file
View File

@ -0,0 +1,37 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* 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 __GRADIENT_P_H__
#define __GRADIENT_P_H__
void gradient_editor_create (void);
void gradient_editor_free (void);
gboolean gradient_editor_set_gradient (gradient_t *gradient);
gint gradient_clist_init (GtkWidget *shell,
GdkGC *gc,
GtkWidget *clist,
gradient_t *active);
void gradient_clist_insert (GtkWidget *shell,
GdkGC *gc,
GtkWidget *clist,
gradient_t *gradient,
gint pos,
gboolean select);
#endif /* __GRADIENT_P_H__ */

View File

@ -21,7 +21,6 @@
#include "procedural_db.h"
#include "gimpcontext.h"
#include "gradient.h"
#include "gradient_header.h"
static ProcRecord gradients_get_list_proc;
@ -148,13 +147,24 @@ gradients_set_active_invoker (Argument *args)
{
gboolean success = TRUE;
gchar *name;
gradient_t *gradient;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL)
success = FALSE;
if (success)
success = grad_set_grad_to_name (name);
{
gradient = gradient_list_get_gradient (gradients_list, name);
success = FALSE;
if (gradient)
{
gimp_context_set_gradient (NULL, gradient);
success = TRUE;
}
}
return procedural_db_return_args (&gradients_set_active_proc, success);
}

File diff suppressed because it is too large Load Diff

View File

@ -23,20 +23,25 @@
typedef struct _gradient_t gradient_t;
void gradients_init (gint no_data);
void gradients_free (void);
/* global variables */
extern GSList * gradients_list;
extern gint num_gradients;
gradient_t * gradients_get_standard_gradient (void);
void gradients_init (gint no_data);
void gradients_free (void);
void gradient_get_color_at (gradient_t *gradient,
gdouble pos,
gdouble *r,
gdouble *g,
gdouble *b,
gdouble *a);
gradient_t * gradients_get_standard_gradient (void);
void grad_create_gradient_editor (void);
void grad_free_gradient_editor (void);
void gradients_check_dialogs (void);
gradient_t * gradient_list_get_gradient (GSList *list,
gchar *name);
gint gradient_list_get_gradient_index (GSList *list,
gradient_t *gradient);
void gradient_get_color_at (gradient_t *gradient,
gdouble pos,
gdouble *r,
gdouble *g,
gdouble *b,
gdouble *a);
#endif /* __GRADIENT_H__ */

View File

@ -20,47 +20,6 @@
#include <gtk/gtk.h>
#define GRAD_LIST_WIDTH 300
#define GRAD_LIST_HEIGHT 80
#define GRAD_SCROLLBAR_STEP_SIZE 0.05
#define GRAD_SCROLLBAR_PAGE_SIZE 0.75
#define GRAD_CLOSE_BUTTON_WIDTH 45
#define GRAD_PREVIEW_WIDTH 600
#define GRAD_PREVIEW_HEIGHT 64
#define GRAD_CONTROL_HEIGHT 10
#define GRAD_CHECK_SIZE 8
#define GRAD_CHECK_SIZE_SM 4
#define GRAD_CHECK_DARK (1.0 / 3.0)
#define GRAD_CHECK_LIGHT (2.0 / 3.0)
#define GRAD_COLOR_BOX_WIDTH 24
#define GRAD_COLOR_BOX_HEIGHT 16
#define GRAD_NUM_COLORS 10
#define GRAD_MOVE_TIME 150 /* ms between mouse click and detection of movement in gradient control */
#define GRAD_PREVIEW_EVENT_MASK (GDK_EXPOSURE_MASK | GDK_LEAVE_NOTIFY_MASK | \
GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | \
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK)
#define GRAD_CONTROL_EVENT_MASK (GDK_EXPOSURE_MASK | \
GDK_LEAVE_NOTIFY_MASK | \
GDK_POINTER_MOTION_MASK | \
GDK_POINTER_MOTION_HINT_MASK | \
GDK_BUTTON_PRESS_MASK | \
GDK_BUTTON_RELEASE_MASK | \
GDK_BUTTON1_MOTION_MASK)
#define GRAD_UPDATE_PREVIEW 0x0001
#define GRAD_UPDATE_CONTROL 0x0002
#define GRAD_RESET_CONTROL 0X0004
/***** Types *****/
/* Gradient segment type */
@ -81,7 +40,21 @@ typedef enum
GRAD_HSV_CW /* clockwise hue */
} grad_color_t;
typedef struct _grad_segment_t
typedef struct _grad_segment_t grad_segment_t;
struct _gradient_t
{
gchar *name;
gchar *filename;
grad_segment_t *segments;
grad_segment_t *last_visited;
gboolean dirty;
GdkPixmap *pixmap;
};
struct _grad_segment_t
{
double left, middle, right; /* Left pos, midpoint, right pos */
double r0, g0, b0, a0; /* Left color */
@ -90,178 +63,6 @@ typedef struct _grad_segment_t
grad_color_t color; /* Segment's coloring type */
struct _grad_segment_t *prev, *next; /* For linked list of segments */
} grad_segment_t;
/* Complete gradient type */
struct _gradient_t
{
char *name;
grad_segment_t *segments;
grad_segment_t *last_visited;
int dirty;
char *filename;
GdkPixmap *pixmap;
};
/* Gradient editor type */
typedef enum
{
GRAD_DRAG_NONE = 0,
GRAD_DRAG_LEFT,
GRAD_DRAG_MIDDLE,
GRAD_DRAG_ALL
} control_drag_mode_t;
typedef struct
{
GtkWidget *shell;
GdkGC *gc;
GtkWidget *hint_label;
GtkWidget *clist;
GtkWidget *scrollbar;
GtkWidget *preview;
GtkWidget *control;
/* Zoom and scrollbar */
unsigned int zoom_factor;
GtkObject *scroll_data;
/* Instant update */
int instant_update;
/* Gradient preview */
guchar *preview_rows[2]; /* For caching redraw info */
gint preview_last_x;
int preview_button_down;
/* Gradient control */
GdkPixmap *control_pixmap;
grad_segment_t *control_drag_segment; /* Segment which is being dragged */
grad_segment_t *control_sel_l; /* Left segment of selection */
grad_segment_t *control_sel_r; /* Right segment of selection */
control_drag_mode_t control_drag_mode; /* What is being dragged? */
guint32 control_click_time; /* Time when mouse was pressed */
int control_compress; /* Compressing/expanding handles */
gint control_last_x; /* Last mouse position when dragging */
double control_last_gx; /* Last position (wrt gradient) when dragging */
double control_orig_pos; /* Original click position when dragging */
GtkWidget *control_main_popup; /* Popup menu */
GtkWidget *control_blending_label; /* Blending function label */
GtkWidget *control_coloring_label; /* Coloring type label */
GtkWidget *control_splitm_label; /* Split at midpoint label */
GtkWidget *control_splitu_label; /* Split uniformly label */
GtkWidget *control_delete_menu_item; /* Delete menu item */
GtkWidget *control_delete_label; /* Delete label */
GtkWidget *control_recenter_label; /* Re-center label */
GtkWidget *control_redistribute_label; /* Re-distribute label */
GtkWidget *control_flip_label; /* Flip label */
GtkWidget *control_replicate_label; /* Replicate label */
GtkWidget *control_blend_colors_menu_item; /* Blend colors menu item */
GtkWidget *control_blend_opacity_menu_item; /* Blend opacity menu item */
GtkWidget *control_left_load_popup; /* Left endpoint load menu */
GtkWidget *control_left_save_popup; /* Left endpoint save menu */
GtkWidget *control_right_load_popup; /* Right endpoint load menu */
GtkWidget *control_right_save_popup; /* Right endpoint save menu */
GtkWidget *control_blending_popup; /* Blending function menu */
GtkWidget *control_coloring_popup; /* Coloring type menu */
GtkWidget *control_sel_ops_popup; /* Selection ops menu */
GtkAccelGroup *accel_group;
/* Blending and coloring menus */
GtkWidget *control_blending_items[5 + 1]; /* Add 1 for the "Varies" item */
GtkWidget *control_coloring_items[3 + 1];
/* Split uniformly dialog */
int split_parts;
/* Replicate dialog */
int replicate_times;
/* Saved colors */
struct
{
double r, g, b, a;
} saved_colors[GRAD_NUM_COLORS];
GtkWidget *left_load_color_boxes[GRAD_NUM_COLORS + 3];
GtkWidget *left_load_labels[GRAD_NUM_COLORS + 3];
GtkWidget *left_save_color_boxes[GRAD_NUM_COLORS];
GtkWidget *left_save_labels[GRAD_NUM_COLORS];
GtkWidget *right_load_color_boxes[GRAD_NUM_COLORS + 3];
GtkWidget *right_load_labels[GRAD_NUM_COLORS + 3];
GtkWidget *right_save_color_boxes[GRAD_NUM_COLORS];
GtkWidget *right_save_labels[GRAD_NUM_COLORS];
/* Color dialogs */
GtkWidget *left_color_preview;
grad_segment_t *left_saved_segments;
int left_saved_dirty;
GtkWidget *right_color_preview;
grad_segment_t *right_saved_segments;
int right_saved_dirty;
} gradient_editor_t;
/* Selection dialog functions */
void sel_update_dialogs (gint row, gradient_t *grad);
void grad_sel_free_all (void);
void grad_sel_refill_all (void);
void grad_sel_rename_all (gint n, gradient_t *grad);
void grad_sel_new_all (gint n, gradient_t *grad);
void grad_sel_copy_all (gint n, gradient_t *grad);
void grad_sel_delete_all (gint n);
void grad_create_gradient_editor_init (gint need_show);
void ed_insert_in_gradients_listbox (GdkGC *, GtkWidget *, gradient_t *grad,
int pos, int select);
gint grad_set_grad_to_name (gchar *name);
gint ed_set_list_of_gradients (GdkGC *, GtkWidget *, gradient_t *);
/* Varibles used */
extern gradient_t *curr_gradient; /* The active gradient */
extern GSList *gradients_list; /* The list of gradients */
extern gradient_t *grad_default_gradient;
extern gradient_editor_t *g_editor; /* The gradient editor */
extern int num_gradients;
#define G_SAMPLE 40
typedef struct _GradSelect _GradSelect, *GradSelectP;
struct _GradSelect
{
GtkWidget *shell;
GtkWidget *frame;
GtkWidget *preview;
GtkWidget *clist;
gchar *callback_name;
gradient_t *grad;
gint sample_size;
GdkColor black;
GdkGC *gc;
};
GradSelectP gsel_new_selection (gchar * title, gchar * initial_gradient);
void grad_select_free (GradSelectP gsp);
extern GSList *grad_active_dialogs; /* List of active dialogs */
extern GradSelectP gradient_select_dialog; /* The main selection dialog */
#endif /* __GRADIENT_HEADER_H__ */

View File

@ -31,408 +31,108 @@
* 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 "config.h"
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "appenv.h"
#include "colormaps.h"
#include "cursorutil.h"
#include "datafiles.h"
#include "dialog_handler.h"
#include "errors.h"
#include "gimpcontext.h"
#include "gimprc.h"
#include "gimpdnd.h"
#include "gimpui.h"
#include "gradient.h"
#include "gradient_header.h"
#include "interface.h"
#include "gradientP.h"
#include "gradient_select.h"
#include "session.h"
#include "libgimp/gimpintl.h"
GSList *grad_active_dialogs = NULL; /* List of active dialogs */
GradSelectP gradient_select_dialog = NULL; /* The main selection dialog */
static void gradient_change_callbacks (GradientSelect *gsp,
gboolean closing);
static void grad_select_close_callback (GtkWidget *, gpointer);
static void grad_select_edit_callback (GtkWidget *, gpointer);
static void grad_change_callbacks (GradSelectP gsp, gint closing);
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 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]));
/* list of active dialogs */
GSList *gradient_active_dialogs = NULL;
/* the main gradient selection dialog */
GradientSelect *gradient_select_dialog = NULL;
void
grad_free_gradient_editor (void)
gradient_dialog_create (void)
{
if (gradient_select_dialog)
session_get_window_info (gradient_select_dialog->shell,
&gradient_select_session_info);
}
void
grad_sel_rename_all (gint n,
gradient_t *grad)
{
GSList *list;
GradSelectP gsp;
for (list = grad_active_dialogs; list; list = g_slist_next (list))
if (! gradient_select_dialog)
{
gsp = (GradSelectP) list->data;
gtk_clist_set_text (GTK_CLIST (gsp->clist), n, 1, grad->name);
}
if (gradient_select_dialog)
{
gtk_clist_set_text (GTK_CLIST (gradient_select_dialog->clist),
n, 1, grad->name);
}
}
void
grad_sel_new_all (gint pos,
gradient_t *grad)
{
GSList *list;
GradSelectP gsp;
for (list = grad_active_dialogs; list; list = g_slist_next (list))
{
gsp = (GradSelectP) list->data;
gtk_clist_freeze (GTK_CLIST (gsp->clist));
ed_insert_in_gradients_listbox (gsp->gc, gsp->clist, grad, pos, 1);
gtk_clist_thaw (GTK_CLIST (gsp->clist));
}
if (gradient_select_dialog)
{
gtk_clist_freeze (GTK_CLIST (gradient_select_dialog->clist));
ed_insert_in_gradients_listbox (gradient_select_dialog->gc,
gradient_select_dialog->clist,
grad, pos, 1);
gtk_clist_thaw (GTK_CLIST (gradient_select_dialog->clist));
}
}
void
grad_sel_copy_all (gint pos,
gradient_t *grad)
{
GSList *list;
GradSelectP gsp;
for (list = grad_active_dialogs; list; list = g_slist_next (list))
{
gsp = (GradSelectP) list->data;
gtk_clist_freeze (GTK_CLIST (gsp->clist));
ed_insert_in_gradients_listbox (gsp->gc, gsp->clist, grad, pos, 1);
gtk_clist_thaw (GTK_CLIST (gsp->clist));
}
if (gradient_select_dialog)
{
gtk_clist_freeze (GTK_CLIST (gradient_select_dialog->clist));
ed_insert_in_gradients_listbox (gradient_select_dialog->gc,
gradient_select_dialog->clist,
grad, pos, 1);
gtk_clist_thaw (GTK_CLIST (gradient_select_dialog->clist));
}
}
void
grad_sel_delete_all (gint n)
{
GSList *list;
GradSelectP gsp;
for (list = grad_active_dialogs; list; list = g_slist_next (list))
{
gsp = (GradSelectP) list->data;
gtk_clist_remove (GTK_CLIST (gsp->clist), n);
}
if (gradient_select_dialog)
{
gtk_clist_remove (GTK_CLIST (gradient_select_dialog->clist), n);
}
}
void
grad_sel_free_all ()
{
GSList *list;
GradSelectP gsp;
for (list = grad_active_dialogs; list; list = g_slist_next (list))
{
gsp = (GradSelectP) list->data;
gtk_clist_freeze (GTK_CLIST (gsp->clist));
gtk_clist_clear (GTK_CLIST (gsp->clist));
gtk_clist_thaw (GTK_CLIST (gsp->clist));
}
if (gradient_select_dialog)
{
gtk_clist_freeze (GTK_CLIST (gradient_select_dialog->clist));
gtk_clist_clear (GTK_CLIST (gradient_select_dialog->clist));
gtk_clist_thaw (GTK_CLIST (gradient_select_dialog->clist));
}
}
void
grad_sel_refill_all ()
{
GSList *list;
GradSelectP gsp;
int select_pos = -1;
for (list = grad_active_dialogs; list; list = g_slist_next (list))
{
gsp = (GradSelectP) list->data;
gsp->grad = curr_gradient;
select_pos = ed_set_list_of_gradients (gsp->gc,
gsp->clist,
curr_gradient);
if (select_pos != -1)
gtk_clist_moveto (GTK_CLIST (gsp->clist), select_pos, 0, 0.0, 0.0);
}
if (gradient_select_dialog)
{
gradient_select_dialog->grad = curr_gradient;
select_pos = ed_set_list_of_gradients (gradient_select_dialog->gc,
gradient_select_dialog->clist,
curr_gradient);
if (select_pos != -1)
gtk_clist_moveto (GTK_CLIST (gradient_select_dialog->clist),
select_pos, 0, 0.0, 0.0);
}
}
void
sel_update_dialogs (gint row,
gradient_t *grad)
{
/* Go around each updating the names and hopefully the previews */
GradSelectP gsp;
GSList *list;
for (list = grad_active_dialogs; list; list = g_slist_next (list))
{
gsp = (GradSelectP) list->data;
gtk_clist_set_text (GTK_CLIST (gsp->clist), row, 1, grad->name);
/* Are we updating one that is selected in a popup dialog? */
if (grad == gsp->grad)
grad_change_callbacks (gsp, 0);
}
if (gradient_select_dialog)
gtk_clist_set_text (GTK_CLIST (gradient_select_dialog->clist),
row, 1, grad->name);
gimp_context_update_gradients (grad);
}
static void
sel_list_item_update (GtkWidget *widget,
gint row,
gint column,
GdkEventButton *event,
gpointer data)
{
GradSelectP gsp = (GradSelectP) data;
GSList* tmp = g_slist_nth (gradients_list, row);
gsp->grad = (gradient_t *) (tmp->data);
/* If main one then make it the current selection */
if (gsp == gradient_select_dialog)
{
grad_set_grad_to_name (gsp->grad->name);
gimp_context_set_gradient (gimp_context_get_user (), gsp->grad);
gradient_select_dialog = gradient_select_new (NULL, NULL);
}
else
{
grad_change_callbacks (gsp, 0);
}
}
static void
grad_select_edit_callback (GtkWidget *widget,
gpointer data)
{
GradSelectP gsp;
gsp = (GradSelectP) data;
grad_create_gradient_editor_init (TRUE);
/* Set the current gradient in this dialog to the "real current" */
if (gsp && gsp->grad)
grad_set_grad_to_name (gsp->grad->name);
}
void
grad_select_free (GradSelectP gsp)
{
if (gsp)
{
if (gsp->callback_name)
g_free (gsp->callback_name);
/* remove from active list */
grad_active_dialogs = g_slist_remove (grad_active_dialogs, gsp);
g_free (gsp);
}
}
/* Close active dialogs that no longer have PDB registered for them */
void
gradients_check_dialogs (void)
{
GSList *list;
GradSelectP gsp;
gchar * name;
ProcRecord *prec = NULL;
for (list = grad_active_dialogs; list;)
{
gsp = (GradSelectP) list->data;
list = g_slist_next (list);
name = gsp->callback_name;
if (name)
{
prec = procedural_db_lookup (name);
if (!prec)
{
grad_active_dialogs = g_slist_remove (grad_active_dialogs, gsp);
/* Can alter grad_active_dialogs list*/
grad_select_close_callback (NULL, gsp);
}
}
}
}
static void
grad_change_callbacks (GradSelectP gsp,
gint closing)
{
gchar * name;
ProcRecord *prec = NULL;
gradient_t *grad;
int nreturn_vals;
static int busy = 0;
/* Any procs registered to callback? */
Argument *return_vals;
if (!gsp || !gsp->callback_name || busy != 0)
return;
busy = 1;
name = gsp->callback_name;
grad = gsp->grad;
/* If its still registered run it */
prec = procedural_db_lookup (name);
if (prec && grad)
{
gdouble *values, *pv;
double pos, delta;
double r, g, b, a;
int i = gsp->sample_size;
pos = 0.0;
delta = 1.0 / (i - 1);
values = g_new (gdouble, 4 * i);
pv = values;
while (i--)
{
gradient_get_color_at (grad, pos, &r, &g, &b, &a);
*pv++ = r;
*pv++ = g;
*pv++ = b;
*pv++ = a;
pos += delta;
}
return_vals = procedural_db_run_proc (name,
&nreturn_vals,
PDB_STRING, grad->name,
PDB_INT32, gsp->sample_size*4,
PDB_FLOATARRAY, values,
PDB_INT32, closing,
PDB_END);
if (!return_vals || return_vals[0].value.pdb_int != PDB_SUCCESS)
g_message ("failed to run gradient callback function");
if (!GTK_WIDGET_VISIBLE (gradient_select_dialog->shell))
gtk_widget_show (gradient_select_dialog->shell);
else
procedural_db_destroy_args (return_vals, nreturn_vals);
gdk_window_raise (gradient_select_dialog->shell->window);
}
busy = 0;
}
static void
grad_select_close_callback (GtkWidget *widget,
gpointer data)
void
gradient_dialog_free (void)
{
GradSelectP gsp;
gsp = (GradSelectP) 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)
if (gradient_select_dialog)
{
grad_change_callbacks (gsp, 1);
gtk_widget_destroy (gsp->shell);
grad_select_free (gsp);
session_get_window_info (gradient_select_dialog->shell,
&gradient_select_session_info);
gradient_select_free (gradient_select_dialog);
gradient_select_dialog = NULL;
}
gradient_editor_free ();
}
GradSelectP
gsel_new_selection (gchar *title,
gchar *initial_gradient)
/* If title == NULL then it is the main gradient select dialog */
GradientSelect *
gradient_select_new (gchar *title,
gchar *initial_gradient)
{
GradSelectP gsp;
gradient_t *grad = NULL;
GSList *list;
GradientSelect *gsp;
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *scrolled_win;
GdkColormap *colormap;
gint select_pos;
/* Load them if they are not already loaded */
if (g_editor == NULL)
{
grad_create_gradient_editor_init(FALSE);
}
gradient_t *active = NULL;
gsp = g_new (_GradSelect, 1);
static gboolean first_call = TRUE;
gsp = g_new (GradientSelect, 1);
gsp->callback_name = NULL;
/* The shell and main vbox */
/* The shell */
gsp->shell = gimp_dialog_new (title ? title : _("Gradient Selection"),
"gradient_selection",
gimp_standard_help_func,
@ -440,18 +140,55 @@ gsel_new_selection (gchar *title,
GTK_WIN_POS_NONE,
FALSE, TRUE, FALSE,
_("Edit"), grad_select_edit_callback,
_("Edit"), gradient_select_edit_callback,
gsp, NULL, FALSE, FALSE,
_("Close"), grad_select_close_callback,
_("Close"), gradient_select_close_callback,
gsp, NULL, TRUE, TRUE,
NULL);
vbox = gtk_vbox_new (FALSE, 1);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 1);
if (title)
{
gsp->context = gimp_context_new (title, NULL);
}
else
{
gsp->context = gimp_context_get_user ();
session_set_window_geometry (gsp->shell, &gradient_select_session_info,
TRUE);
dialog_register (gsp->shell);
}
if (no_data && first_call)
gradients_init (FALSE);
first_call = FALSE;
if (title && initial_gradient && strlen (initial_gradient))
{
active = gradient_list_get_gradient (gradients_list, initial_gradient);
}
else
{
active = gimp_context_get_gradient (gimp_context_get_user ());
}
if (!active)
{
active = gimp_context_get_gradient (gimp_context_get_standard ());
}
if (title)
{
gimp_context_set_gradient (gsp->context, active);
}
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);
/* clist preview of gradients */
/* clist preview of gradients */
scrolled_win = gtk_scrolled_window_new (NULL, NULL);
gsp->clist = gtk_clist_new (2);
@ -463,13 +200,15 @@ gsel_new_selection (gchar *title,
gtk_clist_set_column_title (GTK_CLIST (gsp->clist), 0, _("Gradient"));
gtk_clist_set_column_title (GTK_CLIST (gsp->clist), 1, _("Name"));
gtk_clist_column_titles_show (GTK_CLIST (gsp->clist));
hbox = gtk_hbox_new (FALSE, 8);
gtk_container_set_border_width (GTK_CONTAINER (hbox), 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
gtk_widget_show (hbox);
gtk_box_pack_start (GTK_BOX (hbox), scrolled_win, TRUE, TRUE, 0);
/* dnd stuff */
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);
gtk_container_add (GTK_CONTAINER (vbox), scrolled_win);
gtk_container_add (GTK_CONTAINER (scrolled_win), gsp->clist);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
GTK_POLICY_AUTOMATIC,
@ -483,68 +222,350 @@ gsel_new_selection (gchar *title,
gdk_color_parse ("black", &gsp->black);
gdk_color_alloc (colormap, &gsp->black);
gtk_signal_connect (GTK_OBJECT (gsp->clist), "select_row",
GTK_SIGNAL_FUNC (sel_list_item_update),
(gpointer) gsp);
if (initial_gradient && strlen (initial_gradient))
{
for (list = gradients_list; list; list = g_slist_next (list))
{
grad = (gradient_t *) list->data;
if (strcmp (grad->name, initial_gradient) == 0)
{
/* We found it! */
break;
}
}
}
if (grad == NULL)
grad = curr_gradient;
gsp->grad = grad;
gtk_widget_realize (gsp->shell);
gsp->gc = gdk_gc_new (gsp->shell->window);
select_pos = ed_set_list_of_gradients (gsp->gc,
gsp->clist,
grad);
select_pos = gradient_clist_init (gsp->shell, gsp->gc, gsp->clist, active);
/* Now show the dialog */
gtk_widget_show (vbox);
gtk_widget_show (gsp->shell);
if (select_pos != -1)
gtk_clist_moveto (GTK_CLIST (gsp->clist), select_pos, 0, 0.0, 0.0);
gtk_signal_connect (GTK_OBJECT (gsp->clist), "select_row",
GTK_SIGNAL_FUNC (gradient_select_list_item_update),
(gpointer) gsp);
gtk_signal_connect (GTK_OBJECT (gsp->context), "gradient_changed",
GTK_SIGNAL_FUNC (gradient_select_gradient_changed),
gsp);
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
grad_create_gradient_editor (void)
gradient_select_free (GradientSelect *gsp)
{
if (gradient_select_dialog == NULL)
{
gradient_select_dialog = gsel_new_selection (_("Gradients"), NULL);
if (!gsp)
return;
/* register this one only */
dialog_register (gradient_select_dialog->shell);
/* remove from active list */
gradient_active_dialogs = g_slist_remove (gradient_active_dialogs, gsp);
session_set_window_geometry (gradient_select_dialog->shell,
&gradient_select_session_info, TRUE);
gtk_signal_disconnect_by_data (GTK_OBJECT (gsp->context), gsp);
if (gsp->callback_name)
{
g_free (gsp->callback_name);
gtk_object_unref (GTK_OBJECT (gsp->context));
}
else
g_free (gsp);
}
/* Call this dialog's PDB callback */
static void
gradient_change_callbacks (GradientSelect *gsp,
gboolean closing)
{
gchar * name;
ProcRecord *prec = NULL;
gradient_t *gradient;
gint nreturn_vals;
static gboolean busy = FALSE;
/* Any procs registered to callback? */
Argument *return_vals;
if (!gsp || !gsp->callback_name || busy != 0)
return;
busy = TRUE;
name = gsp->callback_name;
gradient = gimp_context_get_gradient (gsp->context);
/* If its still registered run it */
prec = procedural_db_lookup (name);
if (prec && gradient)
{
if (!GTK_WIDGET_VISIBLE (gradient_select_dialog->shell))
gdouble *values, *pv;
double pos, delta;
double r, g, b, a;
int i = gsp->sample_size;
pos = 0.0;
delta = 1.0 / (i - 1);
values = g_new (gdouble, 4 * i);
pv = values;
while (i--)
{
gtk_widget_show (gradient_select_dialog->shell);
gradient_get_color_at (gradient, pos, &r, &g, &b, &a);
*pv++ = r;
*pv++ = g;
*pv++ = b;
*pv++ = a;
pos += delta;
}
return_vals = procedural_db_run_proc (name,
&nreturn_vals,
PDB_STRING, gradient->name,
PDB_INT32, gsp->sample_size * 4,
PDB_FLOATARRAY, values,
PDB_INT32, (gint) closing,
PDB_END);
if (!return_vals || return_vals[0].value.pdb_int != PDB_SUCCESS)
g_message ("failed to run gradient callback function");
else
procedural_db_destroy_args (return_vals, nreturn_vals);
}
busy = FALSE;
}
/* Close active dialogs that no longer have PDB registered for them */
void
gradients_check_dialogs (void)
{
GradientSelect *gsp;
GSList *list;
gchar *name;
ProcRecord *prec = NULL;
list = gradient_active_dialogs;
while (list)
{
gsp = (GradientSelect *) list->data;
list = g_slist_next (list);
name = gsp->callback_name;
if (name)
{
gdk_window_raise (gradient_select_dialog->shell->window);
prec = procedural_db_lookup (name);
if (!prec)
{
/* Can alter gradient_active_dialogs list */
gradient_select_close_callback (NULL, gsp);
}
}
}
}
void
gradient_select_rename_all (gint n,
gradient_t *gradient)
{
GradientSelect *gsp;
GSList *list;
for (list = gradient_active_dialogs; list; list = g_slist_next (list))
{
gsp = (GradientSelect *) list->data;
gtk_clist_set_text (GTK_CLIST (gsp->clist), n, 1, gradient->name);
}
}
void
gradient_select_insert_all (gint pos,
gradient_t *gradient)
{
GradientSelect *gsp;
GSList *list;
for (list = gradient_active_dialogs; list; list = g_slist_next (list))
{
gsp = (GradientSelect *) list->data;
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));
}
}
void
gradient_select_delete_all (gint n)
{
GradientSelect *gsp;
GSList *list;
for (list = gradient_active_dialogs; list; list = g_slist_next (list))
{
gsp = (GradientSelect *) list->data;
gtk_clist_remove (GTK_CLIST (gsp->clist), n);
}
}
void
gradient_select_free_all (void)
{
GradientSelect *gsp;
GSList *list;
for (list = gradient_active_dialogs; list; list = g_slist_next (list))
{
gsp = (GradientSelect *) list->data;
gtk_clist_freeze (GTK_CLIST (gsp->clist));
gtk_clist_clear (GTK_CLIST (gsp->clist));
gtk_clist_thaw (GTK_CLIST (gsp->clist));
}
}
void
gradient_select_refill_all (void)
{
GradientSelect *gsp;
GSList *list;
gint index = -1;
for (list = gradient_active_dialogs; list; list = g_slist_next (list))
{
gsp = (GradientSelect *) list->data;
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;
for (list = gradient_active_dialogs; list; list = g_slist_next (list))
{
gsp = (GradientSelect *) list->data;
gtk_clist_set_text (GTK_CLIST (gsp->clist), row, 1, gradient->name);
/* Are we updating one that is selected in a popup dialog? */
if ((gradient == gimp_context_get_gradient (gsp->context)) &&
(gsp != gradient_select_dialog))
gradient_change_callbacks (gsp, FALSE);
}
}
/*
* Local functions
*/
static void
gradient_select_drop_gradient (GtkWidget *widget,
gradient_t *gradient,
gpointer data)
{
GradientSelect *gsp;
gsp = (GradientSelect *) data;
gimp_context_set_gradient (gsp->context, gradient);
}
static void
gradient_select_gradient_changed (GimpContext *context,
gradient_t *gradient,
GradientSelect *gsp)
{
if (gradient)
gradient_select_select (gsp, gradient);
}
static void
gradient_select_select (GradientSelect *gsp,
gradient_t *gradient)
{
gint index;
index = gradient_list_get_gradient_index (gradients_list, gradient);
if (index != -1)
{
gtk_signal_handler_block_by_data (GTK_OBJECT (gsp->clist), gsp);
gtk_clist_select_row (GTK_CLIST (gsp->clist), index, -1);
gtk_clist_moveto (GTK_CLIST (gsp->clist), index, 0, 0.5, 0.0);
gtk_signal_handler_unblock_by_data (GTK_OBJECT (gsp->clist), gsp);
}
}
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);
if (gsp != gradient_select_dialog)
{
gradient_change_callbacks (gsp, FALSE);
}
}
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);
}
}

71
app/gradient_select.h Normal file
View File

@ -0,0 +1,71 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* 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 __GRADIENT_SELECT_H__
#define __GRADIENT_SELECT_H__
#include <gtk/gtk.h>
#include "gimpcontext.h"
#define GRADIENT_SAMPLE_SIZE 40
typedef struct _GradientSelect GradientSelect;
struct _GradientSelect
{
GtkWidget *shell;
GtkWidget *frame;
GtkWidget *preview;
GtkWidget *clist;
GimpContext *context;
gchar *callback_name;
gint sample_size;
GdkColor black;
GdkGC *gc;
};
/* list of active dialogs */
extern GSList *gradient_active_dialogs;
/* the main gradient selection dialog */
extern GradientSelect *gradient_select_dialog;
GradientSelect * gradient_select_new (gchar *title,
gchar *initial_gradient);
void gradient_select_free (GradientSelect *gsp);
void gradient_select_rename_all (gint n,
gradient_t *gradient);
void gradient_select_insert_all (gint pos,
gradient_t *gradient);
void gradient_select_delete_all (gint n);
void gradient_select_free_all (void);
void gradient_select_refill_all (void);
void gradient_select_update_all (gint row,
gradient_t *gradient);
void gradients_check_dialogs (void);
/* the main gradient selection */
void gradient_dialog_create (void);
void gradient_dialog_free (void);
#endif /* __GRADIENT_SELECT_H__ */

View File

@ -23,8 +23,8 @@
#include <string.h>
#include "gimpcontext.h"
#include "gradient.h"
#include "gradient_header.h"
#include "gradient_select.h"
static ProcRecord gradients_popup_proc;
static ProcRecord gradients_close_popup_proc;
@ -40,20 +40,18 @@ register_gradient_select_procs (void)
procedural_db_register (&gradients_get_gradient_data_proc);
}
static GradSelectP
gradients_get_gradientselect(gchar *name)
static GradientSelect *
gradients_get_gradientselect (gchar *name)
{
GSList *list = grad_active_dialogs;
GradSelectP gsp;
GSList *list;
GradientSelect *gsp;
while (list)
for (list = gradient_active_dialogs; list; list = g_slist_next (list))
{
gsp = (GradSelectP) list->data;
gsp = (GradientSelect *) list->data;
if (!strcmp (name, gsp->callback_name))
return gsp;
list = list->next;
}
return NULL;
@ -68,7 +66,7 @@ gradients_popup_invoker (Argument *args)
gchar *initial_gradient;
gint32 sample_size;
ProcRecord *prec;
GradSelectP newdialog;
GradientSelect *newdialog;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL)
@ -82,22 +80,19 @@ gradients_popup_invoker (Argument *args)
sample_size = args[3].value.pdb_int;
if (sample_size <= 0 || sample_size > 10000)
sample_size = G_SAMPLE;
sample_size = GRADIENT_SAMPLE_SIZE;
if (success)
{
if ((prec = procedural_db_lookup (name)))
{
if (initial_gradient && strlen (initial_gradient))
newdialog = gsel_new_selection (title, initial_gradient);
newdialog = gradient_select_new (title, initial_gradient);
else
newdialog = gsel_new_selection (title, NULL);
newdialog = gradient_select_new (title, NULL);
newdialog->callback_name = g_strdup (name);
newdialog->sample_size = sample_size;
/* Add to active gradient dialogs list */
grad_active_dialogs = g_slist_append (grad_active_dialogs, newdialog);
newdialog->sample_size = sample_size;
}
else
success = FALSE;
@ -152,7 +147,7 @@ gradients_close_popup_invoker (Argument *args)
gboolean success = TRUE;
gchar *name;
ProcRecord *prec;
GradSelectP gsp;
GradientSelect *gsp;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL)
@ -163,8 +158,6 @@ gradients_close_popup_invoker (Argument *args)
if ((prec = procedural_db_lookup (name)) &&
(gsp = gradients_get_gradientselect (name)))
{
grad_active_dialogs = g_slist_remove (grad_active_dialogs, gsp);
if (GTK_WIDGET_VISIBLE (gsp->shell))
gtk_widget_hide (gsp->shell);
@ -173,7 +166,7 @@ gradients_close_popup_invoker (Argument *args)
{
/* Send data back */
gtk_widget_destroy (gsp->shell);
grad_select_free (gsp);
gradient_select_free (gsp);
}
}
else
@ -215,7 +208,7 @@ gradients_set_popup_invoker (Argument *args)
gchar *pdbname;
gchar *gradient_name;
ProcRecord *prec;
GradSelectP gsp;
GradientSelect *gsp;
pdbname = (gchar *) args[0].value.pdb_pointer;
if (pdbname == NULL)
@ -230,27 +223,20 @@ gradients_set_popup_invoker (Argument *args)
if ((prec = procedural_db_lookup (pdbname)) &&
(gsp = gradients_get_gradientselect (pdbname)))
{
GSList *tmp;
GSList *list;
gradient_t *active = NULL;
int pos = 0;
tmp = gradients_list;
while (tmp)
for (list = gradients_list; list; list = g_slist_next (list))
{
active = tmp->data;
active = (gradient_t *) list->data;
if (!strcmp (gradient_name, active->name))
break; /* We found the one we want */
pos++;
tmp = tmp->next;
}
if (active)
{
gtk_clist_select_row (GTK_CLIST (gsp->clist), pos, -1);
gtk_clist_moveto (GTK_CLIST (gsp->clist), pos, 0, 0.0, 0.0);
gimp_context_set_gradient (gsp->context, active);
}
else
success = FALSE;
@ -300,7 +286,7 @@ gradients_get_gradient_data_invoker (Argument *args)
gchar *name;
gint32 sample_size;
gdouble *values = NULL;
gradient_t *grad = NULL;
gradient_t *gradient = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL)
@ -308,31 +294,29 @@ gradients_get_gradient_data_invoker (Argument *args)
sample_size = args[1].value.pdb_int;
if (sample_size <= 0 || sample_size > 10000)
sample_size = G_SAMPLE;
sample_size = GRADIENT_SAMPLE_SIZE;
if (success)
{
if (strlen (name))
{
GSList *list = gradients_list;
GSList *list;
success = FALSE;
while (list)
for (list = gradients_list; list; list = g_slist_next (list))
{
grad = list->data;
gradient = (gradient_t *) list->data;
if (!strcmp (grad->name, name))
if (!strcmp (gradient->name, name))
{
success = TRUE;
break; /* We found it! */
}
list = list->next;
}
}
else
success = (grad = gimp_context_get_gradient (NULL)) != NULL;
success = (gradient = gimp_context_get_gradient (NULL)) != NULL;
if (success)
{
@ -348,7 +332,7 @@ gradients_get_gradient_data_invoker (Argument *args)
while (i--)
{
gradient_get_color_at (grad, pos, &r, &g, &b, &a);
gradient_get_color_at (gradient, pos, &r, &g, &b, &a);
*pv++ = r;
*pv++ = g;
@ -364,7 +348,7 @@ gradients_get_gradient_data_invoker (Argument *args)
if (success)
{
return_args[1].value.pdb_pointer = g_strdup (grad->name);
return_args[1].value.pdb_pointer = g_strdup (gradient->name);
return_args[2].value.pdb_int = sample_size * 4;
return_args[3].value.pdb_pointer = values;
}

View File

@ -27,6 +27,7 @@
#include "gimpbrushpipe.h"
#include "gimpbrushpipeP.h"
#include "gimpcontext.h"
#include "gimpdnd.h"
#include "gimplist.h"
#include "gimprc.h"
#include "gimpui.h"
@ -63,41 +64,13 @@
#define BLK { 0, 0, 0}
#define RED {255, 127, 127}
static unsigned char scale_indicator_bits[7][7][3] =
{
{ WHT, WHT, WHT, WHT, WHT, WHT, WHT },
{ WHT, WHT, WHT, BLK, WHT, WHT, WHT },
{ WHT, WHT, WHT, BLK, WHT, WHT, WHT },
{ WHT, BLK, BLK, BLK, BLK, BLK, WHT },
{ WHT, WHT, WHT, BLK, WHT, WHT, WHT },
{ WHT, WHT, WHT, BLK, WHT, WHT, WHT },
{ WHT, WHT, WHT, WHT, WHT, WHT, WHT }
};
static unsigned char pipe_indicator_bits[7][7][3] =
{
{ WHT, WHT, WHT, WHT, WHT, WHT, WHT },
{ WHT, WHT, WHT, WHT, WHT, WHT, RED },
{ WHT, WHT, WHT, WHT, WHT, RED, RED },
{ WHT, WHT, WHT, WHT, RED, RED, RED },
{ WHT, WHT, WHT, RED, RED, RED, RED },
{ WHT, WHT, RED, RED, RED, RED, RED },
{ WHT, RED, RED, RED, RED, RED, RED }
};
static unsigned char scale_pipe_indicator_bits[7][7][3] =
{
{ WHT, WHT, WHT, WHT, WHT, WHT, WHT },
{ WHT, WHT, WHT, BLK, WHT, WHT, RED },
{ WHT, WHT, WHT, BLK, WHT, RED, RED },
{ WHT, BLK, BLK, BLK, BLK, BLK, RED },
{ WHT, WHT, WHT, BLK, RED, RED, RED },
{ WHT, WHT, RED, BLK, RED, RED, RED },
{ WHT, RED, RED, RED, RED, RED, RED }
};
/* local function prototypes */
static void brush_change_callbacks (BrushSelect *bsp,
gboolean closing);
static void brush_select_drop_brush (GtkWidget *widget,
GimpBrush *brush,
gpointer data);
static void brush_select_brush_changed (GimpContext *context,
GimpBrush *brush,
BrushSelect *bsp);
@ -162,6 +135,47 @@ static void brush_select_new_brush_callback (GtkWidget *, gpointer);
static void brush_select_edit_brush_callback (GtkWidget *, gpointer);
static void brush_select_delete_brush_callback (GtkWidget *, gpointer);
static unsigned char scale_indicator_bits[7][7][3] =
{
{ WHT, WHT, WHT, WHT, WHT, WHT, WHT },
{ WHT, WHT, WHT, BLK, WHT, WHT, WHT },
{ WHT, WHT, WHT, BLK, WHT, WHT, WHT },
{ WHT, BLK, BLK, BLK, BLK, BLK, WHT },
{ WHT, WHT, WHT, BLK, WHT, WHT, WHT },
{ WHT, WHT, WHT, BLK, WHT, WHT, WHT },
{ WHT, WHT, WHT, WHT, WHT, WHT, WHT }
};
static unsigned char pipe_indicator_bits[7][7][3] =
{
{ WHT, WHT, WHT, WHT, WHT, WHT, WHT },
{ WHT, WHT, WHT, WHT, WHT, WHT, RED },
{ WHT, WHT, WHT, WHT, WHT, RED, RED },
{ WHT, WHT, WHT, WHT, RED, RED, RED },
{ WHT, WHT, WHT, RED, RED, RED, RED },
{ WHT, WHT, RED, RED, RED, RED, RED },
{ WHT, RED, RED, RED, RED, RED, RED }
};
static unsigned char scale_pipe_indicator_bits[7][7][3] =
{
{ WHT, WHT, WHT, WHT, WHT, WHT, WHT },
{ WHT, WHT, WHT, BLK, WHT, WHT, RED },
{ WHT, WHT, WHT, BLK, WHT, RED, RED },
{ WHT, BLK, BLK, BLK, BLK, BLK, RED },
{ WHT, WHT, WHT, BLK, RED, RED, RED },
{ WHT, WHT, RED, BLK, RED, RED, RED },
{ WHT, RED, RED, RED, RED, RED, RED }
};
/* dnd stuff */
static GtkTargetEntry preview_target_table[] =
{
GIMP_TARGET_BRUSH
};
static guint preview_n_targets = (sizeof (preview_target_table) /
sizeof (preview_target_table[0]));
/* The main brush selection dialog */
BrushSelect *brush_select_dialog = NULL;
@ -178,21 +192,15 @@ brush_dialog_create (void)
{
if (! brush_select_dialog)
{
/* Create the dialog... */
brush_select_dialog = brush_select_new (NULL, NULL, 0.0, 0, 0);
/* register this one only */
dialog_register (brush_select_dialog->shell);
}
else
{
/* Popup the dialog */
if (!GTK_WIDGET_VISIBLE (brush_select_dialog->shell))
gtk_widget_show (brush_select_dialog->shell);
else
gdk_window_raise (brush_select_dialog->shell->window);
}
}
void
@ -200,6 +208,15 @@ brush_dialog_free ()
{
if (brush_select_dialog)
{
session_get_window_info (brush_select_dialog->shell,
&brush_select_session_info);
/* save the size of the preview */
brush_select_session_info.width =
brush_select_dialog->preview->allocation.width;
brush_select_session_info.height =
brush_select_dialog->preview->allocation.height;
brush_select_free (brush_select_dialog);
brush_select_dialog = NULL;
}
@ -231,7 +248,7 @@ brush_select_new (gchar *title,
GimpBrush *active = NULL;
/* gboolean gotinitbrush = FALSE; */
static gboolean first_call = TRUE;
bsp = g_new (BrushSelect, 1);
bsp->callback_name = NULL;
@ -267,14 +284,18 @@ brush_select_new (gchar *title,
}
else
{
bsp->context = gimp_context_get_user ();
session_set_window_geometry (bsp->shell, &brush_select_session_info,
FALSE);
bsp->context = gimp_context_get_user ();
dialog_register (bsp->shell);
}
if (no_data)
if (no_data && first_call)
brushes_init (FALSE);
first_call = FALSE;
if (title && init_name && strlen (init_name))
{
active = gimp_brush_list_get_brush (brush_list, init_name);
@ -349,6 +370,13 @@ brush_select_new (gchar *title,
GTK_SIGNAL_FUNC (brush_select_resize),
bsp);
/* dnd stuff */
gtk_drag_dest_set (bsp->preview,
GTK_DEST_DEFAULT_ALL,
preview_target_table, preview_n_targets,
GDK_ACTION_COPY);
gimp_dnd_brush_dest_set (bsp->preview, brush_select_drop_brush, bsp);
gtk_container_add (GTK_CONTAINER (frame), bsp->preview);
gtk_widget_show (bsp->preview);
@ -535,15 +563,6 @@ brush_select_free (BrushSelect *bsp)
/* remove from active list */
brush_active_dialogs = g_slist_remove (brush_active_dialogs, bsp);
/* Only main one is saved */
if (bsp == brush_select_dialog)
{
session_get_window_info (bsp->shell, &brush_select_session_info);
/* save the size of the preview */
brush_select_session_info.width = bsp->preview->allocation.width;
brush_select_session_info.height = bsp->preview->allocation.height;
}
gtk_signal_disconnect_by_data (GTK_OBJECT (bsp->context), bsp);
if (bsp->brush_popup != NULL)
@ -576,6 +595,7 @@ brush_select_freeze_all (void)
bsp->freeze = TRUE;
}
}
void
brush_select_thaw_all (void)
{
@ -633,9 +653,9 @@ brush_select_show_paint_options (BrushSelect *bsp,
/* call this dialog's PDB callback */
void
static void
brush_change_callbacks (BrushSelect *bsp,
gint closing)
gboolean closing)
{
gchar *name;
ProcRecord *prec = NULL;
@ -661,15 +681,15 @@ brush_change_callbacks (BrushSelect *bsp,
return_vals =
procedural_db_run_proc (name,
&nreturn_vals,
PDB_STRING, brush->name,
PDB_FLOAT, gimp_context_get_opacity (bsp->context),
PDB_INT32, bsp->spacing_value,
PDB_INT32, (gint)gimp_context_get_paint_mode (bsp->context),
PDB_INT32, brush->mask->width,
PDB_INT32, brush->mask->height,
PDB_INT32, brush->mask->width * brush->mask->height,
PDB_STRING, brush->name,
PDB_FLOAT, gimp_context_get_opacity (bsp->context),
PDB_INT32, bsp->spacing_value,
PDB_INT32, (gint) gimp_context_get_paint_mode (bsp->context),
PDB_INT32, brush->mask->width,
PDB_INT32, brush->mask->height,
PDB_INT32, brush->mask->width * brush->mask->height,
PDB_INT8ARRAY, temp_buf_data (brush->mask),
PDB_INT32, closing,
PDB_INT32, (gint) closing,
PDB_END);
if (!return_vals || return_vals[0].value.pdb_int != PDB_SUCCESS)
@ -695,7 +715,7 @@ brushes_check_dialogs (void)
while (list)
{
bsp = (BrushSelect *) list->data;
list = list->next;
list = g_slist_next (list);
name = bsp->callback_name;
@ -716,6 +736,18 @@ brushes_check_dialogs (void)
* Local functions
*/
static void
brush_select_drop_brush (GtkWidget *widget,
GimpBrush *brush,
gpointer data)
{
BrushSelect *bsp;
bsp = (BrushSelect *) data;
gimp_context_set_brush (bsp->context, brush);
}
static void
brush_select_brush_changed (GimpContext *context,
GimpBrush *brush,
@ -752,12 +784,14 @@ brush_select_select (BrushSelect *bsp,
{
gint index;
gint row, col;
gint scroll_offset = 0;
index = gimp_brush_list_get_brush_index (brush_list, brush);
if (index >= gimp_brush_list_length (brush_list))
index = gimp_brush_list_length (brush_list) - 1;
if (index < 0 || index >= gimp_brush_list_length (brush_list))
if (index < 0)
return;
if (GIMP_IS_BRUSH_GENERATED (brush))
@ -776,7 +810,23 @@ brush_select_select (BrushSelect *bsp,
row = index / bsp->NUM_BRUSH_COLUMNS;
col = index - row * (bsp->NUM_BRUSH_COLUMNS);
brush_select_show_selected (bsp, row, col);
/* check if the new active brush is already in the preview */
if (((row + 1) * bsp->cell_height) >
(bsp->preview->allocation.height + bsp->scroll_offset))
{
scroll_offset = (((row + 1) * bsp->cell_height) -
(bsp->scroll_offset + bsp->preview->allocation.height));
}
else if ((row * bsp->cell_height) < bsp->scroll_offset)
{
scroll_offset = (row * bsp->cell_height) - bsp->scroll_offset;
}
else
{
brush_select_show_selected (bsp, row, col);
}
gtk_adjustment_set_value (bsp->sbar_data, bsp->scroll_offset + scroll_offset);
}
static void
@ -1373,6 +1423,7 @@ preview_calc_scrollbar (BrushSelect *bsp)
bsp->sbar_data->page_increment = (page_size >> 1);
bsp->sbar_data->step_increment = bsp->cell_width;
gtk_signal_emit_by_name (GTK_OBJECT (bsp->sbar_data), "changed");
gtk_signal_emit_by_name (GTK_OBJECT (bsp->sbar_data), "value_changed");
}
@ -1507,8 +1558,8 @@ brush_select_events (GtkWidget *widget,
/* Close the brush popup window */
brush_popup_close (bsp);
/* Call any callbacks registered */
brush_change_callbacks (bsp, 0);
/* Call any callbacks registered */
brush_change_callbacks (bsp, FALSE);
}
break;
@ -1593,7 +1644,7 @@ opacity_scale_update (GtkAdjustment *adjustment,
if (bsp != brush_select_dialog)
{
brush_change_callbacks (bsp, 0);
brush_change_callbacks (bsp, FALSE);
}
}
@ -1609,7 +1660,7 @@ paint_mode_menu_callback (GtkWidget *widget,
if (bsp != brush_select_dialog)
{
brush_change_callbacks (bsp, 0);
brush_change_callbacks (bsp, FALSE);
}
}
@ -1631,7 +1682,7 @@ spacing_scale_update (GtkAdjustment *adjustment,
if (bsp->spacing_value != adjustment->value)
{
bsp->spacing_value = adjustment->value;
brush_change_callbacks (bsp, 0);
brush_change_callbacks (bsp, FALSE);
}
}
}
@ -1651,7 +1702,7 @@ brush_select_close_callback (GtkWidget *widget,
if (bsp != brush_select_dialog)
{
/* Send data back */
brush_change_callbacks (bsp, 1);
brush_change_callbacks (bsp, TRUE);
gtk_widget_destroy (bsp->shell);
brush_select_free (bsp);
}

View File

@ -96,8 +96,6 @@ void brush_select_free (BrushSelect *bsp);
void brush_select_freeze_all (void);
void brush_select_thaw_all (void);
void brush_change_callbacks (BrushSelect *bsp,
gint closing);
void brushes_check_dialogs (void);
/* show/hide paint options (main brush dialog if bsp == NULL) */

View File

@ -54,18 +54,18 @@ typedef enum
typedef enum
{
HUE = 0,
SATURATION,
VALUE,
RED,
GREEN,
BLUE,
HUE_SATURATION,
HUE_VALUE,
SATURATION_VALUE,
RED_GREEN,
RED_BLUE,
GREEN_BLUE
COLOR_SELECT_HUE = 0,
COLOR_SELECT_SATURATION,
COLOR_SELECT_VALUE,
COLOR_SELECT_RED,
COLOR_SELECT_GREEN,
COLOR_SELECT_BLUE,
COLOR_SELECT_HUE_SATURATION,
COLOR_SELECT_HUE_VALUE,
COLOR_SELECT_SATURATION_VALUE,
COLOR_SELECT_RED_GREEN,
COLOR_SELECT_RED_BLUE,
COLOR_SELECT_GREEN_BLUE
} ColorSelectFillType;
typedef enum
@ -452,9 +452,9 @@ color_select_drag_new_color (GtkWidget *widget,
csp = (ColorSelect *) data;
*r = (guchar) csp->values[RED];
*g = (guchar) csp->values[GREEN];
*b = (guchar) csp->values[BLUE];
*r = (guchar) csp->values[COLOR_SELECT_RED];
*g = (guchar) csp->values[COLOR_SELECT_GREEN];
*b = (guchar) csp->values[COLOR_SELECT_BLUE];
}
static void
@ -468,9 +468,9 @@ color_select_drop_new_color (GtkWidget *widget,
csp = (ColorSelect *) data;
csp->values[RED] = (gint) r;
csp->values[GREEN] = (gint) g;
csp->values[BLUE] = (gint) b;
csp->values[COLOR_SELECT_RED] = (gint) r;
csp->values[COLOR_SELECT_GREEN] = (gint) g;
csp->values[COLOR_SELECT_BLUE] = (gint) b;
color_select_update_hsv_values (csp);
color_select_update_pos (csp);
@ -515,9 +515,9 @@ color_select_set_color (ColorSelect *csp,
if (set_current)
{
csp->values[RED] = r;
csp->values[GREEN] = g;
csp->values[BLUE] = b;
csp->values[COLOR_SELECT_RED] = r;
csp->values[COLOR_SELECT_GREEN] = g;
csp->values[COLOR_SELECT_BLUE] = b;
color_select_update_hsv_values (csp);
color_select_update_pos (csp);
@ -578,9 +578,9 @@ color_select_update_caller (ColorSelect *csp)
{
if (csp && csp->wants_updates && csp->callback)
{
(* csp->callback) (csp->values[RED],
csp->values[GREEN],
csp->values[BLUE],
(* csp->callback) (csp->values[COLOR_SELECT_RED],
csp->values[COLOR_SELECT_GREEN],
csp->values[COLOR_SELECT_BLUE],
COLOR_SELECT_UPDATE,
csp->client_data);
}
@ -593,48 +593,48 @@ color_select_update_values (ColorSelect *csp)
{
switch (csp->z_color_fill)
{
case RED:
csp->values[BLUE] = csp->pos[0];
csp->values[GREEN] = csp->pos[1];
csp->values[RED] = csp->pos[2];
case COLOR_SELECT_RED:
csp->values[COLOR_SELECT_BLUE] = csp->pos[0];
csp->values[COLOR_SELECT_GREEN] = csp->pos[1];
csp->values[COLOR_SELECT_RED] = csp->pos[2];
break;
case GREEN:
csp->values[BLUE] = csp->pos[0];
csp->values[RED] = csp->pos[1];
csp->values[GREEN] = csp->pos[2];
case COLOR_SELECT_GREEN:
csp->values[COLOR_SELECT_BLUE] = csp->pos[0];
csp->values[COLOR_SELECT_RED] = csp->pos[1];
csp->values[COLOR_SELECT_GREEN] = csp->pos[2];
break;
case BLUE:
csp->values[GREEN] = csp->pos[0];
csp->values[RED] = csp->pos[1];
csp->values[BLUE] = csp->pos[2];
case COLOR_SELECT_BLUE:
csp->values[COLOR_SELECT_GREEN] = csp->pos[0];
csp->values[COLOR_SELECT_RED] = csp->pos[1];
csp->values[COLOR_SELECT_BLUE] = csp->pos[2];
break;
case HUE:
csp->values[VALUE] = csp->pos[0] * 100 / 255;
csp->values[SATURATION] = csp->pos[1] * 100 / 255;
csp->values[HUE] = csp->pos[2] * 360 / 255;
case COLOR_SELECT_HUE:
csp->values[COLOR_SELECT_VALUE] = csp->pos[0] * 100 / 255;
csp->values[COLOR_SELECT_SATURATION] = csp->pos[1] * 100 / 255;
csp->values[COLOR_SELECT_HUE] = csp->pos[2] * 360 / 255;
break;
case SATURATION:
csp->values[VALUE] = csp->pos[0] * 100 / 255;
csp->values[HUE] = csp->pos[1] * 360 / 255;
csp->values[SATURATION] = csp->pos[2] * 100 / 255;
case COLOR_SELECT_SATURATION:
csp->values[COLOR_SELECT_VALUE] = csp->pos[0] * 100 / 255;
csp->values[COLOR_SELECT_HUE] = csp->pos[1] * 360 / 255;
csp->values[COLOR_SELECT_SATURATION] = csp->pos[2] * 100 / 255;
break;
case VALUE:
csp->values[SATURATION] = csp->pos[0] * 100 / 255;
csp->values[HUE] = csp->pos[1] * 360 / 255;
csp->values[VALUE] = csp->pos[2] * 100 / 255;
case COLOR_SELECT_VALUE:
csp->values[COLOR_SELECT_SATURATION] = csp->pos[0] * 100 / 255;
csp->values[COLOR_SELECT_HUE] = csp->pos[1] * 360 / 255;
csp->values[COLOR_SELECT_VALUE] = csp->pos[2] * 100 / 255;
break;
}
switch (csp->z_color_fill)
{
case RED:
case GREEN:
case BLUE:
case COLOR_SELECT_RED:
case COLOR_SELECT_GREEN:
case COLOR_SELECT_BLUE:
color_select_update_hsv_values (csp);
break;
case HUE:
case SATURATION:
case VALUE:
case COLOR_SELECT_HUE:
case COLOR_SELECT_SATURATION:
case COLOR_SELECT_VALUE:
color_select_update_rgb_values (csp);
break;
}
@ -649,15 +649,15 @@ color_select_update_rgb_values (ColorSelect *csp)
if (csp)
{
h = csp->values[HUE];
s = csp->values[SATURATION] / 100.0;
v = csp->values[VALUE] / 100.0;
h = csp->values[COLOR_SELECT_HUE];
s = csp->values[COLOR_SELECT_SATURATION] / 100.0;
v = csp->values[COLOR_SELECT_VALUE] / 100.0;
if (s == 0)
{
csp->values[RED] = v * 255;
csp->values[GREEN] = v * 255;
csp->values[BLUE] = v * 255;
csp->values[COLOR_SELECT_RED] = v * 255;
csp->values[COLOR_SELECT_GREEN] = v * 255;
csp->values[COLOR_SELECT_BLUE] = v * 255;
}
else
{
@ -673,34 +673,34 @@ color_select_update_rgb_values (ColorSelect *csp)
switch ((int) h)
{
case 0:
csp->values[RED] = v * 255;
csp->values[GREEN] = t * 255;
csp->values[BLUE] = p * 255;
csp->values[COLOR_SELECT_RED] = v * 255;
csp->values[COLOR_SELECT_GREEN] = t * 255;
csp->values[COLOR_SELECT_BLUE] = p * 255;
break;
case 1:
csp->values[RED] = q * 255;
csp->values[GREEN] = v * 255;
csp->values[BLUE] = p * 255;
csp->values[COLOR_SELECT_RED] = q * 255;
csp->values[COLOR_SELECT_GREEN] = v * 255;
csp->values[COLOR_SELECT_BLUE] = p * 255;
break;
case 2:
csp->values[RED] = p * 255;
csp->values[GREEN] = v * 255;
csp->values[BLUE] = t * 255;
csp->values[COLOR_SELECT_RED] = p * 255;
csp->values[COLOR_SELECT_GREEN] = v * 255;
csp->values[COLOR_SELECT_BLUE] = t * 255;
break;
case 3:
csp->values[RED] = p * 255;
csp->values[GREEN] = q * 255;
csp->values[BLUE] = v * 255;
csp->values[COLOR_SELECT_RED] = p * 255;
csp->values[COLOR_SELECT_GREEN] = q * 255;
csp->values[COLOR_SELECT_BLUE] = v * 255;
break;
case 4:
csp->values[RED] = t * 255;
csp->values[GREEN] = p * 255;
csp->values[BLUE] = v * 255;
csp->values[COLOR_SELECT_RED] = t * 255;
csp->values[COLOR_SELECT_GREEN] = p * 255;
csp->values[COLOR_SELECT_BLUE] = v * 255;
break;
case 5:
csp->values[RED] = v * 255;
csp->values[GREEN] = p * 255;
csp->values[BLUE] = q * 255;
csp->values[COLOR_SELECT_RED] = v * 255;
csp->values[COLOR_SELECT_GREEN] = p * 255;
csp->values[COLOR_SELECT_BLUE] = q * 255;
break;
}
}
@ -717,9 +717,9 @@ color_select_update_hsv_values (ColorSelect *csp)
if (csp)
{
r = csp->values[RED];
g = csp->values[GREEN];
b = csp->values[BLUE];
r = csp->values[COLOR_SELECT_RED];
g = csp->values[COLOR_SELECT_GREEN];
b = csp->values[COLOR_SELECT_BLUE];
if (r > g)
{
@ -771,9 +771,9 @@ color_select_update_hsv_values (ColorSelect *csp)
h += 360;
}
csp->values[HUE] = h;
csp->values[SATURATION] = s * 100;
csp->values[VALUE] = v * 100 / 255;
csp->values[COLOR_SELECT_HUE] = h;
csp->values[COLOR_SELECT_SATURATION] = s * 100;
csp->values[COLOR_SELECT_VALUE] = v * 100 / 255;
}
}
@ -784,35 +784,35 @@ color_select_update_pos (ColorSelect *csp)
{
switch (csp->z_color_fill)
{
case RED:
csp->pos[0] = csp->values[BLUE];
csp->pos[1] = csp->values[GREEN];
csp->pos[2] = csp->values[RED];
case COLOR_SELECT_RED:
csp->pos[0] = csp->values[COLOR_SELECT_BLUE];
csp->pos[1] = csp->values[COLOR_SELECT_GREEN];
csp->pos[2] = csp->values[COLOR_SELECT_RED];
break;
case GREEN:
csp->pos[0] = csp->values[BLUE];
csp->pos[1] = csp->values[RED];
csp->pos[2] = csp->values[GREEN];
case COLOR_SELECT_GREEN:
csp->pos[0] = csp->values[COLOR_SELECT_BLUE];
csp->pos[1] = csp->values[COLOR_SELECT_RED];
csp->pos[2] = csp->values[COLOR_SELECT_GREEN];
break;
case BLUE:
csp->pos[0] = csp->values[GREEN];
csp->pos[1] = csp->values[RED];
csp->pos[2] = csp->values[BLUE];
case COLOR_SELECT_BLUE:
csp->pos[0] = csp->values[COLOR_SELECT_GREEN];
csp->pos[1] = csp->values[COLOR_SELECT_RED];
csp->pos[2] = csp->values[COLOR_SELECT_BLUE];
break;
case HUE:
csp->pos[0] = csp->values[VALUE] * 255 / 100;
csp->pos[1] = csp->values[SATURATION] * 255 / 100;
csp->pos[2] = csp->values[HUE] * 255 / 360;
case COLOR_SELECT_HUE:
csp->pos[0] = csp->values[COLOR_SELECT_VALUE] * 255 / 100;
csp->pos[1] = csp->values[COLOR_SELECT_SATURATION] * 255 / 100;
csp->pos[2] = csp->values[COLOR_SELECT_HUE] * 255 / 360;
break;
case SATURATION:
csp->pos[0] = csp->values[VALUE] * 255 / 100;
csp->pos[1] = csp->values[HUE] * 255 / 360;
csp->pos[2] = csp->values[SATURATION] * 255 / 100;
case COLOR_SELECT_SATURATION:
csp->pos[0] = csp->values[COLOR_SELECT_VALUE] * 255 / 100;
csp->pos[1] = csp->values[COLOR_SELECT_HUE] * 255 / 360;
csp->pos[2] = csp->values[COLOR_SELECT_SATURATION] * 255 / 100;
break;
case VALUE:
csp->pos[0] = csp->values[SATURATION] * 255 / 100;
csp->pos[1] = csp->values[HUE] * 255 / 360;
csp->pos[2] = csp->values[VALUE] * 255 / 100;
case COLOR_SELECT_VALUE:
csp->pos[0] = csp->values[COLOR_SELECT_SATURATION] * 255 / 100;
csp->pos[1] = csp->values[COLOR_SELECT_HUE] * 255 / 360;
csp->pos[2] = csp->values[COLOR_SELECT_VALUE] * 255 / 100;
break;
}
}
@ -858,9 +858,9 @@ color_select_update_entries (ColorSelect *csp,
}
g_snprintf (buffer, sizeof (buffer), "#%.2x%.2x%.2x",
csp->values[RED],
csp->values[GREEN],
csp->values[BLUE]);
csp->values[COLOR_SELECT_RED],
csp->values[COLOR_SELECT_GREEN],
csp->values[COLOR_SELECT_BLUE]);
gtk_entry_set_text (GTK_ENTRY (csp->hex_entry), buffer);
}
}
@ -888,9 +888,9 @@ color_select_update_colors (ColorSelect *csp,
{
window = csp->new_color->window;
color.pixel = new_color_pixel;
red = csp->values[RED];
green = csp->values[GREEN];
blue = csp->values[BLUE];
red = csp->values[COLOR_SELECT_RED];
green = csp->values[COLOR_SELECT_GREEN];
blue = csp->values[COLOR_SELECT_BLUE];
}
/* if we haven't yet been realised, there's no need to redraw
@ -1165,9 +1165,9 @@ color_select_slider_update (GtkAdjustment *adjustment,
csp->values[i] = (int) adjustment->value;
if ((i >= HUE) && (i <= VALUE))
if ((i >= COLOR_SELECT_HUE) && (i <= COLOR_SELECT_VALUE))
color_select_update_rgb_values (csp);
else if ((i >= RED) && (i <= BLUE))
else if ((i >= COLOR_SELECT_RED) && (i <= COLOR_SELECT_BLUE))
color_select_update_hsv_values (csp);
color_select_update_sliders (csp, i);
color_select_update_entries (csp, -1);
@ -1238,9 +1238,9 @@ color_select_entry_update (GtkWidget *widget,
if (csp->values[i] == old_values[i])
return;
if ((i >= HUE) && (i <= VALUE))
if ((i >= COLOR_SELECT_HUE) && (i <= COLOR_SELECT_VALUE))
color_select_update_rgb_values (csp);
else if ((i >= RED) && (i <= BLUE))
else if ((i >= COLOR_SELECT_RED) && (i <= COLOR_SELECT_BLUE))
color_select_update_hsv_values (csp);
color_select_update_entries (csp, i);
color_select_update_sliders (csp, -1);
@ -1291,7 +1291,7 @@ color_select_toggle_update (GtkWidget *widget,
gpointer data)
{
ColorSelect *csp;
ColorSelectFillType type = HUE;
ColorSelectFillType type = COLOR_SELECT_HUE;
gint i;
if (!GTK_TOGGLE_BUTTON (widget)->active)
@ -1307,29 +1307,29 @@ color_select_toggle_update (GtkWidget *widget,
switch (type)
{
case HUE:
csp->z_color_fill = HUE;
csp->xy_color_fill = SATURATION_VALUE;
case COLOR_SELECT_HUE:
csp->z_color_fill = COLOR_SELECT_HUE;
csp->xy_color_fill = COLOR_SELECT_SATURATION_VALUE;
break;
case SATURATION:
csp->z_color_fill = SATURATION;
csp->xy_color_fill = HUE_VALUE;
case COLOR_SELECT_SATURATION:
csp->z_color_fill = COLOR_SELECT_SATURATION;
csp->xy_color_fill = COLOR_SELECT_HUE_VALUE;
break;
case VALUE:
csp->z_color_fill = VALUE;
csp->xy_color_fill = HUE_SATURATION;
case COLOR_SELECT_VALUE:
csp->z_color_fill = COLOR_SELECT_VALUE;
csp->xy_color_fill = COLOR_SELECT_HUE_SATURATION;
break;
case RED:
csp->z_color_fill = RED;
csp->xy_color_fill = GREEN_BLUE;
case COLOR_SELECT_RED:
csp->z_color_fill = COLOR_SELECT_RED;
csp->xy_color_fill = COLOR_SELECT_GREEN_BLUE;
break;
case GREEN:
csp->z_color_fill = GREEN;
csp->xy_color_fill = RED_BLUE;
case COLOR_SELECT_GREEN:
csp->z_color_fill = COLOR_SELECT_GREEN;
csp->xy_color_fill = COLOR_SELECT_RED_BLUE;
break;
case BLUE:
csp->z_color_fill = BLUE;
csp->xy_color_fill = RED_GREEN;
case COLOR_SELECT_BLUE:
csp->z_color_fill = COLOR_SELECT_BLUE;
csp->xy_color_fill = COLOR_SELECT_RED_GREEN;
break;
default:
break;
@ -1357,9 +1357,9 @@ color_select_hex_entry_leave (GtkWidget *widget,
hex_color = g_strdup (gtk_entry_get_text (GTK_ENTRY (csp->hex_entry)));
g_snprintf(buffer, sizeof (buffer), "#%.2x%.2x%.2x",
csp->values[RED],
csp->values[GREEN],
csp->values[BLUE]);
csp->values[COLOR_SELECT_RED],
csp->values[COLOR_SELECT_GREEN],
csp->values[COLOR_SELECT_BLUE]);
if ((strlen (hex_color) == 7) &&
(g_strcasecmp (buffer, hex_color) != 0))
@ -1688,7 +1688,7 @@ color_select_update_red_green (ColorSelectFill *csf)
p = csf->buffer;
csf->y += 1;
b = csf->values[BLUE];
b = csf->values[COLOR_SELECT_BLUE];
r = (csf->height - csf->y + 1) * 255 / csf->height;
if (r < 0)
@ -1719,7 +1719,7 @@ color_select_update_red_blue (ColorSelectFill *csf)
p = csf->buffer;
csf->y += 1;
g = csf->values[GREEN];
g = csf->values[COLOR_SELECT_GREEN];
r = (csf->height - csf->y + 1) * 255 / csf->height;
if (r < 0)
@ -1750,7 +1750,7 @@ color_select_update_green_blue (ColorSelectFill *csf)
p = csf->buffer;
csf->y += 1;
r = csf->values[RED];
r = csf->values[COLOR_SELECT_RED];
g = (csf->height - csf->y + 1) * 255 / csf->height;
if (g < 0)
@ -1795,7 +1795,7 @@ color_select_update_hue_saturation (ColorSelectFill *csf)
s = 0;
ds = 1.0 / csf->width;
v = csf->values[VALUE] / 100.0;
v = csf->values[COLOR_SELECT_VALUE] / 100.0;
switch ((int) h)
{
@ -1886,7 +1886,7 @@ color_select_update_hue_value (ColorSelectFill *csf)
v = 0;
dv = 1.0 / csf->width;
s = csf->values[SATURATION] / 100.0;
s = csf->values[COLOR_SELECT_SATURATION] / 100.0;
switch ((int) h)
{
@ -1973,7 +1973,7 @@ color_select_update_saturation_value (ColorSelectFill *csf)
s = 1 - s;
h = (float) csf->values[HUE];
h = (float) csf->values[COLOR_SELECT_HUE];
if (h >= 360)
h -= 360;
h /= 60;
@ -2081,14 +2081,14 @@ color_select_notebook_new (gint r,
csp->callback = color_select_notebook_update_callback;
csp->client_data = glue;
csp->z_color_fill = HUE;
csp->xy_color_fill = SATURATION_VALUE;
csp->z_color_fill = COLOR_SELECT_HUE;
csp->xy_color_fill = COLOR_SELECT_SATURATION_VALUE;
csp->gc = NULL;
csp->wants_updates = TRUE;
csp->values[RED] = csp->orig_values[0] = r;
csp->values[GREEN] = csp->orig_values[1] = g;
csp->values[BLUE] = csp->orig_values[2] = b;
csp->values[COLOR_SELECT_RED] = csp->orig_values[0] = r;
csp->values[COLOR_SELECT_GREEN] = csp->orig_values[1] = g;
csp->values[COLOR_SELECT_BLUE] = csp->orig_values[2] = b;
color_select_update_hsv_values (csp);
color_select_update_pos (csp);

View File

@ -39,7 +39,7 @@
#include "gimprc.h"
#include "gimpui.h"
#include "global_edit.h"
#include "gradient.h"
#include "gradient_select.h"
#include "image_render.h"
#include "info_window.h"
#include "nav_window.h"
@ -1103,10 +1103,10 @@ dialogs_palette_cmd_callback (GtkWidget *widget,
}
void
dialogs_gradient_editor_cmd_callback (GtkWidget *widget,
gpointer client_data)
dialogs_gradient_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
grad_create_gradient_editor ();
gradient_dialog_create ();
}
void

View File

@ -99,7 +99,7 @@ void filters_repeat_cmd_callback (GtkWidget *widget,
void dialogs_brushes_cmd_callback (GtkWidget *, gpointer);
void dialogs_patterns_cmd_callback (GtkWidget *, gpointer);
void dialogs_palette_cmd_callback (GtkWidget *, gpointer);
void dialogs_gradient_editor_cmd_callback (GtkWidget *, gpointer);
void dialogs_gradient_cmd_callback (GtkWidget *, gpointer);
void dialogs_lc_cmd_callback (GtkWidget *, gpointer);
void dialogs_indexed_palette_cmd_callback (GtkWidget *, gpointer);
void dialogs_tools_options_cmd_callback (GtkWidget *, gpointer);

View File

@ -29,6 +29,7 @@
#include "gimpcontext.h"
#include "gimprc.h"
#include "gimpui.h"
#include "gradient.h"
#include "gradient_header.h"
#include "session.h"
#include "tools.h"
@ -47,7 +48,8 @@
#define DEVICE_CONTEXT_MASK GIMP_CONTEXT_TOOL_MASK | \
GIMP_CONTEXT_FOREGROUND_MASK | \
GIMP_CONTEXT_BRUSH_MASK | \
GIMP_CONTEXT_PATTERN_MASK
GIMP_CONTEXT_PATTERN_MASK | \
GIMP_CONTEXT_GRADIENT_MASK
typedef struct _DeviceInfo DeviceInfo;
@ -86,47 +88,57 @@ struct _DeviceInfoDialog
GtkWidget **colors;
GtkWidget **brushes;
GtkWidget **patterns;
GtkWidget **gradients;
GtkWidget **eventboxes;
};
/* local functions */
static void input_dialog_destroy_callback (GtkWidget *, gpointer);
static void input_dialog_able_callback (GtkWidget *w, guint32 deviceid,
gpointer data);
static void input_dialog_destroy_callback (GtkWidget *, gpointer);
static void input_dialog_able_callback (GtkWidget *w, guint32 deviceid,
gpointer data);
static void devices_write_rc_device (DeviceInfo *device_info, FILE *fp);
static void devices_write_rc (void);
static void devices_write_rc_device (DeviceInfo *device_info,
FILE *fp);
static void devices_write_rc (void);
static void device_status_destroy_callback (void);
static void devices_close_callback (GtkWidget *, gpointer);
static void device_status_destroy_callback (void);
static void devices_close_callback (GtkWidget *, gpointer);
static void device_status_update (guint32 deviceid);
static void device_status_update_current (void);
static void device_status_update (guint32 deviceid);
static void device_status_update_current (void);
static void device_status_drag_color (GtkWidget *,
guchar *, guchar *, guchar *,
gpointer);
static void device_status_drop_color (GtkWidget *,
guchar, guchar, guchar,
gpointer);
static void device_status_drop_brush (GtkWidget *,
GdkDragContext *,
gint, gint, guint, gpointer);
static void device_status_drop_pattern (GtkWidget *,
GdkDragContext *,
gint, gint, guint, gpointer);
static ToolType device_status_drag_tool (GtkWidget *,
gpointer);
static void device_status_drop_tool (GtkWidget *,
ToolType,
gpointer);
static void device_status_drag_color (GtkWidget *,
guchar *, guchar *, guchar *,
gpointer);
static void device_status_drop_color (GtkWidget *,
guchar, guchar, guchar,
gpointer);
static void device_status_drop_brush (GtkWidget *,
GimpBrush *,
gpointer);
static void device_status_drop_pattern (GtkWidget *,
GPattern *,
gpointer);
static void device_status_drop_gradient (GtkWidget *,
gradient_t *,
gpointer);
static void device_status_color_changed (GimpContext *context,
gint r,
gint g,
gint b,
gpointer data);
static void device_status_data_changed (GimpContext *context,
gpointer dummy,
gpointer data);
static void device_status_color_changed (GimpContext *context,
gint r,
gint g,
gint b,
gpointer data);
static void device_status_data_changed (GimpContext *context,
gpointer dummy,
gpointer data);
static void device_status_context_connect (GimpContext *context,
guint32 deviceid);
static void device_status_context_connect (GimpContext *context,
guint32 deviceid);
/* global data */
gint current_device = GDK_CORE_POINTER;
@ -139,6 +151,13 @@ static DeviceInfoDialog *deviceD = NULL;
static gboolean suppress_update = FALSE;
/* dnd stuff */
static GtkTargetEntry tool_target_table[] =
{
GIMP_TARGET_TOOL
};
static guint n_tool_targets = (sizeof (tool_target_table) /
sizeof (tool_target_table[0]));
static GtkTargetEntry color_area_target_table[] =
{
GIMP_TARGET_COLOR
@ -146,20 +165,6 @@ static GtkTargetEntry color_area_target_table[] =
static guint n_color_area_targets = (sizeof (color_area_target_table) /
sizeof (color_area_target_table[0]));
static GtkTargetEntry brush_area_target_table[] =
{
GIMP_TARGET_BRUSH
};
static guint n_brush_area_targets = (sizeof (brush_area_target_table) /
sizeof (brush_area_target_table[0]));
static GtkTargetEntry pattern_area_target_table[] =
{
GIMP_TARGET_PATTERN
};
static guint n_pattern_area_targets = (sizeof (pattern_area_target_table) /
sizeof (pattern_area_target_table[0]));
/* utility functions for the device lists */
static GdkDeviceInfo *
@ -487,19 +492,9 @@ devices_rc_update (gchar *name,
if (values & DEVICE_GRADIENT)
{
gradient_t *gradient;
GSList *list;
for (list = gradients_list; list; list = g_slist_next (list))
{
gradient = (gradient_t *) list->data;
if (! strcmp (gradient->name, gradient_name))
{
gimp_context_set_gradient (device_info->context, gradient);
break;
}
}
gimp_context_set_gradient (device_info->context,
gradient_list_get_gradient (gradients_list,
gradient_name));
}
}
@ -686,6 +681,12 @@ devices_write_rc_device (DeviceInfo *device_info,
gimp_context_get_pattern (device_info->context)->name);
}
if (gimp_context_get_gradient (device_info->context))
{
fprintf (fp, "\n (gradient \"%s\")",
gimp_context_get_gradient (device_info->context)->name);
}
fprintf(fp,")\n");
}
@ -750,7 +751,7 @@ device_status_create (void)
}
/* devices table */
deviceD->table = gtk_table_new (deviceD->num_devices, 5, FALSE);
deviceD->table = gtk_table_new (deviceD->num_devices, 6, FALSE);
gtk_container_set_border_width (GTK_CONTAINER (deviceD->table), 3);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (deviceD->shell)->vbox),
deviceD->table);
@ -763,6 +764,7 @@ device_status_create (void)
deviceD->colors = g_new (GtkWidget *, deviceD->num_devices);
deviceD->brushes = g_new (GtkWidget *, deviceD->num_devices);
deviceD->patterns = g_new (GtkWidget *, deviceD->num_devices);
deviceD->gradients = g_new (GtkWidget *, deviceD->num_devices);
deviceD->eventboxes = g_new (GtkWidget *, deviceD->num_devices);
for (list = device_info_list, i = 0; list; list = g_list_next (list), i++)
@ -792,14 +794,27 @@ device_status_create (void)
/* the tool */
deviceD->eventboxes[i] = gtk_event_box_new();
deviceD->tools[i] =
gtk_pixmap_new (create_tool_pixmap (deviceD->table, RECT_SELECT),
NULL);
gtk_drag_source_set (deviceD->eventboxes[i],
GDK_BUTTON1_MASK,
tool_target_table, n_tool_targets,
GDK_ACTION_COPY);
gimp_dnd_tool_source_set (deviceD->eventboxes[i],
device_status_drag_tool,
GUINT_TO_POINTER (device_info->device));
gtk_drag_dest_set (deviceD->eventboxes[i],
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
tool_target_table, n_tool_targets,
GDK_ACTION_COPY);
gimp_dnd_tool_dest_set (deviceD->eventboxes[i],
device_status_drop_tool,
GUINT_TO_POINTER (device_info->device));
gtk_container_add (GTK_CONTAINER (deviceD->eventboxes[i]),
deviceD->tools[i]);
gtk_table_attach (GTK_TABLE (deviceD->table), deviceD->eventboxes[i],
1, 2, i, i+1,
0, 0, 2, 2);
@ -831,40 +846,40 @@ device_status_create (void)
/* the brush */
deviceD->brushes[i] = gimp_context_preview_new (GCP_BRUSH,
CELL_SIZE, CELL_SIZE,
FALSE, TRUE, TRUE);
gtk_drag_dest_set (deviceD->brushes[i],
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
brush_area_target_table, n_brush_area_targets,
GDK_ACTION_COPY);
gtk_signal_connect (GTK_OBJECT (deviceD->brushes[i]), "drag_drop",
GTK_SIGNAL_FUNC (device_status_drop_brush),
GUINT_TO_POINTER (device_info->device));
deviceD->brushes[i] =
gimp_context_preview_new (GCP_BRUSH,
CELL_SIZE, CELL_SIZE,
FALSE, TRUE, TRUE,
GTK_SIGNAL_FUNC (device_status_drop_brush),
GUINT_TO_POINTER (device_info->device));
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->brushes[i],
3, 4, i, i+1,
0, 0, 2, 2);
/* the pattern */
deviceD->patterns[i] = gimp_context_preview_new (GCP_PATTERN,
CELL_SIZE, CELL_SIZE,
FALSE, TRUE, TRUE);
gtk_drag_dest_set (deviceD->patterns[i],
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
pattern_area_target_table, n_pattern_area_targets,
GDK_ACTION_COPY);
gtk_signal_connect (GTK_OBJECT (deviceD->patterns[i]), "drag_drop",
GTK_SIGNAL_FUNC (device_status_drop_pattern),
GUINT_TO_POINTER (device_info->device));
deviceD->patterns[i] =
gimp_context_preview_new (GCP_PATTERN,
CELL_SIZE, CELL_SIZE,
FALSE, TRUE, TRUE,
GTK_SIGNAL_FUNC (device_status_drop_pattern),
GUINT_TO_POINTER (device_info->device));
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->patterns[i],
4, 5, i, i+1,
0, 0, 2, 2);
/* the gradient */
deviceD->gradients[i] =
gimp_context_preview_new (GCP_GRADIENT,
CELL_SIZE * 2, CELL_SIZE,
FALSE, TRUE, TRUE,
GTK_SIGNAL_FUNC (device_status_drop_gradient),
GUINT_TO_POINTER (device_info->device));
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->gradients[i],
5, 6, i, i+1,
0, 0, 2, 2);
device_status_update (device_info->device);
}
@ -896,6 +911,7 @@ device_status_destroy_callback (void)
g_free (deviceD->colors);
g_free (deviceD->brushes);
g_free (deviceD->patterns);
g_free (deviceD->gradients);
g_free (deviceD);
deviceD = NULL;
@ -977,6 +993,7 @@ device_status_update (guint32 deviceid)
gtk_widget_hide (deviceD->colors[i]);
gtk_widget_hide (deviceD->brushes[i]);
gtk_widget_hide (deviceD->patterns[i]);
gtk_widget_hide (deviceD->gradients[i]);
}
else
{
@ -1033,11 +1050,52 @@ device_status_update (guint32 deviceid)
gimp_context_get_pattern (device_info->context));
gtk_widget_show (deviceD->patterns[i]);
}
if (gimp_context_get_gradient (device_info->context))
{
gimp_context_preview_update
(GIMP_CONTEXT_PREVIEW (deviceD->gradients[i]),
gimp_context_get_gradient (device_info->context));
gtk_widget_show (deviceD->gradients[i]);
}
}
}
/* dnd stuff */
static ToolType
device_status_drag_tool (GtkWidget *widget,
gpointer data)
{
DeviceInfo *device_info;
device_info = device_info_get_by_id (GPOINTER_TO_UINT (data));
if (device_info)
{
return gimp_context_get_tool (device_info->context);
}
else
{
return RECT_SELECT;
}
}
static void
device_status_drop_tool (GtkWidget *widget,
ToolType tool,
gpointer data)
{
DeviceInfo *device_info;
device_info = device_info_get_by_id (GPOINTER_TO_UINT (data));
if (device_info && device_info->is_present)
{
gimp_context_set_tool (device_info->context, tool);
}
}
static void
device_status_drag_color (GtkWidget *widget,
guchar *r,
@ -1077,24 +1135,11 @@ device_status_drop_color (GtkWidget *widget,
}
static void
device_status_drop_brush (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time,
gpointer data)
device_status_drop_brush (GtkWidget *widget,
GimpBrush *brush,
gpointer data)
{
DeviceInfo *device_info;
GtkWidget *src;
GimpBrush *brush = NULL;
src = gtk_drag_get_source_widget (context);
if (!src)
return;
brush = (GimpBrush *) gtk_object_get_data (GTK_OBJECT (src), "gimp_brush");
if (!brush)
return;
device_info = device_info_get_by_id (GPOINTER_TO_UINT (data));
@ -1105,24 +1150,11 @@ device_status_drop_brush (GtkWidget *widget,
}
static void
device_status_drop_pattern (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time,
gpointer data)
device_status_drop_pattern (GtkWidget *widget,
GPattern *pattern,
gpointer data)
{
DeviceInfo *device_info;
GtkWidget *src;
GPattern *pattern = NULL;
src = gtk_drag_get_source_widget (context);
if (!src)
return;
pattern = (GPattern *) gtk_object_get_data (GTK_OBJECT (src), "gimp_pattern");
if (!pattern)
return;
device_info = device_info_get_by_id (GPOINTER_TO_UINT (data));
@ -1132,6 +1164,21 @@ device_status_drop_pattern (GtkWidget *widget,
}
}
static void
device_status_drop_gradient (GtkWidget *widget,
gradient_t *gradient,
gpointer data)
{
DeviceInfo *device_info;
device_info = device_info_get_by_id (GPOINTER_TO_UINT (data));
if (device_info && device_info->is_present)
{
gimp_context_set_gradient (device_info->context, gradient);
}
}
/* context callbacks */
static void
@ -1176,4 +1223,7 @@ device_status_context_connect (GimpContext *context,
gtk_signal_connect (GTK_OBJECT (context), "pattern_changed",
GTK_SIGNAL_FUNC (device_status_data_changed),
(gpointer) deviceid);
gtk_signal_connect (GTK_OBJECT (context), "gradient_changed",
GTK_SIGNAL_FUNC (device_status_data_changed),
(gpointer) deviceid);
}

File diff suppressed because it is too large Load Diff

View File

@ -23,20 +23,25 @@
typedef struct _gradient_t gradient_t;
void gradients_init (gint no_data);
void gradients_free (void);
/* global variables */
extern GSList * gradients_list;
extern gint num_gradients;
gradient_t * gradients_get_standard_gradient (void);
void gradients_init (gint no_data);
void gradients_free (void);
void gradient_get_color_at (gradient_t *gradient,
gdouble pos,
gdouble *r,
gdouble *g,
gdouble *b,
gdouble *a);
gradient_t * gradients_get_standard_gradient (void);
void grad_create_gradient_editor (void);
void grad_free_gradient_editor (void);
void gradients_check_dialogs (void);
gradient_t * gradient_list_get_gradient (GSList *list,
gchar *name);
gint gradient_list_get_gradient_index (GSList *list,
gradient_t *gradient);
void gradient_get_color_at (gradient_t *gradient,
gdouble pos,
gdouble *r,
gdouble *g,
gdouble *b,
gdouble *a);
#endif /* __GRADIENT_H__ */

View File

@ -31,408 +31,108 @@
* 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 "config.h"
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "appenv.h"
#include "colormaps.h"
#include "cursorutil.h"
#include "datafiles.h"
#include "dialog_handler.h"
#include "errors.h"
#include "gimpcontext.h"
#include "gimprc.h"
#include "gimpdnd.h"
#include "gimpui.h"
#include "gradient.h"
#include "gradient_header.h"
#include "interface.h"
#include "gradientP.h"
#include "gradient_select.h"
#include "session.h"
#include "libgimp/gimpintl.h"
GSList *grad_active_dialogs = NULL; /* List of active dialogs */
GradSelectP gradient_select_dialog = NULL; /* The main selection dialog */
static void gradient_change_callbacks (GradientSelect *gsp,
gboolean closing);
static void grad_select_close_callback (GtkWidget *, gpointer);
static void grad_select_edit_callback (GtkWidget *, gpointer);
static void grad_change_callbacks (GradSelectP gsp, gint closing);
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 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]));
/* list of active dialogs */
GSList *gradient_active_dialogs = NULL;
/* the main gradient selection dialog */
GradientSelect *gradient_select_dialog = NULL;
void
grad_free_gradient_editor (void)
gradient_dialog_create (void)
{
if (gradient_select_dialog)
session_get_window_info (gradient_select_dialog->shell,
&gradient_select_session_info);
}
void
grad_sel_rename_all (gint n,
gradient_t *grad)
{
GSList *list;
GradSelectP gsp;
for (list = grad_active_dialogs; list; list = g_slist_next (list))
if (! gradient_select_dialog)
{
gsp = (GradSelectP) list->data;
gtk_clist_set_text (GTK_CLIST (gsp->clist), n, 1, grad->name);
}
if (gradient_select_dialog)
{
gtk_clist_set_text (GTK_CLIST (gradient_select_dialog->clist),
n, 1, grad->name);
}
}
void
grad_sel_new_all (gint pos,
gradient_t *grad)
{
GSList *list;
GradSelectP gsp;
for (list = grad_active_dialogs; list; list = g_slist_next (list))
{
gsp = (GradSelectP) list->data;
gtk_clist_freeze (GTK_CLIST (gsp->clist));
ed_insert_in_gradients_listbox (gsp->gc, gsp->clist, grad, pos, 1);
gtk_clist_thaw (GTK_CLIST (gsp->clist));
}
if (gradient_select_dialog)
{
gtk_clist_freeze (GTK_CLIST (gradient_select_dialog->clist));
ed_insert_in_gradients_listbox (gradient_select_dialog->gc,
gradient_select_dialog->clist,
grad, pos, 1);
gtk_clist_thaw (GTK_CLIST (gradient_select_dialog->clist));
}
}
void
grad_sel_copy_all (gint pos,
gradient_t *grad)
{
GSList *list;
GradSelectP gsp;
for (list = grad_active_dialogs; list; list = g_slist_next (list))
{
gsp = (GradSelectP) list->data;
gtk_clist_freeze (GTK_CLIST (gsp->clist));
ed_insert_in_gradients_listbox (gsp->gc, gsp->clist, grad, pos, 1);
gtk_clist_thaw (GTK_CLIST (gsp->clist));
}
if (gradient_select_dialog)
{
gtk_clist_freeze (GTK_CLIST (gradient_select_dialog->clist));
ed_insert_in_gradients_listbox (gradient_select_dialog->gc,
gradient_select_dialog->clist,
grad, pos, 1);
gtk_clist_thaw (GTK_CLIST (gradient_select_dialog->clist));
}
}
void
grad_sel_delete_all (gint n)
{
GSList *list;
GradSelectP gsp;
for (list = grad_active_dialogs; list; list = g_slist_next (list))
{
gsp = (GradSelectP) list->data;
gtk_clist_remove (GTK_CLIST (gsp->clist), n);
}
if (gradient_select_dialog)
{
gtk_clist_remove (GTK_CLIST (gradient_select_dialog->clist), n);
}
}
void
grad_sel_free_all ()
{
GSList *list;
GradSelectP gsp;
for (list = grad_active_dialogs; list; list = g_slist_next (list))
{
gsp = (GradSelectP) list->data;
gtk_clist_freeze (GTK_CLIST (gsp->clist));
gtk_clist_clear (GTK_CLIST (gsp->clist));
gtk_clist_thaw (GTK_CLIST (gsp->clist));
}
if (gradient_select_dialog)
{
gtk_clist_freeze (GTK_CLIST (gradient_select_dialog->clist));
gtk_clist_clear (GTK_CLIST (gradient_select_dialog->clist));
gtk_clist_thaw (GTK_CLIST (gradient_select_dialog->clist));
}
}
void
grad_sel_refill_all ()
{
GSList *list;
GradSelectP gsp;
int select_pos = -1;
for (list = grad_active_dialogs; list; list = g_slist_next (list))
{
gsp = (GradSelectP) list->data;
gsp->grad = curr_gradient;
select_pos = ed_set_list_of_gradients (gsp->gc,
gsp->clist,
curr_gradient);
if (select_pos != -1)
gtk_clist_moveto (GTK_CLIST (gsp->clist), select_pos, 0, 0.0, 0.0);
}
if (gradient_select_dialog)
{
gradient_select_dialog->grad = curr_gradient;
select_pos = ed_set_list_of_gradients (gradient_select_dialog->gc,
gradient_select_dialog->clist,
curr_gradient);
if (select_pos != -1)
gtk_clist_moveto (GTK_CLIST (gradient_select_dialog->clist),
select_pos, 0, 0.0, 0.0);
}
}
void
sel_update_dialogs (gint row,
gradient_t *grad)
{
/* Go around each updating the names and hopefully the previews */
GradSelectP gsp;
GSList *list;
for (list = grad_active_dialogs; list; list = g_slist_next (list))
{
gsp = (GradSelectP) list->data;
gtk_clist_set_text (GTK_CLIST (gsp->clist), row, 1, grad->name);
/* Are we updating one that is selected in a popup dialog? */
if (grad == gsp->grad)
grad_change_callbacks (gsp, 0);
}
if (gradient_select_dialog)
gtk_clist_set_text (GTK_CLIST (gradient_select_dialog->clist),
row, 1, grad->name);
gimp_context_update_gradients (grad);
}
static void
sel_list_item_update (GtkWidget *widget,
gint row,
gint column,
GdkEventButton *event,
gpointer data)
{
GradSelectP gsp = (GradSelectP) data;
GSList* tmp = g_slist_nth (gradients_list, row);
gsp->grad = (gradient_t *) (tmp->data);
/* If main one then make it the current selection */
if (gsp == gradient_select_dialog)
{
grad_set_grad_to_name (gsp->grad->name);
gimp_context_set_gradient (gimp_context_get_user (), gsp->grad);
gradient_select_dialog = gradient_select_new (NULL, NULL);
}
else
{
grad_change_callbacks (gsp, 0);
}
}
static void
grad_select_edit_callback (GtkWidget *widget,
gpointer data)
{
GradSelectP gsp;
gsp = (GradSelectP) data;
grad_create_gradient_editor_init (TRUE);
/* Set the current gradient in this dialog to the "real current" */
if (gsp && gsp->grad)
grad_set_grad_to_name (gsp->grad->name);
}
void
grad_select_free (GradSelectP gsp)
{
if (gsp)
{
if (gsp->callback_name)
g_free (gsp->callback_name);
/* remove from active list */
grad_active_dialogs = g_slist_remove (grad_active_dialogs, gsp);
g_free (gsp);
}
}
/* Close active dialogs that no longer have PDB registered for them */
void
gradients_check_dialogs (void)
{
GSList *list;
GradSelectP gsp;
gchar * name;
ProcRecord *prec = NULL;
for (list = grad_active_dialogs; list;)
{
gsp = (GradSelectP) list->data;
list = g_slist_next (list);
name = gsp->callback_name;
if (name)
{
prec = procedural_db_lookup (name);
if (!prec)
{
grad_active_dialogs = g_slist_remove (grad_active_dialogs, gsp);
/* Can alter grad_active_dialogs list*/
grad_select_close_callback (NULL, gsp);
}
}
}
}
static void
grad_change_callbacks (GradSelectP gsp,
gint closing)
{
gchar * name;
ProcRecord *prec = NULL;
gradient_t *grad;
int nreturn_vals;
static int busy = 0;
/* Any procs registered to callback? */
Argument *return_vals;
if (!gsp || !gsp->callback_name || busy != 0)
return;
busy = 1;
name = gsp->callback_name;
grad = gsp->grad;
/* If its still registered run it */
prec = procedural_db_lookup (name);
if (prec && grad)
{
gdouble *values, *pv;
double pos, delta;
double r, g, b, a;
int i = gsp->sample_size;
pos = 0.0;
delta = 1.0 / (i - 1);
values = g_new (gdouble, 4 * i);
pv = values;
while (i--)
{
gradient_get_color_at (grad, pos, &r, &g, &b, &a);
*pv++ = r;
*pv++ = g;
*pv++ = b;
*pv++ = a;
pos += delta;
}
return_vals = procedural_db_run_proc (name,
&nreturn_vals,
PDB_STRING, grad->name,
PDB_INT32, gsp->sample_size*4,
PDB_FLOATARRAY, values,
PDB_INT32, closing,
PDB_END);
if (!return_vals || return_vals[0].value.pdb_int != PDB_SUCCESS)
g_message ("failed to run gradient callback function");
if (!GTK_WIDGET_VISIBLE (gradient_select_dialog->shell))
gtk_widget_show (gradient_select_dialog->shell);
else
procedural_db_destroy_args (return_vals, nreturn_vals);
gdk_window_raise (gradient_select_dialog->shell->window);
}
busy = 0;
}
static void
grad_select_close_callback (GtkWidget *widget,
gpointer data)
void
gradient_dialog_free (void)
{
GradSelectP gsp;
gsp = (GradSelectP) 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)
if (gradient_select_dialog)
{
grad_change_callbacks (gsp, 1);
gtk_widget_destroy (gsp->shell);
grad_select_free (gsp);
session_get_window_info (gradient_select_dialog->shell,
&gradient_select_session_info);
gradient_select_free (gradient_select_dialog);
gradient_select_dialog = NULL;
}
gradient_editor_free ();
}
GradSelectP
gsel_new_selection (gchar *title,
gchar *initial_gradient)
/* If title == NULL then it is the main gradient select dialog */
GradientSelect *
gradient_select_new (gchar *title,
gchar *initial_gradient)
{
GradSelectP gsp;
gradient_t *grad = NULL;
GSList *list;
GradientSelect *gsp;
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *scrolled_win;
GdkColormap *colormap;
gint select_pos;
/* Load them if they are not already loaded */
if (g_editor == NULL)
{
grad_create_gradient_editor_init(FALSE);
}
gradient_t *active = NULL;
gsp = g_new (_GradSelect, 1);
static gboolean first_call = TRUE;
gsp = g_new (GradientSelect, 1);
gsp->callback_name = NULL;
/* The shell and main vbox */
/* The shell */
gsp->shell = gimp_dialog_new (title ? title : _("Gradient Selection"),
"gradient_selection",
gimp_standard_help_func,
@ -440,18 +140,55 @@ gsel_new_selection (gchar *title,
GTK_WIN_POS_NONE,
FALSE, TRUE, FALSE,
_("Edit"), grad_select_edit_callback,
_("Edit"), gradient_select_edit_callback,
gsp, NULL, FALSE, FALSE,
_("Close"), grad_select_close_callback,
_("Close"), gradient_select_close_callback,
gsp, NULL, TRUE, TRUE,
NULL);
vbox = gtk_vbox_new (FALSE, 1);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 1);
if (title)
{
gsp->context = gimp_context_new (title, NULL);
}
else
{
gsp->context = gimp_context_get_user ();
session_set_window_geometry (gsp->shell, &gradient_select_session_info,
TRUE);
dialog_register (gsp->shell);
}
if (no_data && first_call)
gradients_init (FALSE);
first_call = FALSE;
if (title && initial_gradient && strlen (initial_gradient))
{
active = gradient_list_get_gradient (gradients_list, initial_gradient);
}
else
{
active = gimp_context_get_gradient (gimp_context_get_user ());
}
if (!active)
{
active = gimp_context_get_gradient (gimp_context_get_standard ());
}
if (title)
{
gimp_context_set_gradient (gsp->context, active);
}
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);
/* clist preview of gradients */
/* clist preview of gradients */
scrolled_win = gtk_scrolled_window_new (NULL, NULL);
gsp->clist = gtk_clist_new (2);
@ -463,13 +200,15 @@ gsel_new_selection (gchar *title,
gtk_clist_set_column_title (GTK_CLIST (gsp->clist), 0, _("Gradient"));
gtk_clist_set_column_title (GTK_CLIST (gsp->clist), 1, _("Name"));
gtk_clist_column_titles_show (GTK_CLIST (gsp->clist));
hbox = gtk_hbox_new (FALSE, 8);
gtk_container_set_border_width (GTK_CONTAINER (hbox), 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
gtk_widget_show (hbox);
gtk_box_pack_start (GTK_BOX (hbox), scrolled_win, TRUE, TRUE, 0);
/* dnd stuff */
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);
gtk_container_add (GTK_CONTAINER (vbox), scrolled_win);
gtk_container_add (GTK_CONTAINER (scrolled_win), gsp->clist);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
GTK_POLICY_AUTOMATIC,
@ -483,68 +222,350 @@ gsel_new_selection (gchar *title,
gdk_color_parse ("black", &gsp->black);
gdk_color_alloc (colormap, &gsp->black);
gtk_signal_connect (GTK_OBJECT (gsp->clist), "select_row",
GTK_SIGNAL_FUNC (sel_list_item_update),
(gpointer) gsp);
if (initial_gradient && strlen (initial_gradient))
{
for (list = gradients_list; list; list = g_slist_next (list))
{
grad = (gradient_t *) list->data;
if (strcmp (grad->name, initial_gradient) == 0)
{
/* We found it! */
break;
}
}
}
if (grad == NULL)
grad = curr_gradient;
gsp->grad = grad;
gtk_widget_realize (gsp->shell);
gsp->gc = gdk_gc_new (gsp->shell->window);
select_pos = ed_set_list_of_gradients (gsp->gc,
gsp->clist,
grad);
select_pos = gradient_clist_init (gsp->shell, gsp->gc, gsp->clist, active);
/* Now show the dialog */
gtk_widget_show (vbox);
gtk_widget_show (gsp->shell);
if (select_pos != -1)
gtk_clist_moveto (GTK_CLIST (gsp->clist), select_pos, 0, 0.0, 0.0);
gtk_signal_connect (GTK_OBJECT (gsp->clist), "select_row",
GTK_SIGNAL_FUNC (gradient_select_list_item_update),
(gpointer) gsp);
gtk_signal_connect (GTK_OBJECT (gsp->context), "gradient_changed",
GTK_SIGNAL_FUNC (gradient_select_gradient_changed),
gsp);
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
grad_create_gradient_editor (void)
gradient_select_free (GradientSelect *gsp)
{
if (gradient_select_dialog == NULL)
{
gradient_select_dialog = gsel_new_selection (_("Gradients"), NULL);
if (!gsp)
return;
/* register this one only */
dialog_register (gradient_select_dialog->shell);
/* remove from active list */
gradient_active_dialogs = g_slist_remove (gradient_active_dialogs, gsp);
session_set_window_geometry (gradient_select_dialog->shell,
&gradient_select_session_info, TRUE);
gtk_signal_disconnect_by_data (GTK_OBJECT (gsp->context), gsp);
if (gsp->callback_name)
{
g_free (gsp->callback_name);
gtk_object_unref (GTK_OBJECT (gsp->context));
}
else
g_free (gsp);
}
/* Call this dialog's PDB callback */
static void
gradient_change_callbacks (GradientSelect *gsp,
gboolean closing)
{
gchar * name;
ProcRecord *prec = NULL;
gradient_t *gradient;
gint nreturn_vals;
static gboolean busy = FALSE;
/* Any procs registered to callback? */
Argument *return_vals;
if (!gsp || !gsp->callback_name || busy != 0)
return;
busy = TRUE;
name = gsp->callback_name;
gradient = gimp_context_get_gradient (gsp->context);
/* If its still registered run it */
prec = procedural_db_lookup (name);
if (prec && gradient)
{
if (!GTK_WIDGET_VISIBLE (gradient_select_dialog->shell))
gdouble *values, *pv;
double pos, delta;
double r, g, b, a;
int i = gsp->sample_size;
pos = 0.0;
delta = 1.0 / (i - 1);
values = g_new (gdouble, 4 * i);
pv = values;
while (i--)
{
gtk_widget_show (gradient_select_dialog->shell);
gradient_get_color_at (gradient, pos, &r, &g, &b, &a);
*pv++ = r;
*pv++ = g;
*pv++ = b;
*pv++ = a;
pos += delta;
}
return_vals = procedural_db_run_proc (name,
&nreturn_vals,
PDB_STRING, gradient->name,
PDB_INT32, gsp->sample_size * 4,
PDB_FLOATARRAY, values,
PDB_INT32, (gint) closing,
PDB_END);
if (!return_vals || return_vals[0].value.pdb_int != PDB_SUCCESS)
g_message ("failed to run gradient callback function");
else
procedural_db_destroy_args (return_vals, nreturn_vals);
}
busy = FALSE;
}
/* Close active dialogs that no longer have PDB registered for them */
void
gradients_check_dialogs (void)
{
GradientSelect *gsp;
GSList *list;
gchar *name;
ProcRecord *prec = NULL;
list = gradient_active_dialogs;
while (list)
{
gsp = (GradientSelect *) list->data;
list = g_slist_next (list);
name = gsp->callback_name;
if (name)
{
gdk_window_raise (gradient_select_dialog->shell->window);
prec = procedural_db_lookup (name);
if (!prec)
{
/* Can alter gradient_active_dialogs list */
gradient_select_close_callback (NULL, gsp);
}
}
}
}
void
gradient_select_rename_all (gint n,
gradient_t *gradient)
{
GradientSelect *gsp;
GSList *list;
for (list = gradient_active_dialogs; list; list = g_slist_next (list))
{
gsp = (GradientSelect *) list->data;
gtk_clist_set_text (GTK_CLIST (gsp->clist), n, 1, gradient->name);
}
}
void
gradient_select_insert_all (gint pos,
gradient_t *gradient)
{
GradientSelect *gsp;
GSList *list;
for (list = gradient_active_dialogs; list; list = g_slist_next (list))
{
gsp = (GradientSelect *) list->data;
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));
}
}
void
gradient_select_delete_all (gint n)
{
GradientSelect *gsp;
GSList *list;
for (list = gradient_active_dialogs; list; list = g_slist_next (list))
{
gsp = (GradientSelect *) list->data;
gtk_clist_remove (GTK_CLIST (gsp->clist), n);
}
}
void
gradient_select_free_all (void)
{
GradientSelect *gsp;
GSList *list;
for (list = gradient_active_dialogs; list; list = g_slist_next (list))
{
gsp = (GradientSelect *) list->data;
gtk_clist_freeze (GTK_CLIST (gsp->clist));
gtk_clist_clear (GTK_CLIST (gsp->clist));
gtk_clist_thaw (GTK_CLIST (gsp->clist));
}
}
void
gradient_select_refill_all (void)
{
GradientSelect *gsp;
GSList *list;
gint index = -1;
for (list = gradient_active_dialogs; list; list = g_slist_next (list))
{
gsp = (GradientSelect *) list->data;
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;
for (list = gradient_active_dialogs; list; list = g_slist_next (list))
{
gsp = (GradientSelect *) list->data;
gtk_clist_set_text (GTK_CLIST (gsp->clist), row, 1, gradient->name);
/* Are we updating one that is selected in a popup dialog? */
if ((gradient == gimp_context_get_gradient (gsp->context)) &&
(gsp != gradient_select_dialog))
gradient_change_callbacks (gsp, FALSE);
}
}
/*
* Local functions
*/
static void
gradient_select_drop_gradient (GtkWidget *widget,
gradient_t *gradient,
gpointer data)
{
GradientSelect *gsp;
gsp = (GradientSelect *) data;
gimp_context_set_gradient (gsp->context, gradient);
}
static void
gradient_select_gradient_changed (GimpContext *context,
gradient_t *gradient,
GradientSelect *gsp)
{
if (gradient)
gradient_select_select (gsp, gradient);
}
static void
gradient_select_select (GradientSelect *gsp,
gradient_t *gradient)
{
gint index;
index = gradient_list_get_gradient_index (gradients_list, gradient);
if (index != -1)
{
gtk_signal_handler_block_by_data (GTK_OBJECT (gsp->clist), gsp);
gtk_clist_select_row (GTK_CLIST (gsp->clist), index, -1);
gtk_clist_moveto (GTK_CLIST (gsp->clist), index, 0, 0.5, 0.0);
gtk_signal_handler_unblock_by_data (GTK_OBJECT (gsp->clist), gsp);
}
}
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);
if (gsp != gradient_select_dialog)
{
gradient_change_callbacks (gsp, FALSE);
}
}
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);
}
}

71
app/gui/gradient-select.h Normal file
View File

@ -0,0 +1,71 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* 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 __GRADIENT_SELECT_H__
#define __GRADIENT_SELECT_H__
#include <gtk/gtk.h>
#include "gimpcontext.h"
#define GRADIENT_SAMPLE_SIZE 40
typedef struct _GradientSelect GradientSelect;
struct _GradientSelect
{
GtkWidget *shell;
GtkWidget *frame;
GtkWidget *preview;
GtkWidget *clist;
GimpContext *context;
gchar *callback_name;
gint sample_size;
GdkColor black;
GdkGC *gc;
};
/* list of active dialogs */
extern GSList *gradient_active_dialogs;
/* the main gradient selection dialog */
extern GradientSelect *gradient_select_dialog;
GradientSelect * gradient_select_new (gchar *title,
gchar *initial_gradient);
void gradient_select_free (GradientSelect *gsp);
void gradient_select_rename_all (gint n,
gradient_t *gradient);
void gradient_select_insert_all (gint pos,
gradient_t *gradient);
void gradient_select_delete_all (gint n);
void gradient_select_free_all (void);
void gradient_select_refill_all (void);
void gradient_select_update_all (gint row,
gradient_t *gradient);
void gradients_check_dialogs (void);
/* the main gradient selection */
void gradient_dialog_create (void);
void gradient_dialog_free (void);
#endif /* __GRADIENT_SELECT_H__ */

View File

@ -39,7 +39,7 @@
#include "gimprc.h"
#include "gimpui.h"
#include "global_edit.h"
#include "gradient.h"
#include "gradient_select.h"
#include "image_render.h"
#include "info_window.h"
#include "nav_window.h"
@ -1103,10 +1103,10 @@ dialogs_palette_cmd_callback (GtkWidget *widget,
}
void
dialogs_gradient_editor_cmd_callback (GtkWidget *widget,
gpointer client_data)
dialogs_gradient_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
grad_create_gradient_editor ();
gradient_dialog_create ();
}
void

View File

@ -99,7 +99,7 @@ void filters_repeat_cmd_callback (GtkWidget *widget,
void dialogs_brushes_cmd_callback (GtkWidget *, gpointer);
void dialogs_patterns_cmd_callback (GtkWidget *, gpointer);
void dialogs_palette_cmd_callback (GtkWidget *, gpointer);
void dialogs_gradient_editor_cmd_callback (GtkWidget *, gpointer);
void dialogs_gradient_cmd_callback (GtkWidget *, gpointer);
void dialogs_lc_cmd_callback (GtkWidget *, gpointer);
void dialogs_indexed_palette_cmd_callback (GtkWidget *, gpointer);
void dialogs_tools_options_cmd_callback (GtkWidget *, gpointer);

View File

@ -22,47 +22,23 @@
#include "brush_select.h"
#include "gimpcontextpreview.h"
#include "gimpdnd.h"
#include "gradient.h"
#include "gradient_header.h"
#include "gradient_select.h"
#include "indicator_area.h"
#include "interface.h" /* for tool_tips */
#include "pattern_select.h"
#include "libgimp/gimpintl.h"
#define CELL_SIZE 23 /* The size of the previews */
#define GRAD_CELL_WIDTH 48 /* The width of the gradient preview */
#define CELL_SIZE 23 /* The size of the previews */
#define GRAD_CELL_WIDTH 48 /* The width of the gradient preview */
#define GRAD_CELL_HEIGHT 12 /* The height of the gradient preview */
#define CELL_PADDING 2 /* How much between brush and pattern cells */
#define CELL_PADDING 2 /* How much between brush and pattern cells */
/* Static variables */
static GtkWidget *brush_preview;
static GtkWidget *pattern_preview;
static GtkWidget *gradient_preview;
/* dnd stuff */
static GtkTargetEntry brush_area_target_table[] =
{
GIMP_TARGET_BRUSH
};
static guint n_brush_area_targets = (sizeof (brush_area_target_table) /
sizeof (brush_area_target_table[0]));
static GtkTargetEntry pattern_area_target_table[] =
{
GIMP_TARGET_PATTERN
};
static guint n_pattern_area_targets = (sizeof (pattern_area_target_table) /
sizeof (pattern_area_target_table[0]));
static GtkTargetEntry gradient_area_target_table[] =
{
GIMP_TARGET_GRADIENT
};
static guint n_gradient_area_targets = (sizeof (gradient_area_target_table) /
sizeof (gradient_area_target_table[0]));
static void
brush_area_update (GimpContext *context,
GimpBrush *brush,
@ -80,24 +56,12 @@ brush_preview_clicked (GtkWidget *widget,
}
static void
brush_preview_drag_drop (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time,
gpointer data)
brush_preview_drop_brush (GtkWidget *widget,
GimpBrush *brush,
gpointer data)
{
GtkWidget *src;
GimpBrush *brush;
if ((src = gtk_drag_get_source_widget (context)))
{
brush = (GimpBrush *) gtk_object_get_data (GTK_OBJECT (src),
"gimp_brush");
if (brush)
gimp_context_set_brush (gimp_context_get_user (), brush);
}
if (brush)
gimp_context_set_brush (gimp_context_get_user (), brush);
}
static void
@ -118,24 +82,12 @@ pattern_preview_clicked (GtkWidget *widget,
}
static void
pattern_preview_drag_drop (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time,
gpointer data)
pattern_preview_drop_pattern (GtkWidget *widget,
GPattern *pattern,
gpointer data)
{
GtkWidget *src;
GPattern *pattern;
if ((src = gtk_drag_get_source_widget (context)))
{
pattern = (GPattern *) gtk_object_get_data (GTK_OBJECT (src),
"gimp_pattern");
if (pattern)
gimp_context_set_pattern (gimp_context_get_user (), pattern);
}
if (pattern)
gimp_context_set_pattern (gimp_context_get_user (), pattern);
}
static void
@ -152,7 +104,16 @@ static void
gradient_preview_clicked (GtkWidget *widget,
gpointer data)
{
grad_create_gradient_editor ();
gradient_dialog_create ();
}
static void
gradient_preview_drop_gradient (GtkWidget *widget,
gradient_t *gradient,
gpointer data)
{
if (gradient)
gimp_context_set_gradient (gimp_context_get_user (), gradient);
}
GtkWidget *
@ -166,59 +127,50 @@ indicator_area_create ()
indicator_table = gtk_table_new (2, 2, FALSE);
gtk_table_set_row_spacing (GTK_TABLE (indicator_table), 0, CELL_PADDING);
gtk_table_set_col_spacing (GTK_TABLE (indicator_table), 0, CELL_PADDING);
brush_preview = gimp_context_preview_new (GCP_BRUSH,
CELL_SIZE, CELL_SIZE,
TRUE, FALSE, FALSE);
brush_preview =
gimp_context_preview_new (GCP_BRUSH,
CELL_SIZE, CELL_SIZE,
TRUE, FALSE, FALSE,
(GimpDndDropBrushFunc) brush_preview_drop_brush,
NULL);
gtk_tooltips_set_tip (tool_tips, brush_preview,
_("The active brush.\nClick to open the Brushes Dialog."),
NULL);
_("The active brush.\n"
"Click to open the Brushes Dialog."), NULL);
gtk_signal_connect (GTK_OBJECT (brush_preview), "clicked",
GTK_SIGNAL_FUNC (brush_preview_clicked),
NULL);
gtk_drag_dest_set (brush_preview,
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
brush_area_target_table, n_brush_area_targets,
GDK_ACTION_COPY);
gtk_signal_connect (GTK_OBJECT (brush_preview), "drag_drop",
GTK_SIGNAL_FUNC (brush_preview_drag_drop),
NULL);
gtk_signal_connect (GTK_OBJECT (context), "brush_changed",
GTK_SIGNAL_FUNC (brush_area_update),
NULL);
gtk_table_attach_defaults (GTK_TABLE (indicator_table), brush_preview,
0, 1, 0, 1);
pattern_preview = gimp_context_preview_new (GCP_PATTERN,
CELL_SIZE, CELL_SIZE,
TRUE, FALSE, FALSE);
pattern_preview =
gimp_context_preview_new (GCP_PATTERN,
CELL_SIZE, CELL_SIZE,
TRUE, FALSE, FALSE,
(GimpDndDropPatternFunc) pattern_preview_drop_pattern,
NULL);
gtk_tooltips_set_tip (tool_tips, pattern_preview,
_("The active pattern.\n"
"Click to open the Patterns Dialog."), NULL);
gtk_signal_connect (GTK_OBJECT (pattern_preview), "clicked",
GTK_SIGNAL_FUNC (pattern_preview_clicked),
NULL);
gtk_drag_dest_set (pattern_preview,
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
pattern_area_target_table, n_pattern_area_targets,
GDK_ACTION_COPY);
gtk_signal_connect (GTK_OBJECT (pattern_preview), "drag_drop",
GTK_SIGNAL_FUNC (pattern_preview_drag_drop),
NULL);
gtk_signal_connect (GTK_OBJECT (context), "pattern_changed",
GTK_SIGNAL_FUNC (pattern_area_update),
NULL);
gtk_table_attach_defaults (GTK_TABLE (indicator_table), pattern_preview,
1, 2, 0, 1);
gradient_preview = gimp_context_preview_new (GCP_GRADIENT,
GRAD_CELL_WIDTH,
GRAD_CELL_HEIGHT,
TRUE, FALSE, FALSE);
gradient_preview =
gimp_context_preview_new (GCP_GRADIENT,
GRAD_CELL_WIDTH,
GRAD_CELL_HEIGHT,
TRUE, FALSE, FALSE,
(GimpDndDropGradientFunc) gradient_preview_drop_gradient,
NULL);
gtk_tooltips_set_tip (tool_tips, gradient_preview,
_("The active gradient.\n"
"Click to open the Gradients Dialog."),

View File

@ -29,6 +29,7 @@
#include "gimpcontext.h"
#include "gimprc.h"
#include "gimpui.h"
#include "gradient.h"
#include "gradient_header.h"
#include "session.h"
#include "tools.h"
@ -47,7 +48,8 @@
#define DEVICE_CONTEXT_MASK GIMP_CONTEXT_TOOL_MASK | \
GIMP_CONTEXT_FOREGROUND_MASK | \
GIMP_CONTEXT_BRUSH_MASK | \
GIMP_CONTEXT_PATTERN_MASK
GIMP_CONTEXT_PATTERN_MASK | \
GIMP_CONTEXT_GRADIENT_MASK
typedef struct _DeviceInfo DeviceInfo;
@ -86,47 +88,57 @@ struct _DeviceInfoDialog
GtkWidget **colors;
GtkWidget **brushes;
GtkWidget **patterns;
GtkWidget **gradients;
GtkWidget **eventboxes;
};
/* local functions */
static void input_dialog_destroy_callback (GtkWidget *, gpointer);
static void input_dialog_able_callback (GtkWidget *w, guint32 deviceid,
gpointer data);
static void input_dialog_destroy_callback (GtkWidget *, gpointer);
static void input_dialog_able_callback (GtkWidget *w, guint32 deviceid,
gpointer data);
static void devices_write_rc_device (DeviceInfo *device_info, FILE *fp);
static void devices_write_rc (void);
static void devices_write_rc_device (DeviceInfo *device_info,
FILE *fp);
static void devices_write_rc (void);
static void device_status_destroy_callback (void);
static void devices_close_callback (GtkWidget *, gpointer);
static void device_status_destroy_callback (void);
static void devices_close_callback (GtkWidget *, gpointer);
static void device_status_update (guint32 deviceid);
static void device_status_update_current (void);
static void device_status_update (guint32 deviceid);
static void device_status_update_current (void);
static void device_status_drag_color (GtkWidget *,
guchar *, guchar *, guchar *,
gpointer);
static void device_status_drop_color (GtkWidget *,
guchar, guchar, guchar,
gpointer);
static void device_status_drop_brush (GtkWidget *,
GdkDragContext *,
gint, gint, guint, gpointer);
static void device_status_drop_pattern (GtkWidget *,
GdkDragContext *,
gint, gint, guint, gpointer);
static ToolType device_status_drag_tool (GtkWidget *,
gpointer);
static void device_status_drop_tool (GtkWidget *,
ToolType,
gpointer);
static void device_status_drag_color (GtkWidget *,
guchar *, guchar *, guchar *,
gpointer);
static void device_status_drop_color (GtkWidget *,
guchar, guchar, guchar,
gpointer);
static void device_status_drop_brush (GtkWidget *,
GimpBrush *,
gpointer);
static void device_status_drop_pattern (GtkWidget *,
GPattern *,
gpointer);
static void device_status_drop_gradient (GtkWidget *,
gradient_t *,
gpointer);
static void device_status_color_changed (GimpContext *context,
gint r,
gint g,
gint b,
gpointer data);
static void device_status_data_changed (GimpContext *context,
gpointer dummy,
gpointer data);
static void device_status_color_changed (GimpContext *context,
gint r,
gint g,
gint b,
gpointer data);
static void device_status_data_changed (GimpContext *context,
gpointer dummy,
gpointer data);
static void device_status_context_connect (GimpContext *context,
guint32 deviceid);
static void device_status_context_connect (GimpContext *context,
guint32 deviceid);
/* global data */
gint current_device = GDK_CORE_POINTER;
@ -139,6 +151,13 @@ static DeviceInfoDialog *deviceD = NULL;
static gboolean suppress_update = FALSE;
/* dnd stuff */
static GtkTargetEntry tool_target_table[] =
{
GIMP_TARGET_TOOL
};
static guint n_tool_targets = (sizeof (tool_target_table) /
sizeof (tool_target_table[0]));
static GtkTargetEntry color_area_target_table[] =
{
GIMP_TARGET_COLOR
@ -146,20 +165,6 @@ static GtkTargetEntry color_area_target_table[] =
static guint n_color_area_targets = (sizeof (color_area_target_table) /
sizeof (color_area_target_table[0]));
static GtkTargetEntry brush_area_target_table[] =
{
GIMP_TARGET_BRUSH
};
static guint n_brush_area_targets = (sizeof (brush_area_target_table) /
sizeof (brush_area_target_table[0]));
static GtkTargetEntry pattern_area_target_table[] =
{
GIMP_TARGET_PATTERN
};
static guint n_pattern_area_targets = (sizeof (pattern_area_target_table) /
sizeof (pattern_area_target_table[0]));
/* utility functions for the device lists */
static GdkDeviceInfo *
@ -487,19 +492,9 @@ devices_rc_update (gchar *name,
if (values & DEVICE_GRADIENT)
{
gradient_t *gradient;
GSList *list;
for (list = gradients_list; list; list = g_slist_next (list))
{
gradient = (gradient_t *) list->data;
if (! strcmp (gradient->name, gradient_name))
{
gimp_context_set_gradient (device_info->context, gradient);
break;
}
}
gimp_context_set_gradient (device_info->context,
gradient_list_get_gradient (gradients_list,
gradient_name));
}
}
@ -686,6 +681,12 @@ devices_write_rc_device (DeviceInfo *device_info,
gimp_context_get_pattern (device_info->context)->name);
}
if (gimp_context_get_gradient (device_info->context))
{
fprintf (fp, "\n (gradient \"%s\")",
gimp_context_get_gradient (device_info->context)->name);
}
fprintf(fp,")\n");
}
@ -750,7 +751,7 @@ device_status_create (void)
}
/* devices table */
deviceD->table = gtk_table_new (deviceD->num_devices, 5, FALSE);
deviceD->table = gtk_table_new (deviceD->num_devices, 6, FALSE);
gtk_container_set_border_width (GTK_CONTAINER (deviceD->table), 3);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (deviceD->shell)->vbox),
deviceD->table);
@ -763,6 +764,7 @@ device_status_create (void)
deviceD->colors = g_new (GtkWidget *, deviceD->num_devices);
deviceD->brushes = g_new (GtkWidget *, deviceD->num_devices);
deviceD->patterns = g_new (GtkWidget *, deviceD->num_devices);
deviceD->gradients = g_new (GtkWidget *, deviceD->num_devices);
deviceD->eventboxes = g_new (GtkWidget *, deviceD->num_devices);
for (list = device_info_list, i = 0; list; list = g_list_next (list), i++)
@ -792,14 +794,27 @@ device_status_create (void)
/* the tool */
deviceD->eventboxes[i] = gtk_event_box_new();
deviceD->tools[i] =
gtk_pixmap_new (create_tool_pixmap (deviceD->table, RECT_SELECT),
NULL);
gtk_drag_source_set (deviceD->eventboxes[i],
GDK_BUTTON1_MASK,
tool_target_table, n_tool_targets,
GDK_ACTION_COPY);
gimp_dnd_tool_source_set (deviceD->eventboxes[i],
device_status_drag_tool,
GUINT_TO_POINTER (device_info->device));
gtk_drag_dest_set (deviceD->eventboxes[i],
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
tool_target_table, n_tool_targets,
GDK_ACTION_COPY);
gimp_dnd_tool_dest_set (deviceD->eventboxes[i],
device_status_drop_tool,
GUINT_TO_POINTER (device_info->device));
gtk_container_add (GTK_CONTAINER (deviceD->eventboxes[i]),
deviceD->tools[i]);
gtk_table_attach (GTK_TABLE (deviceD->table), deviceD->eventboxes[i],
1, 2, i, i+1,
0, 0, 2, 2);
@ -831,40 +846,40 @@ device_status_create (void)
/* the brush */
deviceD->brushes[i] = gimp_context_preview_new (GCP_BRUSH,
CELL_SIZE, CELL_SIZE,
FALSE, TRUE, TRUE);
gtk_drag_dest_set (deviceD->brushes[i],
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
brush_area_target_table, n_brush_area_targets,
GDK_ACTION_COPY);
gtk_signal_connect (GTK_OBJECT (deviceD->brushes[i]), "drag_drop",
GTK_SIGNAL_FUNC (device_status_drop_brush),
GUINT_TO_POINTER (device_info->device));
deviceD->brushes[i] =
gimp_context_preview_new (GCP_BRUSH,
CELL_SIZE, CELL_SIZE,
FALSE, TRUE, TRUE,
GTK_SIGNAL_FUNC (device_status_drop_brush),
GUINT_TO_POINTER (device_info->device));
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->brushes[i],
3, 4, i, i+1,
0, 0, 2, 2);
/* the pattern */
deviceD->patterns[i] = gimp_context_preview_new (GCP_PATTERN,
CELL_SIZE, CELL_SIZE,
FALSE, TRUE, TRUE);
gtk_drag_dest_set (deviceD->patterns[i],
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
pattern_area_target_table, n_pattern_area_targets,
GDK_ACTION_COPY);
gtk_signal_connect (GTK_OBJECT (deviceD->patterns[i]), "drag_drop",
GTK_SIGNAL_FUNC (device_status_drop_pattern),
GUINT_TO_POINTER (device_info->device));
deviceD->patterns[i] =
gimp_context_preview_new (GCP_PATTERN,
CELL_SIZE, CELL_SIZE,
FALSE, TRUE, TRUE,
GTK_SIGNAL_FUNC (device_status_drop_pattern),
GUINT_TO_POINTER (device_info->device));
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->patterns[i],
4, 5, i, i+1,
0, 0, 2, 2);
/* the gradient */
deviceD->gradients[i] =
gimp_context_preview_new (GCP_GRADIENT,
CELL_SIZE * 2, CELL_SIZE,
FALSE, TRUE, TRUE,
GTK_SIGNAL_FUNC (device_status_drop_gradient),
GUINT_TO_POINTER (device_info->device));
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->gradients[i],
5, 6, i, i+1,
0, 0, 2, 2);
device_status_update (device_info->device);
}
@ -896,6 +911,7 @@ device_status_destroy_callback (void)
g_free (deviceD->colors);
g_free (deviceD->brushes);
g_free (deviceD->patterns);
g_free (deviceD->gradients);
g_free (deviceD);
deviceD = NULL;
@ -977,6 +993,7 @@ device_status_update (guint32 deviceid)
gtk_widget_hide (deviceD->colors[i]);
gtk_widget_hide (deviceD->brushes[i]);
gtk_widget_hide (deviceD->patterns[i]);
gtk_widget_hide (deviceD->gradients[i]);
}
else
{
@ -1033,11 +1050,52 @@ device_status_update (guint32 deviceid)
gimp_context_get_pattern (device_info->context));
gtk_widget_show (deviceD->patterns[i]);
}
if (gimp_context_get_gradient (device_info->context))
{
gimp_context_preview_update
(GIMP_CONTEXT_PREVIEW (deviceD->gradients[i]),
gimp_context_get_gradient (device_info->context));
gtk_widget_show (deviceD->gradients[i]);
}
}
}
/* dnd stuff */
static ToolType
device_status_drag_tool (GtkWidget *widget,
gpointer data)
{
DeviceInfo *device_info;
device_info = device_info_get_by_id (GPOINTER_TO_UINT (data));
if (device_info)
{
return gimp_context_get_tool (device_info->context);
}
else
{
return RECT_SELECT;
}
}
static void
device_status_drop_tool (GtkWidget *widget,
ToolType tool,
gpointer data)
{
DeviceInfo *device_info;
device_info = device_info_get_by_id (GPOINTER_TO_UINT (data));
if (device_info && device_info->is_present)
{
gimp_context_set_tool (device_info->context, tool);
}
}
static void
device_status_drag_color (GtkWidget *widget,
guchar *r,
@ -1077,24 +1135,11 @@ device_status_drop_color (GtkWidget *widget,
}
static void
device_status_drop_brush (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time,
gpointer data)
device_status_drop_brush (GtkWidget *widget,
GimpBrush *brush,
gpointer data)
{
DeviceInfo *device_info;
GtkWidget *src;
GimpBrush *brush = NULL;
src = gtk_drag_get_source_widget (context);
if (!src)
return;
brush = (GimpBrush *) gtk_object_get_data (GTK_OBJECT (src), "gimp_brush");
if (!brush)
return;
device_info = device_info_get_by_id (GPOINTER_TO_UINT (data));
@ -1105,24 +1150,11 @@ device_status_drop_brush (GtkWidget *widget,
}
static void
device_status_drop_pattern (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time,
gpointer data)
device_status_drop_pattern (GtkWidget *widget,
GPattern *pattern,
gpointer data)
{
DeviceInfo *device_info;
GtkWidget *src;
GPattern *pattern = NULL;
src = gtk_drag_get_source_widget (context);
if (!src)
return;
pattern = (GPattern *) gtk_object_get_data (GTK_OBJECT (src), "gimp_pattern");
if (!pattern)
return;
device_info = device_info_get_by_id (GPOINTER_TO_UINT (data));
@ -1132,6 +1164,21 @@ device_status_drop_pattern (GtkWidget *widget,
}
}
static void
device_status_drop_gradient (GtkWidget *widget,
gradient_t *gradient,
gpointer data)
{
DeviceInfo *device_info;
device_info = device_info_get_by_id (GPOINTER_TO_UINT (data));
if (device_info && device_info->is_present)
{
gimp_context_set_gradient (device_info->context, gradient);
}
}
/* context callbacks */
static void
@ -1176,4 +1223,7 @@ device_status_context_connect (GimpContext *context,
gtk_signal_connect (GTK_OBJECT (context), "pattern_changed",
GTK_SIGNAL_FUNC (device_status_data_changed),
(gpointer) deviceid);
gtk_signal_connect (GTK_OBJECT (context), "gradient_changed",
GTK_SIGNAL_FUNC (device_status_data_changed),
(gpointer) deviceid);
}

View File

@ -99,7 +99,7 @@ static GimpItemFactoryEntry toolbox_entries[] =
"file/dialogs/palette_selection.html", NULL },
{ { N_("/File/Dialogs/Indexed Palette..."), NULL, dialogs_indexed_palette_cmd_callback, 0 },
"file/dialogs/indexed_palette.html", NULL },
{ { N_("/File/Dialogs/Gradients..."), "<control>G", dialogs_gradient_editor_cmd_callback, 0 },
{ { N_("/File/Dialogs/Gradients..."), "<control>G", dialogs_gradient_cmd_callback, 0 },
"file/dialogs/gradient_selection.html", NULL },
{ { N_("/File/Dialogs/Layers & Channels..."), "<control>L", dialogs_lc_cmd_callback, 0 },
"file/dialogs/layers_and_channels.html", NULL },
@ -395,7 +395,7 @@ static GimpItemFactoryEntry image_entries[] =
"dialogs/palette_selection.html", NULL },
{ { N_("/Dialogs/Indexed Palette..."), NULL, dialogs_indexed_palette_cmd_callback, 0 },
"dialogs/indexed_palette.html", NULL },
{ { N_("/Dialogs/Gradients..."), "<control>G", dialogs_gradient_editor_cmd_callback, 0 },
{ { N_("/Dialogs/Gradients..."), "<control>G", dialogs_gradient_cmd_callback, 0 },
"dialogs/gradient_selection.html", NULL },
{ { N_("/Dialogs/Layers & Channels..."), "<control>L", dialogs_lc_cmd_callback, 0 },
"dialogs/layers_and_channels.html", NULL },
@ -729,16 +729,13 @@ menus_tools_create (ToolInfo *tool_info)
{
GimpItemFactoryEntry entry;
entry.entry.path = tool_info->menu_path;
entry.entry.accelerator = tool_info->menu_accel;
entry.entry.callback = tools_select_cmd_callback;
entry.entry.path = tool_info->menu_path;
entry.entry.accelerator = tool_info->menu_accel;
entry.entry.callback = tools_select_cmd_callback;
entry.entry.callback_action = tool_info->tool_id;
entry.entry.item_type = NULL;
entry.help_page = g_strconcat ("tools/",
tool_info->private_tip,
".html",
NULL);
entry.description = NULL;
entry.entry.item_type = NULL;
entry.help_page = tool_info->private_tip;
entry.description = NULL;
menus_create_item (image_factory,
&entry,

View File

@ -38,8 +38,8 @@
#include "gimpdnd.h"
#include "gimprc.h"
#include "gimpui.h"
#include "gradient.h"
#include "gradient_header.h"
#include "gradient_select.h"
#include "palette.h"
#include "paletteP.h"
#include "palette_entries.h"
@ -179,12 +179,12 @@ palette_init_palettes (gint no_data)
void
palettes_free (void)
{
PaletteEntries *entries;
GSList *list;
PaletteEntriesP entries;
for (list = palette_entries_list; list; list = g_slist_next (list))
{
entries = (PaletteEntriesP) list->data;
entries = (PaletteEntries *) list->data;
/* If the palette has been changed, save it, if possible */
if (entries->changed)
@ -1125,7 +1125,7 @@ static void
palette_dialog_delete_entry_callback (GtkWidget *widget,
gpointer data)
{
PaletteEntryP entry;
PaletteEntry *entry;
PaletteDialog *palette;
GSList *tmp_link;
gint pos = 0;
@ -1471,7 +1471,7 @@ palette_dialog_draw_entries (PaletteDialog *palette,
gint row_start,
gint column_highlight)
{
PaletteEntryP entry;
PaletteEntry *entry;
guchar *buffer;
guchar **colors;
GSList *tmp_link;
@ -1802,13 +1802,13 @@ palette_dialog_merge_entries_callback (GtkWidget *widget,
row = GPOINTER_TO_INT (sel_list->data);
p_entries =
(PaletteEntriesP) gtk_clist_get_row_data (GTK_CLIST (palette->clist), row);
(PaletteEntries *) gtk_clist_get_row_data (GTK_CLIST (palette->clist), row);
/* Go through each palette and merge the colors */
cols = p_entries->colors;
while (cols)
{
PaletteEntryP entry = cols->data;
PaletteEntry *entry = cols->data;
palette_entries_add_entry (new_entries,
entry->name,
entry->color[0],
@ -2239,7 +2239,7 @@ palette_import_select_grad_callback (GtkWidget *widget,
gpointer data)
{
/* Popup grad edit box .... */
grad_create_gradient_editor ();
gradient_dialog_create ();
}
static void
@ -2837,8 +2837,8 @@ static void
palette_import_image_make_palette (GHashTable *h_array,
guchar *name)
{
GSList * sorted_list = NULL;
PaletteEntriesP entries;
PaletteEntries *entries;
GSList *sorted_list = NULL;
g_hash_table_foreach (h_array, palette_import_create_sorted_list,
&sorted_list);
@ -2946,8 +2946,8 @@ static void
palette_import_create_from_indexed (GImage *gimage,
guchar *pname)
{
PaletteEntries *entries;
gint samples, count;
PaletteEntriesP entries;
samples = (gint) import_dialog->sample->value;

View File

@ -41,7 +41,7 @@ palette_new_selection (gchar *title,
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *scrolled_win;
PaletteEntriesP p_entries = NULL;
PaletteEntries *p_entries = NULL;
gint select_pos;
palette_select_palette_init ();
@ -105,7 +105,7 @@ palette_new_selection (gchar *title,
{
for (list = palette_entries_list; list; list = g_slist_next (list))
{
p_entries = (PaletteEntriesP) list->data;
p_entries = (PaletteEntries *) list->data;
if (strcmp (p_entries->name, initial_palette) > 0)
break;
@ -137,16 +137,16 @@ palette_new_selection (gchar *title,
}
void
palette_select_clist_insert_all (PaletteEntriesP p_entries)
palette_select_clist_insert_all (PaletteEntries *p_entries)
{
PaletteEntriesP chk_entries;
PaletteEntries *chk_entries;
PaletteSelect *psp;
GSList *list;
gint pos = 0;
for (list = palette_entries_list; list; list = g_slist_next (list))
{
chk_entries = (PaletteEntriesP) list->data;
chk_entries = (PaletteEntries *) list->data;
/* to make sure we get something! */
if (chk_entries == NULL)
@ -169,9 +169,9 @@ palette_select_clist_insert_all (PaletteEntriesP p_entries)
}
void
palette_select_set_text_all (PaletteEntriesP entries)
palette_select_set_text_all (PaletteEntries *entries)
{
PaletteEntriesP p_entries = NULL;
PaletteEntries *p_entries = NULL;
PaletteSelect *psp;
GSList *list;
gchar *num_buf;
@ -179,7 +179,7 @@ palette_select_set_text_all (PaletteEntriesP entries)
for (list = palette_entries_list; list; list = g_slist_next (list))
{
p_entries = (PaletteEntriesP) list->data;
p_entries = (PaletteEntries *) list->data;
if (p_entries == entries)
break;
@ -225,7 +225,7 @@ static void
palette_select_edit_callback (GtkWidget *widget,
gpointer data)
{
PaletteEntriesP p_entries = NULL;
PaletteEntries *p_entries = NULL;
PaletteSelect *psp = (PaletteSelect *) data;
GList *sel_list;
@ -238,7 +238,7 @@ palette_select_edit_callback (GtkWidget *widget,
row = GPOINTER_TO_INT (sel_list->data);
p_entries =
(PaletteEntriesP) gtk_clist_get_row_data (GTK_CLIST (psp->clist), row);
(PaletteEntries *) gtk_clist_get_row_data (GTK_CLIST (psp->clist), row);
palette_create_edit (p_entries);

View File

@ -21,7 +21,7 @@
#define SM_PREVIEW_WIDTH (96 + 2)
#define SM_PREVIEW_HEIGHT (33 + 2)
typedef struct _PaletteSelect PaletteSelect, *PaletteSelectP;
typedef struct _PaletteSelect PaletteSelect;
struct _PaletteSelect
{
@ -34,8 +34,8 @@ struct _PaletteSelect
PaletteSelect * palette_new_selection (gchar *title,
gchar *initial_palette);
void palette_select_clist_insert_all (PaletteEntriesP p_entries);
void palette_select_set_text_all (PaletteEntriesP entries);
void palette_select_clist_insert_all (PaletteEntries *p_entries);
void palette_select_set_text_all (PaletteEntries *entries);
void palette_select_refresh_all (void);
#endif /* __PALETTE_SELECT_H__ */

View File

@ -20,6 +20,7 @@
#include "appenv.h"
#include "dialog_handler.h"
#include "gimpcontext.h"
#include "gimpdnd.h"
#include "gimpui.h"
#include "patterns.h"
#include "pattern_select.h"
@ -47,6 +48,12 @@
GDK_ENTER_NOTIFY_MASK
/* local function prototypes */
static void pattern_change_callbacks (PatternSelect *psp,
gboolean closing);
static void pattern_select_drop_pattern (GtkWidget *widget,
GPattern *pattern,
gpointer data);
static void pattern_select_pattern_changed (GimpContext *context,
GPattern *pattern,
PatternSelect *psp);
@ -77,6 +84,14 @@ static void pattern_select_scroll_update (GtkAdjustment *, gpointer);
static void pattern_select_close_callback (GtkWidget *, gpointer);
static void pattern_select_refresh_callback (GtkWidget *, gpointer);
/* dnd stuff */
static GtkTargetEntry preview_target_table[] =
{
GIMP_TARGET_PATTERN
};
static guint preview_n_targets = (sizeof (preview_target_table) /
sizeof (preview_target_table[0]));
/* The main pattern selection dialog */
PatternSelect *pattern_select_dialog = NULL;
@ -90,15 +105,10 @@ pattern_dialog_create (void)
{
if (! pattern_select_dialog)
{
/* Create the dialog... */
pattern_select_dialog = pattern_select_new (NULL, NULL);
/* register this one only */
dialog_register (pattern_select_dialog->shell);
}
else
{
/* Popup the dialog */
if (!GTK_WIDGET_VISIBLE (pattern_select_dialog->shell))
gtk_widget_show (pattern_select_dialog->shell);
else
@ -111,6 +121,9 @@ pattern_dialog_free ()
{
if (pattern_select_dialog)
{
session_get_window_info (pattern_select_dialog->shell,
&pattern_select_session_info);
pattern_select_free (pattern_select_dialog);
pattern_select_dialog = NULL;
}
@ -130,6 +143,8 @@ pattern_select_new (gchar *title,
GPattern *active = NULL;
static gboolean first_call = TRUE;
psp = g_new (PatternSelect, 1);
psp->preview = NULL;
psp->callback_name = NULL;
@ -161,15 +176,18 @@ pattern_select_new (gchar *title,
}
else
{
psp->context = gimp_context_get_user ();
session_set_window_geometry (psp->shell, &pattern_select_session_info,
TRUE);
psp->context = gimp_context_get_user ();
dialog_register (psp->shell);
}
if (no_data)
if (no_data && first_call)
patterns_init (FALSE);
first_call = FALSE;
if (title && initial_pattern && strlen (initial_pattern))
{
active = pattern_list_get_pattern (pattern_list, initial_pattern);
@ -247,6 +265,13 @@ pattern_select_new (gchar *title,
GTK_SIGNAL_FUNC (pattern_select_resize),
psp);
/* dnd stuff */
gtk_drag_dest_set (psp->preview,
GTK_DEST_DEFAULT_ALL,
preview_target_table, preview_n_targets,
GDK_ACTION_COPY);
gimp_dnd_pattern_dest_set (psp->preview, pattern_select_drop_pattern, psp);
gtk_container_add (GTK_CONTAINER (frame), psp->preview);
gtk_widget_show (psp->preview);
@ -282,12 +307,6 @@ pattern_select_free (PatternSelect *psp)
/* remove from active list */
pattern_active_dialogs = g_slist_remove (pattern_active_dialogs, psp);
/* Only main one is saved */
if (psp == pattern_select_dialog)
{
session_get_window_info (psp->shell, &pattern_select_session_info);
}
gtk_signal_disconnect_by_data (GTK_OBJECT (psp->context), psp);
if (psp->pattern_popup != NULL)
@ -307,9 +326,9 @@ pattern_select_free (PatternSelect *psp)
/* Call this dialog's PDB callback */
void
static void
pattern_change_callbacks (PatternSelect *psp,
gint closing)
gboolean closing)
{
gchar *name;
ProcRecord *prec = NULL;
@ -335,13 +354,13 @@ pattern_change_callbacks (PatternSelect *psp,
return_vals =
procedural_db_run_proc (name,
&nreturn_vals,
PDB_STRING, pattern->name,
PDB_INT32, pattern->mask->width,
PDB_INT32, pattern->mask->height,
PDB_INT32, pattern->mask->bytes,
PDB_INT32, pattern->mask->bytes*pattern->mask->height*pattern->mask->width,
PDB_STRING, pattern->name,
PDB_INT32, pattern->mask->width,
PDB_INT32, pattern->mask->height,
PDB_INT32, pattern->mask->bytes,
PDB_INT32, pattern->mask->bytes*pattern->mask->height*pattern->mask->width,
PDB_INT8ARRAY, temp_buf_data (pattern->mask),
PDB_INT32, closing,
PDB_INT32, (gint) closing,
PDB_END);
if (!return_vals || return_vals[0].value.pdb_int != PDB_SUCCESS)
@ -367,7 +386,7 @@ patterns_check_dialogs (void)
while (list)
{
psp = (PatternSelect *) list->data;
list = list->next;
list = g_slist_next (list);
name = psp->callback_name;
@ -388,6 +407,18 @@ patterns_check_dialogs (void)
* Local functions
*/
static void
pattern_select_drop_pattern (GtkWidget *widget,
GPattern *pattern,
gpointer data)
{
PatternSelect *psp;
psp = (PatternSelect *) data;
gimp_context_set_pattern (psp->context, pattern);
}
static void
pattern_select_pattern_changed (GimpContext *context,
GPattern *pattern,
@ -402,13 +433,30 @@ pattern_select_select (PatternSelect *psp,
gint index)
{
gint row, col;
gint scroll_offset = 0;
update_active_pattern_field (psp);
row = index / psp->NUM_PATTERN_COLUMNS;
col = index - row * psp->NUM_PATTERN_COLUMNS;
pattern_select_show_selected (psp, row, col);
/* check if the new active pattern is already in the preview */
if (((row + 1) * psp->cell_height) >
(psp->preview->allocation.height + psp->scroll_offset))
{
scroll_offset = (((row + 1) * psp->cell_height) -
(psp->scroll_offset + psp->preview->allocation.height));
}
else if ((row * psp->cell_height) < psp->scroll_offset)
{
scroll_offset = (row * psp->cell_height) - psp->scroll_offset;
}
else
{
pattern_select_show_selected (psp, row, col);
}
gtk_adjustment_set_value (psp->sbar_data, psp->scroll_offset + scroll_offset);
}
typedef struct
@ -777,6 +825,7 @@ preview_calc_scrollbar (PatternSelect *psp)
psp->sbar_data->page_increment = (page_size >> 1);
psp->sbar_data->step_increment = psp->cell_width;
gtk_signal_emit_by_name (GTK_OBJECT (psp->sbar_data), "changed");
gtk_signal_emit_by_name (GTK_OBJECT (psp->sbar_data), "value_changed");
}
@ -889,7 +938,7 @@ pattern_select_events (GtkWidget *widget,
pattern_popup_close (psp);
/* Call any callbacks registered */
pattern_change_callbacks (psp, 0);
pattern_change_callbacks (psp, FALSE);
}
break;
@ -946,7 +995,7 @@ pattern_select_close_callback (GtkWidget *widget,
if (psp != pattern_select_dialog)
{
/* Send data back */
pattern_change_callbacks (psp, 1);
pattern_change_callbacks (psp, TRUE);
gtk_widget_destroy (psp->shell);
pattern_select_free (psp);
}

View File

@ -69,8 +69,6 @@ PatternSelect * pattern_select_new (gchar *title,
void pattern_select_free (PatternSelect *psp);
void pattern_change_callbacks (PatternSelect *psp,
gint closing);
void patterns_check_dialogs (void);
/* the main pattern selection */

View File

@ -94,7 +94,7 @@
#include "general.h"
#include "gimage.h"
#include "gimprc.h"
#include "gradient.h"
#include "gradient_select.h"
#include "interface.h"
#include "menus.h"
#include "pattern_select.h" /* Needed for closing pattern dialogs */

View File

@ -94,7 +94,7 @@
#include "general.h"
#include "gimage.h"
#include "gimprc.h"
#include "gradient.h"
#include "gradient_select.h"
#include "interface.h"
#include "menus.h"
#include "pattern_select.h" /* Needed for closing pattern dialogs */

View File

@ -16,7 +16,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* Session-managment stuff Copyright (C) 1998 Sven Neumann <sven@gimp.org>
I include a short description here on what is done and what problems
@ -57,8 +56,8 @@
#include "libgimp/gimpintl.h"
#include "libgimp/gimpenv.h"
static void sessionrc_write_info (SessionInfo *, FILE *);
static void session_open_dialog (SessionInfo *);
static void sessionrc_write_info (SessionInfo *, FILE *);
static void session_open_dialog (SessionInfo *);
static void session_reset_open_state (SessionInfo *);
GList *session_info_updates = NULL;
@ -79,7 +78,7 @@ SessionInfo brush_select_session_info =
SessionInfo pattern_select_session_info =
{ "pattern-select", (GtkItemFactoryCallback)dialogs_patterns_cmd_callback, 160, 180, 0, 0, FALSE };
SessionInfo gradient_select_session_info =
{ "gradient-editor", (GtkItemFactoryCallback)dialogs_gradient_editor_cmd_callback, 170, 180, 0, 0, FALSE };
{ "gradient-editor", (GtkItemFactoryCallback)dialogs_gradient_cmd_callback, 170, 180, 0, 0, FALSE };
SessionInfo device_status_session_info =
{ "device-status", (GtkItemFactoryCallback)dialogs_device_status_cmd_callback, 0, 600, 0, 0, FALSE };
SessionInfo error_console_session_info =

View File

@ -22,47 +22,23 @@
#include "brush_select.h"
#include "gimpcontextpreview.h"
#include "gimpdnd.h"
#include "gradient.h"
#include "gradient_header.h"
#include "gradient_select.h"
#include "indicator_area.h"
#include "interface.h" /* for tool_tips */
#include "pattern_select.h"
#include "libgimp/gimpintl.h"
#define CELL_SIZE 23 /* The size of the previews */
#define GRAD_CELL_WIDTH 48 /* The width of the gradient preview */
#define CELL_SIZE 23 /* The size of the previews */
#define GRAD_CELL_WIDTH 48 /* The width of the gradient preview */
#define GRAD_CELL_HEIGHT 12 /* The height of the gradient preview */
#define CELL_PADDING 2 /* How much between brush and pattern cells */
#define CELL_PADDING 2 /* How much between brush and pattern cells */
/* Static variables */
static GtkWidget *brush_preview;
static GtkWidget *pattern_preview;
static GtkWidget *gradient_preview;
/* dnd stuff */
static GtkTargetEntry brush_area_target_table[] =
{
GIMP_TARGET_BRUSH
};
static guint n_brush_area_targets = (sizeof (brush_area_target_table) /
sizeof (brush_area_target_table[0]));
static GtkTargetEntry pattern_area_target_table[] =
{
GIMP_TARGET_PATTERN
};
static guint n_pattern_area_targets = (sizeof (pattern_area_target_table) /
sizeof (pattern_area_target_table[0]));
static GtkTargetEntry gradient_area_target_table[] =
{
GIMP_TARGET_GRADIENT
};
static guint n_gradient_area_targets = (sizeof (gradient_area_target_table) /
sizeof (gradient_area_target_table[0]));
static void
brush_area_update (GimpContext *context,
GimpBrush *brush,
@ -80,24 +56,12 @@ brush_preview_clicked (GtkWidget *widget,
}
static void
brush_preview_drag_drop (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time,
gpointer data)
brush_preview_drop_brush (GtkWidget *widget,
GimpBrush *brush,
gpointer data)
{
GtkWidget *src;
GimpBrush *brush;
if ((src = gtk_drag_get_source_widget (context)))
{
brush = (GimpBrush *) gtk_object_get_data (GTK_OBJECT (src),
"gimp_brush");
if (brush)
gimp_context_set_brush (gimp_context_get_user (), brush);
}
if (brush)
gimp_context_set_brush (gimp_context_get_user (), brush);
}
static void
@ -118,24 +82,12 @@ pattern_preview_clicked (GtkWidget *widget,
}
static void
pattern_preview_drag_drop (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time,
gpointer data)
pattern_preview_drop_pattern (GtkWidget *widget,
GPattern *pattern,
gpointer data)
{
GtkWidget *src;
GPattern *pattern;
if ((src = gtk_drag_get_source_widget (context)))
{
pattern = (GPattern *) gtk_object_get_data (GTK_OBJECT (src),
"gimp_pattern");
if (pattern)
gimp_context_set_pattern (gimp_context_get_user (), pattern);
}
if (pattern)
gimp_context_set_pattern (gimp_context_get_user (), pattern);
}
static void
@ -152,7 +104,16 @@ static void
gradient_preview_clicked (GtkWidget *widget,
gpointer data)
{
grad_create_gradient_editor ();
gradient_dialog_create ();
}
static void
gradient_preview_drop_gradient (GtkWidget *widget,
gradient_t *gradient,
gpointer data)
{
if (gradient)
gimp_context_set_gradient (gimp_context_get_user (), gradient);
}
GtkWidget *
@ -166,59 +127,50 @@ indicator_area_create ()
indicator_table = gtk_table_new (2, 2, FALSE);
gtk_table_set_row_spacing (GTK_TABLE (indicator_table), 0, CELL_PADDING);
gtk_table_set_col_spacing (GTK_TABLE (indicator_table), 0, CELL_PADDING);
brush_preview = gimp_context_preview_new (GCP_BRUSH,
CELL_SIZE, CELL_SIZE,
TRUE, FALSE, FALSE);
brush_preview =
gimp_context_preview_new (GCP_BRUSH,
CELL_SIZE, CELL_SIZE,
TRUE, FALSE, FALSE,
(GimpDndDropBrushFunc) brush_preview_drop_brush,
NULL);
gtk_tooltips_set_tip (tool_tips, brush_preview,
_("The active brush.\nClick to open the Brushes Dialog."),
NULL);
_("The active brush.\n"
"Click to open the Brushes Dialog."), NULL);
gtk_signal_connect (GTK_OBJECT (brush_preview), "clicked",
GTK_SIGNAL_FUNC (brush_preview_clicked),
NULL);
gtk_drag_dest_set (brush_preview,
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
brush_area_target_table, n_brush_area_targets,
GDK_ACTION_COPY);
gtk_signal_connect (GTK_OBJECT (brush_preview), "drag_drop",
GTK_SIGNAL_FUNC (brush_preview_drag_drop),
NULL);
gtk_signal_connect (GTK_OBJECT (context), "brush_changed",
GTK_SIGNAL_FUNC (brush_area_update),
NULL);
gtk_table_attach_defaults (GTK_TABLE (indicator_table), brush_preview,
0, 1, 0, 1);
pattern_preview = gimp_context_preview_new (GCP_PATTERN,
CELL_SIZE, CELL_SIZE,
TRUE, FALSE, FALSE);
pattern_preview =
gimp_context_preview_new (GCP_PATTERN,
CELL_SIZE, CELL_SIZE,
TRUE, FALSE, FALSE,
(GimpDndDropPatternFunc) pattern_preview_drop_pattern,
NULL);
gtk_tooltips_set_tip (tool_tips, pattern_preview,
_("The active pattern.\n"
"Click to open the Patterns Dialog."), NULL);
gtk_signal_connect (GTK_OBJECT (pattern_preview), "clicked",
GTK_SIGNAL_FUNC (pattern_preview_clicked),
NULL);
gtk_drag_dest_set (pattern_preview,
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
pattern_area_target_table, n_pattern_area_targets,
GDK_ACTION_COPY);
gtk_signal_connect (GTK_OBJECT (pattern_preview), "drag_drop",
GTK_SIGNAL_FUNC (pattern_preview_drag_drop),
NULL);
gtk_signal_connect (GTK_OBJECT (context), "pattern_changed",
GTK_SIGNAL_FUNC (pattern_area_update),
NULL);
gtk_table_attach_defaults (GTK_TABLE (indicator_table), pattern_preview,
1, 2, 0, 1);
gradient_preview = gimp_context_preview_new (GCP_GRADIENT,
GRAD_CELL_WIDTH,
GRAD_CELL_HEIGHT,
TRUE, FALSE, FALSE);
gradient_preview =
gimp_context_preview_new (GCP_GRADIENT,
GRAD_CELL_WIDTH,
GRAD_CELL_HEIGHT,
TRUE, FALSE, FALSE,
(GimpDndDropGradientFunc) gradient_preview_drop_gradient,
NULL);
gtk_tooltips_set_tip (tool_tips, gradient_preview,
_("The active gradient.\n"
"Click to open the Gradients Dialog."),

View File

@ -90,6 +90,9 @@ static gboolean toolbox_drag_drop (GtkWidget *,
gint,
gint,
guint);
static void toolbox_drop_tool (GtkWidget *,
ToolType,
gpointer);
static void gimp_dnd_open_files (gchar *);
static int pixmap_colors[8][3] =
@ -122,7 +125,8 @@ static GtkTargetEntry toolbox_target_table[] =
GIMP_TARGET_NETSCAPE_URL,
GIMP_TARGET_LAYER,
GIMP_TARGET_CHANNEL,
GIMP_TARGET_LAYER_MASK
GIMP_TARGET_LAYER_MASK,
GIMP_TARGET_TOOL
};
static guint toolbox_n_targets = (sizeof (toolbox_target_table) /
sizeof (toolbox_target_table[0]));
@ -709,7 +713,8 @@ create_display_shell (GDisplay* gdisp,
gtk_signal_connect (GTK_OBJECT (gdisp->shell), "drag_drop",
GTK_SIGNAL_FUNC (gdisplay_drag_drop),
gdisp);
gimp_dnd_color_dest_set (gdisp->shell, gdisplay_set_color, gdisp);
gimp_dnd_color_dest_set (gdisp->shell, gdisplay_drop_color, gdisp);
gimp_dnd_pattern_dest_set (gdisp->shell, gdisplay_drop_pattern, gdisp);
/* the vbox, table containing all widgets */
vbox = gtk_vbox_new (FALSE, 2);
@ -997,6 +1002,8 @@ toolbox_set_drag_dest (GtkWidget *object)
gtk_signal_connect (GTK_OBJECT (object), "drag_drop",
GTK_SIGNAL_FUNC (toolbox_drag_drop),
NULL);
gimp_dnd_tool_dest_set (object, toolbox_drop_tool, NULL);
}
static void
@ -1171,6 +1178,14 @@ toolbox_drag_drop (GtkWidget *widget,
return return_val;
}
static void
toolbox_drop_tool (GtkWidget *widget,
ToolType tool,
gpointer data)
{
gimp_context_set_tool (gimp_context_get_user (), tool);
}
static void
gimp_dnd_open_files (gchar *buffer)
{

View File

@ -99,7 +99,7 @@ static GimpItemFactoryEntry toolbox_entries[] =
"file/dialogs/palette_selection.html", NULL },
{ { N_("/File/Dialogs/Indexed Palette..."), NULL, dialogs_indexed_palette_cmd_callback, 0 },
"file/dialogs/indexed_palette.html", NULL },
{ { N_("/File/Dialogs/Gradients..."), "<control>G", dialogs_gradient_editor_cmd_callback, 0 },
{ { N_("/File/Dialogs/Gradients..."), "<control>G", dialogs_gradient_cmd_callback, 0 },
"file/dialogs/gradient_selection.html", NULL },
{ { N_("/File/Dialogs/Layers & Channels..."), "<control>L", dialogs_lc_cmd_callback, 0 },
"file/dialogs/layers_and_channels.html", NULL },
@ -395,7 +395,7 @@ static GimpItemFactoryEntry image_entries[] =
"dialogs/palette_selection.html", NULL },
{ { N_("/Dialogs/Indexed Palette..."), NULL, dialogs_indexed_palette_cmd_callback, 0 },
"dialogs/indexed_palette.html", NULL },
{ { N_("/Dialogs/Gradients..."), "<control>G", dialogs_gradient_editor_cmd_callback, 0 },
{ { N_("/Dialogs/Gradients..."), "<control>G", dialogs_gradient_cmd_callback, 0 },
"dialogs/gradient_selection.html", NULL },
{ { N_("/Dialogs/Layers & Channels..."), "<control>L", dialogs_lc_cmd_callback, 0 },
"dialogs/layers_and_channels.html", NULL },
@ -729,16 +729,13 @@ menus_tools_create (ToolInfo *tool_info)
{
GimpItemFactoryEntry entry;
entry.entry.path = tool_info->menu_path;
entry.entry.accelerator = tool_info->menu_accel;
entry.entry.callback = tools_select_cmd_callback;
entry.entry.path = tool_info->menu_path;
entry.entry.accelerator = tool_info->menu_accel;
entry.entry.callback = tools_select_cmd_callback;
entry.entry.callback_action = tool_info->tool_id;
entry.entry.item_type = NULL;
entry.help_page = g_strconcat ("tools/",
tool_info->private_tip,
".html",
NULL);
entry.description = NULL;
entry.entry.item_type = NULL;
entry.help_page = tool_info->private_tip;
entry.description = NULL;
menus_create_item (image_factory,
&entry,

View File

@ -99,7 +99,7 @@ static GimpItemFactoryEntry toolbox_entries[] =
"file/dialogs/palette_selection.html", NULL },
{ { N_("/File/Dialogs/Indexed Palette..."), NULL, dialogs_indexed_palette_cmd_callback, 0 },
"file/dialogs/indexed_palette.html", NULL },
{ { N_("/File/Dialogs/Gradients..."), "<control>G", dialogs_gradient_editor_cmd_callback, 0 },
{ { N_("/File/Dialogs/Gradients..."), "<control>G", dialogs_gradient_cmd_callback, 0 },
"file/dialogs/gradient_selection.html", NULL },
{ { N_("/File/Dialogs/Layers & Channels..."), "<control>L", dialogs_lc_cmd_callback, 0 },
"file/dialogs/layers_and_channels.html", NULL },
@ -395,7 +395,7 @@ static GimpItemFactoryEntry image_entries[] =
"dialogs/palette_selection.html", NULL },
{ { N_("/Dialogs/Indexed Palette..."), NULL, dialogs_indexed_palette_cmd_callback, 0 },
"dialogs/indexed_palette.html", NULL },
{ { N_("/Dialogs/Gradients..."), "<control>G", dialogs_gradient_editor_cmd_callback, 0 },
{ { N_("/Dialogs/Gradients..."), "<control>G", dialogs_gradient_cmd_callback, 0 },
"dialogs/gradient_selection.html", NULL },
{ { N_("/Dialogs/Layers & Channels..."), "<control>L", dialogs_lc_cmd_callback, 0 },
"dialogs/layers_and_channels.html", NULL },
@ -729,16 +729,13 @@ menus_tools_create (ToolInfo *tool_info)
{
GimpItemFactoryEntry entry;
entry.entry.path = tool_info->menu_path;
entry.entry.accelerator = tool_info->menu_accel;
entry.entry.callback = tools_select_cmd_callback;
entry.entry.path = tool_info->menu_path;
entry.entry.accelerator = tool_info->menu_accel;
entry.entry.callback = tools_select_cmd_callback;
entry.entry.callback_action = tool_info->tool_id;
entry.entry.item_type = NULL;
entry.help_page = g_strconcat ("tools/",
tool_info->private_tip,
".html",
NULL);
entry.description = NULL;
entry.entry.item_type = NULL;
entry.help_page = tool_info->private_tip;
entry.description = NULL;
menus_create_item (image_factory,
&entry,

View File

@ -94,7 +94,7 @@
#include "general.h"
#include "gimage.h"
#include "gimprc.h"
#include "gradient.h"
#include "gradient_select.h"
#include "interface.h"
#include "menus.h"
#include "pattern_select.h" /* Needed for closing pattern dialogs */

View File

@ -38,8 +38,8 @@
#include "gimpdnd.h"
#include "gimprc.h"
#include "gimpui.h"
#include "gradient.h"
#include "gradient_header.h"
#include "gradient_select.h"
#include "palette.h"
#include "paletteP.h"
#include "palette_entries.h"
@ -179,12 +179,12 @@ palette_init_palettes (gint no_data)
void
palettes_free (void)
{
PaletteEntries *entries;
GSList *list;
PaletteEntriesP entries;
for (list = palette_entries_list; list; list = g_slist_next (list))
{
entries = (PaletteEntriesP) list->data;
entries = (PaletteEntries *) list->data;
/* If the palette has been changed, save it, if possible */
if (entries->changed)
@ -1125,7 +1125,7 @@ static void
palette_dialog_delete_entry_callback (GtkWidget *widget,
gpointer data)
{
PaletteEntryP entry;
PaletteEntry *entry;
PaletteDialog *palette;
GSList *tmp_link;
gint pos = 0;
@ -1471,7 +1471,7 @@ palette_dialog_draw_entries (PaletteDialog *palette,
gint row_start,
gint column_highlight)
{
PaletteEntryP entry;
PaletteEntry *entry;
guchar *buffer;
guchar **colors;
GSList *tmp_link;
@ -1802,13 +1802,13 @@ palette_dialog_merge_entries_callback (GtkWidget *widget,
row = GPOINTER_TO_INT (sel_list->data);
p_entries =
(PaletteEntriesP) gtk_clist_get_row_data (GTK_CLIST (palette->clist), row);
(PaletteEntries *) gtk_clist_get_row_data (GTK_CLIST (palette->clist), row);
/* Go through each palette and merge the colors */
cols = p_entries->colors;
while (cols)
{
PaletteEntryP entry = cols->data;
PaletteEntry *entry = cols->data;
palette_entries_add_entry (new_entries,
entry->name,
entry->color[0],
@ -2239,7 +2239,7 @@ palette_import_select_grad_callback (GtkWidget *widget,
gpointer data)
{
/* Popup grad edit box .... */
grad_create_gradient_editor ();
gradient_dialog_create ();
}
static void
@ -2837,8 +2837,8 @@ static void
palette_import_image_make_palette (GHashTable *h_array,
guchar *name)
{
GSList * sorted_list = NULL;
PaletteEntriesP entries;
PaletteEntries *entries;
GSList *sorted_list = NULL;
g_hash_table_foreach (h_array, palette_import_create_sorted_list,
&sorted_list);
@ -2946,8 +2946,8 @@ static void
palette_import_create_from_indexed (GImage *gimage,
guchar *pname)
{
PaletteEntries *entries;
gint samples, count;
PaletteEntriesP entries;
samples = (gint) import_dialog->sample->value;

View File

@ -20,7 +20,7 @@
#include <gtk/gtk.h>
typedef struct _PaletteEntries PaletteEntries, *PaletteEntriesP;
typedef struct _PaletteEntries PaletteEntries;
struct _PaletteEntries
{
@ -32,7 +32,7 @@ struct _PaletteEntries
GdkPixmap *pixmap;
};
typedef struct _PaletteEntry PaletteEntry, *PaletteEntryP;
typedef struct _PaletteEntry PaletteEntry;
struct _PaletteEntry
{

View File

@ -41,7 +41,7 @@ palette_new_selection (gchar *title,
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *scrolled_win;
PaletteEntriesP p_entries = NULL;
PaletteEntries *p_entries = NULL;
gint select_pos;
palette_select_palette_init ();
@ -105,7 +105,7 @@ palette_new_selection (gchar *title,
{
for (list = palette_entries_list; list; list = g_slist_next (list))
{
p_entries = (PaletteEntriesP) list->data;
p_entries = (PaletteEntries *) list->data;
if (strcmp (p_entries->name, initial_palette) > 0)
break;
@ -137,16 +137,16 @@ palette_new_selection (gchar *title,
}
void
palette_select_clist_insert_all (PaletteEntriesP p_entries)
palette_select_clist_insert_all (PaletteEntries *p_entries)
{
PaletteEntriesP chk_entries;
PaletteEntries *chk_entries;
PaletteSelect *psp;
GSList *list;
gint pos = 0;
for (list = palette_entries_list; list; list = g_slist_next (list))
{
chk_entries = (PaletteEntriesP) list->data;
chk_entries = (PaletteEntries *) list->data;
/* to make sure we get something! */
if (chk_entries == NULL)
@ -169,9 +169,9 @@ palette_select_clist_insert_all (PaletteEntriesP p_entries)
}
void
palette_select_set_text_all (PaletteEntriesP entries)
palette_select_set_text_all (PaletteEntries *entries)
{
PaletteEntriesP p_entries = NULL;
PaletteEntries *p_entries = NULL;
PaletteSelect *psp;
GSList *list;
gchar *num_buf;
@ -179,7 +179,7 @@ palette_select_set_text_all (PaletteEntriesP entries)
for (list = palette_entries_list; list; list = g_slist_next (list))
{
p_entries = (PaletteEntriesP) list->data;
p_entries = (PaletteEntries *) list->data;
if (p_entries == entries)
break;
@ -225,7 +225,7 @@ static void
palette_select_edit_callback (GtkWidget *widget,
gpointer data)
{
PaletteEntriesP p_entries = NULL;
PaletteEntries *p_entries = NULL;
PaletteSelect *psp = (PaletteSelect *) data;
GList *sel_list;
@ -238,7 +238,7 @@ palette_select_edit_callback (GtkWidget *widget,
row = GPOINTER_TO_INT (sel_list->data);
p_entries =
(PaletteEntriesP) gtk_clist_get_row_data (GTK_CLIST (psp->clist), row);
(PaletteEntries *) gtk_clist_get_row_data (GTK_CLIST (psp->clist), row);
palette_create_edit (p_entries);

View File

@ -21,7 +21,7 @@
#define SM_PREVIEW_WIDTH (96 + 2)
#define SM_PREVIEW_HEIGHT (33 + 2)
typedef struct _PaletteSelect PaletteSelect, *PaletteSelectP;
typedef struct _PaletteSelect PaletteSelect;
struct _PaletteSelect
{
@ -34,8 +34,8 @@ struct _PaletteSelect
PaletteSelect * palette_new_selection (gchar *title,
gchar *initial_palette);
void palette_select_clist_insert_all (PaletteEntriesP p_entries);
void palette_select_set_text_all (PaletteEntriesP entries);
void palette_select_clist_insert_all (PaletteEntries *p_entries);
void palette_select_set_text_all (PaletteEntries *entries);
void palette_select_refresh_all (void);
#endif /* __PALETTE_SELECT_H__ */

View File

@ -20,6 +20,7 @@
#include "appenv.h"
#include "dialog_handler.h"
#include "gimpcontext.h"
#include "gimpdnd.h"
#include "gimpui.h"
#include "patterns.h"
#include "pattern_select.h"
@ -47,6 +48,12 @@
GDK_ENTER_NOTIFY_MASK
/* local function prototypes */
static void pattern_change_callbacks (PatternSelect *psp,
gboolean closing);
static void pattern_select_drop_pattern (GtkWidget *widget,
GPattern *pattern,
gpointer data);
static void pattern_select_pattern_changed (GimpContext *context,
GPattern *pattern,
PatternSelect *psp);
@ -77,6 +84,14 @@ static void pattern_select_scroll_update (GtkAdjustment *, gpointer);
static void pattern_select_close_callback (GtkWidget *, gpointer);
static void pattern_select_refresh_callback (GtkWidget *, gpointer);
/* dnd stuff */
static GtkTargetEntry preview_target_table[] =
{
GIMP_TARGET_PATTERN
};
static guint preview_n_targets = (sizeof (preview_target_table) /
sizeof (preview_target_table[0]));
/* The main pattern selection dialog */
PatternSelect *pattern_select_dialog = NULL;
@ -90,15 +105,10 @@ pattern_dialog_create (void)
{
if (! pattern_select_dialog)
{
/* Create the dialog... */
pattern_select_dialog = pattern_select_new (NULL, NULL);
/* register this one only */
dialog_register (pattern_select_dialog->shell);
}
else
{
/* Popup the dialog */
if (!GTK_WIDGET_VISIBLE (pattern_select_dialog->shell))
gtk_widget_show (pattern_select_dialog->shell);
else
@ -111,6 +121,9 @@ pattern_dialog_free ()
{
if (pattern_select_dialog)
{
session_get_window_info (pattern_select_dialog->shell,
&pattern_select_session_info);
pattern_select_free (pattern_select_dialog);
pattern_select_dialog = NULL;
}
@ -130,6 +143,8 @@ pattern_select_new (gchar *title,
GPattern *active = NULL;
static gboolean first_call = TRUE;
psp = g_new (PatternSelect, 1);
psp->preview = NULL;
psp->callback_name = NULL;
@ -161,15 +176,18 @@ pattern_select_new (gchar *title,
}
else
{
psp->context = gimp_context_get_user ();
session_set_window_geometry (psp->shell, &pattern_select_session_info,
TRUE);
psp->context = gimp_context_get_user ();
dialog_register (psp->shell);
}
if (no_data)
if (no_data && first_call)
patterns_init (FALSE);
first_call = FALSE;
if (title && initial_pattern && strlen (initial_pattern))
{
active = pattern_list_get_pattern (pattern_list, initial_pattern);
@ -247,6 +265,13 @@ pattern_select_new (gchar *title,
GTK_SIGNAL_FUNC (pattern_select_resize),
psp);
/* dnd stuff */
gtk_drag_dest_set (psp->preview,
GTK_DEST_DEFAULT_ALL,
preview_target_table, preview_n_targets,
GDK_ACTION_COPY);
gimp_dnd_pattern_dest_set (psp->preview, pattern_select_drop_pattern, psp);
gtk_container_add (GTK_CONTAINER (frame), psp->preview);
gtk_widget_show (psp->preview);
@ -282,12 +307,6 @@ pattern_select_free (PatternSelect *psp)
/* remove from active list */
pattern_active_dialogs = g_slist_remove (pattern_active_dialogs, psp);
/* Only main one is saved */
if (psp == pattern_select_dialog)
{
session_get_window_info (psp->shell, &pattern_select_session_info);
}
gtk_signal_disconnect_by_data (GTK_OBJECT (psp->context), psp);
if (psp->pattern_popup != NULL)
@ -307,9 +326,9 @@ pattern_select_free (PatternSelect *psp)
/* Call this dialog's PDB callback */
void
static void
pattern_change_callbacks (PatternSelect *psp,
gint closing)
gboolean closing)
{
gchar *name;
ProcRecord *prec = NULL;
@ -335,13 +354,13 @@ pattern_change_callbacks (PatternSelect *psp,
return_vals =
procedural_db_run_proc (name,
&nreturn_vals,
PDB_STRING, pattern->name,
PDB_INT32, pattern->mask->width,
PDB_INT32, pattern->mask->height,
PDB_INT32, pattern->mask->bytes,
PDB_INT32, pattern->mask->bytes*pattern->mask->height*pattern->mask->width,
PDB_STRING, pattern->name,
PDB_INT32, pattern->mask->width,
PDB_INT32, pattern->mask->height,
PDB_INT32, pattern->mask->bytes,
PDB_INT32, pattern->mask->bytes*pattern->mask->height*pattern->mask->width,
PDB_INT8ARRAY, temp_buf_data (pattern->mask),
PDB_INT32, closing,
PDB_INT32, (gint) closing,
PDB_END);
if (!return_vals || return_vals[0].value.pdb_int != PDB_SUCCESS)
@ -367,7 +386,7 @@ patterns_check_dialogs (void)
while (list)
{
psp = (PatternSelect *) list->data;
list = list->next;
list = g_slist_next (list);
name = psp->callback_name;
@ -388,6 +407,18 @@ patterns_check_dialogs (void)
* Local functions
*/
static void
pattern_select_drop_pattern (GtkWidget *widget,
GPattern *pattern,
gpointer data)
{
PatternSelect *psp;
psp = (PatternSelect *) data;
gimp_context_set_pattern (psp->context, pattern);
}
static void
pattern_select_pattern_changed (GimpContext *context,
GPattern *pattern,
@ -402,13 +433,30 @@ pattern_select_select (PatternSelect *psp,
gint index)
{
gint row, col;
gint scroll_offset = 0;
update_active_pattern_field (psp);
row = index / psp->NUM_PATTERN_COLUMNS;
col = index - row * psp->NUM_PATTERN_COLUMNS;
pattern_select_show_selected (psp, row, col);
/* check if the new active pattern is already in the preview */
if (((row + 1) * psp->cell_height) >
(psp->preview->allocation.height + psp->scroll_offset))
{
scroll_offset = (((row + 1) * psp->cell_height) -
(psp->scroll_offset + psp->preview->allocation.height));
}
else if ((row * psp->cell_height) < psp->scroll_offset)
{
scroll_offset = (row * psp->cell_height) - psp->scroll_offset;
}
else
{
pattern_select_show_selected (psp, row, col);
}
gtk_adjustment_set_value (psp->sbar_data, psp->scroll_offset + scroll_offset);
}
typedef struct
@ -777,6 +825,7 @@ preview_calc_scrollbar (PatternSelect *psp)
psp->sbar_data->page_increment = (page_size >> 1);
psp->sbar_data->step_increment = psp->cell_width;
gtk_signal_emit_by_name (GTK_OBJECT (psp->sbar_data), "changed");
gtk_signal_emit_by_name (GTK_OBJECT (psp->sbar_data), "value_changed");
}
@ -889,7 +938,7 @@ pattern_select_events (GtkWidget *widget,
pattern_popup_close (psp);
/* Call any callbacks registered */
pattern_change_callbacks (psp, 0);
pattern_change_callbacks (psp, FALSE);
}
break;
@ -946,7 +995,7 @@ pattern_select_close_callback (GtkWidget *widget,
if (psp != pattern_select_dialog)
{
/* Send data back */
pattern_change_callbacks (psp, 1);
pattern_change_callbacks (psp, TRUE);
gtk_widget_destroy (psp->shell);
pattern_select_free (psp);
}

View File

@ -69,8 +69,6 @@ PatternSelect * pattern_select_new (gchar *title,
void pattern_select_free (PatternSelect *psp);
void pattern_change_callbacks (PatternSelect *psp,
gint closing);
void patterns_check_dialogs (void);
/* the main pattern selection */

View File

@ -94,7 +94,7 @@
#include "general.h"
#include "gimage.h"
#include "gimprc.h"
#include "gradient.h"
#include "gradient_select.h"
#include "interface.h"
#include "menus.h"
#include "pattern_select.h" /* Needed for closing pattern dialogs */

View File

@ -94,7 +94,7 @@
#include "general.h"
#include "gimage.h"
#include "gimprc.h"
#include "gradient.h"
#include "gradient_select.h"
#include "interface.h"
#include "menus.h"
#include "pattern_select.h" /* Needed for closing pattern dialogs */

View File

@ -94,7 +94,7 @@
#include "general.h"
#include "gimage.h"
#include "gimprc.h"
#include "gradient.h"
#include "gradient_select.h"
#include "interface.h"
#include "menus.h"
#include "pattern_select.h" /* Needed for closing pattern dialogs */

View File

@ -94,7 +94,7 @@
#include "general.h"
#include "gimage.h"
#include "gimprc.h"
#include "gradient.h"
#include "gradient_select.h"
#include "interface.h"
#include "menus.h"
#include "pattern_select.h" /* Needed for closing pattern dialogs */

View File

@ -94,7 +94,7 @@
#include "general.h"
#include "gimage.h"
#include "gimprc.h"
#include "gradient.h"
#include "gradient_select.h"
#include "interface.h"
#include "menus.h"
#include "pattern_select.h" /* Needed for closing pattern dialogs */

View File

@ -94,7 +94,7 @@
#include "general.h"
#include "gimage.h"
#include "gimprc.h"
#include "gradient.h"
#include "gradient_select.h"
#include "interface.h"
#include "menus.h"
#include "pattern_select.h" /* Needed for closing pattern dialogs */

View File

@ -94,7 +94,7 @@
#include "general.h"
#include "gimage.h"
#include "gimprc.h"
#include "gradient.h"
#include "gradient_select.h"
#include "interface.h"
#include "menus.h"
#include "pattern_select.h" /* Needed for closing pattern dialogs */

View File

@ -94,7 +94,7 @@
#include "general.h"
#include "gimage.h"
#include "gimprc.h"
#include "gradient.h"
#include "gradient_select.h"
#include "interface.h"
#include "menus.h"
#include "pattern_select.h" /* Needed for closing pattern dialogs */

View File

@ -94,7 +94,7 @@
#include "general.h"
#include "gimage.h"
#include "gimprc.h"
#include "gradient.h"
#include "gradient_select.h"
#include "interface.h"
#include "menus.h"
#include "pattern_select.h" /* Needed for closing pattern dialogs */

View File

@ -94,7 +94,7 @@
#include "general.h"
#include "gimage.h"
#include "gimprc.h"
#include "gradient.h"
#include "gradient_select.h"
#include "interface.h"
#include "menus.h"
#include "pattern_select.h" /* Needed for closing pattern dialogs */

View File

@ -94,7 +94,7 @@
#include "general.h"
#include "gimage.h"
#include "gimprc.h"
#include "gradient.h"
#include "gradient_select.h"
#include "interface.h"
#include "menus.h"
#include "pattern_select.h" /* Needed for closing pattern dialogs */

View File

@ -94,7 +94,7 @@
#include "general.h"
#include "gimage.h"
#include "gimprc.h"
#include "gradient.h"
#include "gradient_select.h"
#include "interface.h"
#include "menus.h"
#include "pattern_select.h" /* Needed for closing pattern dialogs */

View File

@ -94,7 +94,7 @@
#include "general.h"
#include "gimage.h"
#include "gimprc.h"
#include "gradient.h"
#include "gradient_select.h"
#include "interface.h"
#include "menus.h"
#include "pattern_select.h" /* Needed for closing pattern dialogs */

View File

@ -94,7 +94,7 @@
#include "general.h"
#include "gimage.h"
#include "gimprc.h"
#include "gradient.h"
#include "gradient_select.h"
#include "interface.h"
#include "menus.h"
#include "pattern_select.h" /* Needed for closing pattern dialogs */

View File

@ -94,7 +94,7 @@
#include "general.h"
#include "gimage.h"
#include "gimprc.h"
#include "gradient.h"
#include "gradient_select.h"
#include "interface.h"
#include "menus.h"
#include "pattern_select.h" /* Needed for closing pattern dialogs */

View File

@ -94,7 +94,7 @@
#include "general.h"
#include "gimage.h"
#include "gimprc.h"
#include "gradient.h"
#include "gradient_select.h"
#include "interface.h"
#include "menus.h"
#include "pattern_select.h" /* Needed for closing pattern dialogs */

View File

@ -16,7 +16,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* Session-managment stuff Copyright (C) 1998 Sven Neumann <sven@gimp.org>
I include a short description here on what is done and what problems
@ -57,8 +56,8 @@
#include "libgimp/gimpintl.h"
#include "libgimp/gimpenv.h"
static void sessionrc_write_info (SessionInfo *, FILE *);
static void session_open_dialog (SessionInfo *);
static void sessionrc_write_info (SessionInfo *, FILE *);
static void session_open_dialog (SessionInfo *);
static void session_reset_open_state (SessionInfo *);
GList *session_info_updates = NULL;
@ -79,7 +78,7 @@ SessionInfo brush_select_session_info =
SessionInfo pattern_select_session_info =
{ "pattern-select", (GtkItemFactoryCallback)dialogs_patterns_cmd_callback, 160, 180, 0, 0, FALSE };
SessionInfo gradient_select_session_info =
{ "gradient-editor", (GtkItemFactoryCallback)dialogs_gradient_editor_cmd_callback, 170, 180, 0, 0, FALSE };
{ "gradient-editor", (GtkItemFactoryCallback)dialogs_gradient_cmd_callback, 170, 180, 0, 0, FALSE };
SessionInfo device_status_session_info =
{ "device-status", (GtkItemFactoryCallback)dialogs_device_status_cmd_callback, 0, 600, 0, 0, FALSE };
SessionInfo error_console_session_info =

View File

@ -69,10 +69,10 @@
Tool * active_tool = NULL;
/* Local Data */
static GtkWidget *options_shell = NULL;
static GtkWidget *options_vbox = NULL;
static GtkWidget *options_label = NULL;
static GtkWidget *options_reset_button = NULL;
static GtkWidget * options_shell = NULL;
static GtkWidget * options_vbox = NULL;
static GtkWidget * options_label = NULL;
static GtkWidget * options_reset_button = NULL;
static gint global_tool_ID = 0;
@ -86,7 +86,7 @@ ToolInfo tool_info[] =
"R",
(char **) rect_bits,
N_("Select rectangular regions"),
"rect_select",
"tools/rect_select.html",
RECT_SELECT,
tools_new_rect_select,
tools_free_rect_select,
@ -101,7 +101,7 @@ ToolInfo tool_info[] =
"E",
(char **) circ_bits,
N_("Select elliptical regions"),
"ellipse_select",
"tools/ellipse_select.html",
ELLIPSE_SELECT,
tools_new_ellipse_select,
tools_free_ellipse_select,
@ -116,7 +116,7 @@ ToolInfo tool_info[] =
"F",
(char **) free_bits,
N_("Select hand-drawn regions"),
"free_select",
"tools/free_select.html",
FREE_SELECT,
tools_new_free_select,
tools_free_free_select,
@ -131,7 +131,7 @@ ToolInfo tool_info[] =
"Z",
(char **) fuzzy_bits,
N_("Select contiguous regions"),
"fuzzy_select",
"tools/fuzzy_select.html",
FUZZY_SELECT,
tools_new_fuzzy_select,
tools_free_fuzzy_select,
@ -146,7 +146,7 @@ ToolInfo tool_info[] =
"B",
(char **) bezier_bits,
N_("Select regions using Bezier curves"),
"bezier_select",
"tools/bezier_select.html",
BEZIER_SELECT,
tools_new_bezier_select,
tools_free_bezier_select,
@ -161,7 +161,7 @@ ToolInfo tool_info[] =
"I",
(char **) iscissors_bits,
N_("Select shapes from image"),
"intelligent_scissors",
"tools/intelligent_scissors.html",
ISCISSORS,
tools_new_iscissors,
tools_free_iscissors,
@ -176,7 +176,7 @@ ToolInfo tool_info[] =
"M",
(char **) move_bits,
N_("Move layers & selections"),
"move",
"tools/move.html",
MOVE,
tools_new_move_tool,
tools_free_move_tool,
@ -191,7 +191,7 @@ ToolInfo tool_info[] =
"<shift>M",
(char **) magnify_bits,
N_("Zoom in & out"),
"magnify",
"tools/magnify.html",
MAGNIFY,
tools_new_magnify,
tools_free_magnify,
@ -206,7 +206,7 @@ ToolInfo tool_info[] =
"<shift>C",
(char **) crop_bits,
N_("Crop or resize the image"),
"crop",
"tools/crop.html",
CROP,
tools_new_crop,
tools_free_crop,
@ -221,7 +221,7 @@ ToolInfo tool_info[] =
"<shift>T",
(char **) scale_bits,
N_("Transform the layer or selection"),
"transform",
"tools/transform.html",
ROTATE,
tools_new_transform_tool,
tools_free_transform_tool,
@ -235,8 +235,8 @@ ToolInfo tool_info[] =
NULL,
NULL,
NULL,
NULL,
"transform",
N_("Transform the layer or selection"),
"tools/transform.html",
SCALE,
tools_new_transform_tool,
tools_free_transform_tool,
@ -250,8 +250,8 @@ ToolInfo tool_info[] =
NULL,
NULL,
NULL,
NULL,
"transform",
N_("Transform the layer or selection"),
"tools/transform.html",
SHEAR,
tools_new_transform_tool,
tools_free_transform_tool,
@ -265,8 +265,8 @@ ToolInfo tool_info[] =
NULL,
NULL,
NULL,
NULL,
"transform",
N_("Transform the layer or selection"),
"tools/transform.html",
PERSPECTIVE,
tools_new_transform_tool,
tools_free_transform_tool,
@ -281,7 +281,7 @@ ToolInfo tool_info[] =
"<shift>F",
(char **) flip_bits,
N_("Flip the layer or selection"),
"flip",
"tools/flip.html",
FLIP,
tools_new_flip,
tools_free_flip_tool,
@ -296,7 +296,7 @@ ToolInfo tool_info[] =
"T",
(char **) text_bits,
N_("Add text to the image"),
"text",
"tools/text.html",
TEXT,
tools_new_text,
tools_free_text,
@ -311,7 +311,7 @@ ToolInfo tool_info[] =
"O",
(char **) colorpicker_bits,
N_("Pick colors from the image"),
"color_picker",
"tools/color_picker.html",
COLOR_PICKER,
tools_new_color_picker,
tools_free_color_picker,
@ -326,7 +326,7 @@ ToolInfo tool_info[] =
"<shift>B",
(char **) fill_bits,
N_("Fill with a color or pattern"),
"bucket_fill",
"tools/bucket_fill.html",
BUCKET_FILL,
tools_new_bucket_fill,
tools_free_bucket_fill,
@ -341,7 +341,7 @@ ToolInfo tool_info[] =
"L",
(char **) gradient_bits,
N_("Fill with a color gradient"),
"blend",
"tools/blend.html",
BLEND,
tools_new_blend,
tools_free_blend,
@ -356,7 +356,7 @@ ToolInfo tool_info[] =
"<shift>P",
(char **) pencil_bits,
N_("Draw sharp pencil strokes"),
"pencil",
"tools/pencil.html",
PENCIL,
tools_new_pencil,
tools_free_pencil,
@ -371,7 +371,7 @@ ToolInfo tool_info[] =
"P",
(char **) paint_bits,
N_("Paint fuzzy brush strokes"),
"paintbrush",
"tools/paintbrush.html",
PAINTBRUSH,
tools_new_paintbrush,
tools_free_paintbrush,
@ -386,7 +386,7 @@ ToolInfo tool_info[] =
"<shift>E",
(char **) erase_bits,
N_("Erase to background or transparency"),
"eraser",
"tools/eraser.html",
ERASER,
tools_new_eraser,
tools_free_eraser,
@ -401,7 +401,7 @@ ToolInfo tool_info[] =
"A",
(char **) airbrush_bits,
N_("Airbrush with variable pressure"),
"airbrush",
"tools/airbrush.html",
AIRBRUSH,
tools_new_airbrush,
tools_free_airbrush,
@ -416,7 +416,7 @@ ToolInfo tool_info[] =
"C",
(char **) clone_bits,
N_("Paint using patterns or image regions"),
"clone",
"tools/clone.html",
CLONE,
tools_new_clone,
tools_free_clone,
@ -431,7 +431,7 @@ ToolInfo tool_info[] =
"V",
(char **) blur_bits,
N_("Blur or sharpen"),
"convolve",
"tools/convolve.html",
CONVOLVE,
tools_new_convolve,
tools_free_convolve,
@ -446,7 +446,7 @@ ToolInfo tool_info[] =
"K",
(char **) ink_bits,
N_("Draw in ink"),
"ink",
"tools/ink.html",
INK,
tools_new_ink,
tools_free_ink,
@ -461,7 +461,7 @@ ToolInfo tool_info[] =
"<shift>D",
(char **) dodge_bits,
N_("Dodge or Burn"),
"dodgeburn",
"tools/dodgeburn.html",
DODGEBURN,
tools_new_dodgeburn,
tools_free_dodgeburn,
@ -476,7 +476,7 @@ ToolInfo tool_info[] =
"<shift>S",
(char **) smudge_bits,
N_("Smudge"),
"smudge",
"tools/smudge.html",
SMUDGE,
tools_new_smudge,
tools_free_smudge,
@ -491,7 +491,7 @@ ToolInfo tool_info[] =
"",
(char **) measure_bits,
N_("Measure distances and angles"),
"measure",
"tools/measure.html",
MEASURE,
tools_new_measure_tool,
tools_free_measure_tool,
@ -506,7 +506,7 @@ ToolInfo tool_info[] =
"<shift>A",
(char **) xinput_airbrush_bits,
N_("Natural Airbrush"),
"xinput_airbrush",
"tools/xinput_airbrush.html",
XINPUT_AIRBRUSH,
tools_new_xinput_airbrush,
tools_free_xinput_airbrush,
@ -521,7 +521,7 @@ ToolInfo tool_info[] =
"",
(char **) path_tool_bits,
N_("Manipulate paths"),
"path",
"tools/path.html",
PATH_TOOL,
tools_new_path_tool,
tools_free_path_tool,
@ -537,8 +537,8 @@ ToolInfo tool_info[] =
N_("/Select/By Color..."),
NULL,
NULL,
NULL,
"by_color_select",
N_("Select regions by color"),
"tools/by_color_select.html",
BY_COLOR_SELECT,
tools_new_by_color_select,
tools_free_by_color_select,
@ -552,8 +552,8 @@ ToolInfo tool_info[] =
N_("/Image/Colors/Color Balance"),
NULL,
NULL,
NULL,
"color_balance",
N_("Adjust color balance"),
"tools/color_balance.html",
COLOR_BALANCE,
tools_new_color_balance,
tools_free_color_balance,
@ -567,8 +567,8 @@ ToolInfo tool_info[] =
N_("/Image/Colors/Brightness-Contrast"),
NULL,
NULL,
NULL,
"brightness_contrast",
N_("Adjust brightness and contrast"),
"tools/brightness_contrast.html",
BRIGHTNESS_CONTRAST,
tools_new_brightness_contrast,
tools_free_brightness_contrast,
@ -582,8 +582,8 @@ ToolInfo tool_info[] =
N_("/Image/Colors/Hue-Saturation"),
NULL,
NULL,
NULL,
"hue_saturation",
N_("Adjust hue and saturation"),
"tools/hue_saturation.html",
HUE_SATURATION,
tools_new_hue_saturation,
tools_free_hue_saturation,
@ -597,8 +597,8 @@ ToolInfo tool_info[] =
N_("/Image/Colors/Posterize"),
NULL,
NULL,
NULL,
"posterize",
N_("Reduce image to a fixed numer of colors"),
"tools/posterize.html",
POSTERIZE,
tools_new_posterize,
tools_free_posterize,
@ -612,8 +612,8 @@ ToolInfo tool_info[] =
N_("/Image/Colors/Threshold"),
NULL,
NULL,
NULL,
"threshold",
N_("Reduce image to two colors using a threshold"),
"tools/threshold.html",
THRESHOLD,
tools_new_threshold,
tools_free_threshold,
@ -627,8 +627,8 @@ ToolInfo tool_info[] =
N_("/Image/Colors/Curves"),
NULL,
NULL,
NULL,
"curves",
N_("Adjust color curves"),
"tools/curves.html",
CURVES,
tools_new_curves,
tools_free_curves,
@ -642,8 +642,8 @@ ToolInfo tool_info[] =
N_("/Image/Colors/Levels"),
NULL,
NULL,
NULL,
"levels",
N_("Adjust color levels"),
"tools/levels.html",
LEVELS,
tools_new_levels,
tools_free_levels,
@ -657,8 +657,8 @@ ToolInfo tool_info[] =
N_("/Image/Histogram"),
NULL,
NULL,
NULL,
"histogram",
N_("View image historgam"),
"tools/histogram.html",
HISTOGRAM,
tools_new_histogram_tool,
tools_free_histogram_tool,
@ -686,7 +686,7 @@ active_tool_free (void)
tools_options_hide (active_tool->type);
(* tool_info[(int) active_tool->type].free_func) (active_tool);
(* tool_info[(gint) active_tool->type].free_func) (active_tool);
g_free (active_tool);
active_tool = NULL;
@ -698,7 +698,7 @@ tools_select (ToolType tool_type)
if (active_tool)
active_tool_free ();
active_tool = (* tool_info[(int) tool_type].new_func) ();
active_tool = (* tool_info[(gint) tool_type].new_func) ();
tools_options_show (active_tool->type);
}
@ -710,14 +710,14 @@ tools_initialize (ToolType tool_type,
/* Tools which have an init function have dialogs and
* cannot be initialized without a display
*/
if (tool_info[(int) tool_type].init_func && !gdisp)
if (tool_info[(gint) tool_type].init_func && !gdisp)
tool_type = RECT_SELECT;
gimp_context_set_tool (gimp_context_get_user (), tool_type);
if (tool_info[(int) tool_type].init_func)
if (tool_info[(gint) tool_type].init_func)
{
(* tool_info[(int) tool_type].init_func) (gdisp);
(* tool_info[(gint) tool_type].init_func) (gdisp);
active_tool->drawable = gimage_active_drawable (gdisp->gimage);
}
@ -726,7 +726,7 @@ tools_initialize (ToolType tool_type,
}
void
tools_options_dialog_show ()
tools_options_dialog_show (void)
{
if (!GTK_WIDGET_VISIBLE (options_shell))
{
@ -894,7 +894,7 @@ tools_new_tool (ToolType tool_type)
/* Tool options function */
void
tools_options_dialog_new ()
tools_options_dialog_new (void)
{
GtkWidget *frame;
GtkWidget *vbox;
@ -951,7 +951,7 @@ tools_options_dialog_new ()
}
void
tools_options_dialog_free ()
tools_options_dialog_free (void)
{
session_get_window_info (options_shell, &tool_options_session_info);
gtk_widget_destroy (options_shell);
@ -960,13 +960,7 @@ tools_options_dialog_free ()
void
tools_help_func (gpointer help_data)
{
gchar *help_page;
help_page = g_strdup_printf ("tools/%s.html",
tool_info[(int) active_tool->type].private_tip);
gimp_help (help_page);
g_free (help_page);
gimp_help (tool_info[(gint) active_tool->type].private_tip);
}
void
@ -1033,7 +1027,7 @@ tools_options_reset_callback (GtkWidget *widget,
shell = (GtkWidget *) data;
if (! active_tool)
if (!active_tool)
return;
if (tool_info[(int) active_tool->type].tool_options->reset_func)
@ -1041,16 +1035,18 @@ tools_options_reset_callback (GtkWidget *widget,
}
guchar *
tool_active_PDB_string()
tool_active_PDB_string (void)
{
guchar *toolStr = "gimp_paintbrush_default";
/* Return the correct PDB function for the active tool */
/* The default is paintbrush if the tool is not recognised */
if(!active_tool)
/* Return the correct PDB function for the active tool
* The default is paintbrush if the tool is not recognised
*/
if (!active_tool)
return toolStr;
switch(active_tool->type)
switch (gimp_context_get_tool (gimp_context_get_user ()))
{
case PENCIL:
toolStr = "gimp_pencil";
@ -1079,5 +1075,6 @@ tool_active_PDB_string()
default:
toolStr = "gimp_paintbrush_default";
}
return toolStr;
}

View File

@ -44,19 +44,19 @@ typedef enum
struct _Tool
{
/* Data */
ToolType type; /* Tool type */
gint ID; /* unique tool ID */
ToolType type; /* Tool type */
gint ID; /* unique tool ID */
ToolState state; /* state of tool activity */
gint paused_count; /* paused control count */
gboolean scroll_lock; /* allow scrolling or not */
gboolean auto_snap_to; /* snap to guides automatically */
ToolState state; /* state of tool activity */
gint paused_count; /* paused control count */
gboolean scroll_lock; /* allow scrolling or not */
gboolean auto_snap_to; /* snap to guides automatically */
gboolean preserve; /* Preserve this tool across drawable changes */
void * gdisp_ptr; /* pointer to currently active gdisp */
void * drawable; /* pointer to the tool's current drawable */
gboolean preserve; /* Preserve this tool across drawable changes */
void *gdisp_ptr; /* pointer to currently active gdisp */
void *drawable; /* pointer to the tool's current drawable */
void * private; /* Tool-specific information */
void *private; /* Tool-specific information */
/* Action functions */
ButtonPressFunc button_press_func;
@ -72,19 +72,19 @@ struct _ToolInfo
{
ToolOptions *tool_options;
char *tool_name;
gchar *tool_name;
int toolbar_position;
gint toolbar_position;
char *menu_path;
char *menu_accel;
gchar *menu_path;
gchar *menu_accel;
char **icon_data;
gchar **icon_data;
char *tool_desc;
char *private_tip;
gchar *tool_desc;
gchar *private_tip;
gint tool_id;
ToolType tool_id;
ToolInfoNewFunc new_func;
ToolInfoFreeFunc free_func;
@ -101,24 +101,24 @@ extern ToolInfo tool_info[];
extern gint num_tools;
/* Function declarations */
Tool * tools_new_tool (ToolType tool_type);
Tool * tools_new_tool (ToolType tool_type);
void tools_select (ToolType tool_type);
void tools_initialize (ToolType tool_type,
GDisplay *gdisplay);
void tools_select (ToolType tool_type);
void tools_initialize (ToolType tool_type,
GDisplay *gdisplay);
void tools_options_dialog_new (void);
void tools_options_dialog_show (void);
void tools_options_dialog_free (void);
void tools_options_dialog_new (void);
void tools_options_dialog_show (void);
void tools_options_dialog_free (void);
void tools_help_func (gpointer);
void tools_help_func (gpointer);
void tools_register (ToolType tool_type,
ToolOptions *tool_options);
void tools_register (ToolType tool_type,
ToolOptions *tool_options);
void active_tool_control (ToolAction action,
void *gdisp_ptr);
void active_tool_control (ToolAction action,
void *gdisp_ptr);
guchar *tool_active_PDB_string (void);
guchar * tool_active_PDB_string (void);
#endif /* __TOOLS_H__ */

View File

@ -69,10 +69,10 @@
Tool * active_tool = NULL;
/* Local Data */
static GtkWidget *options_shell = NULL;
static GtkWidget *options_vbox = NULL;
static GtkWidget *options_label = NULL;
static GtkWidget *options_reset_button = NULL;
static GtkWidget * options_shell = NULL;
static GtkWidget * options_vbox = NULL;
static GtkWidget * options_label = NULL;
static GtkWidget * options_reset_button = NULL;
static gint global_tool_ID = 0;
@ -86,7 +86,7 @@ ToolInfo tool_info[] =
"R",
(char **) rect_bits,
N_("Select rectangular regions"),
"rect_select",
"tools/rect_select.html",
RECT_SELECT,
tools_new_rect_select,
tools_free_rect_select,
@ -101,7 +101,7 @@ ToolInfo tool_info[] =
"E",
(char **) circ_bits,
N_("Select elliptical regions"),
"ellipse_select",
"tools/ellipse_select.html",
ELLIPSE_SELECT,
tools_new_ellipse_select,
tools_free_ellipse_select,
@ -116,7 +116,7 @@ ToolInfo tool_info[] =
"F",
(char **) free_bits,
N_("Select hand-drawn regions"),
"free_select",
"tools/free_select.html",
FREE_SELECT,
tools_new_free_select,
tools_free_free_select,
@ -131,7 +131,7 @@ ToolInfo tool_info[] =
"Z",
(char **) fuzzy_bits,
N_("Select contiguous regions"),
"fuzzy_select",
"tools/fuzzy_select.html",
FUZZY_SELECT,
tools_new_fuzzy_select,
tools_free_fuzzy_select,
@ -146,7 +146,7 @@ ToolInfo tool_info[] =
"B",
(char **) bezier_bits,
N_("Select regions using Bezier curves"),
"bezier_select",
"tools/bezier_select.html",
BEZIER_SELECT,
tools_new_bezier_select,
tools_free_bezier_select,
@ -161,7 +161,7 @@ ToolInfo tool_info[] =
"I",
(char **) iscissors_bits,
N_("Select shapes from image"),
"intelligent_scissors",
"tools/intelligent_scissors.html",
ISCISSORS,
tools_new_iscissors,
tools_free_iscissors,
@ -176,7 +176,7 @@ ToolInfo tool_info[] =
"M",
(char **) move_bits,
N_("Move layers & selections"),
"move",
"tools/move.html",
MOVE,
tools_new_move_tool,
tools_free_move_tool,
@ -191,7 +191,7 @@ ToolInfo tool_info[] =
"<shift>M",
(char **) magnify_bits,
N_("Zoom in & out"),
"magnify",
"tools/magnify.html",
MAGNIFY,
tools_new_magnify,
tools_free_magnify,
@ -206,7 +206,7 @@ ToolInfo tool_info[] =
"<shift>C",
(char **) crop_bits,
N_("Crop or resize the image"),
"crop",
"tools/crop.html",
CROP,
tools_new_crop,
tools_free_crop,
@ -221,7 +221,7 @@ ToolInfo tool_info[] =
"<shift>T",
(char **) scale_bits,
N_("Transform the layer or selection"),
"transform",
"tools/transform.html",
ROTATE,
tools_new_transform_tool,
tools_free_transform_tool,
@ -235,8 +235,8 @@ ToolInfo tool_info[] =
NULL,
NULL,
NULL,
NULL,
"transform",
N_("Transform the layer or selection"),
"tools/transform.html",
SCALE,
tools_new_transform_tool,
tools_free_transform_tool,
@ -250,8 +250,8 @@ ToolInfo tool_info[] =
NULL,
NULL,
NULL,
NULL,
"transform",
N_("Transform the layer or selection"),
"tools/transform.html",
SHEAR,
tools_new_transform_tool,
tools_free_transform_tool,
@ -265,8 +265,8 @@ ToolInfo tool_info[] =
NULL,
NULL,
NULL,
NULL,
"transform",
N_("Transform the layer or selection"),
"tools/transform.html",
PERSPECTIVE,
tools_new_transform_tool,
tools_free_transform_tool,
@ -281,7 +281,7 @@ ToolInfo tool_info[] =
"<shift>F",
(char **) flip_bits,
N_("Flip the layer or selection"),
"flip",
"tools/flip.html",
FLIP,
tools_new_flip,
tools_free_flip_tool,
@ -296,7 +296,7 @@ ToolInfo tool_info[] =
"T",
(char **) text_bits,
N_("Add text to the image"),
"text",
"tools/text.html",
TEXT,
tools_new_text,
tools_free_text,
@ -311,7 +311,7 @@ ToolInfo tool_info[] =
"O",
(char **) colorpicker_bits,
N_("Pick colors from the image"),
"color_picker",
"tools/color_picker.html",
COLOR_PICKER,
tools_new_color_picker,
tools_free_color_picker,
@ -326,7 +326,7 @@ ToolInfo tool_info[] =
"<shift>B",
(char **) fill_bits,
N_("Fill with a color or pattern"),
"bucket_fill",
"tools/bucket_fill.html",
BUCKET_FILL,
tools_new_bucket_fill,
tools_free_bucket_fill,
@ -341,7 +341,7 @@ ToolInfo tool_info[] =
"L",
(char **) gradient_bits,
N_("Fill with a color gradient"),
"blend",
"tools/blend.html",
BLEND,
tools_new_blend,
tools_free_blend,
@ -356,7 +356,7 @@ ToolInfo tool_info[] =
"<shift>P",
(char **) pencil_bits,
N_("Draw sharp pencil strokes"),
"pencil",
"tools/pencil.html",
PENCIL,
tools_new_pencil,
tools_free_pencil,
@ -371,7 +371,7 @@ ToolInfo tool_info[] =
"P",
(char **) paint_bits,
N_("Paint fuzzy brush strokes"),
"paintbrush",
"tools/paintbrush.html",
PAINTBRUSH,
tools_new_paintbrush,
tools_free_paintbrush,
@ -386,7 +386,7 @@ ToolInfo tool_info[] =
"<shift>E",
(char **) erase_bits,
N_("Erase to background or transparency"),
"eraser",
"tools/eraser.html",
ERASER,
tools_new_eraser,
tools_free_eraser,
@ -401,7 +401,7 @@ ToolInfo tool_info[] =
"A",
(char **) airbrush_bits,
N_("Airbrush with variable pressure"),
"airbrush",
"tools/airbrush.html",
AIRBRUSH,
tools_new_airbrush,
tools_free_airbrush,
@ -416,7 +416,7 @@ ToolInfo tool_info[] =
"C",
(char **) clone_bits,
N_("Paint using patterns or image regions"),
"clone",
"tools/clone.html",
CLONE,
tools_new_clone,
tools_free_clone,
@ -431,7 +431,7 @@ ToolInfo tool_info[] =
"V",
(char **) blur_bits,
N_("Blur or sharpen"),
"convolve",
"tools/convolve.html",
CONVOLVE,
tools_new_convolve,
tools_free_convolve,
@ -446,7 +446,7 @@ ToolInfo tool_info[] =
"K",
(char **) ink_bits,
N_("Draw in ink"),
"ink",
"tools/ink.html",
INK,
tools_new_ink,
tools_free_ink,
@ -461,7 +461,7 @@ ToolInfo tool_info[] =
"<shift>D",
(char **) dodge_bits,
N_("Dodge or Burn"),
"dodgeburn",
"tools/dodgeburn.html",
DODGEBURN,
tools_new_dodgeburn,
tools_free_dodgeburn,
@ -476,7 +476,7 @@ ToolInfo tool_info[] =
"<shift>S",
(char **) smudge_bits,
N_("Smudge"),
"smudge",
"tools/smudge.html",
SMUDGE,
tools_new_smudge,
tools_free_smudge,
@ -491,7 +491,7 @@ ToolInfo tool_info[] =
"",
(char **) measure_bits,
N_("Measure distances and angles"),
"measure",
"tools/measure.html",
MEASURE,
tools_new_measure_tool,
tools_free_measure_tool,
@ -506,7 +506,7 @@ ToolInfo tool_info[] =
"<shift>A",
(char **) xinput_airbrush_bits,
N_("Natural Airbrush"),
"xinput_airbrush",
"tools/xinput_airbrush.html",
XINPUT_AIRBRUSH,
tools_new_xinput_airbrush,
tools_free_xinput_airbrush,
@ -521,7 +521,7 @@ ToolInfo tool_info[] =
"",
(char **) path_tool_bits,
N_("Manipulate paths"),
"path",
"tools/path.html",
PATH_TOOL,
tools_new_path_tool,
tools_free_path_tool,
@ -537,8 +537,8 @@ ToolInfo tool_info[] =
N_("/Select/By Color..."),
NULL,
NULL,
NULL,
"by_color_select",
N_("Select regions by color"),
"tools/by_color_select.html",
BY_COLOR_SELECT,
tools_new_by_color_select,
tools_free_by_color_select,
@ -552,8 +552,8 @@ ToolInfo tool_info[] =
N_("/Image/Colors/Color Balance"),
NULL,
NULL,
NULL,
"color_balance",
N_("Adjust color balance"),
"tools/color_balance.html",
COLOR_BALANCE,
tools_new_color_balance,
tools_free_color_balance,
@ -567,8 +567,8 @@ ToolInfo tool_info[] =
N_("/Image/Colors/Brightness-Contrast"),
NULL,
NULL,
NULL,
"brightness_contrast",
N_("Adjust brightness and contrast"),
"tools/brightness_contrast.html",
BRIGHTNESS_CONTRAST,
tools_new_brightness_contrast,
tools_free_brightness_contrast,
@ -582,8 +582,8 @@ ToolInfo tool_info[] =
N_("/Image/Colors/Hue-Saturation"),
NULL,
NULL,
NULL,
"hue_saturation",
N_("Adjust hue and saturation"),
"tools/hue_saturation.html",
HUE_SATURATION,
tools_new_hue_saturation,
tools_free_hue_saturation,
@ -597,8 +597,8 @@ ToolInfo tool_info[] =
N_("/Image/Colors/Posterize"),
NULL,
NULL,
NULL,
"posterize",
N_("Reduce image to a fixed numer of colors"),
"tools/posterize.html",
POSTERIZE,
tools_new_posterize,
tools_free_posterize,
@ -612,8 +612,8 @@ ToolInfo tool_info[] =
N_("/Image/Colors/Threshold"),
NULL,
NULL,
NULL,
"threshold",
N_("Reduce image to two colors using a threshold"),
"tools/threshold.html",
THRESHOLD,
tools_new_threshold,
tools_free_threshold,
@ -627,8 +627,8 @@ ToolInfo tool_info[] =
N_("/Image/Colors/Curves"),
NULL,
NULL,
NULL,
"curves",
N_("Adjust color curves"),
"tools/curves.html",
CURVES,
tools_new_curves,
tools_free_curves,
@ -642,8 +642,8 @@ ToolInfo tool_info[] =
N_("/Image/Colors/Levels"),
NULL,
NULL,
NULL,
"levels",
N_("Adjust color levels"),
"tools/levels.html",
LEVELS,
tools_new_levels,
tools_free_levels,
@ -657,8 +657,8 @@ ToolInfo tool_info[] =
N_("/Image/Histogram"),
NULL,
NULL,
NULL,
"histogram",
N_("View image historgam"),
"tools/histogram.html",
HISTOGRAM,
tools_new_histogram_tool,
tools_free_histogram_tool,
@ -686,7 +686,7 @@ active_tool_free (void)
tools_options_hide (active_tool->type);
(* tool_info[(int) active_tool->type].free_func) (active_tool);
(* tool_info[(gint) active_tool->type].free_func) (active_tool);
g_free (active_tool);
active_tool = NULL;
@ -698,7 +698,7 @@ tools_select (ToolType tool_type)
if (active_tool)
active_tool_free ();
active_tool = (* tool_info[(int) tool_type].new_func) ();
active_tool = (* tool_info[(gint) tool_type].new_func) ();
tools_options_show (active_tool->type);
}
@ -710,14 +710,14 @@ tools_initialize (ToolType tool_type,
/* Tools which have an init function have dialogs and
* cannot be initialized without a display
*/
if (tool_info[(int) tool_type].init_func && !gdisp)
if (tool_info[(gint) tool_type].init_func && !gdisp)
tool_type = RECT_SELECT;
gimp_context_set_tool (gimp_context_get_user (), tool_type);
if (tool_info[(int) tool_type].init_func)
if (tool_info[(gint) tool_type].init_func)
{
(* tool_info[(int) tool_type].init_func) (gdisp);
(* tool_info[(gint) tool_type].init_func) (gdisp);
active_tool->drawable = gimage_active_drawable (gdisp->gimage);
}
@ -726,7 +726,7 @@ tools_initialize (ToolType tool_type,
}
void
tools_options_dialog_show ()
tools_options_dialog_show (void)
{
if (!GTK_WIDGET_VISIBLE (options_shell))
{
@ -894,7 +894,7 @@ tools_new_tool (ToolType tool_type)
/* Tool options function */
void
tools_options_dialog_new ()
tools_options_dialog_new (void)
{
GtkWidget *frame;
GtkWidget *vbox;
@ -951,7 +951,7 @@ tools_options_dialog_new ()
}
void
tools_options_dialog_free ()
tools_options_dialog_free (void)
{
session_get_window_info (options_shell, &tool_options_session_info);
gtk_widget_destroy (options_shell);
@ -960,13 +960,7 @@ tools_options_dialog_free ()
void
tools_help_func (gpointer help_data)
{
gchar *help_page;
help_page = g_strdup_printf ("tools/%s.html",
tool_info[(int) active_tool->type].private_tip);
gimp_help (help_page);
g_free (help_page);
gimp_help (tool_info[(gint) active_tool->type].private_tip);
}
void
@ -1033,7 +1027,7 @@ tools_options_reset_callback (GtkWidget *widget,
shell = (GtkWidget *) data;
if (! active_tool)
if (!active_tool)
return;
if (tool_info[(int) active_tool->type].tool_options->reset_func)
@ -1041,16 +1035,18 @@ tools_options_reset_callback (GtkWidget *widget,
}
guchar *
tool_active_PDB_string()
tool_active_PDB_string (void)
{
guchar *toolStr = "gimp_paintbrush_default";
/* Return the correct PDB function for the active tool */
/* The default is paintbrush if the tool is not recognised */
if(!active_tool)
/* Return the correct PDB function for the active tool
* The default is paintbrush if the tool is not recognised
*/
if (!active_tool)
return toolStr;
switch(active_tool->type)
switch (gimp_context_get_tool (gimp_context_get_user ()))
{
case PENCIL:
toolStr = "gimp_pencil";
@ -1079,5 +1075,6 @@ tool_active_PDB_string()
default:
toolStr = "gimp_paintbrush_default";
}
return toolStr;
}

View File

@ -44,19 +44,19 @@ typedef enum
struct _Tool
{
/* Data */
ToolType type; /* Tool type */
gint ID; /* unique tool ID */
ToolType type; /* Tool type */
gint ID; /* unique tool ID */
ToolState state; /* state of tool activity */
gint paused_count; /* paused control count */
gboolean scroll_lock; /* allow scrolling or not */
gboolean auto_snap_to; /* snap to guides automatically */
ToolState state; /* state of tool activity */
gint paused_count; /* paused control count */
gboolean scroll_lock; /* allow scrolling or not */
gboolean auto_snap_to; /* snap to guides automatically */
gboolean preserve; /* Preserve this tool across drawable changes */
void * gdisp_ptr; /* pointer to currently active gdisp */
void * drawable; /* pointer to the tool's current drawable */
gboolean preserve; /* Preserve this tool across drawable changes */
void *gdisp_ptr; /* pointer to currently active gdisp */
void *drawable; /* pointer to the tool's current drawable */
void * private; /* Tool-specific information */
void *private; /* Tool-specific information */
/* Action functions */
ButtonPressFunc button_press_func;
@ -72,19 +72,19 @@ struct _ToolInfo
{
ToolOptions *tool_options;
char *tool_name;
gchar *tool_name;
int toolbar_position;
gint toolbar_position;
char *menu_path;
char *menu_accel;
gchar *menu_path;
gchar *menu_accel;
char **icon_data;
gchar **icon_data;
char *tool_desc;
char *private_tip;
gchar *tool_desc;
gchar *private_tip;
gint tool_id;
ToolType tool_id;
ToolInfoNewFunc new_func;
ToolInfoFreeFunc free_func;
@ -101,24 +101,24 @@ extern ToolInfo tool_info[];
extern gint num_tools;
/* Function declarations */
Tool * tools_new_tool (ToolType tool_type);
Tool * tools_new_tool (ToolType tool_type);
void tools_select (ToolType tool_type);
void tools_initialize (ToolType tool_type,
GDisplay *gdisplay);
void tools_select (ToolType tool_type);
void tools_initialize (ToolType tool_type,
GDisplay *gdisplay);
void tools_options_dialog_new (void);
void tools_options_dialog_show (void);
void tools_options_dialog_free (void);
void tools_options_dialog_new (void);
void tools_options_dialog_show (void);
void tools_options_dialog_free (void);
void tools_help_func (gpointer);
void tools_help_func (gpointer);
void tools_register (ToolType tool_type,
ToolOptions *tool_options);
void tools_register (ToolType tool_type,
ToolOptions *tool_options);
void active_tool_control (ToolAction action,
void *gdisp_ptr);
void active_tool_control (ToolAction action,
void *gdisp_ptr);
guchar *tool_active_PDB_string (void);
guchar * tool_active_PDB_string (void);
#endif /* __TOOLS_H__ */

View File

@ -29,6 +29,7 @@
#include "gimpcontext.h"
#include "gimprc.h"
#include "gimpui.h"
#include "gradient.h"
#include "gradient_header.h"
#include "session.h"
#include "tools.h"
@ -47,7 +48,8 @@
#define DEVICE_CONTEXT_MASK GIMP_CONTEXT_TOOL_MASK | \
GIMP_CONTEXT_FOREGROUND_MASK | \
GIMP_CONTEXT_BRUSH_MASK | \
GIMP_CONTEXT_PATTERN_MASK
GIMP_CONTEXT_PATTERN_MASK | \
GIMP_CONTEXT_GRADIENT_MASK
typedef struct _DeviceInfo DeviceInfo;
@ -86,47 +88,57 @@ struct _DeviceInfoDialog
GtkWidget **colors;
GtkWidget **brushes;
GtkWidget **patterns;
GtkWidget **gradients;
GtkWidget **eventboxes;
};
/* local functions */
static void input_dialog_destroy_callback (GtkWidget *, gpointer);
static void input_dialog_able_callback (GtkWidget *w, guint32 deviceid,
gpointer data);
static void input_dialog_destroy_callback (GtkWidget *, gpointer);
static void input_dialog_able_callback (GtkWidget *w, guint32 deviceid,
gpointer data);
static void devices_write_rc_device (DeviceInfo *device_info, FILE *fp);
static void devices_write_rc (void);
static void devices_write_rc_device (DeviceInfo *device_info,
FILE *fp);
static void devices_write_rc (void);
static void device_status_destroy_callback (void);
static void devices_close_callback (GtkWidget *, gpointer);
static void device_status_destroy_callback (void);
static void devices_close_callback (GtkWidget *, gpointer);
static void device_status_update (guint32 deviceid);
static void device_status_update_current (void);
static void device_status_update (guint32 deviceid);
static void device_status_update_current (void);
static void device_status_drag_color (GtkWidget *,
guchar *, guchar *, guchar *,
gpointer);
static void device_status_drop_color (GtkWidget *,
guchar, guchar, guchar,
gpointer);
static void device_status_drop_brush (GtkWidget *,
GdkDragContext *,
gint, gint, guint, gpointer);
static void device_status_drop_pattern (GtkWidget *,
GdkDragContext *,
gint, gint, guint, gpointer);
static ToolType device_status_drag_tool (GtkWidget *,
gpointer);
static void device_status_drop_tool (GtkWidget *,
ToolType,
gpointer);
static void device_status_drag_color (GtkWidget *,
guchar *, guchar *, guchar *,
gpointer);
static void device_status_drop_color (GtkWidget *,
guchar, guchar, guchar,
gpointer);
static void device_status_drop_brush (GtkWidget *,
GimpBrush *,
gpointer);
static void device_status_drop_pattern (GtkWidget *,
GPattern *,
gpointer);
static void device_status_drop_gradient (GtkWidget *,
gradient_t *,
gpointer);
static void device_status_color_changed (GimpContext *context,
gint r,
gint g,
gint b,
gpointer data);
static void device_status_data_changed (GimpContext *context,
gpointer dummy,
gpointer data);
static void device_status_color_changed (GimpContext *context,
gint r,
gint g,
gint b,
gpointer data);
static void device_status_data_changed (GimpContext *context,
gpointer dummy,
gpointer data);
static void device_status_context_connect (GimpContext *context,
guint32 deviceid);
static void device_status_context_connect (GimpContext *context,
guint32 deviceid);
/* global data */
gint current_device = GDK_CORE_POINTER;
@ -139,6 +151,13 @@ static DeviceInfoDialog *deviceD = NULL;
static gboolean suppress_update = FALSE;
/* dnd stuff */
static GtkTargetEntry tool_target_table[] =
{
GIMP_TARGET_TOOL
};
static guint n_tool_targets = (sizeof (tool_target_table) /
sizeof (tool_target_table[0]));
static GtkTargetEntry color_area_target_table[] =
{
GIMP_TARGET_COLOR
@ -146,20 +165,6 @@ static GtkTargetEntry color_area_target_table[] =
static guint n_color_area_targets = (sizeof (color_area_target_table) /
sizeof (color_area_target_table[0]));
static GtkTargetEntry brush_area_target_table[] =
{
GIMP_TARGET_BRUSH
};
static guint n_brush_area_targets = (sizeof (brush_area_target_table) /
sizeof (brush_area_target_table[0]));
static GtkTargetEntry pattern_area_target_table[] =
{
GIMP_TARGET_PATTERN
};
static guint n_pattern_area_targets = (sizeof (pattern_area_target_table) /
sizeof (pattern_area_target_table[0]));
/* utility functions for the device lists */
static GdkDeviceInfo *
@ -487,19 +492,9 @@ devices_rc_update (gchar *name,
if (values & DEVICE_GRADIENT)
{
gradient_t *gradient;
GSList *list;
for (list = gradients_list; list; list = g_slist_next (list))
{
gradient = (gradient_t *) list->data;
if (! strcmp (gradient->name, gradient_name))
{
gimp_context_set_gradient (device_info->context, gradient);
break;
}
}
gimp_context_set_gradient (device_info->context,
gradient_list_get_gradient (gradients_list,
gradient_name));
}
}
@ -686,6 +681,12 @@ devices_write_rc_device (DeviceInfo *device_info,
gimp_context_get_pattern (device_info->context)->name);
}
if (gimp_context_get_gradient (device_info->context))
{
fprintf (fp, "\n (gradient \"%s\")",
gimp_context_get_gradient (device_info->context)->name);
}
fprintf(fp,")\n");
}
@ -750,7 +751,7 @@ device_status_create (void)
}
/* devices table */
deviceD->table = gtk_table_new (deviceD->num_devices, 5, FALSE);
deviceD->table = gtk_table_new (deviceD->num_devices, 6, FALSE);
gtk_container_set_border_width (GTK_CONTAINER (deviceD->table), 3);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (deviceD->shell)->vbox),
deviceD->table);
@ -763,6 +764,7 @@ device_status_create (void)
deviceD->colors = g_new (GtkWidget *, deviceD->num_devices);
deviceD->brushes = g_new (GtkWidget *, deviceD->num_devices);
deviceD->patterns = g_new (GtkWidget *, deviceD->num_devices);
deviceD->gradients = g_new (GtkWidget *, deviceD->num_devices);
deviceD->eventboxes = g_new (GtkWidget *, deviceD->num_devices);
for (list = device_info_list, i = 0; list; list = g_list_next (list), i++)
@ -792,14 +794,27 @@ device_status_create (void)
/* the tool */
deviceD->eventboxes[i] = gtk_event_box_new();
deviceD->tools[i] =
gtk_pixmap_new (create_tool_pixmap (deviceD->table, RECT_SELECT),
NULL);
gtk_drag_source_set (deviceD->eventboxes[i],
GDK_BUTTON1_MASK,
tool_target_table, n_tool_targets,
GDK_ACTION_COPY);
gimp_dnd_tool_source_set (deviceD->eventboxes[i],
device_status_drag_tool,
GUINT_TO_POINTER (device_info->device));
gtk_drag_dest_set (deviceD->eventboxes[i],
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
tool_target_table, n_tool_targets,
GDK_ACTION_COPY);
gimp_dnd_tool_dest_set (deviceD->eventboxes[i],
device_status_drop_tool,
GUINT_TO_POINTER (device_info->device));
gtk_container_add (GTK_CONTAINER (deviceD->eventboxes[i]),
deviceD->tools[i]);
gtk_table_attach (GTK_TABLE (deviceD->table), deviceD->eventboxes[i],
1, 2, i, i+1,
0, 0, 2, 2);
@ -831,40 +846,40 @@ device_status_create (void)
/* the brush */
deviceD->brushes[i] = gimp_context_preview_new (GCP_BRUSH,
CELL_SIZE, CELL_SIZE,
FALSE, TRUE, TRUE);
gtk_drag_dest_set (deviceD->brushes[i],
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
brush_area_target_table, n_brush_area_targets,
GDK_ACTION_COPY);
gtk_signal_connect (GTK_OBJECT (deviceD->brushes[i]), "drag_drop",
GTK_SIGNAL_FUNC (device_status_drop_brush),
GUINT_TO_POINTER (device_info->device));
deviceD->brushes[i] =
gimp_context_preview_new (GCP_BRUSH,
CELL_SIZE, CELL_SIZE,
FALSE, TRUE, TRUE,
GTK_SIGNAL_FUNC (device_status_drop_brush),
GUINT_TO_POINTER (device_info->device));
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->brushes[i],
3, 4, i, i+1,
0, 0, 2, 2);
/* the pattern */
deviceD->patterns[i] = gimp_context_preview_new (GCP_PATTERN,
CELL_SIZE, CELL_SIZE,
FALSE, TRUE, TRUE);
gtk_drag_dest_set (deviceD->patterns[i],
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
pattern_area_target_table, n_pattern_area_targets,
GDK_ACTION_COPY);
gtk_signal_connect (GTK_OBJECT (deviceD->patterns[i]), "drag_drop",
GTK_SIGNAL_FUNC (device_status_drop_pattern),
GUINT_TO_POINTER (device_info->device));
deviceD->patterns[i] =
gimp_context_preview_new (GCP_PATTERN,
CELL_SIZE, CELL_SIZE,
FALSE, TRUE, TRUE,
GTK_SIGNAL_FUNC (device_status_drop_pattern),
GUINT_TO_POINTER (device_info->device));
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->patterns[i],
4, 5, i, i+1,
0, 0, 2, 2);
/* the gradient */
deviceD->gradients[i] =
gimp_context_preview_new (GCP_GRADIENT,
CELL_SIZE * 2, CELL_SIZE,
FALSE, TRUE, TRUE,
GTK_SIGNAL_FUNC (device_status_drop_gradient),
GUINT_TO_POINTER (device_info->device));
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->gradients[i],
5, 6, i, i+1,
0, 0, 2, 2);
device_status_update (device_info->device);
}
@ -896,6 +911,7 @@ device_status_destroy_callback (void)
g_free (deviceD->colors);
g_free (deviceD->brushes);
g_free (deviceD->patterns);
g_free (deviceD->gradients);
g_free (deviceD);
deviceD = NULL;
@ -977,6 +993,7 @@ device_status_update (guint32 deviceid)
gtk_widget_hide (deviceD->colors[i]);
gtk_widget_hide (deviceD->brushes[i]);
gtk_widget_hide (deviceD->patterns[i]);
gtk_widget_hide (deviceD->gradients[i]);
}
else
{
@ -1033,11 +1050,52 @@ device_status_update (guint32 deviceid)
gimp_context_get_pattern (device_info->context));
gtk_widget_show (deviceD->patterns[i]);
}
if (gimp_context_get_gradient (device_info->context))
{
gimp_context_preview_update
(GIMP_CONTEXT_PREVIEW (deviceD->gradients[i]),
gimp_context_get_gradient (device_info->context));
gtk_widget_show (deviceD->gradients[i]);
}
}
}
/* dnd stuff */
static ToolType
device_status_drag_tool (GtkWidget *widget,
gpointer data)
{
DeviceInfo *device_info;
device_info = device_info_get_by_id (GPOINTER_TO_UINT (data));
if (device_info)
{
return gimp_context_get_tool (device_info->context);
}
else
{
return RECT_SELECT;
}
}
static void
device_status_drop_tool (GtkWidget *widget,
ToolType tool,
gpointer data)
{
DeviceInfo *device_info;
device_info = device_info_get_by_id (GPOINTER_TO_UINT (data));
if (device_info && device_info->is_present)
{
gimp_context_set_tool (device_info->context, tool);
}
}
static void
device_status_drag_color (GtkWidget *widget,
guchar *r,
@ -1077,24 +1135,11 @@ device_status_drop_color (GtkWidget *widget,
}
static void
device_status_drop_brush (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time,
gpointer data)
device_status_drop_brush (GtkWidget *widget,
GimpBrush *brush,
gpointer data)
{
DeviceInfo *device_info;
GtkWidget *src;
GimpBrush *brush = NULL;
src = gtk_drag_get_source_widget (context);
if (!src)
return;
brush = (GimpBrush *) gtk_object_get_data (GTK_OBJECT (src), "gimp_brush");
if (!brush)
return;
device_info = device_info_get_by_id (GPOINTER_TO_UINT (data));
@ -1105,24 +1150,11 @@ device_status_drop_brush (GtkWidget *widget,
}
static void
device_status_drop_pattern (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time,
gpointer data)
device_status_drop_pattern (GtkWidget *widget,
GPattern *pattern,
gpointer data)
{
DeviceInfo *device_info;
GtkWidget *src;
GPattern *pattern = NULL;
src = gtk_drag_get_source_widget (context);
if (!src)
return;
pattern = (GPattern *) gtk_object_get_data (GTK_OBJECT (src), "gimp_pattern");
if (!pattern)
return;
device_info = device_info_get_by_id (GPOINTER_TO_UINT (data));
@ -1132,6 +1164,21 @@ device_status_drop_pattern (GtkWidget *widget,
}
}
static void
device_status_drop_gradient (GtkWidget *widget,
gradient_t *gradient,
gpointer data)
{
DeviceInfo *device_info;
device_info = device_info_get_by_id (GPOINTER_TO_UINT (data));
if (device_info && device_info->is_present)
{
gimp_context_set_gradient (device_info->context, gradient);
}
}
/* context callbacks */
static void
@ -1176,4 +1223,7 @@ device_status_context_connect (GimpContext *context,
gtk_signal_connect (GTK_OBJECT (context), "pattern_changed",
GTK_SIGNAL_FUNC (device_status_data_changed),
(gpointer) deviceid);
gtk_signal_connect (GTK_OBJECT (context), "gradient_changed",
GTK_SIGNAL_FUNC (device_status_data_changed),
(gpointer) deviceid);
}

View File

@ -29,6 +29,7 @@
#include "gimpcontext.h"
#include "gimprc.h"
#include "gimpui.h"
#include "gradient.h"
#include "gradient_header.h"
#include "session.h"
#include "tools.h"
@ -47,7 +48,8 @@
#define DEVICE_CONTEXT_MASK GIMP_CONTEXT_TOOL_MASK | \
GIMP_CONTEXT_FOREGROUND_MASK | \
GIMP_CONTEXT_BRUSH_MASK | \
GIMP_CONTEXT_PATTERN_MASK
GIMP_CONTEXT_PATTERN_MASK | \
GIMP_CONTEXT_GRADIENT_MASK
typedef struct _DeviceInfo DeviceInfo;
@ -86,47 +88,57 @@ struct _DeviceInfoDialog
GtkWidget **colors;
GtkWidget **brushes;
GtkWidget **patterns;
GtkWidget **gradients;
GtkWidget **eventboxes;
};
/* local functions */
static void input_dialog_destroy_callback (GtkWidget *, gpointer);
static void input_dialog_able_callback (GtkWidget *w, guint32 deviceid,
gpointer data);
static void input_dialog_destroy_callback (GtkWidget *, gpointer);
static void input_dialog_able_callback (GtkWidget *w, guint32 deviceid,
gpointer data);
static void devices_write_rc_device (DeviceInfo *device_info, FILE *fp);
static void devices_write_rc (void);
static void devices_write_rc_device (DeviceInfo *device_info,
FILE *fp);
static void devices_write_rc (void);
static void device_status_destroy_callback (void);
static void devices_close_callback (GtkWidget *, gpointer);
static void device_status_destroy_callback (void);
static void devices_close_callback (GtkWidget *, gpointer);
static void device_status_update (guint32 deviceid);
static void device_status_update_current (void);
static void device_status_update (guint32 deviceid);
static void device_status_update_current (void);
static void device_status_drag_color (GtkWidget *,
guchar *, guchar *, guchar *,
gpointer);
static void device_status_drop_color (GtkWidget *,
guchar, guchar, guchar,
gpointer);
static void device_status_drop_brush (GtkWidget *,
GdkDragContext *,
gint, gint, guint, gpointer);
static void device_status_drop_pattern (GtkWidget *,
GdkDragContext *,
gint, gint, guint, gpointer);
static ToolType device_status_drag_tool (GtkWidget *,
gpointer);
static void device_status_drop_tool (GtkWidget *,
ToolType,
gpointer);
static void device_status_drag_color (GtkWidget *,
guchar *, guchar *, guchar *,
gpointer);
static void device_status_drop_color (GtkWidget *,
guchar, guchar, guchar,
gpointer);
static void device_status_drop_brush (GtkWidget *,
GimpBrush *,
gpointer);
static void device_status_drop_pattern (GtkWidget *,
GPattern *,
gpointer);
static void device_status_drop_gradient (GtkWidget *,
gradient_t *,
gpointer);
static void device_status_color_changed (GimpContext *context,
gint r,
gint g,
gint b,
gpointer data);
static void device_status_data_changed (GimpContext *context,
gpointer dummy,
gpointer data);
static void device_status_color_changed (GimpContext *context,
gint r,
gint g,
gint b,
gpointer data);
static void device_status_data_changed (GimpContext *context,
gpointer dummy,
gpointer data);
static void device_status_context_connect (GimpContext *context,
guint32 deviceid);
static void device_status_context_connect (GimpContext *context,
guint32 deviceid);
/* global data */
gint current_device = GDK_CORE_POINTER;
@ -139,6 +151,13 @@ static DeviceInfoDialog *deviceD = NULL;
static gboolean suppress_update = FALSE;
/* dnd stuff */
static GtkTargetEntry tool_target_table[] =
{
GIMP_TARGET_TOOL
};
static guint n_tool_targets = (sizeof (tool_target_table) /
sizeof (tool_target_table[0]));
static GtkTargetEntry color_area_target_table[] =
{
GIMP_TARGET_COLOR
@ -146,20 +165,6 @@ static GtkTargetEntry color_area_target_table[] =
static guint n_color_area_targets = (sizeof (color_area_target_table) /
sizeof (color_area_target_table[0]));
static GtkTargetEntry brush_area_target_table[] =
{
GIMP_TARGET_BRUSH
};
static guint n_brush_area_targets = (sizeof (brush_area_target_table) /
sizeof (brush_area_target_table[0]));
static GtkTargetEntry pattern_area_target_table[] =
{
GIMP_TARGET_PATTERN
};
static guint n_pattern_area_targets = (sizeof (pattern_area_target_table) /
sizeof (pattern_area_target_table[0]));
/* utility functions for the device lists */
static GdkDeviceInfo *
@ -487,19 +492,9 @@ devices_rc_update (gchar *name,
if (values & DEVICE_GRADIENT)
{
gradient_t *gradient;
GSList *list;
for (list = gradients_list; list; list = g_slist_next (list))
{
gradient = (gradient_t *) list->data;
if (! strcmp (gradient->name, gradient_name))
{
gimp_context_set_gradient (device_info->context, gradient);
break;
}
}
gimp_context_set_gradient (device_info->context,
gradient_list_get_gradient (gradients_list,
gradient_name));
}
}
@ -686,6 +681,12 @@ devices_write_rc_device (DeviceInfo *device_info,
gimp_context_get_pattern (device_info->context)->name);
}
if (gimp_context_get_gradient (device_info->context))
{
fprintf (fp, "\n (gradient \"%s\")",
gimp_context_get_gradient (device_info->context)->name);
}
fprintf(fp,")\n");
}
@ -750,7 +751,7 @@ device_status_create (void)
}
/* devices table */
deviceD->table = gtk_table_new (deviceD->num_devices, 5, FALSE);
deviceD->table = gtk_table_new (deviceD->num_devices, 6, FALSE);
gtk_container_set_border_width (GTK_CONTAINER (deviceD->table), 3);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (deviceD->shell)->vbox),
deviceD->table);
@ -763,6 +764,7 @@ device_status_create (void)
deviceD->colors = g_new (GtkWidget *, deviceD->num_devices);
deviceD->brushes = g_new (GtkWidget *, deviceD->num_devices);
deviceD->patterns = g_new (GtkWidget *, deviceD->num_devices);
deviceD->gradients = g_new (GtkWidget *, deviceD->num_devices);
deviceD->eventboxes = g_new (GtkWidget *, deviceD->num_devices);
for (list = device_info_list, i = 0; list; list = g_list_next (list), i++)
@ -792,14 +794,27 @@ device_status_create (void)
/* the tool */
deviceD->eventboxes[i] = gtk_event_box_new();
deviceD->tools[i] =
gtk_pixmap_new (create_tool_pixmap (deviceD->table, RECT_SELECT),
NULL);
gtk_drag_source_set (deviceD->eventboxes[i],
GDK_BUTTON1_MASK,
tool_target_table, n_tool_targets,
GDK_ACTION_COPY);
gimp_dnd_tool_source_set (deviceD->eventboxes[i],
device_status_drag_tool,
GUINT_TO_POINTER (device_info->device));
gtk_drag_dest_set (deviceD->eventboxes[i],
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
tool_target_table, n_tool_targets,
GDK_ACTION_COPY);
gimp_dnd_tool_dest_set (deviceD->eventboxes[i],
device_status_drop_tool,
GUINT_TO_POINTER (device_info->device));
gtk_container_add (GTK_CONTAINER (deviceD->eventboxes[i]),
deviceD->tools[i]);
gtk_table_attach (GTK_TABLE (deviceD->table), deviceD->eventboxes[i],
1, 2, i, i+1,
0, 0, 2, 2);
@ -831,40 +846,40 @@ device_status_create (void)
/* the brush */
deviceD->brushes[i] = gimp_context_preview_new (GCP_BRUSH,
CELL_SIZE, CELL_SIZE,
FALSE, TRUE, TRUE);
gtk_drag_dest_set (deviceD->brushes[i],
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
brush_area_target_table, n_brush_area_targets,
GDK_ACTION_COPY);
gtk_signal_connect (GTK_OBJECT (deviceD->brushes[i]), "drag_drop",
GTK_SIGNAL_FUNC (device_status_drop_brush),
GUINT_TO_POINTER (device_info->device));
deviceD->brushes[i] =
gimp_context_preview_new (GCP_BRUSH,
CELL_SIZE, CELL_SIZE,
FALSE, TRUE, TRUE,
GTK_SIGNAL_FUNC (device_status_drop_brush),
GUINT_TO_POINTER (device_info->device));
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->brushes[i],
3, 4, i, i+1,
0, 0, 2, 2);
/* the pattern */
deviceD->patterns[i] = gimp_context_preview_new (GCP_PATTERN,
CELL_SIZE, CELL_SIZE,
FALSE, TRUE, TRUE);
gtk_drag_dest_set (deviceD->patterns[i],
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
pattern_area_target_table, n_pattern_area_targets,
GDK_ACTION_COPY);
gtk_signal_connect (GTK_OBJECT (deviceD->patterns[i]), "drag_drop",
GTK_SIGNAL_FUNC (device_status_drop_pattern),
GUINT_TO_POINTER (device_info->device));
deviceD->patterns[i] =
gimp_context_preview_new (GCP_PATTERN,
CELL_SIZE, CELL_SIZE,
FALSE, TRUE, TRUE,
GTK_SIGNAL_FUNC (device_status_drop_pattern),
GUINT_TO_POINTER (device_info->device));
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->patterns[i],
4, 5, i, i+1,
0, 0, 2, 2);
/* the gradient */
deviceD->gradients[i] =
gimp_context_preview_new (GCP_GRADIENT,
CELL_SIZE * 2, CELL_SIZE,
FALSE, TRUE, TRUE,
GTK_SIGNAL_FUNC (device_status_drop_gradient),
GUINT_TO_POINTER (device_info->device));
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->gradients[i],
5, 6, i, i+1,
0, 0, 2, 2);
device_status_update (device_info->device);
}
@ -896,6 +911,7 @@ device_status_destroy_callback (void)
g_free (deviceD->colors);
g_free (deviceD->brushes);
g_free (deviceD->patterns);
g_free (deviceD->gradients);
g_free (deviceD);
deviceD = NULL;
@ -977,6 +993,7 @@ device_status_update (guint32 deviceid)
gtk_widget_hide (deviceD->colors[i]);
gtk_widget_hide (deviceD->brushes[i]);
gtk_widget_hide (deviceD->patterns[i]);
gtk_widget_hide (deviceD->gradients[i]);
}
else
{
@ -1033,11 +1050,52 @@ device_status_update (guint32 deviceid)
gimp_context_get_pattern (device_info->context));
gtk_widget_show (deviceD->patterns[i]);
}
if (gimp_context_get_gradient (device_info->context))
{
gimp_context_preview_update
(GIMP_CONTEXT_PREVIEW (deviceD->gradients[i]),
gimp_context_get_gradient (device_info->context));
gtk_widget_show (deviceD->gradients[i]);
}
}
}
/* dnd stuff */
static ToolType
device_status_drag_tool (GtkWidget *widget,
gpointer data)
{
DeviceInfo *device_info;
device_info = device_info_get_by_id (GPOINTER_TO_UINT (data));
if (device_info)
{
return gimp_context_get_tool (device_info->context);
}
else
{
return RECT_SELECT;
}
}
static void
device_status_drop_tool (GtkWidget *widget,
ToolType tool,
gpointer data)
{
DeviceInfo *device_info;
device_info = device_info_get_by_id (GPOINTER_TO_UINT (data));
if (device_info && device_info->is_present)
{
gimp_context_set_tool (device_info->context, tool);
}
}
static void
device_status_drag_color (GtkWidget *widget,
guchar *r,
@ -1077,24 +1135,11 @@ device_status_drop_color (GtkWidget *widget,
}
static void
device_status_drop_brush (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time,
gpointer data)
device_status_drop_brush (GtkWidget *widget,
GimpBrush *brush,
gpointer data)
{
DeviceInfo *device_info;
GtkWidget *src;
GimpBrush *brush = NULL;
src = gtk_drag_get_source_widget (context);
if (!src)
return;
brush = (GimpBrush *) gtk_object_get_data (GTK_OBJECT (src), "gimp_brush");
if (!brush)
return;
device_info = device_info_get_by_id (GPOINTER_TO_UINT (data));
@ -1105,24 +1150,11 @@ device_status_drop_brush (GtkWidget *widget,
}
static void
device_status_drop_pattern (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time,
gpointer data)
device_status_drop_pattern (GtkWidget *widget,
GPattern *pattern,
gpointer data)
{
DeviceInfo *device_info;
GtkWidget *src;
GPattern *pattern = NULL;
src = gtk_drag_get_source_widget (context);
if (!src)
return;
pattern = (GPattern *) gtk_object_get_data (GTK_OBJECT (src), "gimp_pattern");
if (!pattern)
return;
device_info = device_info_get_by_id (GPOINTER_TO_UINT (data));
@ -1132,6 +1164,21 @@ device_status_drop_pattern (GtkWidget *widget,
}
}
static void
device_status_drop_gradient (GtkWidget *widget,
gradient_t *gradient,
gpointer data)
{
DeviceInfo *device_info;
device_info = device_info_get_by_id (GPOINTER_TO_UINT (data));
if (device_info && device_info->is_present)
{
gimp_context_set_gradient (device_info->context, gradient);
}
}
/* context callbacks */
static void
@ -1176,4 +1223,7 @@ device_status_context_connect (GimpContext *context,
gtk_signal_connect (GTK_OBJECT (context), "pattern_changed",
GTK_SIGNAL_FUNC (device_status_data_changed),
(gpointer) deviceid);
gtk_signal_connect (GTK_OBJECT (context), "gradient_changed",
GTK_SIGNAL_FUNC (device_status_data_changed),
(gpointer) deviceid);
}

Some files were not shown because too many files have changed in this diff Show More