the active_tool may change in the middle of gdisplay_canvas_events(), so
2001-07-08 Michael Natterer <mitch@gimp.org> * app/disp_callbacks.c: the active_tool may change in the middle of gdisplay_canvas_events(), so re-get it after using it for cursor_update. * app/base/boundary.c: made some global variables local. * app/core/gimpdrawable.c: don't call gimp_drawable_set_visible() in gimp_drawable_configure() because we don't want signal emissions while configuring the drawable. * app/gui/Makefile.am * app/gui/brushes-commands.[ch] * app/gui/data-commands.[ch] * app/gui/gradients-commands.[ch] * app/gui/palettes-commands.[ch] * app/gui/patterns-commands.[ch]: new files for new new item factories' callbacks. * app/gui/menus.[ch]: added context menus for brushes, patterns, ... * app/gui/gradient-editor.c * app/gui/palette-editor.c: removed the "Save as POV", "Import Palette" and "Merge Palattes" buttons as they are item factory callbacks now. * app/widgets/gimpbrushfactoryview.[ch] * app/widgets/gimpbufferview.[ch] * app/widgets/gimpcontainereditor.[ch] * app/widgets/gimpdatafactoryview.[ch]: pass a "GimpContainerContextFunc" pointer to all GimpContainerEditor subclasses' constructors. Use the function to show the context menu. * app/widgets/gimpcontainergridview.c: dispatch the previews' "context" signal. * app/widgets/gimppreview.[ch]: new signal "context" which is emitted on right-click. * app/gui/brush-select.c * app/gui/dialogs-constructors.c * app/gui/gradient-select.c * app/gui/layers-commands.c * app/gui/palette-select.c * app/gui/pattern-select.c * app/gui/test-commands.c: changed accordingly.
This commit is contained in:

committed by
Michael Natterer

parent
37ce6b9ac8
commit
c56094201d
49
ChangeLog
49
ChangeLog
@ -1,3 +1,52 @@
|
||||
2001-07-08 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/disp_callbacks.c: the active_tool may change in the middle
|
||||
of gdisplay_canvas_events(), so re-get it after using it for
|
||||
cursor_update.
|
||||
|
||||
* app/base/boundary.c: made some global variables local.
|
||||
|
||||
* app/core/gimpdrawable.c: don't call gimp_drawable_set_visible()
|
||||
in gimp_drawable_configure() because we don't want signal
|
||||
emissions while configuring the drawable.
|
||||
|
||||
* app/gui/Makefile.am
|
||||
* app/gui/brushes-commands.[ch]
|
||||
* app/gui/data-commands.[ch]
|
||||
* app/gui/gradients-commands.[ch]
|
||||
* app/gui/palettes-commands.[ch]
|
||||
* app/gui/patterns-commands.[ch]: new files for new new item
|
||||
factories' callbacks.
|
||||
|
||||
* app/gui/menus.[ch]: added context menus for brushes, patterns, ...
|
||||
|
||||
* app/gui/gradient-editor.c
|
||||
* app/gui/palette-editor.c: removed the "Save as POV", "Import
|
||||
Palette" and "Merge Palattes" buttons as they are item factory
|
||||
callbacks now.
|
||||
|
||||
* app/widgets/gimpbrushfactoryview.[ch]
|
||||
* app/widgets/gimpbufferview.[ch]
|
||||
* app/widgets/gimpcontainereditor.[ch]
|
||||
* app/widgets/gimpdatafactoryview.[ch]: pass a
|
||||
"GimpContainerContextFunc" pointer to all GimpContainerEditor
|
||||
subclasses' constructors. Use the function to show the context
|
||||
menu.
|
||||
|
||||
* app/widgets/gimpcontainergridview.c: dispatch the previews'
|
||||
"context" signal.
|
||||
|
||||
* app/widgets/gimppreview.[ch]: new signal "context" which is
|
||||
emitted on right-click.
|
||||
|
||||
* app/gui/brush-select.c
|
||||
* app/gui/dialogs-constructors.c
|
||||
* app/gui/gradient-select.c
|
||||
* app/gui/layers-commands.c
|
||||
* app/gui/palette-select.c
|
||||
* app/gui/pattern-select.c
|
||||
* app/gui/test-commands.c: changed accordingly.
|
||||
|
||||
2001-07-08 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/Makefile.am
|
||||
|
116
app/actions/data-commands.c
Normal file
116
app/actions/data-commands.c
Normal file
@ -0,0 +1,116 @@
|
||||
/* 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 <gtk/gtk.h>
|
||||
|
||||
#include "widgets/widgets-types.h"
|
||||
|
||||
#include "widgets/gimpdatafactoryview.h"
|
||||
#include "widgets/gimpwidgets-utils.h"
|
||||
|
||||
#include "data-commands.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
void
|
||||
data_new_data_cmd_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GimpDataFactoryView *view;
|
||||
|
||||
view = (GimpDataFactoryView *) gimp_widget_get_callback_context (widget);
|
||||
|
||||
if (! view)
|
||||
return;
|
||||
|
||||
if (GTK_WIDGET_SENSITIVE (view->new_button))
|
||||
{
|
||||
gtk_button_clicked (GTK_BUTTON (view->new_button));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
data_duplicate_data_cmd_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GimpDataFactoryView *view;
|
||||
|
||||
view = (GimpDataFactoryView *) gimp_widget_get_callback_context (widget);
|
||||
|
||||
if (! view)
|
||||
return;
|
||||
|
||||
if (GTK_WIDGET_SENSITIVE (view->duplicate_button))
|
||||
{
|
||||
gtk_button_clicked (GTK_BUTTON (view->duplicate_button));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
data_edit_data_cmd_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GimpDataFactoryView *view;
|
||||
|
||||
view = (GimpDataFactoryView *) gimp_widget_get_callback_context (widget);
|
||||
|
||||
if (! view)
|
||||
return;
|
||||
|
||||
if (GTK_WIDGET_SENSITIVE (view->edit_button))
|
||||
{
|
||||
gtk_button_clicked (GTK_BUTTON (view->edit_button));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
data_delete_data_cmd_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GimpDataFactoryView *view;
|
||||
|
||||
view = (GimpDataFactoryView *) gimp_widget_get_callback_context (widget);
|
||||
|
||||
if (! view)
|
||||
return;
|
||||
|
||||
if (GTK_WIDGET_SENSITIVE (view->delete_button))
|
||||
{
|
||||
gtk_button_clicked (GTK_BUTTON (view->delete_button));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
data_refresh_data_cmd_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GimpDataFactoryView *view;
|
||||
|
||||
view = (GimpDataFactoryView *) gimp_widget_get_callback_context (widget);
|
||||
|
||||
if (! view)
|
||||
return;
|
||||
|
||||
if (GTK_WIDGET_SENSITIVE (view->refresh_button))
|
||||
{
|
||||
gtk_button_clicked (GTK_BUTTON (view->refresh_button));
|
||||
}
|
||||
}
|
35
app/actions/data-commands.h
Normal file
35
app/actions/data-commands.h
Normal file
@ -0,0 +1,35 @@
|
||||
/* 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 __DATA_COMMANDS_H__
|
||||
#define __DATA_COMMANDS_H__
|
||||
|
||||
|
||||
void data_new_data_cmd_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
void data_duplicate_data_cmd_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
void data_edit_data_cmd_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
void data_delete_data_cmd_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
void data_refresh_data_cmd_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
|
||||
#endif /* __DATA_COMMANDS_H__ */
|
217
app/actions/gradients-commands.c
Normal file
217
app/actions/gradients-commands.c
Normal file
@ -0,0 +1,217 @@
|
||||
/* 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 <stdio.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "widgets/widgets-types.h"
|
||||
|
||||
#include "core/gimpgradient.h"
|
||||
#include "core/gimpcontext.h"
|
||||
|
||||
#include "widgets/gimpcontainerview.h"
|
||||
#include "widgets/gimpdatafactoryview.h"
|
||||
#include "widgets/gimpwidgets-utils.h"
|
||||
|
||||
#include "gradients-commands.h"
|
||||
#include "menus.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
/* 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);
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
||||
void
|
||||
gradients_save_as_pov_ray_cmd_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GimpContainerEditor *editor;
|
||||
|
||||
editor = (GimpContainerEditor *) gimp_widget_get_callback_context (widget);
|
||||
|
||||
if (! editor)
|
||||
return;
|
||||
|
||||
gradients_save_as_pov_query (editor);
|
||||
}
|
||||
|
||||
void
|
||||
gradients_show_context_menu (GimpContainerEditor *editor)
|
||||
{
|
||||
GtkItemFactory *item_factory;
|
||||
gint x, y;
|
||||
|
||||
gradients_menu_set_sensitivity (editor);
|
||||
|
||||
item_factory = menus_get_gradients_factory ();
|
||||
|
||||
gimp_menu_position (GTK_MENU (item_factory->widget), &x, &y);
|
||||
|
||||
gtk_item_factory_popup_with_data (item_factory,
|
||||
editor,
|
||||
NULL,
|
||||
x, y,
|
||||
3, 0);
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
static void
|
||||
gradients_menu_set_sensitivity (GimpContainerEditor *editor)
|
||||
{
|
||||
GimpGradient *gradient;
|
||||
|
||||
gradient = gimp_context_get_gradient (editor->view->context);
|
||||
|
||||
#define SET_SENSITIVE(menu,condition) \
|
||||
menus_set_sensitive ("<Gradients>/" menu, (condition) != 0)
|
||||
|
||||
SET_SENSITIVE ("Duplicate Gradient",
|
||||
gradient && GIMP_DATA_CLASS (GTK_OBJECT (gradient)->klass)->duplicate);
|
||||
SET_SENSITIVE ("Edit Gradient...",
|
||||
gradient && GIMP_DATA_FACTORY_VIEW (editor)->data_edit_func);
|
||||
SET_SENSITIVE ("Delete Gradient...",
|
||||
gradient);
|
||||
SET_SENSITIVE ("Save as POV-Ray...",
|
||||
gradient);
|
||||
|
||||
#undef SET_SENSITIVE
|
||||
}
|
||||
|
||||
static void
|
||||
gradients_save_as_pov_query (GimpContainerEditor *editor)
|
||||
{
|
||||
GimpGradient *gradient;
|
||||
GtkFileSelection *filesel;
|
||||
gchar *title;
|
||||
|
||||
gradient = gimp_context_get_gradient (editor->view->context);
|
||||
|
||||
if (! gradient)
|
||||
return;
|
||||
|
||||
title = g_strdup_printf (_("Save \"%s\" as POV-Ray"),
|
||||
GIMP_OBJECT (gradient)->name);
|
||||
|
||||
filesel = GTK_FILE_SELECTION (gtk_file_selection_new (title));
|
||||
|
||||
g_free (title);
|
||||
|
||||
gtk_window_set_wmclass (GTK_WINDOW (filesel), "save_gradient", "Gimp");
|
||||
gtk_window_set_position (GTK_WINDOW (filesel), GTK_WIN_POS_MOUSE);
|
||||
|
||||
gtk_container_set_border_width (GTK_CONTAINER (filesel), 2);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (filesel->button_area), 2);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (filesel->ok_button), "clicked",
|
||||
GTK_SIGNAL_FUNC (gradients_save_as_pov_ok_callback),
|
||||
gradient);
|
||||
|
||||
gtk_signal_connect_object (GTK_OBJECT (filesel->cancel_button), "clicked",
|
||||
GTK_SIGNAL_FUNC (gtk_widget_destroy),
|
||||
GTK_OBJECT (filesel));
|
||||
|
||||
gtk_signal_connect_object (GTK_OBJECT (filesel), "delete_event",
|
||||
GTK_SIGNAL_FUNC (gtk_widget_destroy),
|
||||
GTK_OBJECT (filesel));
|
||||
|
||||
gtk_object_ref (GTK_OBJECT (gradient));
|
||||
|
||||
gtk_signal_connect_object (GTK_OBJECT (filesel), "destroy",
|
||||
GTK_SIGNAL_FUNC (gtk_object_unref),
|
||||
GTK_OBJECT (gradient));
|
||||
|
||||
/* Connect the "F1" help key */
|
||||
gimp_help_connect_help_accel (GTK_WIDGET (filesel), gimp_standard_help_func,
|
||||
"dialogs/save_as_povray.html");
|
||||
|
||||
gtk_widget_show (GTK_WIDGET (filesel));
|
||||
}
|
||||
|
||||
static void
|
||||
gradients_save_as_pov_ok_callback (GtkWidget *widget,
|
||||
GimpGradient *gradient)
|
||||
{
|
||||
GtkFileSelection *filesel;
|
||||
gchar *filename;
|
||||
FILE *file;
|
||||
GimpGradientSegment *seg;
|
||||
|
||||
filesel = GTK_FILE_SELECTION (gtk_widget_get_toplevel (widget));
|
||||
filename = gtk_file_selection_get_filename (filesel);
|
||||
|
||||
file = fopen (filename, "wb");
|
||||
|
||||
if (!file)
|
||||
{
|
||||
g_message ("Could not open \"%s\"", filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf (file, "/* color_map file created by the GIMP */\n");
|
||||
fprintf (file, "/* http://www.gimp.org/ */\n");
|
||||
|
||||
fprintf (file, "color_map {\n");
|
||||
|
||||
for (seg = gradient->segments; seg; seg = seg->next)
|
||||
{
|
||||
/* Left */
|
||||
fprintf (file, "\t[%f color rgbt <%f, %f, %f, %f>]\n",
|
||||
seg->left,
|
||||
seg->left_color.r,
|
||||
seg->left_color.g,
|
||||
seg->left_color.b,
|
||||
1.0 - seg->left_color.a);
|
||||
|
||||
/* Middle */
|
||||
fprintf (file, "\t[%f color rgbt <%f, %f, %f, %f>]\n",
|
||||
seg->middle,
|
||||
(seg->left_color.r + seg->right_color.r) / 2.0,
|
||||
(seg->left_color.g + seg->right_color.g) / 2.0,
|
||||
(seg->left_color.b + seg->right_color.b) / 2.0,
|
||||
1.0 - (seg->left_color.a + seg->right_color.a) / 2.0);
|
||||
|
||||
/* Right */
|
||||
fprintf (file, "\t[%f color rgbt <%f, %f, %f, %f>]\n",
|
||||
seg->right,
|
||||
seg->right_color.r,
|
||||
seg->right_color.g,
|
||||
seg->right_color.b,
|
||||
1.0 - seg->right_color.a);
|
||||
}
|
||||
|
||||
fprintf (file, "} /* color_map */\n");
|
||||
fclose (file);
|
||||
}
|
||||
|
||||
gtk_widget_destroy (GTK_WIDGET (filesel));
|
||||
}
|
30
app/actions/gradients-commands.h
Normal file
30
app/actions/gradients-commands.h
Normal 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 __GRADIENTS_COMMANDS_H__
|
||||
#define __GRADIENTS_COMMANDS_H__
|
||||
|
||||
|
||||
void gradients_save_as_pov_ray_cmd_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
|
||||
void gradients_show_context_menu (GimpContainerEditor *editor);
|
||||
|
||||
|
||||
#endif /* __GRADIENTS_COMMANDS_H__ */
|
@ -1221,7 +1221,8 @@ layers_show_context_menu (GimpImage *gimage)
|
||||
gimp_menu_position (GTK_MENU (item_factory->widget), &x, &y);
|
||||
|
||||
gtk_item_factory_popup_with_data (item_factory,
|
||||
gimage, NULL,
|
||||
gimage,
|
||||
NULL,
|
||||
x, y,
|
||||
3, 0);
|
||||
}
|
||||
|
192
app/actions/palettes-commands.c
Normal file
192
app/actions/palettes-commands.c
Normal file
@ -0,0 +1,192 @@
|
||||
/* 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 <gtk/gtk.h>
|
||||
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "widgets/widgets-types.h"
|
||||
|
||||
#include "core/gimppalette.h"
|
||||
#include "core/gimpcontainer.h"
|
||||
#include "core/gimpcontext.h"
|
||||
|
||||
#include "widgets/gimpcontainerlistview.h"
|
||||
#include "widgets/gimpdatafactoryview.h"
|
||||
#include "widgets/gimplistitem.h"
|
||||
#include "widgets/gimppreview.h"
|
||||
#include "widgets/gimpwidgets-utils.h"
|
||||
|
||||
#include "palette-import-dialog.h"
|
||||
#include "palettes-commands.h"
|
||||
#include "menus.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
/* 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,
|
||||
gpointer data);
|
||||
|
||||
|
||||
/* public functionss */
|
||||
|
||||
void
|
||||
palettes_import_palette_cmd_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GimpContainerEditor *editor;
|
||||
|
||||
editor = (GimpContainerEditor *) gimp_widget_get_callback_context (widget);
|
||||
|
||||
if (! editor)
|
||||
return;
|
||||
|
||||
palette_import_dialog_show ();
|
||||
}
|
||||
|
||||
void
|
||||
palettes_merge_palettes_cmd_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GimpContainerEditor *editor;
|
||||
|
||||
editor = (GimpContainerEditor *) gimp_widget_get_callback_context (widget);
|
||||
|
||||
if (! editor)
|
||||
return;
|
||||
|
||||
palettes_merge_palettes_query (editor);
|
||||
}
|
||||
|
||||
void
|
||||
palettes_show_context_menu (GimpContainerEditor *editor)
|
||||
{
|
||||
GtkItemFactory *item_factory;
|
||||
gint x, y;
|
||||
|
||||
palettes_menu_set_sensitivity (editor);
|
||||
|
||||
item_factory = menus_get_palettes_factory ();
|
||||
|
||||
gimp_menu_position (GTK_MENU (item_factory->widget), &x, &y);
|
||||
|
||||
gtk_item_factory_popup_with_data (item_factory,
|
||||
editor,
|
||||
NULL,
|
||||
x, y,
|
||||
3, 0);
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
static void
|
||||
palettes_menu_set_sensitivity (GimpContainerEditor *editor)
|
||||
{
|
||||
GimpPalette *palette;
|
||||
|
||||
palette = gimp_context_get_palette (editor->view->context);
|
||||
|
||||
#define SET_SENSITIVE(menu,condition) \
|
||||
menus_set_sensitive ("<Palettes>/" menu, (condition) != 0)
|
||||
|
||||
SET_SENSITIVE ("Duplicate Palette",
|
||||
palette && GIMP_DATA_CLASS (GTK_OBJECT (palette)->klass)->duplicate);
|
||||
SET_SENSITIVE ("Edit Palette...",
|
||||
palette && GIMP_DATA_FACTORY_VIEW (editor)->data_edit_func);
|
||||
SET_SENSITIVE ("Delete Palette...",
|
||||
palette);
|
||||
SET_SENSITIVE ("Merge Palettes...",
|
||||
FALSE); /* FIXME palette && GIMP_IS_CONTAINER_LIST_VIEW (editor->view)); */
|
||||
|
||||
#undef SET_SENSITIVE
|
||||
}
|
||||
|
||||
static void
|
||||
palettes_merge_palettes_query (GimpContainerEditor *editor)
|
||||
{
|
||||
GtkWidget *qbox;
|
||||
|
||||
qbox = gimp_query_string_box (_("Merge Palette"),
|
||||
gimp_standard_help_func,
|
||||
"dialogs/palette_editor/merge_palette.html",
|
||||
_("Enter a name for merged palette"),
|
||||
NULL,
|
||||
GTK_OBJECT (editor), "destroy",
|
||||
palettes_merge_palettes_callback,
|
||||
editor);
|
||||
gtk_widget_show (qbox);
|
||||
}
|
||||
|
||||
static void
|
||||
palettes_merge_palettes_callback (GtkWidget *widget,
|
||||
gchar *palette_name,
|
||||
gpointer data)
|
||||
{
|
||||
GimpContainerEditor *editor;
|
||||
GimpPalette *palette;
|
||||
GimpPalette *new_palette;
|
||||
GimpPaletteEntry *entry;
|
||||
GList *sel_list;
|
||||
|
||||
editor = (GimpContainerEditor *) data;
|
||||
|
||||
sel_list = GTK_LIST (GIMP_CONTAINER_LIST_VIEW (editor->view)->gtk_list)->selection;
|
||||
|
||||
if (! sel_list)
|
||||
{
|
||||
g_message ("Can't merge palettes because there are no palettes selected.");
|
||||
return;
|
||||
}
|
||||
|
||||
new_palette = GIMP_PALETTE (gimp_palette_new (palette_name));
|
||||
|
||||
while (sel_list)
|
||||
{
|
||||
GimpListItem *list_item;
|
||||
GList *cols;
|
||||
|
||||
list_item = GIMP_LIST_ITEM (sel_list->data);
|
||||
|
||||
palette = (GimpPalette *) GIMP_PREVIEW (list_item->preview)->viewable;
|
||||
|
||||
if (palette)
|
||||
{
|
||||
for (cols = palette->colors; cols; cols = g_list_next (cols))
|
||||
{
|
||||
entry = (GimpPaletteEntry *) cols->data;
|
||||
|
||||
gimp_palette_add_entry (new_palette,
|
||||
entry->name,
|
||||
&entry->color);
|
||||
}
|
||||
}
|
||||
|
||||
sel_list = sel_list->next;
|
||||
}
|
||||
|
||||
gimp_container_add (editor->view->container,
|
||||
GIMP_OBJECT (new_palette));
|
||||
}
|
32
app/actions/palettes-commands.h
Normal file
32
app/actions/palettes-commands.h
Normal file
@ -0,0 +1,32 @@
|
||||
/* 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 __PALETTES_COMMANDS_H__
|
||||
#define __PALETTES_COMMANDS_H__
|
||||
|
||||
|
||||
void palettes_import_palette_cmd_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
void palettes_merge_palettes_cmd_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
|
||||
void palettes_show_context_menu (GimpContainerEditor *editor);
|
||||
|
||||
|
||||
#endif /* __PALETTES_COMMANDS_H__ */
|
@ -47,16 +47,10 @@ static gint max_segs = 0;
|
||||
|
||||
/* static empty segment arrays */
|
||||
static gint *empty_segs_n = NULL;
|
||||
static gint num_empty_n = 0;
|
||||
static gint *empty_segs_c = NULL;
|
||||
static gint num_empty_c = 0;
|
||||
static gint *empty_segs_l = NULL;
|
||||
static gint num_empty_l = 0;
|
||||
static gint max_empty_segs = 0;
|
||||
|
||||
/* global state variables--improve parameter efficiency */
|
||||
static PixelRegion *cur_PR = NULL;
|
||||
|
||||
|
||||
/* local function prototypes */
|
||||
static void find_empty_segs (PixelRegion *maskPR,
|
||||
@ -74,8 +68,8 @@ static void make_seg (gint x1,
|
||||
gint x2,
|
||||
gint y2,
|
||||
gboolean open);
|
||||
static void allocate_vert_segs (void);
|
||||
static void allocate_empty_segs (void);
|
||||
static void allocate_vert_segs (PixelRegion *PR);
|
||||
static void allocate_empty_segs (PixelRegion *PR);
|
||||
static void process_horiz_seg (gint x1,
|
||||
gint y1,
|
||||
gint x2,
|
||||
@ -87,7 +81,8 @@ static void make_horiz_segs (gint start,
|
||||
gint empty[],
|
||||
gint num_empty,
|
||||
gint top);
|
||||
static void generate_boundary (BoundaryType type,
|
||||
static void generate_boundary (PixelRegion *PR,
|
||||
BoundaryType type,
|
||||
gint x1,
|
||||
gint y1,
|
||||
gint x2,
|
||||
@ -248,26 +243,26 @@ make_seg (gint x1,
|
||||
|
||||
|
||||
static void
|
||||
allocate_vert_segs (void)
|
||||
allocate_vert_segs (PixelRegion *PR)
|
||||
{
|
||||
gint i;
|
||||
|
||||
/* allocate and initialize the vert_segs array */
|
||||
vert_segs = (gint *) g_realloc ((void *) vert_segs,
|
||||
(cur_PR->w + cur_PR->x + 1) * sizeof (gint));
|
||||
(PR->w + PR->x + 1) * sizeof (gint));
|
||||
|
||||
for (i = 0; i <= (cur_PR->w + cur_PR->x); i++)
|
||||
for (i = 0; i <= (PR->w + PR->x); i++)
|
||||
vert_segs[i] = -1;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
allocate_empty_segs (void)
|
||||
allocate_empty_segs (PixelRegion *PR)
|
||||
{
|
||||
gint need_num_segs;
|
||||
|
||||
/* find the maximum possible number of empty segments given the current mask */
|
||||
need_num_segs = cur_PR->w + 3;
|
||||
need_num_segs = PR->w + 3;
|
||||
|
||||
if (need_num_segs > max_empty_segs)
|
||||
{
|
||||
@ -336,7 +331,8 @@ make_horiz_segs (gint start,
|
||||
|
||||
|
||||
static void
|
||||
generate_boundary (BoundaryType type,
|
||||
generate_boundary (PixelRegion *PR,
|
||||
BoundaryType type,
|
||||
gint x1,
|
||||
gint y1,
|
||||
gint x2,
|
||||
@ -347,14 +343,18 @@ generate_boundary (BoundaryType type,
|
||||
gint start, end;
|
||||
gint *tmp_segs;
|
||||
|
||||
gint num_empty_n = 0;
|
||||
gint num_empty_c = 0;
|
||||
gint num_empty_l = 0;
|
||||
|
||||
start = 0;
|
||||
end = 0;
|
||||
|
||||
/* array for determining the vertical line segments which must be drawn */
|
||||
allocate_vert_segs ();
|
||||
allocate_vert_segs (PR);
|
||||
|
||||
/* make sure there is enough space for the empty segment array */
|
||||
allocate_empty_segs ();
|
||||
allocate_empty_segs (PR);
|
||||
|
||||
num_segs = 0;
|
||||
|
||||
@ -365,22 +365,22 @@ generate_boundary (BoundaryType type,
|
||||
}
|
||||
else if (type == IgnoreBounds)
|
||||
{
|
||||
start = cur_PR->y;
|
||||
end = cur_PR->y + cur_PR->h;
|
||||
start = PR->y;
|
||||
end = PR->y + PR->h;
|
||||
}
|
||||
|
||||
/* Find the empty segments for the previous and current scanlines */
|
||||
find_empty_segs (cur_PR, start - 1, empty_segs_l,
|
||||
find_empty_segs (PR, start - 1, empty_segs_l,
|
||||
max_empty_segs, &num_empty_l,
|
||||
type, x1, y1, x2, y2);
|
||||
find_empty_segs (cur_PR, start, empty_segs_c,
|
||||
find_empty_segs (PR, start, empty_segs_c,
|
||||
max_empty_segs, &num_empty_c,
|
||||
type, x1, y1, x2, y2);
|
||||
|
||||
for (scanline = start; scanline < end; scanline++)
|
||||
{
|
||||
/* find the empty segment list for the next scanline */
|
||||
find_empty_segs (cur_PR, scanline + 1, empty_segs_n,
|
||||
find_empty_segs (PR, scanline + 1, empty_segs_n,
|
||||
max_empty_segs, &num_empty_n,
|
||||
type, x1, y1, x2, y2);
|
||||
|
||||
@ -413,16 +413,15 @@ find_mask_boundary (PixelRegion *maskPR,
|
||||
int x2,
|
||||
int y2)
|
||||
{
|
||||
BoundSeg * new_segs = NULL;
|
||||
BoundSeg *new_segs = NULL;
|
||||
|
||||
/* The mask paramater can be any PixelRegion. If the region
|
||||
* has more than 1 bytes/pixel, the last byte of each pixel is
|
||||
* used to determine the boundary outline.
|
||||
*/
|
||||
cur_PR = maskPR;
|
||||
|
||||
/* Calculate the boundary */
|
||||
generate_boundary (type, x1, y1, x2, y2);
|
||||
generate_boundary (maskPR, type, x1, y1, x2, y2);
|
||||
|
||||
/* Set the number of X segments */
|
||||
*num_elems = num_segs;
|
||||
@ -466,11 +465,11 @@ sort_boundary (BoundSeg *segs,
|
||||
gint ns,
|
||||
gint *num_groups)
|
||||
{
|
||||
gint i;
|
||||
gint index;
|
||||
gint x, y;
|
||||
gint startx, starty;
|
||||
gint empty = (num_segs == 0);
|
||||
gint i;
|
||||
gint index;
|
||||
gint x, y;
|
||||
gint startx, starty;
|
||||
gint empty = (num_segs == 0);
|
||||
BoundSeg *new_segs;
|
||||
|
||||
index = 0;
|
||||
|
@ -365,7 +365,7 @@ gimp_drawable_configure (GimpDrawable *drawable,
|
||||
|
||||
drawable->tiles = tile_manager_new (width, height, bpp);
|
||||
|
||||
gimp_drawable_set_visible (drawable, TRUE);
|
||||
drawable->visible = TRUE;
|
||||
|
||||
if (gimage)
|
||||
gimp_drawable_set_gimage (drawable, gimage);
|
||||
|
@ -51,6 +51,7 @@
|
||||
#include "about-dialog.h"
|
||||
#include "brush-editor.h"
|
||||
#include "brush-select.h"
|
||||
#include "brushes-commands.h"
|
||||
#include "channels-commands.h"
|
||||
#include "color-area.h"
|
||||
#include "colormap-dialog.h"
|
||||
@ -61,10 +62,14 @@
|
||||
#include "gdisplay.h"
|
||||
#include "gradient-editor.h"
|
||||
#include "gradient-select.h"
|
||||
#include "gradients-commands.h"
|
||||
#include "layers-commands.h"
|
||||
#include "menus.h"
|
||||
#include "palette-editor.h"
|
||||
#include "palettes-commands.h"
|
||||
#include "paths-dialog.h"
|
||||
#include "pattern-select.h"
|
||||
#include "patterns-commands.h"
|
||||
#include "preferences-dialog.h"
|
||||
#include "tips-dialog.h"
|
||||
#include "tool-options-dialog.h"
|
||||
@ -321,7 +326,8 @@ dialogs_brush_list_view_new (GimpDialogFactory *factory,
|
||||
context,
|
||||
TRUE,
|
||||
32,
|
||||
5, 3);
|
||||
5, 3,
|
||||
brushes_show_context_menu);
|
||||
|
||||
return dialogs_dockable_new (view,
|
||||
"Brush List", "Brushes",
|
||||
@ -340,7 +346,8 @@ dialogs_pattern_list_view_new (GimpDialogFactory *factory,
|
||||
NULL,
|
||||
context,
|
||||
32,
|
||||
5, 3);
|
||||
5, 3,
|
||||
patterns_show_context_menu);
|
||||
|
||||
return dialogs_dockable_new (view,
|
||||
"Pattern List", "Patterns",
|
||||
@ -359,7 +366,8 @@ dialogs_gradient_list_view_new (GimpDialogFactory *factory,
|
||||
dialogs_edit_gradient_func,
|
||||
context,
|
||||
32 / 2,
|
||||
5, 3);
|
||||
5, 3,
|
||||
gradients_show_context_menu);
|
||||
|
||||
return dialogs_dockable_new (view,
|
||||
"Gradient List", "Gradients",
|
||||
@ -378,7 +386,8 @@ dialogs_palette_list_view_new (GimpDialogFactory *factory,
|
||||
dialogs_edit_palette_func,
|
||||
context,
|
||||
32,
|
||||
5, 3);
|
||||
5, 3,
|
||||
palettes_show_context_menu);
|
||||
|
||||
return dialogs_dockable_new (view,
|
||||
"Palette List", "Palettes",
|
||||
@ -413,7 +422,8 @@ dialogs_buffer_list_view_new (GimpDialogFactory *factory,
|
||||
context->gimp->named_buffers,
|
||||
context,
|
||||
32,
|
||||
5, 3);
|
||||
5, 3,
|
||||
NULL);
|
||||
|
||||
return dialogs_dockable_new (view,
|
||||
"Buffer List", "Buffers",
|
||||
@ -453,7 +463,8 @@ dialogs_brush_grid_view_new (GimpDialogFactory *factory,
|
||||
context,
|
||||
TRUE,
|
||||
32,
|
||||
5, 3);
|
||||
5, 3,
|
||||
brushes_show_context_menu);
|
||||
|
||||
return dialogs_dockable_new (view,
|
||||
"Brush Grid", "Brushes",
|
||||
@ -472,7 +483,8 @@ dialogs_pattern_grid_view_new (GimpDialogFactory *factory,
|
||||
NULL,
|
||||
context,
|
||||
32,
|
||||
5, 3);
|
||||
5, 3,
|
||||
patterns_show_context_menu);
|
||||
|
||||
return dialogs_dockable_new (view,
|
||||
"Pattern Grid", "Patterns",
|
||||
@ -491,7 +503,8 @@ dialogs_gradient_grid_view_new (GimpDialogFactory *factory,
|
||||
dialogs_edit_gradient_func,
|
||||
context,
|
||||
32,
|
||||
5, 3);
|
||||
5, 3,
|
||||
gradients_show_context_menu);
|
||||
|
||||
return dialogs_dockable_new (view,
|
||||
"Gradient Grid", "Gradients",
|
||||
@ -510,7 +523,8 @@ dialogs_palette_grid_view_new (GimpDialogFactory *factory,
|
||||
dialogs_edit_palette_func,
|
||||
context,
|
||||
32,
|
||||
5, 3);
|
||||
5, 3,
|
||||
palettes_show_context_menu);
|
||||
|
||||
return dialogs_dockable_new (view,
|
||||
"Palette Grid", "Palettes",
|
||||
@ -545,7 +559,8 @@ dialogs_buffer_grid_view_new (GimpDialogFactory *factory,
|
||||
context->gimp->named_buffers,
|
||||
context,
|
||||
32,
|
||||
5, 3);
|
||||
5, 3,
|
||||
NULL);
|
||||
|
||||
return dialogs_dockable_new (view,
|
||||
"Buffer Grid", "Buffers",
|
||||
|
@ -231,20 +231,19 @@ gdisplay_canvas_events (GtkWidget *canvas,
|
||||
{
|
||||
case GDK_EXPOSE:
|
||||
eevent = (GdkEventExpose *) event;
|
||||
/*printf(" EXP:%d,%d(%dx%d) ",eevent->area.x, eevent->area.y,
|
||||
eevent->area.width, eevent->area.height);fflush(stdout);*/
|
||||
|
||||
gdisplay_redraw (gdisp,
|
||||
eevent->area.x, eevent->area.y,
|
||||
eevent->area.width, eevent->area.height);
|
||||
break;
|
||||
|
||||
case GDK_CONFIGURE:
|
||||
/*printf(" CNF ");fflush(stdout);*/
|
||||
if ((gdisp->disp_width != gdisp->canvas->allocation.width) ||
|
||||
if ((gdisp->disp_width != gdisp->canvas->allocation.width) ||
|
||||
(gdisp->disp_height != gdisp->canvas->allocation.height))
|
||||
{
|
||||
gdisp->disp_width = gdisp->canvas->allocation.width;
|
||||
gdisp->disp_width = gdisp->canvas->allocation.width;
|
||||
gdisp->disp_height = gdisp->canvas->allocation.height;
|
||||
|
||||
resize_display (gdisp, FALSE, FALSE);
|
||||
}
|
||||
break;
|
||||
@ -288,8 +287,6 @@ gdisplay_canvas_events (GtkWidget *canvas,
|
||||
* guaranteed to work in future versions of GTK.
|
||||
* -Yosh
|
||||
*/
|
||||
|
||||
|
||||
if (key_signal_id == 0)
|
||||
key_signal_id = gtk_signal_connect (GTK_OBJECT (canvas),
|
||||
"key_press_event",
|
||||
@ -544,16 +541,16 @@ gdisplay_canvas_events (GtkWidget *canvas,
|
||||
grab_and_scroll (gdisp, mevent);
|
||||
}
|
||||
|
||||
/* Operator update support: Bug #XXXX */
|
||||
|
||||
if (/* Should we have a tool... */
|
||||
if (/* Should we have a tool... */
|
||||
active_tool &&
|
||||
/* and this event is NOT driving */
|
||||
/* button press handlers ... */
|
||||
/* and this event is NOT driving
|
||||
* button press handlers ...
|
||||
*/
|
||||
!(state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK)))
|
||||
{
|
||||
/* ...then preconditions to modify a tool */
|
||||
/* operator state have been met. */
|
||||
/* ...then preconditions to modify a tool
|
||||
* operator state have been met.
|
||||
*/
|
||||
gimp_tool_oper_update (active_tool, mevent, gdisp);
|
||||
}
|
||||
|
||||
@ -587,8 +584,8 @@ gdisplay_canvas_events (GtkWidget *canvas,
|
||||
layer_select_init (gdisp->gimage, -1, kevent->time);
|
||||
|
||||
/* Hide or show all dialogs */
|
||||
if (!kevent->state)
|
||||
dialog_toggle();
|
||||
if (! kevent->state)
|
||||
dialog_toggle ();
|
||||
|
||||
return_val = TRUE;
|
||||
break;
|
||||
@ -653,6 +650,8 @@ gdisplay_canvas_events (GtkWidget *canvas,
|
||||
|
||||
if (gimprc.no_cursor_updating == 0)
|
||||
{
|
||||
active_tool = tool_manager_get_active (gdisp->gimage->gimp);
|
||||
|
||||
if (active_tool && !gimp_image_is_empty (gdisp->gimage) &&
|
||||
!(state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK)))
|
||||
{
|
||||
|
@ -231,20 +231,19 @@ gdisplay_canvas_events (GtkWidget *canvas,
|
||||
{
|
||||
case GDK_EXPOSE:
|
||||
eevent = (GdkEventExpose *) event;
|
||||
/*printf(" EXP:%d,%d(%dx%d) ",eevent->area.x, eevent->area.y,
|
||||
eevent->area.width, eevent->area.height);fflush(stdout);*/
|
||||
|
||||
gdisplay_redraw (gdisp,
|
||||
eevent->area.x, eevent->area.y,
|
||||
eevent->area.width, eevent->area.height);
|
||||
break;
|
||||
|
||||
case GDK_CONFIGURE:
|
||||
/*printf(" CNF ");fflush(stdout);*/
|
||||
if ((gdisp->disp_width != gdisp->canvas->allocation.width) ||
|
||||
if ((gdisp->disp_width != gdisp->canvas->allocation.width) ||
|
||||
(gdisp->disp_height != gdisp->canvas->allocation.height))
|
||||
{
|
||||
gdisp->disp_width = gdisp->canvas->allocation.width;
|
||||
gdisp->disp_width = gdisp->canvas->allocation.width;
|
||||
gdisp->disp_height = gdisp->canvas->allocation.height;
|
||||
|
||||
resize_display (gdisp, FALSE, FALSE);
|
||||
}
|
||||
break;
|
||||
@ -288,8 +287,6 @@ gdisplay_canvas_events (GtkWidget *canvas,
|
||||
* guaranteed to work in future versions of GTK.
|
||||
* -Yosh
|
||||
*/
|
||||
|
||||
|
||||
if (key_signal_id == 0)
|
||||
key_signal_id = gtk_signal_connect (GTK_OBJECT (canvas),
|
||||
"key_press_event",
|
||||
@ -544,16 +541,16 @@ gdisplay_canvas_events (GtkWidget *canvas,
|
||||
grab_and_scroll (gdisp, mevent);
|
||||
}
|
||||
|
||||
/* Operator update support: Bug #XXXX */
|
||||
|
||||
if (/* Should we have a tool... */
|
||||
if (/* Should we have a tool... */
|
||||
active_tool &&
|
||||
/* and this event is NOT driving */
|
||||
/* button press handlers ... */
|
||||
/* and this event is NOT driving
|
||||
* button press handlers ...
|
||||
*/
|
||||
!(state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK)))
|
||||
{
|
||||
/* ...then preconditions to modify a tool */
|
||||
/* operator state have been met. */
|
||||
/* ...then preconditions to modify a tool
|
||||
* operator state have been met.
|
||||
*/
|
||||
gimp_tool_oper_update (active_tool, mevent, gdisp);
|
||||
}
|
||||
|
||||
@ -587,8 +584,8 @@ gdisplay_canvas_events (GtkWidget *canvas,
|
||||
layer_select_init (gdisp->gimage, -1, kevent->time);
|
||||
|
||||
/* Hide or show all dialogs */
|
||||
if (!kevent->state)
|
||||
dialog_toggle();
|
||||
if (! kevent->state)
|
||||
dialog_toggle ();
|
||||
|
||||
return_val = TRUE;
|
||||
break;
|
||||
@ -653,6 +650,8 @@ gdisplay_canvas_events (GtkWidget *canvas,
|
||||
|
||||
if (gimprc.no_cursor_updating == 0)
|
||||
{
|
||||
active_tool = tool_manager_get_active (gdisp->gimage->gimp);
|
||||
|
||||
if (active_tool && !gimp_image_is_empty (gdisp->gimage) &&
|
||||
!(state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK)))
|
||||
{
|
||||
|
@ -231,20 +231,19 @@ gdisplay_canvas_events (GtkWidget *canvas,
|
||||
{
|
||||
case GDK_EXPOSE:
|
||||
eevent = (GdkEventExpose *) event;
|
||||
/*printf(" EXP:%d,%d(%dx%d) ",eevent->area.x, eevent->area.y,
|
||||
eevent->area.width, eevent->area.height);fflush(stdout);*/
|
||||
|
||||
gdisplay_redraw (gdisp,
|
||||
eevent->area.x, eevent->area.y,
|
||||
eevent->area.width, eevent->area.height);
|
||||
break;
|
||||
|
||||
case GDK_CONFIGURE:
|
||||
/*printf(" CNF ");fflush(stdout);*/
|
||||
if ((gdisp->disp_width != gdisp->canvas->allocation.width) ||
|
||||
if ((gdisp->disp_width != gdisp->canvas->allocation.width) ||
|
||||
(gdisp->disp_height != gdisp->canvas->allocation.height))
|
||||
{
|
||||
gdisp->disp_width = gdisp->canvas->allocation.width;
|
||||
gdisp->disp_width = gdisp->canvas->allocation.width;
|
||||
gdisp->disp_height = gdisp->canvas->allocation.height;
|
||||
|
||||
resize_display (gdisp, FALSE, FALSE);
|
||||
}
|
||||
break;
|
||||
@ -288,8 +287,6 @@ gdisplay_canvas_events (GtkWidget *canvas,
|
||||
* guaranteed to work in future versions of GTK.
|
||||
* -Yosh
|
||||
*/
|
||||
|
||||
|
||||
if (key_signal_id == 0)
|
||||
key_signal_id = gtk_signal_connect (GTK_OBJECT (canvas),
|
||||
"key_press_event",
|
||||
@ -544,16 +541,16 @@ gdisplay_canvas_events (GtkWidget *canvas,
|
||||
grab_and_scroll (gdisp, mevent);
|
||||
}
|
||||
|
||||
/* Operator update support: Bug #XXXX */
|
||||
|
||||
if (/* Should we have a tool... */
|
||||
if (/* Should we have a tool... */
|
||||
active_tool &&
|
||||
/* and this event is NOT driving */
|
||||
/* button press handlers ... */
|
||||
/* and this event is NOT driving
|
||||
* button press handlers ...
|
||||
*/
|
||||
!(state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK)))
|
||||
{
|
||||
/* ...then preconditions to modify a tool */
|
||||
/* operator state have been met. */
|
||||
/* ...then preconditions to modify a tool
|
||||
* operator state have been met.
|
||||
*/
|
||||
gimp_tool_oper_update (active_tool, mevent, gdisp);
|
||||
}
|
||||
|
||||
@ -587,8 +584,8 @@ gdisplay_canvas_events (GtkWidget *canvas,
|
||||
layer_select_init (gdisp->gimage, -1, kevent->time);
|
||||
|
||||
/* Hide or show all dialogs */
|
||||
if (!kevent->state)
|
||||
dialog_toggle();
|
||||
if (! kevent->state)
|
||||
dialog_toggle ();
|
||||
|
||||
return_val = TRUE;
|
||||
break;
|
||||
@ -653,6 +650,8 @@ gdisplay_canvas_events (GtkWidget *canvas,
|
||||
|
||||
if (gimprc.no_cursor_updating == 0)
|
||||
{
|
||||
active_tool = tool_manager_get_active (gdisp->gimage->gimp);
|
||||
|
||||
if (active_tool && !gimp_image_is_empty (gdisp->gimage) &&
|
||||
!(state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK)))
|
||||
{
|
||||
|
@ -10,6 +10,8 @@ libappgui_a_SOURCES = @STRIP_BEGIN@ \
|
||||
brush-editor.h \
|
||||
brush-select.c \
|
||||
brush-select.h \
|
||||
brushes-commands.c \
|
||||
brushes-commands.h \
|
||||
channels-commands.c \
|
||||
channels-commands.h \
|
||||
color-area.c \
|
||||
@ -24,6 +26,8 @@ libappgui_a_SOURCES = @STRIP_BEGIN@ \
|
||||
commands.h \
|
||||
convert-dialog.c \
|
||||
convert-dialog.h \
|
||||
data-commands.c \
|
||||
data-commands.h \
|
||||
dialogs.c \
|
||||
dialogs.h \
|
||||
dialogs-commands.c \
|
||||
@ -46,6 +50,8 @@ libappgui_a_SOURCES = @STRIP_BEGIN@ \
|
||||
gradient-editor.h \
|
||||
gradient-select.h \
|
||||
gradient-select.c \
|
||||
gradients-commands.c \
|
||||
gradients-commands.h \
|
||||
gui.c \
|
||||
gui.h \
|
||||
image-commands.c \
|
||||
@ -70,10 +76,14 @@ libappgui_a_SOURCES = @STRIP_BEGIN@ \
|
||||
palette-import-dialog.h \
|
||||
palette-select.c \
|
||||
palette-select.h \
|
||||
palettes-commands.c \
|
||||
palettes-commands.h \
|
||||
paths-dialog.c \
|
||||
paths-dialog.h \
|
||||
pattern-select.c \
|
||||
pattern-select.h \
|
||||
patterns-commands.c \
|
||||
patterns-commands.h \
|
||||
preferences-dialog.c \
|
||||
preferences-dialog.h \
|
||||
resize-dialog.c \
|
||||
|
@ -202,7 +202,8 @@ brush_select_new (gchar *title,
|
||||
title ? FALSE : TRUE,
|
||||
MIN_CELL_SIZE,
|
||||
STD_BRUSH_COLUMNS,
|
||||
STD_BRUSH_ROWS);
|
||||
STD_BRUSH_ROWS,
|
||||
NULL);
|
||||
gtk_box_pack_start (GTK_BOX (main_vbox), bsp->view, TRUE, TRUE, 0);
|
||||
gtk_widget_show (bsp->view);
|
||||
|
||||
|
79
app/gui/brushes-commands.c
Normal file
79
app/gui/brushes-commands.c
Normal file
@ -0,0 +1,79 @@
|
||||
/* 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 <gtk/gtk.h>
|
||||
|
||||
#include "widgets/widgets-types.h"
|
||||
|
||||
#include "core/gimpbrushgenerated.h"
|
||||
#include "core/gimpcontext.h"
|
||||
|
||||
#include "widgets/gimpcontainereditor.h"
|
||||
#include "widgets/gimpcontainerview.h"
|
||||
#include "widgets/gimpwidgets-utils.h"
|
||||
|
||||
#include "brushes-commands.h"
|
||||
#include "menus.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
static void brushes_menu_set_sensitivity (GimpContainerEditor *editor);
|
||||
|
||||
|
||||
void
|
||||
brushes_show_context_menu (GimpContainerEditor *editor)
|
||||
{
|
||||
GtkItemFactory *item_factory;
|
||||
gint x, y;
|
||||
|
||||
brushes_menu_set_sensitivity (editor);
|
||||
|
||||
item_factory = menus_get_brushes_factory ();
|
||||
|
||||
gimp_menu_position (GTK_MENU (item_factory->widget), &x, &y);
|
||||
|
||||
gtk_item_factory_popup_with_data (item_factory,
|
||||
editor,
|
||||
NULL,
|
||||
x, y,
|
||||
3, 0);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
brushes_menu_set_sensitivity (GimpContainerEditor *editor)
|
||||
{
|
||||
GimpBrush *brush;
|
||||
|
||||
brush = gimp_context_get_brush (editor->view->context);
|
||||
|
||||
#define SET_SENSITIVE(menu,condition) \
|
||||
menus_set_sensitive ("<Brushes>/" menu, (condition) != 0)
|
||||
|
||||
SET_SENSITIVE ("Duplicate Brush",
|
||||
brush && GIMP_DATA_CLASS (GTK_OBJECT (brush)->klass)->duplicate);
|
||||
SET_SENSITIVE ("Edit Brush...",
|
||||
brush && GIMP_IS_BRUSH_GENERATED (brush));
|
||||
SET_SENSITIVE ("Delete Brush...",
|
||||
brush);
|
||||
|
||||
#undef SET_SENSITIVE
|
||||
}
|
26
app/gui/brushes-commands.h
Normal file
26
app/gui/brushes-commands.h
Normal file
@ -0,0 +1,26 @@
|
||||
/* 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 __BRUSHES_COMMANDS_H__
|
||||
#define __BRUSHES_COMMANDS_H__
|
||||
|
||||
|
||||
void brushes_show_context_menu (GimpContainerEditor *editor);
|
||||
|
||||
|
||||
#endif /* __BRUSHES_COMMANDS_H__ */
|
116
app/gui/data-commands.c
Normal file
116
app/gui/data-commands.c
Normal file
@ -0,0 +1,116 @@
|
||||
/* 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 <gtk/gtk.h>
|
||||
|
||||
#include "widgets/widgets-types.h"
|
||||
|
||||
#include "widgets/gimpdatafactoryview.h"
|
||||
#include "widgets/gimpwidgets-utils.h"
|
||||
|
||||
#include "data-commands.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
void
|
||||
data_new_data_cmd_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GimpDataFactoryView *view;
|
||||
|
||||
view = (GimpDataFactoryView *) gimp_widget_get_callback_context (widget);
|
||||
|
||||
if (! view)
|
||||
return;
|
||||
|
||||
if (GTK_WIDGET_SENSITIVE (view->new_button))
|
||||
{
|
||||
gtk_button_clicked (GTK_BUTTON (view->new_button));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
data_duplicate_data_cmd_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GimpDataFactoryView *view;
|
||||
|
||||
view = (GimpDataFactoryView *) gimp_widget_get_callback_context (widget);
|
||||
|
||||
if (! view)
|
||||
return;
|
||||
|
||||
if (GTK_WIDGET_SENSITIVE (view->duplicate_button))
|
||||
{
|
||||
gtk_button_clicked (GTK_BUTTON (view->duplicate_button));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
data_edit_data_cmd_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GimpDataFactoryView *view;
|
||||
|
||||
view = (GimpDataFactoryView *) gimp_widget_get_callback_context (widget);
|
||||
|
||||
if (! view)
|
||||
return;
|
||||
|
||||
if (GTK_WIDGET_SENSITIVE (view->edit_button))
|
||||
{
|
||||
gtk_button_clicked (GTK_BUTTON (view->edit_button));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
data_delete_data_cmd_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GimpDataFactoryView *view;
|
||||
|
||||
view = (GimpDataFactoryView *) gimp_widget_get_callback_context (widget);
|
||||
|
||||
if (! view)
|
||||
return;
|
||||
|
||||
if (GTK_WIDGET_SENSITIVE (view->delete_button))
|
||||
{
|
||||
gtk_button_clicked (GTK_BUTTON (view->delete_button));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
data_refresh_data_cmd_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GimpDataFactoryView *view;
|
||||
|
||||
view = (GimpDataFactoryView *) gimp_widget_get_callback_context (widget);
|
||||
|
||||
if (! view)
|
||||
return;
|
||||
|
||||
if (GTK_WIDGET_SENSITIVE (view->refresh_button))
|
||||
{
|
||||
gtk_button_clicked (GTK_BUTTON (view->refresh_button));
|
||||
}
|
||||
}
|
35
app/gui/data-commands.h
Normal file
35
app/gui/data-commands.h
Normal file
@ -0,0 +1,35 @@
|
||||
/* 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 __DATA_COMMANDS_H__
|
||||
#define __DATA_COMMANDS_H__
|
||||
|
||||
|
||||
void data_new_data_cmd_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
void data_duplicate_data_cmd_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
void data_edit_data_cmd_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
void data_delete_data_cmd_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
void data_refresh_data_cmd_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
|
||||
#endif /* __DATA_COMMANDS_H__ */
|
@ -51,6 +51,7 @@
|
||||
#include "about-dialog.h"
|
||||
#include "brush-editor.h"
|
||||
#include "brush-select.h"
|
||||
#include "brushes-commands.h"
|
||||
#include "channels-commands.h"
|
||||
#include "color-area.h"
|
||||
#include "colormap-dialog.h"
|
||||
@ -61,10 +62,14 @@
|
||||
#include "gdisplay.h"
|
||||
#include "gradient-editor.h"
|
||||
#include "gradient-select.h"
|
||||
#include "gradients-commands.h"
|
||||
#include "layers-commands.h"
|
||||
#include "menus.h"
|
||||
#include "palette-editor.h"
|
||||
#include "palettes-commands.h"
|
||||
#include "paths-dialog.h"
|
||||
#include "pattern-select.h"
|
||||
#include "patterns-commands.h"
|
||||
#include "preferences-dialog.h"
|
||||
#include "tips-dialog.h"
|
||||
#include "tool-options-dialog.h"
|
||||
@ -321,7 +326,8 @@ dialogs_brush_list_view_new (GimpDialogFactory *factory,
|
||||
context,
|
||||
TRUE,
|
||||
32,
|
||||
5, 3);
|
||||
5, 3,
|
||||
brushes_show_context_menu);
|
||||
|
||||
return dialogs_dockable_new (view,
|
||||
"Brush List", "Brushes",
|
||||
@ -340,7 +346,8 @@ dialogs_pattern_list_view_new (GimpDialogFactory *factory,
|
||||
NULL,
|
||||
context,
|
||||
32,
|
||||
5, 3);
|
||||
5, 3,
|
||||
patterns_show_context_menu);
|
||||
|
||||
return dialogs_dockable_new (view,
|
||||
"Pattern List", "Patterns",
|
||||
@ -359,7 +366,8 @@ dialogs_gradient_list_view_new (GimpDialogFactory *factory,
|
||||
dialogs_edit_gradient_func,
|
||||
context,
|
||||
32 / 2,
|
||||
5, 3);
|
||||
5, 3,
|
||||
gradients_show_context_menu);
|
||||
|
||||
return dialogs_dockable_new (view,
|
||||
"Gradient List", "Gradients",
|
||||
@ -378,7 +386,8 @@ dialogs_palette_list_view_new (GimpDialogFactory *factory,
|
||||
dialogs_edit_palette_func,
|
||||
context,
|
||||
32,
|
||||
5, 3);
|
||||
5, 3,
|
||||
palettes_show_context_menu);
|
||||
|
||||
return dialogs_dockable_new (view,
|
||||
"Palette List", "Palettes",
|
||||
@ -413,7 +422,8 @@ dialogs_buffer_list_view_new (GimpDialogFactory *factory,
|
||||
context->gimp->named_buffers,
|
||||
context,
|
||||
32,
|
||||
5, 3);
|
||||
5, 3,
|
||||
NULL);
|
||||
|
||||
return dialogs_dockable_new (view,
|
||||
"Buffer List", "Buffers",
|
||||
@ -453,7 +463,8 @@ dialogs_brush_grid_view_new (GimpDialogFactory *factory,
|
||||
context,
|
||||
TRUE,
|
||||
32,
|
||||
5, 3);
|
||||
5, 3,
|
||||
brushes_show_context_menu);
|
||||
|
||||
return dialogs_dockable_new (view,
|
||||
"Brush Grid", "Brushes",
|
||||
@ -472,7 +483,8 @@ dialogs_pattern_grid_view_new (GimpDialogFactory *factory,
|
||||
NULL,
|
||||
context,
|
||||
32,
|
||||
5, 3);
|
||||
5, 3,
|
||||
patterns_show_context_menu);
|
||||
|
||||
return dialogs_dockable_new (view,
|
||||
"Pattern Grid", "Patterns",
|
||||
@ -491,7 +503,8 @@ dialogs_gradient_grid_view_new (GimpDialogFactory *factory,
|
||||
dialogs_edit_gradient_func,
|
||||
context,
|
||||
32,
|
||||
5, 3);
|
||||
5, 3,
|
||||
gradients_show_context_menu);
|
||||
|
||||
return dialogs_dockable_new (view,
|
||||
"Gradient Grid", "Gradients",
|
||||
@ -510,7 +523,8 @@ dialogs_palette_grid_view_new (GimpDialogFactory *factory,
|
||||
dialogs_edit_palette_func,
|
||||
context,
|
||||
32,
|
||||
5, 3);
|
||||
5, 3,
|
||||
palettes_show_context_menu);
|
||||
|
||||
return dialogs_dockable_new (view,
|
||||
"Palette Grid", "Palettes",
|
||||
@ -545,7 +559,8 @@ dialogs_buffer_grid_view_new (GimpDialogFactory *factory,
|
||||
context->gimp->named_buffers,
|
||||
context,
|
||||
32,
|
||||
5, 3);
|
||||
5, 3,
|
||||
NULL);
|
||||
|
||||
return dialogs_dockable_new (view,
|
||||
"Buffer Grid", "Buffers",
|
||||
|
@ -259,16 +259,6 @@ static void ed_initialize_saved_colors (GradientEditor *gradient_edi
|
||||
|
||||
/* Main dialog button callbacks & functions */
|
||||
|
||||
static void ed_save_pov_callback (GtkWidget *widget,
|
||||
GradientEditor *gradient_editor);
|
||||
static void ed_do_save_pov_callback (GtkWidget *widget,
|
||||
GradientEditor *gradient_editor);
|
||||
static void ed_cancel_save_pov_callback (GtkWidget *widget,
|
||||
GradientEditor *gradient_editor);
|
||||
static gint ed_delete_save_pov_callback (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
GradientEditor *gradient_editor);
|
||||
|
||||
static void ed_close_callback (GtkWidget *widget,
|
||||
GradientEditor *gradient_editor);
|
||||
|
||||
@ -710,20 +700,6 @@ gradient_editor_new (void)
|
||||
gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
/* Save as POV-Ray button */
|
||||
button = gtk_button_new_with_label (_("Save as POV-Ray"));
|
||||
gimp_help_set_help_data (button, NULL,
|
||||
"dialogs/gradient_editor/save_as_povray.html");
|
||||
gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child), 2, 0);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
||||
gtk_widget_show (button);
|
||||
|
||||
GTK_WIDGET_UNSET_FLAGS (button, GTK_RECEIVES_DEFAULT);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
GTK_SIGNAL_FUNC (ed_save_pov_callback),
|
||||
gradient_editor);
|
||||
|
||||
/* + and - buttons */
|
||||
gtk_widget_realize (gradient_editor->shell);
|
||||
|
||||
@ -994,134 +970,6 @@ ed_initialize_saved_colors (GradientEditor *gradient_editor)
|
||||
|
||||
/***** Main gradient editor dialog callbacks *****/
|
||||
|
||||
|
||||
/***** The "save as pov" dialog functions *****/
|
||||
|
||||
static void
|
||||
ed_save_pov_callback (GtkWidget *widget,
|
||||
GradientEditor *gradient_editor)
|
||||
{
|
||||
GimpGradient *gradient;
|
||||
GtkWidget *window;
|
||||
|
||||
gradient = gimp_context_get_gradient (gradient_editor->context);
|
||||
|
||||
if (! gradient)
|
||||
return;
|
||||
|
||||
window = gtk_file_selection_new (_("Save as POV-Ray"));
|
||||
gtk_window_set_wmclass (GTK_WINDOW (window), "save_gradient", "Gimp");
|
||||
gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_MOUSE);
|
||||
|
||||
gtk_container_set_border_width (GTK_CONTAINER (window), 2);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (GTK_FILE_SELECTION (window)->button_area), 2);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (window)->ok_button),
|
||||
"clicked",
|
||||
GTK_SIGNAL_FUNC (ed_do_save_pov_callback),
|
||||
gradient_editor);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (window)->cancel_button),
|
||||
"clicked",
|
||||
GTK_SIGNAL_FUNC (ed_cancel_save_pov_callback),
|
||||
gradient_editor);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (window), "delete_event",
|
||||
GTK_SIGNAL_FUNC (ed_delete_save_pov_callback),
|
||||
gradient_editor);
|
||||
|
||||
/* Connect the "F1" help key */
|
||||
gimp_help_connect_help_accel (window, gimp_standard_help_func,
|
||||
"dialogs/gradient_editor/save_as_povray.html");
|
||||
|
||||
gtk_widget_show (window);
|
||||
gtk_widget_set_sensitive (gradient_editor->shell, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
ed_do_save_pov_callback (GtkWidget *widget,
|
||||
GradientEditor *gradient_editor)
|
||||
{
|
||||
GimpGradient *gradient;
|
||||
gchar *filename;
|
||||
FILE *file;
|
||||
GimpGradientSegment *seg;
|
||||
|
||||
gradient = gimp_context_get_gradient (gradient_editor->context);
|
||||
|
||||
if (! gradient)
|
||||
return;
|
||||
|
||||
filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (gtk_widget_get_toplevel (widget)));
|
||||
|
||||
file = fopen (filename, "wb");
|
||||
|
||||
if (!file)
|
||||
{
|
||||
g_message ("Could not open \"%s\"", filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf (file, "/* color_map file created by the GIMP */\n");
|
||||
fprintf (file, "/* http://www.gimp.org/ */\n");
|
||||
|
||||
fprintf (file, "color_map {\n");
|
||||
|
||||
for (seg = gradient->segments; seg; seg = seg->next)
|
||||
{
|
||||
/* Left */
|
||||
fprintf (file, "\t[%f color rgbt <%f, %f, %f, %f>]\n",
|
||||
seg->left,
|
||||
seg->left_color.r,
|
||||
seg->left_color.g,
|
||||
seg->left_color.b,
|
||||
1.0 - seg->left_color.a);
|
||||
|
||||
/* Middle */
|
||||
fprintf (file, "\t[%f color rgbt <%f, %f, %f, %f>]\n",
|
||||
seg->middle,
|
||||
(seg->left_color.r + seg->right_color.r) / 2.0,
|
||||
(seg->left_color.g + seg->right_color.g) / 2.0,
|
||||
(seg->left_color.b + seg->right_color.b) / 2.0,
|
||||
1.0 - (seg->left_color.a + seg->right_color.a) / 2.0);
|
||||
|
||||
/* Right */
|
||||
fprintf (file, "\t[%f color rgbt <%f, %f, %f, %f>]\n",
|
||||
seg->right,
|
||||
seg->right_color.r,
|
||||
seg->right_color.g,
|
||||
seg->right_color.b,
|
||||
1.0 - seg->right_color.a);
|
||||
}
|
||||
|
||||
fprintf (file, "} /* color_map */\n");
|
||||
fclose (file);
|
||||
}
|
||||
|
||||
gtk_widget_destroy (gtk_widget_get_toplevel (widget));
|
||||
gtk_widget_set_sensitive (gradient_editor->shell, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
ed_cancel_save_pov_callback (GtkWidget *widget,
|
||||
GradientEditor *gradient_editor)
|
||||
{
|
||||
gtk_widget_destroy (gtk_widget_get_toplevel (widget));
|
||||
gtk_widget_set_sensitive (gradient_editor->shell, TRUE);
|
||||
}
|
||||
|
||||
static gint
|
||||
ed_delete_save_pov_callback (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
GradientEditor *gradient_editor)
|
||||
{
|
||||
ed_cancel_save_pov_callback (widget, gradient_editor);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/***** The main dialog action area button callbacks *****/
|
||||
|
||||
static void
|
||||
ed_close_callback (GtkWidget *widget,
|
||||
GradientEditor *gradient_editor)
|
||||
@ -1130,6 +978,7 @@ ed_close_callback (GtkWidget *widget,
|
||||
gtk_widget_hide (gradient_editor->shell);
|
||||
}
|
||||
|
||||
|
||||
/***** Zoom, scrollbar & instant update callbacks *****/
|
||||
|
||||
static void
|
||||
|
@ -161,7 +161,8 @@ gradient_select_new (gchar *title,
|
||||
dialogs_edit_gradient_func,
|
||||
gsp->context,
|
||||
16,
|
||||
10, 10);
|
||||
10, 10,
|
||||
NULL);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), gsp->view, TRUE, TRUE, 0);
|
||||
gtk_widget_show (gsp->view);
|
||||
|
||||
|
217
app/gui/gradients-commands.c
Normal file
217
app/gui/gradients-commands.c
Normal file
@ -0,0 +1,217 @@
|
||||
/* 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 <stdio.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "widgets/widgets-types.h"
|
||||
|
||||
#include "core/gimpgradient.h"
|
||||
#include "core/gimpcontext.h"
|
||||
|
||||
#include "widgets/gimpcontainerview.h"
|
||||
#include "widgets/gimpdatafactoryview.h"
|
||||
#include "widgets/gimpwidgets-utils.h"
|
||||
|
||||
#include "gradients-commands.h"
|
||||
#include "menus.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
/* 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);
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
||||
void
|
||||
gradients_save_as_pov_ray_cmd_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GimpContainerEditor *editor;
|
||||
|
||||
editor = (GimpContainerEditor *) gimp_widget_get_callback_context (widget);
|
||||
|
||||
if (! editor)
|
||||
return;
|
||||
|
||||
gradients_save_as_pov_query (editor);
|
||||
}
|
||||
|
||||
void
|
||||
gradients_show_context_menu (GimpContainerEditor *editor)
|
||||
{
|
||||
GtkItemFactory *item_factory;
|
||||
gint x, y;
|
||||
|
||||
gradients_menu_set_sensitivity (editor);
|
||||
|
||||
item_factory = menus_get_gradients_factory ();
|
||||
|
||||
gimp_menu_position (GTK_MENU (item_factory->widget), &x, &y);
|
||||
|
||||
gtk_item_factory_popup_with_data (item_factory,
|
||||
editor,
|
||||
NULL,
|
||||
x, y,
|
||||
3, 0);
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
static void
|
||||
gradients_menu_set_sensitivity (GimpContainerEditor *editor)
|
||||
{
|
||||
GimpGradient *gradient;
|
||||
|
||||
gradient = gimp_context_get_gradient (editor->view->context);
|
||||
|
||||
#define SET_SENSITIVE(menu,condition) \
|
||||
menus_set_sensitive ("<Gradients>/" menu, (condition) != 0)
|
||||
|
||||
SET_SENSITIVE ("Duplicate Gradient",
|
||||
gradient && GIMP_DATA_CLASS (GTK_OBJECT (gradient)->klass)->duplicate);
|
||||
SET_SENSITIVE ("Edit Gradient...",
|
||||
gradient && GIMP_DATA_FACTORY_VIEW (editor)->data_edit_func);
|
||||
SET_SENSITIVE ("Delete Gradient...",
|
||||
gradient);
|
||||
SET_SENSITIVE ("Save as POV-Ray...",
|
||||
gradient);
|
||||
|
||||
#undef SET_SENSITIVE
|
||||
}
|
||||
|
||||
static void
|
||||
gradients_save_as_pov_query (GimpContainerEditor *editor)
|
||||
{
|
||||
GimpGradient *gradient;
|
||||
GtkFileSelection *filesel;
|
||||
gchar *title;
|
||||
|
||||
gradient = gimp_context_get_gradient (editor->view->context);
|
||||
|
||||
if (! gradient)
|
||||
return;
|
||||
|
||||
title = g_strdup_printf (_("Save \"%s\" as POV-Ray"),
|
||||
GIMP_OBJECT (gradient)->name);
|
||||
|
||||
filesel = GTK_FILE_SELECTION (gtk_file_selection_new (title));
|
||||
|
||||
g_free (title);
|
||||
|
||||
gtk_window_set_wmclass (GTK_WINDOW (filesel), "save_gradient", "Gimp");
|
||||
gtk_window_set_position (GTK_WINDOW (filesel), GTK_WIN_POS_MOUSE);
|
||||
|
||||
gtk_container_set_border_width (GTK_CONTAINER (filesel), 2);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (filesel->button_area), 2);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (filesel->ok_button), "clicked",
|
||||
GTK_SIGNAL_FUNC (gradients_save_as_pov_ok_callback),
|
||||
gradient);
|
||||
|
||||
gtk_signal_connect_object (GTK_OBJECT (filesel->cancel_button), "clicked",
|
||||
GTK_SIGNAL_FUNC (gtk_widget_destroy),
|
||||
GTK_OBJECT (filesel));
|
||||
|
||||
gtk_signal_connect_object (GTK_OBJECT (filesel), "delete_event",
|
||||
GTK_SIGNAL_FUNC (gtk_widget_destroy),
|
||||
GTK_OBJECT (filesel));
|
||||
|
||||
gtk_object_ref (GTK_OBJECT (gradient));
|
||||
|
||||
gtk_signal_connect_object (GTK_OBJECT (filesel), "destroy",
|
||||
GTK_SIGNAL_FUNC (gtk_object_unref),
|
||||
GTK_OBJECT (gradient));
|
||||
|
||||
/* Connect the "F1" help key */
|
||||
gimp_help_connect_help_accel (GTK_WIDGET (filesel), gimp_standard_help_func,
|
||||
"dialogs/save_as_povray.html");
|
||||
|
||||
gtk_widget_show (GTK_WIDGET (filesel));
|
||||
}
|
||||
|
||||
static void
|
||||
gradients_save_as_pov_ok_callback (GtkWidget *widget,
|
||||
GimpGradient *gradient)
|
||||
{
|
||||
GtkFileSelection *filesel;
|
||||
gchar *filename;
|
||||
FILE *file;
|
||||
GimpGradientSegment *seg;
|
||||
|
||||
filesel = GTK_FILE_SELECTION (gtk_widget_get_toplevel (widget));
|
||||
filename = gtk_file_selection_get_filename (filesel);
|
||||
|
||||
file = fopen (filename, "wb");
|
||||
|
||||
if (!file)
|
||||
{
|
||||
g_message ("Could not open \"%s\"", filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf (file, "/* color_map file created by the GIMP */\n");
|
||||
fprintf (file, "/* http://www.gimp.org/ */\n");
|
||||
|
||||
fprintf (file, "color_map {\n");
|
||||
|
||||
for (seg = gradient->segments; seg; seg = seg->next)
|
||||
{
|
||||
/* Left */
|
||||
fprintf (file, "\t[%f color rgbt <%f, %f, %f, %f>]\n",
|
||||
seg->left,
|
||||
seg->left_color.r,
|
||||
seg->left_color.g,
|
||||
seg->left_color.b,
|
||||
1.0 - seg->left_color.a);
|
||||
|
||||
/* Middle */
|
||||
fprintf (file, "\t[%f color rgbt <%f, %f, %f, %f>]\n",
|
||||
seg->middle,
|
||||
(seg->left_color.r + seg->right_color.r) / 2.0,
|
||||
(seg->left_color.g + seg->right_color.g) / 2.0,
|
||||
(seg->left_color.b + seg->right_color.b) / 2.0,
|
||||
1.0 - (seg->left_color.a + seg->right_color.a) / 2.0);
|
||||
|
||||
/* Right */
|
||||
fprintf (file, "\t[%f color rgbt <%f, %f, %f, %f>]\n",
|
||||
seg->right,
|
||||
seg->right_color.r,
|
||||
seg->right_color.g,
|
||||
seg->right_color.b,
|
||||
1.0 - seg->right_color.a);
|
||||
}
|
||||
|
||||
fprintf (file, "} /* color_map */\n");
|
||||
fclose (file);
|
||||
}
|
||||
|
||||
gtk_widget_destroy (GTK_WIDGET (filesel));
|
||||
}
|
30
app/gui/gradients-commands.h
Normal file
30
app/gui/gradients-commands.h
Normal 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 __GRADIENTS_COMMANDS_H__
|
||||
#define __GRADIENTS_COMMANDS_H__
|
||||
|
||||
|
||||
void gradients_save_as_pov_ray_cmd_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
|
||||
void gradients_show_context_menu (GimpContainerEditor *editor);
|
||||
|
||||
|
||||
#endif /* __GRADIENTS_COMMANDS_H__ */
|
@ -1221,7 +1221,8 @@ layers_show_context_menu (GimpImage *gimage)
|
||||
gimp_menu_position (GTK_MENU (item_factory->widget), &x, &y);
|
||||
|
||||
gtk_item_factory_popup_with_data (item_factory,
|
||||
gimage, NULL,
|
||||
gimage,
|
||||
NULL,
|
||||
x, y,
|
||||
3, 0);
|
||||
}
|
||||
|
237
app/gui/menus.c
237
app/gui/menus.c
@ -45,15 +45,18 @@
|
||||
|
||||
#include "channels-commands.h"
|
||||
#include "commands.h"
|
||||
#include "data-commands.h"
|
||||
#include "dialog_handler.h"
|
||||
#include "dialogs-commands.h"
|
||||
#include "edit-commands.h"
|
||||
#include "file-commands.h"
|
||||
#include "file-open-dialog.h"
|
||||
#include "file-save-dialog.h"
|
||||
#include "gradients-commands.h"
|
||||
#include "image-commands.h"
|
||||
#include "layers-commands.h"
|
||||
#include "menus.h"
|
||||
#include "palettes-commands.h"
|
||||
#include "paths-dialog.h"
|
||||
#include "select-commands.h"
|
||||
#include "test-commands.h"
|
||||
@ -1267,6 +1270,156 @@ static guint n_dialogs_entries = (sizeof (dialogs_entries) /
|
||||
static GtkItemFactory *dialogs_factory = NULL;
|
||||
|
||||
|
||||
/***** <Brushes> *****/
|
||||
|
||||
static GimpItemFactoryEntry brushes_entries[] =
|
||||
{
|
||||
{ { N_("/New Brush"), NULL,
|
||||
data_new_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
{ { N_("/Duplicate Brush"), NULL,
|
||||
data_duplicate_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
{ { N_("/Edit Brush..."), NULL,
|
||||
data_edit_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
{ { N_("/Delete Brush..."), NULL,
|
||||
data_delete_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
|
||||
SEPARATOR ("/---"),
|
||||
|
||||
{ { N_("/Refresh Brushes"), NULL,
|
||||
data_refresh_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL }
|
||||
};
|
||||
static guint n_brushes_entries = (sizeof (brushes_entries) /
|
||||
sizeof (brushes_entries[0]));
|
||||
static GtkItemFactory *brushes_factory = NULL;
|
||||
|
||||
|
||||
/***** <Patterns> *****/
|
||||
|
||||
static GimpItemFactoryEntry patterns_entries[] =
|
||||
{
|
||||
{ { N_("/New Pattern"), NULL,
|
||||
data_new_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
{ { N_("/Duplicate Pattern"), NULL,
|
||||
data_duplicate_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
{ { N_("/Edit Pattern..."), NULL,
|
||||
data_edit_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
{ { N_("/Delete Pattern..."), NULL,
|
||||
data_delete_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
|
||||
SEPARATOR ("/---"),
|
||||
|
||||
{ { N_("/Refresh Patterns"), NULL,
|
||||
data_refresh_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL }
|
||||
};
|
||||
static guint n_patterns_entries = (sizeof (patterns_entries) /
|
||||
sizeof (patterns_entries[0]));
|
||||
static GtkItemFactory *patterns_factory = NULL;
|
||||
|
||||
|
||||
/***** <Gradients> *****/
|
||||
|
||||
static GimpItemFactoryEntry gradients_entries[] =
|
||||
{
|
||||
{ { N_("/New Gradient"), NULL,
|
||||
data_new_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
{ { N_("/Duplicate Gradient"), NULL,
|
||||
data_duplicate_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
{ { N_("/Edit Gradient..."), NULL,
|
||||
data_edit_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
{ { N_("/Delete Gradient..."), NULL,
|
||||
data_delete_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
|
||||
SEPARATOR ("/---"),
|
||||
|
||||
{ { N_("/Refresh Gradients"), NULL,
|
||||
data_refresh_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
|
||||
SEPARATOR ("/---"),
|
||||
|
||||
{ { N_("/Save as POV-Ray..."), NULL,
|
||||
gradients_save_as_pov_ray_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL }
|
||||
};
|
||||
static guint n_gradients_entries = (sizeof (gradients_entries) /
|
||||
sizeof (gradients_entries[0]));
|
||||
static GtkItemFactory *gradients_factory = NULL;
|
||||
|
||||
|
||||
/***** <Palettes> *****/
|
||||
|
||||
static GimpItemFactoryEntry palettes_entries[] =
|
||||
{
|
||||
{ { N_("/New Palette"), NULL,
|
||||
data_new_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
{ { N_("/Duplicate Palette"), NULL,
|
||||
data_duplicate_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
{ { N_("/Edit Palette..."), NULL,
|
||||
data_edit_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
{ { N_("/Delete Palette..."), NULL,
|
||||
data_delete_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
|
||||
SEPARATOR ("/---"),
|
||||
|
||||
{ { N_("/Refresh Palettes"), NULL,
|
||||
data_refresh_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
|
||||
SEPARATOR ("/---"),
|
||||
|
||||
{ { N_("/Import Palette..."), NULL,
|
||||
palettes_import_palette_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
{ { N_("/Merge Palettes..."), NULL,
|
||||
palettes_merge_palettes_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL }
|
||||
};
|
||||
static guint n_palettes_entries = (sizeof (palettes_entries) /
|
||||
sizeof (palettes_entries[0]));
|
||||
static GtkItemFactory *palettes_factory = NULL;
|
||||
|
||||
|
||||
static gboolean menus_initialized = FALSE;
|
||||
|
||||
|
||||
@ -1342,6 +1495,42 @@ menus_get_dialogs_factory (void)
|
||||
return dialogs_factory;
|
||||
}
|
||||
|
||||
GtkItemFactory *
|
||||
menus_get_brushes_factory (void)
|
||||
{
|
||||
if (! menus_initialized)
|
||||
menus_init ();
|
||||
|
||||
return brushes_factory;
|
||||
}
|
||||
|
||||
GtkItemFactory *
|
||||
menus_get_patterns_factory (void)
|
||||
{
|
||||
if (! menus_initialized)
|
||||
menus_init ();
|
||||
|
||||
return patterns_factory;
|
||||
}
|
||||
|
||||
GtkItemFactory *
|
||||
menus_get_gradients_factory (void)
|
||||
{
|
||||
if (! menus_initialized)
|
||||
menus_init ();
|
||||
|
||||
return gradients_factory;
|
||||
}
|
||||
|
||||
GtkItemFactory *
|
||||
menus_get_palettes_factory (void)
|
||||
{
|
||||
if (! menus_initialized)
|
||||
menus_init ();
|
||||
|
||||
return palettes_factory;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
menus_create_item_from_full_path (GimpItemFactoryEntry *entry,
|
||||
@ -2243,6 +2432,54 @@ menus_init (void)
|
||||
FALSE,
|
||||
TRUE);
|
||||
|
||||
brushes_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<Brushes>", NULL);
|
||||
gtk_object_set_data (GTK_OBJECT (brushes_factory), "factory_path",
|
||||
"brushes");
|
||||
gtk_item_factory_set_translate_func (dialogs_factory, menu_translate,
|
||||
"<Brushes>", NULL);
|
||||
menus_create_items (brushes_factory,
|
||||
n_brushes_entries,
|
||||
brushes_entries,
|
||||
NULL, 2,
|
||||
FALSE,
|
||||
TRUE);
|
||||
|
||||
patterns_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<Patterns>", NULL);
|
||||
gtk_object_set_data (GTK_OBJECT (patterns_factory), "factory_path",
|
||||
"patterns");
|
||||
gtk_item_factory_set_translate_func (dialogs_factory, menu_translate,
|
||||
"<Patterns>", NULL);
|
||||
menus_create_items (patterns_factory,
|
||||
n_patterns_entries,
|
||||
patterns_entries,
|
||||
NULL, 2,
|
||||
FALSE,
|
||||
TRUE);
|
||||
|
||||
gradients_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<Gradients>", NULL);
|
||||
gtk_object_set_data (GTK_OBJECT (gradients_factory), "factory_path",
|
||||
"gradients");
|
||||
gtk_item_factory_set_translate_func (dialogs_factory, menu_translate,
|
||||
"<Gradients>", NULL);
|
||||
menus_create_items (gradients_factory,
|
||||
n_gradients_entries,
|
||||
gradients_entries,
|
||||
NULL, 2,
|
||||
FALSE,
|
||||
TRUE);
|
||||
|
||||
palettes_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<Palettes>", NULL);
|
||||
gtk_object_set_data (GTK_OBJECT (palettes_factory), "factory_path",
|
||||
"palettes");
|
||||
gtk_item_factory_set_translate_func (dialogs_factory, menu_translate,
|
||||
"<Palettes>", NULL);
|
||||
menus_create_items (palettes_factory,
|
||||
n_palettes_entries,
|
||||
palettes_entries,
|
||||
NULL, 2,
|
||||
FALSE,
|
||||
TRUE);
|
||||
|
||||
|
||||
for (list = GIMP_LIST (the_gimp->tool_info_list)->list;
|
||||
list;
|
||||
|
@ -36,14 +36,18 @@ struct _GimpItemFactoryEntry
|
||||
extern GSList *last_opened_raw_filenames;
|
||||
|
||||
|
||||
GtkItemFactory * menus_get_toolbox_factory (void);
|
||||
GtkItemFactory * menus_get_image_factory (void);
|
||||
GtkItemFactory * menus_get_load_factory (void);
|
||||
GtkItemFactory * menus_get_save_factory (void);
|
||||
GtkItemFactory * menus_get_layers_factory (void);
|
||||
GtkItemFactory * menus_get_channels_factory (void);
|
||||
GtkItemFactory * menus_get_paths_factory (void);
|
||||
GtkItemFactory * menus_get_dialogs_factory (void);
|
||||
GtkItemFactory * menus_get_toolbox_factory (void);
|
||||
GtkItemFactory * menus_get_image_factory (void);
|
||||
GtkItemFactory * menus_get_load_factory (void);
|
||||
GtkItemFactory * menus_get_save_factory (void);
|
||||
GtkItemFactory * menus_get_layers_factory (void);
|
||||
GtkItemFactory * menus_get_channels_factory (void);
|
||||
GtkItemFactory * menus_get_paths_factory (void);
|
||||
GtkItemFactory * menus_get_dialogs_factory (void);
|
||||
GtkItemFactory * menus_get_brushes_factory (void);
|
||||
GtkItemFactory * menus_get_patterns_factory (void);
|
||||
GtkItemFactory * menus_get_gradients_factory (void);
|
||||
GtkItemFactory * menus_get_palettes_factory (void);
|
||||
|
||||
|
||||
void menus_create_item_from_full_path (GimpItemFactoryEntry *entry,
|
||||
|
@ -41,7 +41,6 @@
|
||||
#include "color-area.h"
|
||||
#include "color-notebook.h"
|
||||
#include "palette-editor.h"
|
||||
#include "palette-import-dialog.h"
|
||||
#include "palette-select.h"
|
||||
|
||||
#include "app_procs.h"
|
||||
@ -138,13 +137,6 @@ static void palette_dialog_zoomin_callback (GtkWidget *widget,
|
||||
static void palette_dialog_zoomout_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void palette_dialog_redraw_zoom (PaletteDialog *palette_dialog);
|
||||
static void palette_dialog_import_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void palette_dialog_merge_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void palette_dialog_do_merge_callback (GtkWidget *widget,
|
||||
gchar *palette_name,
|
||||
gpointer data);
|
||||
static void palette_dialog_close_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void palette_dialog_palette_changed (GimpContext *context,
|
||||
@ -193,8 +185,6 @@ palette_dialog_free (void)
|
||||
{
|
||||
if (top_level_edit_palette)
|
||||
{
|
||||
palette_import_dialog_destroy ();
|
||||
|
||||
if (top_level_edit_palette->color_notebook)
|
||||
color_notebook_free (top_level_edit_palette->color_notebook);
|
||||
|
||||
@ -321,7 +311,6 @@ palette_dialog_new (gboolean editor)
|
||||
GtkWidget *entry;
|
||||
GtkWidget *eventbox;
|
||||
GtkWidget *alignment;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *button;
|
||||
|
||||
palette_dialog = g_new0 (PaletteDialog, 1);
|
||||
@ -475,7 +464,8 @@ palette_dialog_new (gboolean editor)
|
||||
editor ? NULL : palette_dialog_edit_palette,
|
||||
palette_dialog->context,
|
||||
SM_PREVIEW_HEIGHT,
|
||||
2, 4);
|
||||
2, 4,
|
||||
NULL);
|
||||
|
||||
if (! editor)
|
||||
{
|
||||
@ -506,40 +496,6 @@ palette_dialog_new (gboolean editor)
|
||||
|
||||
gtk_widget_show (palette_dialog->view);
|
||||
|
||||
if (editor)
|
||||
{
|
||||
frame = gtk_frame_new (_("Palette Ops"));
|
||||
gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, FALSE, 0);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 2);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
|
||||
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
button = gtk_button_new_with_label (_("Import"));
|
||||
GTK_WIDGET_UNSET_FLAGS (button, GTK_RECEIVES_DEFAULT);
|
||||
gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child), 2, 0);
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
GTK_SIGNAL_FUNC (palette_dialog_import_callback),
|
||||
palette_dialog);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
||||
gimp_help_set_help_data (button, NULL,
|
||||
"dialogs/palette_editor/import_palette.html");
|
||||
gtk_widget_show (button);
|
||||
|
||||
button = gtk_button_new_with_label (_("Merge"));
|
||||
GTK_WIDGET_UNSET_FLAGS (button, GTK_RECEIVES_DEFAULT);
|
||||
gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child), 2, 0);
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
GTK_SIGNAL_FUNC (palette_dialog_merge_callback),
|
||||
palette_dialog);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
||||
gimp_help_set_help_data (button, NULL,
|
||||
"dialogs/palette_editor/merge_palette.html");
|
||||
gtk_widget_show (button);
|
||||
}
|
||||
|
||||
gtk_widget_realize (palette_dialog->shell);
|
||||
|
||||
palette_dialog_create_popup_menu (palette_dialog);
|
||||
@ -1274,77 +1230,6 @@ palette_dialog_redraw_zoom (PaletteDialog *palette_dialog)
|
||||
|
||||
/* the palette dialog action callbacks **************************************/
|
||||
|
||||
static void
|
||||
palette_dialog_import_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
palette_import_dialog_show ();
|
||||
}
|
||||
|
||||
static void
|
||||
palette_dialog_merge_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GtkWidget *qbox;
|
||||
|
||||
qbox = gimp_query_string_box (_("Merge Palette"),
|
||||
gimp_standard_help_func,
|
||||
"dialogs/palette_editor/merge_palette.html",
|
||||
_("Enter a name for merged palette"),
|
||||
NULL,
|
||||
NULL, NULL,
|
||||
palette_dialog_do_merge_callback,
|
||||
data);
|
||||
gtk_widget_show (qbox);
|
||||
}
|
||||
|
||||
static void
|
||||
palette_dialog_do_merge_callback (GtkWidget *widget,
|
||||
gchar *palette_name,
|
||||
gpointer data)
|
||||
{
|
||||
PaletteDialog *palette_dialog;
|
||||
GimpPalette *palette;
|
||||
GimpPalette *new_palette;
|
||||
GimpPaletteEntry *entry;
|
||||
GList *sel_list;
|
||||
|
||||
new_palette = GIMP_PALETTE (gimp_palette_new (palette_name));
|
||||
|
||||
palette_dialog = (PaletteDialog *) data;
|
||||
|
||||
sel_list = GTK_LIST (GIMP_CONTAINER_LIST_VIEW (GIMP_CONTAINER_EDITOR (palette_dialog->view)->view)->gtk_list)->selection;
|
||||
|
||||
while (sel_list)
|
||||
{
|
||||
GtkWidget *list_item;
|
||||
GList *cols;
|
||||
|
||||
list_item = GTK_WIDGET (sel_list->data);
|
||||
|
||||
palette = (GimpPalette *)
|
||||
GIMP_PREVIEW (gtk_object_get_data (GTK_OBJECT (list_item),
|
||||
"preview"))->viewable;
|
||||
|
||||
if (palette)
|
||||
{
|
||||
for (cols = palette->colors; cols; cols = g_list_next (cols))
|
||||
{
|
||||
entry = (GimpPaletteEntry *) cols->data;
|
||||
|
||||
gimp_palette_add_entry (new_palette,
|
||||
entry->name,
|
||||
&entry->color);
|
||||
}
|
||||
}
|
||||
|
||||
sel_list = sel_list->next;
|
||||
}
|
||||
|
||||
gimp_container_add (the_gimp->palette_factory->container,
|
||||
GIMP_OBJECT (new_palette));
|
||||
}
|
||||
|
||||
static void
|
||||
palette_dialog_close_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
@ -1361,11 +1246,6 @@ palette_dialog_close_callback (GtkWidget *widget,
|
||||
palette_dialog->color_notebook_active = FALSE;
|
||||
}
|
||||
|
||||
if (palette_dialog == top_level_edit_palette)
|
||||
{
|
||||
palette_import_dialog_destroy ();
|
||||
}
|
||||
|
||||
if (GTK_WIDGET_VISIBLE (palette_dialog->shell))
|
||||
gtk_widget_hide (palette_dialog->shell);
|
||||
}
|
||||
|
@ -147,7 +147,8 @@ palette_select_new (const gchar *title,
|
||||
dialogs_edit_palette_func,
|
||||
psp->context,
|
||||
32,
|
||||
5, 3);
|
||||
5, 3,
|
||||
NULL);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), psp->view, TRUE, TRUE, 0);
|
||||
gtk_widget_show (psp->view);
|
||||
|
||||
|
192
app/gui/palettes-commands.c
Normal file
192
app/gui/palettes-commands.c
Normal file
@ -0,0 +1,192 @@
|
||||
/* 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 <gtk/gtk.h>
|
||||
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "widgets/widgets-types.h"
|
||||
|
||||
#include "core/gimppalette.h"
|
||||
#include "core/gimpcontainer.h"
|
||||
#include "core/gimpcontext.h"
|
||||
|
||||
#include "widgets/gimpcontainerlistview.h"
|
||||
#include "widgets/gimpdatafactoryview.h"
|
||||
#include "widgets/gimplistitem.h"
|
||||
#include "widgets/gimppreview.h"
|
||||
#include "widgets/gimpwidgets-utils.h"
|
||||
|
||||
#include "palette-import-dialog.h"
|
||||
#include "palettes-commands.h"
|
||||
#include "menus.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
/* 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,
|
||||
gpointer data);
|
||||
|
||||
|
||||
/* public functionss */
|
||||
|
||||
void
|
||||
palettes_import_palette_cmd_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GimpContainerEditor *editor;
|
||||
|
||||
editor = (GimpContainerEditor *) gimp_widget_get_callback_context (widget);
|
||||
|
||||
if (! editor)
|
||||
return;
|
||||
|
||||
palette_import_dialog_show ();
|
||||
}
|
||||
|
||||
void
|
||||
palettes_merge_palettes_cmd_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GimpContainerEditor *editor;
|
||||
|
||||
editor = (GimpContainerEditor *) gimp_widget_get_callback_context (widget);
|
||||
|
||||
if (! editor)
|
||||
return;
|
||||
|
||||
palettes_merge_palettes_query (editor);
|
||||
}
|
||||
|
||||
void
|
||||
palettes_show_context_menu (GimpContainerEditor *editor)
|
||||
{
|
||||
GtkItemFactory *item_factory;
|
||||
gint x, y;
|
||||
|
||||
palettes_menu_set_sensitivity (editor);
|
||||
|
||||
item_factory = menus_get_palettes_factory ();
|
||||
|
||||
gimp_menu_position (GTK_MENU (item_factory->widget), &x, &y);
|
||||
|
||||
gtk_item_factory_popup_with_data (item_factory,
|
||||
editor,
|
||||
NULL,
|
||||
x, y,
|
||||
3, 0);
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
static void
|
||||
palettes_menu_set_sensitivity (GimpContainerEditor *editor)
|
||||
{
|
||||
GimpPalette *palette;
|
||||
|
||||
palette = gimp_context_get_palette (editor->view->context);
|
||||
|
||||
#define SET_SENSITIVE(menu,condition) \
|
||||
menus_set_sensitive ("<Palettes>/" menu, (condition) != 0)
|
||||
|
||||
SET_SENSITIVE ("Duplicate Palette",
|
||||
palette && GIMP_DATA_CLASS (GTK_OBJECT (palette)->klass)->duplicate);
|
||||
SET_SENSITIVE ("Edit Palette...",
|
||||
palette && GIMP_DATA_FACTORY_VIEW (editor)->data_edit_func);
|
||||
SET_SENSITIVE ("Delete Palette...",
|
||||
palette);
|
||||
SET_SENSITIVE ("Merge Palettes...",
|
||||
FALSE); /* FIXME palette && GIMP_IS_CONTAINER_LIST_VIEW (editor->view)); */
|
||||
|
||||
#undef SET_SENSITIVE
|
||||
}
|
||||
|
||||
static void
|
||||
palettes_merge_palettes_query (GimpContainerEditor *editor)
|
||||
{
|
||||
GtkWidget *qbox;
|
||||
|
||||
qbox = gimp_query_string_box (_("Merge Palette"),
|
||||
gimp_standard_help_func,
|
||||
"dialogs/palette_editor/merge_palette.html",
|
||||
_("Enter a name for merged palette"),
|
||||
NULL,
|
||||
GTK_OBJECT (editor), "destroy",
|
||||
palettes_merge_palettes_callback,
|
||||
editor);
|
||||
gtk_widget_show (qbox);
|
||||
}
|
||||
|
||||
static void
|
||||
palettes_merge_palettes_callback (GtkWidget *widget,
|
||||
gchar *palette_name,
|
||||
gpointer data)
|
||||
{
|
||||
GimpContainerEditor *editor;
|
||||
GimpPalette *palette;
|
||||
GimpPalette *new_palette;
|
||||
GimpPaletteEntry *entry;
|
||||
GList *sel_list;
|
||||
|
||||
editor = (GimpContainerEditor *) data;
|
||||
|
||||
sel_list = GTK_LIST (GIMP_CONTAINER_LIST_VIEW (editor->view)->gtk_list)->selection;
|
||||
|
||||
if (! sel_list)
|
||||
{
|
||||
g_message ("Can't merge palettes because there are no palettes selected.");
|
||||
return;
|
||||
}
|
||||
|
||||
new_palette = GIMP_PALETTE (gimp_palette_new (palette_name));
|
||||
|
||||
while (sel_list)
|
||||
{
|
||||
GimpListItem *list_item;
|
||||
GList *cols;
|
||||
|
||||
list_item = GIMP_LIST_ITEM (sel_list->data);
|
||||
|
||||
palette = (GimpPalette *) GIMP_PREVIEW (list_item->preview)->viewable;
|
||||
|
||||
if (palette)
|
||||
{
|
||||
for (cols = palette->colors; cols; cols = g_list_next (cols))
|
||||
{
|
||||
entry = (GimpPaletteEntry *) cols->data;
|
||||
|
||||
gimp_palette_add_entry (new_palette,
|
||||
entry->name,
|
||||
&entry->color);
|
||||
}
|
||||
}
|
||||
|
||||
sel_list = sel_list->next;
|
||||
}
|
||||
|
||||
gimp_container_add (editor->view->container,
|
||||
GIMP_OBJECT (new_palette));
|
||||
}
|
32
app/gui/palettes-commands.h
Normal file
32
app/gui/palettes-commands.h
Normal file
@ -0,0 +1,32 @@
|
||||
/* 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 __PALETTES_COMMANDS_H__
|
||||
#define __PALETTES_COMMANDS_H__
|
||||
|
||||
|
||||
void palettes_import_palette_cmd_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
void palettes_merge_palettes_cmd_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
|
||||
void palettes_show_context_menu (GimpContainerEditor *editor);
|
||||
|
||||
|
||||
#endif /* __PALETTES_COMMANDS_H__ */
|
@ -172,7 +172,8 @@ pattern_select_new (gchar *title,
|
||||
psp->context,
|
||||
MIN_CELL_SIZE,
|
||||
STD_PATTERN_COLUMNS,
|
||||
STD_PATTERN_ROWS);
|
||||
STD_PATTERN_ROWS,
|
||||
NULL);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), psp->view, TRUE, TRUE, 0);
|
||||
gtk_widget_show (psp->view);
|
||||
|
||||
|
79
app/gui/patterns-commands.c
Normal file
79
app/gui/patterns-commands.c
Normal file
@ -0,0 +1,79 @@
|
||||
/* 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 <gtk/gtk.h>
|
||||
|
||||
#include "widgets/widgets-types.h"
|
||||
|
||||
#include "core/gimppattern.h"
|
||||
#include "core/gimpcontext.h"
|
||||
|
||||
#include "widgets/gimpcontainerview.h"
|
||||
#include "widgets/gimpdatafactoryview.h"
|
||||
#include "widgets/gimpwidgets-utils.h"
|
||||
|
||||
#include "patterns-commands.h"
|
||||
#include "menus.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
static void patterns_menu_set_sensitivity (GimpContainerEditor *editor);
|
||||
|
||||
|
||||
void
|
||||
patterns_show_context_menu (GimpContainerEditor *editor)
|
||||
{
|
||||
GtkItemFactory *item_factory;
|
||||
gint x, y;
|
||||
|
||||
patterns_menu_set_sensitivity (editor);
|
||||
|
||||
item_factory = menus_get_patterns_factory ();
|
||||
|
||||
gimp_menu_position (GTK_MENU (item_factory->widget), &x, &y);
|
||||
|
||||
gtk_item_factory_popup_with_data (item_factory,
|
||||
editor,
|
||||
NULL,
|
||||
x, y,
|
||||
3, 0);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
patterns_menu_set_sensitivity (GimpContainerEditor *editor)
|
||||
{
|
||||
GimpPattern *pattern;
|
||||
|
||||
pattern = gimp_context_get_pattern (editor->view->context);
|
||||
|
||||
#define SET_SENSITIVE(menu,condition) \
|
||||
menus_set_sensitive ("<Patterns>/" menu, (condition) != 0)
|
||||
|
||||
SET_SENSITIVE ("Duplicate Pattern",
|
||||
pattern && GIMP_DATA_CLASS (GTK_OBJECT (pattern)->klass)->duplicate);
|
||||
SET_SENSITIVE ("Edit Pattern...",
|
||||
pattern && GIMP_DATA_FACTORY_VIEW (editor)->data_edit_func);
|
||||
SET_SENSITIVE ("Delete Pattern...",
|
||||
pattern);
|
||||
|
||||
#undef SET_SENSITIVE
|
||||
}
|
26
app/gui/patterns-commands.h
Normal file
26
app/gui/patterns-commands.h
Normal file
@ -0,0 +1,26 @@
|
||||
/* 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 __PATTERNS_COMMANDS_H__
|
||||
#define __PATTERNS_COMMANDS_H__
|
||||
|
||||
|
||||
void patterns_show_context_menu (GimpContainerEditor *editor);
|
||||
|
||||
|
||||
#endif /* __PATTERNS_COMMANDS_H__ */
|
@ -205,7 +205,8 @@ data_factory_view_new (GimpViewType view_type,
|
||||
edit_func,
|
||||
context,
|
||||
preview_size,
|
||||
5, 5);
|
||||
5, 5,
|
||||
NULL);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), view);
|
||||
gtk_widget_show (view);
|
||||
|
@ -45,15 +45,18 @@
|
||||
|
||||
#include "channels-commands.h"
|
||||
#include "commands.h"
|
||||
#include "data-commands.h"
|
||||
#include "dialog_handler.h"
|
||||
#include "dialogs-commands.h"
|
||||
#include "edit-commands.h"
|
||||
#include "file-commands.h"
|
||||
#include "file-open-dialog.h"
|
||||
#include "file-save-dialog.h"
|
||||
#include "gradients-commands.h"
|
||||
#include "image-commands.h"
|
||||
#include "layers-commands.h"
|
||||
#include "menus.h"
|
||||
#include "palettes-commands.h"
|
||||
#include "paths-dialog.h"
|
||||
#include "select-commands.h"
|
||||
#include "test-commands.h"
|
||||
@ -1267,6 +1270,156 @@ static guint n_dialogs_entries = (sizeof (dialogs_entries) /
|
||||
static GtkItemFactory *dialogs_factory = NULL;
|
||||
|
||||
|
||||
/***** <Brushes> *****/
|
||||
|
||||
static GimpItemFactoryEntry brushes_entries[] =
|
||||
{
|
||||
{ { N_("/New Brush"), NULL,
|
||||
data_new_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
{ { N_("/Duplicate Brush"), NULL,
|
||||
data_duplicate_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
{ { N_("/Edit Brush..."), NULL,
|
||||
data_edit_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
{ { N_("/Delete Brush..."), NULL,
|
||||
data_delete_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
|
||||
SEPARATOR ("/---"),
|
||||
|
||||
{ { N_("/Refresh Brushes"), NULL,
|
||||
data_refresh_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL }
|
||||
};
|
||||
static guint n_brushes_entries = (sizeof (brushes_entries) /
|
||||
sizeof (brushes_entries[0]));
|
||||
static GtkItemFactory *brushes_factory = NULL;
|
||||
|
||||
|
||||
/***** <Patterns> *****/
|
||||
|
||||
static GimpItemFactoryEntry patterns_entries[] =
|
||||
{
|
||||
{ { N_("/New Pattern"), NULL,
|
||||
data_new_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
{ { N_("/Duplicate Pattern"), NULL,
|
||||
data_duplicate_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
{ { N_("/Edit Pattern..."), NULL,
|
||||
data_edit_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
{ { N_("/Delete Pattern..."), NULL,
|
||||
data_delete_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
|
||||
SEPARATOR ("/---"),
|
||||
|
||||
{ { N_("/Refresh Patterns"), NULL,
|
||||
data_refresh_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL }
|
||||
};
|
||||
static guint n_patterns_entries = (sizeof (patterns_entries) /
|
||||
sizeof (patterns_entries[0]));
|
||||
static GtkItemFactory *patterns_factory = NULL;
|
||||
|
||||
|
||||
/***** <Gradients> *****/
|
||||
|
||||
static GimpItemFactoryEntry gradients_entries[] =
|
||||
{
|
||||
{ { N_("/New Gradient"), NULL,
|
||||
data_new_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
{ { N_("/Duplicate Gradient"), NULL,
|
||||
data_duplicate_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
{ { N_("/Edit Gradient..."), NULL,
|
||||
data_edit_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
{ { N_("/Delete Gradient..."), NULL,
|
||||
data_delete_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
|
||||
SEPARATOR ("/---"),
|
||||
|
||||
{ { N_("/Refresh Gradients"), NULL,
|
||||
data_refresh_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
|
||||
SEPARATOR ("/---"),
|
||||
|
||||
{ { N_("/Save as POV-Ray..."), NULL,
|
||||
gradients_save_as_pov_ray_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL }
|
||||
};
|
||||
static guint n_gradients_entries = (sizeof (gradients_entries) /
|
||||
sizeof (gradients_entries[0]));
|
||||
static GtkItemFactory *gradients_factory = NULL;
|
||||
|
||||
|
||||
/***** <Palettes> *****/
|
||||
|
||||
static GimpItemFactoryEntry palettes_entries[] =
|
||||
{
|
||||
{ { N_("/New Palette"), NULL,
|
||||
data_new_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
{ { N_("/Duplicate Palette"), NULL,
|
||||
data_duplicate_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
{ { N_("/Edit Palette..."), NULL,
|
||||
data_edit_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
{ { N_("/Delete Palette..."), NULL,
|
||||
data_delete_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
|
||||
SEPARATOR ("/---"),
|
||||
|
||||
{ { N_("/Refresh Palettes"), NULL,
|
||||
data_refresh_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
|
||||
SEPARATOR ("/---"),
|
||||
|
||||
{ { N_("/Import Palette..."), NULL,
|
||||
palettes_import_palette_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
{ { N_("/Merge Palettes..."), NULL,
|
||||
palettes_merge_palettes_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL }
|
||||
};
|
||||
static guint n_palettes_entries = (sizeof (palettes_entries) /
|
||||
sizeof (palettes_entries[0]));
|
||||
static GtkItemFactory *palettes_factory = NULL;
|
||||
|
||||
|
||||
static gboolean menus_initialized = FALSE;
|
||||
|
||||
|
||||
@ -1342,6 +1495,42 @@ menus_get_dialogs_factory (void)
|
||||
return dialogs_factory;
|
||||
}
|
||||
|
||||
GtkItemFactory *
|
||||
menus_get_brushes_factory (void)
|
||||
{
|
||||
if (! menus_initialized)
|
||||
menus_init ();
|
||||
|
||||
return brushes_factory;
|
||||
}
|
||||
|
||||
GtkItemFactory *
|
||||
menus_get_patterns_factory (void)
|
||||
{
|
||||
if (! menus_initialized)
|
||||
menus_init ();
|
||||
|
||||
return patterns_factory;
|
||||
}
|
||||
|
||||
GtkItemFactory *
|
||||
menus_get_gradients_factory (void)
|
||||
{
|
||||
if (! menus_initialized)
|
||||
menus_init ();
|
||||
|
||||
return gradients_factory;
|
||||
}
|
||||
|
||||
GtkItemFactory *
|
||||
menus_get_palettes_factory (void)
|
||||
{
|
||||
if (! menus_initialized)
|
||||
menus_init ();
|
||||
|
||||
return palettes_factory;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
menus_create_item_from_full_path (GimpItemFactoryEntry *entry,
|
||||
@ -2243,6 +2432,54 @@ menus_init (void)
|
||||
FALSE,
|
||||
TRUE);
|
||||
|
||||
brushes_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<Brushes>", NULL);
|
||||
gtk_object_set_data (GTK_OBJECT (brushes_factory), "factory_path",
|
||||
"brushes");
|
||||
gtk_item_factory_set_translate_func (dialogs_factory, menu_translate,
|
||||
"<Brushes>", NULL);
|
||||
menus_create_items (brushes_factory,
|
||||
n_brushes_entries,
|
||||
brushes_entries,
|
||||
NULL, 2,
|
||||
FALSE,
|
||||
TRUE);
|
||||
|
||||
patterns_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<Patterns>", NULL);
|
||||
gtk_object_set_data (GTK_OBJECT (patterns_factory), "factory_path",
|
||||
"patterns");
|
||||
gtk_item_factory_set_translate_func (dialogs_factory, menu_translate,
|
||||
"<Patterns>", NULL);
|
||||
menus_create_items (patterns_factory,
|
||||
n_patterns_entries,
|
||||
patterns_entries,
|
||||
NULL, 2,
|
||||
FALSE,
|
||||
TRUE);
|
||||
|
||||
gradients_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<Gradients>", NULL);
|
||||
gtk_object_set_data (GTK_OBJECT (gradients_factory), "factory_path",
|
||||
"gradients");
|
||||
gtk_item_factory_set_translate_func (dialogs_factory, menu_translate,
|
||||
"<Gradients>", NULL);
|
||||
menus_create_items (gradients_factory,
|
||||
n_gradients_entries,
|
||||
gradients_entries,
|
||||
NULL, 2,
|
||||
FALSE,
|
||||
TRUE);
|
||||
|
||||
palettes_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<Palettes>", NULL);
|
||||
gtk_object_set_data (GTK_OBJECT (palettes_factory), "factory_path",
|
||||
"palettes");
|
||||
gtk_item_factory_set_translate_func (dialogs_factory, menu_translate,
|
||||
"<Palettes>", NULL);
|
||||
menus_create_items (palettes_factory,
|
||||
n_palettes_entries,
|
||||
palettes_entries,
|
||||
NULL, 2,
|
||||
FALSE,
|
||||
TRUE);
|
||||
|
||||
|
||||
for (list = GIMP_LIST (the_gimp->tool_info_list)->list;
|
||||
list;
|
||||
|
@ -36,14 +36,18 @@ struct _GimpItemFactoryEntry
|
||||
extern GSList *last_opened_raw_filenames;
|
||||
|
||||
|
||||
GtkItemFactory * menus_get_toolbox_factory (void);
|
||||
GtkItemFactory * menus_get_image_factory (void);
|
||||
GtkItemFactory * menus_get_load_factory (void);
|
||||
GtkItemFactory * menus_get_save_factory (void);
|
||||
GtkItemFactory * menus_get_layers_factory (void);
|
||||
GtkItemFactory * menus_get_channels_factory (void);
|
||||
GtkItemFactory * menus_get_paths_factory (void);
|
||||
GtkItemFactory * menus_get_dialogs_factory (void);
|
||||
GtkItemFactory * menus_get_toolbox_factory (void);
|
||||
GtkItemFactory * menus_get_image_factory (void);
|
||||
GtkItemFactory * menus_get_load_factory (void);
|
||||
GtkItemFactory * menus_get_save_factory (void);
|
||||
GtkItemFactory * menus_get_layers_factory (void);
|
||||
GtkItemFactory * menus_get_channels_factory (void);
|
||||
GtkItemFactory * menus_get_paths_factory (void);
|
||||
GtkItemFactory * menus_get_dialogs_factory (void);
|
||||
GtkItemFactory * menus_get_brushes_factory (void);
|
||||
GtkItemFactory * menus_get_patterns_factory (void);
|
||||
GtkItemFactory * menus_get_gradients_factory (void);
|
||||
GtkItemFactory * menus_get_palettes_factory (void);
|
||||
|
||||
|
||||
void menus_create_item_from_full_path (GimpItemFactoryEntry *entry,
|
||||
|
@ -147,14 +147,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)
|
||||
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)
|
||||
{
|
||||
GimpBrushFactoryView *factory_view;
|
||||
GimpContainerEditor *editor;
|
||||
@ -176,7 +177,8 @@ gimp_brush_factory_view_new (GimpViewType view_type,
|
||||
context,
|
||||
preview_size,
|
||||
min_items_x,
|
||||
min_items_y))
|
||||
min_items_y,
|
||||
context_func))
|
||||
{
|
||||
gtk_object_unref (GTK_OBJECT (factory_view));
|
||||
return NULL;
|
||||
|
@ -54,14 +54,15 @@ struct _GimpBrushFactoryViewClass
|
||||
|
||||
GtkType gimp_brush_factory_view_get_type (void);
|
||||
|
||||
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);
|
||||
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);
|
||||
|
||||
|
||||
#endif /* __GIMP_BRUSH_FACTORY_VIEW_H__ */
|
||||
|
@ -160,12 +160,13 @@ gimp_buffer_view_destroy (GtkObject *object)
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gimp_buffer_view_new (GimpViewType view_type,
|
||||
GimpContainer *container,
|
||||
GimpContext *context,
|
||||
gint preview_size,
|
||||
gint min_items_x,
|
||||
gint min_items_y)
|
||||
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)
|
||||
{
|
||||
GimpBufferView *buffer_view;
|
||||
GimpContainerEditor *editor;
|
||||
@ -178,7 +179,8 @@ gimp_buffer_view_new (GimpViewType view_type,
|
||||
context,
|
||||
preview_size,
|
||||
min_items_x,
|
||||
min_items_y))
|
||||
min_items_y,
|
||||
context_func))
|
||||
{
|
||||
gtk_object_unref (GTK_OBJECT (buffer_view));
|
||||
return NULL;
|
||||
|
@ -53,12 +53,13 @@ struct _GimpBufferViewClass
|
||||
|
||||
GtkType gimp_buffer_view_get_type (void);
|
||||
|
||||
GtkWidget * gimp_buffer_view_new (GimpViewType view_type,
|
||||
GimpContainer *container,
|
||||
GimpContext *context,
|
||||
gint preview_size,
|
||||
gint min_items_x,
|
||||
gint min_items_y);
|
||||
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);
|
||||
|
||||
|
||||
#endif /* __GIMP_BUFFER_VIEW_H__ */
|
||||
|
@ -56,6 +56,8 @@ static void gimp_container_editor_context_item (GtkWidget *widge
|
||||
GimpViewable *viewable,
|
||||
gpointer insert_data,
|
||||
GimpContainerEditor *editor);
|
||||
static void gimp_container_editor_real_context_item(GimpContainerEditor *editor,
|
||||
GimpViewable *viewable);
|
||||
|
||||
|
||||
static GtkVBoxClass *parent_class = NULL;
|
||||
@ -99,13 +101,14 @@ gimp_container_editor_class_init (GimpContainerEditorClass *klass)
|
||||
|
||||
klass->select_item = NULL;
|
||||
klass->activate_item = NULL;
|
||||
klass->context_item = NULL;
|
||||
klass->context_item = gimp_container_editor_real_context_item;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_container_editor_init (GimpContainerEditor *view)
|
||||
{
|
||||
view->view = NULL;
|
||||
view->context_func = NULL;
|
||||
view->view = NULL;
|
||||
|
||||
gtk_box_set_spacing (GTK_BOX (view), 2);
|
||||
|
||||
@ -126,13 +129,14 @@ gimp_container_editor_destroy (GtkObject *object)
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_container_editor_construct (GimpContainerEditor *editor,
|
||||
GimpViewType view_type,
|
||||
GimpContainer *container,
|
||||
GimpContext *context,
|
||||
gint preview_size,
|
||||
gint min_items_x,
|
||||
gint min_items_y)
|
||||
gimp_container_editor_construct (GimpContainerEditor *editor,
|
||||
GimpViewType view_type,
|
||||
GimpContainer *container,
|
||||
GimpContext *context,
|
||||
gint preview_size,
|
||||
gint min_items_x,
|
||||
gint min_items_y,
|
||||
GimpContainerContextFunc context_func)
|
||||
{
|
||||
g_return_val_if_fail (editor != NULL, FALSE);
|
||||
g_return_val_if_fail (GIMP_IS_CONTAINER_EDITOR (editor), FALSE);
|
||||
@ -145,6 +149,8 @@ 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;
|
||||
|
||||
switch (view_type)
|
||||
{
|
||||
case GIMP_VIEW_TYPE_GRID:
|
||||
@ -322,3 +328,15 @@ gimp_container_editor_context_item (GtkWidget *widget,
|
||||
if (klass->context_item)
|
||||
klass->context_item (editor, viewable);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_container_editor_real_context_item (GimpContainerEditor *editor,
|
||||
GimpViewable *viewable)
|
||||
{
|
||||
if (viewable && gimp_container_have (editor->view->container,
|
||||
GIMP_OBJECT (viewable)))
|
||||
{
|
||||
if (editor->context_func)
|
||||
editor->context_func (editor);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include <gtk/gtkvbox.h>
|
||||
|
||||
|
||||
typedef void (* GimpContainerEditFunc) (GimpContainer *container);
|
||||
typedef void (* GimpContainerContextFunc) (GimpContainerEditor *editor);
|
||||
|
||||
|
||||
typedef enum
|
||||
@ -47,11 +47,12 @@ typedef struct _GimpContainerEditorClass GimpContainerEditorClass;
|
||||
|
||||
struct _GimpContainerEditor
|
||||
{
|
||||
GtkVBox parent_instance;
|
||||
GtkVBox parent_instance;
|
||||
|
||||
GimpContainerView *view;
|
||||
GimpContainerContextFunc context_func;
|
||||
|
||||
GtkWidget *button_box;
|
||||
GimpContainerView *view;
|
||||
GtkWidget *button_box;
|
||||
};
|
||||
|
||||
struct _GimpContainerEditorClass
|
||||
@ -78,7 +79,8 @@ gboolean gimp_container_editor_construct (GimpContainerEditor *editor,
|
||||
GimpContext *context,
|
||||
gint preview_size,
|
||||
gint min_items_x,
|
||||
gint min_items_y);
|
||||
gint min_items_y,
|
||||
GimpContainerContextFunc context_func);
|
||||
|
||||
GtkWidget * gimp_container_editor_add_button (GimpContainerEditor *editor,
|
||||
gchar **xpm_data,
|
||||
|
@ -64,6 +64,8 @@ static void gimp_container_grid_view_item_selected (GtkWidget *w
|
||||
gpointer data);
|
||||
static void gimp_container_grid_view_item_activated (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void gimp_container_grid_view_item_context (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void gimp_container_grid_view_highlight_item (GimpContainerView *view,
|
||||
GimpViewable *viewable,
|
||||
gpointer insert_data);
|
||||
@ -263,6 +265,10 @@ gimp_container_grid_view_insert_item (GimpContainerView *view,
|
||||
GTK_SIGNAL_FUNC (gimp_container_grid_view_item_activated),
|
||||
view);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (preview), "context",
|
||||
GTK_SIGNAL_FUNC (gimp_container_grid_view_item_context),
|
||||
view);
|
||||
|
||||
return (gpointer) preview;
|
||||
}
|
||||
|
||||
@ -368,6 +374,16 @@ gimp_container_grid_view_item_activated (GtkWidget *widget,
|
||||
GIMP_PREVIEW (widget)->viewable);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_container_grid_view_item_context (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
gimp_container_view_item_selected (GIMP_CONTAINER_VIEW (data),
|
||||
GIMP_PREVIEW (widget)->viewable);
|
||||
gimp_container_view_item_context (GIMP_CONTAINER_VIEW (data),
|
||||
GIMP_PREVIEW (widget)->viewable);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_container_grid_view_highlight_item (GimpContainerView *view,
|
||||
GimpViewable *viewable,
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "gimpcontainergridview.h"
|
||||
#include "gimpcontainerlistview.h"
|
||||
#include "gimpdnd.h"
|
||||
#include "gimpwidgets-utils.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
@ -172,13 +173,14 @@ gimp_data_factory_view_destroy (GtkObject *object)
|
||||
}
|
||||
|
||||
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)
|
||||
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)
|
||||
{
|
||||
GimpDataFactoryView *factory_view;
|
||||
|
||||
@ -191,7 +193,8 @@ gimp_data_factory_view_new (GimpViewType view_type,
|
||||
context,
|
||||
preview_size,
|
||||
min_items_x,
|
||||
min_items_y))
|
||||
min_items_y,
|
||||
context_func))
|
||||
{
|
||||
gtk_object_unref (GTK_OBJECT (factory_view));
|
||||
return NULL;
|
||||
@ -201,14 +204,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)
|
||||
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)
|
||||
{
|
||||
GimpContainerEditor *editor;
|
||||
|
||||
@ -229,7 +233,8 @@ gimp_data_factory_view_construct (GimpDataFactoryView *factory_view,
|
||||
context,
|
||||
preview_size,
|
||||
min_items_x,
|
||||
min_items_y))
|
||||
min_items_y,
|
||||
context_func))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@ -435,7 +440,6 @@ gimp_data_factory_view_select_item (GimpContainerEditor *editor,
|
||||
GimpViewable *viewable)
|
||||
{
|
||||
GimpDataFactoryView *view;
|
||||
GimpData *data;
|
||||
|
||||
gboolean duplicate_sensitive = FALSE;
|
||||
gboolean edit_sensitive = FALSE;
|
||||
@ -445,13 +449,12 @@ gimp_data_factory_view_select_item (GimpContainerEditor *editor,
|
||||
GIMP_CONTAINER_EDITOR_CLASS (parent_class)->select_item (editor, viewable);
|
||||
|
||||
view = GIMP_DATA_FACTORY_VIEW (editor);
|
||||
data = GIMP_DATA (viewable);
|
||||
|
||||
if (data && gimp_container_have (view->factory->container,
|
||||
GIMP_OBJECT (data)))
|
||||
if (viewable && gimp_container_have (view->factory->container,
|
||||
GIMP_OBJECT (viewable)))
|
||||
{
|
||||
duplicate_sensitive =
|
||||
(GIMP_DATA_CLASS (GTK_OBJECT (data)->klass)->duplicate != NULL);
|
||||
(GIMP_DATA_CLASS (GTK_OBJECT (viewable)->klass)->duplicate != NULL);
|
||||
|
||||
edit_sensitive = (view->data_edit_func != NULL);
|
||||
delete_sensitive = TRUE; /* TODO: check permissions */
|
||||
|
@ -61,24 +61,27 @@ struct _GimpDataFactoryViewClass
|
||||
|
||||
GtkType gimp_data_factory_view_get_type (void);
|
||||
|
||||
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);
|
||||
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);
|
||||
|
||||
|
||||
/* 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);
|
||||
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);
|
||||
|
||||
|
||||
#endif /* __GIMP_DATA_FACTORY_VIEW_H__ */
|
||||
|
@ -259,16 +259,6 @@ static void ed_initialize_saved_colors (GradientEditor *gradient_edi
|
||||
|
||||
/* Main dialog button callbacks & functions */
|
||||
|
||||
static void ed_save_pov_callback (GtkWidget *widget,
|
||||
GradientEditor *gradient_editor);
|
||||
static void ed_do_save_pov_callback (GtkWidget *widget,
|
||||
GradientEditor *gradient_editor);
|
||||
static void ed_cancel_save_pov_callback (GtkWidget *widget,
|
||||
GradientEditor *gradient_editor);
|
||||
static gint ed_delete_save_pov_callback (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
GradientEditor *gradient_editor);
|
||||
|
||||
static void ed_close_callback (GtkWidget *widget,
|
||||
GradientEditor *gradient_editor);
|
||||
|
||||
@ -710,20 +700,6 @@ gradient_editor_new (void)
|
||||
gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
/* Save as POV-Ray button */
|
||||
button = gtk_button_new_with_label (_("Save as POV-Ray"));
|
||||
gimp_help_set_help_data (button, NULL,
|
||||
"dialogs/gradient_editor/save_as_povray.html");
|
||||
gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child), 2, 0);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
||||
gtk_widget_show (button);
|
||||
|
||||
GTK_WIDGET_UNSET_FLAGS (button, GTK_RECEIVES_DEFAULT);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
GTK_SIGNAL_FUNC (ed_save_pov_callback),
|
||||
gradient_editor);
|
||||
|
||||
/* + and - buttons */
|
||||
gtk_widget_realize (gradient_editor->shell);
|
||||
|
||||
@ -994,134 +970,6 @@ ed_initialize_saved_colors (GradientEditor *gradient_editor)
|
||||
|
||||
/***** Main gradient editor dialog callbacks *****/
|
||||
|
||||
|
||||
/***** The "save as pov" dialog functions *****/
|
||||
|
||||
static void
|
||||
ed_save_pov_callback (GtkWidget *widget,
|
||||
GradientEditor *gradient_editor)
|
||||
{
|
||||
GimpGradient *gradient;
|
||||
GtkWidget *window;
|
||||
|
||||
gradient = gimp_context_get_gradient (gradient_editor->context);
|
||||
|
||||
if (! gradient)
|
||||
return;
|
||||
|
||||
window = gtk_file_selection_new (_("Save as POV-Ray"));
|
||||
gtk_window_set_wmclass (GTK_WINDOW (window), "save_gradient", "Gimp");
|
||||
gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_MOUSE);
|
||||
|
||||
gtk_container_set_border_width (GTK_CONTAINER (window), 2);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (GTK_FILE_SELECTION (window)->button_area), 2);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (window)->ok_button),
|
||||
"clicked",
|
||||
GTK_SIGNAL_FUNC (ed_do_save_pov_callback),
|
||||
gradient_editor);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (window)->cancel_button),
|
||||
"clicked",
|
||||
GTK_SIGNAL_FUNC (ed_cancel_save_pov_callback),
|
||||
gradient_editor);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (window), "delete_event",
|
||||
GTK_SIGNAL_FUNC (ed_delete_save_pov_callback),
|
||||
gradient_editor);
|
||||
|
||||
/* Connect the "F1" help key */
|
||||
gimp_help_connect_help_accel (window, gimp_standard_help_func,
|
||||
"dialogs/gradient_editor/save_as_povray.html");
|
||||
|
||||
gtk_widget_show (window);
|
||||
gtk_widget_set_sensitive (gradient_editor->shell, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
ed_do_save_pov_callback (GtkWidget *widget,
|
||||
GradientEditor *gradient_editor)
|
||||
{
|
||||
GimpGradient *gradient;
|
||||
gchar *filename;
|
||||
FILE *file;
|
||||
GimpGradientSegment *seg;
|
||||
|
||||
gradient = gimp_context_get_gradient (gradient_editor->context);
|
||||
|
||||
if (! gradient)
|
||||
return;
|
||||
|
||||
filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (gtk_widget_get_toplevel (widget)));
|
||||
|
||||
file = fopen (filename, "wb");
|
||||
|
||||
if (!file)
|
||||
{
|
||||
g_message ("Could not open \"%s\"", filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf (file, "/* color_map file created by the GIMP */\n");
|
||||
fprintf (file, "/* http://www.gimp.org/ */\n");
|
||||
|
||||
fprintf (file, "color_map {\n");
|
||||
|
||||
for (seg = gradient->segments; seg; seg = seg->next)
|
||||
{
|
||||
/* Left */
|
||||
fprintf (file, "\t[%f color rgbt <%f, %f, %f, %f>]\n",
|
||||
seg->left,
|
||||
seg->left_color.r,
|
||||
seg->left_color.g,
|
||||
seg->left_color.b,
|
||||
1.0 - seg->left_color.a);
|
||||
|
||||
/* Middle */
|
||||
fprintf (file, "\t[%f color rgbt <%f, %f, %f, %f>]\n",
|
||||
seg->middle,
|
||||
(seg->left_color.r + seg->right_color.r) / 2.0,
|
||||
(seg->left_color.g + seg->right_color.g) / 2.0,
|
||||
(seg->left_color.b + seg->right_color.b) / 2.0,
|
||||
1.0 - (seg->left_color.a + seg->right_color.a) / 2.0);
|
||||
|
||||
/* Right */
|
||||
fprintf (file, "\t[%f color rgbt <%f, %f, %f, %f>]\n",
|
||||
seg->right,
|
||||
seg->right_color.r,
|
||||
seg->right_color.g,
|
||||
seg->right_color.b,
|
||||
1.0 - seg->right_color.a);
|
||||
}
|
||||
|
||||
fprintf (file, "} /* color_map */\n");
|
||||
fclose (file);
|
||||
}
|
||||
|
||||
gtk_widget_destroy (gtk_widget_get_toplevel (widget));
|
||||
gtk_widget_set_sensitive (gradient_editor->shell, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
ed_cancel_save_pov_callback (GtkWidget *widget,
|
||||
GradientEditor *gradient_editor)
|
||||
{
|
||||
gtk_widget_destroy (gtk_widget_get_toplevel (widget));
|
||||
gtk_widget_set_sensitive (gradient_editor->shell, TRUE);
|
||||
}
|
||||
|
||||
static gint
|
||||
ed_delete_save_pov_callback (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
GradientEditor *gradient_editor)
|
||||
{
|
||||
ed_cancel_save_pov_callback (widget, gradient_editor);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/***** The main dialog action area button callbacks *****/
|
||||
|
||||
static void
|
||||
ed_close_callback (GtkWidget *widget,
|
||||
GradientEditor *gradient_editor)
|
||||
@ -1130,6 +978,7 @@ ed_close_callback (GtkWidget *widget,
|
||||
gtk_widget_hide (gradient_editor->shell);
|
||||
}
|
||||
|
||||
|
||||
/***** Zoom, scrollbar & instant update callbacks *****/
|
||||
|
||||
static void
|
||||
|
@ -45,15 +45,18 @@
|
||||
|
||||
#include "channels-commands.h"
|
||||
#include "commands.h"
|
||||
#include "data-commands.h"
|
||||
#include "dialog_handler.h"
|
||||
#include "dialogs-commands.h"
|
||||
#include "edit-commands.h"
|
||||
#include "file-commands.h"
|
||||
#include "file-open-dialog.h"
|
||||
#include "file-save-dialog.h"
|
||||
#include "gradients-commands.h"
|
||||
#include "image-commands.h"
|
||||
#include "layers-commands.h"
|
||||
#include "menus.h"
|
||||
#include "palettes-commands.h"
|
||||
#include "paths-dialog.h"
|
||||
#include "select-commands.h"
|
||||
#include "test-commands.h"
|
||||
@ -1267,6 +1270,156 @@ static guint n_dialogs_entries = (sizeof (dialogs_entries) /
|
||||
static GtkItemFactory *dialogs_factory = NULL;
|
||||
|
||||
|
||||
/***** <Brushes> *****/
|
||||
|
||||
static GimpItemFactoryEntry brushes_entries[] =
|
||||
{
|
||||
{ { N_("/New Brush"), NULL,
|
||||
data_new_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
{ { N_("/Duplicate Brush"), NULL,
|
||||
data_duplicate_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
{ { N_("/Edit Brush..."), NULL,
|
||||
data_edit_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
{ { N_("/Delete Brush..."), NULL,
|
||||
data_delete_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
|
||||
SEPARATOR ("/---"),
|
||||
|
||||
{ { N_("/Refresh Brushes"), NULL,
|
||||
data_refresh_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL }
|
||||
};
|
||||
static guint n_brushes_entries = (sizeof (brushes_entries) /
|
||||
sizeof (brushes_entries[0]));
|
||||
static GtkItemFactory *brushes_factory = NULL;
|
||||
|
||||
|
||||
/***** <Patterns> *****/
|
||||
|
||||
static GimpItemFactoryEntry patterns_entries[] =
|
||||
{
|
||||
{ { N_("/New Pattern"), NULL,
|
||||
data_new_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
{ { N_("/Duplicate Pattern"), NULL,
|
||||
data_duplicate_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
{ { N_("/Edit Pattern..."), NULL,
|
||||
data_edit_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
{ { N_("/Delete Pattern..."), NULL,
|
||||
data_delete_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
|
||||
SEPARATOR ("/---"),
|
||||
|
||||
{ { N_("/Refresh Patterns"), NULL,
|
||||
data_refresh_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL }
|
||||
};
|
||||
static guint n_patterns_entries = (sizeof (patterns_entries) /
|
||||
sizeof (patterns_entries[0]));
|
||||
static GtkItemFactory *patterns_factory = NULL;
|
||||
|
||||
|
||||
/***** <Gradients> *****/
|
||||
|
||||
static GimpItemFactoryEntry gradients_entries[] =
|
||||
{
|
||||
{ { N_("/New Gradient"), NULL,
|
||||
data_new_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
{ { N_("/Duplicate Gradient"), NULL,
|
||||
data_duplicate_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
{ { N_("/Edit Gradient..."), NULL,
|
||||
data_edit_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
{ { N_("/Delete Gradient..."), NULL,
|
||||
data_delete_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
|
||||
SEPARATOR ("/---"),
|
||||
|
||||
{ { N_("/Refresh Gradients"), NULL,
|
||||
data_refresh_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
|
||||
SEPARATOR ("/---"),
|
||||
|
||||
{ { N_("/Save as POV-Ray..."), NULL,
|
||||
gradients_save_as_pov_ray_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL }
|
||||
};
|
||||
static guint n_gradients_entries = (sizeof (gradients_entries) /
|
||||
sizeof (gradients_entries[0]));
|
||||
static GtkItemFactory *gradients_factory = NULL;
|
||||
|
||||
|
||||
/***** <Palettes> *****/
|
||||
|
||||
static GimpItemFactoryEntry palettes_entries[] =
|
||||
{
|
||||
{ { N_("/New Palette"), NULL,
|
||||
data_new_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
{ { N_("/Duplicate Palette"), NULL,
|
||||
data_duplicate_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
{ { N_("/Edit Palette..."), NULL,
|
||||
data_edit_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
{ { N_("/Delete Palette..."), NULL,
|
||||
data_delete_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
|
||||
SEPARATOR ("/---"),
|
||||
|
||||
{ { N_("/Refresh Palettes"), NULL,
|
||||
data_refresh_data_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
|
||||
SEPARATOR ("/---"),
|
||||
|
||||
{ { N_("/Import Palette..."), NULL,
|
||||
palettes_import_palette_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
{ { N_("/Merge Palettes..."), NULL,
|
||||
palettes_merge_palettes_cmd_callback, 0 },
|
||||
NULL,
|
||||
NULL, NULL }
|
||||
};
|
||||
static guint n_palettes_entries = (sizeof (palettes_entries) /
|
||||
sizeof (palettes_entries[0]));
|
||||
static GtkItemFactory *palettes_factory = NULL;
|
||||
|
||||
|
||||
static gboolean menus_initialized = FALSE;
|
||||
|
||||
|
||||
@ -1342,6 +1495,42 @@ menus_get_dialogs_factory (void)
|
||||
return dialogs_factory;
|
||||
}
|
||||
|
||||
GtkItemFactory *
|
||||
menus_get_brushes_factory (void)
|
||||
{
|
||||
if (! menus_initialized)
|
||||
menus_init ();
|
||||
|
||||
return brushes_factory;
|
||||
}
|
||||
|
||||
GtkItemFactory *
|
||||
menus_get_patterns_factory (void)
|
||||
{
|
||||
if (! menus_initialized)
|
||||
menus_init ();
|
||||
|
||||
return patterns_factory;
|
||||
}
|
||||
|
||||
GtkItemFactory *
|
||||
menus_get_gradients_factory (void)
|
||||
{
|
||||
if (! menus_initialized)
|
||||
menus_init ();
|
||||
|
||||
return gradients_factory;
|
||||
}
|
||||
|
||||
GtkItemFactory *
|
||||
menus_get_palettes_factory (void)
|
||||
{
|
||||
if (! menus_initialized)
|
||||
menus_init ();
|
||||
|
||||
return palettes_factory;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
menus_create_item_from_full_path (GimpItemFactoryEntry *entry,
|
||||
@ -2243,6 +2432,54 @@ menus_init (void)
|
||||
FALSE,
|
||||
TRUE);
|
||||
|
||||
brushes_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<Brushes>", NULL);
|
||||
gtk_object_set_data (GTK_OBJECT (brushes_factory), "factory_path",
|
||||
"brushes");
|
||||
gtk_item_factory_set_translate_func (dialogs_factory, menu_translate,
|
||||
"<Brushes>", NULL);
|
||||
menus_create_items (brushes_factory,
|
||||
n_brushes_entries,
|
||||
brushes_entries,
|
||||
NULL, 2,
|
||||
FALSE,
|
||||
TRUE);
|
||||
|
||||
patterns_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<Patterns>", NULL);
|
||||
gtk_object_set_data (GTK_OBJECT (patterns_factory), "factory_path",
|
||||
"patterns");
|
||||
gtk_item_factory_set_translate_func (dialogs_factory, menu_translate,
|
||||
"<Patterns>", NULL);
|
||||
menus_create_items (patterns_factory,
|
||||
n_patterns_entries,
|
||||
patterns_entries,
|
||||
NULL, 2,
|
||||
FALSE,
|
||||
TRUE);
|
||||
|
||||
gradients_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<Gradients>", NULL);
|
||||
gtk_object_set_data (GTK_OBJECT (gradients_factory), "factory_path",
|
||||
"gradients");
|
||||
gtk_item_factory_set_translate_func (dialogs_factory, menu_translate,
|
||||
"<Gradients>", NULL);
|
||||
menus_create_items (gradients_factory,
|
||||
n_gradients_entries,
|
||||
gradients_entries,
|
||||
NULL, 2,
|
||||
FALSE,
|
||||
TRUE);
|
||||
|
||||
palettes_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<Palettes>", NULL);
|
||||
gtk_object_set_data (GTK_OBJECT (palettes_factory), "factory_path",
|
||||
"palettes");
|
||||
gtk_item_factory_set_translate_func (dialogs_factory, menu_translate,
|
||||
"<Palettes>", NULL);
|
||||
menus_create_items (palettes_factory,
|
||||
n_palettes_entries,
|
||||
palettes_entries,
|
||||
NULL, 2,
|
||||
FALSE,
|
||||
TRUE);
|
||||
|
||||
|
||||
for (list = GIMP_LIST (the_gimp->tool_info_list)->list;
|
||||
list;
|
||||
|
@ -36,14 +36,18 @@ struct _GimpItemFactoryEntry
|
||||
extern GSList *last_opened_raw_filenames;
|
||||
|
||||
|
||||
GtkItemFactory * menus_get_toolbox_factory (void);
|
||||
GtkItemFactory * menus_get_image_factory (void);
|
||||
GtkItemFactory * menus_get_load_factory (void);
|
||||
GtkItemFactory * menus_get_save_factory (void);
|
||||
GtkItemFactory * menus_get_layers_factory (void);
|
||||
GtkItemFactory * menus_get_channels_factory (void);
|
||||
GtkItemFactory * menus_get_paths_factory (void);
|
||||
GtkItemFactory * menus_get_dialogs_factory (void);
|
||||
GtkItemFactory * menus_get_toolbox_factory (void);
|
||||
GtkItemFactory * menus_get_image_factory (void);
|
||||
GtkItemFactory * menus_get_load_factory (void);
|
||||
GtkItemFactory * menus_get_save_factory (void);
|
||||
GtkItemFactory * menus_get_layers_factory (void);
|
||||
GtkItemFactory * menus_get_channels_factory (void);
|
||||
GtkItemFactory * menus_get_paths_factory (void);
|
||||
GtkItemFactory * menus_get_dialogs_factory (void);
|
||||
GtkItemFactory * menus_get_brushes_factory (void);
|
||||
GtkItemFactory * menus_get_patterns_factory (void);
|
||||
GtkItemFactory * menus_get_gradients_factory (void);
|
||||
GtkItemFactory * menus_get_palettes_factory (void);
|
||||
|
||||
|
||||
void menus_create_item_from_full_path (GimpItemFactoryEntry *entry,
|
||||
|
@ -41,7 +41,6 @@
|
||||
#include "color-area.h"
|
||||
#include "color-notebook.h"
|
||||
#include "palette-editor.h"
|
||||
#include "palette-import-dialog.h"
|
||||
#include "palette-select.h"
|
||||
|
||||
#include "app_procs.h"
|
||||
@ -138,13 +137,6 @@ static void palette_dialog_zoomin_callback (GtkWidget *widget,
|
||||
static void palette_dialog_zoomout_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void palette_dialog_redraw_zoom (PaletteDialog *palette_dialog);
|
||||
static void palette_dialog_import_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void palette_dialog_merge_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void palette_dialog_do_merge_callback (GtkWidget *widget,
|
||||
gchar *palette_name,
|
||||
gpointer data);
|
||||
static void palette_dialog_close_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void palette_dialog_palette_changed (GimpContext *context,
|
||||
@ -193,8 +185,6 @@ palette_dialog_free (void)
|
||||
{
|
||||
if (top_level_edit_palette)
|
||||
{
|
||||
palette_import_dialog_destroy ();
|
||||
|
||||
if (top_level_edit_palette->color_notebook)
|
||||
color_notebook_free (top_level_edit_palette->color_notebook);
|
||||
|
||||
@ -321,7 +311,6 @@ palette_dialog_new (gboolean editor)
|
||||
GtkWidget *entry;
|
||||
GtkWidget *eventbox;
|
||||
GtkWidget *alignment;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *button;
|
||||
|
||||
palette_dialog = g_new0 (PaletteDialog, 1);
|
||||
@ -475,7 +464,8 @@ palette_dialog_new (gboolean editor)
|
||||
editor ? NULL : palette_dialog_edit_palette,
|
||||
palette_dialog->context,
|
||||
SM_PREVIEW_HEIGHT,
|
||||
2, 4);
|
||||
2, 4,
|
||||
NULL);
|
||||
|
||||
if (! editor)
|
||||
{
|
||||
@ -506,40 +496,6 @@ palette_dialog_new (gboolean editor)
|
||||
|
||||
gtk_widget_show (palette_dialog->view);
|
||||
|
||||
if (editor)
|
||||
{
|
||||
frame = gtk_frame_new (_("Palette Ops"));
|
||||
gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, FALSE, 0);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 2);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
|
||||
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
button = gtk_button_new_with_label (_("Import"));
|
||||
GTK_WIDGET_UNSET_FLAGS (button, GTK_RECEIVES_DEFAULT);
|
||||
gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child), 2, 0);
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
GTK_SIGNAL_FUNC (palette_dialog_import_callback),
|
||||
palette_dialog);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
||||
gimp_help_set_help_data (button, NULL,
|
||||
"dialogs/palette_editor/import_palette.html");
|
||||
gtk_widget_show (button);
|
||||
|
||||
button = gtk_button_new_with_label (_("Merge"));
|
||||
GTK_WIDGET_UNSET_FLAGS (button, GTK_RECEIVES_DEFAULT);
|
||||
gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child), 2, 0);
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
GTK_SIGNAL_FUNC (palette_dialog_merge_callback),
|
||||
palette_dialog);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
||||
gimp_help_set_help_data (button, NULL,
|
||||
"dialogs/palette_editor/merge_palette.html");
|
||||
gtk_widget_show (button);
|
||||
}
|
||||
|
||||
gtk_widget_realize (palette_dialog->shell);
|
||||
|
||||
palette_dialog_create_popup_menu (palette_dialog);
|
||||
@ -1274,77 +1230,6 @@ palette_dialog_redraw_zoom (PaletteDialog *palette_dialog)
|
||||
|
||||
/* the palette dialog action callbacks **************************************/
|
||||
|
||||
static void
|
||||
palette_dialog_import_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
palette_import_dialog_show ();
|
||||
}
|
||||
|
||||
static void
|
||||
palette_dialog_merge_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GtkWidget *qbox;
|
||||
|
||||
qbox = gimp_query_string_box (_("Merge Palette"),
|
||||
gimp_standard_help_func,
|
||||
"dialogs/palette_editor/merge_palette.html",
|
||||
_("Enter a name for merged palette"),
|
||||
NULL,
|
||||
NULL, NULL,
|
||||
palette_dialog_do_merge_callback,
|
||||
data);
|
||||
gtk_widget_show (qbox);
|
||||
}
|
||||
|
||||
static void
|
||||
palette_dialog_do_merge_callback (GtkWidget *widget,
|
||||
gchar *palette_name,
|
||||
gpointer data)
|
||||
{
|
||||
PaletteDialog *palette_dialog;
|
||||
GimpPalette *palette;
|
||||
GimpPalette *new_palette;
|
||||
GimpPaletteEntry *entry;
|
||||
GList *sel_list;
|
||||
|
||||
new_palette = GIMP_PALETTE (gimp_palette_new (palette_name));
|
||||
|
||||
palette_dialog = (PaletteDialog *) data;
|
||||
|
||||
sel_list = GTK_LIST (GIMP_CONTAINER_LIST_VIEW (GIMP_CONTAINER_EDITOR (palette_dialog->view)->view)->gtk_list)->selection;
|
||||
|
||||
while (sel_list)
|
||||
{
|
||||
GtkWidget *list_item;
|
||||
GList *cols;
|
||||
|
||||
list_item = GTK_WIDGET (sel_list->data);
|
||||
|
||||
palette = (GimpPalette *)
|
||||
GIMP_PREVIEW (gtk_object_get_data (GTK_OBJECT (list_item),
|
||||
"preview"))->viewable;
|
||||
|
||||
if (palette)
|
||||
{
|
||||
for (cols = palette->colors; cols; cols = g_list_next (cols))
|
||||
{
|
||||
entry = (GimpPaletteEntry *) cols->data;
|
||||
|
||||
gimp_palette_add_entry (new_palette,
|
||||
entry->name,
|
||||
&entry->color);
|
||||
}
|
||||
}
|
||||
|
||||
sel_list = sel_list->next;
|
||||
}
|
||||
|
||||
gimp_container_add (the_gimp->palette_factory->container,
|
||||
GIMP_OBJECT (new_palette));
|
||||
}
|
||||
|
||||
static void
|
||||
palette_dialog_close_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
@ -1361,11 +1246,6 @@ palette_dialog_close_callback (GtkWidget *widget,
|
||||
palette_dialog->color_notebook_active = FALSE;
|
||||
}
|
||||
|
||||
if (palette_dialog == top_level_edit_palette)
|
||||
{
|
||||
palette_import_dialog_destroy ();
|
||||
}
|
||||
|
||||
if (GTK_WIDGET_VISIBLE (palette_dialog->shell))
|
||||
gtk_widget_hide (palette_dialog->shell);
|
||||
}
|
||||
|
@ -70,6 +70,7 @@ enum
|
||||
CLICKED,
|
||||
DOUBLE_CLICKED,
|
||||
EXTENDED_CLICKED,
|
||||
CONTEXT,
|
||||
RENDER,
|
||||
GET_SIZE,
|
||||
NEEDS_POPUP,
|
||||
@ -187,6 +188,15 @@ gimp_preview_class_init (GimpPreviewClass *klass)
|
||||
GTK_TYPE_NONE, 1,
|
||||
GTK_TYPE_UINT);
|
||||
|
||||
preview_signals[CONTEXT] =
|
||||
gtk_signal_new ("context",
|
||||
GTK_RUN_FIRST,
|
||||
object_class->type,
|
||||
GTK_SIGNAL_OFFSET (GimpPreviewClass,
|
||||
context),
|
||||
gtk_signal_default_marshaller,
|
||||
GTK_TYPE_NONE, 0);
|
||||
|
||||
preview_signals[RENDER] =
|
||||
gtk_signal_new ("render",
|
||||
GTK_RUN_LAST,
|
||||
@ -239,6 +249,7 @@ gimp_preview_class_init (GimpPreviewClass *klass)
|
||||
klass->clicked = NULL;
|
||||
klass->double_clicked = NULL;
|
||||
klass->extended_clicked = NULL;
|
||||
klass->context = NULL;
|
||||
klass->render = gimp_preview_real_render;
|
||||
klass->get_size = gimp_preview_real_get_size;
|
||||
klass->needs_popup = gimp_preview_real_needs_popup;
|
||||
@ -591,6 +602,10 @@ gimp_preview_button_press_event (GtkWidget *widget,
|
||||
bevent->y);
|
||||
}
|
||||
}
|
||||
else if (bevent->button == 3)
|
||||
{
|
||||
gtk_signal_emit (GTK_OBJECT (widget), preview_signals[CONTEXT]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
|
@ -75,6 +75,8 @@ struct _GimpPreviewClass
|
||||
void (* double_clicked) (GimpPreview *preview);
|
||||
void (* extended_clicked) (GimpPreview *preview,
|
||||
guint modifier_state);
|
||||
void (* context) (GimpPreview *preview);
|
||||
|
||||
void (* render) (GimpPreview *preview);
|
||||
void (* get_size) (GimpPreview *preview,
|
||||
gint size,
|
||||
|
@ -70,6 +70,7 @@ enum
|
||||
CLICKED,
|
||||
DOUBLE_CLICKED,
|
||||
EXTENDED_CLICKED,
|
||||
CONTEXT,
|
||||
RENDER,
|
||||
GET_SIZE,
|
||||
NEEDS_POPUP,
|
||||
@ -187,6 +188,15 @@ gimp_preview_class_init (GimpPreviewClass *klass)
|
||||
GTK_TYPE_NONE, 1,
|
||||
GTK_TYPE_UINT);
|
||||
|
||||
preview_signals[CONTEXT] =
|
||||
gtk_signal_new ("context",
|
||||
GTK_RUN_FIRST,
|
||||
object_class->type,
|
||||
GTK_SIGNAL_OFFSET (GimpPreviewClass,
|
||||
context),
|
||||
gtk_signal_default_marshaller,
|
||||
GTK_TYPE_NONE, 0);
|
||||
|
||||
preview_signals[RENDER] =
|
||||
gtk_signal_new ("render",
|
||||
GTK_RUN_LAST,
|
||||
@ -239,6 +249,7 @@ gimp_preview_class_init (GimpPreviewClass *klass)
|
||||
klass->clicked = NULL;
|
||||
klass->double_clicked = NULL;
|
||||
klass->extended_clicked = NULL;
|
||||
klass->context = NULL;
|
||||
klass->render = gimp_preview_real_render;
|
||||
klass->get_size = gimp_preview_real_get_size;
|
||||
klass->needs_popup = gimp_preview_real_needs_popup;
|
||||
@ -591,6 +602,10 @@ gimp_preview_button_press_event (GtkWidget *widget,
|
||||
bevent->y);
|
||||
}
|
||||
}
|
||||
else if (bevent->button == 3)
|
||||
{
|
||||
gtk_signal_emit (GTK_OBJECT (widget), preview_signals[CONTEXT]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
|
@ -75,6 +75,8 @@ struct _GimpPreviewClass
|
||||
void (* double_clicked) (GimpPreview *preview);
|
||||
void (* extended_clicked) (GimpPreview *preview,
|
||||
guint modifier_state);
|
||||
void (* context) (GimpPreview *preview);
|
||||
|
||||
void (* render) (GimpPreview *preview);
|
||||
void (* get_size) (GimpPreview *preview,
|
||||
gint size,
|
||||
|
@ -70,6 +70,7 @@ enum
|
||||
CLICKED,
|
||||
DOUBLE_CLICKED,
|
||||
EXTENDED_CLICKED,
|
||||
CONTEXT,
|
||||
RENDER,
|
||||
GET_SIZE,
|
||||
NEEDS_POPUP,
|
||||
@ -187,6 +188,15 @@ gimp_preview_class_init (GimpPreviewClass *klass)
|
||||
GTK_TYPE_NONE, 1,
|
||||
GTK_TYPE_UINT);
|
||||
|
||||
preview_signals[CONTEXT] =
|
||||
gtk_signal_new ("context",
|
||||
GTK_RUN_FIRST,
|
||||
object_class->type,
|
||||
GTK_SIGNAL_OFFSET (GimpPreviewClass,
|
||||
context),
|
||||
gtk_signal_default_marshaller,
|
||||
GTK_TYPE_NONE, 0);
|
||||
|
||||
preview_signals[RENDER] =
|
||||
gtk_signal_new ("render",
|
||||
GTK_RUN_LAST,
|
||||
@ -239,6 +249,7 @@ gimp_preview_class_init (GimpPreviewClass *klass)
|
||||
klass->clicked = NULL;
|
||||
klass->double_clicked = NULL;
|
||||
klass->extended_clicked = NULL;
|
||||
klass->context = NULL;
|
||||
klass->render = gimp_preview_real_render;
|
||||
klass->get_size = gimp_preview_real_get_size;
|
||||
klass->needs_popup = gimp_preview_real_needs_popup;
|
||||
@ -591,6 +602,10 @@ gimp_preview_button_press_event (GtkWidget *widget,
|
||||
bevent->y);
|
||||
}
|
||||
}
|
||||
else if (bevent->button == 3)
|
||||
{
|
||||
gtk_signal_emit (GTK_OBJECT (widget), preview_signals[CONTEXT]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
|
@ -75,6 +75,8 @@ struct _GimpPreviewClass
|
||||
void (* double_clicked) (GimpPreview *preview);
|
||||
void (* extended_clicked) (GimpPreview *preview,
|
||||
guint modifier_state);
|
||||
void (* context) (GimpPreview *preview);
|
||||
|
||||
void (* render) (GimpPreview *preview);
|
||||
void (* get_size) (GimpPreview *preview,
|
||||
gint size,
|
||||
|
@ -70,6 +70,7 @@ enum
|
||||
CLICKED,
|
||||
DOUBLE_CLICKED,
|
||||
EXTENDED_CLICKED,
|
||||
CONTEXT,
|
||||
RENDER,
|
||||
GET_SIZE,
|
||||
NEEDS_POPUP,
|
||||
@ -187,6 +188,15 @@ gimp_preview_class_init (GimpPreviewClass *klass)
|
||||
GTK_TYPE_NONE, 1,
|
||||
GTK_TYPE_UINT);
|
||||
|
||||
preview_signals[CONTEXT] =
|
||||
gtk_signal_new ("context",
|
||||
GTK_RUN_FIRST,
|
||||
object_class->type,
|
||||
GTK_SIGNAL_OFFSET (GimpPreviewClass,
|
||||
context),
|
||||
gtk_signal_default_marshaller,
|
||||
GTK_TYPE_NONE, 0);
|
||||
|
||||
preview_signals[RENDER] =
|
||||
gtk_signal_new ("render",
|
||||
GTK_RUN_LAST,
|
||||
@ -239,6 +249,7 @@ gimp_preview_class_init (GimpPreviewClass *klass)
|
||||
klass->clicked = NULL;
|
||||
klass->double_clicked = NULL;
|
||||
klass->extended_clicked = NULL;
|
||||
klass->context = NULL;
|
||||
klass->render = gimp_preview_real_render;
|
||||
klass->get_size = gimp_preview_real_get_size;
|
||||
klass->needs_popup = gimp_preview_real_needs_popup;
|
||||
@ -591,6 +602,10 @@ gimp_preview_button_press_event (GtkWidget *widget,
|
||||
bevent->y);
|
||||
}
|
||||
}
|
||||
else if (bevent->button == 3)
|
||||
{
|
||||
gtk_signal_emit (GTK_OBJECT (widget), preview_signals[CONTEXT]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
|
@ -75,6 +75,8 @@ struct _GimpPreviewClass
|
||||
void (* double_clicked) (GimpPreview *preview);
|
||||
void (* extended_clicked) (GimpPreview *preview,
|
||||
guint modifier_state);
|
||||
void (* context) (GimpPreview *preview);
|
||||
|
||||
void (* render) (GimpPreview *preview);
|
||||
void (* get_size) (GimpPreview *preview,
|
||||
gint size,
|
||||
|
Reference in New Issue
Block a user