app/core/Makefile.am new files: the QMask stuff stripped from GUI code.

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

	* app/core/Makefile.am
	* app/core/gimpimage-qmask.[ch]: new files: the QMask stuff
	stripped from GUI code. Added gimp_image_qmask_invert().

	* app/core/gimpimage.[ch]: removed the QMask functions.

	* app/display/Makefile.am
	* app/display/gimpdisplayshell-qmask.[ch]: removed.

	* app/gui/Makefile.am
	* app/gui/qmask-commands.[ch]: new files for the new QMask item
	factory callbacks and the qmask query dialog.

	* app/gui/menus.c: added a context menu for the QMask button.

	* app/display/gimpdisplayshell.c
	* app/display/gimpdisplayshell-handlers.c: don't include the qmask
	stuff.

	* app/display/gimpdisplayshell-callbacks.[ch]: Moved the 2 qmask
	callbacks here. Don't popup the dialog on double_click. Show
	the contect menu on right-click.

	* app/display/gimpdisplayshell-callbacks.[ch]:
	gimp_display_shell_canvas_events(): removed the hack of
	conntecting "key_press_event" to gtk_true() while a tool is
	active. Instead, check for (event & GDK_BUTTON1_MASK) in the
	key_press and key_release handlers and stop signal emission. Save
	the modifier state on "button_press" and restore it after
	"button_release".

	Changed the way context menus are updated/shown:

	- removed GimpContainerContextFunc.
	- pass around item factory identifiers (e.g. "<Brushes>")
	- added voodoo to update the menus before showing them.

	* app/widgets/gimpitemfactory.[ch]: gimp_item_factory_new(): take
	a GimpItemFactoryUpdateFunc parameter, attach it as data to the
	factory and use it to update the menu in
	gimp_item_factory_popup_with_date().

	* app/widgets/gimpwidgets-utils.[ch]: removed
	gimp_item_factory_popup_with_data() here.

	* app/widgets/gimpbrushfactoryview.[ch]
	* app/widgets/gimpbufferview.[ch]
	* app/widgets/gimpcontainereditor.[ch]
	* app/widgets/gimpdatafactoryview.[ch]
	* app/widgets/gimpdocumentview.[ch]
	* app/widgets/gimpdrawablelistview.[ch]: use item_factory
	identifier strings all over the place.

	* app/widgets/gimpdockbook.c: removed the menu update code, it's
	now in gui/dialogs-commands.c.

	* app/gui/brushes-commands.[ch]
	* app/gui/buffers-commands.[c]
	* app/gui/channels-commands.[ch]
	* app/gui/dialogs-commands.[ch]
	* app/gui/documents-commands.[ch]
	* app/gui/gradient-editor-commands.[ch]
	* app/gui/gradients-commands.[ch]
	* app/gui/layers-commands.[ch]
	* app/gui/palettes-commands.[ch]
	* app/gui/patterns-commands.[ch]: removed all show_context_menu()
	functions and made the update functions public. Changed all
	update functions to use the gimp_item_factory_set_foo() methods
	instead of gimp_menu_item_set_foo().

	* app/gui/menus.c: pass the update functions to the
	gimp_item_factory_new().

	* app/gui/dialogs-constructors.c: pass item factory identifiers to
	all view constructors.

	* app/gui/gradient-editor.c: show the context menu using the new
	method.

	* app/gui/toolbox.c: no need to include "dialogs-commands.h".
This commit is contained in:
Michael Natterer 2001-11-30 14:41:56 +00:00 committed by Michael Natterer
parent 84f148fef0
commit bba8413773
91 changed files with 2099 additions and 2528 deletions

View File

@ -1,3 +1,86 @@
2001-11-30 Michael Natterer <mitch@gimp.org>
* app/core/Makefile.am
* app/core/gimpimage-qmask.[ch]: new files: the QMask stuff
stripped from GUI code. Added gimp_image_qmask_invert().
* app/core/gimpimage.[ch]: removed the QMask functions.
* app/display/Makefile.am
* app/display/gimpdisplayshell-qmask.[ch]: removed.
* app/gui/Makefile.am
* app/gui/qmask-commands.[ch]: new files for the new QMask item
factory callbacks and the qmask query dialog.
* app/gui/menus.c: added a context menu for the QMask button.
* app/display/gimpdisplayshell.c
* app/display/gimpdisplayshell-handlers.c: don't include the qmask
stuff.
* app/display/gimpdisplayshell-callbacks.[ch]: Moved the 2 qmask
callbacks here. Don't popup the dialog on double_click. Show
the contect menu on right-click.
* app/display/gimpdisplayshell-callbacks.[ch]:
gimp_display_shell_canvas_events(): removed the hack of
conntecting "key_press_event" to gtk_true() while a tool is
active. Instead, check for (event & GDK_BUTTON1_MASK) in the
key_press and key_release handlers and stop signal emission. Save
the modifier state on "button_press" and restore it after
"button_release".
Changed the way context menus are updated/shown:
- removed GimpContainerContextFunc.
- pass around item factory identifiers (e.g. "<Brushes>")
- added voodoo to update the menus before showing them.
* app/widgets/gimpitemfactory.[ch]: gimp_item_factory_new(): take
a GimpItemFactoryUpdateFunc parameter, attach it as data to the
factory and use it to update the menu in
gimp_item_factory_popup_with_date().
* app/widgets/gimpwidgets-utils.[ch]: removed
gimp_item_factory_popup_with_data() here.
* app/widgets/gimpbrushfactoryview.[ch]
* app/widgets/gimpbufferview.[ch]
* app/widgets/gimpcontainereditor.[ch]
* app/widgets/gimpdatafactoryview.[ch]
* app/widgets/gimpdocumentview.[ch]
* app/widgets/gimpdrawablelistview.[ch]: use item_factory
identifier strings all over the place.
* app/widgets/gimpdockbook.c: removed the menu update code, it's
now in gui/dialogs-commands.c.
* app/gui/brushes-commands.[ch]
* app/gui/buffers-commands.[c]
* app/gui/channels-commands.[ch]
* app/gui/dialogs-commands.[ch]
* app/gui/documents-commands.[ch]
* app/gui/gradient-editor-commands.[ch]
* app/gui/gradients-commands.[ch]
* app/gui/layers-commands.[ch]
* app/gui/palettes-commands.[ch]
* app/gui/patterns-commands.[ch]: removed all show_context_menu()
functions and made the update functions public. Changed all
update functions to use the gimp_item_factory_set_foo() methods
instead of gimp_menu_item_set_foo().
* app/gui/menus.c: pass the update functions to the
gimp_item_factory_new().
* app/gui/dialogs-constructors.c: pass item factory identifiers to
all view constructors.
* app/gui/gradient-editor.c: show the context menu using the new
method.
* app/gui/toolbox.c: no need to include "dialogs-commands.h".
2001-11-29 Sven Neumann <sven@gimp.org>
* app/config/gimpconfig.c (gimp_config_serialize): ooops.
@ -28,7 +111,7 @@
2001-11-29 Michael Natterer <mitch@gimp.org>
* app/display/gimpdisplayshell.[ch]: replaced the QMask radio
buttons ba a single check button. Still needs some tuning.
buttons by a single check button. Still needs some tuning.
* app/display/gimpdisplayshell-handlers.c
* app/display/gimpdisplayshell-qmask.[ch]: changed accordingly.
@ -43,7 +126,7 @@
display manually (we have the pointer grabbed anyway).
* app/display/gimpdisplayshell-callbacks.c: don't check for
GIMP_IS_MODE_TOOL(active_tool) but look at
GIMP_IS_MOVE_TOOL(active_tool) but look at
active_tool->handle_empty_image. Removed the checks for
GIMP_IS_FUZZY_SELECT_TOOL(active_tool) because fuzzy_select
doesn't set GIMP busy while it's active any more.

View File

@ -40,11 +40,6 @@
#include "libgimp/gimpintl.h"
/* local function prototypes */
static void buffers_menu_set_sensitivity (GimpContainerEditor *editor);
/* public functionss */
void
@ -104,34 +99,23 @@ buffers_delete_buffer_cmd_callback (GtkWidget *widget,
}
void
buffers_show_context_menu (GimpContainerEditor *editor)
buffers_menu_update (GtkItemFactory *factory,
gpointer data)
{
GtkItemFactory *item_factory;
GimpContainerEditor *editor;
GimpBuffer *buffer;
buffers_menu_set_sensitivity (editor);
item_factory = gtk_item_factory_from_path ("<Buffers>");
gimp_item_factory_popup_with_data (item_factory, editor);
}
/* private functions */
static void
buffers_menu_set_sensitivity (GimpContainerEditor *editor)
{
GimpBuffer *buffer;
editor = GIMP_CONTAINER_EDITOR (data);
buffer = gimp_context_get_buffer (editor->view->context);
#define SET_SENSITIVE(menu,condition) \
gimp_menu_item_set_sensitive ("<Buffers>/" menu, (condition) != 0)
gimp_item_factory_set_sensitive (factory, menu, (condition) != 0)
SET_SENSITIVE ("Paste Buffer", buffer);
SET_SENSITIVE ("Paste Buffer Into", buffer);
SET_SENSITIVE ("Paste Buffer as New", buffer);
SET_SENSITIVE ("Delete Buffer", buffer);
SET_SENSITIVE ("/Paste Buffer", buffer);
SET_SENSITIVE ("/Paste Buffer Into", buffer);
SET_SENSITIVE ("/Paste Buffer as New", buffer);
SET_SENSITIVE ("/Delete Buffer", buffer);
#undef SET_SENSITIVE
}

View File

@ -29,8 +29,8 @@ void buffers_paste_buffer_as_new_cmd_callback (GtkWidget *widget,
void buffers_delete_buffer_cmd_callback (GtkWidget *widget,
gpointer data);
void buffers_show_context_menu (GimpContainerEditor *editor);
void buffers_menu_update (GtkItemFactory *factory,
gpointer data);
#endif /* __BUFFERS_COMMANDS_H__ */

View File

@ -42,11 +42,6 @@
#include "libgimp/gimpintl.h"
/* local function prototypes */
static void channels_menu_set_sensitivity (GimpImage *gimage);
/* public functions */
void
@ -592,29 +587,17 @@ channels_edit_channel_query (GimpChannel *channel)
}
void
channels_show_context_menu (GimpImage *gimage)
{
GtkItemFactory *item_factory;
channels_menu_set_sensitivity (gimage);
item_factory = gtk_item_factory_from_path ("<Channels>");
gimp_item_factory_popup_with_data (item_factory, gimage);
}
static void
channels_menu_set_sensitivity (GimpImage *gimage)
channels_menu_update (GtkItemFactory *factory,
gpointer data)
{
GimpImage *gimage;
GimpChannel *channel;
gboolean fs;
GList *list;
GList *next = NULL;
GList *prev = NULL;
g_return_if_fail (gimage != NULL);
g_return_if_fail (GIMP_IS_IMAGE (gimage));
gimage = GIMP_IMAGE (data);
channel = gimp_image_get_active_channel (gimage);
@ -633,18 +616,18 @@ channels_menu_set_sensitivity (GimpImage *gimage)
}
#define SET_SENSITIVE(menu,condition) \
gimp_menu_item_set_sensitive ("<Channels>/" menu, (condition) != 0)
gimp_item_factory_set_sensitive (factory, menu, (condition) != 0)
SET_SENSITIVE ("New Channel...", !fs);
SET_SENSITIVE ("Raise Channel", !fs && channel && prev);
SET_SENSITIVE ("Lower Channel", !fs && channel && next);
SET_SENSITIVE ("Duplicate Channel", !fs && channel);
SET_SENSITIVE ("Channel to Selection", !fs && channel);
SET_SENSITIVE ("Add to Selection", !fs && channel);
SET_SENSITIVE ("Subtract from Selection", !fs && channel);
SET_SENSITIVE ("Intersect with Selection", !fs && channel);
SET_SENSITIVE ("Delete Channel", !fs && channel);
SET_SENSITIVE ("Edit Channel Attributes...", !fs && channel);
SET_SENSITIVE ("/New Channel...", !fs);
SET_SENSITIVE ("/Raise Channel", !fs && channel && prev);
SET_SENSITIVE ("/Lower Channel", !fs && channel && next);
SET_SENSITIVE ("/Duplicate Channel", !fs && channel);
SET_SENSITIVE ("/Channel to Selection", !fs && channel);
SET_SENSITIVE ("/Add to Selection", !fs && channel);
SET_SENSITIVE ("/Subtract from Selection", !fs && channel);
SET_SENSITIVE ("/Intersect with Selection", !fs && channel);
SET_SENSITIVE ("/Delete Channel", !fs && channel);
SET_SENSITIVE ("/Edit Channel Attributes...", !fs && channel);
#undef SET_OPS_SENSITIVE
}

View File

@ -43,7 +43,9 @@ void channels_edit_channel_attributes_cmd_callback (GtkWidget *widget,
void channels_new_channel_query (GimpImage *gimage);
void channels_edit_channel_query (GimpChannel *channel);
void channels_show_context_menu (GimpImage *gimage);
void channels_menu_update (GtkItemFactory *factory,
gpointer data);
#endif /* __CHANNELS_COMMANDS_H__ */

View File

@ -30,6 +30,7 @@
#include "widgets/gimpdockable.h"
#include "widgets/gimpdockbook.h"
#include "widgets/gimpimagedock.h"
#include "widgets/gimpitemfactory.h"
#include "dialogs.h"
#include "dialogs-commands.h"
@ -286,8 +287,8 @@ dialogs_toggle_auto_cmd_callback (GtkWidget *widget,
void
dialogs_create_lc_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
gpointer data,
guint action)
{
GtkWidget *dock;
GtkWidget *dockbook;
@ -358,3 +359,99 @@ dialogs_create_stuff_cmd_callback (GtkWidget *widget,
gtk_widget_show (dock);
}
void
dialogs_menu_update (GtkItemFactory *factory,
gpointer data)
{
GimpDockbook *dockbook;
dockbook = GIMP_DOCKBOOK (data);
if (dockbook)
{
GimpDockable *dockable;
gint page_num;
GimpDialogFactoryEntry *entry;
GimpContainerView *view;
gboolean is_grid = FALSE;
GimpPreviewSize preview_size = GIMP_PREVIEW_SIZE_NONE;
page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (dockbook));
dockable = (GimpDockable *)
gtk_notebook_get_nth_page (GTK_NOTEBOOK (dockbook), page_num);
entry = g_object_get_data (G_OBJECT (dockable),
"gimp-dialog-factory-entry");
if (entry)
{
if (strstr (entry->identifier, "grid"))
is_grid = TRUE;
}
view = gimp_container_view_get_by_dockable (dockable);
if (view)
{
preview_size = view->preview_size;
}
#define SET_ACTIVE(path,active) \
gimp_item_factory_set_active (factory, (path), (active))
if (preview_size >= GIMP_PREVIEW_SIZE_GIGANTIC)
{
SET_ACTIVE ("/Preview Size/Gigantic", TRUE);
}
else if (preview_size >= GIMP_PREVIEW_SIZE_ENORMOUS)
{
SET_ACTIVE ("/Preview Size/Enormous", TRUE);
}
else if (preview_size >= GIMP_PREVIEW_SIZE_HUGE)
{
SET_ACTIVE ("/Preview Size/Huge", TRUE);
}
else if (preview_size >= GIMP_PREVIEW_SIZE_EXTRA_LARGE)
{
SET_ACTIVE ("/Preview Size/Extra Large", TRUE);
}
else if (preview_size >= GIMP_PREVIEW_SIZE_LARGE)
{
SET_ACTIVE ("/Preview Size/Large", TRUE);
}
else if (preview_size >= GIMP_PREVIEW_SIZE_MEDIUM)
{
SET_ACTIVE ("/Preview Size/Medium", TRUE);
}
else if (preview_size >= GIMP_PREVIEW_SIZE_SMALL)
{
SET_ACTIVE ("/Preview Size/Small", TRUE);
}
else if (preview_size >= GIMP_PREVIEW_SIZE_EXTRA_SMALL)
{
SET_ACTIVE ("/Preview Size/Extra Small", TRUE);
}
else
{
SET_ACTIVE ("/Preview Size/Tiny", TRUE);
}
if (is_grid)
{
SET_ACTIVE ("/View as Grid", TRUE);
}
else
{
SET_ACTIVE ("/View as List", TRUE);
}
SET_ACTIVE ("/Show Image Menu",
GIMP_IMAGE_DOCK (dockbook->dock)->show_image_menu);
SET_ACTIVE ("/Auto Follow Active Image",
GIMP_IMAGE_DOCK (dockbook->dock)->auto_follow_active);
#undef SET_ACTIVE
}
}

View File

@ -55,5 +55,8 @@ void dialogs_create_stuff_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void dialogs_menu_update (GtkItemFactory *factory,
gpointer data);
#endif /* __DIALOGS_COMMANDS_H__ */

View File

@ -38,11 +38,6 @@
#include "libgimp/gimpintl.h"
/* local function prototypes */
static void documents_menu_set_sensitivity (GimpContainerEditor *editor);
/* public functionss */
void
@ -119,35 +114,24 @@ documents_refresh_documents_cmd_callback (GtkWidget *widget,
}
void
documents_show_context_menu (GimpContainerEditor *editor)
documents_menu_update (GtkItemFactory *factory,
gpointer data)
{
GtkItemFactory *item_factory;
GimpContainerEditor *editor;
GimpImagefile *imagefile;
documents_menu_set_sensitivity (editor);
item_factory = gtk_item_factory_from_path ("<Documents>");
gimp_item_factory_popup_with_data (item_factory, editor);
}
/* private functions */
static void
documents_menu_set_sensitivity (GimpContainerEditor *editor)
{
GimpImagefile *imagefile;
editor = GIMP_CONTAINER_EDITOR (data);
imagefile = gimp_context_get_imagefile (editor->view->context);
#define SET_SENSITIVE(menu,condition) \
gimp_menu_item_set_sensitive ("<Documents>/" menu, (condition) != 0)
gimp_item_factory_set_sensitive (factory, menu, (condition) != 0)
SET_SENSITIVE ("Open Image", imagefile);
SET_SENSITIVE ("Raise or Open Image", imagefile);
SET_SENSITIVE ("File Open Dialog...", TRUE);
SET_SENSITIVE ("Remove Entry", imagefile);
SET_SENSITIVE ("Refresh History", TRUE);
SET_SENSITIVE ("/Open Image", imagefile);
SET_SENSITIVE ("/Raise or Open Image", imagefile);
SET_SENSITIVE ("/File Open Dialog...", TRUE);
SET_SENSITIVE ("/Remove Entry", imagefile);
SET_SENSITIVE ("/Refresh History", TRUE);
#undef SET_SENSITIVE
}

View File

@ -31,8 +31,8 @@ void documents_delete_document_cmd_callback (GtkWidget *widget,
void documents_refresh_documents_cmd_callback (GtkWidget *widget,
gpointer data);
void documents_show_context_menu (GimpContainerEditor *editor);
void documents_menu_update (GtkItemFactory *factory,
gpointer data);
#endif /* __DOCUMENTS_COMMANDS_H__ */

View File

@ -40,7 +40,6 @@
/* local function prototypes */
static void gradient_editor_menu_set_sensitivity (GradientEditor *editor);
static void gradient_editor_left_color_changed (ColorNotebook *cnb,
const GimpRGB *color,
ColorNotebookState state,
@ -915,23 +914,10 @@ gradient_editor_blend_opacity_cmd_callback (GtkWidget *widget,
}
void
gradient_editor_show_context_menu (GradientEditor *editor)
{
GtkItemFactory *item_factory;
gradient_editor_menu_set_sensitivity (editor);
item_factory = gtk_item_factory_from_path ("<GradientEditor>");
gimp_item_factory_popup_with_data (item_factory, editor);
}
/* private functions */
static void
gradient_editor_menu_set_sensitivity (GradientEditor *editor)
gradient_editor_menu_update (GtkItemFactory *factory,
gpointer data)
{
GradientEditor *editor;
GimpGradientSegment *left_seg;
GimpGradientSegment *right_seg;
GimpRGB fg;
@ -941,6 +927,8 @@ gradient_editor_menu_set_sensitivity (GradientEditor *editor)
gboolean selection;
gboolean delete;
editor = (GradientEditor *) data;
if (editor->control_sel_l->prev)
left_seg = editor->control_sel_l->prev;
else
@ -981,161 +969,161 @@ gradient_editor_menu_set_sensitivity (GradientEditor *editor)
delete = (editor->control_sel_l->prev || editor->control_sel_r->next);
#define SET_ACTIVE(menu,active) \
gimp_menu_item_set_active ("<GradientEditor>/" menu, (active))
gimp_item_factory_set_active (factory, menu, (active))
#define SET_COLOR(menu,color,set_label) \
gimp_menu_item_set_color ("<GradientEditor>/" menu, (color), (set_label))
gimp_item_factory_set_color (factory, menu, (color), (set_label))
#define SET_LABEL(menu,label) \
gimp_menu_item_set_label ("<GradientEditor>/" menu, (label))
gimp_item_factory_set_label (factory, menu, (label))
#define SET_SENSITIVE(menu,condition) \
gimp_menu_item_set_sensitive ("<GradientEditor>/" menu, (condition) != 0)
gimp_item_factory_set_sensitive (factory, menu, (condition) != 0)
#define SET_VISIBLE(menu,condition) \
gimp_menu_item_set_visible ("<GradientEditor>/" menu, (condition) != 0)
gimp_item_factory_set_visible (factory, menu, (condition) != 0)
SET_COLOR ("Left Endpoint's Color...",
SET_COLOR ("/Left Endpoint's Color...",
&editor->control_sel_l->left_color, FALSE);
SET_COLOR ("Load Left Color From/Left Neighbor's Right Endpoint",
SET_COLOR ("/Load Left Color From/Left Neighbor's Right Endpoint",
&left_seg->right_color, FALSE);
SET_COLOR ("Load Left Color From/Right Endpoint",
SET_COLOR ("/Load Left Color From/Right Endpoint",
&editor->control_sel_r->right_color, FALSE);
SET_COLOR ("Load Left Color From/FG Color", &fg, FALSE);
SET_COLOR ("Load Left Color From/BG Color", &bg, FALSE);
SET_COLOR ("/Load Left Color From/FG Color", &fg, FALSE);
SET_COLOR ("/Load Left Color From/BG Color", &bg, FALSE);
SET_COLOR ("Load Left Color From/01", &editor->saved_colors[0], TRUE);
SET_COLOR ("Load Left Color From/02", &editor->saved_colors[1], TRUE);
SET_COLOR ("Load Left Color From/03", &editor->saved_colors[2], TRUE);
SET_COLOR ("Load Left Color From/04", &editor->saved_colors[3], TRUE);
SET_COLOR ("Load Left Color From/05", &editor->saved_colors[4], TRUE);
SET_COLOR ("Load Left Color From/06", &editor->saved_colors[5], TRUE);
SET_COLOR ("Load Left Color From/07", &editor->saved_colors[6], TRUE);
SET_COLOR ("Load Left Color From/08", &editor->saved_colors[7], TRUE);
SET_COLOR ("Load Left Color From/09", &editor->saved_colors[8], TRUE);
SET_COLOR ("Load Left Color From/10", &editor->saved_colors[9], TRUE);
SET_COLOR ("/Load Left Color From/01", &editor->saved_colors[0], TRUE);
SET_COLOR ("/Load Left Color From/02", &editor->saved_colors[1], TRUE);
SET_COLOR ("/Load Left Color From/03", &editor->saved_colors[2], TRUE);
SET_COLOR ("/Load Left Color From/04", &editor->saved_colors[3], TRUE);
SET_COLOR ("/Load Left Color From/05", &editor->saved_colors[4], TRUE);
SET_COLOR ("/Load Left Color From/06", &editor->saved_colors[5], TRUE);
SET_COLOR ("/Load Left Color From/07", &editor->saved_colors[6], TRUE);
SET_COLOR ("/Load Left Color From/08", &editor->saved_colors[7], TRUE);
SET_COLOR ("/Load Left Color From/09", &editor->saved_colors[8], TRUE);
SET_COLOR ("/Load Left Color From/10", &editor->saved_colors[9], TRUE);
SET_COLOR ("Save Left Color To/01", &editor->saved_colors[0], TRUE);
SET_COLOR ("Save Left Color To/02", &editor->saved_colors[1], TRUE);
SET_COLOR ("Save Left Color To/03", &editor->saved_colors[2], TRUE);
SET_COLOR ("Save Left Color To/04", &editor->saved_colors[3], TRUE);
SET_COLOR ("Save Left Color To/05", &editor->saved_colors[4], TRUE);
SET_COLOR ("Save Left Color To/06", &editor->saved_colors[5], TRUE);
SET_COLOR ("Save Left Color To/07", &editor->saved_colors[6], TRUE);
SET_COLOR ("Save Left Color To/08", &editor->saved_colors[7], TRUE);
SET_COLOR ("Save Left Color To/09", &editor->saved_colors[8], TRUE);
SET_COLOR ("Save Left Color To/10", &editor->saved_colors[9], TRUE);
SET_COLOR ("/Save Left Color To/01", &editor->saved_colors[0], TRUE);
SET_COLOR ("/Save Left Color To/02", &editor->saved_colors[1], TRUE);
SET_COLOR ("/Save Left Color To/03", &editor->saved_colors[2], TRUE);
SET_COLOR ("/Save Left Color To/04", &editor->saved_colors[3], TRUE);
SET_COLOR ("/Save Left Color To/05", &editor->saved_colors[4], TRUE);
SET_COLOR ("/Save Left Color To/06", &editor->saved_colors[5], TRUE);
SET_COLOR ("/Save Left Color To/07", &editor->saved_colors[6], TRUE);
SET_COLOR ("/Save Left Color To/08", &editor->saved_colors[7], TRUE);
SET_COLOR ("/Save Left Color To/09", &editor->saved_colors[8], TRUE);
SET_COLOR ("/Save Left Color To/10", &editor->saved_colors[9], TRUE);
SET_COLOR ("Right Endpoint's Color...",
SET_COLOR ("/Right Endpoint's Color...",
&editor->control_sel_r->right_color, FALSE);
SET_COLOR ("Load Right Color From/Right Neighbor's Left Endpoint",
SET_COLOR ("/Load Right Color From/Right Neighbor's Left Endpoint",
&right_seg->left_color, FALSE);
SET_COLOR ("Load Right Color From/Left Endpoint",
SET_COLOR ("/Load Right Color From/Left Endpoint",
&editor->control_sel_l->left_color, FALSE);
SET_COLOR ("Load Right Color From/FG Color", &fg, FALSE);
SET_COLOR ("Load Right Color From/BG Color", &bg, FALSE);
SET_COLOR ("/Load Right Color From/FG Color", &fg, FALSE);
SET_COLOR ("/Load Right Color From/BG Color", &bg, FALSE);
SET_COLOR ("Load Right Color From/01", &editor->saved_colors[0], TRUE);
SET_COLOR ("Load Right Color From/02", &editor->saved_colors[1], TRUE);
SET_COLOR ("Load Right Color From/03", &editor->saved_colors[2], TRUE);
SET_COLOR ("Load Right Color From/04", &editor->saved_colors[3], TRUE);
SET_COLOR ("Load Right Color From/05", &editor->saved_colors[4], TRUE);
SET_COLOR ("Load Right Color From/06", &editor->saved_colors[5], TRUE);
SET_COLOR ("Load Right Color From/07", &editor->saved_colors[6], TRUE);
SET_COLOR ("Load Right Color From/08", &editor->saved_colors[7], TRUE);
SET_COLOR ("Load Right Color From/09", &editor->saved_colors[8], TRUE);
SET_COLOR ("Load Right Color From/10", &editor->saved_colors[9], TRUE);
SET_COLOR ("/Load Right Color From/01", &editor->saved_colors[0], TRUE);
SET_COLOR ("/Load Right Color From/02", &editor->saved_colors[1], TRUE);
SET_COLOR ("/Load Right Color From/03", &editor->saved_colors[2], TRUE);
SET_COLOR ("/Load Right Color From/04", &editor->saved_colors[3], TRUE);
SET_COLOR ("/Load Right Color From/05", &editor->saved_colors[4], TRUE);
SET_COLOR ("/Load Right Color From/06", &editor->saved_colors[5], TRUE);
SET_COLOR ("/Load Right Color From/07", &editor->saved_colors[6], TRUE);
SET_COLOR ("/Load Right Color From/08", &editor->saved_colors[7], TRUE);
SET_COLOR ("/Load Right Color From/09", &editor->saved_colors[8], TRUE);
SET_COLOR ("/Load Right Color From/10", &editor->saved_colors[9], TRUE);
SET_COLOR ("Save Right Color To/01", &editor->saved_colors[0], TRUE);
SET_COLOR ("Save Right Color To/02", &editor->saved_colors[1], TRUE);
SET_COLOR ("Save Right Color To/03", &editor->saved_colors[2], TRUE);
SET_COLOR ("Save Right Color To/04", &editor->saved_colors[3], TRUE);
SET_COLOR ("Save Right Color To/05", &editor->saved_colors[4], TRUE);
SET_COLOR ("Save Right Color To/06", &editor->saved_colors[5], TRUE);
SET_COLOR ("Save Right Color To/07", &editor->saved_colors[6], TRUE);
SET_COLOR ("Save Right Color To/08", &editor->saved_colors[7], TRUE);
SET_COLOR ("Save Right Color To/09", &editor->saved_colors[8], TRUE);
SET_COLOR ("Save Right Color To/10", &editor->saved_colors[9], TRUE);
SET_COLOR ("/Save Right Color To/01", &editor->saved_colors[0], TRUE);
SET_COLOR ("/Save Right Color To/02", &editor->saved_colors[1], TRUE);
SET_COLOR ("/Save Right Color To/03", &editor->saved_colors[2], TRUE);
SET_COLOR ("/Save Right Color To/04", &editor->saved_colors[3], TRUE);
SET_COLOR ("/Save Right Color To/05", &editor->saved_colors[4], TRUE);
SET_COLOR ("/Save Right Color To/06", &editor->saved_colors[5], TRUE);
SET_COLOR ("/Save Right Color To/07", &editor->saved_colors[6], TRUE);
SET_COLOR ("/Save Right Color To/08", &editor->saved_colors[7], TRUE);
SET_COLOR ("/Save Right Color To/09", &editor->saved_colors[8], TRUE);
SET_COLOR ("/Save Right Color To/10", &editor->saved_colors[9], TRUE);
if (! selection)
{
SET_LABEL ("flip", _("Flip Segment"));
SET_LABEL ("replicate", _("Replicate Segment"));
SET_LABEL ("blendingfunction", _("Blending Function for Segment"));
SET_LABEL ("coloringtype", _("Coloring Type for Segment"));
SET_LABEL ("splitmidpoint", _("Split Segment at Midpoint"));
SET_LABEL ("splituniformly", _("Split Segment Uniformly"));
SET_LABEL ("delete", _("Delete Segment"));
SET_LABEL ("recenter", _("Re-center Segment's Midpoint"));
SET_LABEL ("redistribute", _("Re-distribute Handles in Segment"));
SET_LABEL ("/flip", _("Flip Segment"));
SET_LABEL ("/replicate", _("Replicate Segment"));
SET_LABEL ("/blendingfunction", _("Blending Function for Segment"));
SET_LABEL ("/coloringtype", _("Coloring Type for Segment"));
SET_LABEL ("/splitmidpoint", _("Split Segment at Midpoint"));
SET_LABEL ("/splituniformly", _("Split Segment Uniformly"));
SET_LABEL ("/delete", _("Delete Segment"));
SET_LABEL ("/recenter", _("Re-center Segment's Midpoint"));
SET_LABEL ("/redistribute", _("Re-distribute Handles in Segment"));
}
else
{
SET_LABEL ("flip", _("Flip Selection"));
SET_LABEL ("replicate", _("Replicate Selection"));
SET_LABEL ("blendingfunction", _("Blending Function for Selection"));
SET_LABEL ("coloringtype", _("Coloring Type for Selection"));
SET_LABEL ("splitmidpoint", _("Split Segments at Midpoints"));
SET_LABEL ("splituniformly", _("Split Segments Uniformly"));
SET_LABEL ("delete", _("Delete Selection"));
SET_LABEL ("recenter", _("Re-center Midpoints in Selection"));
SET_LABEL ("redistribute", _("Re-distribute Handles in Selection"));
SET_LABEL ("/flip", _("Flip Selection"));
SET_LABEL ("/replicate", _("Replicate Selection"));
SET_LABEL ("/blendingfunction", _("Blending Function for Selection"));
SET_LABEL ("/coloringtype", _("Coloring Type for Selection"));
SET_LABEL ("/splitmidpoint", _("Split Segments at Midpoints"));
SET_LABEL ("/splituniformly", _("Split Segments Uniformly"));
SET_LABEL ("/delete", _("Delete Selection"));
SET_LABEL ("/recenter", _("Re-center Midpoints in Selection"));
SET_LABEL ("/redistribute", _("Re-distribute Handles in Selection"));
}
SET_SENSITIVE ("blendingfunction/(Varies)", FALSE);
SET_SENSITIVE ("coloringtype/(Varies)", FALSE);
SET_SENSITIVE ("/blendingfunction/(Varies)", FALSE);
SET_SENSITIVE ("/coloringtype/(Varies)", FALSE);
if (blending_equal)
{
SET_VISIBLE ("blendingfunction/(Varies)", FALSE);
SET_VISIBLE ("/blendingfunction/(Varies)", FALSE);
switch (editor->control_sel_l->type)
{
case GRAD_LINEAR:
SET_ACTIVE ("blendingfunction/Linear", TRUE);
SET_ACTIVE ("/blendingfunction/Linear", TRUE);
break;
case GRAD_CURVED:
SET_ACTIVE ("blendingfunction/Curved", TRUE);
SET_ACTIVE ("/blendingfunction/Curved", TRUE);
break;
case GRAD_SINE:
SET_ACTIVE ("blendingfunction/Sinusodial", TRUE);
SET_ACTIVE ("/blendingfunction/Sinusodial", TRUE);
break;
case GRAD_SPHERE_INCREASING:
SET_ACTIVE ("blendingfunction/Spherical (increasing)", TRUE);
SET_ACTIVE ("/blendingfunction/Spherical (increasing)", TRUE);
break;
case GRAD_SPHERE_DECREASING:
SET_ACTIVE ("blendingfunction/Spherical (decreasing)", TRUE);
SET_ACTIVE ("/blendingfunction/Spherical (decreasing)", TRUE);
break;
}
}
else
{
SET_VISIBLE ("blendingfunction/(Varies)", TRUE);
SET_ACTIVE ("blendingfunction/(Varies)", TRUE);
SET_VISIBLE ("/blendingfunction/(Varies)", TRUE);
SET_ACTIVE ("/blendingfunction/(Varies)", TRUE);
}
if (coloring_equal)
{
SET_VISIBLE ("coloringtype/(Varies)", FALSE);
SET_VISIBLE ("/coloringtype/(Varies)", FALSE);
switch (editor->control_sel_l->color)
{
case GRAD_RGB:
SET_ACTIVE ("coloringtype/RGB", TRUE);
SET_ACTIVE ("/coloringtype/RGB", TRUE);
break;
case GRAD_HSV_CCW:
SET_ACTIVE ("coloringtype/HSV (counter-clockwise hue)", TRUE);
SET_ACTIVE ("/coloringtype/HSV (counter-clockwise hue)", TRUE);
break;
case GRAD_HSV_CW:
SET_ACTIVE ("coloringtype/HSV (clockwise hue)", TRUE);
SET_ACTIVE ("/coloringtype/HSV (clockwise hue)", TRUE);
break;
}
}
else
{
SET_VISIBLE ("coloringtype/(Varies)", TRUE);
SET_ACTIVE ("coloringtype/(Varies)", TRUE);
SET_VISIBLE ("/coloringtype/(Varies)", TRUE);
SET_ACTIVE ("/coloringtype/(Varies)", TRUE);
}
SET_SENSITIVE ("Blend Endpoints' Colors", selection);
SET_SENSITIVE ("Blend Endpoints' Opacity", selection);
SET_SENSITIVE ("delete", delete);
SET_SENSITIVE ("/Blend Endpoints' Colors", selection);
SET_SENSITIVE ("/Blend Endpoints' Opacity", selection);
SET_SENSITIVE ("/delete", delete);
#undef SET_ACTIVE
#undef SET_COLOR

View File

@ -76,7 +76,8 @@ void gradient_editor_blend_opacity_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_show_context_menu (GradientEditor *editor);
void gradient_editor_menu_update (GtkItemFactory *factory,
gpointer data);
#endif /* __GRADIENT_EDITOR_COMMANDS_H__ */

View File

@ -41,7 +41,6 @@
/* local function prototypes */
static void gradients_menu_set_sensitivity (GimpContainerEditor *editor);
static void gradients_save_as_pov_query (GimpContainerEditor *editor);
static void gradients_save_as_pov_ok_callback (GtkWidget *widget,
GimpGradient *gradient);
@ -64,42 +63,34 @@ gradients_save_as_pov_ray_cmd_callback (GtkWidget *widget,
}
void
gradients_show_context_menu (GimpContainerEditor *editor)
gradients_menu_update (GtkItemFactory *factory,
gpointer data)
{
GtkItemFactory *item_factory;
GimpContainerEditor *editor;
GimpGradient *gradient;
gradients_menu_set_sensitivity (editor);
item_factory = gtk_item_factory_from_path ("<Gradients>");
gimp_item_factory_popup_with_data (item_factory, editor);
}
/* private functions */
static void
gradients_menu_set_sensitivity (GimpContainerEditor *editor)
{
GimpGradient *gradient;
editor = GIMP_CONTAINER_EDITOR (data);
gradient = gimp_context_get_gradient (editor->view->context);
#define SET_SENSITIVE(menu,condition) \
gimp_menu_item_set_sensitive ("<Gradients>/" menu, (condition) != 0)
gimp_item_factory_set_sensitive (factory, menu, (condition) != 0)
SET_SENSITIVE ("Duplicate Gradient",
SET_SENSITIVE ("/Duplicate Gradient",
gradient && GIMP_DATA_GET_CLASS (gradient)->duplicate);
SET_SENSITIVE ("Edit Gradient...",
SET_SENSITIVE ("/Edit Gradient...",
gradient && GIMP_DATA_FACTORY_VIEW (editor)->data_edit_func);
SET_SENSITIVE ("Delete Gradient...",
SET_SENSITIVE ("/Delete Gradient...",
gradient);
SET_SENSITIVE ("Save as POV-Ray...",
SET_SENSITIVE ("/Save as POV-Ray...",
gradient);
#undef SET_SENSITIVE
}
/* private functions */
static void
gradients_save_as_pov_query (GimpContainerEditor *editor)
{

View File

@ -23,8 +23,8 @@
void gradients_save_as_pov_ray_cmd_callback (GtkWidget *widget,
gpointer data);
void gradients_show_context_menu (GimpContainerEditor *editor);
void gradients_menu_update (GtkItemFactory *factory,
gpointer data);
#endif /* __GRADIENTS_COMMANDS_H__ */

View File

@ -52,14 +52,17 @@
#include "libgimp/gimpintl.h"
/* local function prototypes */
static void layers_add_mask_query (GimpLayer *layer);
static void layers_scale_layer_query (GimpImage *gimage,
GimpLayer *layer);
static void layers_resize_layer_query (GimpImage *gimage,
GimpLayer *layer);
static void layers_menu_set_sensitivity (GimpImage *gimage);
/* public functions */
void
layers_previous_cmd_callback (GtkWidget *widget,
gpointer data)
@ -1219,20 +1222,10 @@ layers_layer_merge_query (GimpImage *gimage,
}
void
layers_show_context_menu (GimpImage *gimage)
{
GtkItemFactory *item_factory;
layers_menu_set_sensitivity (gimage);
item_factory = gtk_item_factory_from_path ("<Layers>");
gimp_item_factory_popup_with_data (item_factory, gimage);
}
static void
layers_menu_set_sensitivity (GimpImage *gimage)
layers_menu_update (GtkItemFactory *factory,
gpointer data)
{
GimpImage *gimage;
GimpLayer *layer;
gboolean fs = FALSE; /* floating sel */
gboolean ac = FALSE; /* active channel */
@ -1245,8 +1238,7 @@ layers_menu_set_sensitivity (GimpImage *gimage)
GList *next = NULL;
GList *prev = NULL;
g_return_if_fail (gimage != NULL);
g_return_if_fail (GIMP_IS_IMAGE (gimage));
gimage = GIMP_IMAGE (data);
layer = gimp_image_get_active_layer (gimage);
@ -1279,43 +1271,43 @@ layers_menu_set_sensitivity (GimpImage *gimage)
next_alpha = FALSE;
#define SET_SENSITIVE(menu,condition) \
gimp_menu_item_set_sensitive ("<Layers>/" menu, (condition) != 0)
gimp_item_factory_set_sensitive (factory, menu, (condition) != 0)
SET_SENSITIVE ("New Layer...", gimage);
SET_SENSITIVE ("/New Layer...", gimage);
SET_SENSITIVE ("Stack/Raise Layer",
SET_SENSITIVE ("/Stack/Raise Layer",
!fs && !ac && gimage && lp && alpha && prev);
SET_SENSITIVE ("Stack/Lower Layer",
SET_SENSITIVE ("/Stack/Lower Layer",
!fs && !ac && gimage && lp && next && next_alpha);
SET_SENSITIVE ("Stack/Layer to Top",
SET_SENSITIVE ("/Stack/Layer to Top",
!fs && !ac && gimage && lp && alpha && prev);
SET_SENSITIVE ("Stack/Layer to Bottom",
SET_SENSITIVE ("/Stack/Layer to Bottom",
!fs && !ac && gimage && lp && next && next_alpha);
SET_SENSITIVE ("Duplicate Layer", !fs && !ac && gimage && lp);
SET_SENSITIVE ("Anchor Layer", !fs && !ac && gimage && lp);
SET_SENSITIVE ("Delete Layer", !ac && gimage && lp);
SET_SENSITIVE ("/Duplicate Layer", !fs && !ac && gimage && lp);
SET_SENSITIVE ("/Anchor Layer", !fs && !ac && gimage && lp);
SET_SENSITIVE ("/Delete Layer", !ac && gimage && lp);
SET_SENSITIVE ("Layer Boundary Size...", !ac && gimage && lp);
SET_SENSITIVE ("Layer to Imagesize", !ac && gimage && lp);
SET_SENSITIVE ("Scale Layer...", !ac && gimage && lp);
SET_SENSITIVE ("/Layer Boundary Size...", !ac && gimage && lp);
SET_SENSITIVE ("/Layer to Imagesize", !ac && gimage && lp);
SET_SENSITIVE ("/Scale Layer...", !ac && gimage && lp);
SET_SENSITIVE ("Merge Visible Layers...", !fs && !ac && gimage && lp);
SET_SENSITIVE ("Merge Down", !fs && !ac && gimage && lp && next);
SET_SENSITIVE ("Flatten Image", !fs && !ac && gimage && lp);
SET_SENSITIVE ("/Merge Visible Layers...", !fs && !ac && gimage && lp);
SET_SENSITIVE ("/Merge Down", !fs && !ac && gimage && lp && next);
SET_SENSITIVE ("/Flatten Image", !fs && !ac && gimage && lp);
SET_SENSITIVE ("Add Layer Mask...",
SET_SENSITIVE ("/Add Layer Mask...",
!fs && !ac && gimage && !lm && lp && alpha && !indexed);
SET_SENSITIVE ("Apply Layer Mask", !fs && !ac && gimage && lm && lp);
SET_SENSITIVE ("Delete Layer Mask", !fs && !ac && gimage && lm && lp);
SET_SENSITIVE ("Mask to Selection", !fs && !ac && gimage && lm && lp);
SET_SENSITIVE ("/Apply Layer Mask", !fs && !ac && gimage && lm && lp);
SET_SENSITIVE ("/Delete Layer Mask", !fs && !ac && gimage && lm && lp);
SET_SENSITIVE ("/Mask to Selection", !fs && !ac && gimage && lm && lp);
SET_SENSITIVE ("Add Alpha Channel", !fs && !alpha);
SET_SENSITIVE ("Alpha to Selection", !fs && !ac && gimage && lp && alpha);
SET_SENSITIVE ("/Add Alpha Channel", !fs && !alpha);
SET_SENSITIVE ("/Alpha to Selection", !fs && !ac && gimage && lp && alpha);
SET_SENSITIVE ("Edit Layer Attributes...", !fs && !ac && gimage && lp);
SET_SENSITIVE ("/Edit Layer Attributes...", !fs && !ac && gimage && lp);
#undef SET_SENSITIVE
}

View File

@ -67,9 +67,11 @@ void layers_add_alpha_channel_cmd_callback (GtkWidget *widet,
void layers_edit_attributes_cmd_callback (GtkWidget *widet,
gpointer data);
void layers_menu_update (GtkItemFactory *factory,
gpointer data);
void layers_new_layer_query (GimpImage *gimage);
void layers_edit_layer_query (GimpLayer *layer);
void layers_show_context_menu (GimpImage *gimage);
void layers_layer_merge_query (GimpImage *gimage,
gboolean merge_visible);

View File

@ -43,7 +43,6 @@
/* local function prototypes */
static void palettes_menu_set_sensitivity (GimpContainerEditor *editor);
static void palettes_merge_palettes_query (GimpContainerEditor *editor);
static void palettes_merge_palettes_callback (GtkWidget *widget,
gchar *palette_name,
@ -81,42 +80,34 @@ palettes_merge_palettes_cmd_callback (GtkWidget *widget,
}
void
palettes_show_context_menu (GimpContainerEditor *editor)
palettes_menu_update (GtkItemFactory *factory,
gpointer data)
{
GtkItemFactory *item_factory;
GimpContainerEditor *editor;
GimpPalette *palette;
palettes_menu_set_sensitivity (editor);
item_factory = gtk_item_factory_from_path ("<Palettes>");
gimp_item_factory_popup_with_data (item_factory, editor);
}
/* private functions */
static void
palettes_menu_set_sensitivity (GimpContainerEditor *editor)
{
GimpPalette *palette;
editor = GIMP_CONTAINER_EDITOR (data);
palette = gimp_context_get_palette (editor->view->context);
#define SET_SENSITIVE(menu,condition) \
gimp_menu_item_set_sensitive ("<Palettes>/" menu, (condition) != 0)
gimp_item_factory_set_sensitive (factory, menu, (condition) != 0)
SET_SENSITIVE ("Duplicate Palette",
SET_SENSITIVE ("/Duplicate Palette",
palette && GIMP_DATA_GET_CLASS (palette)->duplicate);
SET_SENSITIVE ("Edit Palette...",
SET_SENSITIVE ("/Edit Palette...",
palette && GIMP_DATA_FACTORY_VIEW (editor)->data_edit_func);
SET_SENSITIVE ("Delete Palette...",
SET_SENSITIVE ("/Delete Palette...",
palette);
SET_SENSITIVE ("Merge Palettes...",
SET_SENSITIVE ("/Merge Palettes...",
FALSE); /* FIXME palette && GIMP_IS_CONTAINER_LIST_VIEW (editor->view)); */
#undef SET_SENSITIVE
}
/* private functions */
static void
palettes_merge_palettes_query (GimpContainerEditor *editor)
{

View File

@ -25,8 +25,8 @@ void palettes_import_palette_cmd_callback (GtkWidget *widget,
void palettes_merge_palettes_cmd_callback (GtkWidget *widget,
gpointer data);
void palettes_show_context_menu (GimpContainerEditor *editor);
void palettes_menu_update (GtkItemFactory *factory,
gpointer data);
#endif /* __PALETTES_COMMANDS_H__ */

View File

@ -18,30 +18,26 @@
#include "config.h"
#include <stdlib.h>
#include <gtk/gtk.h>
#include "libgimpcolor/gimpcolor.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "display-types.h"
#include "gui-types.h"
#include "core/gimp.h"
#include "core/gimpchannel.h"
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "core/gimpimage-mask.h"
#include "core/gimpimage-qmask.h"
#include "widgets/gimpcolorpanel.h"
#include "widgets/gimpitemfactory.h"
#include "widgets/gimpwidgets-utils.h"
#include "gimpdisplay.h"
#include "gimpdisplay-foreach.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-qmask.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplay-foreach.h"
#include "display/gimpdisplayshell.h"
#include "floating_sel.h"
#include "undo.h"
#include "qmask-commands.h"
#include "libgimp/gimpintl.h"
@ -60,149 +56,105 @@ struct _EditQmaskOptions
/* local function prototypes */
static void edit_qmask_channel_query (GimpDisplay *gdisp);
static void edit_qmask_query_ok_callback (GtkWidget *widget,
gpointer client_data);
static void edit_qmask_query_cancel_callback (GtkWidget *widget,
gpointer client_data);
static void qmask_query_scale_update (GtkAdjustment *adjustment,
gpointer data);
static void qmask_color_changed (GimpColorButton *button,
gpointer data);
static void qmask_removed_callback (GtkObject *qmask,
gpointer data);
static void qmask_channel_query (GimpDisplayShell *shell);
static void qmask_query_ok_callback (GtkWidget *widget,
gpointer client_data);
static void qmask_query_cancel_callback (GtkWidget *widget,
gpointer client_data);
static void qmask_query_scale_update (GtkAdjustment *adjustment,
gpointer data);
static void qmask_query_color_changed (GimpColorButton *button,
gpointer data);
/* public functions */
gboolean
gimp_display_shell_qmask_button_press (GtkWidget *widget,
GdkEventButton *event,
GimpDisplayShell *shell)
/* public functionss */
void
qmask_toggle_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
{
GimpDisplay *gdisp;
GimpDisplayShell *shell;
gdisp = shell->gdisp;
shell = (GimpDisplayShell *) gimp_widget_get_callback_context (widget);
if ((event->type == GDK_2BUTTON_PRESS) && (event->button == 1))
{
edit_qmask_channel_query (gdisp);
if (! shell)
return;
return TRUE;
}
gimp_image_set_qmask_state (shell->gdisp->gimage,
GTK_CHECK_MENU_ITEM (widget)->active);
return FALSE;
gdisplays_flush ();
}
void
gimp_display_shell_qmask_toggled (GtkWidget *widget,
GimpDisplayShell *shell)
qmask_invert_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
{
GimpDisplay *gdisp;
GimpImage *gimage;
GimpChannel *mask;
GimpLayer *layer;
GimpRGB color;
GimpDisplayShell *shell;
gdisp = shell->gdisp;
shell = (GimpDisplayShell *) gimp_widget_get_callback_context (widget);
gimage = gdisp->gimage;
if (! shell)
return;
if (GTK_TOGGLE_BUTTON (widget)->active)
if (GTK_CHECK_MENU_ITEM (widget)->active)
{
if (gimp_image_get_qmask_state (gimage))
return; /* if already set, do nothing */
/* Set the defaults */
color = gimage->qmask_color;
gimp_image_qmask_invert (shell->gdisp->gimage);
mask = gimp_image_get_channel_by_name (gimage, "Qmask");
if (mask)
{
/* if the user was clever and created his own */
gimp_image_set_qmask_state (gimage, TRUE);
return;
}
undo_push_group_start (gimage, QMASK_UNDO);
if (gimp_image_mask_is_empty (gimage))
{
/* if no selection */
if ((layer = gimp_image_floating_sel (gimage)))
{
floating_sel_to_layer (layer);
}
mask = gimp_channel_new (gimage,
gimage->width,
gimage->height,
"Qmask",
&color);
gimp_image_add_channel (gimage, mask, 0);
gimp_drawable_fill_by_type (GIMP_DRAWABLE (mask),
gimp_get_user_context (gimage->gimp),
TRANSPARENT_FILL);
}
else /* if selection */
{
mask = gimp_channel_copy (gimp_image_get_mask (gimage), TRUE);
gimp_image_add_channel (gimage, mask, 0);
gimp_channel_set_color (mask, &color);
gimp_object_set_name (GIMP_OBJECT (mask), "Qmask");
gimp_image_mask_none (gimage); /* Clear the selection */
}
undo_push_qmask (gimage);
undo_push_group_end (gimage);
gimp_image_set_qmask_state (gimage, TRUE);
gdisplays_flush ();
/* connect to the removed signal, so the buttons get updated */
g_signal_connect (G_OBJECT (mask), "removed",
G_CALLBACK (qmask_removed_callback),
gdisp);
if (shell->gdisp->gimage->qmask_state)
gdisplays_flush ();
}
}
void
qmask_configure_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
{
GimpDisplayShell *shell;
shell = (GimpDisplayShell *) gimp_widget_get_callback_context (widget);
if (! shell)
return;
qmask_channel_query (shell);
}
void
qmask_menu_update (GtkItemFactory *factory,
gpointer data)
{
GimpDisplayShell *shell;
shell = GIMP_DISPLAY_SHELL (data);
#define SET_ACTIVE(menu,active) \
gimp_item_factory_set_active (factory, "/" menu, (active))
#define SET_COLOR(menu,color) \
gimp_item_factory_set_color (factory, "/" menu, (color), FALSE)
SET_ACTIVE ("QMask Active", shell->gdisp->gimage->qmask_state);
if (shell->gdisp->gimage->qmask_inverted)
SET_ACTIVE ("Mask Selected Areas", TRUE);
else
{
gimage = gdisp->gimage;
SET_ACTIVE ("Mask Unselected Areas", TRUE);
if (! gimp_image_get_qmask_state (gimage))
return; /* if already set do nothing */
SET_COLOR ("Configure Color and Opacity...",
&shell->gdisp->gimage->qmask_color);
mask = gimp_image_get_channel_by_name (gimage, "Qmask");
if (mask)
{
undo_push_group_start (gimage, QMASK_UNDO);
/* push the undo here since removing the mask will
* call the qmask_removed_callback() which will set
* the qmask_state to FALSE
*/
undo_push_qmask (gimage);
gimp_image_mask_load (gimage, mask);
gimp_image_remove_channel (gimage, mask);
undo_push_group_end (gimage);
}
gimp_image_set_qmask_state (gdisp->gimage, FALSE);
if (mask)
gdisplays_flush ();
}
#undef SET_SENSITIVE
#undef SET_COLOR
}
/* private functions */
static void
edit_qmask_channel_query (GimpDisplay *gdisp)
qmask_channel_query (GimpDisplayShell *shell)
{
EditQmaskOptions *options;
GtkWidget *hbox;
@ -214,7 +166,7 @@ edit_qmask_channel_query (GimpDisplay *gdisp)
/* the new options structure */
options = g_new0 (EditQmaskOptions, 1);
options->gimage = gdisp->gimage;
options->gimage = shell->gdisp->gimage;
options->color_panel = gimp_color_panel_new (_("Edit Qmask Color"),
&options->gimage->qmask_color,
GIMP_COLOR_AREA_LARGE_CHECKS,
@ -228,10 +180,10 @@ edit_qmask_channel_query (GimpDisplay *gdisp)
GTK_WIN_POS_MOUSE,
FALSE, TRUE, FALSE,
GTK_STOCK_CANCEL, edit_qmask_query_cancel_callback,
GTK_STOCK_CANCEL, qmask_query_cancel_callback,
options, NULL, NULL, FALSE, TRUE,
GTK_STOCK_OK, edit_qmask_query_ok_callback,
GTK_STOCK_OK, qmask_query_ok_callback,
options, NULL, NULL, TRUE, FALSE,
NULL);
@ -276,15 +228,15 @@ edit_qmask_channel_query (GimpDisplay *gdisp)
gtk_widget_show (options->color_panel);
g_signal_connect (G_OBJECT (options->color_panel), "color_changed",
G_CALLBACK (qmask_color_changed),
G_CALLBACK (qmask_query_color_changed),
opacity_scale_data);
gtk_widget_show (options->query_box);
}
static void
edit_qmask_query_ok_callback (GtkWidget *widget,
gpointer data)
qmask_query_ok_callback (GtkWidget *widget,
gpointer data)
{
EditQmaskOptions *options;
GimpChannel *channel;
@ -315,7 +267,7 @@ edit_qmask_query_ok_callback (GtkWidget *widget,
}
static void
edit_qmask_query_cancel_callback (GtkWidget *widget,
qmask_query_cancel_callback (GtkWidget *widget,
gpointer data)
{
EditQmaskOptions *options;
@ -338,8 +290,8 @@ qmask_query_scale_update (GtkAdjustment *adjustment,
}
static void
qmask_color_changed (GimpColorButton *button,
gpointer data)
qmask_query_color_changed (GimpColorButton *button,
gpointer data)
{
GtkAdjustment *adj = GTK_ADJUSTMENT (data);
GimpRGB color;
@ -347,15 +299,3 @@ qmask_color_changed (GimpColorButton *button,
gimp_color_button_get_color (button, &color);
gtk_adjustment_set_value (adj, color.a * 100.0);
}
static void
qmask_removed_callback (GtkObject *qmask,
gpointer data)
{
GimpDisplay *gdisp = (GimpDisplay *) data;
if (!gdisp->gimage)
return;
gimp_image_set_qmask_state (gdisp->gimage, FALSE);
}

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 __QMASK_COMMANDS_H__
#define __QMASK_COMMANDS_H__
void qmask_toggle_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void qmask_invert_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void qmask_configure_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void qmask_menu_update (GtkItemFactory *factory,
gpointer data);
#endif /* __QMASK_COMMANDS_H__ */

View File

@ -18,30 +18,26 @@
#include "config.h"
#include <stdlib.h>
#include <gtk/gtk.h>
#include "libgimpcolor/gimpcolor.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "display-types.h"
#include "gui-types.h"
#include "core/gimp.h"
#include "core/gimpchannel.h"
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "core/gimpimage-mask.h"
#include "core/gimpimage-qmask.h"
#include "widgets/gimpcolorpanel.h"
#include "widgets/gimpitemfactory.h"
#include "widgets/gimpwidgets-utils.h"
#include "gimpdisplay.h"
#include "gimpdisplay-foreach.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-qmask.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplay-foreach.h"
#include "display/gimpdisplayshell.h"
#include "floating_sel.h"
#include "undo.h"
#include "qmask-commands.h"
#include "libgimp/gimpintl.h"
@ -60,149 +56,105 @@ struct _EditQmaskOptions
/* local function prototypes */
static void edit_qmask_channel_query (GimpDisplay *gdisp);
static void edit_qmask_query_ok_callback (GtkWidget *widget,
gpointer client_data);
static void edit_qmask_query_cancel_callback (GtkWidget *widget,
gpointer client_data);
static void qmask_query_scale_update (GtkAdjustment *adjustment,
gpointer data);
static void qmask_color_changed (GimpColorButton *button,
gpointer data);
static void qmask_removed_callback (GtkObject *qmask,
gpointer data);
static void qmask_channel_query (GimpDisplayShell *shell);
static void qmask_query_ok_callback (GtkWidget *widget,
gpointer client_data);
static void qmask_query_cancel_callback (GtkWidget *widget,
gpointer client_data);
static void qmask_query_scale_update (GtkAdjustment *adjustment,
gpointer data);
static void qmask_query_color_changed (GimpColorButton *button,
gpointer data);
/* public functions */
gboolean
gimp_display_shell_qmask_button_press (GtkWidget *widget,
GdkEventButton *event,
GimpDisplayShell *shell)
/* public functionss */
void
qmask_toggle_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
{
GimpDisplay *gdisp;
GimpDisplayShell *shell;
gdisp = shell->gdisp;
shell = (GimpDisplayShell *) gimp_widget_get_callback_context (widget);
if ((event->type == GDK_2BUTTON_PRESS) && (event->button == 1))
{
edit_qmask_channel_query (gdisp);
if (! shell)
return;
return TRUE;
}
gimp_image_set_qmask_state (shell->gdisp->gimage,
GTK_CHECK_MENU_ITEM (widget)->active);
return FALSE;
gdisplays_flush ();
}
void
gimp_display_shell_qmask_toggled (GtkWidget *widget,
GimpDisplayShell *shell)
qmask_invert_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
{
GimpDisplay *gdisp;
GimpImage *gimage;
GimpChannel *mask;
GimpLayer *layer;
GimpRGB color;
GimpDisplayShell *shell;
gdisp = shell->gdisp;
shell = (GimpDisplayShell *) gimp_widget_get_callback_context (widget);
gimage = gdisp->gimage;
if (! shell)
return;
if (GTK_TOGGLE_BUTTON (widget)->active)
if (GTK_CHECK_MENU_ITEM (widget)->active)
{
if (gimp_image_get_qmask_state (gimage))
return; /* if already set, do nothing */
/* Set the defaults */
color = gimage->qmask_color;
gimp_image_qmask_invert (shell->gdisp->gimage);
mask = gimp_image_get_channel_by_name (gimage, "Qmask");
if (mask)
{
/* if the user was clever and created his own */
gimp_image_set_qmask_state (gimage, TRUE);
return;
}
undo_push_group_start (gimage, QMASK_UNDO);
if (gimp_image_mask_is_empty (gimage))
{
/* if no selection */
if ((layer = gimp_image_floating_sel (gimage)))
{
floating_sel_to_layer (layer);
}
mask = gimp_channel_new (gimage,
gimage->width,
gimage->height,
"Qmask",
&color);
gimp_image_add_channel (gimage, mask, 0);
gimp_drawable_fill_by_type (GIMP_DRAWABLE (mask),
gimp_get_user_context (gimage->gimp),
TRANSPARENT_FILL);
}
else /* if selection */
{
mask = gimp_channel_copy (gimp_image_get_mask (gimage), TRUE);
gimp_image_add_channel (gimage, mask, 0);
gimp_channel_set_color (mask, &color);
gimp_object_set_name (GIMP_OBJECT (mask), "Qmask");
gimp_image_mask_none (gimage); /* Clear the selection */
}
undo_push_qmask (gimage);
undo_push_group_end (gimage);
gimp_image_set_qmask_state (gimage, TRUE);
gdisplays_flush ();
/* connect to the removed signal, so the buttons get updated */
g_signal_connect (G_OBJECT (mask), "removed",
G_CALLBACK (qmask_removed_callback),
gdisp);
if (shell->gdisp->gimage->qmask_state)
gdisplays_flush ();
}
}
void
qmask_configure_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
{
GimpDisplayShell *shell;
shell = (GimpDisplayShell *) gimp_widget_get_callback_context (widget);
if (! shell)
return;
qmask_channel_query (shell);
}
void
qmask_menu_update (GtkItemFactory *factory,
gpointer data)
{
GimpDisplayShell *shell;
shell = GIMP_DISPLAY_SHELL (data);
#define SET_ACTIVE(menu,active) \
gimp_item_factory_set_active (factory, "/" menu, (active))
#define SET_COLOR(menu,color) \
gimp_item_factory_set_color (factory, "/" menu, (color), FALSE)
SET_ACTIVE ("QMask Active", shell->gdisp->gimage->qmask_state);
if (shell->gdisp->gimage->qmask_inverted)
SET_ACTIVE ("Mask Selected Areas", TRUE);
else
{
gimage = gdisp->gimage;
SET_ACTIVE ("Mask Unselected Areas", TRUE);
if (! gimp_image_get_qmask_state (gimage))
return; /* if already set do nothing */
SET_COLOR ("Configure Color and Opacity...",
&shell->gdisp->gimage->qmask_color);
mask = gimp_image_get_channel_by_name (gimage, "Qmask");
if (mask)
{
undo_push_group_start (gimage, QMASK_UNDO);
/* push the undo here since removing the mask will
* call the qmask_removed_callback() which will set
* the qmask_state to FALSE
*/
undo_push_qmask (gimage);
gimp_image_mask_load (gimage, mask);
gimp_image_remove_channel (gimage, mask);
undo_push_group_end (gimage);
}
gimp_image_set_qmask_state (gdisp->gimage, FALSE);
if (mask)
gdisplays_flush ();
}
#undef SET_SENSITIVE
#undef SET_COLOR
}
/* private functions */
static void
edit_qmask_channel_query (GimpDisplay *gdisp)
qmask_channel_query (GimpDisplayShell *shell)
{
EditQmaskOptions *options;
GtkWidget *hbox;
@ -214,7 +166,7 @@ edit_qmask_channel_query (GimpDisplay *gdisp)
/* the new options structure */
options = g_new0 (EditQmaskOptions, 1);
options->gimage = gdisp->gimage;
options->gimage = shell->gdisp->gimage;
options->color_panel = gimp_color_panel_new (_("Edit Qmask Color"),
&options->gimage->qmask_color,
GIMP_COLOR_AREA_LARGE_CHECKS,
@ -228,10 +180,10 @@ edit_qmask_channel_query (GimpDisplay *gdisp)
GTK_WIN_POS_MOUSE,
FALSE, TRUE, FALSE,
GTK_STOCK_CANCEL, edit_qmask_query_cancel_callback,
GTK_STOCK_CANCEL, qmask_query_cancel_callback,
options, NULL, NULL, FALSE, TRUE,
GTK_STOCK_OK, edit_qmask_query_ok_callback,
GTK_STOCK_OK, qmask_query_ok_callback,
options, NULL, NULL, TRUE, FALSE,
NULL);
@ -276,15 +228,15 @@ edit_qmask_channel_query (GimpDisplay *gdisp)
gtk_widget_show (options->color_panel);
g_signal_connect (G_OBJECT (options->color_panel), "color_changed",
G_CALLBACK (qmask_color_changed),
G_CALLBACK (qmask_query_color_changed),
opacity_scale_data);
gtk_widget_show (options->query_box);
}
static void
edit_qmask_query_ok_callback (GtkWidget *widget,
gpointer data)
qmask_query_ok_callback (GtkWidget *widget,
gpointer data)
{
EditQmaskOptions *options;
GimpChannel *channel;
@ -315,7 +267,7 @@ edit_qmask_query_ok_callback (GtkWidget *widget,
}
static void
edit_qmask_query_cancel_callback (GtkWidget *widget,
qmask_query_cancel_callback (GtkWidget *widget,
gpointer data)
{
EditQmaskOptions *options;
@ -338,8 +290,8 @@ qmask_query_scale_update (GtkAdjustment *adjustment,
}
static void
qmask_color_changed (GimpColorButton *button,
gpointer data)
qmask_query_color_changed (GimpColorButton *button,
gpointer data)
{
GtkAdjustment *adj = GTK_ADJUSTMENT (data);
GimpRGB color;
@ -347,15 +299,3 @@ qmask_color_changed (GimpColorButton *button,
gimp_color_button_get_color (button, &color);
gtk_adjustment_set_value (adj, color.a * 100.0);
}
static void
qmask_removed_callback (GtkObject *qmask,
gpointer data)
{
GimpDisplay *gdisp = (GimpDisplay *) data;
if (!gdisp->gimage)
return;
gimp_image_set_qmask_state (gdisp->gimage, FALSE);
}

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 __QMASK_COMMANDS_H__
#define __QMASK_COMMANDS_H__
void qmask_toggle_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void qmask_invert_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void qmask_configure_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void qmask_menu_update (GtkItemFactory *factory,
gpointer data);
#endif /* __QMASK_COMMANDS_H__ */

View File

@ -97,6 +97,8 @@ libappcore_a_sources = @STRIP_BEGIN@ \
gimpimage-new.h \
gimpimage-projection.c \
gimpimage-projection.h \
gimpimage-qmask.c \
gimpimage-qmask.h \
gimpimage-resize.c \
gimpimage-resize.h \
gimpimage-scale.c \

View File

@ -20,25 +20,18 @@
#include <stdlib.h>
#include <gtk/gtk.h>
#include <glib-object.h>
#include "libgimpcolor/gimpcolor.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "display-types.h"
#include "core-types.h"
#include "core/gimp.h"
#include "core/gimpchannel.h"
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "core/gimpimage-mask.h"
#include "widgets/gimpcolorpanel.h"
#include "gimpdisplay.h"
#include "gimpdisplay-foreach.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-qmask.h"
#include "gimp.h"
#include "gimpchannel.h"
#include "gimpcontext.h"
#include "gimpimage.h"
#include "gimpimage-mask.h"
#include "gimpimage-qmask.h"
#include "floating_sel.h"
#include "undo.h"
@ -46,316 +39,150 @@
#include "libgimp/gimpintl.h"
typedef struct _EditQmaskOptions EditQmaskOptions;
struct _EditQmaskOptions
{
GtkWidget *query_box;
GtkWidget *name_entry;
GtkWidget *color_panel;
GimpImage *gimage;
};
/* local function prototypes */
static void edit_qmask_channel_query (GimpDisplay *gdisp);
static void edit_qmask_query_ok_callback (GtkWidget *widget,
gpointer client_data);
static void edit_qmask_query_cancel_callback (GtkWidget *widget,
gpointer client_data);
static void qmask_query_scale_update (GtkAdjustment *adjustment,
gpointer data);
static void qmask_color_changed (GimpColorButton *button,
gpointer data);
static void qmask_removed_callback (GtkObject *qmask,
gpointer data);
static void gimp_image_qmask_removed_callback (GObject *qmask,
GimpImage *gimage);
/* public functions */
gboolean
gimp_display_shell_qmask_button_press (GtkWidget *widget,
GdkEventButton *event,
GimpDisplayShell *shell)
void
gimp_image_set_qmask_state (GimpImage *gimage,
gboolean qmask_state)
{
GimpDisplay *gdisp;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
gdisp = shell->gdisp;
if ((event->type == GDK_2BUTTON_PRESS) && (event->button == 1))
if (qmask_state != gimage->qmask_state)
{
edit_qmask_channel_query (gdisp);
GimpChannel *mask;
GimpRGB color;
return TRUE;
if (qmask_state)
{
/* Set the defaults */
color = gimage->qmask_color;
mask = gimp_image_get_channel_by_name (gimage, "Qmask");
if (! mask)
{
undo_push_group_start (gimage, QMASK_UNDO);
if (gimp_image_mask_is_empty (gimage))
{
GimpLayer *layer;
/* if no selection */
if ((layer = gimp_image_floating_sel (gimage)))
{
floating_sel_to_layer (layer);
}
mask = gimp_channel_new (gimage,
gimage->width,
gimage->height,
"Qmask",
&color);
gimp_image_add_channel (gimage, mask, 0);
gimp_drawable_fill_by_type (GIMP_DRAWABLE (mask),
gimp_get_current_context (gimage->gimp),
TRANSPARENT_FILL);
}
else /* if selection */
{
mask = gimp_channel_copy (gimp_image_get_mask (gimage), TRUE);
gimp_image_mask_none (gimage); /* Clear the selection */
gimp_image_add_channel (gimage, mask, 0);
gimp_channel_set_color (mask, &color);
gimp_object_set_name (GIMP_OBJECT (mask), "Qmask");
}
if (gimage->qmask_inverted)
gimp_channel_invert (mask);
undo_push_qmask (gimage);
undo_push_group_end (gimage);
/* connect to the removed signal, so the buttons get updated */
g_signal_connect (G_OBJECT (mask), "removed",
G_CALLBACK (gimp_image_qmask_removed_callback),
gimage);
}
}
else
{
mask = gimp_image_get_channel_by_name (gimage, "Qmask");
if (mask)
{
undo_push_group_start (gimage, QMASK_UNDO);
/* push the undo here since removing the mask will
* call the qmask_removed_callback() which will set
* the qmask_state to FALSE
*/
undo_push_qmask (gimage);
if (gimage->qmask_inverted)
gimp_channel_invert (mask);
gimp_image_mask_load (gimage, mask);
gimp_image_remove_channel (gimage, mask);
undo_push_group_end (gimage);
}
}
gimage->qmask_state = qmask_state ? TRUE : FALSE;
gimp_image_qmask_changed (gimage);
}
}
return FALSE;
gboolean
gimp_image_get_qmask_state (const GimpImage *gimage)
{
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
return gimage->qmask_state;
}
void
gimp_display_shell_qmask_toggled (GtkWidget *widget,
GimpDisplayShell *shell)
gimp_image_qmask_invert (GimpImage *gimage)
{
GimpDisplay *gdisp;
GimpImage *gimage;
GimpChannel *mask;
GimpLayer *layer;
GimpRGB color;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
gdisp = shell->gdisp;
gimage = gdisp->gimage;
if (GTK_TOGGLE_BUTTON (widget)->active)
if (gimage->qmask_state)
{
if (gimp_image_get_qmask_state (gimage))
return; /* if already set, do nothing */
/* Set the defaults */
color = gimage->qmask_color;
GimpChannel *qmask;
mask = gimp_image_get_channel_by_name (gimage, "Qmask");
qmask = gimp_image_get_channel_by_name (gimage, "Qmask");
if (mask)
{
/* if the user was clever and created his own */
if (qmask)
{
gimp_channel_invert (qmask);
gimp_image_set_qmask_state (gimage, TRUE);
return;
}
undo_push_group_start (gimage, QMASK_UNDO);
if (gimp_image_mask_is_empty (gimage))
{
/* if no selection */
if ((layer = gimp_image_floating_sel (gimage)))
{
floating_sel_to_layer (layer);
}
mask = gimp_channel_new (gimage,
gimage->width,
gimage->height,
"Qmask",
&color);
gimp_image_add_channel (gimage, mask, 0);
gimp_drawable_fill_by_type (GIMP_DRAWABLE (mask),
gimp_get_user_context (gimage->gimp),
TRANSPARENT_FILL);
}
else /* if selection */
{
mask = gimp_channel_copy (gimp_image_get_mask (gimage), TRUE);
gimp_image_add_channel (gimage, mask, 0);
gimp_channel_set_color (mask, &color);
gimp_object_set_name (GIMP_OBJECT (mask), "Qmask");
gimp_image_mask_none (gimage); /* Clear the selection */
}
undo_push_qmask (gimage);
undo_push_group_end (gimage);
gimp_image_set_qmask_state (gimage, TRUE);
gdisplays_flush ();
/* connect to the removed signal, so the buttons get updated */
g_signal_connect (G_OBJECT (mask), "removed",
G_CALLBACK (qmask_removed_callback),
gdisp);
gimp_drawable_update (GIMP_DRAWABLE (qmask),
0, 0,
GIMP_DRAWABLE (qmask)->width,
GIMP_DRAWABLE (qmask)->height);
}
}
else
{
gimage = gdisp->gimage;
if (! gimp_image_get_qmask_state (gimage))
return; /* if already set do nothing */
mask = gimp_image_get_channel_by_name (gimage, "Qmask");
if (mask)
{
undo_push_group_start (gimage, QMASK_UNDO);
/* push the undo here since removing the mask will
* call the qmask_removed_callback() which will set
* the qmask_state to FALSE
*/
undo_push_qmask (gimage);
gimp_image_mask_load (gimage, mask);
gimp_image_remove_channel (gimage, mask);
undo_push_group_end (gimage);
}
gimp_image_set_qmask_state (gdisp->gimage, FALSE);
if (mask)
gdisplays_flush ();
}
gimage->qmask_inverted = ! gimage->qmask_inverted;
}
/* private functions */
static void
edit_qmask_channel_query (GimpDisplay *gdisp)
gimp_image_qmask_removed_callback (GObject *qmask,
GimpImage *gimage)
{
EditQmaskOptions *options;
GtkWidget *hbox;
GtkWidget *vbox;
GtkWidget *table;
GtkWidget *opacity_scale;
GtkObject *opacity_scale_data;
/* the new options structure */
options = g_new0 (EditQmaskOptions, 1);
options->gimage = gdisp->gimage;
options->color_panel = gimp_color_panel_new (_("Edit Qmask Color"),
&options->gimage->qmask_color,
GIMP_COLOR_AREA_LARGE_CHECKS,
48, 64);
/* The dialog */
options->query_box =
gimp_dialog_new (_("Edit Qmask Attributes"), "edit_qmask_attributes",
gimp_standard_help_func,
"dialogs/edit_qmask_attributes.html",
GTK_WIN_POS_MOUSE,
FALSE, TRUE, FALSE,
GTK_STOCK_CANCEL, edit_qmask_query_cancel_callback,
options, NULL, NULL, FALSE, TRUE,
GTK_STOCK_OK, edit_qmask_query_ok_callback,
options, NULL, NULL, TRUE, FALSE,
NULL);
/* The main hbox */
hbox = gtk_hbox_new (FALSE, 4);
gtk_container_set_border_width (GTK_CONTAINER (hbox), 4);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (options->query_box)->vbox),
hbox);
gtk_widget_show (hbox);
/* The vbox */
vbox = gtk_vbox_new (FALSE, 2);
gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
gtk_widget_show (vbox);
/* The table */
table = gtk_table_new (1, 2, FALSE);
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
gtk_widget_show (table);
/* The opacity scale */
opacity_scale_data =
gtk_adjustment_new (options->gimage->qmask_color.a * 100.0,
0.0, 100.0, 1.0, 1.0, 0.0);
opacity_scale = gtk_hscale_new (GTK_ADJUSTMENT (opacity_scale_data));
gtk_widget_set_usize (opacity_scale, 100, -1);
gtk_scale_set_value_pos (GTK_SCALE (opacity_scale), GTK_POS_TOP);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
_("Mask Opacity:"), 1.0, 1.0,
opacity_scale, 1, FALSE);
g_signal_connect (G_OBJECT (opacity_scale_data), "value_changed",
G_CALLBACK (qmask_query_scale_update),
options->color_panel);
/* The color panel */
gtk_box_pack_start (GTK_BOX (hbox), options->color_panel,
TRUE, TRUE, 0);
gtk_widget_show (options->color_panel);
g_signal_connect (G_OBJECT (options->color_panel), "color_changed",
G_CALLBACK (qmask_color_changed),
opacity_scale_data);
gtk_widget_show (options->query_box);
}
static void
edit_qmask_query_ok_callback (GtkWidget *widget,
gpointer data)
{
EditQmaskOptions *options;
GimpChannel *channel;
GimpRGB color;
options = (EditQmaskOptions *) data;
channel = gimp_image_get_channel_by_name (options->gimage, "Qmask");
if (options->gimage && channel)
{
gimp_color_button_get_color (GIMP_COLOR_BUTTON (options->color_panel),
&color);
if (gimp_rgba_distance (&color, &channel->color) > 0.0001)
{
gimp_channel_set_color (channel, &color);
gdisplays_flush ();
}
}
/* update the qmask color no matter what */
options->gimage->qmask_color = color;
gtk_widget_destroy (options->query_box);
g_free (options);
}
static void
edit_qmask_query_cancel_callback (GtkWidget *widget,
gpointer data)
{
EditQmaskOptions *options;
options = (EditQmaskOptions *) data;
gtk_widget_destroy (options->query_box);
g_free (options);
}
static void
qmask_query_scale_update (GtkAdjustment *adjustment,
gpointer data)
{
GimpRGB color;
gimp_color_button_get_color (GIMP_COLOR_BUTTON (data), &color);
gimp_rgb_set_alpha (&color, adjustment->value / 100.0);
gimp_color_button_set_color (GIMP_COLOR_BUTTON (data), &color);
}
static void
qmask_color_changed (GimpColorButton *button,
gpointer data)
{
GtkAdjustment *adj = GTK_ADJUSTMENT (data);
GimpRGB color;
gimp_color_button_get_color (button, &color);
gtk_adjustment_set_value (adj, color.a * 100.0);
}
static void
qmask_removed_callback (GtkObject *qmask,
gpointer data)
{
GimpDisplay *gdisp = (GimpDisplay *) data;
if (!gdisp->gimage)
return;
gimp_image_set_qmask_state (gdisp->gimage, FALSE);
gimp_image_set_qmask_state (gimage, FALSE);
}

View File

@ -16,15 +16,15 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_DISPLAY_SHELL_QMASK_H__
#define __GIMP_DISPLAY_SHELL_QMASK_H__
#ifndef __GIMP_IMAGE_QMASK_H__
#define __GIMP_IMAGE_QMASK_H__
gboolean gimp_display_shell_qmask_button_press (GtkWidget *widget,
GdkEventButton *event,
GimpDisplayShell *shell);
void gimp_display_shell_qmask_toggled (GtkWidget *widget,
GimpDisplayShell *shell);
void gimp_image_set_qmask_state (GimpImage *gimage,
gboolean qmask_state);
gboolean gimp_image_get_qmask_state (const GimpImage *gimage);
void gimp_image_qmask_invert (GimpImage *gimage);
#endif /* __GIMP_DISPLAY_SHELL_QMASK_H__ */
#endif /* __GIMP_IMAGE_QMASK_H__ */

View File

@ -20,25 +20,18 @@
#include <stdlib.h>
#include <gtk/gtk.h>
#include <glib-object.h>
#include "libgimpcolor/gimpcolor.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "display-types.h"
#include "core-types.h"
#include "core/gimp.h"
#include "core/gimpchannel.h"
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "core/gimpimage-mask.h"
#include "widgets/gimpcolorpanel.h"
#include "gimpdisplay.h"
#include "gimpdisplay-foreach.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-qmask.h"
#include "gimp.h"
#include "gimpchannel.h"
#include "gimpcontext.h"
#include "gimpimage.h"
#include "gimpimage-mask.h"
#include "gimpimage-qmask.h"
#include "floating_sel.h"
#include "undo.h"
@ -46,316 +39,150 @@
#include "libgimp/gimpintl.h"
typedef struct _EditQmaskOptions EditQmaskOptions;
struct _EditQmaskOptions
{
GtkWidget *query_box;
GtkWidget *name_entry;
GtkWidget *color_panel;
GimpImage *gimage;
};
/* local function prototypes */
static void edit_qmask_channel_query (GimpDisplay *gdisp);
static void edit_qmask_query_ok_callback (GtkWidget *widget,
gpointer client_data);
static void edit_qmask_query_cancel_callback (GtkWidget *widget,
gpointer client_data);
static void qmask_query_scale_update (GtkAdjustment *adjustment,
gpointer data);
static void qmask_color_changed (GimpColorButton *button,
gpointer data);
static void qmask_removed_callback (GtkObject *qmask,
gpointer data);
static void gimp_image_qmask_removed_callback (GObject *qmask,
GimpImage *gimage);
/* public functions */
gboolean
gimp_display_shell_qmask_button_press (GtkWidget *widget,
GdkEventButton *event,
GimpDisplayShell *shell)
void
gimp_image_set_qmask_state (GimpImage *gimage,
gboolean qmask_state)
{
GimpDisplay *gdisp;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
gdisp = shell->gdisp;
if ((event->type == GDK_2BUTTON_PRESS) && (event->button == 1))
if (qmask_state != gimage->qmask_state)
{
edit_qmask_channel_query (gdisp);
GimpChannel *mask;
GimpRGB color;
return TRUE;
if (qmask_state)
{
/* Set the defaults */
color = gimage->qmask_color;
mask = gimp_image_get_channel_by_name (gimage, "Qmask");
if (! mask)
{
undo_push_group_start (gimage, QMASK_UNDO);
if (gimp_image_mask_is_empty (gimage))
{
GimpLayer *layer;
/* if no selection */
if ((layer = gimp_image_floating_sel (gimage)))
{
floating_sel_to_layer (layer);
}
mask = gimp_channel_new (gimage,
gimage->width,
gimage->height,
"Qmask",
&color);
gimp_image_add_channel (gimage, mask, 0);
gimp_drawable_fill_by_type (GIMP_DRAWABLE (mask),
gimp_get_current_context (gimage->gimp),
TRANSPARENT_FILL);
}
else /* if selection */
{
mask = gimp_channel_copy (gimp_image_get_mask (gimage), TRUE);
gimp_image_mask_none (gimage); /* Clear the selection */
gimp_image_add_channel (gimage, mask, 0);
gimp_channel_set_color (mask, &color);
gimp_object_set_name (GIMP_OBJECT (mask), "Qmask");
}
if (gimage->qmask_inverted)
gimp_channel_invert (mask);
undo_push_qmask (gimage);
undo_push_group_end (gimage);
/* connect to the removed signal, so the buttons get updated */
g_signal_connect (G_OBJECT (mask), "removed",
G_CALLBACK (gimp_image_qmask_removed_callback),
gimage);
}
}
else
{
mask = gimp_image_get_channel_by_name (gimage, "Qmask");
if (mask)
{
undo_push_group_start (gimage, QMASK_UNDO);
/* push the undo here since removing the mask will
* call the qmask_removed_callback() which will set
* the qmask_state to FALSE
*/
undo_push_qmask (gimage);
if (gimage->qmask_inverted)
gimp_channel_invert (mask);
gimp_image_mask_load (gimage, mask);
gimp_image_remove_channel (gimage, mask);
undo_push_group_end (gimage);
}
}
gimage->qmask_state = qmask_state ? TRUE : FALSE;
gimp_image_qmask_changed (gimage);
}
}
return FALSE;
gboolean
gimp_image_get_qmask_state (const GimpImage *gimage)
{
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
return gimage->qmask_state;
}
void
gimp_display_shell_qmask_toggled (GtkWidget *widget,
GimpDisplayShell *shell)
gimp_image_qmask_invert (GimpImage *gimage)
{
GimpDisplay *gdisp;
GimpImage *gimage;
GimpChannel *mask;
GimpLayer *layer;
GimpRGB color;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
gdisp = shell->gdisp;
gimage = gdisp->gimage;
if (GTK_TOGGLE_BUTTON (widget)->active)
if (gimage->qmask_state)
{
if (gimp_image_get_qmask_state (gimage))
return; /* if already set, do nothing */
/* Set the defaults */
color = gimage->qmask_color;
GimpChannel *qmask;
mask = gimp_image_get_channel_by_name (gimage, "Qmask");
qmask = gimp_image_get_channel_by_name (gimage, "Qmask");
if (mask)
{
/* if the user was clever and created his own */
if (qmask)
{
gimp_channel_invert (qmask);
gimp_image_set_qmask_state (gimage, TRUE);
return;
}
undo_push_group_start (gimage, QMASK_UNDO);
if (gimp_image_mask_is_empty (gimage))
{
/* if no selection */
if ((layer = gimp_image_floating_sel (gimage)))
{
floating_sel_to_layer (layer);
}
mask = gimp_channel_new (gimage,
gimage->width,
gimage->height,
"Qmask",
&color);
gimp_image_add_channel (gimage, mask, 0);
gimp_drawable_fill_by_type (GIMP_DRAWABLE (mask),
gimp_get_user_context (gimage->gimp),
TRANSPARENT_FILL);
}
else /* if selection */
{
mask = gimp_channel_copy (gimp_image_get_mask (gimage), TRUE);
gimp_image_add_channel (gimage, mask, 0);
gimp_channel_set_color (mask, &color);
gimp_object_set_name (GIMP_OBJECT (mask), "Qmask");
gimp_image_mask_none (gimage); /* Clear the selection */
}
undo_push_qmask (gimage);
undo_push_group_end (gimage);
gimp_image_set_qmask_state (gimage, TRUE);
gdisplays_flush ();
/* connect to the removed signal, so the buttons get updated */
g_signal_connect (G_OBJECT (mask), "removed",
G_CALLBACK (qmask_removed_callback),
gdisp);
gimp_drawable_update (GIMP_DRAWABLE (qmask),
0, 0,
GIMP_DRAWABLE (qmask)->width,
GIMP_DRAWABLE (qmask)->height);
}
}
else
{
gimage = gdisp->gimage;
if (! gimp_image_get_qmask_state (gimage))
return; /* if already set do nothing */
mask = gimp_image_get_channel_by_name (gimage, "Qmask");
if (mask)
{
undo_push_group_start (gimage, QMASK_UNDO);
/* push the undo here since removing the mask will
* call the qmask_removed_callback() which will set
* the qmask_state to FALSE
*/
undo_push_qmask (gimage);
gimp_image_mask_load (gimage, mask);
gimp_image_remove_channel (gimage, mask);
undo_push_group_end (gimage);
}
gimp_image_set_qmask_state (gdisp->gimage, FALSE);
if (mask)
gdisplays_flush ();
}
gimage->qmask_inverted = ! gimage->qmask_inverted;
}
/* private functions */
static void
edit_qmask_channel_query (GimpDisplay *gdisp)
gimp_image_qmask_removed_callback (GObject *qmask,
GimpImage *gimage)
{
EditQmaskOptions *options;
GtkWidget *hbox;
GtkWidget *vbox;
GtkWidget *table;
GtkWidget *opacity_scale;
GtkObject *opacity_scale_data;
/* the new options structure */
options = g_new0 (EditQmaskOptions, 1);
options->gimage = gdisp->gimage;
options->color_panel = gimp_color_panel_new (_("Edit Qmask Color"),
&options->gimage->qmask_color,
GIMP_COLOR_AREA_LARGE_CHECKS,
48, 64);
/* The dialog */
options->query_box =
gimp_dialog_new (_("Edit Qmask Attributes"), "edit_qmask_attributes",
gimp_standard_help_func,
"dialogs/edit_qmask_attributes.html",
GTK_WIN_POS_MOUSE,
FALSE, TRUE, FALSE,
GTK_STOCK_CANCEL, edit_qmask_query_cancel_callback,
options, NULL, NULL, FALSE, TRUE,
GTK_STOCK_OK, edit_qmask_query_ok_callback,
options, NULL, NULL, TRUE, FALSE,
NULL);
/* The main hbox */
hbox = gtk_hbox_new (FALSE, 4);
gtk_container_set_border_width (GTK_CONTAINER (hbox), 4);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (options->query_box)->vbox),
hbox);
gtk_widget_show (hbox);
/* The vbox */
vbox = gtk_vbox_new (FALSE, 2);
gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
gtk_widget_show (vbox);
/* The table */
table = gtk_table_new (1, 2, FALSE);
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
gtk_widget_show (table);
/* The opacity scale */
opacity_scale_data =
gtk_adjustment_new (options->gimage->qmask_color.a * 100.0,
0.0, 100.0, 1.0, 1.0, 0.0);
opacity_scale = gtk_hscale_new (GTK_ADJUSTMENT (opacity_scale_data));
gtk_widget_set_usize (opacity_scale, 100, -1);
gtk_scale_set_value_pos (GTK_SCALE (opacity_scale), GTK_POS_TOP);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
_("Mask Opacity:"), 1.0, 1.0,
opacity_scale, 1, FALSE);
g_signal_connect (G_OBJECT (opacity_scale_data), "value_changed",
G_CALLBACK (qmask_query_scale_update),
options->color_panel);
/* The color panel */
gtk_box_pack_start (GTK_BOX (hbox), options->color_panel,
TRUE, TRUE, 0);
gtk_widget_show (options->color_panel);
g_signal_connect (G_OBJECT (options->color_panel), "color_changed",
G_CALLBACK (qmask_color_changed),
opacity_scale_data);
gtk_widget_show (options->query_box);
}
static void
edit_qmask_query_ok_callback (GtkWidget *widget,
gpointer data)
{
EditQmaskOptions *options;
GimpChannel *channel;
GimpRGB color;
options = (EditQmaskOptions *) data;
channel = gimp_image_get_channel_by_name (options->gimage, "Qmask");
if (options->gimage && channel)
{
gimp_color_button_get_color (GIMP_COLOR_BUTTON (options->color_panel),
&color);
if (gimp_rgba_distance (&color, &channel->color) > 0.0001)
{
gimp_channel_set_color (channel, &color);
gdisplays_flush ();
}
}
/* update the qmask color no matter what */
options->gimage->qmask_color = color;
gtk_widget_destroy (options->query_box);
g_free (options);
}
static void
edit_qmask_query_cancel_callback (GtkWidget *widget,
gpointer data)
{
EditQmaskOptions *options;
options = (EditQmaskOptions *) data;
gtk_widget_destroy (options->query_box);
g_free (options);
}
static void
qmask_query_scale_update (GtkAdjustment *adjustment,
gpointer data)
{
GimpRGB color;
gimp_color_button_get_color (GIMP_COLOR_BUTTON (data), &color);
gimp_rgb_set_alpha (&color, adjustment->value / 100.0);
gimp_color_button_set_color (GIMP_COLOR_BUTTON (data), &color);
}
static void
qmask_color_changed (GimpColorButton *button,
gpointer data)
{
GtkAdjustment *adj = GTK_ADJUSTMENT (data);
GimpRGB color;
gimp_color_button_get_color (button, &color);
gtk_adjustment_set_value (adj, color.a * 100.0);
}
static void
qmask_removed_callback (GtkObject *qmask,
gpointer data)
{
GimpDisplay *gdisp = (GimpDisplay *) data;
if (!gdisp->gimage)
return;
gimp_image_set_qmask_state (gdisp->gimage, FALSE);
gimp_image_set_qmask_state (gimage, FALSE);
}

View File

@ -0,0 +1,30 @@
/* 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 __GIMP_IMAGE_QMASK_H__
#define __GIMP_IMAGE_QMASK_H__
void gimp_image_set_qmask_state (GimpImage *gimage,
gboolean qmask_state);
gboolean gimp_image_get_qmask_state (const GimpImage *gimage);
void gimp_image_qmask_invert (GimpImage *gimage);
#endif /* __GIMP_IMAGE_QMASK_H__ */

View File

@ -429,6 +429,7 @@ gimp_image_init (GimpImage *gimage)
gimage->paths = NULL;
gimage->qmask_state = FALSE;
gimage->qmask_inverted = FALSE;
gimage->qmask_color.r = 1.0;
gimage->qmask_color.g = 0.0;
gimage->qmask_color.b = 0.0;
@ -1040,36 +1041,6 @@ gimp_image_unit_changed (GimpImage *gimage)
g_signal_emit (G_OBJECT (gimage), gimp_image_signals[UNIT_CHANGED], 0);
}
void
gimp_image_set_qmask_state (GimpImage *gimage,
gboolean qmask_state)
{
g_return_if_fail (GIMP_IS_IMAGE (gimage));
if (qmask_state != gimage->qmask_state)
{
gimage->qmask_state = qmask_state ? TRUE : FALSE;
gimp_image_qmask_changed (gimage);
}
}
gboolean
gimp_image_get_qmask_state (const GimpImage *gimage)
{
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
return gimage->qmask_state;
}
void
gimp_image_qmask_changed (GimpImage *gimage)
{
g_return_if_fail (GIMP_IS_IMAGE (gimage));
g_signal_emit (G_OBJECT (gimage), gimp_image_signals[QMASK_CHANGED], 0);
}
gint
gimp_image_get_width (const GimpImage *gimage)
{
@ -1371,6 +1342,14 @@ gimp_image_selection_control (GimpImage *gimage,
control);
}
void
gimp_image_qmask_changed (GimpImage *gimage)
{
g_return_if_fail (GIMP_IS_IMAGE (gimage));
g_signal_emit (G_OBJECT (gimage), gimp_image_signals[QMASK_CHANGED], 0);
}
/* undo */

View File

@ -106,6 +106,7 @@ struct _GimpImage
gboolean active[MAX_CHANNELS]; /* active channels */
gboolean qmask_state; /* TRUE if qmask is on */
gboolean qmask_inverted; /* TRUE if qmask is inverted */
GimpRGB qmask_color; /* rgba triplet of the color */
/* Old undo apparatus */
@ -201,11 +202,6 @@ void gimp_image_set_unit (GimpImage *gimage,
GimpUnit gimp_image_get_unit (const GimpImage *gimage);
void gimp_image_unit_changed (GimpImage *gimage);
void gimp_image_set_qmask_state (GimpImage *gimage,
gboolean qmask_state);
gboolean gimp_image_get_qmask_state (const GimpImage *gimage);
void gimp_image_qmask_changed (GimpImage *gimage);
gint gimp_image_get_width (const GimpImage *gimage);
gint gimp_image_get_height (const GimpImage *gimage);
@ -247,6 +243,7 @@ void gimp_image_update_guide (GimpImage *gimage,
GimpGuide *guide);
void gimp_image_selection_control (GimpImage *gimage,
GimpSelectionControl control);
void gimp_image_qmask_changed (GimpImage *gimage);
/* undo */

View File

@ -385,7 +385,7 @@ dialogs_brush_list_view_new (GimpDialogFactory *factory,
TRUE,
preview_size,
5, 3,
brushes_show_context_menu);
"<Brushes>");
return dialogs_dockable_new (view,
"Brush List", "Brushes",
@ -406,7 +406,7 @@ dialogs_pattern_list_view_new (GimpDialogFactory *factory,
context,
preview_size,
5, 3,
patterns_show_context_menu);
"<Patterns>");
return dialogs_dockable_new (view,
"Pattern List", "Patterns",
@ -427,7 +427,7 @@ dialogs_gradient_list_view_new (GimpDialogFactory *factory,
context,
preview_size,
5, 3,
gradients_show_context_menu);
"<Gradients>");
return dialogs_dockable_new (view,
"Gradient List", "Gradients",
@ -448,7 +448,7 @@ dialogs_palette_list_view_new (GimpDialogFactory *factory,
context,
preview_size,
5, 3,
palettes_show_context_menu);
"<Palettes>");
return dialogs_dockable_new (view,
"Palette List", "Palettes",
@ -487,7 +487,7 @@ dialogs_buffer_list_view_new (GimpDialogFactory *factory,
context,
preview_size,
5, 3,
buffers_show_context_menu);
"<Buffers>");
return dialogs_dockable_new (view,
"Buffer List", "Buffers",
@ -531,7 +531,7 @@ dialogs_brush_grid_view_new (GimpDialogFactory *factory,
TRUE,
preview_size,
5, 3,
brushes_show_context_menu);
"<Brushes>");
return dialogs_dockable_new (view,
"Brush Grid", "Brushes",
@ -552,7 +552,7 @@ dialogs_pattern_grid_view_new (GimpDialogFactory *factory,
context,
preview_size,
5, 3,
patterns_show_context_menu);
"<Patterns>");
return dialogs_dockable_new (view,
"Pattern Grid", "Patterns",
@ -573,7 +573,7 @@ dialogs_gradient_grid_view_new (GimpDialogFactory *factory,
context,
preview_size,
5, 3,
gradients_show_context_menu);
"<Gradients>");
return dialogs_dockable_new (view,
"Gradient Grid", "Gradients",
@ -594,7 +594,7 @@ dialogs_palette_grid_view_new (GimpDialogFactory *factory,
context,
preview_size,
5, 3,
palettes_show_context_menu);
"<Gradients>");
return dialogs_dockable_new (view,
"Palette Grid", "Palettes",
@ -633,7 +633,7 @@ dialogs_buffer_grid_view_new (GimpDialogFactory *factory,
context,
preview_size,
5, 3,
buffers_show_context_menu);
"<Buffers>");
return dialogs_dockable_new (view,
"Buffer Grid", "Buffers",
@ -669,7 +669,7 @@ dialogs_layer_list_view_new (GimpDialogFactory *factory,
(GimpCopyDrawableFunc) gimp_layer_copy,
(GimpNewDrawableFunc) layers_new_layer_query,
(GimpEditDrawableFunc) layers_edit_layer_query,
(GimpDrawableContextFunc) layers_show_context_menu);
"<Layers>");
dockable = dialogs_dockable_new (view,
"Layer List", "Layers",
@ -706,7 +706,7 @@ dialogs_channel_list_view_new (GimpDialogFactory *factory,
(GimpCopyDrawableFunc) gimp_channel_copy,
(GimpNewDrawableFunc) channels_new_channel_query,
(GimpEditDrawableFunc) channels_edit_channel_query,
(GimpDrawableContextFunc) channels_show_context_menu);
"<Channels>");
dockable = dialogs_dockable_new (view,
"Channel List", "Channels",
@ -786,7 +786,7 @@ dialogs_document_history_new (GimpDialogFactory *factory,
context,
preview_size,
5, 3,
documents_show_context_menu);
"<Documents>");
return dialogs_dockable_new (view,
"Document History", "History",

View File

@ -23,8 +23,6 @@ libappdisplay_a_SOURCES = @STRIP_BEGIN@ \
gimpdisplayshell-layer-select.c \
gimpdisplayshell-layer-select.h \
gimpdisplayshell-marching-ants.h \
gimpdisplayshell-qmask.c \
gimpdisplayshell-qmask.h \
gimpdisplayshell-render.c \
gimpdisplayshell-render.h \
gimpdisplayshell-scale.c \

View File

@ -32,6 +32,7 @@
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "core/gimpimage-qmask.h"
#include "core/gimplayer.h"
#include "core/gimptoolinfo.h"
@ -42,11 +43,12 @@
#include "widgets/gimpcursor.h"
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimpwidgets-utils.h"
#include "widgets/gimpitemfactory.h"
#include "gui/dialogs.h"
#include "gimpdisplay.h"
#include "gimpdisplay-foreach.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-callbacks.h"
#include "gimpdisplayshell-layer-select.h"
@ -243,14 +245,6 @@ gimp_display_shell_canvas_realize (GtkWidget *canvas,
GIMP_CURSOR_MODIFIER_NONE);
}
static void
gimp_display_shell_get_device_state (GimpDisplayShell *shell,
GdkDevice *device,
GdkModifierType *state)
{
gdk_device_get_state (device, shell->canvas->window, NULL, state);
}
static void
gimp_display_shell_get_device_coords (GimpDisplayShell *shell,
GdkDevice *device,
@ -299,6 +293,14 @@ gimp_display_shell_get_coords (GimpDisplayShell *shell,
return FALSE;
}
static void
gimp_display_shell_get_device_state (GimpDisplayShell *shell,
GdkDevice *device,
GdkModifierType *state)
{
gdk_device_get_state (device, shell->canvas->window, NULL, state);
}
static gboolean
gimp_display_shell_get_state (GimpDisplayShell *shell,
GdkEvent *event,
@ -321,6 +323,7 @@ gimp_display_shell_canvas_events (GtkWidget *canvas,
GimpDisplayShell *shell)
{
GimpDisplay *gdisp;
GimpImage *gimage;
GimpCoords display_coords;
GimpCoords image_coords;
GdkModifierType state;
@ -328,21 +331,24 @@ gimp_display_shell_canvas_events (GtkWidget *canvas,
gboolean return_val = FALSE;
gboolean update_cursor = FALSE;
static GdkModifierType press_state;
static gboolean scrolling = FALSE;
static gint scroll_start_x = 0;
static gint scroll_start_y = 0;
static guint key_signal_id = 0;
if (! canvas->window)
{
g_warning ("gimp_display_shell_canvas_events(): called unrealized");
g_warning ("%s: called unrealized", G_STRLOC);
return FALSE;
}
gdisp = shell->gdisp;
gimage = gdisp->gimage;
/* Find out what device the event occurred upon */
if (! gdisp->gimage->gimp->busy && devices_check_change (event))
if (! gimage->gimp->busy && devices_check_change (event))
gimp_display_shell_check_device_cursor (shell);
gimp_display_shell_get_coords (shell, event, current_device, &display_coords);
@ -414,19 +420,19 @@ gimp_display_shell_canvas_events (GtkWidget *canvas,
if (state)
{
if (state & GDK_SHIFT_MASK)
tool_manager_modifier_key_active (gdisp->gimage->gimp,
tool_manager_modifier_key_active (gimage->gimp,
GDK_SHIFT_MASK, TRUE, state,
gdisp);
if (state & GDK_CONTROL_MASK)
tool_manager_modifier_key_active (gdisp->gimage->gimp,
tool_manager_modifier_key_active (gimage->gimp,
GDK_CONTROL_MASK, TRUE, state,
gdisp);
if (state & GDK_MOD1_MASK)
tool_manager_modifier_key_active (gdisp->gimage->gimp,
tool_manager_modifier_key_active (gimage->gimp,
GDK_MOD1_MASK, TRUE, state,
gdisp);
tool_manager_oper_update_active (gdisp->gimage->gimp,
tool_manager_oper_update_active (gimage->gimp,
&image_coords, state,
gdisp);
}
@ -450,19 +456,19 @@ gimp_display_shell_canvas_events (GtkWidget *canvas,
if (state)
{
if (state & GDK_MOD1_MASK)
tool_manager_modifier_key_active (gdisp->gimage->gimp,
tool_manager_modifier_key_active (gimage->gimp,
GDK_MOD1_MASK, FALSE, 0,
gdisp);
if (state & GDK_CONTROL_MASK)
tool_manager_modifier_key_active (gdisp->gimage->gimp,
tool_manager_modifier_key_active (gimage->gimp,
GDK_CONTROL_MASK, FALSE, 0,
gdisp);
if (state & GDK_SHIFT_MASK)
tool_manager_modifier_key_active (gdisp->gimage->gimp,
tool_manager_modifier_key_active (gimage->gimp,
GDK_SHIFT_MASK, FALSE, 0,
gdisp);
tool_manager_oper_update_active (gdisp->gimage->gimp,
tool_manager_oper_update_active (gimage->gimp,
&image_coords, 0,
gdisp);
}
@ -484,10 +490,10 @@ gimp_display_shell_canvas_events (GtkWidget *canvas,
bevent = (GdkEventButton *) event;
/* ignore new mouse events */
if (gdisp->gimage->gimp->busy)
if (gimage->gimp->busy)
return TRUE;
active_tool = tool_manager_get_active (gdisp->gimage->gimp);
active_tool = tool_manager_get_active (gimage->gimp);
switch (bevent->button)
{
@ -496,23 +502,12 @@ gimp_display_shell_canvas_events (GtkWidget *canvas,
gtk_grab_add (canvas);
/* This is a hack to prevent other stuff being run in the middle of
* a tool operation (like changing image types.... brrrr). We just
* block all the keypress event. A better solution is to implement
* some sort of locking for images.
* Note that this is dependent on specific GTK behavior, and isn't
* guaranteed to work in future versions of GTK.
* -Yosh
/* save the current modifier state because tools don't get
* key events while BUTTON1 is down
*/
if (key_signal_id == 0)
key_signal_id = g_signal_connect (G_OBJECT (canvas),
"key_press_event",
G_CALLBACK (gtk_true),
NULL);
press_state = state;
/* FIXME!!! This code is ugly */
if (active_tool && (! gimp_image_is_empty (gdisp->gimage) ||
if (active_tool && (! gimp_image_is_empty (gimage) ||
active_tool->handle_empty_image))
{
if (active_tool->auto_snap_to)
@ -534,20 +529,20 @@ gimp_display_shell_canvas_events (GtkWidget *canvas,
*/
if (! active_tool->drawable)
{
tool_manager_initialize_active (gdisp->gimage->gimp, gdisp);
tool_manager_initialize_active (gimage->gimp, gdisp);
}
else if ((active_tool->drawable !=
gimp_image_active_drawable (gdisp->gimage)) &&
gimp_image_active_drawable (gimage)) &&
! active_tool->preserve)
{
/* create a new one, deleting the current
*/
gimp_context_tool_changed (gimp_get_user_context (gdisp->gimage->gimp));
gimp_context_tool_changed (gimp_get_user_context (gimage->gimp));
tool_manager_initialize_active (gdisp->gimage->gimp, gdisp);
tool_manager_initialize_active (gimage->gimp, gdisp);
}
tool_manager_button_press_active (gdisp->gimage->gimp,
tool_manager_button_press_active (gimage->gimp,
&image_coords, time, state,
gdisp);
}
@ -568,7 +563,9 @@ gimp_display_shell_canvas_events (GtkWidget *canvas,
case 3:
state |= GDK_BUTTON3_MASK;
gimp_item_factory_popup_with_data (shell->ifactory, gdisp->gimage);
gimp_item_factory_popup_with_data (shell->ifactory,
gimage,
NULL);
return_val = TRUE;
break;
@ -585,9 +582,9 @@ gimp_display_shell_canvas_events (GtkWidget *canvas,
bevent = (GdkEventButton *) event;
active_tool = tool_manager_get_active (gdisp->gimage->gimp);
active_tool = tool_manager_get_active (gimage->gimp);
if (gdisp->gimage->gimp->busy)
if (gimage->gimp->busy)
return TRUE;
switch (bevent->button)
@ -595,16 +592,9 @@ gimp_display_shell_canvas_events (GtkWidget *canvas,
case 1:
state &= ~GDK_BUTTON1_MASK;
/* Lame hack. See above */
if (key_signal_id)
{
g_signal_handler_disconnect (G_OBJECT (canvas), key_signal_id);
key_signal_id = 0;
}
gtk_grab_remove (canvas);
if (active_tool && (! gimp_image_is_empty (gdisp->gimage) ||
if (active_tool && (! gimp_image_is_empty (gimage) ||
active_tool->handle_empty_image))
{
if (active_tool->state == ACTIVE)
@ -624,15 +614,48 @@ gimp_display_shell_canvas_events (GtkWidget *canvas,
update_cursor = TRUE;
}
tool_manager_button_release_active (gdisp->gimage->gimp,
tool_manager_button_release_active (gimage->gimp,
&image_coords, time, state,
gdisp);
tool_manager_oper_update_active (gdisp->gimage->gimp,
&image_coords, state,
gdisp);
}
}
/* restore the tool's modifier state because it didn't get
* key events while BUTTON1 was down
*/
if ((press_state & GDK_SHIFT_MASK) != (state & GDK_SHIFT_MASK))
{
tool_manager_modifier_key_active (gimage->gimp,
GDK_SHIFT_MASK,
(state & GDK_SHIFT_MASK) ?
TRUE : FALSE,
state,
gdisp);
}
if ((press_state & GDK_CONTROL_MASK) != (state & GDK_CONTROL_MASK))
{
tool_manager_modifier_key_active (gimage->gimp,
GDK_CONTROL_MASK,
(state & GDK_CONTROL_MASK) ?
TRUE : FALSE,
state,
gdisp);
}
if ((press_state & GDK_MOD1_MASK) != (state & GDK_MOD1_MASK))
{
tool_manager_modifier_key_active (gimage->gimp,
GDK_MOD1_MASK,
(state & GDK_MOD1_MASK) ?
TRUE : FALSE,
state,
gdisp);
}
tool_manager_oper_update_active (gimage->gimp,
&image_coords, state,
gdisp);
break;
case 2:
@ -693,7 +716,7 @@ gimp_display_shell_canvas_events (GtkWidget *canvas,
&display_coords,
&image_coords);
tool_manager_oper_update_active (gdisp->gimage->gimp,
tool_manager_oper_update_active (gimage->gimp,
&image_coords, state,
gdisp);
@ -708,7 +731,7 @@ gimp_display_shell_canvas_events (GtkWidget *canvas,
mevent = (GdkEventMotion *) event;
if (gdisp->gimage->gimp->busy)
if (gimage->gimp->busy)
return TRUE;
/* Ask for the pointer position, but ignore it except for cursor
@ -729,10 +752,10 @@ gimp_display_shell_canvas_events (GtkWidget *canvas,
gimp_display_shell_check_device_cursor (shell);
}
active_tool = tool_manager_get_active (gdisp->gimage->gimp);
active_tool = tool_manager_get_active (gimage->gimp);
if ((state & GDK_BUTTON1_MASK) &&
active_tool && (! gimp_image_is_empty (gdisp->gimage) ||
active_tool && (! gimp_image_is_empty (gimage) ||
active_tool->handle_empty_image))
{
if (active_tool->state == ACTIVE)
@ -795,7 +818,7 @@ gimp_display_shell_canvas_events (GtkWidget *canvas,
update_cursor = TRUE;
}
tool_manager_motion_active (gdisp->gimage->gimp,
tool_manager_motion_active (gimage->gimp,
&image_coords, time, state,
gdisp);
}
@ -811,7 +834,7 @@ gimp_display_shell_canvas_events (GtkWidget *canvas,
if (! (state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK)))
{
tool_manager_oper_update_active (gdisp->gimage->gimp,
tool_manager_oper_update_active (gimage->gimp,
&image_coords, state,
gdisp);
}
@ -825,7 +848,14 @@ gimp_display_shell_canvas_events (GtkWidget *canvas,
kevent = (GdkEventKey *) event;
/* ignore any key presses */
if (gdisp->gimage->gimp->busy)
if (gimage->gimp->busy)
return TRUE;
/* do not process any key event while BUTTON1 is down. We do this
* so tools keep the modifier state they were in when BUTTON1 was
* pressed and to prevent accelerators from being invoked.
*/
if (state & GDK_BUTTON1_MASK)
return TRUE;
switch (kevent->keyval)
@ -834,9 +864,9 @@ gimp_display_shell_canvas_events (GtkWidget *canvas,
case GDK_Left: case GDK_Right:
case GDK_Up: case GDK_Down:
if (! gimp_image_is_empty (gdisp->gimage))
if (! gimp_image_is_empty (gimage))
{
tool_manager_arrow_key_active (gdisp->gimage->gimp,
tool_manager_arrow_key_active (gimage->gimp,
kevent,
gdisp);
}
@ -845,17 +875,18 @@ gimp_display_shell_canvas_events (GtkWidget *canvas,
break;
case GDK_Tab:
if ((state & GDK_MOD1_MASK) &&
! gimp_image_is_empty (gdisp->gimage))
if (! gimp_image_is_empty (gimage))
{
gimp_display_shell_layer_select_init (gdisp->gimage,
1, kevent->time);
}
else if ((state & GDK_CONTROL_MASK) &&
! gimp_image_is_empty (gdisp->gimage))
{
gimp_display_shell_layer_select_init (gdisp->gimage,
-1, kevent->time);
if (state & GDK_MOD1_MASK)
{
gimp_display_shell_layer_select_init (gdisp->gimage,
1, kevent->time);
}
else if (state & GDK_CONTROL_MASK)
{
gimp_display_shell_layer_select_init (gdisp->gimage,
-1, kevent->time);
}
}
else if (! state)
{
@ -879,18 +910,16 @@ gimp_display_shell_canvas_events (GtkWidget *canvas,
* oper_update method so tools can choose if they are interested
* in the release itself or only in the resulting state
*/
if (! gimp_image_is_empty (gdisp->gimage))
if (! gimp_image_is_empty (gimage))
{
tool_manager_modifier_key_active (gdisp->gimage->gimp,
tool_manager_modifier_key_active (gimage->gimp,
key, TRUE, state,
gdisp);
return_val = TRUE;
}
break;
}
tool_manager_oper_update_active (gdisp->gimage->gimp,
tool_manager_oper_update_active (gimage->gimp,
&image_coords, state,
gdisp);
}
@ -903,7 +932,14 @@ gimp_display_shell_canvas_events (GtkWidget *canvas,
kevent = (GdkEventKey *) event;
/* ignore any key releases */
if (gdisp->gimage->gimp->busy)
if (gimage->gimp->busy)
return TRUE;
/* do not process any key event while BUTTON1 is down. We do this
* so tools keep the modifier state they were in when BUTTON1 was
* pressed and to prevent accelerators from being invoked.
*/
if (state & GDK_BUTTON1_MASK)
return TRUE;
switch (kevent->keyval)
@ -921,9 +957,9 @@ gimp_display_shell_canvas_events (GtkWidget *canvas,
* oper_update method so tools can choose if they are interested
* in the press itself or only in the resulting state
*/
if (! gimp_image_is_empty (gdisp->gimage))
if (! gimp_image_is_empty (gimage))
{
tool_manager_modifier_key_active (gdisp->gimage->gimp,
tool_manager_modifier_key_active (gimage->gimp,
key, FALSE, state,
gdisp);
}
@ -933,8 +969,6 @@ gimp_display_shell_canvas_events (GtkWidget *canvas,
tool_manager_oper_update_active (gdisp->gimage->gimp,
&image_coords, state,
gdisp);
return_val = TRUE;
}
break;
@ -943,7 +977,7 @@ gimp_display_shell_canvas_events (GtkWidget *canvas,
}
/* if we reached this point in gimp_busy mode, return now */
if (gdisp->gimage->gimp->busy)
if (gimage->gimp->busy)
return TRUE;
/* cursor update support */
@ -952,21 +986,21 @@ gimp_display_shell_canvas_events (GtkWidget *canvas,
{
GimpTool *active_tool;
active_tool = tool_manager_get_active (gdisp->gimage->gimp);
active_tool = tool_manager_get_active (gimage->gimp);
if (active_tool)
{
if ((! gimp_image_is_empty (gdisp->gimage) ||
if ((! gimp_image_is_empty (gimage) ||
active_tool->handle_empty_image) &&
! (state & (GDK_BUTTON1_MASK |
GDK_BUTTON2_MASK |
GDK_BUTTON3_MASK)))
{
tool_manager_cursor_update_active (gdisp->gimage->gimp,
tool_manager_cursor_update_active (gimage->gimp,
&image_coords, state,
gdisp);
}
else if (gimp_image_is_empty (gdisp->gimage))
else if (gimp_image_is_empty (gimage))
{
gimp_display_shell_install_tool_cursor (shell,
GIMP_BAD_CURSOR,
@ -1112,7 +1146,8 @@ gimp_display_shell_origin_button_press (GtkWidget *widget,
&x, &y, widget);
gtk_item_factory_popup_with_data (shell->ifactory,
gdisp->gimage, NULL,
gdisp->gimage,
NULL,
x, y,
1, event->time);
}
@ -1144,3 +1179,36 @@ gimp_display_shell_color_changed (GtkWidget *widget,
gimp_display_shell_expose_full (shell);
gimp_display_shell_flush (shell);
}
gboolean
gimp_display_shell_qmask_button_press (GtkWidget *widget,
GdkEventButton *event,
GimpDisplayShell *shell)
{
GimpDisplay *gdisp;
gdisp = shell->gdisp;
if ((event->type == GDK_BUTTON_PRESS) && (event->button == 3))
{
GtkItemFactory *factory;
factory = gtk_item_factory_from_path ("<QMask>");
gimp_item_factory_popup_with_data (factory, shell, NULL);
return TRUE;
}
return FALSE;
}
void
gimp_display_shell_qmask_toggled (GtkWidget *widget,
GimpDisplayShell *shell)
{
gimp_image_set_qmask_state (shell->gdisp->gimage,
GTK_TOGGLE_BUTTON (widget)->active);
gdisplays_flush ();
}

View File

@ -56,5 +56,11 @@ gboolean gimp_display_shell_origin_button_press (GtkWidget *widget,
void gimp_display_shell_color_changed (GtkWidget *widget,
GimpDisplayShell *shell);
gboolean gimp_display_shell_qmask_button_press (GtkWidget *widget,
GdkEventButton *event,
GimpDisplayShell *shell);
void gimp_display_shell_qmask_toggled (GtkWidget *widget,
GimpDisplayShell *shell);
#endif /* __GIMP_DISPLAY_SHELL_CALLBACKS_H__ */

View File

@ -58,7 +58,6 @@
#include "gimpdisplayshell-callbacks.h"
#include "gimpdisplayshell-dnd.h"
#include "gimpdisplayshell-handlers.h"
#include "gimpdisplayshell-qmask.h"
#include "gimpdisplayshell-render.h"
#include "gimpdisplayshell-selection.h"
#include "gximage.h"

View File

@ -28,8 +28,8 @@
#include "gimpdisplay.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-callbacks.h"
#include "gimpdisplayshell-handlers.h"
#include "gimpdisplayshell-qmask.h"
#include "gimpdisplayshell-scale.h"
#include "gimprc.h"

View File

@ -1,361 +0,0 @@
/* 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.
*/
#include "config.h"
#include <stdlib.h>
#include <gtk/gtk.h>
#include "libgimpcolor/gimpcolor.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "display-types.h"
#include "core/gimp.h"
#include "core/gimpchannel.h"
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "core/gimpimage-mask.h"
#include "widgets/gimpcolorpanel.h"
#include "gimpdisplay.h"
#include "gimpdisplay-foreach.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-qmask.h"
#include "floating_sel.h"
#include "undo.h"
#include "libgimp/gimpintl.h"
typedef struct _EditQmaskOptions EditQmaskOptions;
struct _EditQmaskOptions
{
GtkWidget *query_box;
GtkWidget *name_entry;
GtkWidget *color_panel;
GimpImage *gimage;
};
/* local function prototypes */
static void edit_qmask_channel_query (GimpDisplay *gdisp);
static void edit_qmask_query_ok_callback (GtkWidget *widget,
gpointer client_data);
static void edit_qmask_query_cancel_callback (GtkWidget *widget,
gpointer client_data);
static void qmask_query_scale_update (GtkAdjustment *adjustment,
gpointer data);
static void qmask_color_changed (GimpColorButton *button,
gpointer data);
static void qmask_removed_callback (GtkObject *qmask,
gpointer data);
/* public functions */
gboolean
gimp_display_shell_qmask_button_press (GtkWidget *widget,
GdkEventButton *event,
GimpDisplayShell *shell)
{
GimpDisplay *gdisp;
gdisp = shell->gdisp;
if ((event->type == GDK_2BUTTON_PRESS) && (event->button == 1))
{
edit_qmask_channel_query (gdisp);
return TRUE;
}
return FALSE;
}
void
gimp_display_shell_qmask_toggled (GtkWidget *widget,
GimpDisplayShell *shell)
{
GimpDisplay *gdisp;
GimpImage *gimage;
GimpChannel *mask;
GimpLayer *layer;
GimpRGB color;
gdisp = shell->gdisp;
gimage = gdisp->gimage;
if (GTK_TOGGLE_BUTTON (widget)->active)
{
if (gimp_image_get_qmask_state (gimage))
return; /* if already set, do nothing */
/* Set the defaults */
color = gimage->qmask_color;
mask = gimp_image_get_channel_by_name (gimage, "Qmask");
if (mask)
{
/* if the user was clever and created his own */
gimp_image_set_qmask_state (gimage, TRUE);
return;
}
undo_push_group_start (gimage, QMASK_UNDO);
if (gimp_image_mask_is_empty (gimage))
{
/* if no selection */
if ((layer = gimp_image_floating_sel (gimage)))
{
floating_sel_to_layer (layer);
}
mask = gimp_channel_new (gimage,
gimage->width,
gimage->height,
"Qmask",
&color);
gimp_image_add_channel (gimage, mask, 0);
gimp_drawable_fill_by_type (GIMP_DRAWABLE (mask),
gimp_get_user_context (gimage->gimp),
TRANSPARENT_FILL);
}
else /* if selection */
{
mask = gimp_channel_copy (gimp_image_get_mask (gimage), TRUE);
gimp_image_add_channel (gimage, mask, 0);
gimp_channel_set_color (mask, &color);
gimp_object_set_name (GIMP_OBJECT (mask), "Qmask");
gimp_image_mask_none (gimage); /* Clear the selection */
}
undo_push_qmask (gimage);
undo_push_group_end (gimage);
gimp_image_set_qmask_state (gimage, TRUE);
gdisplays_flush ();
/* connect to the removed signal, so the buttons get updated */
g_signal_connect (G_OBJECT (mask), "removed",
G_CALLBACK (qmask_removed_callback),
gdisp);
}
else
{
gimage = gdisp->gimage;
if (! gimp_image_get_qmask_state (gimage))
return; /* if already set do nothing */
mask = gimp_image_get_channel_by_name (gimage, "Qmask");
if (mask)
{
undo_push_group_start (gimage, QMASK_UNDO);
/* push the undo here since removing the mask will
* call the qmask_removed_callback() which will set
* the qmask_state to FALSE
*/
undo_push_qmask (gimage);
gimp_image_mask_load (gimage, mask);
gimp_image_remove_channel (gimage, mask);
undo_push_group_end (gimage);
}
gimp_image_set_qmask_state (gdisp->gimage, FALSE);
if (mask)
gdisplays_flush ();
}
}
/* private functions */
static void
edit_qmask_channel_query (GimpDisplay *gdisp)
{
EditQmaskOptions *options;
GtkWidget *hbox;
GtkWidget *vbox;
GtkWidget *table;
GtkWidget *opacity_scale;
GtkObject *opacity_scale_data;
/* the new options structure */
options = g_new0 (EditQmaskOptions, 1);
options->gimage = gdisp->gimage;
options->color_panel = gimp_color_panel_new (_("Edit Qmask Color"),
&options->gimage->qmask_color,
GIMP_COLOR_AREA_LARGE_CHECKS,
48, 64);
/* The dialog */
options->query_box =
gimp_dialog_new (_("Edit Qmask Attributes"), "edit_qmask_attributes",
gimp_standard_help_func,
"dialogs/edit_qmask_attributes.html",
GTK_WIN_POS_MOUSE,
FALSE, TRUE, FALSE,
GTK_STOCK_CANCEL, edit_qmask_query_cancel_callback,
options, NULL, NULL, FALSE, TRUE,
GTK_STOCK_OK, edit_qmask_query_ok_callback,
options, NULL, NULL, TRUE, FALSE,
NULL);
/* The main hbox */
hbox = gtk_hbox_new (FALSE, 4);
gtk_container_set_border_width (GTK_CONTAINER (hbox), 4);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (options->query_box)->vbox),
hbox);
gtk_widget_show (hbox);
/* The vbox */
vbox = gtk_vbox_new (FALSE, 2);
gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
gtk_widget_show (vbox);
/* The table */
table = gtk_table_new (1, 2, FALSE);
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
gtk_widget_show (table);
/* The opacity scale */
opacity_scale_data =
gtk_adjustment_new (options->gimage->qmask_color.a * 100.0,
0.0, 100.0, 1.0, 1.0, 0.0);
opacity_scale = gtk_hscale_new (GTK_ADJUSTMENT (opacity_scale_data));
gtk_widget_set_usize (opacity_scale, 100, -1);
gtk_scale_set_value_pos (GTK_SCALE (opacity_scale), GTK_POS_TOP);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
_("Mask Opacity:"), 1.0, 1.0,
opacity_scale, 1, FALSE);
g_signal_connect (G_OBJECT (opacity_scale_data), "value_changed",
G_CALLBACK (qmask_query_scale_update),
options->color_panel);
/* The color panel */
gtk_box_pack_start (GTK_BOX (hbox), options->color_panel,
TRUE, TRUE, 0);
gtk_widget_show (options->color_panel);
g_signal_connect (G_OBJECT (options->color_panel), "color_changed",
G_CALLBACK (qmask_color_changed),
opacity_scale_data);
gtk_widget_show (options->query_box);
}
static void
edit_qmask_query_ok_callback (GtkWidget *widget,
gpointer data)
{
EditQmaskOptions *options;
GimpChannel *channel;
GimpRGB color;
options = (EditQmaskOptions *) data;
channel = gimp_image_get_channel_by_name (options->gimage, "Qmask");
if (options->gimage && channel)
{
gimp_color_button_get_color (GIMP_COLOR_BUTTON (options->color_panel),
&color);
if (gimp_rgba_distance (&color, &channel->color) > 0.0001)
{
gimp_channel_set_color (channel, &color);
gdisplays_flush ();
}
}
/* update the qmask color no matter what */
options->gimage->qmask_color = color;
gtk_widget_destroy (options->query_box);
g_free (options);
}
static void
edit_qmask_query_cancel_callback (GtkWidget *widget,
gpointer data)
{
EditQmaskOptions *options;
options = (EditQmaskOptions *) data;
gtk_widget_destroy (options->query_box);
g_free (options);
}
static void
qmask_query_scale_update (GtkAdjustment *adjustment,
gpointer data)
{
GimpRGB color;
gimp_color_button_get_color (GIMP_COLOR_BUTTON (data), &color);
gimp_rgb_set_alpha (&color, adjustment->value / 100.0);
gimp_color_button_set_color (GIMP_COLOR_BUTTON (data), &color);
}
static void
qmask_color_changed (GimpColorButton *button,
gpointer data)
{
GtkAdjustment *adj = GTK_ADJUSTMENT (data);
GimpRGB color;
gimp_color_button_get_color (button, &color);
gtk_adjustment_set_value (adj, color.a * 100.0);
}
static void
qmask_removed_callback (GtkObject *qmask,
gpointer data)
{
GimpDisplay *gdisp = (GimpDisplay *) data;
if (!gdisp->gimage)
return;
gimp_image_set_qmask_state (gdisp->gimage, FALSE);
}

View File

@ -58,7 +58,6 @@
#include "gimpdisplayshell-callbacks.h"
#include "gimpdisplayshell-dnd.h"
#include "gimpdisplayshell-handlers.h"
#include "gimpdisplayshell-qmask.h"
#include "gimpdisplayshell-render.h"
#include "gimpdisplayshell-selection.h"
#include "gximage.h"

View File

@ -95,6 +95,8 @@ libappgui_a_SOURCES = @STRIP_BEGIN@ \
patterns-commands.h \
preferences-dialog.c \
preferences-dialog.h \
qmask-commands.c \
qmask-commands.h \
resize-dialog.c \
resize-dialog.h \
resolution-calibrate-dialog.c \

View File

@ -28,44 +28,31 @@
#include "widgets/gimpcontainereditor.h"
#include "widgets/gimpcontainerview.h"
#include "widgets/gimpitemfactory.h"
#include "widgets/gimpwidgets-utils.h"
#include "brushes-commands.h"
#include "libgimp/gimpintl.h"
static void brushes_menu_set_sensitivity (GimpContainerEditor *editor);
void
brushes_show_context_menu (GimpContainerEditor *editor)
brushes_menu_update (GtkItemFactory *factory,
gpointer data)
{
GtkItemFactory *item_factory;
GimpContainerEditor *editor;
GimpBrush *brush;
brushes_menu_set_sensitivity (editor);
item_factory = gtk_item_factory_from_path ("<Brushes>");
gimp_item_factory_popup_with_data (item_factory, editor);
}
static void
brushes_menu_set_sensitivity (GimpContainerEditor *editor)
{
GimpBrush *brush;
editor = GIMP_CONTAINER_EDITOR (data);
brush = gimp_context_get_brush (editor->view->context);
#define SET_SENSITIVE(menu,condition) \
gimp_menu_item_set_sensitive ("<Brushes>/" menu, (condition) != 0)
gimp_item_factory_set_sensitive (factory, menu, (condition) != 0)
SET_SENSITIVE ("Duplicate Brush",
SET_SENSITIVE ("/Duplicate Brush",
brush && GIMP_DATA_GET_CLASS (brush)->duplicate);
SET_SENSITIVE ("Edit Brush...",
SET_SENSITIVE ("/Edit Brush...",
brush && GIMP_IS_BRUSH_GENERATED (brush));
SET_SENSITIVE ("Delete Brush...",
SET_SENSITIVE ("/Delete Brush...",
brush);
#undef SET_SENSITIVE

View File

@ -20,7 +20,8 @@
#define __BRUSHES_COMMANDS_H__
void brushes_show_context_menu (GimpContainerEditor *editor);
void brushes_menu_update (GtkItemFactory *factory,
gpointer data);
#endif /* __BRUSHES_COMMANDS_H__ */

View File

@ -40,11 +40,6 @@
#include "libgimp/gimpintl.h"
/* local function prototypes */
static void buffers_menu_set_sensitivity (GimpContainerEditor *editor);
/* public functionss */
void
@ -104,34 +99,23 @@ buffers_delete_buffer_cmd_callback (GtkWidget *widget,
}
void
buffers_show_context_menu (GimpContainerEditor *editor)
buffers_menu_update (GtkItemFactory *factory,
gpointer data)
{
GtkItemFactory *item_factory;
GimpContainerEditor *editor;
GimpBuffer *buffer;
buffers_menu_set_sensitivity (editor);
item_factory = gtk_item_factory_from_path ("<Buffers>");
gimp_item_factory_popup_with_data (item_factory, editor);
}
/* private functions */
static void
buffers_menu_set_sensitivity (GimpContainerEditor *editor)
{
GimpBuffer *buffer;
editor = GIMP_CONTAINER_EDITOR (data);
buffer = gimp_context_get_buffer (editor->view->context);
#define SET_SENSITIVE(menu,condition) \
gimp_menu_item_set_sensitive ("<Buffers>/" menu, (condition) != 0)
gimp_item_factory_set_sensitive (factory, menu, (condition) != 0)
SET_SENSITIVE ("Paste Buffer", buffer);
SET_SENSITIVE ("Paste Buffer Into", buffer);
SET_SENSITIVE ("Paste Buffer as New", buffer);
SET_SENSITIVE ("Delete Buffer", buffer);
SET_SENSITIVE ("/Paste Buffer", buffer);
SET_SENSITIVE ("/Paste Buffer Into", buffer);
SET_SENSITIVE ("/Paste Buffer as New", buffer);
SET_SENSITIVE ("/Delete Buffer", buffer);
#undef SET_SENSITIVE
}

View File

@ -29,8 +29,8 @@ void buffers_paste_buffer_as_new_cmd_callback (GtkWidget *widget,
void buffers_delete_buffer_cmd_callback (GtkWidget *widget,
gpointer data);
void buffers_show_context_menu (GimpContainerEditor *editor);
void buffers_menu_update (GtkItemFactory *factory,
gpointer data);
#endif /* __BUFFERS_COMMANDS_H__ */

View File

@ -42,11 +42,6 @@
#include "libgimp/gimpintl.h"
/* local function prototypes */
static void channels_menu_set_sensitivity (GimpImage *gimage);
/* public functions */
void
@ -592,29 +587,17 @@ channels_edit_channel_query (GimpChannel *channel)
}
void
channels_show_context_menu (GimpImage *gimage)
{
GtkItemFactory *item_factory;
channels_menu_set_sensitivity (gimage);
item_factory = gtk_item_factory_from_path ("<Channels>");
gimp_item_factory_popup_with_data (item_factory, gimage);
}
static void
channels_menu_set_sensitivity (GimpImage *gimage)
channels_menu_update (GtkItemFactory *factory,
gpointer data)
{
GimpImage *gimage;
GimpChannel *channel;
gboolean fs;
GList *list;
GList *next = NULL;
GList *prev = NULL;
g_return_if_fail (gimage != NULL);
g_return_if_fail (GIMP_IS_IMAGE (gimage));
gimage = GIMP_IMAGE (data);
channel = gimp_image_get_active_channel (gimage);
@ -633,18 +616,18 @@ channels_menu_set_sensitivity (GimpImage *gimage)
}
#define SET_SENSITIVE(menu,condition) \
gimp_menu_item_set_sensitive ("<Channels>/" menu, (condition) != 0)
gimp_item_factory_set_sensitive (factory, menu, (condition) != 0)
SET_SENSITIVE ("New Channel...", !fs);
SET_SENSITIVE ("Raise Channel", !fs && channel && prev);
SET_SENSITIVE ("Lower Channel", !fs && channel && next);
SET_SENSITIVE ("Duplicate Channel", !fs && channel);
SET_SENSITIVE ("Channel to Selection", !fs && channel);
SET_SENSITIVE ("Add to Selection", !fs && channel);
SET_SENSITIVE ("Subtract from Selection", !fs && channel);
SET_SENSITIVE ("Intersect with Selection", !fs && channel);
SET_SENSITIVE ("Delete Channel", !fs && channel);
SET_SENSITIVE ("Edit Channel Attributes...", !fs && channel);
SET_SENSITIVE ("/New Channel...", !fs);
SET_SENSITIVE ("/Raise Channel", !fs && channel && prev);
SET_SENSITIVE ("/Lower Channel", !fs && channel && next);
SET_SENSITIVE ("/Duplicate Channel", !fs && channel);
SET_SENSITIVE ("/Channel to Selection", !fs && channel);
SET_SENSITIVE ("/Add to Selection", !fs && channel);
SET_SENSITIVE ("/Subtract from Selection", !fs && channel);
SET_SENSITIVE ("/Intersect with Selection", !fs && channel);
SET_SENSITIVE ("/Delete Channel", !fs && channel);
SET_SENSITIVE ("/Edit Channel Attributes...", !fs && channel);
#undef SET_OPS_SENSITIVE
}

View File

@ -43,7 +43,9 @@ void channels_edit_channel_attributes_cmd_callback (GtkWidget *widget,
void channels_new_channel_query (GimpImage *gimage);
void channels_edit_channel_query (GimpChannel *channel);
void channels_show_context_menu (GimpImage *gimage);
void channels_menu_update (GtkItemFactory *factory,
gpointer data);
#endif /* __CHANNELS_COMMANDS_H__ */

View File

@ -30,6 +30,7 @@
#include "widgets/gimpdockable.h"
#include "widgets/gimpdockbook.h"
#include "widgets/gimpimagedock.h"
#include "widgets/gimpitemfactory.h"
#include "dialogs.h"
#include "dialogs-commands.h"
@ -286,8 +287,8 @@ dialogs_toggle_auto_cmd_callback (GtkWidget *widget,
void
dialogs_create_lc_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
gpointer data,
guint action)
{
GtkWidget *dock;
GtkWidget *dockbook;
@ -358,3 +359,99 @@ dialogs_create_stuff_cmd_callback (GtkWidget *widget,
gtk_widget_show (dock);
}
void
dialogs_menu_update (GtkItemFactory *factory,
gpointer data)
{
GimpDockbook *dockbook;
dockbook = GIMP_DOCKBOOK (data);
if (dockbook)
{
GimpDockable *dockable;
gint page_num;
GimpDialogFactoryEntry *entry;
GimpContainerView *view;
gboolean is_grid = FALSE;
GimpPreviewSize preview_size = GIMP_PREVIEW_SIZE_NONE;
page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (dockbook));
dockable = (GimpDockable *)
gtk_notebook_get_nth_page (GTK_NOTEBOOK (dockbook), page_num);
entry = g_object_get_data (G_OBJECT (dockable),
"gimp-dialog-factory-entry");
if (entry)
{
if (strstr (entry->identifier, "grid"))
is_grid = TRUE;
}
view = gimp_container_view_get_by_dockable (dockable);
if (view)
{
preview_size = view->preview_size;
}
#define SET_ACTIVE(path,active) \
gimp_item_factory_set_active (factory, (path), (active))
if (preview_size >= GIMP_PREVIEW_SIZE_GIGANTIC)
{
SET_ACTIVE ("/Preview Size/Gigantic", TRUE);
}
else if (preview_size >= GIMP_PREVIEW_SIZE_ENORMOUS)
{
SET_ACTIVE ("/Preview Size/Enormous", TRUE);
}
else if (preview_size >= GIMP_PREVIEW_SIZE_HUGE)
{
SET_ACTIVE ("/Preview Size/Huge", TRUE);
}
else if (preview_size >= GIMP_PREVIEW_SIZE_EXTRA_LARGE)
{
SET_ACTIVE ("/Preview Size/Extra Large", TRUE);
}
else if (preview_size >= GIMP_PREVIEW_SIZE_LARGE)
{
SET_ACTIVE ("/Preview Size/Large", TRUE);
}
else if (preview_size >= GIMP_PREVIEW_SIZE_MEDIUM)
{
SET_ACTIVE ("/Preview Size/Medium", TRUE);
}
else if (preview_size >= GIMP_PREVIEW_SIZE_SMALL)
{
SET_ACTIVE ("/Preview Size/Small", TRUE);
}
else if (preview_size >= GIMP_PREVIEW_SIZE_EXTRA_SMALL)
{
SET_ACTIVE ("/Preview Size/Extra Small", TRUE);
}
else
{
SET_ACTIVE ("/Preview Size/Tiny", TRUE);
}
if (is_grid)
{
SET_ACTIVE ("/View as Grid", TRUE);
}
else
{
SET_ACTIVE ("/View as List", TRUE);
}
SET_ACTIVE ("/Show Image Menu",
GIMP_IMAGE_DOCK (dockbook->dock)->show_image_menu);
SET_ACTIVE ("/Auto Follow Active Image",
GIMP_IMAGE_DOCK (dockbook->dock)->auto_follow_active);
#undef SET_ACTIVE
}
}

View File

@ -55,5 +55,8 @@ void dialogs_create_stuff_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void dialogs_menu_update (GtkItemFactory *factory,
gpointer data);
#endif /* __DIALOGS_COMMANDS_H__ */

View File

@ -385,7 +385,7 @@ dialogs_brush_list_view_new (GimpDialogFactory *factory,
TRUE,
preview_size,
5, 3,
brushes_show_context_menu);
"<Brushes>");
return dialogs_dockable_new (view,
"Brush List", "Brushes",
@ -406,7 +406,7 @@ dialogs_pattern_list_view_new (GimpDialogFactory *factory,
context,
preview_size,
5, 3,
patterns_show_context_menu);
"<Patterns>");
return dialogs_dockable_new (view,
"Pattern List", "Patterns",
@ -427,7 +427,7 @@ dialogs_gradient_list_view_new (GimpDialogFactory *factory,
context,
preview_size,
5, 3,
gradients_show_context_menu);
"<Gradients>");
return dialogs_dockable_new (view,
"Gradient List", "Gradients",
@ -448,7 +448,7 @@ dialogs_palette_list_view_new (GimpDialogFactory *factory,
context,
preview_size,
5, 3,
palettes_show_context_menu);
"<Palettes>");
return dialogs_dockable_new (view,
"Palette List", "Palettes",
@ -487,7 +487,7 @@ dialogs_buffer_list_view_new (GimpDialogFactory *factory,
context,
preview_size,
5, 3,
buffers_show_context_menu);
"<Buffers>");
return dialogs_dockable_new (view,
"Buffer List", "Buffers",
@ -531,7 +531,7 @@ dialogs_brush_grid_view_new (GimpDialogFactory *factory,
TRUE,
preview_size,
5, 3,
brushes_show_context_menu);
"<Brushes>");
return dialogs_dockable_new (view,
"Brush Grid", "Brushes",
@ -552,7 +552,7 @@ dialogs_pattern_grid_view_new (GimpDialogFactory *factory,
context,
preview_size,
5, 3,
patterns_show_context_menu);
"<Patterns>");
return dialogs_dockable_new (view,
"Pattern Grid", "Patterns",
@ -573,7 +573,7 @@ dialogs_gradient_grid_view_new (GimpDialogFactory *factory,
context,
preview_size,
5, 3,
gradients_show_context_menu);
"<Gradients>");
return dialogs_dockable_new (view,
"Gradient Grid", "Gradients",
@ -594,7 +594,7 @@ dialogs_palette_grid_view_new (GimpDialogFactory *factory,
context,
preview_size,
5, 3,
palettes_show_context_menu);
"<Gradients>");
return dialogs_dockable_new (view,
"Palette Grid", "Palettes",
@ -633,7 +633,7 @@ dialogs_buffer_grid_view_new (GimpDialogFactory *factory,
context,
preview_size,
5, 3,
buffers_show_context_menu);
"<Buffers>");
return dialogs_dockable_new (view,
"Buffer Grid", "Buffers",
@ -669,7 +669,7 @@ dialogs_layer_list_view_new (GimpDialogFactory *factory,
(GimpCopyDrawableFunc) gimp_layer_copy,
(GimpNewDrawableFunc) layers_new_layer_query,
(GimpEditDrawableFunc) layers_edit_layer_query,
(GimpDrawableContextFunc) layers_show_context_menu);
"<Layers>");
dockable = dialogs_dockable_new (view,
"Layer List", "Layers",
@ -706,7 +706,7 @@ dialogs_channel_list_view_new (GimpDialogFactory *factory,
(GimpCopyDrawableFunc) gimp_channel_copy,
(GimpNewDrawableFunc) channels_new_channel_query,
(GimpEditDrawableFunc) channels_edit_channel_query,
(GimpDrawableContextFunc) channels_show_context_menu);
"<Channels>");
dockable = dialogs_dockable_new (view,
"Channel List", "Channels",
@ -786,7 +786,7 @@ dialogs_document_history_new (GimpDialogFactory *factory,
context,
preview_size,
5, 3,
documents_show_context_menu);
"<Documents>");
return dialogs_dockable_new (view,
"Document History", "History",

View File

@ -38,11 +38,6 @@
#include "libgimp/gimpintl.h"
/* local function prototypes */
static void documents_menu_set_sensitivity (GimpContainerEditor *editor);
/* public functionss */
void
@ -119,35 +114,24 @@ documents_refresh_documents_cmd_callback (GtkWidget *widget,
}
void
documents_show_context_menu (GimpContainerEditor *editor)
documents_menu_update (GtkItemFactory *factory,
gpointer data)
{
GtkItemFactory *item_factory;
GimpContainerEditor *editor;
GimpImagefile *imagefile;
documents_menu_set_sensitivity (editor);
item_factory = gtk_item_factory_from_path ("<Documents>");
gimp_item_factory_popup_with_data (item_factory, editor);
}
/* private functions */
static void
documents_menu_set_sensitivity (GimpContainerEditor *editor)
{
GimpImagefile *imagefile;
editor = GIMP_CONTAINER_EDITOR (data);
imagefile = gimp_context_get_imagefile (editor->view->context);
#define SET_SENSITIVE(menu,condition) \
gimp_menu_item_set_sensitive ("<Documents>/" menu, (condition) != 0)
gimp_item_factory_set_sensitive (factory, menu, (condition) != 0)
SET_SENSITIVE ("Open Image", imagefile);
SET_SENSITIVE ("Raise or Open Image", imagefile);
SET_SENSITIVE ("File Open Dialog...", TRUE);
SET_SENSITIVE ("Remove Entry", imagefile);
SET_SENSITIVE ("Refresh History", TRUE);
SET_SENSITIVE ("/Open Image", imagefile);
SET_SENSITIVE ("/Raise or Open Image", imagefile);
SET_SENSITIVE ("/File Open Dialog...", TRUE);
SET_SENSITIVE ("/Remove Entry", imagefile);
SET_SENSITIVE ("/Refresh History", TRUE);
#undef SET_SENSITIVE
}

View File

@ -31,8 +31,8 @@ void documents_delete_document_cmd_callback (GtkWidget *widget,
void documents_refresh_documents_cmd_callback (GtkWidget *widget,
gpointer data);
void documents_show_context_menu (GimpContainerEditor *editor);
void documents_menu_update (GtkItemFactory *factory,
gpointer data);
#endif /* __DOCUMENTS_COMMANDS_H__ */

View File

@ -40,7 +40,6 @@
/* local function prototypes */
static void gradient_editor_menu_set_sensitivity (GradientEditor *editor);
static void gradient_editor_left_color_changed (ColorNotebook *cnb,
const GimpRGB *color,
ColorNotebookState state,
@ -915,23 +914,10 @@ gradient_editor_blend_opacity_cmd_callback (GtkWidget *widget,
}
void
gradient_editor_show_context_menu (GradientEditor *editor)
{
GtkItemFactory *item_factory;
gradient_editor_menu_set_sensitivity (editor);
item_factory = gtk_item_factory_from_path ("<GradientEditor>");
gimp_item_factory_popup_with_data (item_factory, editor);
}
/* private functions */
static void
gradient_editor_menu_set_sensitivity (GradientEditor *editor)
gradient_editor_menu_update (GtkItemFactory *factory,
gpointer data)
{
GradientEditor *editor;
GimpGradientSegment *left_seg;
GimpGradientSegment *right_seg;
GimpRGB fg;
@ -941,6 +927,8 @@ gradient_editor_menu_set_sensitivity (GradientEditor *editor)
gboolean selection;
gboolean delete;
editor = (GradientEditor *) data;
if (editor->control_sel_l->prev)
left_seg = editor->control_sel_l->prev;
else
@ -981,161 +969,161 @@ gradient_editor_menu_set_sensitivity (GradientEditor *editor)
delete = (editor->control_sel_l->prev || editor->control_sel_r->next);
#define SET_ACTIVE(menu,active) \
gimp_menu_item_set_active ("<GradientEditor>/" menu, (active))
gimp_item_factory_set_active (factory, menu, (active))
#define SET_COLOR(menu,color,set_label) \
gimp_menu_item_set_color ("<GradientEditor>/" menu, (color), (set_label))
gimp_item_factory_set_color (factory, menu, (color), (set_label))
#define SET_LABEL(menu,label) \
gimp_menu_item_set_label ("<GradientEditor>/" menu, (label))
gimp_item_factory_set_label (factory, menu, (label))
#define SET_SENSITIVE(menu,condition) \
gimp_menu_item_set_sensitive ("<GradientEditor>/" menu, (condition) != 0)
gimp_item_factory_set_sensitive (factory, menu, (condition) != 0)
#define SET_VISIBLE(menu,condition) \
gimp_menu_item_set_visible ("<GradientEditor>/" menu, (condition) != 0)
gimp_item_factory_set_visible (factory, menu, (condition) != 0)
SET_COLOR ("Left Endpoint's Color...",
SET_COLOR ("/Left Endpoint's Color...",
&editor->control_sel_l->left_color, FALSE);
SET_COLOR ("Load Left Color From/Left Neighbor's Right Endpoint",
SET_COLOR ("/Load Left Color From/Left Neighbor's Right Endpoint",
&left_seg->right_color, FALSE);
SET_COLOR ("Load Left Color From/Right Endpoint",
SET_COLOR ("/Load Left Color From/Right Endpoint",
&editor->control_sel_r->right_color, FALSE);
SET_COLOR ("Load Left Color From/FG Color", &fg, FALSE);
SET_COLOR ("Load Left Color From/BG Color", &bg, FALSE);
SET_COLOR ("/Load Left Color From/FG Color", &fg, FALSE);
SET_COLOR ("/Load Left Color From/BG Color", &bg, FALSE);
SET_COLOR ("Load Left Color From/01", &editor->saved_colors[0], TRUE);
SET_COLOR ("Load Left Color From/02", &editor->saved_colors[1], TRUE);
SET_COLOR ("Load Left Color From/03", &editor->saved_colors[2], TRUE);
SET_COLOR ("Load Left Color From/04", &editor->saved_colors[3], TRUE);
SET_COLOR ("Load Left Color From/05", &editor->saved_colors[4], TRUE);
SET_COLOR ("Load Left Color From/06", &editor->saved_colors[5], TRUE);
SET_COLOR ("Load Left Color From/07", &editor->saved_colors[6], TRUE);
SET_COLOR ("Load Left Color From/08", &editor->saved_colors[7], TRUE);
SET_COLOR ("Load Left Color From/09", &editor->saved_colors[8], TRUE);
SET_COLOR ("Load Left Color From/10", &editor->saved_colors[9], TRUE);
SET_COLOR ("/Load Left Color From/01", &editor->saved_colors[0], TRUE);
SET_COLOR ("/Load Left Color From/02", &editor->saved_colors[1], TRUE);
SET_COLOR ("/Load Left Color From/03", &editor->saved_colors[2], TRUE);
SET_COLOR ("/Load Left Color From/04", &editor->saved_colors[3], TRUE);
SET_COLOR ("/Load Left Color From/05", &editor->saved_colors[4], TRUE);
SET_COLOR ("/Load Left Color From/06", &editor->saved_colors[5], TRUE);
SET_COLOR ("/Load Left Color From/07", &editor->saved_colors[6], TRUE);
SET_COLOR ("/Load Left Color From/08", &editor->saved_colors[7], TRUE);
SET_COLOR ("/Load Left Color From/09", &editor->saved_colors[8], TRUE);
SET_COLOR ("/Load Left Color From/10", &editor->saved_colors[9], TRUE);
SET_COLOR ("Save Left Color To/01", &editor->saved_colors[0], TRUE);
SET_COLOR ("Save Left Color To/02", &editor->saved_colors[1], TRUE);
SET_COLOR ("Save Left Color To/03", &editor->saved_colors[2], TRUE);
SET_COLOR ("Save Left Color To/04", &editor->saved_colors[3], TRUE);
SET_COLOR ("Save Left Color To/05", &editor->saved_colors[4], TRUE);
SET_COLOR ("Save Left Color To/06", &editor->saved_colors[5], TRUE);
SET_COLOR ("Save Left Color To/07", &editor->saved_colors[6], TRUE);
SET_COLOR ("Save Left Color To/08", &editor->saved_colors[7], TRUE);
SET_COLOR ("Save Left Color To/09", &editor->saved_colors[8], TRUE);
SET_COLOR ("Save Left Color To/10", &editor->saved_colors[9], TRUE);
SET_COLOR ("/Save Left Color To/01", &editor->saved_colors[0], TRUE);
SET_COLOR ("/Save Left Color To/02", &editor->saved_colors[1], TRUE);
SET_COLOR ("/Save Left Color To/03", &editor->saved_colors[2], TRUE);
SET_COLOR ("/Save Left Color To/04", &editor->saved_colors[3], TRUE);
SET_COLOR ("/Save Left Color To/05", &editor->saved_colors[4], TRUE);
SET_COLOR ("/Save Left Color To/06", &editor->saved_colors[5], TRUE);
SET_COLOR ("/Save Left Color To/07", &editor->saved_colors[6], TRUE);
SET_COLOR ("/Save Left Color To/08", &editor->saved_colors[7], TRUE);
SET_COLOR ("/Save Left Color To/09", &editor->saved_colors[8], TRUE);
SET_COLOR ("/Save Left Color To/10", &editor->saved_colors[9], TRUE);
SET_COLOR ("Right Endpoint's Color...",
SET_COLOR ("/Right Endpoint's Color...",
&editor->control_sel_r->right_color, FALSE);
SET_COLOR ("Load Right Color From/Right Neighbor's Left Endpoint",
SET_COLOR ("/Load Right Color From/Right Neighbor's Left Endpoint",
&right_seg->left_color, FALSE);
SET_COLOR ("Load Right Color From/Left Endpoint",
SET_COLOR ("/Load Right Color From/Left Endpoint",
&editor->control_sel_l->left_color, FALSE);
SET_COLOR ("Load Right Color From/FG Color", &fg, FALSE);
SET_COLOR ("Load Right Color From/BG Color", &bg, FALSE);
SET_COLOR ("/Load Right Color From/FG Color", &fg, FALSE);
SET_COLOR ("/Load Right Color From/BG Color", &bg, FALSE);
SET_COLOR ("Load Right Color From/01", &editor->saved_colors[0], TRUE);
SET_COLOR ("Load Right Color From/02", &editor->saved_colors[1], TRUE);
SET_COLOR ("Load Right Color From/03", &editor->saved_colors[2], TRUE);
SET_COLOR ("Load Right Color From/04", &editor->saved_colors[3], TRUE);
SET_COLOR ("Load Right Color From/05", &editor->saved_colors[4], TRUE);
SET_COLOR ("Load Right Color From/06", &editor->saved_colors[5], TRUE);
SET_COLOR ("Load Right Color From/07", &editor->saved_colors[6], TRUE);
SET_COLOR ("Load Right Color From/08", &editor->saved_colors[7], TRUE);
SET_COLOR ("Load Right Color From/09", &editor->saved_colors[8], TRUE);
SET_COLOR ("Load Right Color From/10", &editor->saved_colors[9], TRUE);
SET_COLOR ("/Load Right Color From/01", &editor->saved_colors[0], TRUE);
SET_COLOR ("/Load Right Color From/02", &editor->saved_colors[1], TRUE);
SET_COLOR ("/Load Right Color From/03", &editor->saved_colors[2], TRUE);
SET_COLOR ("/Load Right Color From/04", &editor->saved_colors[3], TRUE);
SET_COLOR ("/Load Right Color From/05", &editor->saved_colors[4], TRUE);
SET_COLOR ("/Load Right Color From/06", &editor->saved_colors[5], TRUE);
SET_COLOR ("/Load Right Color From/07", &editor->saved_colors[6], TRUE);
SET_COLOR ("/Load Right Color From/08", &editor->saved_colors[7], TRUE);
SET_COLOR ("/Load Right Color From/09", &editor->saved_colors[8], TRUE);
SET_COLOR ("/Load Right Color From/10", &editor->saved_colors[9], TRUE);
SET_COLOR ("Save Right Color To/01", &editor->saved_colors[0], TRUE);
SET_COLOR ("Save Right Color To/02", &editor->saved_colors[1], TRUE);
SET_COLOR ("Save Right Color To/03", &editor->saved_colors[2], TRUE);
SET_COLOR ("Save Right Color To/04", &editor->saved_colors[3], TRUE);
SET_COLOR ("Save Right Color To/05", &editor->saved_colors[4], TRUE);
SET_COLOR ("Save Right Color To/06", &editor->saved_colors[5], TRUE);
SET_COLOR ("Save Right Color To/07", &editor->saved_colors[6], TRUE);
SET_COLOR ("Save Right Color To/08", &editor->saved_colors[7], TRUE);
SET_COLOR ("Save Right Color To/09", &editor->saved_colors[8], TRUE);
SET_COLOR ("Save Right Color To/10", &editor->saved_colors[9], TRUE);
SET_COLOR ("/Save Right Color To/01", &editor->saved_colors[0], TRUE);
SET_COLOR ("/Save Right Color To/02", &editor->saved_colors[1], TRUE);
SET_COLOR ("/Save Right Color To/03", &editor->saved_colors[2], TRUE);
SET_COLOR ("/Save Right Color To/04", &editor->saved_colors[3], TRUE);
SET_COLOR ("/Save Right Color To/05", &editor->saved_colors[4], TRUE);
SET_COLOR ("/Save Right Color To/06", &editor->saved_colors[5], TRUE);
SET_COLOR ("/Save Right Color To/07", &editor->saved_colors[6], TRUE);
SET_COLOR ("/Save Right Color To/08", &editor->saved_colors[7], TRUE);
SET_COLOR ("/Save Right Color To/09", &editor->saved_colors[8], TRUE);
SET_COLOR ("/Save Right Color To/10", &editor->saved_colors[9], TRUE);
if (! selection)
{
SET_LABEL ("flip", _("Flip Segment"));
SET_LABEL ("replicate", _("Replicate Segment"));
SET_LABEL ("blendingfunction", _("Blending Function for Segment"));
SET_LABEL ("coloringtype", _("Coloring Type for Segment"));
SET_LABEL ("splitmidpoint", _("Split Segment at Midpoint"));
SET_LABEL ("splituniformly", _("Split Segment Uniformly"));
SET_LABEL ("delete", _("Delete Segment"));
SET_LABEL ("recenter", _("Re-center Segment's Midpoint"));
SET_LABEL ("redistribute", _("Re-distribute Handles in Segment"));
SET_LABEL ("/flip", _("Flip Segment"));
SET_LABEL ("/replicate", _("Replicate Segment"));
SET_LABEL ("/blendingfunction", _("Blending Function for Segment"));
SET_LABEL ("/coloringtype", _("Coloring Type for Segment"));
SET_LABEL ("/splitmidpoint", _("Split Segment at Midpoint"));
SET_LABEL ("/splituniformly", _("Split Segment Uniformly"));
SET_LABEL ("/delete", _("Delete Segment"));
SET_LABEL ("/recenter", _("Re-center Segment's Midpoint"));
SET_LABEL ("/redistribute", _("Re-distribute Handles in Segment"));
}
else
{
SET_LABEL ("flip", _("Flip Selection"));
SET_LABEL ("replicate", _("Replicate Selection"));
SET_LABEL ("blendingfunction", _("Blending Function for Selection"));
SET_LABEL ("coloringtype", _("Coloring Type for Selection"));
SET_LABEL ("splitmidpoint", _("Split Segments at Midpoints"));
SET_LABEL ("splituniformly", _("Split Segments Uniformly"));
SET_LABEL ("delete", _("Delete Selection"));
SET_LABEL ("recenter", _("Re-center Midpoints in Selection"));
SET_LABEL ("redistribute", _("Re-distribute Handles in Selection"));
SET_LABEL ("/flip", _("Flip Selection"));
SET_LABEL ("/replicate", _("Replicate Selection"));
SET_LABEL ("/blendingfunction", _("Blending Function for Selection"));
SET_LABEL ("/coloringtype", _("Coloring Type for Selection"));
SET_LABEL ("/splitmidpoint", _("Split Segments at Midpoints"));
SET_LABEL ("/splituniformly", _("Split Segments Uniformly"));
SET_LABEL ("/delete", _("Delete Selection"));
SET_LABEL ("/recenter", _("Re-center Midpoints in Selection"));
SET_LABEL ("/redistribute", _("Re-distribute Handles in Selection"));
}
SET_SENSITIVE ("blendingfunction/(Varies)", FALSE);
SET_SENSITIVE ("coloringtype/(Varies)", FALSE);
SET_SENSITIVE ("/blendingfunction/(Varies)", FALSE);
SET_SENSITIVE ("/coloringtype/(Varies)", FALSE);
if (blending_equal)
{
SET_VISIBLE ("blendingfunction/(Varies)", FALSE);
SET_VISIBLE ("/blendingfunction/(Varies)", FALSE);
switch (editor->control_sel_l->type)
{
case GRAD_LINEAR:
SET_ACTIVE ("blendingfunction/Linear", TRUE);
SET_ACTIVE ("/blendingfunction/Linear", TRUE);
break;
case GRAD_CURVED:
SET_ACTIVE ("blendingfunction/Curved", TRUE);
SET_ACTIVE ("/blendingfunction/Curved", TRUE);
break;
case GRAD_SINE:
SET_ACTIVE ("blendingfunction/Sinusodial", TRUE);
SET_ACTIVE ("/blendingfunction/Sinusodial", TRUE);
break;
case GRAD_SPHERE_INCREASING:
SET_ACTIVE ("blendingfunction/Spherical (increasing)", TRUE);
SET_ACTIVE ("/blendingfunction/Spherical (increasing)", TRUE);
break;
case GRAD_SPHERE_DECREASING:
SET_ACTIVE ("blendingfunction/Spherical (decreasing)", TRUE);
SET_ACTIVE ("/blendingfunction/Spherical (decreasing)", TRUE);
break;
}
}
else
{
SET_VISIBLE ("blendingfunction/(Varies)", TRUE);
SET_ACTIVE ("blendingfunction/(Varies)", TRUE);
SET_VISIBLE ("/blendingfunction/(Varies)", TRUE);
SET_ACTIVE ("/blendingfunction/(Varies)", TRUE);
}
if (coloring_equal)
{
SET_VISIBLE ("coloringtype/(Varies)", FALSE);
SET_VISIBLE ("/coloringtype/(Varies)", FALSE);
switch (editor->control_sel_l->color)
{
case GRAD_RGB:
SET_ACTIVE ("coloringtype/RGB", TRUE);
SET_ACTIVE ("/coloringtype/RGB", TRUE);
break;
case GRAD_HSV_CCW:
SET_ACTIVE ("coloringtype/HSV (counter-clockwise hue)", TRUE);
SET_ACTIVE ("/coloringtype/HSV (counter-clockwise hue)", TRUE);
break;
case GRAD_HSV_CW:
SET_ACTIVE ("coloringtype/HSV (clockwise hue)", TRUE);
SET_ACTIVE ("/coloringtype/HSV (clockwise hue)", TRUE);
break;
}
}
else
{
SET_VISIBLE ("coloringtype/(Varies)", TRUE);
SET_ACTIVE ("coloringtype/(Varies)", TRUE);
SET_VISIBLE ("/coloringtype/(Varies)", TRUE);
SET_ACTIVE ("/coloringtype/(Varies)", TRUE);
}
SET_SENSITIVE ("Blend Endpoints' Colors", selection);
SET_SENSITIVE ("Blend Endpoints' Opacity", selection);
SET_SENSITIVE ("delete", delete);
SET_SENSITIVE ("/Blend Endpoints' Colors", selection);
SET_SENSITIVE ("/Blend Endpoints' Opacity", selection);
SET_SENSITIVE ("/delete", delete);
#undef SET_ACTIVE
#undef SET_COLOR

View File

@ -76,7 +76,8 @@ void gradient_editor_blend_opacity_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_show_context_menu (GradientEditor *editor);
void gradient_editor_menu_update (GtkItemFactory *factory,
gpointer data);
#endif /* __GRADIENT_EDITOR_COMMANDS_H__ */

View File

@ -71,9 +71,9 @@
#include "core/gimpgradient.h"
#include "widgets/gimpdnd.h"
#include "widgets/gimpitemfactory.h"
#include "gradient-editor.h"
#include "gradient-editor-commands.h"
#include "gimprc.h"
@ -810,7 +810,13 @@ preview_events (GtkWidget *widget,
break;
case 3:
gradient_editor_show_context_menu (editor);
{
GtkItemFactory *factory;
factory = gtk_item_factory_from_path ("<GradientEditor>");
gimp_item_factory_popup_with_data (factory, editor, NULL);
}
break;
default:
@ -1291,7 +1297,13 @@ control_button_press (GradientEditor *editor,
break;
case 3:
gradient_editor_show_context_menu (editor);
{
GtkItemFactory *factory;
factory = gtk_item_factory_from_path ("<GradientEditor>");
gimp_item_factory_popup_with_data (factory, editor, NULL);
}
return;
/* wheelmouse support */

View File

@ -41,7 +41,6 @@
/* local function prototypes */
static void gradients_menu_set_sensitivity (GimpContainerEditor *editor);
static void gradients_save_as_pov_query (GimpContainerEditor *editor);
static void gradients_save_as_pov_ok_callback (GtkWidget *widget,
GimpGradient *gradient);
@ -64,42 +63,34 @@ gradients_save_as_pov_ray_cmd_callback (GtkWidget *widget,
}
void
gradients_show_context_menu (GimpContainerEditor *editor)
gradients_menu_update (GtkItemFactory *factory,
gpointer data)
{
GtkItemFactory *item_factory;
GimpContainerEditor *editor;
GimpGradient *gradient;
gradients_menu_set_sensitivity (editor);
item_factory = gtk_item_factory_from_path ("<Gradients>");
gimp_item_factory_popup_with_data (item_factory, editor);
}
/* private functions */
static void
gradients_menu_set_sensitivity (GimpContainerEditor *editor)
{
GimpGradient *gradient;
editor = GIMP_CONTAINER_EDITOR (data);
gradient = gimp_context_get_gradient (editor->view->context);
#define SET_SENSITIVE(menu,condition) \
gimp_menu_item_set_sensitive ("<Gradients>/" menu, (condition) != 0)
gimp_item_factory_set_sensitive (factory, menu, (condition) != 0)
SET_SENSITIVE ("Duplicate Gradient",
SET_SENSITIVE ("/Duplicate Gradient",
gradient && GIMP_DATA_GET_CLASS (gradient)->duplicate);
SET_SENSITIVE ("Edit Gradient...",
SET_SENSITIVE ("/Edit Gradient...",
gradient && GIMP_DATA_FACTORY_VIEW (editor)->data_edit_func);
SET_SENSITIVE ("Delete Gradient...",
SET_SENSITIVE ("/Delete Gradient...",
gradient);
SET_SENSITIVE ("Save as POV-Ray...",
SET_SENSITIVE ("/Save as POV-Ray...",
gradient);
#undef SET_SENSITIVE
}
/* private functions */
static void
gradients_save_as_pov_query (GimpContainerEditor *editor)
{

View File

@ -23,8 +23,8 @@
void gradients_save_as_pov_ray_cmd_callback (GtkWidget *widget,
gpointer data);
void gradients_show_context_menu (GimpContainerEditor *editor);
void gradients_menu_update (GtkItemFactory *factory,
gpointer data);
#endif /* __GRADIENTS_COMMANDS_H__ */

View File

@ -52,14 +52,17 @@
#include "libgimp/gimpintl.h"
/* local function prototypes */
static void layers_add_mask_query (GimpLayer *layer);
static void layers_scale_layer_query (GimpImage *gimage,
GimpLayer *layer);
static void layers_resize_layer_query (GimpImage *gimage,
GimpLayer *layer);
static void layers_menu_set_sensitivity (GimpImage *gimage);
/* public functions */
void
layers_previous_cmd_callback (GtkWidget *widget,
gpointer data)
@ -1219,20 +1222,10 @@ layers_layer_merge_query (GimpImage *gimage,
}
void
layers_show_context_menu (GimpImage *gimage)
{
GtkItemFactory *item_factory;
layers_menu_set_sensitivity (gimage);
item_factory = gtk_item_factory_from_path ("<Layers>");
gimp_item_factory_popup_with_data (item_factory, gimage);
}
static void
layers_menu_set_sensitivity (GimpImage *gimage)
layers_menu_update (GtkItemFactory *factory,
gpointer data)
{
GimpImage *gimage;
GimpLayer *layer;
gboolean fs = FALSE; /* floating sel */
gboolean ac = FALSE; /* active channel */
@ -1245,8 +1238,7 @@ layers_menu_set_sensitivity (GimpImage *gimage)
GList *next = NULL;
GList *prev = NULL;
g_return_if_fail (gimage != NULL);
g_return_if_fail (GIMP_IS_IMAGE (gimage));
gimage = GIMP_IMAGE (data);
layer = gimp_image_get_active_layer (gimage);
@ -1279,43 +1271,43 @@ layers_menu_set_sensitivity (GimpImage *gimage)
next_alpha = FALSE;
#define SET_SENSITIVE(menu,condition) \
gimp_menu_item_set_sensitive ("<Layers>/" menu, (condition) != 0)
gimp_item_factory_set_sensitive (factory, menu, (condition) != 0)
SET_SENSITIVE ("New Layer...", gimage);
SET_SENSITIVE ("/New Layer...", gimage);
SET_SENSITIVE ("Stack/Raise Layer",
SET_SENSITIVE ("/Stack/Raise Layer",
!fs && !ac && gimage && lp && alpha && prev);
SET_SENSITIVE ("Stack/Lower Layer",
SET_SENSITIVE ("/Stack/Lower Layer",
!fs && !ac && gimage && lp && next && next_alpha);
SET_SENSITIVE ("Stack/Layer to Top",
SET_SENSITIVE ("/Stack/Layer to Top",
!fs && !ac && gimage && lp && alpha && prev);
SET_SENSITIVE ("Stack/Layer to Bottom",
SET_SENSITIVE ("/Stack/Layer to Bottom",
!fs && !ac && gimage && lp && next && next_alpha);
SET_SENSITIVE ("Duplicate Layer", !fs && !ac && gimage && lp);
SET_SENSITIVE ("Anchor Layer", !fs && !ac && gimage && lp);
SET_SENSITIVE ("Delete Layer", !ac && gimage && lp);
SET_SENSITIVE ("/Duplicate Layer", !fs && !ac && gimage && lp);
SET_SENSITIVE ("/Anchor Layer", !fs && !ac && gimage && lp);
SET_SENSITIVE ("/Delete Layer", !ac && gimage && lp);
SET_SENSITIVE ("Layer Boundary Size...", !ac && gimage && lp);
SET_SENSITIVE ("Layer to Imagesize", !ac && gimage && lp);
SET_SENSITIVE ("Scale Layer...", !ac && gimage && lp);
SET_SENSITIVE ("/Layer Boundary Size...", !ac && gimage && lp);
SET_SENSITIVE ("/Layer to Imagesize", !ac && gimage && lp);
SET_SENSITIVE ("/Scale Layer...", !ac && gimage && lp);
SET_SENSITIVE ("Merge Visible Layers...", !fs && !ac && gimage && lp);
SET_SENSITIVE ("Merge Down", !fs && !ac && gimage && lp && next);
SET_SENSITIVE ("Flatten Image", !fs && !ac && gimage && lp);
SET_SENSITIVE ("/Merge Visible Layers...", !fs && !ac && gimage && lp);
SET_SENSITIVE ("/Merge Down", !fs && !ac && gimage && lp && next);
SET_SENSITIVE ("/Flatten Image", !fs && !ac && gimage && lp);
SET_SENSITIVE ("Add Layer Mask...",
SET_SENSITIVE ("/Add Layer Mask...",
!fs && !ac && gimage && !lm && lp && alpha && !indexed);
SET_SENSITIVE ("Apply Layer Mask", !fs && !ac && gimage && lm && lp);
SET_SENSITIVE ("Delete Layer Mask", !fs && !ac && gimage && lm && lp);
SET_SENSITIVE ("Mask to Selection", !fs && !ac && gimage && lm && lp);
SET_SENSITIVE ("/Apply Layer Mask", !fs && !ac && gimage && lm && lp);
SET_SENSITIVE ("/Delete Layer Mask", !fs && !ac && gimage && lm && lp);
SET_SENSITIVE ("/Mask to Selection", !fs && !ac && gimage && lm && lp);
SET_SENSITIVE ("Add Alpha Channel", !fs && !alpha);
SET_SENSITIVE ("Alpha to Selection", !fs && !ac && gimage && lp && alpha);
SET_SENSITIVE ("/Add Alpha Channel", !fs && !alpha);
SET_SENSITIVE ("/Alpha to Selection", !fs && !ac && gimage && lp && alpha);
SET_SENSITIVE ("Edit Layer Attributes...", !fs && !ac && gimage && lp);
SET_SENSITIVE ("/Edit Layer Attributes...", !fs && !ac && gimage && lp);
#undef SET_SENSITIVE
}

View File

@ -67,9 +67,11 @@ void layers_add_alpha_channel_cmd_callback (GtkWidget *widet,
void layers_edit_attributes_cmd_callback (GtkWidget *widet,
gpointer data);
void layers_menu_update (GtkItemFactory *factory,
gpointer data);
void layers_new_layer_query (GimpImage *gimage);
void layers_edit_layer_query (GimpLayer *layer);
void layers_show_context_menu (GimpImage *gimage);
void layers_layer_merge_query (GimpImage *gimage,
gboolean merge_visible);

View File

@ -47,6 +47,7 @@
#include "tools/gimpthresholdtool.h"
#include "tools/tool_manager.h"
#include "brushes-commands.h"
#include "buffers-commands.h"
#include "channels-commands.h"
#include "commands.h"
@ -62,6 +63,8 @@
#include "menus.h"
#include "palettes-commands.h"
#include "paths-dialog.h"
#include "patterns-commands.h"
#include "qmask-commands.h"
#include "select-commands.h"
#include "test-commands.h"
#include "tools-commands.h"
@ -696,11 +699,6 @@ static GimpItemFactoryEntry image_entries[] =
SEPARATOR ("/Layers/---"),
{ { N_("/Layers/Layer to Imagesize"), NULL,
layers_resize_to_image_cmd_callback, 0 },
NULL,
"layers/layer_to_image_size.html", NULL },
/* <Image>/Layers/Stack */
{ { N_("/Layers/Stack/Previous Layer"), "Prior",
@ -745,10 +743,24 @@ static GimpItemFactoryEntry image_entries[] =
"<StockItem>", GIMP_STOCK_ANCHOR },
NULL,
"layers/anchor_layer.html", NULL },
SEPARATOR ("/Layers/---"),
{ { N_("/Layers/Layer to Imagesize"), NULL,
layers_resize_to_image_cmd_callback, 0 },
NULL,
"layers/layer_to_image_size.html", NULL },
SEPARATOR ("/Layers/---"),
{ { N_("/Layers/Merge Visible Layers..."), "<control>M",
layers_merge_layers_cmd_callback, 0 },
NULL,
"layers/dialogs/merge_visible_layers.html", NULL },
{ { N_("/Layers/Merge Down"), "<control><shift>M",
layers_merge_down_cmd_callback, 0 },
NULL,
"layers/merge_visible_layers.html", NULL },
{ { N_("/Layers/Flatten Image"), NULL,
layers_flatten_image_cmd_callback, 0 },
NULL,
@ -805,7 +817,7 @@ static GimpItemFactoryEntry image_entries[] =
dialogs_create_lc_cmd_callback, 0 },
NULL,
"dialogs/layers_and_channels.html", NULL },
{ { N_("/File/Dialogs/Brushes, Patterns & Stuff..."), NULL,
{ { N_("/Dialogs/Brushes, Patterns & Stuff..."), NULL,
dialogs_create_stuff_cmd_callback, 0 },
NULL,
NULL, NULL },
@ -973,12 +985,12 @@ static GimpItemFactoryEntry layers_entries[] =
"<StockItem>", GIMP_STOCK_LOWER },
NULL,
"stack/stack.html#lower_layer", NULL },
{ { N_("/Stack/Layer to Top"), "<shift><control>F",
{ { N_("/Stack/Layer to Top"), "<control><shift>F",
layers_raise_to_top_cmd_callback, 0,
"<StockItem>", GIMP_STOCK_RAISE },
NULL,
"stack/stack.html#later_to_top", NULL },
{ { N_("/Stack/Layer to Bottom"), "<shift><control>B",
{ { N_("/Stack/Layer to Bottom"), "<control><shift>B",
layers_lower_to_bottom_cmd_callback, 0,
"<StockItem>", GIMP_STOCK_LOWER },
NULL,
@ -1729,6 +1741,31 @@ static GimpItemFactoryEntry documents_entries[] =
};
/***** <QMask> *****/
static GimpItemFactoryEntry qmask_entries[] =
{
{ { N_("/QMask Active"), NULL,
qmask_toggle_cmd_callback, 0, "<ToggleItem>" },
NULL, NULL, NULL },
SEPARATOR ("/---"),
{ { N_("/Mask Selected Areas"), NULL,
qmask_invert_cmd_callback, FALSE, "<RadioItem>" },
NULL, NULL, NULL },
{ { N_("/Mask Unselected Areas"), NULL,
qmask_invert_cmd_callback, TRUE, "/Mask Selected Areas" },
NULL, NULL, NULL },
SEPARATOR ("/---"),
{ { N_("/Configure Color and Opacity..."), NULL,
qmask_configure_cmd_callback, 0 },
NULL, NULL, NULL }
};
static gboolean menus_initialized = FALSE;
@ -1747,6 +1784,7 @@ static GtkItemFactory *gradients_factory = NULL;
static GtkItemFactory *palettes_factory = NULL;
static GtkItemFactory *buffers_factory = NULL;
static GtkItemFactory *documents_factory = NULL;
static GtkItemFactory *qmask_factory = NULL;
/* public functions */
@ -1771,6 +1809,7 @@ menus_init (Gimp *gimp)
toolbox_factory = gimp_item_factory_new (GTK_TYPE_MENU_BAR,
"<Toolbox>", "toolbox",
NULL,
G_N_ELEMENTS (toolbox_entries),
toolbox_entries,
gimp,
@ -1825,6 +1864,7 @@ menus_init (Gimp *gimp)
image_factory = gimp_item_factory_new (GTK_TYPE_MENU,
"<Image>", "image",
NULL,
G_N_ELEMENTS (image_entries),
image_entries,
gimp,
@ -1832,6 +1872,7 @@ menus_init (Gimp *gimp)
load_factory = gimp_item_factory_new (GTK_TYPE_MENU,
"<Load>", "open",
NULL,
G_N_ELEMENTS (load_entries),
load_entries,
gimp,
@ -1839,6 +1880,7 @@ menus_init (Gimp *gimp)
save_factory = gimp_item_factory_new (GTK_TYPE_MENU,
"<Save>", "save",
NULL,
G_N_ELEMENTS (save_entries),
save_entries,
gimp,
@ -1846,6 +1888,7 @@ menus_init (Gimp *gimp)
layers_factory = gimp_item_factory_new (GTK_TYPE_MENU,
"<Layers>", "layers",
layers_menu_update,
G_N_ELEMENTS (layers_entries),
layers_entries,
gimp,
@ -1853,6 +1896,7 @@ menus_init (Gimp *gimp)
channels_factory = gimp_item_factory_new (GTK_TYPE_MENU,
"<Channels>", "channels",
channels_menu_update,
G_N_ELEMENTS (channels_entries),
channels_entries,
gimp,
@ -1860,6 +1904,7 @@ menus_init (Gimp *gimp)
paths_factory = gimp_item_factory_new (GTK_TYPE_MENU,
"<Paths>", "paths",
NULL,
G_N_ELEMENTS (paths_entries),
paths_entries,
gimp,
@ -1867,6 +1912,7 @@ menus_init (Gimp *gimp)
dialogs_factory = gimp_item_factory_new (GTK_TYPE_MENU,
"<Dialogs>", "dialogs",
dialogs_menu_update,
G_N_ELEMENTS (dialogs_entries),
dialogs_entries,
gimp,
@ -1874,6 +1920,7 @@ menus_init (Gimp *gimp)
brushes_factory = gimp_item_factory_new (GTK_TYPE_MENU,
"<Brushes>", "brushes",
brushes_menu_update,
G_N_ELEMENTS (brushes_entries),
brushes_entries,
gimp,
@ -1881,6 +1928,7 @@ menus_init (Gimp *gimp)
patterns_factory = gimp_item_factory_new (GTK_TYPE_MENU,
"<Patterns>", "patterns",
patterns_menu_update,
G_N_ELEMENTS (patterns_entries),
patterns_entries,
gimp,
@ -1888,6 +1936,7 @@ menus_init (Gimp *gimp)
gradient_editor_factory = gimp_item_factory_new (GTK_TYPE_MENU,
"<GradientEditor>", "gradient_editor",
gradient_editor_menu_update,
G_N_ELEMENTS (gradient_editor_entries),
gradient_editor_entries,
gimp,
@ -1895,6 +1944,7 @@ menus_init (Gimp *gimp)
gradients_factory = gimp_item_factory_new (GTK_TYPE_MENU,
"<Gradients>", "gradients",
gradients_menu_update,
G_N_ELEMENTS (gradients_entries),
gradients_entries,
gimp,
@ -1902,6 +1952,7 @@ menus_init (Gimp *gimp)
palettes_factory = gimp_item_factory_new (GTK_TYPE_MENU,
"<Palettes>", "palettes",
palettes_menu_update,
G_N_ELEMENTS (palettes_entries),
palettes_entries,
gimp,
@ -1909,6 +1960,7 @@ menus_init (Gimp *gimp)
buffers_factory = gimp_item_factory_new (GTK_TYPE_MENU,
"<Buffers>", "buffers",
buffers_menu_update,
G_N_ELEMENTS (buffers_entries),
buffers_entries,
gimp,
@ -1916,11 +1968,20 @@ menus_init (Gimp *gimp)
documents_factory = gimp_item_factory_new (GTK_TYPE_MENU,
"<Documents>", "documents",
documents_menu_update,
G_N_ELEMENTS (documents_entries),
documents_entries,
gimp,
FALSE);
qmask_factory = gimp_item_factory_new (GTK_TYPE_MENU,
"<QMask>", "qmask",
qmask_menu_update,
G_N_ELEMENTS (qmask_entries),
qmask_entries,
gimp,
FALSE);
for (list = GIMP_LIST (gimp->tool_info_list)->list;
list;
list = g_list_next (list))
@ -2104,6 +2165,12 @@ menus_exit (Gimp *gimp)
g_object_unref (G_OBJECT (documents_factory));
documents_factory = NULL;
}
if (qmask_factory)
{
g_object_unref (G_OBJECT (qmask_factory));
qmask_factory = NULL;
}
}
void

View File

@ -43,7 +43,6 @@
/* local function prototypes */
static void palettes_menu_set_sensitivity (GimpContainerEditor *editor);
static void palettes_merge_palettes_query (GimpContainerEditor *editor);
static void palettes_merge_palettes_callback (GtkWidget *widget,
gchar *palette_name,
@ -81,42 +80,34 @@ palettes_merge_palettes_cmd_callback (GtkWidget *widget,
}
void
palettes_show_context_menu (GimpContainerEditor *editor)
palettes_menu_update (GtkItemFactory *factory,
gpointer data)
{
GtkItemFactory *item_factory;
GimpContainerEditor *editor;
GimpPalette *palette;
palettes_menu_set_sensitivity (editor);
item_factory = gtk_item_factory_from_path ("<Palettes>");
gimp_item_factory_popup_with_data (item_factory, editor);
}
/* private functions */
static void
palettes_menu_set_sensitivity (GimpContainerEditor *editor)
{
GimpPalette *palette;
editor = GIMP_CONTAINER_EDITOR (data);
palette = gimp_context_get_palette (editor->view->context);
#define SET_SENSITIVE(menu,condition) \
gimp_menu_item_set_sensitive ("<Palettes>/" menu, (condition) != 0)
gimp_item_factory_set_sensitive (factory, menu, (condition) != 0)
SET_SENSITIVE ("Duplicate Palette",
SET_SENSITIVE ("/Duplicate Palette",
palette && GIMP_DATA_GET_CLASS (palette)->duplicate);
SET_SENSITIVE ("Edit Palette...",
SET_SENSITIVE ("/Edit Palette...",
palette && GIMP_DATA_FACTORY_VIEW (editor)->data_edit_func);
SET_SENSITIVE ("Delete Palette...",
SET_SENSITIVE ("/Delete Palette...",
palette);
SET_SENSITIVE ("Merge Palettes...",
SET_SENSITIVE ("/Merge Palettes...",
FALSE); /* FIXME palette && GIMP_IS_CONTAINER_LIST_VIEW (editor->view)); */
#undef SET_SENSITIVE
}
/* private functions */
static void
palettes_merge_palettes_query (GimpContainerEditor *editor)
{

View File

@ -25,8 +25,8 @@ void palettes_import_palette_cmd_callback (GtkWidget *widget,
void palettes_merge_palettes_cmd_callback (GtkWidget *widget,
gpointer data);
void palettes_show_context_menu (GimpContainerEditor *editor);
void palettes_menu_update (GtkItemFactory *factory,
gpointer data);
#endif /* __PALETTES_COMMANDS_H__ */

View File

@ -35,43 +35,27 @@
#include "libgimp/gimpintl.h"
/* local function prototypes */
static void patterns_menu_set_sensitivity (GimpContainerEditor *editor);
/* public functions */
void
patterns_show_context_menu (GimpContainerEditor *editor)
patterns_menu_update (GtkItemFactory *factory,
gpointer data)
{
GtkItemFactory *item_factory;
GimpContainerEditor *editor;
GimpPattern *pattern;
patterns_menu_set_sensitivity (editor);
item_factory = gtk_item_factory_from_path ("<Patterns>");
gimp_item_factory_popup_with_data (item_factory, editor);
}
/* private functions */
static void
patterns_menu_set_sensitivity (GimpContainerEditor *editor)
{
GimpPattern *pattern;
editor = GIMP_CONTAINER_EDITOR (data);
pattern = gimp_context_get_pattern (editor->view->context);
#define SET_SENSITIVE(menu,condition) \
gimp_menu_item_set_sensitive ("<Patterns>/" menu, (condition) != 0)
gimp_item_factory_set_sensitive (factory, menu, (condition) != 0)
SET_SENSITIVE ("Duplicate Pattern",
SET_SENSITIVE ("/Duplicate Pattern",
pattern && GIMP_DATA_GET_CLASS (pattern)->duplicate);
SET_SENSITIVE ("Edit Pattern...",
SET_SENSITIVE ("/Edit Pattern...",
pattern && GIMP_DATA_FACTORY_VIEW (editor)->data_edit_func);
SET_SENSITIVE ("Delete Pattern...",
SET_SENSITIVE ("/Delete Pattern...",
pattern);
#undef SET_SENSITIVE

View File

@ -20,7 +20,8 @@
#define __PATTERNS_COMMANDS_H__
void patterns_show_context_menu (GimpContainerEditor *editor);
void patterns_menu_update (GtkItemFactory *factory,
gpointer data);
#endif /* __PATTERNS_COMMANDS_H__ */

View File

@ -18,30 +18,26 @@
#include "config.h"
#include <stdlib.h>
#include <gtk/gtk.h>
#include "libgimpcolor/gimpcolor.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "display-types.h"
#include "gui-types.h"
#include "core/gimp.h"
#include "core/gimpchannel.h"
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "core/gimpimage-mask.h"
#include "core/gimpimage-qmask.h"
#include "widgets/gimpcolorpanel.h"
#include "widgets/gimpitemfactory.h"
#include "widgets/gimpwidgets-utils.h"
#include "gimpdisplay.h"
#include "gimpdisplay-foreach.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-qmask.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplay-foreach.h"
#include "display/gimpdisplayshell.h"
#include "floating_sel.h"
#include "undo.h"
#include "qmask-commands.h"
#include "libgimp/gimpintl.h"
@ -60,149 +56,105 @@ struct _EditQmaskOptions
/* local function prototypes */
static void edit_qmask_channel_query (GimpDisplay *gdisp);
static void edit_qmask_query_ok_callback (GtkWidget *widget,
gpointer client_data);
static void edit_qmask_query_cancel_callback (GtkWidget *widget,
gpointer client_data);
static void qmask_query_scale_update (GtkAdjustment *adjustment,
gpointer data);
static void qmask_color_changed (GimpColorButton *button,
gpointer data);
static void qmask_removed_callback (GtkObject *qmask,
gpointer data);
static void qmask_channel_query (GimpDisplayShell *shell);
static void qmask_query_ok_callback (GtkWidget *widget,
gpointer client_data);
static void qmask_query_cancel_callback (GtkWidget *widget,
gpointer client_data);
static void qmask_query_scale_update (GtkAdjustment *adjustment,
gpointer data);
static void qmask_query_color_changed (GimpColorButton *button,
gpointer data);
/* public functions */
gboolean
gimp_display_shell_qmask_button_press (GtkWidget *widget,
GdkEventButton *event,
GimpDisplayShell *shell)
/* public functionss */
void
qmask_toggle_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
{
GimpDisplay *gdisp;
GimpDisplayShell *shell;
gdisp = shell->gdisp;
shell = (GimpDisplayShell *) gimp_widget_get_callback_context (widget);
if ((event->type == GDK_2BUTTON_PRESS) && (event->button == 1))
{
edit_qmask_channel_query (gdisp);
if (! shell)
return;
return TRUE;
}
gimp_image_set_qmask_state (shell->gdisp->gimage,
GTK_CHECK_MENU_ITEM (widget)->active);
return FALSE;
gdisplays_flush ();
}
void
gimp_display_shell_qmask_toggled (GtkWidget *widget,
GimpDisplayShell *shell)
qmask_invert_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
{
GimpDisplay *gdisp;
GimpImage *gimage;
GimpChannel *mask;
GimpLayer *layer;
GimpRGB color;
GimpDisplayShell *shell;
gdisp = shell->gdisp;
shell = (GimpDisplayShell *) gimp_widget_get_callback_context (widget);
gimage = gdisp->gimage;
if (! shell)
return;
if (GTK_TOGGLE_BUTTON (widget)->active)
if (GTK_CHECK_MENU_ITEM (widget)->active)
{
if (gimp_image_get_qmask_state (gimage))
return; /* if already set, do nothing */
/* Set the defaults */
color = gimage->qmask_color;
gimp_image_qmask_invert (shell->gdisp->gimage);
mask = gimp_image_get_channel_by_name (gimage, "Qmask");
if (mask)
{
/* if the user was clever and created his own */
gimp_image_set_qmask_state (gimage, TRUE);
return;
}
undo_push_group_start (gimage, QMASK_UNDO);
if (gimp_image_mask_is_empty (gimage))
{
/* if no selection */
if ((layer = gimp_image_floating_sel (gimage)))
{
floating_sel_to_layer (layer);
}
mask = gimp_channel_new (gimage,
gimage->width,
gimage->height,
"Qmask",
&color);
gimp_image_add_channel (gimage, mask, 0);
gimp_drawable_fill_by_type (GIMP_DRAWABLE (mask),
gimp_get_user_context (gimage->gimp),
TRANSPARENT_FILL);
}
else /* if selection */
{
mask = gimp_channel_copy (gimp_image_get_mask (gimage), TRUE);
gimp_image_add_channel (gimage, mask, 0);
gimp_channel_set_color (mask, &color);
gimp_object_set_name (GIMP_OBJECT (mask), "Qmask");
gimp_image_mask_none (gimage); /* Clear the selection */
}
undo_push_qmask (gimage);
undo_push_group_end (gimage);
gimp_image_set_qmask_state (gimage, TRUE);
gdisplays_flush ();
/* connect to the removed signal, so the buttons get updated */
g_signal_connect (G_OBJECT (mask), "removed",
G_CALLBACK (qmask_removed_callback),
gdisp);
if (shell->gdisp->gimage->qmask_state)
gdisplays_flush ();
}
}
void
qmask_configure_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
{
GimpDisplayShell *shell;
shell = (GimpDisplayShell *) gimp_widget_get_callback_context (widget);
if (! shell)
return;
qmask_channel_query (shell);
}
void
qmask_menu_update (GtkItemFactory *factory,
gpointer data)
{
GimpDisplayShell *shell;
shell = GIMP_DISPLAY_SHELL (data);
#define SET_ACTIVE(menu,active) \
gimp_item_factory_set_active (factory, "/" menu, (active))
#define SET_COLOR(menu,color) \
gimp_item_factory_set_color (factory, "/" menu, (color), FALSE)
SET_ACTIVE ("QMask Active", shell->gdisp->gimage->qmask_state);
if (shell->gdisp->gimage->qmask_inverted)
SET_ACTIVE ("Mask Selected Areas", TRUE);
else
{
gimage = gdisp->gimage;
SET_ACTIVE ("Mask Unselected Areas", TRUE);
if (! gimp_image_get_qmask_state (gimage))
return; /* if already set do nothing */
SET_COLOR ("Configure Color and Opacity...",
&shell->gdisp->gimage->qmask_color);
mask = gimp_image_get_channel_by_name (gimage, "Qmask");
if (mask)
{
undo_push_group_start (gimage, QMASK_UNDO);
/* push the undo here since removing the mask will
* call the qmask_removed_callback() which will set
* the qmask_state to FALSE
*/
undo_push_qmask (gimage);
gimp_image_mask_load (gimage, mask);
gimp_image_remove_channel (gimage, mask);
undo_push_group_end (gimage);
}
gimp_image_set_qmask_state (gdisp->gimage, FALSE);
if (mask)
gdisplays_flush ();
}
#undef SET_SENSITIVE
#undef SET_COLOR
}
/* private functions */
static void
edit_qmask_channel_query (GimpDisplay *gdisp)
qmask_channel_query (GimpDisplayShell *shell)
{
EditQmaskOptions *options;
GtkWidget *hbox;
@ -214,7 +166,7 @@ edit_qmask_channel_query (GimpDisplay *gdisp)
/* the new options structure */
options = g_new0 (EditQmaskOptions, 1);
options->gimage = gdisp->gimage;
options->gimage = shell->gdisp->gimage;
options->color_panel = gimp_color_panel_new (_("Edit Qmask Color"),
&options->gimage->qmask_color,
GIMP_COLOR_AREA_LARGE_CHECKS,
@ -228,10 +180,10 @@ edit_qmask_channel_query (GimpDisplay *gdisp)
GTK_WIN_POS_MOUSE,
FALSE, TRUE, FALSE,
GTK_STOCK_CANCEL, edit_qmask_query_cancel_callback,
GTK_STOCK_CANCEL, qmask_query_cancel_callback,
options, NULL, NULL, FALSE, TRUE,
GTK_STOCK_OK, edit_qmask_query_ok_callback,
GTK_STOCK_OK, qmask_query_ok_callback,
options, NULL, NULL, TRUE, FALSE,
NULL);
@ -276,15 +228,15 @@ edit_qmask_channel_query (GimpDisplay *gdisp)
gtk_widget_show (options->color_panel);
g_signal_connect (G_OBJECT (options->color_panel), "color_changed",
G_CALLBACK (qmask_color_changed),
G_CALLBACK (qmask_query_color_changed),
opacity_scale_data);
gtk_widget_show (options->query_box);
}
static void
edit_qmask_query_ok_callback (GtkWidget *widget,
gpointer data)
qmask_query_ok_callback (GtkWidget *widget,
gpointer data)
{
EditQmaskOptions *options;
GimpChannel *channel;
@ -315,7 +267,7 @@ edit_qmask_query_ok_callback (GtkWidget *widget,
}
static void
edit_qmask_query_cancel_callback (GtkWidget *widget,
qmask_query_cancel_callback (GtkWidget *widget,
gpointer data)
{
EditQmaskOptions *options;
@ -338,8 +290,8 @@ qmask_query_scale_update (GtkAdjustment *adjustment,
}
static void
qmask_color_changed (GimpColorButton *button,
gpointer data)
qmask_query_color_changed (GimpColorButton *button,
gpointer data)
{
GtkAdjustment *adj = GTK_ADJUSTMENT (data);
GimpRGB color;
@ -347,15 +299,3 @@ qmask_color_changed (GimpColorButton *button,
gimp_color_button_get_color (button, &color);
gtk_adjustment_set_value (adj, color.a * 100.0);
}
static void
qmask_removed_callback (GtkObject *qmask,
gpointer data)
{
GimpDisplay *gdisp = (GimpDisplay *) data;
if (!gdisp->gimage)
return;
gimp_image_set_qmask_state (gdisp->gimage, FALSE);
}

37
app/gui/qmask-commands.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 __QMASK_COMMANDS_H__
#define __QMASK_COMMANDS_H__
void qmask_toggle_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void qmask_invert_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void qmask_configure_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void qmask_menu_update (GtkItemFactory *factory,
gpointer data);
#endif /* __QMASK_COMMANDS_H__ */

View File

@ -50,7 +50,6 @@
#include "color-area.h"
#include "devices.h"
#include "dialogs.h"
#include "dialogs-commands.h"
#include "indicator-area.h"
#include "app_procs.h"

View File

@ -47,6 +47,7 @@
#include "tools/gimpthresholdtool.h"
#include "tools/tool_manager.h"
#include "brushes-commands.h"
#include "buffers-commands.h"
#include "channels-commands.h"
#include "commands.h"
@ -62,6 +63,8 @@
#include "menus.h"
#include "palettes-commands.h"
#include "paths-dialog.h"
#include "patterns-commands.h"
#include "qmask-commands.h"
#include "select-commands.h"
#include "test-commands.h"
#include "tools-commands.h"
@ -696,11 +699,6 @@ static GimpItemFactoryEntry image_entries[] =
SEPARATOR ("/Layers/---"),
{ { N_("/Layers/Layer to Imagesize"), NULL,
layers_resize_to_image_cmd_callback, 0 },
NULL,
"layers/layer_to_image_size.html", NULL },
/* <Image>/Layers/Stack */
{ { N_("/Layers/Stack/Previous Layer"), "Prior",
@ -745,10 +743,24 @@ static GimpItemFactoryEntry image_entries[] =
"<StockItem>", GIMP_STOCK_ANCHOR },
NULL,
"layers/anchor_layer.html", NULL },
SEPARATOR ("/Layers/---"),
{ { N_("/Layers/Layer to Imagesize"), NULL,
layers_resize_to_image_cmd_callback, 0 },
NULL,
"layers/layer_to_image_size.html", NULL },
SEPARATOR ("/Layers/---"),
{ { N_("/Layers/Merge Visible Layers..."), "<control>M",
layers_merge_layers_cmd_callback, 0 },
NULL,
"layers/dialogs/merge_visible_layers.html", NULL },
{ { N_("/Layers/Merge Down"), "<control><shift>M",
layers_merge_down_cmd_callback, 0 },
NULL,
"layers/merge_visible_layers.html", NULL },
{ { N_("/Layers/Flatten Image"), NULL,
layers_flatten_image_cmd_callback, 0 },
NULL,
@ -805,7 +817,7 @@ static GimpItemFactoryEntry image_entries[] =
dialogs_create_lc_cmd_callback, 0 },
NULL,
"dialogs/layers_and_channels.html", NULL },
{ { N_("/File/Dialogs/Brushes, Patterns & Stuff..."), NULL,
{ { N_("/Dialogs/Brushes, Patterns & Stuff..."), NULL,
dialogs_create_stuff_cmd_callback, 0 },
NULL,
NULL, NULL },
@ -973,12 +985,12 @@ static GimpItemFactoryEntry layers_entries[] =
"<StockItem>", GIMP_STOCK_LOWER },
NULL,
"stack/stack.html#lower_layer", NULL },
{ { N_("/Stack/Layer to Top"), "<shift><control>F",
{ { N_("/Stack/Layer to Top"), "<control><shift>F",
layers_raise_to_top_cmd_callback, 0,
"<StockItem>", GIMP_STOCK_RAISE },
NULL,
"stack/stack.html#later_to_top", NULL },
{ { N_("/Stack/Layer to Bottom"), "<shift><control>B",
{ { N_("/Stack/Layer to Bottom"), "<control><shift>B",
layers_lower_to_bottom_cmd_callback, 0,
"<StockItem>", GIMP_STOCK_LOWER },
NULL,
@ -1729,6 +1741,31 @@ static GimpItemFactoryEntry documents_entries[] =
};
/***** <QMask> *****/
static GimpItemFactoryEntry qmask_entries[] =
{
{ { N_("/QMask Active"), NULL,
qmask_toggle_cmd_callback, 0, "<ToggleItem>" },
NULL, NULL, NULL },
SEPARATOR ("/---"),
{ { N_("/Mask Selected Areas"), NULL,
qmask_invert_cmd_callback, FALSE, "<RadioItem>" },
NULL, NULL, NULL },
{ { N_("/Mask Unselected Areas"), NULL,
qmask_invert_cmd_callback, TRUE, "/Mask Selected Areas" },
NULL, NULL, NULL },
SEPARATOR ("/---"),
{ { N_("/Configure Color and Opacity..."), NULL,
qmask_configure_cmd_callback, 0 },
NULL, NULL, NULL }
};
static gboolean menus_initialized = FALSE;
@ -1747,6 +1784,7 @@ static GtkItemFactory *gradients_factory = NULL;
static GtkItemFactory *palettes_factory = NULL;
static GtkItemFactory *buffers_factory = NULL;
static GtkItemFactory *documents_factory = NULL;
static GtkItemFactory *qmask_factory = NULL;
/* public functions */
@ -1771,6 +1809,7 @@ menus_init (Gimp *gimp)
toolbox_factory = gimp_item_factory_new (GTK_TYPE_MENU_BAR,
"<Toolbox>", "toolbox",
NULL,
G_N_ELEMENTS (toolbox_entries),
toolbox_entries,
gimp,
@ -1825,6 +1864,7 @@ menus_init (Gimp *gimp)
image_factory = gimp_item_factory_new (GTK_TYPE_MENU,
"<Image>", "image",
NULL,
G_N_ELEMENTS (image_entries),
image_entries,
gimp,
@ -1832,6 +1872,7 @@ menus_init (Gimp *gimp)
load_factory = gimp_item_factory_new (GTK_TYPE_MENU,
"<Load>", "open",
NULL,
G_N_ELEMENTS (load_entries),
load_entries,
gimp,
@ -1839,6 +1880,7 @@ menus_init (Gimp *gimp)
save_factory = gimp_item_factory_new (GTK_TYPE_MENU,
"<Save>", "save",
NULL,
G_N_ELEMENTS (save_entries),
save_entries,
gimp,
@ -1846,6 +1888,7 @@ menus_init (Gimp *gimp)
layers_factory = gimp_item_factory_new (GTK_TYPE_MENU,
"<Layers>", "layers",
layers_menu_update,
G_N_ELEMENTS (layers_entries),
layers_entries,
gimp,
@ -1853,6 +1896,7 @@ menus_init (Gimp *gimp)
channels_factory = gimp_item_factory_new (GTK_TYPE_MENU,
"<Channels>", "channels",
channels_menu_update,
G_N_ELEMENTS (channels_entries),
channels_entries,
gimp,
@ -1860,6 +1904,7 @@ menus_init (Gimp *gimp)
paths_factory = gimp_item_factory_new (GTK_TYPE_MENU,
"<Paths>", "paths",
NULL,
G_N_ELEMENTS (paths_entries),
paths_entries,
gimp,
@ -1867,6 +1912,7 @@ menus_init (Gimp *gimp)
dialogs_factory = gimp_item_factory_new (GTK_TYPE_MENU,
"<Dialogs>", "dialogs",
dialogs_menu_update,
G_N_ELEMENTS (dialogs_entries),
dialogs_entries,
gimp,
@ -1874,6 +1920,7 @@ menus_init (Gimp *gimp)
brushes_factory = gimp_item_factory_new (GTK_TYPE_MENU,
"<Brushes>", "brushes",
brushes_menu_update,
G_N_ELEMENTS (brushes_entries),
brushes_entries,
gimp,
@ -1881,6 +1928,7 @@ menus_init (Gimp *gimp)
patterns_factory = gimp_item_factory_new (GTK_TYPE_MENU,
"<Patterns>", "patterns",
patterns_menu_update,
G_N_ELEMENTS (patterns_entries),
patterns_entries,
gimp,
@ -1888,6 +1936,7 @@ menus_init (Gimp *gimp)
gradient_editor_factory = gimp_item_factory_new (GTK_TYPE_MENU,
"<GradientEditor>", "gradient_editor",
gradient_editor_menu_update,
G_N_ELEMENTS (gradient_editor_entries),
gradient_editor_entries,
gimp,
@ -1895,6 +1944,7 @@ menus_init (Gimp *gimp)
gradients_factory = gimp_item_factory_new (GTK_TYPE_MENU,
"<Gradients>", "gradients",
gradients_menu_update,
G_N_ELEMENTS (gradients_entries),
gradients_entries,
gimp,
@ -1902,6 +1952,7 @@ menus_init (Gimp *gimp)
palettes_factory = gimp_item_factory_new (GTK_TYPE_MENU,
"<Palettes>", "palettes",
palettes_menu_update,
G_N_ELEMENTS (palettes_entries),
palettes_entries,
gimp,
@ -1909,6 +1960,7 @@ menus_init (Gimp *gimp)
buffers_factory = gimp_item_factory_new (GTK_TYPE_MENU,
"<Buffers>", "buffers",
buffers_menu_update,
G_N_ELEMENTS (buffers_entries),
buffers_entries,
gimp,
@ -1916,11 +1968,20 @@ menus_init (Gimp *gimp)
documents_factory = gimp_item_factory_new (GTK_TYPE_MENU,
"<Documents>", "documents",
documents_menu_update,
G_N_ELEMENTS (documents_entries),
documents_entries,
gimp,
FALSE);
qmask_factory = gimp_item_factory_new (GTK_TYPE_MENU,
"<QMask>", "qmask",
qmask_menu_update,
G_N_ELEMENTS (qmask_entries),
qmask_entries,
gimp,
FALSE);
for (list = GIMP_LIST (gimp->tool_info_list)->list;
list;
list = g_list_next (list))
@ -2104,6 +2165,12 @@ menus_exit (Gimp *gimp)
g_object_unref (G_OBJECT (documents_factory));
documents_factory = NULL;
}
if (qmask_factory)
{
g_object_unref (G_OBJECT (qmask_factory));
qmask_factory = NULL;
}
}
void

View File

@ -148,15 +148,15 @@ gimp_brush_factory_view_destroy (GtkObject *object)
}
GtkWidget *
gimp_brush_factory_view_new (GimpViewType view_type,
GimpDataFactory *factory,
GimpDataEditFunc edit_func,
GimpContext *context,
gboolean change_brush_spacing,
gint preview_size,
gint min_items_x,
gint min_items_y,
GimpContainerContextFunc context_func)
gimp_brush_factory_view_new (GimpViewType view_type,
GimpDataFactory *factory,
GimpDataEditFunc edit_func,
GimpContext *context,
gboolean change_brush_spacing,
gint preview_size,
gint min_items_x,
gint min_items_y,
const gchar *item_factory)
{
GimpBrushFactoryView *factory_view;
GimpContainerEditor *editor;
@ -178,7 +178,7 @@ gimp_brush_factory_view_new (GimpViewType view_type,
preview_size,
min_items_x,
min_items_y,
context_func))
item_factory))
{
g_object_unref (G_OBJECT (factory_view));
return NULL;

View File

@ -54,16 +54,15 @@ struct _GimpBrushFactoryViewClass
GType gimp_brush_factory_view_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_brush_factory_view_new (GimpViewType view_type,
GimpDataFactory *factory,
GimpDataEditFunc edit_func,
GimpContext *context,
gboolean change_brush_spacing,
gint preview_size,
gint min_items_x,
gint min_items_y,
GimpContainerContextFunc context_func);
GtkWidget * gimp_brush_factory_view_new (GimpViewType view_type,
GimpDataFactory *factory,
GimpDataEditFunc edit_func,
GimpContext *context,
gboolean change_brush_spacing,
gint preview_size,
gint min_items_x,
gint min_items_y,
const gchar *item_factory);
#endif /* __GIMP_BRUSH_FACTORY_VIEW_H__ */

View File

@ -114,13 +114,13 @@ gimp_buffer_view_init (GimpBufferView *view)
}
GtkWidget *
gimp_buffer_view_new (GimpViewType view_type,
GimpContainer *container,
GimpContext *context,
gint preview_size,
gint min_items_x,
gint min_items_y,
GimpContainerContextFunc context_func)
gimp_buffer_view_new (GimpViewType view_type,
GimpContainer *container,
GimpContext *context,
gint preview_size,
gint min_items_x,
gint min_items_y,
const gchar *item_factory)
{
GimpBufferView *buffer_view;
GimpContainerEditor *editor;
@ -128,14 +128,14 @@ gimp_buffer_view_new (GimpViewType view_type,
buffer_view = g_object_new (GIMP_TYPE_BUFFER_VIEW, NULL);
if (! gimp_container_editor_construct (GIMP_CONTAINER_EDITOR (buffer_view),
view_type,
container,
context,
preview_size,
view_type,
container,
context,
preview_size,
TRUE, /* reorderable */
min_items_x,
min_items_y,
context_func))
min_items_x,
min_items_y,
item_factory))
{
g_object_unref (G_OBJECT (buffer_view));
return NULL;

View File

@ -54,13 +54,13 @@ struct _GimpBufferViewClass
GType gimp_buffer_view_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_buffer_view_new (GimpViewType view_type,
GimpContainer *container,
GimpContext *context,
gint preview_size,
gint min_items_x,
gint min_items_y,
GimpContainerContextFunc context_func);
GtkWidget * gimp_buffer_view_new (GimpViewType view_type,
GimpContainer *container,
GimpContext *context,
gint preview_size,
gint min_items_x,
gint min_items_y,
const gchar *item_factory);
#endif /* __GIMP_BUFFER_VIEW_H__ */

View File

@ -34,11 +34,14 @@
#include "gimpcontainergridview.h"
#include "gimpcontainerlistview.h"
#include "gimpdnd.h"
#include "gimpitemfactory.h"
static void gimp_container_editor_class_init (GimpContainerEditorClass *klass);
static void gimp_container_editor_init (GimpContainerEditor *view);
static void gimp_container_editor_finalize (GObject *object);
static void gimp_container_editor_select_item (GtkWidget *widget,
GimpViewable *viewable,
gpointer insert_data,
@ -89,30 +92,49 @@ gimp_container_editor_get_type (void)
static void
gimp_container_editor_class_init (GimpContainerEditorClass *klass)
{
GObjectClass *object_class;
object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
klass->select_item = NULL;
klass->activate_item = NULL;
klass->context_item = gimp_container_editor_real_context_item;
object_class->finalize = gimp_container_editor_finalize;
klass->select_item = NULL;
klass->activate_item = NULL;
klass->context_item = gimp_container_editor_real_context_item;
}
static void
gimp_container_editor_init (GimpContainerEditor *view)
{
view->context_func = NULL;
view->item_factory = NULL;
view->view = NULL;
}
static void
gimp_container_editor_finalize (GObject *object)
{
GimpContainerEditor *editor;
editor = GIMP_CONTAINER_EDITOR (object);
g_free (editor->item_factory);
editor->item_factory = NULL;
G_OBJECT_CLASS (parent_class)->finalize (object);
}
gboolean
gimp_container_editor_construct (GimpContainerEditor *editor,
GimpViewType view_type,
GimpContainer *container,
GimpContext *context,
gint preview_size,
gboolean reorderable,
gint min_items_x,
gint min_items_y,
GimpContainerContextFunc context_func)
gimp_container_editor_construct (GimpContainerEditor *editor,
GimpViewType view_type,
GimpContainer *container,
GimpContext *context,
gint preview_size,
gboolean reorderable,
gint min_items_x,
gint min_items_y,
const gchar *item_factory)
{
g_return_val_if_fail (GIMP_IS_CONTAINER_EDITOR (editor), FALSE);
g_return_val_if_fail (GIMP_IS_CONTAINER (container), FALSE);
@ -122,7 +144,7 @@ gimp_container_editor_construct (GimpContainerEditor *editor,
g_return_val_if_fail (min_items_x > 0 && min_items_x <= 64, FALSE);
g_return_val_if_fail (min_items_y > 0 && min_items_y <= 64, FALSE);
editor->context_func = context_func;
editor->item_factory = g_strdup (item_factory);
switch (view_type)
{
@ -225,7 +247,16 @@ gimp_container_editor_real_context_item (GimpContainerEditor *editor,
if (viewable && gimp_container_have (editor->view->container,
GIMP_OBJECT (viewable)))
{
if (editor->context_func)
editor->context_func (editor);
if (editor->item_factory)
{
GtkItemFactory *factory;
factory = gtk_item_factory_from_path (editor->item_factory);
if (factory)
{
gimp_item_factory_popup_with_data (factory, editor, NULL);
}
}
}
}

View File

@ -26,9 +26,6 @@
#include <gtk/gtkvbox.h>
typedef void (* GimpContainerContextFunc) (GimpContainerEditor *editor);
#define GIMP_TYPE_CONTAINER_EDITOR (gimp_container_editor_get_type ())
#define GIMP_CONTAINER_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_CONTAINER_EDITOR, GimpContainerEditor))
#define GIMP_CONTAINER_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_CONTAINER_EDITOR, GimpContainerEditorClass))
@ -41,11 +38,11 @@ typedef struct _GimpContainerEditorClass GimpContainerEditorClass;
struct _GimpContainerEditor
{
GtkVBox parent_instance;
GtkVBox parent_instance;
GimpContainerContextFunc context_func;
gchar *item_factory;
GimpContainerView *view;
GimpContainerView *view;
};
struct _GimpContainerEditorClass
@ -66,15 +63,15 @@ GType gimp_container_editor_get_type (void) G_GNUC_CONST;
/* protected */
gboolean gimp_container_editor_construct (GimpContainerEditor *editor,
GimpViewType view_type,
GimpContainer *container,
GimpContext *context,
gint preview_size,
gboolean reorderable,
gint min_items_x,
gint min_items_y,
GimpContainerContextFunc context_func);
gboolean gimp_container_editor_construct (GimpContainerEditor *editor,
GimpViewType view_type,
GimpContainer *container,
GimpContext *context,
gint preview_size,
gboolean reorderable,
gint min_items_x,
gint min_items_y,
const gchar *item_factory);
#endif /* __GIMP_CONTAINER_EDITOR_H__ */

View File

@ -122,14 +122,14 @@ gimp_data_factory_view_init (GimpDataFactoryView *view)
}
GtkWidget *
gimp_data_factory_view_new (GimpViewType view_type,
GimpDataFactory *factory,
GimpDataEditFunc edit_func,
GimpContext *context,
gint preview_size,
gint min_items_x,
gint min_items_y,
GimpContainerContextFunc context_func)
gimp_data_factory_view_new (GimpViewType view_type,
GimpDataFactory *factory,
GimpDataEditFunc edit_func,
GimpContext *context,
gint preview_size,
gint min_items_x,
gint min_items_y,
const gchar *item_factory)
{
GimpDataFactoryView *factory_view;
@ -143,7 +143,7 @@ gimp_data_factory_view_new (GimpViewType view_type,
preview_size,
min_items_x,
min_items_y,
context_func))
item_factory))
{
g_object_unref (G_OBJECT (factory_view));
return NULL;
@ -153,15 +153,15 @@ gimp_data_factory_view_new (GimpViewType view_type,
}
gboolean
gimp_data_factory_view_construct (GimpDataFactoryView *factory_view,
GimpViewType view_type,
GimpDataFactory *factory,
GimpDataEditFunc edit_func,
GimpContext *context,
gint preview_size,
gint min_items_x,
gint min_items_y,
GimpContainerContextFunc context_func)
gimp_data_factory_view_construct (GimpDataFactoryView *factory_view,
GimpViewType view_type,
GimpDataFactory *factory,
GimpDataEditFunc edit_func,
GimpContext *context,
gint preview_size,
gint min_items_x,
gint min_items_y,
const gchar *item_factory)
{
GimpContainerEditor *editor;
@ -182,7 +182,7 @@ gimp_data_factory_view_construct (GimpDataFactoryView *factory_view,
FALSE, /* reorderable */
min_items_x,
min_items_y,
context_func))
item_factory))
{
return FALSE;
}

View File

@ -62,27 +62,27 @@ struct _GimpDataFactoryViewClass
GType gimp_data_factory_view_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_data_factory_view_new (GimpViewType view_type,
GimpDataFactory *factory,
GimpDataEditFunc edit_func,
GimpContext *context,
gint preview_size,
gint min_items_x,
gint min_items_y,
GimpContainerContextFunc context_func);
GtkWidget * gimp_data_factory_view_new (GimpViewType view_type,
GimpDataFactory *factory,
GimpDataEditFunc edit_func,
GimpContext *context,
gint preview_size,
gint min_items_x,
gint min_items_y,
const gchar *item_factory);
/* protected */
gboolean gimp_data_factory_view_construct (GimpDataFactoryView *factory_view,
GimpViewType view_type,
GimpDataFactory *factory,
GimpDataEditFunc edit_func,
GimpContext *context,
gint preview_size,
gint min_items_x,
gint min_items_y,
GimpContainerContextFunc context_func);
gboolean gimp_data_factory_view_construct (GimpDataFactoryView *factory_view,
GimpViewType view_type,
GimpDataFactory *factory,
GimpDataEditFunc edit_func,
GimpContext *context,
gint preview_size,
gint min_items_x,
gint min_items_y,
const gchar *item_factory);
#endif /* __GIMP_DATA_FACTORY_VIEW_H__ */

View File

@ -464,94 +464,11 @@ gimp_dockbook_tab_button_press (GtkWidget *widget,
{
GtkItemFactory *ifactory;
GtkWidget *add_widget;
gint origin_x;
gint origin_y;
gint x, y;
ifactory = GTK_ITEM_FACTORY (dockbook->dock->factory->item_factory);
add_widget = gtk_item_factory_get_widget (ifactory, "/Select Tab");
/* update the menu items */
{
GimpDialogFactoryEntry *entry;
GimpContainerView *view;
gboolean is_grid = FALSE;
GimpPreviewSize preview_size = GIMP_PREVIEW_SIZE_NONE;
entry = g_object_get_data (G_OBJECT (dockable),
"gimp-dialog-factory-entry");
if (entry)
{
if (strstr (entry->identifier, "grid"))
is_grid = TRUE;
}
view = gimp_container_view_get_by_dockable (dockable);
if (view)
{
preview_size = view->preview_size;
}
#define SET_ACTIVE(path,active) \
gimp_item_factory_set_active (ifactory, (path), (active))
if (preview_size >= GIMP_PREVIEW_SIZE_GIGANTIC)
{
SET_ACTIVE ("/Preview Size/Gigantic", TRUE);
}
else if (preview_size >= GIMP_PREVIEW_SIZE_ENORMOUS)
{
SET_ACTIVE ("/Preview Size/Enormous", TRUE);
}
else if (preview_size >= GIMP_PREVIEW_SIZE_HUGE)
{
SET_ACTIVE ("/Preview Size/Huge", TRUE);
}
else if (preview_size >= GIMP_PREVIEW_SIZE_EXTRA_LARGE)
{
SET_ACTIVE ("/Preview Size/Extra Large", TRUE);
}
else if (preview_size >= GIMP_PREVIEW_SIZE_LARGE)
{
SET_ACTIVE ("/Preview Size/Large", TRUE);
}
else if (preview_size >= GIMP_PREVIEW_SIZE_MEDIUM)
{
SET_ACTIVE ("/Preview Size/Medium", TRUE);
}
else if (preview_size >= GIMP_PREVIEW_SIZE_SMALL)
{
SET_ACTIVE ("/Preview Size/Small", TRUE);
}
else if (preview_size >= GIMP_PREVIEW_SIZE_EXTRA_SMALL)
{
SET_ACTIVE ("/Preview Size/Extra Small", TRUE);
}
else
{
SET_ACTIVE ("/Preview Size/Tiny", TRUE);
}
if (is_grid)
{
SET_ACTIVE ("/View as Grid", TRUE);
}
else
{
SET_ACTIVE ("/View as List", TRUE);
}
SET_ACTIVE ("/Show Image Menu",
GIMP_IMAGE_DOCK (dockbook->dock)->show_image_menu);
SET_ACTIVE ("/Auto Follow Active Image",
GIMP_IMAGE_DOCK (dockbook->dock)->auto_follow_active);
#undef SET_ACTIVE
}
/* do evil things */
{
GtkWidget *notebook_menu;
@ -568,27 +485,14 @@ gimp_dockbook_tab_button_press (GtkWidget *widget,
g_object_unref (G_OBJECT (notebook_menu));
}
gdk_window_get_origin (widget->window, &origin_x, &origin_y);
x = bevent->x + origin_x;
y = bevent->y + origin_y;
if (x + ifactory->widget->requisition.width > gdk_screen_width ())
x -= ifactory->widget->requisition.width;
if (y + ifactory->widget->requisition.height > gdk_screen_height ())
y -= ifactory->widget->requisition.height;
/* an item factory callback may destroy the dockbook, so reference
* if for gimp_dockbook_menu_end()
*/
g_object_ref (G_OBJECT (dockbook));
gtk_item_factory_popup_with_data (ifactory,
dockbook,
(GtkDestroyNotify) gimp_dockbook_menu_end,
x, y,
3, bevent->time);
gimp_item_factory_popup_with_data (ifactory,
dockbook,
(GtkDestroyNotify) gimp_dockbook_menu_end);
}
return TRUE;

View File

@ -121,13 +121,13 @@ gimp_document_view_init (GimpDocumentView *view)
}
GtkWidget *
gimp_document_view_new (GimpViewType view_type,
GimpContainer *container,
GimpContext *context,
gint preview_size,
gint min_items_x,
gint min_items_y,
GimpContainerContextFunc context_func)
gimp_document_view_new (GimpViewType view_type,
GimpContainer *container,
GimpContext *context,
gint preview_size,
gint min_items_x,
gint min_items_y,
const gchar *item_factory)
{
GimpDocumentView *document_view;
GimpContainerEditor *editor;
@ -135,14 +135,14 @@ gimp_document_view_new (GimpViewType view_type,
document_view = g_object_new (GIMP_TYPE_DOCUMENT_VIEW, NULL);
if (! gimp_container_editor_construct (GIMP_CONTAINER_EDITOR (document_view),
view_type,
container,
context,
preview_size,
view_type,
container,
context,
preview_size,
TRUE, /* reorderable */
min_items_x,
min_items_y,
context_func))
min_items_x,
min_items_y,
item_factory))
{
g_object_unref (G_OBJECT (document_view));
return NULL;

View File

@ -53,13 +53,13 @@ struct _GimpDocumentViewClass
GType gimp_document_view_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_document_view_new (GimpViewType view_type,
GimpContainer *container,
GimpContext *context,
gint preview_size,
gint min_items_x,
gint min_items_y,
GimpContainerContextFunc context_func);
GtkWidget * gimp_document_view_new (GimpViewType view_type,
GimpContainer *container,
GimpContext *context,
gint preview_size,
gint min_items_x,
gint min_items_y,
const gchar *item_factory);
#endif /* __GIMP_DOCUMENT_VIEW_H__ */

View File

@ -40,6 +40,7 @@
#include "gimpchannellistview.h"
#include "gimpdnd.h"
#include "gimpdrawablelistview.h"
#include "gimpitemfactory.h"
#include "gimplayerlistview.h"
#include "gimplistitem.h"
#include "gimppreview.h"
@ -256,6 +257,12 @@ gimp_drawable_list_view_destroy (GtkObject *object)
view->signal_name = NULL;
}
if (view->item_factory)
{
g_free (view->item_factory);
view->item_factory = NULL;
}
if (GTK_OBJECT_CLASS (parent_class)->destroy)
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
@ -274,7 +281,7 @@ gimp_drawable_list_view_new (gint preview_size,
GimpCopyDrawableFunc copy_drawable_func,
GimpNewDrawableFunc new_drawable_func,
GimpEditDrawableFunc edit_drawable_func,
GimpDrawableContextFunc drawable_context_func)
const gchar *item_factory)
{
GimpDrawableListView *list_view;
GimpContainerView *view;
@ -291,7 +298,7 @@ gimp_drawable_list_view_new (gint preview_size,
g_return_val_if_fail (copy_drawable_func != NULL, NULL);
g_return_val_if_fail (new_drawable_func != NULL, NULL);
g_return_val_if_fail (edit_drawable_func != NULL, NULL);
g_return_val_if_fail (drawable_context_func != NULL, NULL);
g_return_val_if_fail (item_factory != NULL, NULL);
if (drawable_type == GIMP_TYPE_LAYER)
{
@ -322,7 +329,8 @@ gimp_drawable_list_view_new (gint preview_size,
list_view->copy_drawable_func = copy_drawable_func;
list_view->new_drawable_func = new_drawable_func;
list_view->edit_drawable_func = edit_drawable_func;
list_view->drawable_context_func = drawable_context_func;
list_view->item_factory = g_strdup (item_factory);
/* connect "drop to new" manually as it makes a difference whether
* it was clicked or dropped
@ -495,13 +503,21 @@ gimp_drawable_list_view_context_item (GimpContainerView *view,
GimpViewable *item,
gpointer insert_data)
{
GtkItemFactory *factory;
if (GIMP_CONTAINER_VIEW_CLASS (parent_class)->context_item)
GIMP_CONTAINER_VIEW_CLASS (parent_class)->context_item (view,
item,
insert_data);
GIMP_DRAWABLE_LIST_VIEW (view)->drawable_context_func
(gimp_drawable_gimage (GIMP_DRAWABLE (item)));
factory = gtk_item_factory_from_path (GIMP_DRAWABLE_LIST_VIEW (view)->item_factory);
if (factory)
{
gimp_item_factory_popup_with_data (factory,
gimp_drawable_gimage (GIMP_DRAWABLE (item)),
NULL);
}
}

View File

@ -44,7 +44,6 @@ typedef GimpDrawable * (* GimpCopyDrawableFunc) (GimpDrawable *drawable,
typedef void (* GimpNewDrawableFunc) (GimpImage *gimage);
typedef void (* GimpEditDrawableFunc) (GimpDrawable *drawable);
typedef void (* GimpDrawableContextFunc) (GimpImage *gimage);
#define GIMP_TYPE_DRAWABLE_LIST_VIEW (gimp_drawable_list_view_get_type ())
@ -76,7 +75,8 @@ struct _GimpDrawableListView
GimpNewDrawableFunc new_drawable_func;
GimpEditDrawableFunc edit_drawable_func;
GimpDrawableContextFunc drawable_context_func;
gchar *item_factory;
GtkWidget *new_button;
GtkWidget *raise_button;
@ -110,7 +110,7 @@ GtkWidget * gimp_drawable_list_view_new (gint preview_s
GimpCopyDrawableFunc copy_drawable_func,
GimpNewDrawableFunc new_drawable_func,
GimpEditDrawableFunc edit_drawable_func,
GimpDrawableContextFunc drawable_context_func);
const gchar *item_factory);
void gimp_drawable_list_view_set_image (GimpDrawableListView *view,
GimpImage *gimage);

View File

@ -40,6 +40,7 @@
#include "gimpchannellistview.h"
#include "gimpdnd.h"
#include "gimpdrawablelistview.h"
#include "gimpitemfactory.h"
#include "gimplayerlistview.h"
#include "gimplistitem.h"
#include "gimppreview.h"
@ -256,6 +257,12 @@ gimp_drawable_list_view_destroy (GtkObject *object)
view->signal_name = NULL;
}
if (view->item_factory)
{
g_free (view->item_factory);
view->item_factory = NULL;
}
if (GTK_OBJECT_CLASS (parent_class)->destroy)
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
@ -274,7 +281,7 @@ gimp_drawable_list_view_new (gint preview_size,
GimpCopyDrawableFunc copy_drawable_func,
GimpNewDrawableFunc new_drawable_func,
GimpEditDrawableFunc edit_drawable_func,
GimpDrawableContextFunc drawable_context_func)
const gchar *item_factory)
{
GimpDrawableListView *list_view;
GimpContainerView *view;
@ -291,7 +298,7 @@ gimp_drawable_list_view_new (gint preview_size,
g_return_val_if_fail (copy_drawable_func != NULL, NULL);
g_return_val_if_fail (new_drawable_func != NULL, NULL);
g_return_val_if_fail (edit_drawable_func != NULL, NULL);
g_return_val_if_fail (drawable_context_func != NULL, NULL);
g_return_val_if_fail (item_factory != NULL, NULL);
if (drawable_type == GIMP_TYPE_LAYER)
{
@ -322,7 +329,8 @@ gimp_drawable_list_view_new (gint preview_size,
list_view->copy_drawable_func = copy_drawable_func;
list_view->new_drawable_func = new_drawable_func;
list_view->edit_drawable_func = edit_drawable_func;
list_view->drawable_context_func = drawable_context_func;
list_view->item_factory = g_strdup (item_factory);
/* connect "drop to new" manually as it makes a difference whether
* it was clicked or dropped
@ -495,13 +503,21 @@ gimp_drawable_list_view_context_item (GimpContainerView *view,
GimpViewable *item,
gpointer insert_data)
{
GtkItemFactory *factory;
if (GIMP_CONTAINER_VIEW_CLASS (parent_class)->context_item)
GIMP_CONTAINER_VIEW_CLASS (parent_class)->context_item (view,
item,
insert_data);
GIMP_DRAWABLE_LIST_VIEW (view)->drawable_context_func
(gimp_drawable_gimage (GIMP_DRAWABLE (item)));
factory = gtk_item_factory_from_path (GIMP_DRAWABLE_LIST_VIEW (view)->item_factory);
if (factory)
{
gimp_item_factory_popup_with_data (factory,
gimp_drawable_gimage (GIMP_DRAWABLE (item)),
NULL);
}
}

View File

@ -44,7 +44,6 @@ typedef GimpDrawable * (* GimpCopyDrawableFunc) (GimpDrawable *drawable,
typedef void (* GimpNewDrawableFunc) (GimpImage *gimage);
typedef void (* GimpEditDrawableFunc) (GimpDrawable *drawable);
typedef void (* GimpDrawableContextFunc) (GimpImage *gimage);
#define GIMP_TYPE_DRAWABLE_LIST_VIEW (gimp_drawable_list_view_get_type ())
@ -76,7 +75,8 @@ struct _GimpDrawableListView
GimpNewDrawableFunc new_drawable_func;
GimpEditDrawableFunc edit_drawable_func;
GimpDrawableContextFunc drawable_context_func;
gchar *item_factory;
GtkWidget *new_button;
GtkWidget *raise_button;
@ -110,7 +110,7 @@ GtkWidget * gimp_drawable_list_view_new (gint preview_s
GimpCopyDrawableFunc copy_drawable_func,
GimpNewDrawableFunc new_drawable_func,
GimpEditDrawableFunc edit_drawable_func,
GimpDrawableContextFunc drawable_context_func);
const gchar *item_factory);
void gimp_drawable_list_view_set_image (GimpDrawableListView *view,
GimpImage *gimage);

View File

@ -71,9 +71,9 @@
#include "core/gimpgradient.h"
#include "widgets/gimpdnd.h"
#include "widgets/gimpitemfactory.h"
#include "gradient-editor.h"
#include "gradient-editor-commands.h"
#include "gimprc.h"
@ -810,7 +810,13 @@ preview_events (GtkWidget *widget,
break;
case 3:
gradient_editor_show_context_menu (editor);
{
GtkItemFactory *factory;
factory = gtk_item_factory_from_path ("<GradientEditor>");
gimp_item_factory_popup_with_data (factory, editor, NULL);
}
break;
default:
@ -1291,7 +1297,13 @@ control_button_press (GradientEditor *editor,
break;
case 3:
gradient_editor_show_context_menu (editor);
{
GtkItemFactory *factory;
factory = gtk_item_factory_from_path ("<GradientEditor>");
gimp_item_factory_popup_with_data (factory, editor, NULL);
}
return;
/* wheelmouse support */

View File

@ -29,6 +29,7 @@
#include "widgets-types.h"
#include "gimpitemfactory.h"
#include "gimpwidgets-utils.h"
#include "gimphelp.h"
#include "gimprc.h"
@ -210,13 +211,14 @@ gimp_menu_item_set_visible (gchar *path,
GtkItemFactory *
gimp_item_factory_new (GType container_type,
const gchar *path,
const gchar *factory_path,
guint n_entries,
GimpItemFactoryEntry *entries,
gpointer callback_data,
gboolean create_tearoff)
gimp_item_factory_new (GType container_type,
const gchar *path,
const gchar *factory_path,
GimpItemFactoryUpdateFunc update_func,
guint n_entries,
GimpItemFactoryEntry *entries,
gpointer callback_data,
gboolean create_tearoff)
{
GtkItemFactory *factory;
@ -230,6 +232,9 @@ gimp_item_factory_new (GType container_type,
g_object_set_data (G_OBJECT (factory), "factory_path",
(gpointer) factory_path);
g_object_set_data (G_OBJECT (factory), "gimp-item-factory-update-func",
update_func);
gimp_item_factory_create_items (factory,
n_entries,
entries,
@ -241,6 +246,37 @@ gimp_item_factory_new (GType container_type,
return factory;
}
void
gimp_item_factory_popup_with_data (GtkItemFactory *item_factory,
gpointer data,
GtkDestroyNotify popdown_func)
{
GimpItemFactoryUpdateFunc update_func;
gint x, y;
guint button;
guint32 activate_time;
g_return_if_fail (GTK_IS_ITEM_FACTORY (item_factory));
update_func = g_object_get_data (G_OBJECT (item_factory),
"gimp-item-factory-update-func");
if (update_func)
(* update_func) (item_factory, data);
gimp_menu_position (GTK_MENU (item_factory->widget),
&x, &y,
&button,
&activate_time);
gtk_item_factory_popup_with_data (item_factory,
data,
popdown_func,
x, y,
button,
activate_time);
}
void
gimp_item_factory_create_item (GtkItemFactory *item_factory,
GimpItemFactoryEntry *entry,

View File

@ -22,6 +22,10 @@
G_BEGIN_DECLS
typedef void (* GimpItemFactoryUpdateFunc) (GtkItemFactory *factory,
gpointer data);
typedef struct _GimpItemFactoryEntry GimpItemFactoryEntry;
struct _GimpItemFactoryEntry
@ -35,13 +39,18 @@ struct _GimpItemFactoryEntry
};
GtkItemFactory * gimp_item_factory_new (GType container_type,
const gchar *path,
const gchar *factory_path,
guint n_entries,
GimpItemFactoryEntry *entries,
gpointer callback_data,
gboolean create_tearoff);
GtkItemFactory * gimp_item_factory_new (GType container_type,
const gchar *path,
const gchar *factory_path,
GimpItemFactoryUpdateFunc update_func,
guint n_entries,
GimpItemFactoryEntry *entries,
gpointer callback_data,
gboolean create_tearoff);
void gimp_item_factory_popup_with_data (GtkItemFactory *item_factory,
gpointer data,
GtkDestroyNotify popdown_func);
void gimp_item_factory_create_item (GtkItemFactory *item_factory,
GimpItemFactoryEntry *entry,

View File

@ -40,6 +40,7 @@
#include "gimpchannellistview.h"
#include "gimpdnd.h"
#include "gimpdrawablelistview.h"
#include "gimpitemfactory.h"
#include "gimplayerlistview.h"
#include "gimplistitem.h"
#include "gimppreview.h"
@ -256,6 +257,12 @@ gimp_drawable_list_view_destroy (GtkObject *object)
view->signal_name = NULL;
}
if (view->item_factory)
{
g_free (view->item_factory);
view->item_factory = NULL;
}
if (GTK_OBJECT_CLASS (parent_class)->destroy)
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
@ -274,7 +281,7 @@ gimp_drawable_list_view_new (gint preview_size,
GimpCopyDrawableFunc copy_drawable_func,
GimpNewDrawableFunc new_drawable_func,
GimpEditDrawableFunc edit_drawable_func,
GimpDrawableContextFunc drawable_context_func)
const gchar *item_factory)
{
GimpDrawableListView *list_view;
GimpContainerView *view;
@ -291,7 +298,7 @@ gimp_drawable_list_view_new (gint preview_size,
g_return_val_if_fail (copy_drawable_func != NULL, NULL);
g_return_val_if_fail (new_drawable_func != NULL, NULL);
g_return_val_if_fail (edit_drawable_func != NULL, NULL);
g_return_val_if_fail (drawable_context_func != NULL, NULL);
g_return_val_if_fail (item_factory != NULL, NULL);
if (drawable_type == GIMP_TYPE_LAYER)
{
@ -322,7 +329,8 @@ gimp_drawable_list_view_new (gint preview_size,
list_view->copy_drawable_func = copy_drawable_func;
list_view->new_drawable_func = new_drawable_func;
list_view->edit_drawable_func = edit_drawable_func;
list_view->drawable_context_func = drawable_context_func;
list_view->item_factory = g_strdup (item_factory);
/* connect "drop to new" manually as it makes a difference whether
* it was clicked or dropped
@ -495,13 +503,21 @@ gimp_drawable_list_view_context_item (GimpContainerView *view,
GimpViewable *item,
gpointer insert_data)
{
GtkItemFactory *factory;
if (GIMP_CONTAINER_VIEW_CLASS (parent_class)->context_item)
GIMP_CONTAINER_VIEW_CLASS (parent_class)->context_item (view,
item,
insert_data);
GIMP_DRAWABLE_LIST_VIEW (view)->drawable_context_func
(gimp_drawable_gimage (GIMP_DRAWABLE (item)));
factory = gtk_item_factory_from_path (GIMP_DRAWABLE_LIST_VIEW (view)->item_factory);
if (factory)
{
gimp_item_factory_popup_with_data (factory,
gimp_drawable_gimage (GIMP_DRAWABLE (item)),
NULL);
}
}

View File

@ -44,7 +44,6 @@ typedef GimpDrawable * (* GimpCopyDrawableFunc) (GimpDrawable *drawable,
typedef void (* GimpNewDrawableFunc) (GimpImage *gimage);
typedef void (* GimpEditDrawableFunc) (GimpDrawable *drawable);
typedef void (* GimpDrawableContextFunc) (GimpImage *gimage);
#define GIMP_TYPE_DRAWABLE_LIST_VIEW (gimp_drawable_list_view_get_type ())
@ -76,7 +75,8 @@ struct _GimpDrawableListView
GimpNewDrawableFunc new_drawable_func;
GimpEditDrawableFunc edit_drawable_func;
GimpDrawableContextFunc drawable_context_func;
gchar *item_factory;
GtkWidget *new_button;
GtkWidget *raise_button;
@ -110,7 +110,7 @@ GtkWidget * gimp_drawable_list_view_new (gint preview_s
GimpCopyDrawableFunc copy_drawable_func,
GimpNewDrawableFunc new_drawable_func,
GimpEditDrawableFunc edit_drawable_func,
GimpDrawableContextFunc drawable_context_func);
const gchar *item_factory);
void gimp_drawable_list_view_set_image (GimpDrawableListView *view,
GimpImage *gimage);

View File

@ -40,6 +40,7 @@
#include "gimpchannellistview.h"
#include "gimpdnd.h"
#include "gimpdrawablelistview.h"
#include "gimpitemfactory.h"
#include "gimplayerlistview.h"
#include "gimplistitem.h"
#include "gimppreview.h"
@ -256,6 +257,12 @@ gimp_drawable_list_view_destroy (GtkObject *object)
view->signal_name = NULL;
}
if (view->item_factory)
{
g_free (view->item_factory);
view->item_factory = NULL;
}
if (GTK_OBJECT_CLASS (parent_class)->destroy)
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
@ -274,7 +281,7 @@ gimp_drawable_list_view_new (gint preview_size,
GimpCopyDrawableFunc copy_drawable_func,
GimpNewDrawableFunc new_drawable_func,
GimpEditDrawableFunc edit_drawable_func,
GimpDrawableContextFunc drawable_context_func)
const gchar *item_factory)
{
GimpDrawableListView *list_view;
GimpContainerView *view;
@ -291,7 +298,7 @@ gimp_drawable_list_view_new (gint preview_size,
g_return_val_if_fail (copy_drawable_func != NULL, NULL);
g_return_val_if_fail (new_drawable_func != NULL, NULL);
g_return_val_if_fail (edit_drawable_func != NULL, NULL);
g_return_val_if_fail (drawable_context_func != NULL, NULL);
g_return_val_if_fail (item_factory != NULL, NULL);
if (drawable_type == GIMP_TYPE_LAYER)
{
@ -322,7 +329,8 @@ gimp_drawable_list_view_new (gint preview_size,
list_view->copy_drawable_func = copy_drawable_func;
list_view->new_drawable_func = new_drawable_func;
list_view->edit_drawable_func = edit_drawable_func;
list_view->drawable_context_func = drawable_context_func;
list_view->item_factory = g_strdup (item_factory);
/* connect "drop to new" manually as it makes a difference whether
* it was clicked or dropped
@ -495,13 +503,21 @@ gimp_drawable_list_view_context_item (GimpContainerView *view,
GimpViewable *item,
gpointer insert_data)
{
GtkItemFactory *factory;
if (GIMP_CONTAINER_VIEW_CLASS (parent_class)->context_item)
GIMP_CONTAINER_VIEW_CLASS (parent_class)->context_item (view,
item,
insert_data);
GIMP_DRAWABLE_LIST_VIEW (view)->drawable_context_func
(gimp_drawable_gimage (GIMP_DRAWABLE (item)));
factory = gtk_item_factory_from_path (GIMP_DRAWABLE_LIST_VIEW (view)->item_factory);
if (factory)
{
gimp_item_factory_popup_with_data (factory,
gimp_drawable_gimage (GIMP_DRAWABLE (item)),
NULL);
}
}

View File

@ -44,7 +44,6 @@ typedef GimpDrawable * (* GimpCopyDrawableFunc) (GimpDrawable *drawable,
typedef void (* GimpNewDrawableFunc) (GimpImage *gimage);
typedef void (* GimpEditDrawableFunc) (GimpDrawable *drawable);
typedef void (* GimpDrawableContextFunc) (GimpImage *gimage);
#define GIMP_TYPE_DRAWABLE_LIST_VIEW (gimp_drawable_list_view_get_type ())
@ -76,7 +75,8 @@ struct _GimpDrawableListView
GimpNewDrawableFunc new_drawable_func;
GimpEditDrawableFunc edit_drawable_func;
GimpDrawableContextFunc drawable_context_func;
gchar *item_factory;
GtkWidget *new_button;
GtkWidget *raise_button;
@ -110,7 +110,7 @@ GtkWidget * gimp_drawable_list_view_new (gint preview_s
GimpCopyDrawableFunc copy_drawable_func,
GimpNewDrawableFunc new_drawable_func,
GimpEditDrawableFunc edit_drawable_func,
GimpDrawableContextFunc drawable_context_func);
const gchar *item_factory);
void gimp_drawable_list_view_set_image (GimpDrawableListView *view,
GimpImage *gimage);

View File

@ -50,7 +50,6 @@
#include "color-area.h"
#include "devices.h"
#include "dialogs.h"
#include "dialogs-commands.h"
#include "indicator-area.h"
#include "app_procs.h"

View File

@ -188,7 +188,7 @@ gimp_menu_position (GtkMenu *menu,
gint screen_width;
gint screen_height;
g_return_if_fail (menu != NULL);
g_return_if_fail (GTK_IS_MENU (menu));
g_return_if_fail (x != NULL);
g_return_if_fail (y != NULL);
g_return_if_fail (button != NULL);
@ -228,29 +228,6 @@ gimp_menu_position (GtkMenu *menu,
}
}
void
gimp_item_factory_popup_with_data (GtkItemFactory *item_factory,
gpointer data)
{
gint x, y;
guint button;
guint32 activate_time;
g_return_if_fail (GTK_IS_ITEM_FACTORY (item_factory));
gimp_menu_position (GTK_MENU (item_factory->widget),
&x, &y,
&button,
&activate_time);
gtk_item_factory_popup_with_data (item_factory,
data,
NULL,
x, y,
button,
activate_time);
}
typedef struct _GimpAccelContextData GimpAccelContextData;

View File

@ -35,8 +35,6 @@ void gimp_menu_position (GtkMenu *menu,
gint *y,
guint *button,
guint32 *activate_time);
void gimp_item_factory_popup_with_data (GtkItemFactory *item_factory,
gpointer data);
void gimp_window_add_accel_group (GtkWindow *window,
GtkItemFactory *item_factory,

View File

@ -1,3 +1,7 @@
2001-11-30 Michael Natterer <mitch@gimp.org>
* POTFILES.in: updated.
2001-11-23 Simon Budig <simon@gimp.org>
* de.po: reverted one message.

View File

@ -36,7 +36,6 @@ app/display/gimpdisplay.c
app/display/gimpdisplayshell.c
app/display/gimpdisplayshell-callbacks.c
app/display/gimpdisplayshell-layer-select.c
app/display/gimpdisplayshell-qmask.c
app/file/file-open.c
app/file/file-save.c
@ -75,6 +74,7 @@ app/gui/palettes-commands.c
app/gui/paths-dialog.c
app/gui/pattern-select.c
app/gui/preferences-dialog.c
app/gui/qmask-commands.c
app/gui/resize-dialog.c
app/gui/resolution-calibrate-dialog.c
app/gui/select-commands.c