GType is a pointer now, not a guint.

2001-11-27  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpcontainer.c: GType is a pointer now, not a guint.

	* app/widgets/gimpdock.c: chain up in widget_class->style_set().

	Gradient Editor chopping plus merging of bex' proofreading:
	(fixes #62278).

	* app/core/core-types.h: moved the gradient related enums here.

	* app/core/gimpgradient.[ch]: removed the enums, added gradient
	segment utility functions from the gradient_editor.

	* app/gui/gui-types.h: added the GradientEditor typedef here.

	* app/gui/Makefile.am
	* app/gui/gradient-editor-commands.[ch]: new files implementing
	callbacks and menu_update stuff for the new gradient_editor
	item factory.

	* app/gui/gradient-editor.[ch]: removed tons of code, namespace
	cleanup, stuff...

	* app/gui/menus.[ch]: added the gradient_editor menu stuff here.
	Added menus_set_color() which creates & updates a color menu item
	(will soon be used in other places too). Renamed menus_set_state()
	to menus_set_active().

	The editor's menu code is ugly as before, only different and evil
	the same way as the rest of the menu stuff, so it's at least
	consistent :)

	* app/display/gimpdisplayshell.c: changed accordingly.

	* app/gui/test-commands.c: don't include "gradient-editor.h".
This commit is contained in:
Michael Natterer 2001-11-27 15:44:02 +00:00 committed by Michael Natterer
parent 19e1acbcd7
commit 09a51f2193
25 changed files with 6556 additions and 6366 deletions

View File

@ -1,3 +1,40 @@
2001-11-27 Michael Natterer <mitch@gimp.org>
* app/core/gimpcontainer.c: GType is a pointer now, not a guint.
* app/widgets/gimpdock.c: chain up in widget_class->style_set().
Gradient Editor chopping plus merging of bex' proofreading:
(fixes #62278).
* app/core/core-types.h: moved the gradient related enums here.
* app/core/gimpgradient.[ch]: removed the enums, added gradient
segment utility functions from the gradient_editor.
* app/gui/gui-types.h: added the GradientEditor typedef here.
* app/gui/Makefile.am
* app/gui/gradient-editor-commands.[ch]: new files implementing
callbacks and menu_update stuff for the new gradient_editor
item factory.
* app/gui/gradient-editor.[ch]: removed tons of code, namespace
cleanup, stuff...
* app/gui/menus.[ch]: added the gradient_editor menu stuff here.
Added menus_set_color() which creates & updates a color menu item
(will soon be used in other places too). Renamed menus_set_state()
to menus_set_active().
The editor's menu code is ugly as before, only different and evil
the same way as the rest of the menu stuff, so it's at least
consistent :)
* app/display/gimpdisplayshell.c: changed accordingly.
* app/gui/test-commands.c: don't include "gradient-editor.h".
2001-11-27 Sven Neumann <sven@gimp.org>
* configure.in
@ -64,7 +101,6 @@
* app/gui/file-save-dialog.c: More of my extensive proofing.
Someone needs to check bex comments and do some hacking.
2001-11-26 Michael Natterer <mitch@gimp.org>
* app/core/gimpimage.c: gimp_image_construct_layers/channels():

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,82 @@
/* 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_EDITOR_COMMANDS_H__
#define __GRADIENT_EDITOR_COMMANDS_H__
void gradient_editor_left_color_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_load_left_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_save_left_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_right_color_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_load_right_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_save_right_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_blending_func_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_coloring_type_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_flip_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_replicate_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_split_midpoint_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_split_uniformly_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_delete_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_recenter_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_redistribute_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_blend_color_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_blend_opacity_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_show_context_menu (GradientEditor *editor);
#endif /* __GRADIENT_EDITOR_COMMANDS_H__ */

View File

@ -176,6 +176,22 @@ typedef enum
SPIRAL_ANTICLOCKWISE
} GradientType;
typedef enum /*< skip >*/
{
GRAD_LINEAR = 0,
GRAD_CURVED,
GRAD_SINE,
GRAD_SPHERE_INCREASING,
GRAD_SPHERE_DECREASING
} GimpGradientSegmentType;
typedef enum /*< skip >*/
{
GRAD_RGB = 0, /* normal RGB */
GRAD_HSV_CCW, /* counterclockwise hue */
GRAD_HSV_CW /* clockwise hue */
} GimpGradientSegmentColor;
typedef enum /*< chop=_MODE >*/
{
FG_BG_RGB_MODE,

View File

@ -205,22 +205,11 @@ gimp_container_class_init (GimpContainerClass *klass)
klass->get_child_by_index = NULL;
klass->get_child_index = NULL;
/* spit out a warning once GType becomes a gpointer */
{
guint32 *foo = NULL;
GType *bar;
bar = foo;
}
g_object_class_install_property (object_class,
PROP_CHILDREN_TYPE,
g_param_spec_uint ("children_type",
NULL, NULL,
GIMP_TYPE_OBJECT,
G_MAXINT,
GIMP_TYPE_OBJECT,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_param_spec_pointer ("children_type",
NULL, NULL,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class,
PROP_POLICY,
@ -278,7 +267,7 @@ gimp_container_set_property (GObject *object,
switch (property_id)
{
case PROP_CHILDREN_TYPE:
container->children_type = (GType) g_value_get_uint (value);
container->children_type = (GType) g_value_get_pointer (value);
g_type_class_ref (container->children_type);
break;
case PROP_POLICY:
@ -303,7 +292,7 @@ gimp_container_get_property (GObject *object,
switch (property_id)
{
case PROP_CHILDREN_TYPE:
g_value_set_uint (value, (guint) container->children_type);
g_value_set_pointer (value, (gpointer) container->children_type);
break;
case PROP_POLICY:
g_value_set_enum (value, container->policy);

View File

@ -811,3 +811,242 @@ gimp_gradient_segment_get_last (GimpGradientSegment *seg)
return seg;
}
GimpGradientSegment *
gimp_gradient_segment_get_first (GimpGradientSegment *seg)
{
if (!seg)
return NULL;
while (seg->prev)
seg = seg->prev;
return seg;
}
void
gimp_gradient_segment_split_midpoint (GimpGradient *gradient,
GimpGradientSegment *lseg,
GimpGradientSegment **newl,
GimpGradientSegment **newr)
{
GimpRGB color;
GimpGradientSegment *newseg;
g_return_if_fail (GIMP_IS_GRADIENT (gradient));
g_return_if_fail (lseg != NULL);
g_return_if_fail (newl != NULL);
g_return_if_fail (newr != NULL);
/* Get color at original segment's midpoint */
gimp_gradient_get_color_at (gradient, lseg->middle, &color);
/* Create a new segment and insert it in the list */
newseg = gimp_gradient_segment_new ();
newseg->prev = lseg;
newseg->next = lseg->next;
lseg->next = newseg;
if (newseg->next)
newseg->next->prev = newseg;
/* Set coordinates of new segment */
newseg->left = lseg->middle;
newseg->right = lseg->right;
newseg->middle = (newseg->left + newseg->right) / 2.0;
/* Set coordinates of original segment */
lseg->right = newseg->left;
lseg->middle = (lseg->left + lseg->right) / 2.0;
/* Set colors of both segments */
newseg->right_color = lseg->right_color;
lseg->right_color.r = newseg->left_color.r = color.r;
lseg->right_color.g = newseg->left_color.g = color.g;
lseg->right_color.b = newseg->left_color.b = color.b;
lseg->right_color.a = newseg->left_color.a = color.a;
/* Set parameters of new segment */
newseg->type = lseg->type;
newseg->color = lseg->color;
/* Done */
*newl = lseg;
*newr = newseg;
}
void
gimp_gradient_segment_split_uniform (GimpGradient *gradient,
GimpGradientSegment *lseg,
gint parts,
GimpGradientSegment **newl,
GimpGradientSegment **newr)
{
GimpGradientSegment *seg, *prev, *tmp;
gdouble seg_len;
gint i;
g_return_if_fail (GIMP_IS_GRADIENT (gradient));
g_return_if_fail (lseg != NULL);
g_return_if_fail (newl != NULL);
g_return_if_fail (newr != NULL);
seg_len = (lseg->right - lseg->left) / parts; /* Length of divisions */
seg = NULL;
prev = NULL;
tmp = NULL;
for (i = 0; i < parts; i++)
{
seg = gimp_gradient_segment_new ();
if (i == 0)
tmp = seg; /* Remember first segment */
seg->left = lseg->left + i * seg_len;
seg->right = lseg->left + (i + 1) * seg_len;
seg->middle = (seg->left + seg->right) / 2.0;
gimp_gradient_get_color_at (gradient, seg->left, &seg->left_color);
gimp_gradient_get_color_at (gradient, seg->right, &seg->right_color);
seg->type = lseg->type;
seg->color = lseg->color;
seg->prev = prev;
seg->next = NULL;
if (prev)
prev->next = seg;
prev = seg;
}
/* Fix edges */
tmp->left_color = lseg->left_color;
seg->right_color = lseg->right_color;
tmp->left = lseg->left;
seg->right = lseg->right; /* To squish accumulative error */
/* Link in list */
tmp->prev = lseg->prev;
seg->next = lseg->next;
if (lseg->prev)
lseg->prev->next = tmp;
else
gradient->segments = tmp; /* We are on leftmost segment */
if (lseg->next)
lseg->next->prev = seg;
gradient->last_visited = NULL; /* Force re-search */
/* Done */
*newl = tmp;
*newr = seg;
/* Delete old segment */
gimp_gradient_segment_free (lseg);
}
void
gimp_gradient_segments_compress_range (GimpGradientSegment *range_l,
GimpGradientSegment *range_r,
gdouble new_l,
gdouble new_r)
{
gdouble orig_l, orig_r;
gdouble scale;
GimpGradientSegment *seg, *aseg;
g_return_if_fail (range_l != NULL);
g_return_if_fail (range_r != NULL);
orig_l = range_l->left;
orig_r = range_r->right;
scale = (new_r - new_l) / (orig_r - orig_l);
seg = range_l;
do
{
seg->left = new_l + (seg->left - orig_l) * scale;
seg->middle = new_l + (seg->middle - orig_l) * scale;
seg->right = new_l + (seg->right - orig_l) * scale;
/* Next */
aseg = seg;
seg = seg->next;
}
while (aseg != range_r);
}
void
gimp_gradient_segments_blend_endpoints (GimpGradientSegment *lseg,
GimpGradientSegment *rseg,
GimpRGB *rgb1,
GimpRGB *rgb2,
gboolean blend_colors,
gboolean blend_opacity)
{
GimpRGB d;
gdouble left, len;
GimpGradientSegment *seg;
GimpGradientSegment *aseg;
g_return_if_fail (lseg != NULL);
g_return_if_fail (rseg != NULL);
d.r = rgb2->r - rgb1->r;
d.g = rgb2->g - rgb1->g;
d.b = rgb2->b - rgb1->b;
d.a = rgb2->a - rgb1->a;
left = lseg->left;
len = rseg->right - left;
seg = lseg;
do
{
if (blend_colors)
{
seg->left_color.r = rgb1->r + (seg->left - left) / len * d.r;
seg->left_color.g = rgb1->g + (seg->left - left) / len * d.g;
seg->left_color.b = rgb1->b + (seg->left - left) / len * d.b;
seg->right_color.r = rgb1->r + (seg->right - left) / len * d.r;
seg->right_color.g = rgb1->g + (seg->right - left) / len * d.g;
seg->right_color.b = rgb1->b + (seg->right - left) / len * d.b;
}
if (blend_opacity)
{
seg->left_color.a = rgb1->a + (seg->left - left) / len * d.a;
seg->right_color.a = rgb1->a + (seg->right - left) / len * d.a;
}
aseg = seg;
seg = seg->next;
}
while (aseg != rseg);
}

View File

@ -28,23 +28,6 @@
#define GIMP_GRADIENT_DEFAULT_SAMPLE_SIZE 40
typedef enum
{
GRAD_LINEAR = 0,
GRAD_CURVED,
GRAD_SINE,
GRAD_SPHERE_INCREASING,
GRAD_SPHERE_DECREASING
} GimpGradientSegmentType;
typedef enum
{
GRAD_RGB = 0, /* normal RGB */
GRAD_HSV_CCW, /* counterclockwise hue */
GRAD_HSV_CW /* clockwise hue */
} GimpGradientSegmentColor;
typedef struct _GimpGradientSegment GimpGradientSegment;
struct _GimpGradientSegment
@ -101,11 +84,32 @@ GimpGradientSegment * gimp_gradient_get_segment_at (GimpGradient *grad,
/* gradient segment functions */
GimpGradientSegment * gimp_gradient_segment_new (void);
GimpGradientSegment * gimp_gradient_segment_get_last (GimpGradientSegment *seg);
GimpGradientSegment * gimp_gradient_segment_new (void);
GimpGradientSegment * gimp_gradient_segment_get_last (GimpGradientSegment *seg);
GimpGradientSegment * gimp_gradient_segment_get_first (GimpGradientSegment *seg);
void gimp_gradient_segment_free (GimpGradientSegment *seg);
void gimp_gradient_segments_free (GimpGradientSegment *seg);
void gimp_gradient_segment_split_midpoint (GimpGradient *gradient,
GimpGradientSegment *lseg,
GimpGradientSegment **newl,
GimpGradientSegment **newr);
void gimp_gradient_segment_split_uniform (GimpGradient *gradient,
GimpGradientSegment *lseg,
gint parts,
GimpGradientSegment **newl,
GimpGradientSegment **newr);
void gimp_gradient_segments_compress_range (GimpGradientSegment *range_l,
GimpGradientSegment *range_r,
gdouble new_l,
gdouble new_r);
void gimp_gradient_segments_blend_endpoints (GimpGradientSegment *lseg,
GimpGradientSegment *rseg,
GimpRGB *rgb1,
GimpRGB *rgb2,
gboolean blend_colors,
gboolean blend_opacity);
#endif /* __GIMP_GRADIENT_H__ */

View File

@ -953,8 +953,8 @@ gimp_display_shell_set_menu_sensitivity (GimpDisplayShell *shell)
#define SET_SENSITIVE(menu,condition) \
menus_set_sensitive ("<Image>/" menu, (condition) != 0)
#define SET_STATE(menu,condition) \
menus_set_state ("<Image>/" menu, (condition) != 0)
#define SET_ACTIVE(menu,condition) \
menus_set_active ("<Image>/" menu, (condition) != 0)
SET_SENSITIVE ("File/Save", gdisp && drawable);
SET_SENSITIVE ("File/Save as...", gdisp && drawable);
@ -998,15 +998,15 @@ gimp_display_shell_set_menu_sensitivity (GimpDisplayShell *shell)
SET_SENSITIVE ("View/Zoom", gdisp);
if (gdisp)
{
SET_STATE ("View/Toggle Selection", ! shell->select->hidden);
SET_STATE ("View/Toggle Layer Boundary", ! shell->select->layer_hidden);
SET_STATE ("View/Toggle Rulers",
GTK_WIDGET_VISIBLE (shell->origin) ? 1 : 0);
SET_STATE ("View/Toggle Guides", gdisp->draw_guides);
SET_STATE ("View/Snap to Guides", gdisp->snap_to_guides);
SET_STATE ("View/Toggle Statusbar",
GTK_WIDGET_VISIBLE (shell->statusarea) ? 1 : 0);
SET_STATE ("View/Dot for Dot", gdisp->dot_for_dot);
SET_ACTIVE ("View/Toggle Selection", ! shell->select->hidden);
SET_ACTIVE ("View/Toggle Layer Boundary", ! shell->select->layer_hidden);
SET_ACTIVE ("View/Toggle Rulers",
GTK_WIDGET_VISIBLE (shell->origin) ? 1 : 0);
SET_ACTIVE ("View/Toggle Guides", gdisp->draw_guides);
SET_ACTIVE ("View/Snap to Guides", gdisp->snap_to_guides);
SET_ACTIVE ("View/Toggle Statusbar",
GTK_WIDGET_VISIBLE (shell->statusarea) ? 1 : 0);
SET_ACTIVE ("View/Dot for Dot", gdisp->dot_for_dot);
}
SET_SENSITIVE ("Image", gdisp);
@ -1073,7 +1073,7 @@ gimp_display_shell_set_menu_sensitivity (GimpDisplayShell *shell)
SET_SENSITIVE ("Script-Fu", gdisp && lp);
#undef SET_STATE
#undef SET_ACTIVE
#undef SET_SENSITIVE
plug_in_set_menu_sensitivity (type);

View File

@ -953,8 +953,8 @@ gimp_display_shell_set_menu_sensitivity (GimpDisplayShell *shell)
#define SET_SENSITIVE(menu,condition) \
menus_set_sensitive ("<Image>/" menu, (condition) != 0)
#define SET_STATE(menu,condition) \
menus_set_state ("<Image>/" menu, (condition) != 0)
#define SET_ACTIVE(menu,condition) \
menus_set_active ("<Image>/" menu, (condition) != 0)
SET_SENSITIVE ("File/Save", gdisp && drawable);
SET_SENSITIVE ("File/Save as...", gdisp && drawable);
@ -998,15 +998,15 @@ gimp_display_shell_set_menu_sensitivity (GimpDisplayShell *shell)
SET_SENSITIVE ("View/Zoom", gdisp);
if (gdisp)
{
SET_STATE ("View/Toggle Selection", ! shell->select->hidden);
SET_STATE ("View/Toggle Layer Boundary", ! shell->select->layer_hidden);
SET_STATE ("View/Toggle Rulers",
GTK_WIDGET_VISIBLE (shell->origin) ? 1 : 0);
SET_STATE ("View/Toggle Guides", gdisp->draw_guides);
SET_STATE ("View/Snap to Guides", gdisp->snap_to_guides);
SET_STATE ("View/Toggle Statusbar",
GTK_WIDGET_VISIBLE (shell->statusarea) ? 1 : 0);
SET_STATE ("View/Dot for Dot", gdisp->dot_for_dot);
SET_ACTIVE ("View/Toggle Selection", ! shell->select->hidden);
SET_ACTIVE ("View/Toggle Layer Boundary", ! shell->select->layer_hidden);
SET_ACTIVE ("View/Toggle Rulers",
GTK_WIDGET_VISIBLE (shell->origin) ? 1 : 0);
SET_ACTIVE ("View/Toggle Guides", gdisp->draw_guides);
SET_ACTIVE ("View/Snap to Guides", gdisp->snap_to_guides);
SET_ACTIVE ("View/Toggle Statusbar",
GTK_WIDGET_VISIBLE (shell->statusarea) ? 1 : 0);
SET_ACTIVE ("View/Dot for Dot", gdisp->dot_for_dot);
}
SET_SENSITIVE ("Image", gdisp);
@ -1073,7 +1073,7 @@ gimp_display_shell_set_menu_sensitivity (GimpDisplayShell *shell)
SET_SENSITIVE ("Script-Fu", gdisp && lp);
#undef SET_STATE
#undef SET_ACTIVE
#undef SET_SENSITIVE
plug_in_set_menu_sensitivity (type);

View File

@ -54,6 +54,8 @@ libappgui_a_SOURCES = @STRIP_BEGIN@ \
file-save-dialog.h \
gradient-editor.c \
gradient-editor.h \
gradient-editor-commands.c \
gradient-editor-commands.h \
gradient-select.h \
gradient-select.c \
gradients-commands.c \

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,82 @@
/* 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_EDITOR_COMMANDS_H__
#define __GRADIENT_EDITOR_COMMANDS_H__
void gradient_editor_left_color_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_load_left_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_save_left_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_right_color_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_load_right_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_save_right_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_blending_func_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_coloring_type_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_flip_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_replicate_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_split_midpoint_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_split_uniformly_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_delete_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_recenter_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_redistribute_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_blend_color_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_blend_opacity_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_show_context_menu (GradientEditor *editor);
#endif /* __GRADIENT_EDITOR_COMMANDS_H__ */

File diff suppressed because it is too large Load Diff

View File

@ -23,14 +23,89 @@
#define __GRADIENT_EDITOR_H__
typedef struct _GradientEditor GradientEditor;
#define GRAD_NUM_COLORS 10
GradientEditor * gradient_editor_new (Gimp *gimp);
typedef enum
{
GRAD_DRAG_NONE = 0,
GRAD_DRAG_LEFT,
GRAD_DRAG_MIDDLE,
GRAD_DRAG_ALL
} GradientEditorDragMode;
void gradient_editor_set_gradient (GradientEditor *gradient_editor,
GimpGradient *gradient);
void gradient_editor_free (GradientEditor *gradient_editor);
typedef enum
{
GRAD_UPDATE_GRADIENT = 1 << 0,
GRAD_UPDATE_PREVIEW = 1 << 1,
GRAD_UPDATE_CONTROL = 1 << 2,
GRAD_RESET_CONTROL = 1 << 3
} GradientEditorUpdateMask;
struct _GradientEditor
{
GtkWidget *shell;
GtkWidget *name;
GtkWidget *hint_label;
GtkWidget *scrollbar;
GtkWidget *preview;
GtkWidget *control;
GimpContext *context;
/* Zoom and scrollbar */
guint zoom_factor;
GtkObject *scroll_data;
/* Instant update */
gboolean instant_update;
/* Gradient preview */
guchar *preview_rows[2]; /* For caching redraw info */
gint preview_last_x;
gboolean preview_button_down;
/* Gradient control */
GdkPixmap *control_pixmap;
GimpGradientSegment *control_drag_segment; /* Segment which is being dragged */
GimpGradientSegment *control_sel_l; /* Left segment of selection */
GimpGradientSegment *control_sel_r; /* Right segment of selection */
GradientEditorDragMode control_drag_mode; /* What is being dragged? */
guint32 control_click_time; /* Time when mouse was pressed */
gboolean control_compress; /* Compressing/expanding handles */
gint control_last_x; /* Last mouse position when dragging */
gdouble control_last_gx; /* Last position (wrt gradient) when dragging */
gdouble control_orig_pos; /* Original click position when dragging */
/* Split uniformly dialog */
gint split_parts;
/* Replicate dialog */
gint replicate_times;
/* Saved colors */
GimpRGB saved_colors[GRAD_NUM_COLORS];
/* Color dialogs */
GimpGradientSegment *left_saved_segments;
gboolean left_saved_dirty;
GimpGradientSegment *right_saved_segments;
gboolean right_saved_dirty;
};
GradientEditor * gradient_editor_new (Gimp *gimp);
void gradient_editor_set_gradient (GradientEditor *gradient_editor,
GimpGradient *gradient);
void gradient_editor_free (GradientEditor *gradient_editor);
void gradient_editor_update (GradientEditor *gradient_editor,
GradientEditorUpdateMask flags);
#endif /* __GRADIENT_EDITOR_H__ */

View File

@ -25,6 +25,7 @@
typedef struct _ColorNotebook ColorNotebook;
typedef struct _GradientEditor GradientEditor;
typedef struct _InfoDialog InfoDialog;
typedef struct _NavigationDialog NavigationDialog;

View File

@ -53,6 +53,7 @@
#include "documents-commands.h"
#include "edit-commands.h"
#include "file-commands.h"
#include "gradient-editor-commands.h"
#include "gradients-commands.h"
#include "image-commands.h"
#include "layers-commands.h"
@ -1446,6 +1447,324 @@ static GimpItemFactoryEntry patterns_entries[] =
};
/***** <GradientEditor> *****/
static GimpItemFactoryEntry gradient_editor_entries[] =
{
{ { N_("/Left Endpoint's Color..."), NULL,
gradient_editor_left_color_cmd_callback, 0 },
NULL,
NULL, NULL },
{ { N_("/Load Left Color From/Left Neighbor's Right Endpoint"), NULL,
gradient_editor_load_left_cmd_callback, 0 },
NULL,
NULL, NULL },
{ { N_("/Load Left Color From/Right Endpoint"), NULL,
gradient_editor_load_left_cmd_callback, 1 },
NULL,
NULL, NULL },
{ { N_("/Load Left Color From/FG Color"), NULL,
gradient_editor_load_left_cmd_callback, 2 },
NULL,
NULL, NULL },
{ { N_("/Load Left Color From/BG Color"), NULL,
gradient_editor_load_left_cmd_callback, 3 },
NULL,
NULL, NULL },
SEPARATOR ("/Load Left Color From/---"),
{ { "/Load Left Color From/01", NULL,
gradient_editor_load_left_cmd_callback, 4 },
NULL,
NULL, NULL },
{ { "/Load Left Color From/02", NULL,
gradient_editor_load_left_cmd_callback, 5 },
NULL,
NULL, NULL },
{ { "/Load Left Color From/03", NULL,
gradient_editor_load_left_cmd_callback, 6 },
NULL,
NULL, NULL },
{ { "/Load Left Color From/04", NULL,
gradient_editor_load_left_cmd_callback, 7 },
NULL,
NULL, NULL },
{ { "/Load Left Color From/05", NULL,
gradient_editor_load_left_cmd_callback, 8 },
NULL,
NULL, NULL },
{ { "/Load Left Color From/06", NULL,
gradient_editor_load_left_cmd_callback, 9 },
NULL,
NULL, NULL },
{ { "/Load Left Color From/07", NULL,
gradient_editor_load_left_cmd_callback, 10 },
NULL,
NULL, NULL },
{ { "/Load Left Color From/08", NULL,
gradient_editor_load_left_cmd_callback, 11 },
NULL,
NULL, NULL },
{ { "/Load Left Color From/09", NULL,
gradient_editor_load_left_cmd_callback, 12 },
NULL,
NULL, NULL },
{ { "/Load Left Color From/10", NULL,
gradient_editor_load_left_cmd_callback, 13 },
NULL,
NULL, NULL },
BRANCH (N_("/Save Left Color To")),
{ { "/Save Left Color To/01", NULL,
gradient_editor_save_left_cmd_callback, 0 },
NULL,
NULL, NULL },
{ { "/Save Left Color To/02", NULL,
gradient_editor_save_left_cmd_callback, 1 },
NULL,
NULL, NULL },
{ { "/Save Left Color To/03", NULL,
gradient_editor_save_left_cmd_callback, 2 },
NULL,
NULL, NULL },
{ { "/Save Left Color To/04", NULL,
gradient_editor_save_left_cmd_callback, 3 },
NULL,
NULL, NULL },
{ { "/Save Left Color To/05", NULL,
gradient_editor_save_left_cmd_callback, 4 },
NULL,
NULL, NULL },
{ { "/Save Left Color To/06", NULL,
gradient_editor_save_left_cmd_callback, 5 },
NULL,
NULL, NULL },
{ { "/Save Left Color To/07", NULL,
gradient_editor_save_left_cmd_callback, 6 },
NULL,
NULL, NULL },
{ { "/Save Left Color To/08", NULL,
gradient_editor_save_left_cmd_callback, 7 },
NULL,
NULL, NULL },
{ { "/Save Left Color To/09", NULL,
gradient_editor_save_left_cmd_callback, 8 },
NULL,
NULL, NULL },
{ { "/Save Left Color To/10", NULL,
gradient_editor_save_left_cmd_callback, 9 },
NULL,
NULL, NULL },
SEPARATOR ("/---"),
{ { N_("/Right Endpoint's Color..."), NULL,
gradient_editor_right_color_cmd_callback, 0 },
NULL,
NULL, NULL },
{ { N_("/Load Right Color From/Right Neighbor's Left Endpoint"), NULL,
gradient_editor_load_right_cmd_callback, 0 },
NULL,
NULL, NULL },
{ { N_("/Load Right Color From/Left Endpoint"), NULL,
gradient_editor_load_right_cmd_callback, 1 },
NULL,
NULL, NULL },
{ { N_("/Load Right Color From/FG Color"), NULL,
gradient_editor_load_right_cmd_callback, 2 },
NULL,
NULL, NULL },
{ { N_("/Load Right Color From/BG Color"), NULL,
gradient_editor_load_right_cmd_callback, 3 },
NULL,
NULL, NULL },
SEPARATOR ("/Load Right Color From/---"),
{ { "/Load Right Color From/01", NULL,
gradient_editor_load_right_cmd_callback, 4 },
NULL,
NULL, NULL },
{ { "/Load Right Color From/02", NULL,
gradient_editor_load_right_cmd_callback, 5 },
NULL,
NULL, NULL },
{ { "/Load Right Color From/03", NULL,
gradient_editor_load_right_cmd_callback, 6 },
NULL,
NULL, NULL },
{ { "/Load Right Color From/04", NULL,
gradient_editor_load_right_cmd_callback, 7 },
NULL,
NULL, NULL },
{ { "/Load Right Color From/05", NULL,
gradient_editor_load_right_cmd_callback, 8 },
NULL,
NULL, NULL },
{ { "/Load Right Color From/06", NULL,
gradient_editor_load_right_cmd_callback, 9 },
NULL,
NULL, NULL },
{ { "/Load Right Color From/07", NULL,
gradient_editor_load_right_cmd_callback, 10 },
NULL,
NULL, NULL },
{ { "/Load Right Color From/08", NULL,
gradient_editor_load_right_cmd_callback, 11 },
NULL,
NULL, NULL },
{ { "/Load Right Color From/09", NULL,
gradient_editor_load_right_cmd_callback, 12 },
NULL,
NULL, NULL },
{ { "/Load Right Color From/10", NULL,
gradient_editor_load_right_cmd_callback, 13 },
NULL,
NULL, NULL },
BRANCH (N_("/Save Right Color To")),
{ { "/Save Right Color To/01", NULL,
gradient_editor_save_right_cmd_callback, 0 },
NULL,
NULL, NULL },
{ { "/Save Right Color To/02", NULL,
gradient_editor_save_right_cmd_callback, 1 },
NULL,
NULL, NULL },
{ { "/Save Right Color To/03", NULL,
gradient_editor_save_right_cmd_callback, 2 },
NULL,
NULL, NULL },
{ { "/Save Right Color To/04", NULL,
gradient_editor_save_right_cmd_callback, 3 },
NULL,
NULL, NULL },
{ { "/Save Right Color To/05", NULL,
gradient_editor_save_right_cmd_callback, 4 },
NULL,
NULL, NULL },
{ { "/Save Right Color To/06", NULL,
gradient_editor_save_right_cmd_callback, 5 },
NULL,
NULL, NULL },
{ { "/Save Right Color To/07", NULL,
gradient_editor_save_right_cmd_callback, 6 },
NULL,
NULL, NULL },
{ { "/Save Right Color To/08", NULL,
gradient_editor_save_right_cmd_callback, 7 },
NULL,
NULL, NULL },
{ { "/Save Right Color To/09", NULL,
gradient_editor_save_right_cmd_callback, 8 },
NULL,
NULL, NULL },
{ { "/Save Right Color To/10", NULL,
gradient_editor_save_right_cmd_callback, 9 },
NULL,
NULL, NULL },
SEPARATOR ("/---"),
{ { N_("/blendingfunction/Linear"), NULL,
gradient_editor_blending_func_cmd_callback,
GRAD_LINEAR, "<RadioItem>" },
NULL,
NULL, NULL },
{ { N_("/blendingfunction/Curved"), NULL,
gradient_editor_blending_func_cmd_callback,
GRAD_CURVED, "/blendingfunction/Linear" },
NULL,
NULL, NULL },
{ { N_("/blendingfunction/Sinusodial"), NULL,
gradient_editor_blending_func_cmd_callback,
GRAD_SINE, "/blendingfunction/Linear" },
NULL,
NULL, NULL },
{ { N_("/blendingfunction/Spherical (increasing)"), NULL,
gradient_editor_blending_func_cmd_callback,
GRAD_SPHERE_INCREASING, "/blendingfunction/Linear" },
NULL,
NULL, NULL },
{ { N_("/blendingfunction/Spherical (decreasing)"), NULL,
gradient_editor_blending_func_cmd_callback,
GRAD_SPHERE_DECREASING, "/blendingfunction/Linear" },
NULL,
NULL, NULL },
{ { N_("/blendingfunction/(Varies)"), NULL, NULL,
0, "/blendingfunction/Linear" },
NULL,
NULL, NULL },
{ { N_("/coloringtype/RGB"), NULL,
gradient_editor_coloring_type_cmd_callback,
GRAD_RGB, "<RadioItem>" },
NULL,
NULL, NULL },
{ { N_("/coloringtype/HSV (counter-clockwise hue)"), NULL,
gradient_editor_coloring_type_cmd_callback,
GRAD_HSV_CCW, "/coloringtype/RGB" },
NULL,
NULL, NULL },
{ { N_("/coloringtype/HSV (clockwise hue)"), NULL,
gradient_editor_coloring_type_cmd_callback,
GRAD_HSV_CW, "/coloringtype/RGB" },
NULL,
NULL, NULL },
{ { N_("/coloringtype/(Varies)"), NULL, NULL,
0, "/coloringtype/RGB" },
NULL,
NULL, NULL },
SEPARATOR ("/---"),
{ { "/flip", "F",
gradient_editor_flip_cmd_callback, 0 },
NULL,
NULL, NULL },
{ { "/replicate", "R",
gradient_editor_replicate_cmd_callback, 0 },
NULL,
NULL, NULL },
{ { "/splitmidpoint", "S",
gradient_editor_split_midpoint_cmd_callback, 0 },
NULL,
NULL, NULL },
{ { "/splituniformly", "U",
gradient_editor_split_uniformly_cmd_callback, 0 },
NULL,
NULL, NULL },
{ { "/delete", "D",
gradient_editor_delete_cmd_callback, 0 },
NULL,
NULL, NULL },
{ { "/recenter", "C",
gradient_editor_recenter_cmd_callback, 0 },
NULL,
NULL, NULL },
{ { "/redistribute", "<control>C",
gradient_editor_redistribute_cmd_callback, 0 },
NULL,
NULL, NULL },
SEPARATOR ("/---"),
{ { N_("/Blend Endpoints' Colors"), "B",
gradient_editor_blend_color_cmd_callback, 0 },
NULL,
NULL, NULL },
{ { N_("/Blend Endpoints' Opacity"), "<control>B",
gradient_editor_blend_opacity_cmd_callback, 0 },
NULL,
NULL, NULL },
};
/***** <Gradients> *****/
static GimpItemFactoryEntry gradients_entries[] =
@ -1601,20 +1920,21 @@ static GimpItemFactoryEntry documents_entries[] =
static gboolean menus_initialized = FALSE;
static GtkItemFactory *toolbox_factory = NULL;
static GtkItemFactory *image_factory = NULL;
static GtkItemFactory *load_factory = NULL;
static GtkItemFactory *save_factory = NULL;
static GtkItemFactory *layers_factory = NULL;
static GtkItemFactory *channels_factory = NULL;
static GtkItemFactory *paths_factory = NULL;
static GtkItemFactory *dialogs_factory = NULL;
static GtkItemFactory *brushes_factory = NULL;
static GtkItemFactory *patterns_factory = NULL;
static GtkItemFactory *gradients_factory = NULL;
static GtkItemFactory *palettes_factory = NULL;
static GtkItemFactory *buffers_factory = NULL;
static GtkItemFactory *documents_factory = NULL;
static GtkItemFactory *toolbox_factory = NULL;
static GtkItemFactory *image_factory = NULL;
static GtkItemFactory *load_factory = NULL;
static GtkItemFactory *save_factory = NULL;
static GtkItemFactory *layers_factory = NULL;
static GtkItemFactory *channels_factory = NULL;
static GtkItemFactory *paths_factory = NULL;
static GtkItemFactory *dialogs_factory = NULL;
static GtkItemFactory *brushes_factory = NULL;
static GtkItemFactory *patterns_factory = NULL;
static GtkItemFactory *gradient_editor_factory = NULL;
static GtkItemFactory *gradients_factory = NULL;
static GtkItemFactory *palettes_factory = NULL;
static GtkItemFactory *buffers_factory = NULL;
static GtkItemFactory *documents_factory = NULL;
/* public functions */
@ -1760,6 +2080,13 @@ menus_init (Gimp *gimp)
gimp,
FALSE);
gradient_editor_factory = menus_item_factory_new (GTK_TYPE_MENU,
"<GradientEditor>", "gradient_editor",
G_N_ELEMENTS (gradient_editor_entries),
gradient_editor_entries,
gimp,
FALSE);
gradients_factory = menus_item_factory_new (GTK_TYPE_MENU,
"<Gradients>", "gradients",
G_N_ELEMENTS (gradients_entries),
@ -1931,6 +2258,12 @@ menus_exit (Gimp *gimp)
patterns_factory = NULL;
}
if (gradient_editor_factory)
{
g_object_unref (G_OBJECT (gradient_editor_factory));
gradient_editor_factory = NULL;
}
if (gradients_factory)
{
g_object_unref (G_OBJECT (gradients_factory));
@ -2205,6 +2538,12 @@ menus_get_patterns_factory (void)
return patterns_factory;
}
GtkItemFactory *
menus_get_gradient_editor_factory (void)
{
return gradient_editor_factory;
}
GtkItemFactory *
menus_get_gradients_factory (void)
{
@ -2264,6 +2603,222 @@ menus_create_item_from_full_path (GimpItemFactoryEntry *entry,
menus_create_item (item_factory, entry, callback_data, 2, TRUE, FALSE);
}
void
menus_set_active (gchar *path,
gboolean active)
{
GtkItemFactory *ifactory;
GtkWidget *widget = NULL;
g_return_if_fail (path != NULL);
g_return_if_fail (menus_initialized);
ifactory = gtk_item_factory_from_path (path);
if (ifactory)
{
widget = gtk_item_factory_get_widget (ifactory, path);
if (widget && GTK_IS_CHECK_MENU_ITEM (widget))
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (widget), active);
else
widget = NULL;
}
if ((!ifactory || !widget) && ! strstr (path, "Script-Fu"))
g_warning ("Unable to set \"active\" for menu which doesn't exist:\n%s",
path);
}
void
menus_set_color (gchar *path,
const GimpRGB *color,
gboolean set_label)
{
GtkItemFactory *ifactory;
GtkWidget *widget;
GtkWidget *preview = NULL;
GtkWidget *label = NULL;
g_return_if_fail (path != NULL);
g_return_if_fail (color != NULL);
g_return_if_fail (menus_initialized);
ifactory = gtk_item_factory_from_path (path);
#define COLOR_BOX_WIDTH 24
#define COLOR_BOX_HEIGHT 16
if (! ifactory)
return;
widget = gtk_item_factory_get_widget (ifactory, path);
if (! widget)
return;
if (GTK_IS_HBOX (GTK_BIN (widget)->child))
{
preview = g_object_get_data (G_OBJECT (GTK_BIN (widget)->child),
"preview");
label = g_object_get_data (G_OBJECT (GTK_BIN (widget)->child),
"label");
}
else if (GTK_IS_LABEL (GTK_BIN (widget)->child))
{
GtkWidget *hbox;
label = GTK_BIN (widget)->child;
g_object_ref (G_OBJECT (label));
gtk_container_remove (GTK_CONTAINER (widget), label);
hbox = gtk_hbox_new (FALSE, 4);
gtk_container_add (GTK_CONTAINER (widget), hbox);
gtk_widget_show (hbox);
preview = gtk_preview_new (GTK_PREVIEW_COLOR);
gtk_preview_size (GTK_PREVIEW (preview),
COLOR_BOX_WIDTH, COLOR_BOX_HEIGHT);
gtk_box_pack_start (GTK_BOX (hbox), preview, FALSE, FALSE, 0);
gtk_widget_show (preview);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
g_object_unref (G_OBJECT (label));
g_object_set_data (G_OBJECT (hbox), "preview", preview);
g_object_set_data (G_OBJECT (hbox), "label", label);
}
if (preview)
{
guchar rows[3][COLOR_BOX_WIDTH * 3];
gint x, y;
gint r0, g0, b0;
gint r1, g1, b1;
guchar *p0, *p1, *p2;
/* Fill rows */
r0 = (GIMP_CHECK_DARK + (color->r - GIMP_CHECK_DARK) * color->a) * 255.0;
r1 = (GIMP_CHECK_LIGHT + (color->r - GIMP_CHECK_LIGHT) * color->a) * 255.0;
g0 = (GIMP_CHECK_DARK + (color->g - GIMP_CHECK_DARK) * color->a) * 255.0;
g1 = (GIMP_CHECK_LIGHT + (color->g - GIMP_CHECK_LIGHT) * color->a) * 255.0;
b0 = (GIMP_CHECK_DARK + (color->b - GIMP_CHECK_DARK) * color->a) * 255.0;
b1 = (GIMP_CHECK_LIGHT + (color->b - GIMP_CHECK_LIGHT) * color->a) * 255.0;
p0 = rows[0];
p1 = rows[1];
p2 = rows[2];
for (x = 0; x < COLOR_BOX_WIDTH; x++)
{
if ((x == 0) || (x == (COLOR_BOX_WIDTH - 1)))
{
*p0++ = 0;
*p0++ = 0;
*p0++ = 0;
*p1++ = 0;
*p1++ = 0;
*p1++ = 0;
}
else if ((x / GIMP_CHECK_SIZE) & 1)
{
*p0++ = r1;
*p0++ = g1;
*p0++ = b1;
*p1++ = r0;
*p1++ = g0;
*p1++ = b0;
}
else
{
*p0++ = r0;
*p0++ = g0;
*p0++ = b0;
*p1++ = r1;
*p1++ = g1;
*p1++ = b1;
}
*p2++ = 0;
*p2++ = 0;
*p2++ = 0;
}
/* Fill preview */
gtk_preview_draw_row (GTK_PREVIEW (preview), rows[2],
0, 0, COLOR_BOX_WIDTH);
for (y = 1; y < (COLOR_BOX_HEIGHT - 1); y++)
if ((y / GIMP_CHECK_SIZE) & 1)
gtk_preview_draw_row (GTK_PREVIEW (preview), rows[1],
0, y, COLOR_BOX_WIDTH);
else
gtk_preview_draw_row (GTK_PREVIEW (preview), rows[0],
0, y, COLOR_BOX_WIDTH);
gtk_preview_draw_row (GTK_PREVIEW (preview), rows[2],
0, y, COLOR_BOX_WIDTH);
}
if (label && set_label)
{
gchar *str;
str = g_strdup_printf (_("RGBA (%0.3f, %0.3f, %0.3f, %0.3f)"),
color->r, color->g, color->b, color->a);
gtk_label_set_text (GTK_LABEL (label), str);
g_free (str);
}
#undef COLOR_BOX_WIDTH
#undef COLOR_BOX_HEIGHT
}
void
menus_set_label (gchar *path,
const gchar *label)
{
GtkItemFactory *ifactory;
GtkWidget *widget = NULL;
g_return_if_fail (path != NULL);
g_return_if_fail (label != NULL);
g_return_if_fail (menus_initialized);
ifactory = gtk_item_factory_from_path (path);
if (ifactory)
{
widget = gtk_item_factory_get_widget (ifactory, path);
if (widget)
{
if (GTK_IS_MENU (widget))
{
widget = gtk_menu_get_attach_widget (GTK_MENU (widget));
}
if (GTK_IS_LABEL (GTK_BIN (widget)->child))
{
gtk_label_set_text (GTK_LABEL (GTK_BIN (widget)->child), label);
}
}
}
}
void
menus_set_sensitive (gchar *path,
gboolean sensitive)
@ -2290,11 +2845,11 @@ menus_set_sensitive (gchar *path,
}
void
menus_set_state (gchar *path,
gboolean state)
menus_set_visible (gchar *path,
gboolean visible)
{
GtkItemFactory *ifactory;
GtkWidget *widget = NULL;
GtkWidget *widget;
g_return_if_fail (path != NULL);
g_return_if_fail (menus_initialized);
@ -2305,15 +2860,14 @@ menus_set_state (gchar *path,
{
widget = gtk_item_factory_get_widget (ifactory, path);
if (widget && GTK_IS_CHECK_MENU_ITEM (widget))
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (widget), state);
else
widget = NULL;
if (widget)
{
if (visible)
gtk_widget_show (widget);
else
gtk_widget_hide (widget);
}
}
if ((!ifactory || !widget) && ! strstr (path, "Script-Fu"))
g_warning ("Unable to set state for menu which doesn't exist:\n%s",
path);
}
void

View File

@ -33,34 +33,43 @@ struct _GimpItemFactoryEntry
};
void menus_init (Gimp *gimp);
void menus_exit (Gimp *gimp);
void menus_restore (Gimp *gimp);
void menus_init (Gimp *gimp);
void menus_exit (Gimp *gimp);
void menus_restore (Gimp *gimp);
GtkItemFactory * menus_get_toolbox_factory (void);
GtkItemFactory * menus_get_image_factory (void);
GtkItemFactory * menus_get_load_factory (void);
GtkItemFactory * menus_get_save_factory (void);
GtkItemFactory * menus_get_layers_factory (void);
GtkItemFactory * menus_get_channels_factory (void);
GtkItemFactory * menus_get_paths_factory (void);
GtkItemFactory * menus_get_dialogs_factory (void);
GtkItemFactory * menus_get_brushes_factory (void);
GtkItemFactory * menus_get_patterns_factory (void);
GtkItemFactory * menus_get_gradients_factory (void);
GtkItemFactory * menus_get_palettes_factory (void);
GtkItemFactory * menus_get_buffers_factory (void);
GtkItemFactory * menus_get_documents_factory (void);
GtkItemFactory * menus_get_toolbox_factory (void);
GtkItemFactory * menus_get_image_factory (void);
GtkItemFactory * menus_get_load_factory (void);
GtkItemFactory * menus_get_save_factory (void);
GtkItemFactory * menus_get_layers_factory (void);
GtkItemFactory * menus_get_channels_factory (void);
GtkItemFactory * menus_get_paths_factory (void);
GtkItemFactory * menus_get_dialogs_factory (void);
GtkItemFactory * menus_get_brushes_factory (void);
GtkItemFactory * menus_get_patterns_factory (void);
GtkItemFactory * menus_get_gradient_editor_factory (void);
GtkItemFactory * menus_get_gradients_factory (void);
GtkItemFactory * menus_get_palettes_factory (void);
GtkItemFactory * menus_get_buffers_factory (void);
GtkItemFactory * menus_get_documents_factory (void);
void menus_create_item_from_full_path (GimpItemFactoryEntry *entry,
gchar *domain_name,
gpointer callback_data);
void menus_set_active (gchar *path,
gboolean state);
void menus_set_color (gchar *path,
const GimpRGB *color,
gboolean set_label);
void menus_set_label (gchar *path,
const gchar *label);
void menus_set_sensitive (gchar *path,
gboolean sensitive);
void menus_set_state (gchar *path,
gboolean state);
void menus_set_visible (gchar *path,
gboolean visible);
void menus_destroy (gchar *path);

View File

@ -23,9 +23,7 @@
#include "libgimpmath/gimpmath.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "core/core-types.h"
#include "tools/tools-types.h"
#include "widgets/widgets-types.h"
#include "gui-types.h"
#include "core/gimp.h"
#include "core/gimpchannel.h"
@ -50,7 +48,6 @@
#include "tools/tool_manager.h"
#include "dialogs.h"
#include "gradient-editor.h"
#include "gimprc.h"

View File

@ -53,6 +53,7 @@
#include "documents-commands.h"
#include "edit-commands.h"
#include "file-commands.h"
#include "gradient-editor-commands.h"
#include "gradients-commands.h"
#include "image-commands.h"
#include "layers-commands.h"
@ -1446,6 +1447,324 @@ static GimpItemFactoryEntry patterns_entries[] =
};
/***** <GradientEditor> *****/
static GimpItemFactoryEntry gradient_editor_entries[] =
{
{ { N_("/Left Endpoint's Color..."), NULL,
gradient_editor_left_color_cmd_callback, 0 },
NULL,
NULL, NULL },
{ { N_("/Load Left Color From/Left Neighbor's Right Endpoint"), NULL,
gradient_editor_load_left_cmd_callback, 0 },
NULL,
NULL, NULL },
{ { N_("/Load Left Color From/Right Endpoint"), NULL,
gradient_editor_load_left_cmd_callback, 1 },
NULL,
NULL, NULL },
{ { N_("/Load Left Color From/FG Color"), NULL,
gradient_editor_load_left_cmd_callback, 2 },
NULL,
NULL, NULL },
{ { N_("/Load Left Color From/BG Color"), NULL,
gradient_editor_load_left_cmd_callback, 3 },
NULL,
NULL, NULL },
SEPARATOR ("/Load Left Color From/---"),
{ { "/Load Left Color From/01", NULL,
gradient_editor_load_left_cmd_callback, 4 },
NULL,
NULL, NULL },
{ { "/Load Left Color From/02", NULL,
gradient_editor_load_left_cmd_callback, 5 },
NULL,
NULL, NULL },
{ { "/Load Left Color From/03", NULL,
gradient_editor_load_left_cmd_callback, 6 },
NULL,
NULL, NULL },
{ { "/Load Left Color From/04", NULL,
gradient_editor_load_left_cmd_callback, 7 },
NULL,
NULL, NULL },
{ { "/Load Left Color From/05", NULL,
gradient_editor_load_left_cmd_callback, 8 },
NULL,
NULL, NULL },
{ { "/Load Left Color From/06", NULL,
gradient_editor_load_left_cmd_callback, 9 },
NULL,
NULL, NULL },
{ { "/Load Left Color From/07", NULL,
gradient_editor_load_left_cmd_callback, 10 },
NULL,
NULL, NULL },
{ { "/Load Left Color From/08", NULL,
gradient_editor_load_left_cmd_callback, 11 },
NULL,
NULL, NULL },
{ { "/Load Left Color From/09", NULL,
gradient_editor_load_left_cmd_callback, 12 },
NULL,
NULL, NULL },
{ { "/Load Left Color From/10", NULL,
gradient_editor_load_left_cmd_callback, 13 },
NULL,
NULL, NULL },
BRANCH (N_("/Save Left Color To")),
{ { "/Save Left Color To/01", NULL,
gradient_editor_save_left_cmd_callback, 0 },
NULL,
NULL, NULL },
{ { "/Save Left Color To/02", NULL,
gradient_editor_save_left_cmd_callback, 1 },
NULL,
NULL, NULL },
{ { "/Save Left Color To/03", NULL,
gradient_editor_save_left_cmd_callback, 2 },
NULL,
NULL, NULL },
{ { "/Save Left Color To/04", NULL,
gradient_editor_save_left_cmd_callback, 3 },
NULL,
NULL, NULL },
{ { "/Save Left Color To/05", NULL,
gradient_editor_save_left_cmd_callback, 4 },
NULL,
NULL, NULL },
{ { "/Save Left Color To/06", NULL,
gradient_editor_save_left_cmd_callback, 5 },
NULL,
NULL, NULL },
{ { "/Save Left Color To/07", NULL,
gradient_editor_save_left_cmd_callback, 6 },
NULL,
NULL, NULL },
{ { "/Save Left Color To/08", NULL,
gradient_editor_save_left_cmd_callback, 7 },
NULL,
NULL, NULL },
{ { "/Save Left Color To/09", NULL,
gradient_editor_save_left_cmd_callback, 8 },
NULL,
NULL, NULL },
{ { "/Save Left Color To/10", NULL,
gradient_editor_save_left_cmd_callback, 9 },
NULL,
NULL, NULL },
SEPARATOR ("/---"),
{ { N_("/Right Endpoint's Color..."), NULL,
gradient_editor_right_color_cmd_callback, 0 },
NULL,
NULL, NULL },
{ { N_("/Load Right Color From/Right Neighbor's Left Endpoint"), NULL,
gradient_editor_load_right_cmd_callback, 0 },
NULL,
NULL, NULL },
{ { N_("/Load Right Color From/Left Endpoint"), NULL,
gradient_editor_load_right_cmd_callback, 1 },
NULL,
NULL, NULL },
{ { N_("/Load Right Color From/FG Color"), NULL,
gradient_editor_load_right_cmd_callback, 2 },
NULL,
NULL, NULL },
{ { N_("/Load Right Color From/BG Color"), NULL,
gradient_editor_load_right_cmd_callback, 3 },
NULL,
NULL, NULL },
SEPARATOR ("/Load Right Color From/---"),
{ { "/Load Right Color From/01", NULL,
gradient_editor_load_right_cmd_callback, 4 },
NULL,
NULL, NULL },
{ { "/Load Right Color From/02", NULL,
gradient_editor_load_right_cmd_callback, 5 },
NULL,
NULL, NULL },
{ { "/Load Right Color From/03", NULL,
gradient_editor_load_right_cmd_callback, 6 },
NULL,
NULL, NULL },
{ { "/Load Right Color From/04", NULL,
gradient_editor_load_right_cmd_callback, 7 },
NULL,
NULL, NULL },
{ { "/Load Right Color From/05", NULL,
gradient_editor_load_right_cmd_callback, 8 },
NULL,
NULL, NULL },
{ { "/Load Right Color From/06", NULL,
gradient_editor_load_right_cmd_callback, 9 },
NULL,
NULL, NULL },
{ { "/Load Right Color From/07", NULL,
gradient_editor_load_right_cmd_callback, 10 },
NULL,
NULL, NULL },
{ { "/Load Right Color From/08", NULL,
gradient_editor_load_right_cmd_callback, 11 },
NULL,
NULL, NULL },
{ { "/Load Right Color From/09", NULL,
gradient_editor_load_right_cmd_callback, 12 },
NULL,
NULL, NULL },
{ { "/Load Right Color From/10", NULL,
gradient_editor_load_right_cmd_callback, 13 },
NULL,
NULL, NULL },
BRANCH (N_("/Save Right Color To")),
{ { "/Save Right Color To/01", NULL,
gradient_editor_save_right_cmd_callback, 0 },
NULL,
NULL, NULL },
{ { "/Save Right Color To/02", NULL,
gradient_editor_save_right_cmd_callback, 1 },
NULL,
NULL, NULL },
{ { "/Save Right Color To/03", NULL,
gradient_editor_save_right_cmd_callback, 2 },
NULL,
NULL, NULL },
{ { "/Save Right Color To/04", NULL,
gradient_editor_save_right_cmd_callback, 3 },
NULL,
NULL, NULL },
{ { "/Save Right Color To/05", NULL,
gradient_editor_save_right_cmd_callback, 4 },
NULL,
NULL, NULL },
{ { "/Save Right Color To/06", NULL,
gradient_editor_save_right_cmd_callback, 5 },
NULL,
NULL, NULL },
{ { "/Save Right Color To/07", NULL,
gradient_editor_save_right_cmd_callback, 6 },
NULL,
NULL, NULL },
{ { "/Save Right Color To/08", NULL,
gradient_editor_save_right_cmd_callback, 7 },
NULL,
NULL, NULL },
{ { "/Save Right Color To/09", NULL,
gradient_editor_save_right_cmd_callback, 8 },
NULL,
NULL, NULL },
{ { "/Save Right Color To/10", NULL,
gradient_editor_save_right_cmd_callback, 9 },
NULL,
NULL, NULL },
SEPARATOR ("/---"),
{ { N_("/blendingfunction/Linear"), NULL,
gradient_editor_blending_func_cmd_callback,
GRAD_LINEAR, "<RadioItem>" },
NULL,
NULL, NULL },
{ { N_("/blendingfunction/Curved"), NULL,
gradient_editor_blending_func_cmd_callback,
GRAD_CURVED, "/blendingfunction/Linear" },
NULL,
NULL, NULL },
{ { N_("/blendingfunction/Sinusodial"), NULL,
gradient_editor_blending_func_cmd_callback,
GRAD_SINE, "/blendingfunction/Linear" },
NULL,
NULL, NULL },
{ { N_("/blendingfunction/Spherical (increasing)"), NULL,
gradient_editor_blending_func_cmd_callback,
GRAD_SPHERE_INCREASING, "/blendingfunction/Linear" },
NULL,
NULL, NULL },
{ { N_("/blendingfunction/Spherical (decreasing)"), NULL,
gradient_editor_blending_func_cmd_callback,
GRAD_SPHERE_DECREASING, "/blendingfunction/Linear" },
NULL,
NULL, NULL },
{ { N_("/blendingfunction/(Varies)"), NULL, NULL,
0, "/blendingfunction/Linear" },
NULL,
NULL, NULL },
{ { N_("/coloringtype/RGB"), NULL,
gradient_editor_coloring_type_cmd_callback,
GRAD_RGB, "<RadioItem>" },
NULL,
NULL, NULL },
{ { N_("/coloringtype/HSV (counter-clockwise hue)"), NULL,
gradient_editor_coloring_type_cmd_callback,
GRAD_HSV_CCW, "/coloringtype/RGB" },
NULL,
NULL, NULL },
{ { N_("/coloringtype/HSV (clockwise hue)"), NULL,
gradient_editor_coloring_type_cmd_callback,
GRAD_HSV_CW, "/coloringtype/RGB" },
NULL,
NULL, NULL },
{ { N_("/coloringtype/(Varies)"), NULL, NULL,
0, "/coloringtype/RGB" },
NULL,
NULL, NULL },
SEPARATOR ("/---"),
{ { "/flip", "F",
gradient_editor_flip_cmd_callback, 0 },
NULL,
NULL, NULL },
{ { "/replicate", "R",
gradient_editor_replicate_cmd_callback, 0 },
NULL,
NULL, NULL },
{ { "/splitmidpoint", "S",
gradient_editor_split_midpoint_cmd_callback, 0 },
NULL,
NULL, NULL },
{ { "/splituniformly", "U",
gradient_editor_split_uniformly_cmd_callback, 0 },
NULL,
NULL, NULL },
{ { "/delete", "D",
gradient_editor_delete_cmd_callback, 0 },
NULL,
NULL, NULL },
{ { "/recenter", "C",
gradient_editor_recenter_cmd_callback, 0 },
NULL,
NULL, NULL },
{ { "/redistribute", "<control>C",
gradient_editor_redistribute_cmd_callback, 0 },
NULL,
NULL, NULL },
SEPARATOR ("/---"),
{ { N_("/Blend Endpoints' Colors"), "B",
gradient_editor_blend_color_cmd_callback, 0 },
NULL,
NULL, NULL },
{ { N_("/Blend Endpoints' Opacity"), "<control>B",
gradient_editor_blend_opacity_cmd_callback, 0 },
NULL,
NULL, NULL },
};
/***** <Gradients> *****/
static GimpItemFactoryEntry gradients_entries[] =
@ -1601,20 +1920,21 @@ static GimpItemFactoryEntry documents_entries[] =
static gboolean menus_initialized = FALSE;
static GtkItemFactory *toolbox_factory = NULL;
static GtkItemFactory *image_factory = NULL;
static GtkItemFactory *load_factory = NULL;
static GtkItemFactory *save_factory = NULL;
static GtkItemFactory *layers_factory = NULL;
static GtkItemFactory *channels_factory = NULL;
static GtkItemFactory *paths_factory = NULL;
static GtkItemFactory *dialogs_factory = NULL;
static GtkItemFactory *brushes_factory = NULL;
static GtkItemFactory *patterns_factory = NULL;
static GtkItemFactory *gradients_factory = NULL;
static GtkItemFactory *palettes_factory = NULL;
static GtkItemFactory *buffers_factory = NULL;
static GtkItemFactory *documents_factory = NULL;
static GtkItemFactory *toolbox_factory = NULL;
static GtkItemFactory *image_factory = NULL;
static GtkItemFactory *load_factory = NULL;
static GtkItemFactory *save_factory = NULL;
static GtkItemFactory *layers_factory = NULL;
static GtkItemFactory *channels_factory = NULL;
static GtkItemFactory *paths_factory = NULL;
static GtkItemFactory *dialogs_factory = NULL;
static GtkItemFactory *brushes_factory = NULL;
static GtkItemFactory *patterns_factory = NULL;
static GtkItemFactory *gradient_editor_factory = NULL;
static GtkItemFactory *gradients_factory = NULL;
static GtkItemFactory *palettes_factory = NULL;
static GtkItemFactory *buffers_factory = NULL;
static GtkItemFactory *documents_factory = NULL;
/* public functions */
@ -1760,6 +2080,13 @@ menus_init (Gimp *gimp)
gimp,
FALSE);
gradient_editor_factory = menus_item_factory_new (GTK_TYPE_MENU,
"<GradientEditor>", "gradient_editor",
G_N_ELEMENTS (gradient_editor_entries),
gradient_editor_entries,
gimp,
FALSE);
gradients_factory = menus_item_factory_new (GTK_TYPE_MENU,
"<Gradients>", "gradients",
G_N_ELEMENTS (gradients_entries),
@ -1931,6 +2258,12 @@ menus_exit (Gimp *gimp)
patterns_factory = NULL;
}
if (gradient_editor_factory)
{
g_object_unref (G_OBJECT (gradient_editor_factory));
gradient_editor_factory = NULL;
}
if (gradients_factory)
{
g_object_unref (G_OBJECT (gradients_factory));
@ -2205,6 +2538,12 @@ menus_get_patterns_factory (void)
return patterns_factory;
}
GtkItemFactory *
menus_get_gradient_editor_factory (void)
{
return gradient_editor_factory;
}
GtkItemFactory *
menus_get_gradients_factory (void)
{
@ -2264,6 +2603,222 @@ menus_create_item_from_full_path (GimpItemFactoryEntry *entry,
menus_create_item (item_factory, entry, callback_data, 2, TRUE, FALSE);
}
void
menus_set_active (gchar *path,
gboolean active)
{
GtkItemFactory *ifactory;
GtkWidget *widget = NULL;
g_return_if_fail (path != NULL);
g_return_if_fail (menus_initialized);
ifactory = gtk_item_factory_from_path (path);
if (ifactory)
{
widget = gtk_item_factory_get_widget (ifactory, path);
if (widget && GTK_IS_CHECK_MENU_ITEM (widget))
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (widget), active);
else
widget = NULL;
}
if ((!ifactory || !widget) && ! strstr (path, "Script-Fu"))
g_warning ("Unable to set \"active\" for menu which doesn't exist:\n%s",
path);
}
void
menus_set_color (gchar *path,
const GimpRGB *color,
gboolean set_label)
{
GtkItemFactory *ifactory;
GtkWidget *widget;
GtkWidget *preview = NULL;
GtkWidget *label = NULL;
g_return_if_fail (path != NULL);
g_return_if_fail (color != NULL);
g_return_if_fail (menus_initialized);
ifactory = gtk_item_factory_from_path (path);
#define COLOR_BOX_WIDTH 24
#define COLOR_BOX_HEIGHT 16
if (! ifactory)
return;
widget = gtk_item_factory_get_widget (ifactory, path);
if (! widget)
return;
if (GTK_IS_HBOX (GTK_BIN (widget)->child))
{
preview = g_object_get_data (G_OBJECT (GTK_BIN (widget)->child),
"preview");
label = g_object_get_data (G_OBJECT (GTK_BIN (widget)->child),
"label");
}
else if (GTK_IS_LABEL (GTK_BIN (widget)->child))
{
GtkWidget *hbox;
label = GTK_BIN (widget)->child;
g_object_ref (G_OBJECT (label));
gtk_container_remove (GTK_CONTAINER (widget), label);
hbox = gtk_hbox_new (FALSE, 4);
gtk_container_add (GTK_CONTAINER (widget), hbox);
gtk_widget_show (hbox);
preview = gtk_preview_new (GTK_PREVIEW_COLOR);
gtk_preview_size (GTK_PREVIEW (preview),
COLOR_BOX_WIDTH, COLOR_BOX_HEIGHT);
gtk_box_pack_start (GTK_BOX (hbox), preview, FALSE, FALSE, 0);
gtk_widget_show (preview);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
g_object_unref (G_OBJECT (label));
g_object_set_data (G_OBJECT (hbox), "preview", preview);
g_object_set_data (G_OBJECT (hbox), "label", label);
}
if (preview)
{
guchar rows[3][COLOR_BOX_WIDTH * 3];
gint x, y;
gint r0, g0, b0;
gint r1, g1, b1;
guchar *p0, *p1, *p2;
/* Fill rows */
r0 = (GIMP_CHECK_DARK + (color->r - GIMP_CHECK_DARK) * color->a) * 255.0;
r1 = (GIMP_CHECK_LIGHT + (color->r - GIMP_CHECK_LIGHT) * color->a) * 255.0;
g0 = (GIMP_CHECK_DARK + (color->g - GIMP_CHECK_DARK) * color->a) * 255.0;
g1 = (GIMP_CHECK_LIGHT + (color->g - GIMP_CHECK_LIGHT) * color->a) * 255.0;
b0 = (GIMP_CHECK_DARK + (color->b - GIMP_CHECK_DARK) * color->a) * 255.0;
b1 = (GIMP_CHECK_LIGHT + (color->b - GIMP_CHECK_LIGHT) * color->a) * 255.0;
p0 = rows[0];
p1 = rows[1];
p2 = rows[2];
for (x = 0; x < COLOR_BOX_WIDTH; x++)
{
if ((x == 0) || (x == (COLOR_BOX_WIDTH - 1)))
{
*p0++ = 0;
*p0++ = 0;
*p0++ = 0;
*p1++ = 0;
*p1++ = 0;
*p1++ = 0;
}
else if ((x / GIMP_CHECK_SIZE) & 1)
{
*p0++ = r1;
*p0++ = g1;
*p0++ = b1;
*p1++ = r0;
*p1++ = g0;
*p1++ = b0;
}
else
{
*p0++ = r0;
*p0++ = g0;
*p0++ = b0;
*p1++ = r1;
*p1++ = g1;
*p1++ = b1;
}
*p2++ = 0;
*p2++ = 0;
*p2++ = 0;
}
/* Fill preview */
gtk_preview_draw_row (GTK_PREVIEW (preview), rows[2],
0, 0, COLOR_BOX_WIDTH);
for (y = 1; y < (COLOR_BOX_HEIGHT - 1); y++)
if ((y / GIMP_CHECK_SIZE) & 1)
gtk_preview_draw_row (GTK_PREVIEW (preview), rows[1],
0, y, COLOR_BOX_WIDTH);
else
gtk_preview_draw_row (GTK_PREVIEW (preview), rows[0],
0, y, COLOR_BOX_WIDTH);
gtk_preview_draw_row (GTK_PREVIEW (preview), rows[2],
0, y, COLOR_BOX_WIDTH);
}
if (label && set_label)
{
gchar *str;
str = g_strdup_printf (_("RGBA (%0.3f, %0.3f, %0.3f, %0.3f)"),
color->r, color->g, color->b, color->a);
gtk_label_set_text (GTK_LABEL (label), str);
g_free (str);
}
#undef COLOR_BOX_WIDTH
#undef COLOR_BOX_HEIGHT
}
void
menus_set_label (gchar *path,
const gchar *label)
{
GtkItemFactory *ifactory;
GtkWidget *widget = NULL;
g_return_if_fail (path != NULL);
g_return_if_fail (label != NULL);
g_return_if_fail (menus_initialized);
ifactory = gtk_item_factory_from_path (path);
if (ifactory)
{
widget = gtk_item_factory_get_widget (ifactory, path);
if (widget)
{
if (GTK_IS_MENU (widget))
{
widget = gtk_menu_get_attach_widget (GTK_MENU (widget));
}
if (GTK_IS_LABEL (GTK_BIN (widget)->child))
{
gtk_label_set_text (GTK_LABEL (GTK_BIN (widget)->child), label);
}
}
}
}
void
menus_set_sensitive (gchar *path,
gboolean sensitive)
@ -2290,11 +2845,11 @@ menus_set_sensitive (gchar *path,
}
void
menus_set_state (gchar *path,
gboolean state)
menus_set_visible (gchar *path,
gboolean visible)
{
GtkItemFactory *ifactory;
GtkWidget *widget = NULL;
GtkWidget *widget;
g_return_if_fail (path != NULL);
g_return_if_fail (menus_initialized);
@ -2305,15 +2860,14 @@ menus_set_state (gchar *path,
{
widget = gtk_item_factory_get_widget (ifactory, path);
if (widget && GTK_IS_CHECK_MENU_ITEM (widget))
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (widget), state);
else
widget = NULL;
if (widget)
{
if (visible)
gtk_widget_show (widget);
else
gtk_widget_hide (widget);
}
}
if ((!ifactory || !widget) && ! strstr (path, "Script-Fu"))
g_warning ("Unable to set state for menu which doesn't exist:\n%s",
path);
}
void

View File

@ -33,34 +33,43 @@ struct _GimpItemFactoryEntry
};
void menus_init (Gimp *gimp);
void menus_exit (Gimp *gimp);
void menus_restore (Gimp *gimp);
void menus_init (Gimp *gimp);
void menus_exit (Gimp *gimp);
void menus_restore (Gimp *gimp);
GtkItemFactory * menus_get_toolbox_factory (void);
GtkItemFactory * menus_get_image_factory (void);
GtkItemFactory * menus_get_load_factory (void);
GtkItemFactory * menus_get_save_factory (void);
GtkItemFactory * menus_get_layers_factory (void);
GtkItemFactory * menus_get_channels_factory (void);
GtkItemFactory * menus_get_paths_factory (void);
GtkItemFactory * menus_get_dialogs_factory (void);
GtkItemFactory * menus_get_brushes_factory (void);
GtkItemFactory * menus_get_patterns_factory (void);
GtkItemFactory * menus_get_gradients_factory (void);
GtkItemFactory * menus_get_palettes_factory (void);
GtkItemFactory * menus_get_buffers_factory (void);
GtkItemFactory * menus_get_documents_factory (void);
GtkItemFactory * menus_get_toolbox_factory (void);
GtkItemFactory * menus_get_image_factory (void);
GtkItemFactory * menus_get_load_factory (void);
GtkItemFactory * menus_get_save_factory (void);
GtkItemFactory * menus_get_layers_factory (void);
GtkItemFactory * menus_get_channels_factory (void);
GtkItemFactory * menus_get_paths_factory (void);
GtkItemFactory * menus_get_dialogs_factory (void);
GtkItemFactory * menus_get_brushes_factory (void);
GtkItemFactory * menus_get_patterns_factory (void);
GtkItemFactory * menus_get_gradient_editor_factory (void);
GtkItemFactory * menus_get_gradients_factory (void);
GtkItemFactory * menus_get_palettes_factory (void);
GtkItemFactory * menus_get_buffers_factory (void);
GtkItemFactory * menus_get_documents_factory (void);
void menus_create_item_from_full_path (GimpItemFactoryEntry *entry,
gchar *domain_name,
gpointer callback_data);
void menus_set_active (gchar *path,
gboolean state);
void menus_set_color (gchar *path,
const GimpRGB *color,
gboolean set_label);
void menus_set_label (gchar *path,
const gchar *label);
void menus_set_sensitive (gchar *path,
gboolean sensitive);
void menus_set_state (gchar *path,
gboolean state);
void menus_set_visible (gchar *path,
gboolean visible);
void menus_destroy (gchar *path);

View File

@ -185,6 +185,9 @@ gimp_dock_style_set (GtkWidget *widget,
GList *list;
gint separator_height;
if (GTK_WIDGET_CLASS (parent_class)->style_set)
GTK_WIDGET_CLASS (parent_class)->style_set (widget, prev_style);
gtk_widget_style_get (widget,
"separator_height", &separator_height,
NULL);

File diff suppressed because it is too large Load Diff

View File

@ -23,14 +23,89 @@
#define __GRADIENT_EDITOR_H__
typedef struct _GradientEditor GradientEditor;
#define GRAD_NUM_COLORS 10
GradientEditor * gradient_editor_new (Gimp *gimp);
typedef enum
{
GRAD_DRAG_NONE = 0,
GRAD_DRAG_LEFT,
GRAD_DRAG_MIDDLE,
GRAD_DRAG_ALL
} GradientEditorDragMode;
void gradient_editor_set_gradient (GradientEditor *gradient_editor,
GimpGradient *gradient);
void gradient_editor_free (GradientEditor *gradient_editor);
typedef enum
{
GRAD_UPDATE_GRADIENT = 1 << 0,
GRAD_UPDATE_PREVIEW = 1 << 1,
GRAD_UPDATE_CONTROL = 1 << 2,
GRAD_RESET_CONTROL = 1 << 3
} GradientEditorUpdateMask;
struct _GradientEditor
{
GtkWidget *shell;
GtkWidget *name;
GtkWidget *hint_label;
GtkWidget *scrollbar;
GtkWidget *preview;
GtkWidget *control;
GimpContext *context;
/* Zoom and scrollbar */
guint zoom_factor;
GtkObject *scroll_data;
/* Instant update */
gboolean instant_update;
/* Gradient preview */
guchar *preview_rows[2]; /* For caching redraw info */
gint preview_last_x;
gboolean preview_button_down;
/* Gradient control */
GdkPixmap *control_pixmap;
GimpGradientSegment *control_drag_segment; /* Segment which is being dragged */
GimpGradientSegment *control_sel_l; /* Left segment of selection */
GimpGradientSegment *control_sel_r; /* Right segment of selection */
GradientEditorDragMode control_drag_mode; /* What is being dragged? */
guint32 control_click_time; /* Time when mouse was pressed */
gboolean control_compress; /* Compressing/expanding handles */
gint control_last_x; /* Last mouse position when dragging */
gdouble control_last_gx; /* Last position (wrt gradient) when dragging */
gdouble control_orig_pos; /* Original click position when dragging */
/* Split uniformly dialog */
gint split_parts;
/* Replicate dialog */
gint replicate_times;
/* Saved colors */
GimpRGB saved_colors[GRAD_NUM_COLORS];
/* Color dialogs */
GimpGradientSegment *left_saved_segments;
gboolean left_saved_dirty;
GimpGradientSegment *right_saved_segments;
gboolean right_saved_dirty;
};
GradientEditor * gradient_editor_new (Gimp *gimp);
void gradient_editor_set_gradient (GradientEditor *gradient_editor,
GimpGradient *gradient);
void gradient_editor_free (GradientEditor *gradient_editor);
void gradient_editor_update (GradientEditor *gradient_editor,
GradientEditorUpdateMask flags);
#endif /* __GRADIENT_EDITOR_H__ */

View File

@ -53,6 +53,7 @@
#include "documents-commands.h"
#include "edit-commands.h"
#include "file-commands.h"
#include "gradient-editor-commands.h"
#include "gradients-commands.h"
#include "image-commands.h"
#include "layers-commands.h"
@ -1446,6 +1447,324 @@ static GimpItemFactoryEntry patterns_entries[] =
};
/***** <GradientEditor> *****/
static GimpItemFactoryEntry gradient_editor_entries[] =
{
{ { N_("/Left Endpoint's Color..."), NULL,
gradient_editor_left_color_cmd_callback, 0 },
NULL,
NULL, NULL },
{ { N_("/Load Left Color From/Left Neighbor's Right Endpoint"), NULL,
gradient_editor_load_left_cmd_callback, 0 },
NULL,
NULL, NULL },
{ { N_("/Load Left Color From/Right Endpoint"), NULL,
gradient_editor_load_left_cmd_callback, 1 },
NULL,
NULL, NULL },
{ { N_("/Load Left Color From/FG Color"), NULL,
gradient_editor_load_left_cmd_callback, 2 },
NULL,
NULL, NULL },
{ { N_("/Load Left Color From/BG Color"), NULL,
gradient_editor_load_left_cmd_callback, 3 },
NULL,
NULL, NULL },
SEPARATOR ("/Load Left Color From/---"),
{ { "/Load Left Color From/01", NULL,
gradient_editor_load_left_cmd_callback, 4 },
NULL,
NULL, NULL },
{ { "/Load Left Color From/02", NULL,
gradient_editor_load_left_cmd_callback, 5 },
NULL,
NULL, NULL },
{ { "/Load Left Color From/03", NULL,
gradient_editor_load_left_cmd_callback, 6 },
NULL,
NULL, NULL },
{ { "/Load Left Color From/04", NULL,
gradient_editor_load_left_cmd_callback, 7 },
NULL,
NULL, NULL },
{ { "/Load Left Color From/05", NULL,
gradient_editor_load_left_cmd_callback, 8 },
NULL,
NULL, NULL },
{ { "/Load Left Color From/06", NULL,
gradient_editor_load_left_cmd_callback, 9 },
NULL,
NULL, NULL },
{ { "/Load Left Color From/07", NULL,
gradient_editor_load_left_cmd_callback, 10 },
NULL,
NULL, NULL },
{ { "/Load Left Color From/08", NULL,
gradient_editor_load_left_cmd_callback, 11 },
NULL,
NULL, NULL },
{ { "/Load Left Color From/09", NULL,
gradient_editor_load_left_cmd_callback, 12 },
NULL,
NULL, NULL },
{ { "/Load Left Color From/10", NULL,
gradient_editor_load_left_cmd_callback, 13 },
NULL,
NULL, NULL },
BRANCH (N_("/Save Left Color To")),
{ { "/Save Left Color To/01", NULL,
gradient_editor_save_left_cmd_callback, 0 },
NULL,
NULL, NULL },
{ { "/Save Left Color To/02", NULL,
gradient_editor_save_left_cmd_callback, 1 },
NULL,
NULL, NULL },
{ { "/Save Left Color To/03", NULL,
gradient_editor_save_left_cmd_callback, 2 },
NULL,
NULL, NULL },
{ { "/Save Left Color To/04", NULL,
gradient_editor_save_left_cmd_callback, 3 },
NULL,
NULL, NULL },
{ { "/Save Left Color To/05", NULL,
gradient_editor_save_left_cmd_callback, 4 },
NULL,
NULL, NULL },
{ { "/Save Left Color To/06", NULL,
gradient_editor_save_left_cmd_callback, 5 },
NULL,
NULL, NULL },
{ { "/Save Left Color To/07", NULL,
gradient_editor_save_left_cmd_callback, 6 },
NULL,
NULL, NULL },
{ { "/Save Left Color To/08", NULL,
gradient_editor_save_left_cmd_callback, 7 },
NULL,
NULL, NULL },
{ { "/Save Left Color To/09", NULL,
gradient_editor_save_left_cmd_callback, 8 },
NULL,
NULL, NULL },
{ { "/Save Left Color To/10", NULL,
gradient_editor_save_left_cmd_callback, 9 },
NULL,
NULL, NULL },
SEPARATOR ("/---"),
{ { N_("/Right Endpoint's Color..."), NULL,
gradient_editor_right_color_cmd_callback, 0 },
NULL,
NULL, NULL },
{ { N_("/Load Right Color From/Right Neighbor's Left Endpoint"), NULL,
gradient_editor_load_right_cmd_callback, 0 },
NULL,
NULL, NULL },
{ { N_("/Load Right Color From/Left Endpoint"), NULL,
gradient_editor_load_right_cmd_callback, 1 },
NULL,
NULL, NULL },
{ { N_("/Load Right Color From/FG Color"), NULL,
gradient_editor_load_right_cmd_callback, 2 },
NULL,
NULL, NULL },
{ { N_("/Load Right Color From/BG Color"), NULL,
gradient_editor_load_right_cmd_callback, 3 },
NULL,
NULL, NULL },
SEPARATOR ("/Load Right Color From/---"),
{ { "/Load Right Color From/01", NULL,
gradient_editor_load_right_cmd_callback, 4 },
NULL,
NULL, NULL },
{ { "/Load Right Color From/02", NULL,
gradient_editor_load_right_cmd_callback, 5 },
NULL,
NULL, NULL },
{ { "/Load Right Color From/03", NULL,
gradient_editor_load_right_cmd_callback, 6 },
NULL,
NULL, NULL },
{ { "/Load Right Color From/04", NULL,
gradient_editor_load_right_cmd_callback, 7 },
NULL,
NULL, NULL },
{ { "/Load Right Color From/05", NULL,
gradient_editor_load_right_cmd_callback, 8 },
NULL,
NULL, NULL },
{ { "/Load Right Color From/06", NULL,
gradient_editor_load_right_cmd_callback, 9 },
NULL,
NULL, NULL },
{ { "/Load Right Color From/07", NULL,
gradient_editor_load_right_cmd_callback, 10 },
NULL,
NULL, NULL },
{ { "/Load Right Color From/08", NULL,
gradient_editor_load_right_cmd_callback, 11 },
NULL,
NULL, NULL },
{ { "/Load Right Color From/09", NULL,
gradient_editor_load_right_cmd_callback, 12 },
NULL,
NULL, NULL },
{ { "/Load Right Color From/10", NULL,
gradient_editor_load_right_cmd_callback, 13 },
NULL,
NULL, NULL },
BRANCH (N_("/Save Right Color To")),
{ { "/Save Right Color To/01", NULL,
gradient_editor_save_right_cmd_callback, 0 },
NULL,
NULL, NULL },
{ { "/Save Right Color To/02", NULL,
gradient_editor_save_right_cmd_callback, 1 },
NULL,
NULL, NULL },
{ { "/Save Right Color To/03", NULL,
gradient_editor_save_right_cmd_callback, 2 },
NULL,
NULL, NULL },
{ { "/Save Right Color To/04", NULL,
gradient_editor_save_right_cmd_callback, 3 },
NULL,
NULL, NULL },
{ { "/Save Right Color To/05", NULL,
gradient_editor_save_right_cmd_callback, 4 },
NULL,
NULL, NULL },
{ { "/Save Right Color To/06", NULL,
gradient_editor_save_right_cmd_callback, 5 },
NULL,
NULL, NULL },
{ { "/Save Right Color To/07", NULL,
gradient_editor_save_right_cmd_callback, 6 },
NULL,
NULL, NULL },
{ { "/Save Right Color To/08", NULL,
gradient_editor_save_right_cmd_callback, 7 },
NULL,
NULL, NULL },
{ { "/Save Right Color To/09", NULL,
gradient_editor_save_right_cmd_callback, 8 },
NULL,
NULL, NULL },
{ { "/Save Right Color To/10", NULL,
gradient_editor_save_right_cmd_callback, 9 },
NULL,
NULL, NULL },
SEPARATOR ("/---"),
{ { N_("/blendingfunction/Linear"), NULL,
gradient_editor_blending_func_cmd_callback,
GRAD_LINEAR, "<RadioItem>" },
NULL,
NULL, NULL },
{ { N_("/blendingfunction/Curved"), NULL,
gradient_editor_blending_func_cmd_callback,
GRAD_CURVED, "/blendingfunction/Linear" },
NULL,
NULL, NULL },
{ { N_("/blendingfunction/Sinusodial"), NULL,
gradient_editor_blending_func_cmd_callback,
GRAD_SINE, "/blendingfunction/Linear" },
NULL,
NULL, NULL },
{ { N_("/blendingfunction/Spherical (increasing)"), NULL,
gradient_editor_blending_func_cmd_callback,
GRAD_SPHERE_INCREASING, "/blendingfunction/Linear" },
NULL,
NULL, NULL },
{ { N_("/blendingfunction/Spherical (decreasing)"), NULL,
gradient_editor_blending_func_cmd_callback,
GRAD_SPHERE_DECREASING, "/blendingfunction/Linear" },
NULL,
NULL, NULL },
{ { N_("/blendingfunction/(Varies)"), NULL, NULL,
0, "/blendingfunction/Linear" },
NULL,
NULL, NULL },
{ { N_("/coloringtype/RGB"), NULL,
gradient_editor_coloring_type_cmd_callback,
GRAD_RGB, "<RadioItem>" },
NULL,
NULL, NULL },
{ { N_("/coloringtype/HSV (counter-clockwise hue)"), NULL,
gradient_editor_coloring_type_cmd_callback,
GRAD_HSV_CCW, "/coloringtype/RGB" },
NULL,
NULL, NULL },
{ { N_("/coloringtype/HSV (clockwise hue)"), NULL,
gradient_editor_coloring_type_cmd_callback,
GRAD_HSV_CW, "/coloringtype/RGB" },
NULL,
NULL, NULL },
{ { N_("/coloringtype/(Varies)"), NULL, NULL,
0, "/coloringtype/RGB" },
NULL,
NULL, NULL },
SEPARATOR ("/---"),
{ { "/flip", "F",
gradient_editor_flip_cmd_callback, 0 },
NULL,
NULL, NULL },
{ { "/replicate", "R",
gradient_editor_replicate_cmd_callback, 0 },
NULL,
NULL, NULL },
{ { "/splitmidpoint", "S",
gradient_editor_split_midpoint_cmd_callback, 0 },
NULL,
NULL, NULL },
{ { "/splituniformly", "U",
gradient_editor_split_uniformly_cmd_callback, 0 },
NULL,
NULL, NULL },
{ { "/delete", "D",
gradient_editor_delete_cmd_callback, 0 },
NULL,
NULL, NULL },
{ { "/recenter", "C",
gradient_editor_recenter_cmd_callback, 0 },
NULL,
NULL, NULL },
{ { "/redistribute", "<control>C",
gradient_editor_redistribute_cmd_callback, 0 },
NULL,
NULL, NULL },
SEPARATOR ("/---"),
{ { N_("/Blend Endpoints' Colors"), "B",
gradient_editor_blend_color_cmd_callback, 0 },
NULL,
NULL, NULL },
{ { N_("/Blend Endpoints' Opacity"), "<control>B",
gradient_editor_blend_opacity_cmd_callback, 0 },
NULL,
NULL, NULL },
};
/***** <Gradients> *****/
static GimpItemFactoryEntry gradients_entries[] =
@ -1601,20 +1920,21 @@ static GimpItemFactoryEntry documents_entries[] =
static gboolean menus_initialized = FALSE;
static GtkItemFactory *toolbox_factory = NULL;
static GtkItemFactory *image_factory = NULL;
static GtkItemFactory *load_factory = NULL;
static GtkItemFactory *save_factory = NULL;
static GtkItemFactory *layers_factory = NULL;
static GtkItemFactory *channels_factory = NULL;
static GtkItemFactory *paths_factory = NULL;
static GtkItemFactory *dialogs_factory = NULL;
static GtkItemFactory *brushes_factory = NULL;
static GtkItemFactory *patterns_factory = NULL;
static GtkItemFactory *gradients_factory = NULL;
static GtkItemFactory *palettes_factory = NULL;
static GtkItemFactory *buffers_factory = NULL;
static GtkItemFactory *documents_factory = NULL;
static GtkItemFactory *toolbox_factory = NULL;
static GtkItemFactory *image_factory = NULL;
static GtkItemFactory *load_factory = NULL;
static GtkItemFactory *save_factory = NULL;
static GtkItemFactory *layers_factory = NULL;
static GtkItemFactory *channels_factory = NULL;
static GtkItemFactory *paths_factory = NULL;
static GtkItemFactory *dialogs_factory = NULL;
static GtkItemFactory *brushes_factory = NULL;
static GtkItemFactory *patterns_factory = NULL;
static GtkItemFactory *gradient_editor_factory = NULL;
static GtkItemFactory *gradients_factory = NULL;
static GtkItemFactory *palettes_factory = NULL;
static GtkItemFactory *buffers_factory = NULL;
static GtkItemFactory *documents_factory = NULL;
/* public functions */
@ -1760,6 +2080,13 @@ menus_init (Gimp *gimp)
gimp,
FALSE);
gradient_editor_factory = menus_item_factory_new (GTK_TYPE_MENU,
"<GradientEditor>", "gradient_editor",
G_N_ELEMENTS (gradient_editor_entries),
gradient_editor_entries,
gimp,
FALSE);
gradients_factory = menus_item_factory_new (GTK_TYPE_MENU,
"<Gradients>", "gradients",
G_N_ELEMENTS (gradients_entries),
@ -1931,6 +2258,12 @@ menus_exit (Gimp *gimp)
patterns_factory = NULL;
}
if (gradient_editor_factory)
{
g_object_unref (G_OBJECT (gradient_editor_factory));
gradient_editor_factory = NULL;
}
if (gradients_factory)
{
g_object_unref (G_OBJECT (gradients_factory));
@ -2205,6 +2538,12 @@ menus_get_patterns_factory (void)
return patterns_factory;
}
GtkItemFactory *
menus_get_gradient_editor_factory (void)
{
return gradient_editor_factory;
}
GtkItemFactory *
menus_get_gradients_factory (void)
{
@ -2264,6 +2603,222 @@ menus_create_item_from_full_path (GimpItemFactoryEntry *entry,
menus_create_item (item_factory, entry, callback_data, 2, TRUE, FALSE);
}
void
menus_set_active (gchar *path,
gboolean active)
{
GtkItemFactory *ifactory;
GtkWidget *widget = NULL;
g_return_if_fail (path != NULL);
g_return_if_fail (menus_initialized);
ifactory = gtk_item_factory_from_path (path);
if (ifactory)
{
widget = gtk_item_factory_get_widget (ifactory, path);
if (widget && GTK_IS_CHECK_MENU_ITEM (widget))
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (widget), active);
else
widget = NULL;
}
if ((!ifactory || !widget) && ! strstr (path, "Script-Fu"))
g_warning ("Unable to set \"active\" for menu which doesn't exist:\n%s",
path);
}
void
menus_set_color (gchar *path,
const GimpRGB *color,
gboolean set_label)
{
GtkItemFactory *ifactory;
GtkWidget *widget;
GtkWidget *preview = NULL;
GtkWidget *label = NULL;
g_return_if_fail (path != NULL);
g_return_if_fail (color != NULL);
g_return_if_fail (menus_initialized);
ifactory = gtk_item_factory_from_path (path);
#define COLOR_BOX_WIDTH 24
#define COLOR_BOX_HEIGHT 16
if (! ifactory)
return;
widget = gtk_item_factory_get_widget (ifactory, path);
if (! widget)
return;
if (GTK_IS_HBOX (GTK_BIN (widget)->child))
{
preview = g_object_get_data (G_OBJECT (GTK_BIN (widget)->child),
"preview");
label = g_object_get_data (G_OBJECT (GTK_BIN (widget)->child),
"label");
}
else if (GTK_IS_LABEL (GTK_BIN (widget)->child))
{
GtkWidget *hbox;
label = GTK_BIN (widget)->child;
g_object_ref (G_OBJECT (label));
gtk_container_remove (GTK_CONTAINER (widget), label);
hbox = gtk_hbox_new (FALSE, 4);
gtk_container_add (GTK_CONTAINER (widget), hbox);
gtk_widget_show (hbox);
preview = gtk_preview_new (GTK_PREVIEW_COLOR);
gtk_preview_size (GTK_PREVIEW (preview),
COLOR_BOX_WIDTH, COLOR_BOX_HEIGHT);
gtk_box_pack_start (GTK_BOX (hbox), preview, FALSE, FALSE, 0);
gtk_widget_show (preview);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
g_object_unref (G_OBJECT (label));
g_object_set_data (G_OBJECT (hbox), "preview", preview);
g_object_set_data (G_OBJECT (hbox), "label", label);
}
if (preview)
{
guchar rows[3][COLOR_BOX_WIDTH * 3];
gint x, y;
gint r0, g0, b0;
gint r1, g1, b1;
guchar *p0, *p1, *p2;
/* Fill rows */
r0 = (GIMP_CHECK_DARK + (color->r - GIMP_CHECK_DARK) * color->a) * 255.0;
r1 = (GIMP_CHECK_LIGHT + (color->r - GIMP_CHECK_LIGHT) * color->a) * 255.0;
g0 = (GIMP_CHECK_DARK + (color->g - GIMP_CHECK_DARK) * color->a) * 255.0;
g1 = (GIMP_CHECK_LIGHT + (color->g - GIMP_CHECK_LIGHT) * color->a) * 255.0;
b0 = (GIMP_CHECK_DARK + (color->b - GIMP_CHECK_DARK) * color->a) * 255.0;
b1 = (GIMP_CHECK_LIGHT + (color->b - GIMP_CHECK_LIGHT) * color->a) * 255.0;
p0 = rows[0];
p1 = rows[1];
p2 = rows[2];
for (x = 0; x < COLOR_BOX_WIDTH; x++)
{
if ((x == 0) || (x == (COLOR_BOX_WIDTH - 1)))
{
*p0++ = 0;
*p0++ = 0;
*p0++ = 0;
*p1++ = 0;
*p1++ = 0;
*p1++ = 0;
}
else if ((x / GIMP_CHECK_SIZE) & 1)
{
*p0++ = r1;
*p0++ = g1;
*p0++ = b1;
*p1++ = r0;
*p1++ = g0;
*p1++ = b0;
}
else
{
*p0++ = r0;
*p0++ = g0;
*p0++ = b0;
*p1++ = r1;
*p1++ = g1;
*p1++ = b1;
}
*p2++ = 0;
*p2++ = 0;
*p2++ = 0;
}
/* Fill preview */
gtk_preview_draw_row (GTK_PREVIEW (preview), rows[2],
0, 0, COLOR_BOX_WIDTH);
for (y = 1; y < (COLOR_BOX_HEIGHT - 1); y++)
if ((y / GIMP_CHECK_SIZE) & 1)
gtk_preview_draw_row (GTK_PREVIEW (preview), rows[1],
0, y, COLOR_BOX_WIDTH);
else
gtk_preview_draw_row (GTK_PREVIEW (preview), rows[0],
0, y, COLOR_BOX_WIDTH);
gtk_preview_draw_row (GTK_PREVIEW (preview), rows[2],
0, y, COLOR_BOX_WIDTH);
}
if (label && set_label)
{
gchar *str;
str = g_strdup_printf (_("RGBA (%0.3f, %0.3f, %0.3f, %0.3f)"),
color->r, color->g, color->b, color->a);
gtk_label_set_text (GTK_LABEL (label), str);
g_free (str);
}
#undef COLOR_BOX_WIDTH
#undef COLOR_BOX_HEIGHT
}
void
menus_set_label (gchar *path,
const gchar *label)
{
GtkItemFactory *ifactory;
GtkWidget *widget = NULL;
g_return_if_fail (path != NULL);
g_return_if_fail (label != NULL);
g_return_if_fail (menus_initialized);
ifactory = gtk_item_factory_from_path (path);
if (ifactory)
{
widget = gtk_item_factory_get_widget (ifactory, path);
if (widget)
{
if (GTK_IS_MENU (widget))
{
widget = gtk_menu_get_attach_widget (GTK_MENU (widget));
}
if (GTK_IS_LABEL (GTK_BIN (widget)->child))
{
gtk_label_set_text (GTK_LABEL (GTK_BIN (widget)->child), label);
}
}
}
}
void
menus_set_sensitive (gchar *path,
gboolean sensitive)
@ -2290,11 +2845,11 @@ menus_set_sensitive (gchar *path,
}
void
menus_set_state (gchar *path,
gboolean state)
menus_set_visible (gchar *path,
gboolean visible)
{
GtkItemFactory *ifactory;
GtkWidget *widget = NULL;
GtkWidget *widget;
g_return_if_fail (path != NULL);
g_return_if_fail (menus_initialized);
@ -2305,15 +2860,14 @@ menus_set_state (gchar *path,
{
widget = gtk_item_factory_get_widget (ifactory, path);
if (widget && GTK_IS_CHECK_MENU_ITEM (widget))
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (widget), state);
else
widget = NULL;
if (widget)
{
if (visible)
gtk_widget_show (widget);
else
gtk_widget_hide (widget);
}
}
if ((!ifactory || !widget) && ! strstr (path, "Script-Fu"))
g_warning ("Unable to set state for menu which doesn't exist:\n%s",
path);
}
void

View File

@ -33,34 +33,43 @@ struct _GimpItemFactoryEntry
};
void menus_init (Gimp *gimp);
void menus_exit (Gimp *gimp);
void menus_restore (Gimp *gimp);
void menus_init (Gimp *gimp);
void menus_exit (Gimp *gimp);
void menus_restore (Gimp *gimp);
GtkItemFactory * menus_get_toolbox_factory (void);
GtkItemFactory * menus_get_image_factory (void);
GtkItemFactory * menus_get_load_factory (void);
GtkItemFactory * menus_get_save_factory (void);
GtkItemFactory * menus_get_layers_factory (void);
GtkItemFactory * menus_get_channels_factory (void);
GtkItemFactory * menus_get_paths_factory (void);
GtkItemFactory * menus_get_dialogs_factory (void);
GtkItemFactory * menus_get_brushes_factory (void);
GtkItemFactory * menus_get_patterns_factory (void);
GtkItemFactory * menus_get_gradients_factory (void);
GtkItemFactory * menus_get_palettes_factory (void);
GtkItemFactory * menus_get_buffers_factory (void);
GtkItemFactory * menus_get_documents_factory (void);
GtkItemFactory * menus_get_toolbox_factory (void);
GtkItemFactory * menus_get_image_factory (void);
GtkItemFactory * menus_get_load_factory (void);
GtkItemFactory * menus_get_save_factory (void);
GtkItemFactory * menus_get_layers_factory (void);
GtkItemFactory * menus_get_channels_factory (void);
GtkItemFactory * menus_get_paths_factory (void);
GtkItemFactory * menus_get_dialogs_factory (void);
GtkItemFactory * menus_get_brushes_factory (void);
GtkItemFactory * menus_get_patterns_factory (void);
GtkItemFactory * menus_get_gradient_editor_factory (void);
GtkItemFactory * menus_get_gradients_factory (void);
GtkItemFactory * menus_get_palettes_factory (void);
GtkItemFactory * menus_get_buffers_factory (void);
GtkItemFactory * menus_get_documents_factory (void);
void menus_create_item_from_full_path (GimpItemFactoryEntry *entry,
gchar *domain_name,
gpointer callback_data);
void menus_set_active (gchar *path,
gboolean state);
void menus_set_color (gchar *path,
const GimpRGB *color,
gboolean set_label);
void menus_set_label (gchar *path,
const gchar *label);
void menus_set_sensitive (gchar *path,
gboolean sensitive);
void menus_set_state (gchar *path,
gboolean state);
void menus_set_visible (gchar *path,
gboolean visible);
void menus_destroy (gchar *path);