app/gui/Makefile.am app/gui/brush-select.[ch] app/gui/font-select.[ch]

2004-07-09  Michael Natterer  <mitch@gimp.org>

	* app/gui/Makefile.am
	* app/gui/brush-select.[ch]
	* app/gui/font-select.[ch]
	* app/gui/gradient-select.[ch]
	* app/gui/palette-select.[ch]
	* app/gui/pattern-select.[ch]: removed...

	* app/widgets/Makefile.am
	* app/widgets/widgets-types.h
	* app/widgets/gimppdbdialog.[ch]
	* app/widgets/gimpdataselect.[ch]
	* app/widgets/gimpbrushselect.[ch]
	* app/widgets/gimpgradientselect.[ch]
	* app/widgets/gimppaletteselect.[ch]
	* app/widgets/gimppatternselect.[ch]
	* app/widgets/gimpfontselect.[ch]: ...and added here as a
	hierarchy of widgets.

	* app/widgets/gimpdatafactoryview.h: removed typdef
	GimpDataEditFunc, it's in widgets-types.h now.

	* app/gui/convert-dialog.c: changed accordingly.

	* app/core/gimp.[ch]: added vtable entries for creating, closing
	and setting PDB dialogs.

	* app/gui/gui-vtable.c: implement the vtable entries using the new
	widgets.

	* tools/pdbgen/pdb/brush_select.pdb
	* tools/pdbgen/pdb/font_select.pdb
	* tools/pdbgen/pdb/gradient_select.pdb
	* tools/pdbgen/pdb/palette_select.pdb
	* tools/pdbgen/pdb/pattern_select.pdb: use the new functions of
	the Gimp object to create / manage the selection dialogs. The
	generated files don't depend on GUI stuff any longer.

	* app/pdb/brush_select_cmds.c
	* app/pdb/font_select_cmds.c
	* app/pdb/gradient_select_cmds.c
	* app/pdb/palette_select_cmds.c
	* app/pdb/pattern_select_cmds.c: regenerated.
This commit is contained in:
Michael Natterer 2004-07-09 19:14:59 +00:00 committed by Michael Natterer
parent ac9e95bb6f
commit 8d9e362249
44 changed files with 2732 additions and 2348 deletions

View File

@ -1,3 +1,48 @@
2004-07-09 Michael Natterer <mitch@gimp.org>
* app/gui/Makefile.am
* app/gui/brush-select.[ch]
* app/gui/font-select.[ch]
* app/gui/gradient-select.[ch]
* app/gui/palette-select.[ch]
* app/gui/pattern-select.[ch]: removed...
* app/widgets/Makefile.am
* app/widgets/widgets-types.h
* app/widgets/gimppdbdialog.[ch]
* app/widgets/gimpdataselect.[ch]
* app/widgets/gimpbrushselect.[ch]
* app/widgets/gimpgradientselect.[ch]
* app/widgets/gimppaletteselect.[ch]
* app/widgets/gimppatternselect.[ch]
* app/widgets/gimpfontselect.[ch]: ...and added here as a
hierarchy of widgets.
* app/widgets/gimpdatafactoryview.h: removed typdef
GimpDataEditFunc, it's in widgets-types.h now.
* app/gui/convert-dialog.c: changed accordingly.
* app/core/gimp.[ch]: added vtable entries for creating, closing
and setting PDB dialogs.
* app/gui/gui-vtable.c: implement the vtable entries using the new
widgets.
* tools/pdbgen/pdb/brush_select.pdb
* tools/pdbgen/pdb/font_select.pdb
* tools/pdbgen/pdb/gradient_select.pdb
* tools/pdbgen/pdb/palette_select.pdb
* tools/pdbgen/pdb/pattern_select.pdb: use the new functions of
the Gimp object to create / manage the selection dialogs. The
generated files don't depend on GUI stuff any longer.
* app/pdb/brush_select_cmds.c
* app/pdb/font_select_cmds.c
* app/pdb/gradient_select_cmds.c
* app/pdb/palette_select_cmds.c
* app/pdb/pattern_select_cmds.c: regenerated.
2004-07-09 Sven Neumann <sven@gimp.org>
* app/gui/file-save-dialog.c (file_save_overwrite): improved text

View File

@ -223,6 +223,11 @@ gimp_init (Gimp *gimp)
gimp->gui_progress_restart_func = NULL;
gimp->gui_progress_update_func = NULL;
gimp->gui_progress_end_func = NULL;
gimp->gui_get_program_class_func = NULL;
gimp->gui_get_display_name_func = NULL;
gimp->gui_get_theme_dir_func = NULL;
gimp->gui_pdb_dialog_set_func = NULL;
gimp->gui_pdb_dialog_close_func = NULL;
gimp->gui_pdb_dialogs_check_func = NULL;
gimp->busy = 0;
@ -1128,15 +1133,6 @@ gimp_end_progress (Gimp *gimp,
gimp->gui_progress_end_func (gimp, progress);
}
void
gimp_pdb_dialogs_check (Gimp *gimp)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
if (gimp->gui_pdb_dialogs_check_func)
gimp->gui_pdb_dialogs_check_func (gimp);
}
const gchar *
gimp_get_program_class (Gimp *gimp)
{
@ -1175,6 +1171,92 @@ gimp_get_theme_dir (Gimp *gimp)
return NULL;
}
gboolean
gimp_pdb_dialog_new (Gimp *gimp,
GimpContext *context,
GimpContainer *container,
const gchar *title,
const gchar *callback_name,
const gchar *object_name,
...)
{
gboolean retval = FALSE;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), FALSE);
g_return_val_if_fail (GIMP_IS_CONTAINER (container), FALSE);
g_return_val_if_fail (title != NULL, FALSE);
g_return_val_if_fail (callback_name != NULL, FALSE);
if (gimp->gui_pdb_dialog_new_func)
{
va_list args;
va_start (args, object_name);
retval = gimp->gui_pdb_dialog_new_func (gimp, context, container, title,
callback_name, object_name,
args);
va_end (args);
}
return retval;
}
gboolean
gimp_pdb_dialog_set (Gimp *gimp,
GimpContainer *container,
const gchar *callback_name,
const gchar *object_name,
...)
{
gboolean retval = FALSE;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE);
g_return_val_if_fail (GIMP_IS_CONTAINER (container), FALSE);
g_return_val_if_fail (callback_name != NULL, FALSE);
g_return_val_if_fail (object_name != NULL, FALSE);
if (gimp->gui_pdb_dialog_set_func)
{
va_list args;
va_start (args, object_name);
retval = gimp->gui_pdb_dialog_set_func (gimp, container, callback_name,
object_name, args);
va_end (args);
}
return retval;
}
gboolean
gimp_pdb_dialog_close (Gimp *gimp,
GimpContainer *container,
const gchar *callback_name)
{
g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE);
g_return_val_if_fail (GIMP_IS_CONTAINER (container), FALSE);
g_return_val_if_fail (callback_name != NULL, FALSE);
if (gimp->gui_pdb_dialog_close_func)
return gimp->gui_pdb_dialog_close_func (gimp, container, callback_name);
return FALSE;
}
void
gimp_pdb_dialogs_check (Gimp *gimp)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
if (gimp->gui_pdb_dialogs_check_func)
gimp->gui_pdb_dialogs_check_func (gimp);
}
GimpImage *
gimp_create_image (Gimp *gimp,
gint width,

View File

@ -55,12 +55,27 @@ typedef void (* GimpProgressUpdateFunc) (Gimp *gimp,
gdouble percentage);
typedef void (* GimpProgressEndFunc) (Gimp *gimp,
GimpProgress *progress);
typedef void (* GimpPDBDialogsCheckFunc) (Gimp *gimp);
typedef const gchar * (* GimpGetProgramClassFunc) (Gimp *gimp);
typedef gchar * (* GimpGetDisplayNameFunc) (Gimp *gimp,
gint gdisp_ID,
gint *monitor_number);
typedef const gchar * (* GimpGetThemeDirFunc) (Gimp *);
typedef const gchar * (* GimpGetThemeDirFunc) (Gimp *gimp);
typedef gboolean (* GimpPDBDialogNewFunc) (Gimp *gimp,
GimpContext *context,
GimpContainer *container,
const gchar *title,
const gchar *callback_name,
const gchar *object_name,
va_list args);
typedef gboolean (* GimpPDBDialogSetFunc) (Gimp *gimp,
GimpContainer *container,
const gchar *callback_name,
const gchar *object_name,
va_list args);
typedef gboolean (* GimpPDBDialogCloseFunc) (Gimp *gimp,
GimpContainer *container,
const gchar *callback_name);
typedef void (* GimpPDBDialogsCheckFunc) (Gimp *gimp);
#define GIMP_TYPE_GIMP (gimp_get_type ())
@ -105,10 +120,13 @@ struct _Gimp
GimpProgressRestartFunc gui_progress_restart_func;
GimpProgressUpdateFunc gui_progress_update_func;
GimpProgressEndFunc gui_progress_end_func;
GimpPDBDialogsCheckFunc gui_pdb_dialogs_check_func;
GimpGetProgramClassFunc gui_get_program_class_func;
GimpGetDisplayNameFunc gui_get_display_name_func;
GimpGetThemeDirFunc gui_get_theme_dir_func;
GimpPDBDialogNewFunc gui_pdb_dialog_new_func;
GimpPDBDialogSetFunc gui_pdb_dialog_set_func;
GimpPDBDialogCloseFunc gui_pdb_dialog_close_func;
GimpPDBDialogsCheckFunc gui_pdb_dialogs_check_func;
gint busy;
guint busy_idle_id;
@ -262,12 +280,27 @@ void gimp_update_progress (Gimp *gimp,
gdouble percentage);
void gimp_end_progress (Gimp *gimp,
GimpProgress *progress);
void gimp_pdb_dialogs_check (Gimp *gimp);
const gchar * gimp_get_program_class (Gimp *gimp);
gchar * gimp_get_display_name (Gimp *gimp,
gint gdisp_ID,
gint *monitor_number);
const gchar * gimp_get_theme_dir (Gimp *gimp);
gboolean gimp_pdb_dialog_new (Gimp *gimp,
GimpContext *context,
GimpContainer *container,
const gchar *title,
const gchar *callback_name,
const gchar *object_name,
...);
gboolean gimp_pdb_dialog_set (Gimp *gimp,
GimpContainer *container,
const gchar *callback_name,
const gchar *object_name,
...);
gboolean gimp_pdb_dialog_close (Gimp *gimp,
GimpContainer *container,
const gchar *callback_name);
void gimp_pdb_dialogs_check (Gimp *gimp);
GimpImage * gimp_create_image (Gimp *gimp,
gint width,

View File

@ -33,9 +33,10 @@
#include "widgets/gimpenumwidgets.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimppaletteselect.h"
#include "widgets/gimpviewabledialog.h"
#include "palette-select.h"
#include "menus/menus.h"
#include "gimp-intl.h"
@ -45,7 +46,7 @@ typedef struct
GtkWidget *shell;
GtkWidget *custom_palette_button;
GimpImage *gimage;
PaletteSelect *palette_select;
GimpPdbDialog *palette_select;
GimpConvertDitherType dither_type;
gboolean alpha_dither;
gboolean remove_dups;
@ -55,18 +56,21 @@ typedef struct
} IndexedDialog;
static void indexed_response (GtkWidget *widget,
gint response_id,
IndexedDialog *dialog);
static void indexed_destroy_callback (GtkWidget *widget,
IndexedDialog *dialog);
static void indexed_response (GtkWidget *widget,
gint response_id,
IndexedDialog *dialog);
static void indexed_destroy (GtkWidget *widget,
IndexedDialog *dialog);
static void indexed_custom_palette_button_callback (GtkWidget *widget,
IndexedDialog *dialog);
static void indexed_palette_select_destroy_callback (GtkWidget *widget,
IndexedDialog *dialog);
static void indexed_custom_palette_button_callback (GtkWidget *widget,
IndexedDialog *dialog);
static void indexed_palette_select_destroy (GtkWidget *widget,
IndexedDialog *dialog);
static void indexed_palette_select_changed (GimpContext *context,
GimpPalette *palette,
IndexedDialog *dialog);
static GtkWidget * build_palette_button (Gimp *gimp);
static GtkWidget * build_palette_button (Gimp *gimp);
static gboolean UserHasWebPal = FALSE;
@ -129,7 +133,7 @@ convert_dialog_new (GimpImage *gimage,
dialog);
g_signal_connect (dialog->shell, "destroy",
G_CALLBACK (indexed_destroy_callback),
G_CALLBACK (indexed_destroy),
dialog);
main_vbox = gtk_vbox_new (FALSE, 12);
@ -433,24 +437,53 @@ indexed_response (GtkWidget *widget,
}
static void
indexed_destroy_callback (GtkWidget *widget,
IndexedDialog *dialog)
indexed_destroy (GtkWidget *widget,
IndexedDialog *dialog)
{
if (dialog->palette_select)
gtk_widget_destroy (dialog->palette_select->shell);
gtk_widget_destroy (GTK_WIDGET (dialog->palette_select));
g_free (dialog);
}
static void
indexed_palette_select_destroy_callback (GtkWidget *widget,
IndexedDialog *dialog)
indexed_custom_palette_button_callback (GtkWidget *widget,
IndexedDialog *dialog)
{
if (! dialog->palette_select)
{
dialog->palette_select =
g_object_new (GIMP_TYPE_PALETTE_SELECT,
"title", _("Select Custom Palette"),
"role", "gimp-pelette-selection",
"help-func", gimp_standard_help_func,
"help_id", GIMP_HELP_PALETTE_DIALOG,
"context", gimp_get_user_context (dialog->gimage->gimp),
"select-type", GIMP_TYPE_PALETTE,
"initial-object", theCustomPalette,
"menu-factory", global_menu_factory,
NULL);
g_signal_connect (dialog->palette_select, "destroy",
G_CALLBACK (indexed_palette_select_destroy),
dialog);
g_signal_connect (dialog->palette_select->context, "palette_changed",
G_CALLBACK (indexed_palette_select_changed),
dialog);
}
gtk_window_present (GTK_WINDOW (dialog->palette_select));
}
static void
indexed_palette_select_destroy (GtkWidget *widget,
IndexedDialog *dialog)
{
dialog->palette_select = NULL;
}
static void
indexed_palette_select_palette (GimpContext *context,
indexed_palette_select_changed (GimpContext *context,
GimpPalette *palette,
IndexedDialog *dialog)
{
@ -469,30 +502,3 @@ indexed_palette_select_palette (GimpContext *context,
gimp_object_get_name (GIMP_OBJECT (palette)));
}
}
static void
indexed_custom_palette_button_callback (GtkWidget *widget,
IndexedDialog *dialog)
{
if (dialog->palette_select == NULL)
{
dialog->palette_select =
palette_select_new (dialog->gimage->gimp,
gimp_get_user_context (dialog->gimage->gimp),
_("Select Custom Palette"),
GIMP_OBJECT (theCustomPalette)->name,
NULL);
g_signal_connect (dialog->palette_select->shell, "destroy",
G_CALLBACK (indexed_palette_select_destroy_callback),
dialog);
g_signal_connect (dialog->palette_select->context,
"palette_changed",
G_CALLBACK (indexed_palette_select_palette),
dialog);
}
else
{
gtk_window_present (GTK_WINDOW (dialog->palette_select->shell));
}
}

View File

@ -5,8 +5,6 @@ noinst_LIBRARIES = libappgui.a
dialogs_sources = \
about-dialog.c \
about-dialog.h \
brush-select.c \
brush-select.h \
color-notebook.c \
color-notebook.h \
convert-dialog.c \
@ -25,10 +23,6 @@ dialogs_sources = \
file-open-location-dialog.h \
file-save-dialog.c \
file-save-dialog.h \
font-select.c \
font-select.h \
gradient-select.c \
gradient-select.h \
grid-dialog.h \
grid-dialog.c \
info-dialog.c \
@ -41,10 +35,6 @@ dialogs_sources = \
offset-dialog.h \
palette-import-dialog.c \
palette-import-dialog.h \
palette-select.c \
palette-select.h \
pattern-select.c \
pattern-select.h \
preferences-dialog.c \
preferences-dialog.h \
resize-dialog.c \

View File

@ -1,421 +0,0 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <string.h>
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
#include "gui-types.h"
#include "base/temp-buf.h"
#include "core/gimp.h"
#include "core/gimpbrush.h"
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h"
#include "core/gimpdatafactory.h"
#include "pdb/procedural_db.h"
#include "widgets/gimpbrushfactoryview.h"
#include "widgets/gimpcontainerbox.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpwidgets-constructors.h"
#include "menus/menus.h"
#include "brush-select.h"
#include "dialogs-constructors.h"
#include "gimp-intl.h"
/* local function prototypes */
static void brush_select_change_callbacks (BrushSelect *bsp,
gboolean closing);
static void brush_select_brush_changed (GimpContext *context,
GimpBrush *brush,
BrushSelect *bsp);
static void brush_select_opacity_changed (GimpContext *context,
gdouble opacity,
BrushSelect *bsp);
static void brush_select_paint_mode_changed (GimpContext *context,
GimpLayerModeEffects paint_mode,
BrushSelect *bsp);
static void opacity_scale_update (GtkAdjustment *adj,
BrushSelect *bsp);
static void paint_mode_menu_callback (GtkWidget *widget,
BrushSelect *bsp);
static void spacing_scale_update (GtkAdjustment *adj,
BrushSelect *bsp);
static void brush_select_response (GtkWidget *widget,
gint response_id,
BrushSelect *bsp);
/* list of active dialogs */
static GSList *brush_active_dialogs = NULL;
/* public functions */
BrushSelect *
brush_select_new (Gimp *gimp,
GimpContext *context,
const gchar *title,
const gchar *initial_brush,
const gchar *callback_name,
gdouble initial_opacity,
GimpLayerModeEffects initial_mode,
gint initial_spacing)
{
BrushSelect *bsp;
GtkWidget *table;
GtkAdjustment *spacing_adj;
GimpBrush *active = NULL;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (title != NULL, NULL);
if (gimp->no_data)
{
static gboolean first_call = TRUE;
if (first_call)
gimp_data_factory_data_init (gimp->brush_factory, FALSE);
first_call = FALSE;
}
if (initial_brush && strlen (initial_brush))
{
active = (GimpBrush *)
gimp_container_get_child_by_name (gimp->brush_factory->container,
initial_brush);
}
if (! active)
active = gimp_context_get_brush (context);
if (! active)
return NULL;
bsp = g_new0 (BrushSelect, 1);
/* Add to active brush dialogs list */
brush_active_dialogs = g_slist_append (brush_active_dialogs, bsp);
bsp->context = gimp_context_new (gimp, title, NULL);
bsp->callback_name = g_strdup (callback_name);
gimp_context_set_brush (bsp->context, active);
gimp_context_set_paint_mode (bsp->context, initial_mode);
gimp_context_set_opacity (bsp->context, initial_opacity);
bsp->spacing_value = initial_spacing;
g_signal_connect (bsp->context, "brush_changed",
G_CALLBACK (brush_select_brush_changed),
bsp);
g_signal_connect (bsp->context, "opacity_changed",
G_CALLBACK (brush_select_opacity_changed),
bsp);
g_signal_connect (bsp->context, "paint_mode_changed",
G_CALLBACK (brush_select_paint_mode_changed),
bsp);
/* The shell */
bsp->shell = gimp_dialog_new (title, "brush_selection",
NULL, 0,
gimp_standard_help_func,
GIMP_HELP_BRUSH_DIALOG,
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
NULL);
g_signal_connect (bsp->shell, "response",
G_CALLBACK (brush_select_response),
bsp);
/* The Brush Grid */
bsp->view = gimp_brush_factory_view_new (GIMP_VIEW_TYPE_GRID,
gimp->brush_factory,
dialogs_edit_brush_func,
bsp->context,
FALSE,
GIMP_PREVIEW_SIZE_MEDIUM, 1,
global_menu_factory);
gimp_container_box_set_size_request (GIMP_CONTAINER_BOX (GIMP_CONTAINER_EDITOR (bsp->view)->view),
5 * (GIMP_PREVIEW_SIZE_MEDIUM + 2),
5 * (GIMP_PREVIEW_SIZE_MEDIUM + 2));
gtk_container_set_border_width (GTK_CONTAINER (bsp->view), 12);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (bsp->shell)->vbox), bsp->view);
gtk_widget_show (bsp->view);
/* Create the frame and the table for the options */
table = GIMP_BRUSH_FACTORY_VIEW (bsp->view)->spacing_scale->parent;
gtk_table_set_col_spacings (GTK_TABLE (table), 6);
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
/* Create the opacity scale widget */
bsp->opacity_data =
GTK_ADJUSTMENT (gimp_scale_entry_new (GTK_TABLE (table), 0, 1,
_("Opacity:"), -1, 5,
gimp_context_get_opacity (bsp->context) * 100.0,
0.0, 100.0, 1.0, 10.0, 1,
TRUE, 0.0, 0.0,
NULL, NULL));
g_signal_connect (bsp->opacity_data, "value_changed",
G_CALLBACK (opacity_scale_update),
bsp);
/* Create the paint mode option menu */
bsp->paint_mode_menu =
gimp_paint_mode_menu_new (G_CALLBACK (paint_mode_menu_callback),
bsp,
TRUE,
gimp_context_get_paint_mode (bsp->context));
gimp_table_attach_aligned (GTK_TABLE (table), 0, 2,
_("Mode:"), 0.0, 0.5,
bsp->paint_mode_menu, 2, FALSE);
spacing_adj = GIMP_BRUSH_FACTORY_VIEW (bsp->view)->spacing_adjustment;
/* Use passed spacing instead of brushes default */
if (initial_spacing >= 0)
gtk_adjustment_set_value (spacing_adj, initial_spacing);
g_signal_connect (spacing_adj, "value_changed",
G_CALLBACK (spacing_scale_update),
bsp);
gtk_widget_show (table);
gtk_widget_show (bsp->shell);
return bsp;
}
void
brush_select_free (BrushSelect *bsp)
{
g_return_if_fail (bsp != NULL);
gtk_widget_destroy (bsp->shell);
/* remove from active list */
brush_active_dialogs = g_slist_remove (brush_active_dialogs, bsp);
if (bsp->callback_name)
g_free (bsp->callback_name);
if (bsp->context)
g_object_unref (bsp->context);
g_free (bsp);
}
BrushSelect *
brush_select_get_by_callback (const gchar *callback_name)
{
GSList *list;
for (list = brush_active_dialogs; list; list = g_slist_next (list))
{
BrushSelect *bsp = list->data;
if (bsp->callback_name && ! strcmp (callback_name, bsp->callback_name))
return bsp;
}
return NULL;
}
void
brush_select_dialogs_check (void)
{
GSList *list = brush_active_dialogs;
while (list)
{
BrushSelect *bsp = list->data;
list = g_slist_next (list);
if (bsp->callback_name)
{
if (! procedural_db_lookup (bsp->context->gimp, bsp->callback_name))
brush_select_response (NULL, GTK_RESPONSE_CLOSE, bsp);
}
}
}
/* private functions */
static void
brush_select_change_callbacks (BrushSelect *bsp,
gboolean closing)
{
ProcRecord *proc;
GimpBrush *brush;
static gboolean busy = FALSE;
if (! bsp->callback_name || busy)
return;
busy = TRUE;
brush = gimp_context_get_brush (bsp->context);
/* If its still registered run it */
proc = procedural_db_lookup (bsp->context->gimp, bsp->callback_name);
if (proc && brush)
{
Argument *return_vals;
gint n_return_vals;
return_vals =
procedural_db_run_proc (bsp->context->gimp,
bsp->context,
bsp->callback_name,
&n_return_vals,
GIMP_PDB_STRING, GIMP_OBJECT (brush)->name,
GIMP_PDB_FLOAT, gimp_context_get_opacity (bsp->context) * 100.0,
GIMP_PDB_INT32, bsp->spacing_value,
GIMP_PDB_INT32, (gint) gimp_context_get_paint_mode (bsp->context),
GIMP_PDB_INT32, brush->mask->width,
GIMP_PDB_INT32, brush->mask->height,
GIMP_PDB_INT32, (brush->mask->width *
brush->mask->height),
GIMP_PDB_INT8ARRAY, temp_buf_data (brush->mask),
GIMP_PDB_INT32, closing,
GIMP_PDB_END);
if (!return_vals || return_vals[0].value.pdb_int != GIMP_PDB_SUCCESS)
g_message (_("Unable to run brush callback. "
"The corresponding plug-in may have crashed."));
if (return_vals)
procedural_db_destroy_args (return_vals, n_return_vals);
}
busy = FALSE;
}
static void
brush_select_brush_changed (GimpContext *context,
GimpBrush *brush,
BrushSelect *bsp)
{
if (brush)
brush_select_change_callbacks (bsp, FALSE);
}
static void
brush_select_opacity_changed (GimpContext *context,
gdouble opacity,
BrushSelect *bsp)
{
g_signal_handlers_block_by_func (bsp->opacity_data,
opacity_scale_update,
bsp);
gtk_adjustment_set_value (GTK_ADJUSTMENT (bsp->opacity_data),
opacity * 100.0);
g_signal_handlers_unblock_by_func (bsp->opacity_data,
opacity_scale_update,
bsp);
brush_select_change_callbacks (bsp, FALSE);
}
static void
brush_select_paint_mode_changed (GimpContext *context,
GimpLayerModeEffects paint_mode,
BrushSelect *bsp)
{
gimp_paint_mode_menu_set_history (GTK_OPTION_MENU (bsp->paint_mode_menu),
paint_mode);
brush_select_change_callbacks (bsp, FALSE);
}
static void
opacity_scale_update (GtkAdjustment *adjustment,
BrushSelect *bsp)
{
g_signal_handlers_block_by_func (bsp->context,
brush_select_opacity_changed,
bsp);
gimp_context_set_opacity (bsp->context, adjustment->value / 100.0);
g_signal_handlers_unblock_by_func (bsp->context,
brush_select_opacity_changed,
bsp);
brush_select_change_callbacks (bsp, FALSE);
}
static void
paint_mode_menu_callback (GtkWidget *widget,
BrushSelect *bsp)
{
GimpLayerModeEffects paint_mode;
paint_mode = (GimpLayerModeEffects)
GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "gimp-item-data"));
gimp_context_set_paint_mode (bsp->context, paint_mode);
}
static void
spacing_scale_update (GtkAdjustment *adjustment,
BrushSelect *bsp)
{
if (bsp->spacing_value != adjustment->value)
{
bsp->spacing_value = adjustment->value;
brush_select_change_callbacks (bsp, FALSE);
}
}
static void
brush_select_response (GtkWidget *widget,
gint response_id,
BrushSelect *bsp)
{
brush_select_change_callbacks (bsp, TRUE);
brush_select_free (bsp);
}

View File

@ -1,52 +0,0 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __BRUSH_SELECT_H__
#define __BRUSH_SELECT_H__
typedef struct _BrushSelect BrushSelect;
struct _BrushSelect
{
GimpContext *context;
gchar *callback_name;
gint spacing_value;
GtkWidget *shell;
GtkWidget *view;
GtkAdjustment *opacity_data;
GtkWidget *paint_mode_menu;
};
BrushSelect * brush_select_new (Gimp *gimp,
GimpContext *context,
const gchar *title,
const gchar *initial_brush,
const gchar *callback_name,
gdouble initial_opacity,
GimpLayerModeEffects initial_mode,
gint initial_spacing);
void brush_select_free (BrushSelect *bsp);
BrushSelect * brush_select_get_by_callback (const gchar *callback_name);
void brush_select_dialogs_check (void);
#endif /* __BRUSH_SELECT_H__ */

View File

@ -33,9 +33,10 @@
#include "widgets/gimpenumwidgets.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimppaletteselect.h"
#include "widgets/gimpviewabledialog.h"
#include "palette-select.h"
#include "menus/menus.h"
#include "gimp-intl.h"
@ -45,7 +46,7 @@ typedef struct
GtkWidget *shell;
GtkWidget *custom_palette_button;
GimpImage *gimage;
PaletteSelect *palette_select;
GimpPdbDialog *palette_select;
GimpConvertDitherType dither_type;
gboolean alpha_dither;
gboolean remove_dups;
@ -55,18 +56,21 @@ typedef struct
} IndexedDialog;
static void indexed_response (GtkWidget *widget,
gint response_id,
IndexedDialog *dialog);
static void indexed_destroy_callback (GtkWidget *widget,
IndexedDialog *dialog);
static void indexed_response (GtkWidget *widget,
gint response_id,
IndexedDialog *dialog);
static void indexed_destroy (GtkWidget *widget,
IndexedDialog *dialog);
static void indexed_custom_palette_button_callback (GtkWidget *widget,
IndexedDialog *dialog);
static void indexed_palette_select_destroy_callback (GtkWidget *widget,
IndexedDialog *dialog);
static void indexed_custom_palette_button_callback (GtkWidget *widget,
IndexedDialog *dialog);
static void indexed_palette_select_destroy (GtkWidget *widget,
IndexedDialog *dialog);
static void indexed_palette_select_changed (GimpContext *context,
GimpPalette *palette,
IndexedDialog *dialog);
static GtkWidget * build_palette_button (Gimp *gimp);
static GtkWidget * build_palette_button (Gimp *gimp);
static gboolean UserHasWebPal = FALSE;
@ -129,7 +133,7 @@ convert_dialog_new (GimpImage *gimage,
dialog);
g_signal_connect (dialog->shell, "destroy",
G_CALLBACK (indexed_destroy_callback),
G_CALLBACK (indexed_destroy),
dialog);
main_vbox = gtk_vbox_new (FALSE, 12);
@ -433,24 +437,53 @@ indexed_response (GtkWidget *widget,
}
static void
indexed_destroy_callback (GtkWidget *widget,
IndexedDialog *dialog)
indexed_destroy (GtkWidget *widget,
IndexedDialog *dialog)
{
if (dialog->palette_select)
gtk_widget_destroy (dialog->palette_select->shell);
gtk_widget_destroy (GTK_WIDGET (dialog->palette_select));
g_free (dialog);
}
static void
indexed_palette_select_destroy_callback (GtkWidget *widget,
IndexedDialog *dialog)
indexed_custom_palette_button_callback (GtkWidget *widget,
IndexedDialog *dialog)
{
if (! dialog->palette_select)
{
dialog->palette_select =
g_object_new (GIMP_TYPE_PALETTE_SELECT,
"title", _("Select Custom Palette"),
"role", "gimp-pelette-selection",
"help-func", gimp_standard_help_func,
"help_id", GIMP_HELP_PALETTE_DIALOG,
"context", gimp_get_user_context (dialog->gimage->gimp),
"select-type", GIMP_TYPE_PALETTE,
"initial-object", theCustomPalette,
"menu-factory", global_menu_factory,
NULL);
g_signal_connect (dialog->palette_select, "destroy",
G_CALLBACK (indexed_palette_select_destroy),
dialog);
g_signal_connect (dialog->palette_select->context, "palette_changed",
G_CALLBACK (indexed_palette_select_changed),
dialog);
}
gtk_window_present (GTK_WINDOW (dialog->palette_select));
}
static void
indexed_palette_select_destroy (GtkWidget *widget,
IndexedDialog *dialog)
{
dialog->palette_select = NULL;
}
static void
indexed_palette_select_palette (GimpContext *context,
indexed_palette_select_changed (GimpContext *context,
GimpPalette *palette,
IndexedDialog *dialog)
{
@ -469,30 +502,3 @@ indexed_palette_select_palette (GimpContext *context,
gimp_object_get_name (GIMP_OBJECT (palette)));
}
}
static void
indexed_custom_palette_button_callback (GtkWidget *widget,
IndexedDialog *dialog)
{
if (dialog->palette_select == NULL)
{
dialog->palette_select =
palette_select_new (dialog->gimage->gimp,
gimp_get_user_context (dialog->gimage->gimp),
_("Select Custom Palette"),
GIMP_OBJECT (theCustomPalette)->name,
NULL);
g_signal_connect (dialog->palette_select->shell, "destroy",
G_CALLBACK (indexed_palette_select_destroy_callback),
dialog);
g_signal_connect (dialog->palette_select->context,
"palette_changed",
G_CALLBACK (indexed_palette_select_palette),
dialog);
}
else
{
gtk_window_present (GTK_WINDOW (dialog->palette_select->shell));
}
}

View File

@ -1,261 +0,0 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
* Copyright (C) 1998 Andy Thomas (alt@picnic.demon.co.uk)
*
* 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 <string.h>
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
#include "gui-types.h"
#include "core/gimp.h"
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h"
#include "text/gimpfont.h"
#include "pdb/procedural_db.h"
#include "widgets/gimpcontainertreeview.h"
#include "widgets/gimphelp-ids.h"
#include "menus/menus.h"
#include "dialogs-constructors.h"
#include "font-select.h"
#include "gimp-intl.h"
/* local function prototypes */
static void font_select_change_callbacks (FontSelect *font_select,
gboolean closing);
static void font_select_font_changed (GimpContext *context,
GimpFont *font,
FontSelect *font_select);
static void font_select_response (GtkWidget *widget,
gint response_id,
FontSelect *font_select);
/* list of active dialogs */
static GSList *font_active_dialogs = NULL;
/* public functions */
FontSelect *
font_select_new (Gimp *gimp,
GimpContext *context,
const gchar *title,
const gchar *initial_font,
const gchar *callback_name)
{
FontSelect *font_select;
GimpFont *active = NULL;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (title != NULL, NULL);
if (initial_font && strlen (initial_font))
{
active = (GimpFont *)
gimp_container_get_child_by_name (gimp->fonts, initial_font);
}
if (! active)
active = gimp_context_get_font (context);
if (! active)
return NULL;
font_select = g_new0 (FontSelect, 1);
/* Add to active font dialogs list */
font_active_dialogs = g_slist_append (font_active_dialogs, font_select);
font_select->context = gimp_context_new (gimp, title, NULL);
font_select->callback_name = g_strdup (callback_name);
gimp_context_set_font (font_select->context, active);
g_signal_connect (font_select->context, "font_changed",
G_CALLBACK (font_select_font_changed),
font_select);
/* the shell */
font_select->shell = gimp_dialog_new (title, "font_selection",
NULL, 0,
gimp_standard_help_func,
GIMP_HELP_FONT_DIALOG,
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
NULL);
g_signal_connect (font_select->shell, "response",
G_CALLBACK (font_select_response),
font_select);
/* The Font List */
font_select->view = gimp_container_tree_view_new (gimp->fonts,
font_select->context,
GIMP_PREVIEW_SIZE_MEDIUM, 1);
gimp_container_box_set_size_request (GIMP_CONTAINER_BOX (font_select->view),
5 * (GIMP_PREVIEW_SIZE_MEDIUM + 2),
5 * (GIMP_PREVIEW_SIZE_MEDIUM + 2));
gtk_container_set_border_width (GTK_CONTAINER (font_select->view), 12);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (font_select->shell)->vbox),
font_select->view);
gtk_widget_show (font_select->view);
gtk_widget_show (font_select->shell);
return font_select;
}
void
font_select_free (FontSelect *font_select)
{
g_return_if_fail (font_select != NULL);
gtk_widget_destroy (font_select->shell);
/* remove from active list */
font_active_dialogs = g_slist_remove (font_active_dialogs, font_select);
if (font_select->callback_name)
g_free (font_select->callback_name);
if (font_select->context)
g_object_unref (font_select->context);
g_free (font_select);
}
FontSelect *
font_select_get_by_callback (const gchar *callback_name)
{
GSList *list;
for (list = font_active_dialogs; list; list = g_slist_next (list))
{
FontSelect *font_select = list->data;
if (font_select->callback_name && !
strcmp (callback_name, font_select->callback_name))
return font_select;
}
return NULL;
}
void
font_select_dialogs_check (void)
{
GSList *list;
list = font_active_dialogs;
while (list)
{
FontSelect *font_select = list->data;
list = g_slist_next (list);
if (font_select->callback_name)
{
if (! procedural_db_lookup (font_select->context->gimp,
font_select->callback_name))
font_select_response (NULL, GTK_RESPONSE_CLOSE, font_select);
}
}
}
/* private functions */
static void
font_select_change_callbacks (FontSelect *font_select,
gboolean closing)
{
ProcRecord *proc;
GimpFont *font;
static gboolean busy = FALSE;
if (! font_select->callback_name || busy)
return;
busy = TRUE;
font = gimp_context_get_font (font_select->context);
/* If its still registered run it */
proc = procedural_db_lookup (font_select->context->gimp,
font_select->callback_name);
if (proc && font)
{
Argument *return_vals;
gint n_return_vals;
return_vals =
procedural_db_run_proc (font_select->context->gimp,
font_select->context,
font_select->callback_name,
&n_return_vals,
GIMP_PDB_STRING, GIMP_OBJECT (font)->name,
GIMP_PDB_INT32, closing,
GIMP_PDB_END);
if (!return_vals || return_vals[0].value.pdb_int != GIMP_PDB_SUCCESS)
g_message (_("Unable to run font callback. "
"The corresponding plug-in may have crashed."));
if (return_vals)
procedural_db_destroy_args (return_vals, n_return_vals);
}
busy = FALSE;
}
static void
font_select_font_changed (GimpContext *context,
GimpFont *font,
FontSelect *font_select)
{
if (font)
font_select_change_callbacks (font_select, FALSE);
}
static void
font_select_response (GtkWidget *widget,
gint response_id,
FontSelect *font_select)
{
font_select_change_callbacks (font_select, TRUE);
font_select_free (font_select);
}

View File

@ -1,46 +0,0 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __FONT_SELECT_H__
#define __FONT_SELECT_H__
typedef struct _FontSelect FontSelect;
struct _FontSelect
{
GimpContext *context;
gchar *callback_name;
GtkWidget *shell;
GtkWidget *view;
};
FontSelect * font_select_new (Gimp *gimp,
GimpContext *context,
const gchar *title,
const gchar *initial_font,
const gchar *callback_name);
void font_select_free (FontSelect *font_select);
FontSelect * font_select_get_by_callback (const gchar *callback_name);
void font_select_dialogs_check (void);
#endif /* __FONT_SELECT_H__ */

View File

@ -1,302 +0,0 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
* Copyright (C) 1998 Andy Thomas.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURIGHTE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <string.h>
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
#include "gui-types.h"
#include "core/gimp.h"
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h"
#include "core/gimpdatafactory.h"
#include "core/gimpgradient.h"
#include "pdb/procedural_db.h"
#include "widgets/gimpcontainerbox.h"
#include "widgets/gimpdatafactoryview.h"
#include "widgets/gimphelp-ids.h"
#include "menus/menus.h"
#include "dialogs-constructors.h"
#include "gradient-select.h"
#include "gimp-intl.h"
/* local function prototypes */
static void gradient_select_change_callbacks (GradientSelect *gsp,
gboolean closing);
static void gradient_select_gradient_changed (GimpContext *context,
GimpGradient *gradient,
GradientSelect *gsp);
static void gradient_select_response (GtkWidget *widget,
gint response_id,
GradientSelect *gsp);
/* list of active dialogs */
static GSList *gradient_active_dialogs = NULL;
/* public functions */
GradientSelect *
gradient_select_new (Gimp *gimp,
GimpContext *context,
const gchar *title,
const gchar *initial_gradient,
const gchar *callback_name,
gint sample_size)
{
GradientSelect *gsp;
GimpGradient *active = NULL;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (title != NULL, NULL);
if (gimp->no_data)
{
static gboolean first_call = TRUE;
if (first_call)
gimp_data_factory_data_init (gimp->gradient_factory, FALSE);
first_call = FALSE;
}
if (initial_gradient && strlen (initial_gradient))
{
active = (GimpGradient *)
gimp_container_get_child_by_name (gimp->gradient_factory->container,
initial_gradient);
}
if (! active)
active = gimp_context_get_gradient (context);
if (! active)
return NULL;
gsp = g_new0 (GradientSelect, 1);
/* Add to active gradient dialogs list */
gradient_active_dialogs = g_slist_append (gradient_active_dialogs, gsp);
gsp->context = gimp_context_new (gimp, title, NULL);
gsp->callback_name = g_strdup (callback_name);
gsp->sample_size = sample_size;
gimp_context_set_gradient (gsp->context, active);
g_signal_connect (gsp->context, "gradient_changed",
G_CALLBACK (gradient_select_gradient_changed),
gsp);
/* the shell */
gsp->shell = gimp_dialog_new (title, "gradient_selection",
NULL, 0,
gimp_standard_help_func,
GIMP_HELP_GRADIENT_DIALOG,
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
NULL);
g_signal_connect (gsp->shell, "response",
G_CALLBACK (gradient_select_response),
gsp);
/* the gradient list */
gsp->view = gimp_data_factory_view_new (GIMP_VIEW_TYPE_LIST,
gimp->gradient_factory,
dialogs_edit_gradient_func,
gsp->context,
GIMP_PREVIEW_SIZE_MEDIUM, 1,
global_menu_factory, "<Gradients>",
"/gradients-popup",
"gradients");
gimp_container_box_set_size_request (GIMP_CONTAINER_BOX (GIMP_CONTAINER_EDITOR (gsp->view)->view),
6 * (GIMP_PREVIEW_SIZE_MEDIUM + 2),
6 * (GIMP_PREVIEW_SIZE_MEDIUM + 2));
gtk_container_set_border_width (GTK_CONTAINER (gsp->view), 12);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (gsp->shell)->vbox), gsp->view);
gtk_widget_show (gsp->view);
gtk_widget_show (gsp->shell);
return gsp;
}
void
gradient_select_free (GradientSelect *gsp)
{
g_return_if_fail (gsp != NULL);
gtk_widget_destroy (gsp->shell);
/* remove from active list */
gradient_active_dialogs = g_slist_remove (gradient_active_dialogs, gsp);
if (gsp->callback_name)
g_free (gsp->callback_name);
if (gsp->context)
g_object_unref (gsp->context);
g_free (gsp);
}
GradientSelect *
gradient_select_get_by_callback (const gchar *callback_name)
{
GSList *list;
for (list = gradient_active_dialogs; list; list = g_slist_next (list))
{
GradientSelect *gsp = list->data;
if (gsp->callback_name && ! strcmp (callback_name, gsp->callback_name))
return gsp;
}
return NULL;
}
void
gradient_select_dialogs_check (void)
{
GSList *list;
list = gradient_active_dialogs;
while (list)
{
GradientSelect *gsp = list->data;
list = g_slist_next (list);
if (gsp->callback_name)
{
if (! procedural_db_lookup (gsp->context->gimp, gsp->callback_name))
gradient_select_response (NULL, GTK_RESPONSE_CLOSE, gsp);
}
}
}
/* private functions */
static void
gradient_select_change_callbacks (GradientSelect *gsp,
gboolean closing)
{
ProcRecord *proc = NULL;
GimpGradient *gradient;
static gboolean busy = FALSE;
if (! gsp->callback_name || busy)
return;
busy = TRUE;
gradient = gimp_context_get_gradient (gsp->context);
/* If its still registered run it */
proc = procedural_db_lookup (gsp->context->gimp, gsp->callback_name);
if (proc && gradient)
{
Argument *return_vals;
gint n_return_vals;
gdouble *values, *pv;
double pos, delta;
GimpRGB color;
gint i;
i = gsp->sample_size;
pos = 0.0;
delta = 1.0 / (i - 1);
values = g_new (gdouble, 4 * i);
pv = values;
while (i--)
{
gimp_gradient_get_color_at (gradient, pos, FALSE, &color);
*pv++ = color.r;
*pv++ = color.g;
*pv++ = color.b;
*pv++ = color.a;
pos += delta;
}
return_vals =
procedural_db_run_proc (gsp->context->gimp,
gsp->context,
gsp->callback_name,
&n_return_vals,
GIMP_PDB_STRING, GIMP_OBJECT (gradient)->name,
GIMP_PDB_INT32, gsp->sample_size * 4,
GIMP_PDB_FLOATARRAY, values,
GIMP_PDB_INT32, (gint) closing,
GIMP_PDB_END);
if (!return_vals || return_vals[0].value.pdb_int != GIMP_PDB_SUCCESS)
g_message (_("Unable to run gradient callback. "
"The corresponding plug-in may have crashed."));
if (return_vals)
procedural_db_destroy_args (return_vals, n_return_vals);
}
busy = FALSE;
}
static void
gradient_select_gradient_changed (GimpContext *context,
GimpGradient *gradient,
GradientSelect *gsp)
{
if (gradient)
gradient_select_change_callbacks (gsp, FALSE);
}
static void
gradient_select_response (GtkWidget *widget,
gint response_id,
GradientSelect *gsp)
{
gradient_select_change_callbacks (gsp, TRUE);
gradient_select_free (gsp);
}

View File

@ -1,49 +0,0 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GRADIENT_SELECT_H__
#define __GRADIENT_SELECT_H__
typedef struct _GradientSelect GradientSelect;
struct _GradientSelect
{
GimpContext *context;
gchar *callback_name;
gint sample_size;
GtkWidget *shell;
GtkWidget *view;
};
GradientSelect * gradient_select_new (Gimp *gimp,
GimpContext *context,
const gchar *title,
const gchar *initial_gradient,
const gchar *callback_name,
gint sample_size);
void gradient_select_free (GradientSelect *gsp);
GradientSelect * gradient_select_get_by_callback (const gchar *callback_name);
void gradient_select_dialogs_check (void);
#endif /* __GRADIENT_SELECT_H__ */

View File

@ -21,6 +21,7 @@
#include <string.h>
#include <gtk/gtk.h>
#include <gobject/gvaluecollector.h>
#include "libgimpwidgets/gimpwidgets.h"
@ -29,15 +30,29 @@
#include "config/gimpguiconfig.h"
#include "core/gimp.h"
#include "core/gimpbrush.h"
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h"
#include "core/gimpgradient.h"
#include "core/gimpimage.h"
#include "core/gimppalette.h"
#include "core/gimppattern.h"
#include "text/gimpfont.h"
#include "plug-in/plug-ins.h"
#include "plug-in/plug-in-proc.h"
#include "widgets/gimpactiongroup.h"
#include "widgets/gimpbrushselect.h"
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimperrorconsole.h"
#include "widgets/gimpfontselect.h"
#include "widgets/gimpgradientselect.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpmenufactory.h"
#include "widgets/gimppaletteselect.h"
#include "widgets/gimppatternselect.h"
#include "widgets/gimpuimanager.h"
#include "widgets/gimpwidgets-utils.h"
@ -51,12 +66,8 @@
#include "menus/menus.h"
#include "menus/plug-in-menus.h"
#include "brush-select.h"
#include "dialogs.h"
#include "font-select.h"
#include "gradient-select.h"
#include "palette-select.h"
#include "pattern-select.h"
#include "dialogs-constructors.h"
#include "themes.h"
@ -94,12 +105,27 @@ static void gui_update_progress (Gimp *gimp,
gdouble percentage);
static void gui_end_progress (Gimp *gimp,
GimpProgress *progress);
static void gui_pdb_dialogs_check (Gimp *gimp);
static const gchar * gui_get_program_class (Gimp *gimp);
static gchar * gui_get_display_name (Gimp *gimp,
gint gdisp_ID,
gint *monitor_number);
static const gchar * gui_get_theme_dir (Gimp *gimp);
static gboolean gui_pdb_dialog_new (Gimp *gimp,
GimpContext *context,
GimpContainer *container,
const gchar *title,
const gchar *callback_name,
const gchar *object_name,
va_list args);
static gboolean gui_pdb_dialog_set (Gimp *gimp,
GimpContainer *container,
const gchar *callback_name,
const gchar *object_name,
va_list args);
static gboolean gui_pdb_dialog_close (Gimp *gimp,
GimpContainer *container,
const gchar *callback_name);
static void gui_pdb_dialogs_check (Gimp *gimp);
/* public functions */
@ -122,10 +148,13 @@ gui_vtable_init (Gimp *gimp)
gimp->gui_progress_restart_func = gui_restart_progress;
gimp->gui_progress_update_func = gui_update_progress;
gimp->gui_progress_end_func = gui_end_progress;
gimp->gui_pdb_dialogs_check_func = gui_pdb_dialogs_check;
gimp->gui_get_program_class_func = gui_get_program_class;
gimp->gui_get_display_name_func = gui_get_display_name;
gimp->gui_get_theme_dir_func = gui_get_theme_dir;
gimp->gui_pdb_dialog_new_func = gui_pdb_dialog_new;
gimp->gui_pdb_dialog_set_func = gui_pdb_dialog_set;
gimp->gui_pdb_dialog_close_func = gui_pdb_dialog_close;
gimp->gui_pdb_dialogs_check_func = gui_pdb_dialogs_check;
}
@ -322,16 +351,6 @@ gui_end_progress (Gimp *gimp,
gimp_progress_end (progress);
}
static void
gui_pdb_dialogs_check (Gimp *gimp)
{
brush_select_dialogs_check ();
font_select_dialogs_check ();
gradient_select_dialogs_check ();
palette_select_dialogs_check ();
pattern_select_dialogs_check ();
}
static const gchar *
gui_get_program_class (Gimp *gimp)
{
@ -378,3 +397,295 @@ gui_get_theme_dir (Gimp *gimp)
{
return themes_get_theme_dir (gimp, GIMP_GUI_CONFIG (gimp->config)->theme);
}
static gboolean
gui_pdb_dialog_new (Gimp *gimp,
GimpContext *context,
GimpContainer *container,
const gchar *title,
const gchar *callback_name,
const gchar *object_name,
va_list args)
{
GType dialog_type = G_TYPE_NONE;
const gchar *dialog_role = NULL;
const gchar *help_id = NULL;
GimpDataEditFunc edit_func = NULL;
if (container->children_type == GIMP_TYPE_BRUSH)
{
dialog_type = GIMP_TYPE_BRUSH_SELECT;
dialog_role = "gimp-brush-selection";
help_id = GIMP_HELP_BRUSH_DIALOG;
edit_func = dialogs_edit_brush_func;
}
else if (container->children_type == GIMP_TYPE_FONT)
{
dialog_type = GIMP_TYPE_FONT_SELECT;
dialog_role = "gimp-font-selection";
help_id = GIMP_HELP_FONT_DIALOG;
}
else if (container->children_type == GIMP_TYPE_GRADIENT)
{
dialog_type = GIMP_TYPE_GRADIENT_SELECT;
dialog_role = "gimp-gradient-selection";
help_id = GIMP_HELP_GRADIENT_DIALOG;
edit_func = dialogs_edit_gradient_func;
}
else if (container->children_type == GIMP_TYPE_PALETTE)
{
dialog_type = GIMP_TYPE_PALETTE_SELECT;
dialog_role = "gimp-palette-selection";
help_id = GIMP_HELP_PALETTE_DIALOG;
edit_func = dialogs_edit_palette_func;
}
else if (container->children_type == GIMP_TYPE_PATTERN)
{
dialog_type = GIMP_TYPE_PATTERN_SELECT;
dialog_role = "gimp-pattern-selection";
help_id = GIMP_HELP_PATTERN_DIALOG;
}
if (dialog_type != G_TYPE_NONE)
{
GimpObject *object = NULL;
#ifdef __GNUC__
#warning FIXME: re-enable gimp->no_data case
#endif
#if 0
if (gimp->no_data)
{
static gboolean first_call = TRUE;
if (first_call)
gimp_data_factory_data_init (gimp->pattern_factory, FALSE);
first_call = FALSE;
}
#endif
if (object_name && strlen (object_name))
object = gimp_container_get_child_by_name (container, object_name);
if (! object)
object = gimp_context_get_by_type (context, container->children_type);
if (object)
{
GObjectClass *object_class;
GtkWidget *dialog;
GParameter *params;
gint n_params;
gchar *param_name;
gint i;
if (edit_func)
n_params = 10;
else
n_params = 9;
params = g_new0 (GParameter, n_params);
params[0].name = "title";
g_value_init (&params[0].value, G_TYPE_STRING);
g_value_set_string (&params[0].value, title);
params[1].name = "role";
g_value_init (&params[1].value, G_TYPE_STRING);
g_value_set_string (&params[1].value, dialog_role);
params[2].name = "help-func";
g_value_init (&params[2].value, G_TYPE_POINTER);
g_value_set_pointer (&params[2].value, gimp_standard_help_func);
params[3].name = "help-id";
g_value_init (&params[3].value, G_TYPE_STRING);
g_value_set_string (&params[3].value, help_id);
params[4].name = "context";
g_value_init (&params[4].value, GIMP_TYPE_CONTEXT);
g_value_set_object (&params[4].value, context);
params[5].name = "select-type";
g_value_init (&params[5].value, G_TYPE_POINTER);
g_value_set_pointer (&params[5].value, (gpointer) container->children_type);
params[6].name = "initial-object";
g_value_init (&params[6].value, GIMP_TYPE_OBJECT);
g_value_set_object (&params[6].value, object);
params[7].name = "callback-name";
g_value_init (&params[7].value, G_TYPE_STRING);
g_value_set_string (&params[7].value, callback_name);
params[8].name = "menu-factory";
g_value_init (&params[8].value, GIMP_TYPE_MENU_FACTORY);
g_value_set_object (&params[8].value, global_menu_factory);
if (edit_func)
{
params[9].name = "edit-func";
g_value_init (&params[9].value, G_TYPE_POINTER);
g_value_set_pointer (&params[9].value, edit_func);
}
object_class = g_type_class_ref (dialog_type);
param_name = va_arg (args, gchar *);
while (param_name)
{
gchar *error = NULL;
GParamSpec *pspec = g_object_class_find_property (object_class,
param_name);
if (! pspec)
{
g_warning ("%s: object class `%s' has no property named `%s'",
G_STRFUNC, g_type_name (dialog_type), param_name);
break;
}
params = g_renew (GParameter, params, n_params + 1);
params[n_params].name = param_name;
params[n_params].value.g_type = 0;
g_value_init (&params[n_params].value,
G_PARAM_SPEC_VALUE_TYPE (pspec));
G_VALUE_COLLECT (&params[n_params].value, args, 0, &error);
if (error)
{
g_warning ("%s: %s", G_STRFUNC, error);
g_free (error);
g_value_unset (&params[n_params].value);
break;
}
n_params++;
param_name = va_arg (args, gchar *);
}
g_type_class_unref (object_class);
dialog = g_object_newv (dialog_type, n_params, params);
for (i = 0; i < n_params; i++)
g_value_unset (&params[i].value);
g_free (params);
gtk_widget_show (dialog);
return TRUE;
}
}
return FALSE;
}
static gboolean
gui_pdb_dialog_set (Gimp *gimp,
GimpContainer *container,
const gchar *callback_name,
const gchar *object_name,
va_list args)
{
GimpPdbDialogClass *klass = NULL;
if (container->children_type == GIMP_TYPE_BRUSH)
klass = g_type_class_peek (GIMP_TYPE_BRUSH_SELECT);
else if (container->children_type == GIMP_TYPE_FONT)
klass = g_type_class_peek (GIMP_TYPE_FONT_SELECT);
else if (container->children_type == GIMP_TYPE_GRADIENT)
klass = g_type_class_peek (GIMP_TYPE_GRADIENT_SELECT);
else if (container->children_type == GIMP_TYPE_PALETTE)
klass = g_type_class_peek (GIMP_TYPE_PALETTE_SELECT);
else if (container->children_type == GIMP_TYPE_PATTERN)
klass = g_type_class_peek (GIMP_TYPE_PATTERN_SELECT);
if (klass)
{
GimpPdbDialog *dialog;
dialog = gimp_pdb_dialog_get_by_callback (klass, callback_name);
if (dialog && dialog->select_type == container->children_type)
{
GimpObject *object;
object = gimp_container_get_child_by_name (container, object_name);
if (object)
{
const gchar *prop_name;
gimp_context_set_by_type (dialog->context, dialog->select_type,
object);
prop_name = va_arg (args, const gchar *);
if (prop_name)
g_object_set_valist (G_OBJECT (dialog), prop_name, args);
gtk_window_present (GTK_WINDOW (dialog));
return TRUE;
}
}
}
return FALSE;
}
static gboolean
gui_pdb_dialog_close (Gimp *gimp,
GimpContainer *container,
const gchar *callback_name)
{
GimpPdbDialogClass *klass = NULL;
if (container->children_type == GIMP_TYPE_BRUSH)
klass = g_type_class_peek (GIMP_TYPE_BRUSH_SELECT);
else if (container->children_type == GIMP_TYPE_FONT)
klass = g_type_class_peek (GIMP_TYPE_FONT_SELECT);
else if (container->children_type == GIMP_TYPE_GRADIENT)
klass = g_type_class_peek (GIMP_TYPE_GRADIENT_SELECT);
else if (container->children_type == GIMP_TYPE_PALETTE)
klass = g_type_class_peek (GIMP_TYPE_PALETTE_SELECT);
else if (container->children_type == GIMP_TYPE_PATTERN)
klass = g_type_class_peek (GIMP_TYPE_PATTERN_SELECT);
if (klass)
{
GimpPdbDialog *dialog;
dialog = gimp_pdb_dialog_get_by_callback (klass, callback_name);
if (dialog && dialog->select_type == container->children_type)
{
gtk_widget_destroy (GTK_WIDGET (dialog));
return TRUE;
}
}
return FALSE;
}
static void
gui_pdb_dialogs_check (Gimp *gimp)
{
GimpPdbDialogClass *klass;
if ((klass = g_type_class_peek (GIMP_TYPE_BRUSH_SELECT)))
gimp_pdb_dialogs_check_callback (klass);
if ((klass = g_type_class_peek (GIMP_TYPE_FONT_SELECT)))
gimp_pdb_dialogs_check_callback (klass);
if ((klass = g_type_class_peek (GIMP_TYPE_GRADIENT_SELECT)))
gimp_pdb_dialogs_check_callback (klass);
if ((klass = g_type_class_peek (GIMP_TYPE_PALETTE_SELECT)))
gimp_pdb_dialogs_check_callback (klass);
if ((klass = g_type_class_peek (GIMP_TYPE_PATTERN_SELECT)))
gimp_pdb_dialogs_check_callback (klass);
}

View File

@ -1,280 +0,0 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
* Copyright (C) 1998 Andy Thomas (alt@picnic.demon.co.uk)
*
* 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 <string.h>
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
#include "gui-types.h"
#include "core/gimp.h"
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h"
#include "core/gimpdatafactory.h"
#include "core/gimppalette.h"
#include "pdb/procedural_db.h"
#include "widgets/gimpcontainerbox.h"
#include "widgets/gimpdatafactoryview.h"
#include "widgets/gimphelp-ids.h"
#include "menus/menus.h"
#include "dialogs-constructors.h"
#include "palette-select.h"
#include "gimp-intl.h"
#define STD_PALETTE_COLUMNS 6
#define STD_PALETTE_ROWS 5
/* local function prototypes */
static void palette_select_change_callbacks (PaletteSelect *psp,
gboolean closing);
static void palette_select_palette_changed (GimpContext *context,
GimpPalette *palette,
PaletteSelect *psp);
static void palette_select_response (GtkWidget *widget,
gint response_id,
PaletteSelect *psp);
/* list of active dialogs */
static GSList *palette_active_dialogs = NULL;
/* public functions */
PaletteSelect *
palette_select_new (Gimp *gimp,
GimpContext *context,
const gchar *title,
const gchar *initial_palette,
const gchar *callback_name)
{
PaletteSelect *psp;
GimpPalette *active = NULL;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (title != NULL, NULL);
if (gimp->no_data)
{
static gboolean first_call = TRUE;
if (first_call)
gimp_data_factory_data_init (gimp->palette_factory, FALSE);
first_call = FALSE;
}
if (initial_palette && strlen (initial_palette))
{
active = (GimpPalette *)
gimp_container_get_child_by_name (gimp->palette_factory->container,
initial_palette);
}
if (! active)
active = gimp_context_get_palette (context);
if (! active)
return NULL;
psp = g_new0 (PaletteSelect, 1);
/* Add to active palette dialogs list */
palette_active_dialogs = g_slist_append (palette_active_dialogs, psp);
psp->context = gimp_context_new (gimp, title, NULL);
psp->callback_name = g_strdup (callback_name);
gimp_context_set_palette (psp->context, active);
g_signal_connect (psp->context, "palette_changed",
G_CALLBACK (palette_select_palette_changed),
psp);
/* the shell */
psp->shell = gimp_dialog_new (title, "palette_selection",
NULL, 0,
gimp_standard_help_func,
GIMP_HELP_PALETTE_DIALOG,
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
NULL);
g_signal_connect (psp->shell, "response",
G_CALLBACK (palette_select_response),
psp);
/* The Palette List */
psp->view = gimp_data_factory_view_new (GIMP_VIEW_TYPE_LIST,
gimp->palette_factory,
dialogs_edit_palette_func,
psp->context,
GIMP_PREVIEW_SIZE_MEDIUM, 1,
global_menu_factory, "<Palettes>",
"/palettes-popup",
"palettes");
gimp_container_box_set_size_request (GIMP_CONTAINER_BOX (GIMP_CONTAINER_EDITOR (psp->view)->view),
5 * (GIMP_PREVIEW_SIZE_MEDIUM + 2),
8 * (GIMP_PREVIEW_SIZE_MEDIUM + 2));
gtk_container_set_border_width (GTK_CONTAINER (psp->view), 12);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (psp->shell)->vbox), psp->view);
gtk_widget_show (psp->view);
gtk_widget_show (psp->shell);
return psp;
}
void
palette_select_free (PaletteSelect *psp)
{
g_return_if_fail (psp != NULL);
gtk_widget_destroy (psp->shell);
/* remove from active list */
palette_active_dialogs = g_slist_remove (palette_active_dialogs, psp);
if (psp->callback_name)
g_free (psp->callback_name);
if (psp->context)
g_object_unref (psp->context);
g_free (psp);
}
PaletteSelect *
palette_select_get_by_callback (const gchar *callback_name)
{
GSList *list;
for (list = palette_active_dialogs; list; list = g_slist_next (list))
{
PaletteSelect *psp = list->data;
if (psp->callback_name && ! strcmp (callback_name, psp->callback_name))
return psp;
}
return NULL;
}
void
palette_select_dialogs_check (void)
{
GSList *list;
list = palette_active_dialogs;
while (list)
{
PaletteSelect *psp = list->data;
list = g_slist_next (list);
if (psp->callback_name)
{
if (! procedural_db_lookup (psp->context->gimp, psp->callback_name))
palette_select_response (NULL, GTK_RESPONSE_CLOSE, psp);
}
}
}
/* private functions */
static void
palette_select_change_callbacks (PaletteSelect *psp,
gboolean closing)
{
ProcRecord *proc;
GimpPalette *palette;
static gboolean busy = FALSE;
if (! psp->callback_name || busy)
return;
busy = TRUE;
palette = gimp_context_get_palette (psp->context);
/* If its still registered run it */
proc = procedural_db_lookup (psp->context->gimp, psp->callback_name);
if (proc && palette)
{
Argument *return_vals;
gint n_return_vals;
return_vals =
procedural_db_run_proc (psp->context->gimp,
psp->context,
psp->callback_name,
&n_return_vals,
GIMP_PDB_STRING, GIMP_OBJECT (palette)->name,
GIMP_PDB_INT32, palette->n_colors,
GIMP_PDB_INT32, closing,
GIMP_PDB_END);
if (!return_vals || return_vals[0].value.pdb_int != GIMP_PDB_SUCCESS)
g_message (_("Unable to run palette callback. "
"The corresponding plug-in may have crashed."));
if (return_vals)
procedural_db_destroy_args (return_vals, n_return_vals);
}
busy = FALSE;
}
static void
palette_select_palette_changed (GimpContext *context,
GimpPalette *palette,
PaletteSelect *psp)
{
if (palette)
palette_select_change_callbacks (psp, FALSE);
}
static void
palette_select_response (GtkWidget *widget,
gint response_id,
PaletteSelect *psp)
{
palette_select_change_callbacks (psp, TRUE);
palette_select_free (psp);
}

View File

@ -1,46 +0,0 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __PALETTE_SELECT_H__
#define __PALETTE_SELECT_H__
typedef struct _PaletteSelect PaletteSelect;
struct _PaletteSelect
{
GimpContext *context;
gchar *callback_name;
GtkWidget *shell;
GtkWidget *view;
};
PaletteSelect * palette_select_new (Gimp *gimp,
GimpContext *context,
const gchar *title,
const gchar *initial_palette,
const gchar *callback_name);
void palette_select_free (PaletteSelect *palette_select);
PaletteSelect * palette_select_get_by_callback (const gchar *callback_name);
void palette_select_dialogs_check (void);
#endif /* __PALETTE_SELECT_H__ */

View File

@ -1,282 +0,0 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <string.h>
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
#include "gui-types.h"
#include "base/temp-buf.h"
#include "core/gimp.h"
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h"
#include "core/gimpdatafactory.h"
#include "core/gimppattern.h"
#include "pdb/procedural_db.h"
#include "widgets/gimpcontainerbox.h"
#include "widgets/gimpdatafactoryview.h"
#include "widgets/gimphelp-ids.h"
#include "menus/menus.h"
#include "pattern-select.h"
#include "gimp-intl.h"
/* local function prototypes */
static void pattern_select_change_callbacks (PatternSelect *psp,
gboolean closing);
static void pattern_select_pattern_changed (GimpContext *context,
GimpPattern *pattern,
PatternSelect *psp);
static void pattern_select_response (GtkWidget *widget,
gint response_id,
PatternSelect *psp);
/* List of active dialogs */
static GSList *pattern_active_dialogs = NULL;
/* public functions */
PatternSelect *
pattern_select_new (Gimp *gimp,
GimpContext *context,
const gchar *title,
const gchar *initial_pattern,
const gchar *callback_name)
{
PatternSelect *psp;
GimpPattern *active = NULL;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (title != NULL, NULL);
if (gimp->no_data)
{
static gboolean first_call = TRUE;
if (first_call)
gimp_data_factory_data_init (gimp->pattern_factory, FALSE);
first_call = FALSE;
}
if (initial_pattern && strlen (initial_pattern))
{
active = (GimpPattern *)
gimp_container_get_child_by_name (gimp->pattern_factory->container,
initial_pattern);
}
if (! active)
active = gimp_context_get_pattern (context);
if (! active)
return NULL;
psp = g_new0 (PatternSelect, 1);
/* Add to active pattern dialogs list */
pattern_active_dialogs = g_slist_append (pattern_active_dialogs, psp);
psp->context = gimp_context_new (gimp, title, NULL);
psp->callback_name = g_strdup (callback_name);
gimp_context_set_pattern (psp->context, active);
g_signal_connect (psp->context, "pattern_changed",
G_CALLBACK (pattern_select_pattern_changed),
psp);
/* the shell */
psp->shell = gimp_dialog_new (title, "pattern_selection",
NULL, 0,
gimp_standard_help_func,
GIMP_HELP_PATTERN_DIALOG,
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
NULL);
g_signal_connect (psp->shell, "response",
G_CALLBACK (pattern_select_response),
psp);
/* the pattern grid */
psp->view = gimp_data_factory_view_new (GIMP_VIEW_TYPE_GRID,
gimp->pattern_factory,
NULL,
psp->context,
GIMP_PREVIEW_SIZE_MEDIUM, 1,
global_menu_factory, "<Patterns>",
"/patterns-popup",
"patterns");
gimp_container_box_set_size_request (GIMP_CONTAINER_BOX (GIMP_CONTAINER_EDITOR (psp->view)->view),
6 * (GIMP_PREVIEW_SIZE_MEDIUM + 2),
6 * (GIMP_PREVIEW_SIZE_MEDIUM + 2));
gtk_container_set_border_width (GTK_CONTAINER (psp->view), 12);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (psp->shell)->vbox), psp->view);
gtk_widget_show (psp->view);
gtk_widget_show (psp->shell);
return psp;
}
void
pattern_select_free (PatternSelect *psp)
{
g_return_if_fail (psp != NULL);
gtk_widget_destroy (psp->shell);
/* remove from active list */
pattern_active_dialogs = g_slist_remove (pattern_active_dialogs, psp);
if (psp->callback_name)
g_free (psp->callback_name);
if (psp->context)
g_object_unref (psp->context);
g_free (psp);
}
PatternSelect *
pattern_select_get_by_callback (const gchar *callback_name)
{
GSList *list;
for (list = pattern_active_dialogs; list; list = g_slist_next (list))
{
PatternSelect *psp = list->data;
if (psp->callback_name && ! strcmp (callback_name, psp->callback_name))
return psp;
}
return NULL;
}
void
pattern_select_dialogs_check (void)
{
GSList *list;
list = pattern_active_dialogs;
while (list)
{
PatternSelect *psp = list->data;
list = g_slist_next (list);
if (psp->callback_name)
{
if (! procedural_db_lookup (psp->context->gimp, psp->callback_name))
pattern_select_response (NULL, GTK_RESPONSE_CLOSE, psp);
}
}
}
/* private functions */
static void
pattern_select_change_callbacks (PatternSelect *psp,
gboolean closing)
{
ProcRecord *proc;
GimpPattern *pattern;
static gboolean busy = FALSE;
if (! psp->callback_name || busy)
return;
busy = TRUE;
pattern = gimp_context_get_pattern (psp->context);
/* If its still registered run it */
proc = procedural_db_lookup (psp->context->gimp, psp->callback_name);
if (proc && pattern)
{
Argument *return_vals;
gint n_return_vals;
return_vals =
procedural_db_run_proc (psp->context->gimp,
psp->context,
psp->callback_name,
&n_return_vals,
GIMP_PDB_STRING, GIMP_OBJECT (pattern)->name,
GIMP_PDB_INT32, pattern->mask->width,
GIMP_PDB_INT32, pattern->mask->height,
GIMP_PDB_INT32, pattern->mask->bytes,
GIMP_PDB_INT32, (pattern->mask->bytes *
pattern->mask->height *
pattern->mask->width),
GIMP_PDB_INT8ARRAY, temp_buf_data (pattern->mask),
GIMP_PDB_INT32, closing,
GIMP_PDB_END);
if (!return_vals || return_vals[0].value.pdb_int != GIMP_PDB_SUCCESS)
g_message (_("Unable to run pattern callback. "
"The corresponding plug-in may have crashed."));
if (return_vals)
procedural_db_destroy_args (return_vals, n_return_vals);
}
busy = FALSE;
}
static void
pattern_select_pattern_changed (GimpContext *context,
GimpPattern *pattern,
PatternSelect *psp)
{
if (pattern)
pattern_select_change_callbacks (psp, FALSE);
}
static void
pattern_select_response (GtkWidget *widget,
gint response_id,
PatternSelect *psp)
{
pattern_select_change_callbacks (psp, TRUE);
pattern_select_free (psp);
}

View File

@ -1,46 +0,0 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __PATTERN_SELECT_H__
#define __PATTERN_SELECT_H__
typedef struct _PatternSelect PatternSelect;
struct _PatternSelect
{
GimpContext *context;
gchar *callback_name;
GtkWidget *shell;
GtkWidget *view;
};
PatternSelect * pattern_select_new (Gimp *gimp,
GimpContext *context,
const gchar *title,
const gchar *initial_pattern,
const gchar *callback_name);
void pattern_select_free (PatternSelect *psp);
PatternSelect * pattern_select_get_by_callback (const gchar *callback_name);
void pattern_select_dialogs_check (void);
#endif /* __PATTERN_SELECT_H__ */

View File

@ -21,20 +21,15 @@
#include "config.h"
#include <gtk/gtk.h>
#include <glib-object.h>
#include "libgimpbase/gimpbasetypes.h"
#include "pdb-types.h"
#include "gui/gui-types.h"
#include "procedural_db.h"
#include "core/gimp.h"
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h"
#include "core/gimpdatafactory.h"
#include "gui/brush-select.h"
#include "widgets/gimpbrushfactoryview.h"
static ProcRecord brushes_popup_proc;
static ProcRecord brushes_close_popup_proc;
@ -60,7 +55,6 @@ brushes_popup_invoker (Gimp *gimp,
gdouble opacity;
gint32 spacing;
gint32 paint_mode;
ProcRecord *proc;
brush_callback = (gchar *) args[0].value.pdb_pointer;
if (brush_callback == NULL || !g_utf8_validate (brush_callback, -1, NULL))
@ -88,16 +82,14 @@ brushes_popup_invoker (Gimp *gimp,
if (success)
{
if (! gimp->no_interface &&
(proc = procedural_db_lookup (gimp, brush_callback)))
{
brush_select_new (gimp, context, popup_title,
initial_brush, brush_callback,
opacity / 100.0,
paint_mode,
spacing);
}
else
if (gimp->no_interface ||
! procedural_db_lookup (gimp, brush_callback) ||
! gimp_pdb_dialog_new (gimp, context, gimp->brush_factory->container,
popup_title, brush_callback, initial_brush,
"opacity", opacity / 100.0,
"paint-mode", paint_mode,
"spacing", spacing,
NULL))
success = FALSE;
}
@ -161,8 +153,6 @@ brushes_close_popup_invoker (Gimp *gimp,
{
gboolean success = TRUE;
gchar *brush_callback;
ProcRecord *proc;
BrushSelect *brush_select;
brush_callback = (gchar *) args[0].value.pdb_pointer;
if (brush_callback == NULL || !g_utf8_validate (brush_callback, -1, NULL))
@ -170,13 +160,10 @@ brushes_close_popup_invoker (Gimp *gimp,
if (success)
{
if (! gimp->no_interface &&
(proc = procedural_db_lookup (gimp, brush_callback)) &&
(brush_select = brush_select_get_by_callback (brush_callback)))
{
brush_select_free (brush_select);
}
else
if (gimp->no_interface ||
! procedural_db_lookup (gimp, brush_callback) ||
! gimp_pdb_dialog_close (gimp, gimp->brush_factory->container,
brush_callback))
success = FALSE;
}
@ -219,8 +206,6 @@ brushes_set_popup_invoker (Gimp *gimp,
gdouble opacity;
gint32 spacing;
gint32 paint_mode;
ProcRecord *proc;
BrushSelect *brush_select;
brush_callback = (gchar *) args[0].value.pdb_pointer;
if (brush_callback == NULL || !g_utf8_validate (brush_callback, -1, NULL))
@ -244,33 +229,14 @@ brushes_set_popup_invoker (Gimp *gimp,
if (success)
{
if (! gimp->no_interface &&
(proc = procedural_db_lookup (gimp, brush_callback)) &&
(brush_select = brush_select_get_by_callback (brush_callback)))
{
GimpBrush *active = (GimpBrush *)
gimp_container_get_child_by_name (gimp->brush_factory->container,
brush_name);
if (active)
{
GtkAdjustment *spacing_adj;
spacing_adj = GIMP_BRUSH_FACTORY_VIEW (brush_select->view)->spacing_adjustment;
gimp_context_set_brush (brush_select->context, active);
gimp_context_set_opacity (brush_select->context, opacity / 100.0);
gimp_context_set_paint_mode (brush_select->context, paint_mode);
if (spacing >= 0)
gtk_adjustment_set_value (spacing_adj, spacing);
gtk_window_present (GTK_WINDOW (brush_select->shell));
}
else
success = FALSE;
}
else
if (gimp->no_interface ||
! procedural_db_lookup (gimp, brush_callback) ||
! gimp_pdb_dialog_set (gimp, gimp->brush_factory->container,
brush_callback, brush_name,
"opacity", opacity / 100.0,
"paint-mode", paint_mode,
"spacing", spacing,
NULL))
success = FALSE;
}

View File

@ -21,18 +21,14 @@
#include "config.h"
#include <gtk/gtk.h>
#include <glib-object.h>
#include "libgimpbase/gimpbasetypes.h"
#include "pdb-types.h"
#include "gui/gui-types.h"
#include "procedural_db.h"
#include "core/gimp.h"
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h"
#include "gui/font-select.h"
static ProcRecord fonts_popup_proc;
static ProcRecord fonts_close_popup_proc;
@ -55,7 +51,6 @@ fonts_popup_invoker (Gimp *gimp,
gchar *font_callback;
gchar *popup_title;
gchar *initial_font;
ProcRecord *proc;
font_callback = (gchar *) args[0].value.pdb_pointer;
if (font_callback == NULL || !g_utf8_validate (font_callback, -1, NULL))
@ -71,13 +66,11 @@ fonts_popup_invoker (Gimp *gimp,
if (success)
{
if (! gimp->no_interface &&
(proc = procedural_db_lookup (gimp, font_callback)))
{
font_select_new (gimp, context, popup_title,
initial_font, font_callback);
}
else
if (gimp->no_interface ||
! procedural_db_lookup (gimp, font_callback) ||
! gimp_pdb_dialog_new (gimp, context, gimp->fonts,
popup_title, font_callback, initial_font,
NULL))
success = FALSE;
}
@ -126,8 +119,6 @@ fonts_close_popup_invoker (Gimp *gimp,
{
gboolean success = TRUE;
gchar *font_callback;
ProcRecord *proc;
FontSelect *font_select;
font_callback = (gchar *) args[0].value.pdb_pointer;
if (font_callback == NULL || !g_utf8_validate (font_callback, -1, NULL))
@ -135,13 +126,9 @@ fonts_close_popup_invoker (Gimp *gimp,
if (success)
{
if (! gimp->no_interface &&
(proc = procedural_db_lookup (gimp, font_callback)) &&
(font_select = font_select_get_by_callback (font_callback)))
{
font_select_free (font_select);
}
else
if (gimp->no_interface ||
! procedural_db_lookup (gimp, font_callback) ||
! gimp_pdb_dialog_close (gimp, gimp->fonts, font_callback))
success = FALSE;
}
@ -181,8 +168,6 @@ fonts_set_popup_invoker (Gimp *gimp,
gboolean success = TRUE;
gchar *font_callback;
gchar *font_name;
ProcRecord *proc;
FontSelect *font_select;
font_callback = (gchar *) args[0].value.pdb_pointer;
if (font_callback == NULL || !g_utf8_validate (font_callback, -1, NULL))
@ -194,23 +179,10 @@ fonts_set_popup_invoker (Gimp *gimp,
if (success)
{
if (! gimp->no_interface &&
(proc = procedural_db_lookup (gimp, font_callback)) &&
(font_select = font_select_get_by_callback (font_callback)))
{
GimpFont *active = (GimpFont *)
gimp_container_get_child_by_name (gimp->fonts, font_name);
if (active)
{
gimp_context_set_font (font_select->context, active);
gtk_window_present (GTK_WINDOW (font_select->shell));
}
else
success = FALSE;
}
else
if (gimp->no_interface ||
! procedural_db_lookup (gimp, font_callback) ||
! gimp_pdb_dialog_set (gimp, gimp->fonts, font_callback, font_name,
NULL))
success = FALSE;
}

View File

@ -21,20 +21,16 @@
#include "config.h"
#include <gtk/gtk.h>
#include <glib-object.h>
#include "libgimpbase/gimpbasetypes.h"
#include "pdb-types.h"
#include "gui/gui-types.h"
#include "procedural_db.h"
#include "core/gimp.h"
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h"
#include "core/gimpdatafactory.h"
#include "core/gimpgradient.h"
#include "gui/gradient-select.h"
static ProcRecord gradients_popup_proc;
static ProcRecord gradients_close_popup_proc;
@ -58,7 +54,6 @@ gradients_popup_invoker (Gimp *gimp,
gchar *popup_title;
gchar *initial_gradient;
gint32 sample_size;
ProcRecord *proc;
gradient_callback = (gchar *) args[0].value.pdb_pointer;
if (gradient_callback == NULL || !g_utf8_validate (gradient_callback, -1, NULL))
@ -78,14 +73,12 @@ gradients_popup_invoker (Gimp *gimp,
if (success)
{
if (! gimp->no_interface &&
(proc = procedural_db_lookup (gimp, gradient_callback)))
{
gradient_select_new (gimp, context, popup_title,
initial_gradient, gradient_callback,
sample_size);
}
else
if (gimp->no_interface ||
! procedural_db_lookup (gimp, gradient_callback) ||
! gimp_pdb_dialog_new (gimp, context, gimp->gradient_factory->container,
popup_title, gradient_callback, initial_gradient,
"sample-size", sample_size,
NULL))
success = FALSE;
}
@ -139,8 +132,6 @@ gradients_close_popup_invoker (Gimp *gimp,
{
gboolean success = TRUE;
gchar *gradient_callback;
ProcRecord *prec;
GradientSelect *gradient_select;
gradient_callback = (gchar *) args[0].value.pdb_pointer;
if (gradient_callback == NULL || !g_utf8_validate (gradient_callback, -1, NULL))
@ -148,13 +139,10 @@ gradients_close_popup_invoker (Gimp *gimp,
if (success)
{
if (! gimp->no_interface &&
(prec = procedural_db_lookup (gimp, gradient_callback)) &&
(gradient_select = gradient_select_get_by_callback (gradient_callback)))
{
gradient_select_free (gradient_select);
}
else
if (gimp->no_interface ||
! procedural_db_lookup (gimp, gradient_callback) ||
! gimp_pdb_dialog_close (gimp, gimp->gradient_factory->container,
gradient_callback))
success = FALSE;
}
@ -194,8 +182,6 @@ gradients_set_popup_invoker (Gimp *gimp,
gboolean success = TRUE;
gchar *gradient_callback;
gchar *gradient_name;
ProcRecord *prec;
GradientSelect *gradient_select;
gradient_callback = (gchar *) args[0].value.pdb_pointer;
if (gradient_callback == NULL || !g_utf8_validate (gradient_callback, -1, NULL))
@ -207,24 +193,11 @@ gradients_set_popup_invoker (Gimp *gimp,
if (success)
{
if (! gimp->no_interface &&
(prec = procedural_db_lookup (gimp, gradient_callback)) &&
(gradient_select = gradient_select_get_by_callback (gradient_callback)))
{
GimpGradient *active = (GimpGradient *)
gimp_container_get_child_by_name (gimp->gradient_factory->container,
gradient_name);
if (active)
{
gimp_context_set_gradient (gradient_select->context, active);
gtk_window_present (GTK_WINDOW (gradient_select->shell));
}
else
success = FALSE;
}
else
if (gimp->no_interface ||
! procedural_db_lookup (gimp, gradient_callback) ||
! gimp_pdb_dialog_set (gimp, gimp->gradient_factory->container,
gradient_callback, gradient_name,
NULL))
success = FALSE;
}

View File

@ -21,19 +21,15 @@
#include "config.h"
#include <gtk/gtk.h>
#include <glib-object.h>
#include "libgimpbase/gimpbasetypes.h"
#include "pdb-types.h"
#include "gui/gui-types.h"
#include "procedural_db.h"
#include "core/gimp.h"
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h"
#include "core/gimpdatafactory.h"
#include "gui/palette-select.h"
static ProcRecord palettes_popup_proc;
static ProcRecord palettes_close_popup_proc;
@ -56,7 +52,6 @@ palettes_popup_invoker (Gimp *gimp,
gchar *palette_callback;
gchar *popup_title;
gchar *initial_palette;
ProcRecord *proc;
palette_callback = (gchar *) args[0].value.pdb_pointer;
if (palette_callback == NULL || !g_utf8_validate (palette_callback, -1, NULL))
@ -72,13 +67,11 @@ palettes_popup_invoker (Gimp *gimp,
if (success)
{
if (! gimp->no_interface &&
(proc = procedural_db_lookup (gimp, palette_callback)))
{
palette_select_new (gimp, context, popup_title,
initial_palette, palette_callback);
}
else
if (gimp->no_interface ||
! procedural_db_lookup (gimp, palette_callback) ||
! gimp_pdb_dialog_new (gimp, context, gimp->palette_factory->container,
popup_title, palette_callback, initial_palette,
NULL))
success = FALSE;
}
@ -127,8 +120,6 @@ palettes_close_popup_invoker (Gimp *gimp,
{
gboolean success = TRUE;
gchar *palette_callback;
ProcRecord *proc;
PaletteSelect *palette_select;
palette_callback = (gchar *) args[0].value.pdb_pointer;
if (palette_callback == NULL || !g_utf8_validate (palette_callback, -1, NULL))
@ -136,13 +127,10 @@ palettes_close_popup_invoker (Gimp *gimp,
if (success)
{
if (! gimp->no_interface &&
(proc = procedural_db_lookup (gimp, palette_callback)) &&
(palette_select = palette_select_get_by_callback (palette_callback)))
{
palette_select_free (palette_select);
}
else
if (gimp->no_interface ||
! procedural_db_lookup (gimp, palette_callback) ||
! gimp_pdb_dialog_close (gimp, gimp->palette_factory->container,
palette_callback))
success = FALSE;
}
@ -182,8 +170,6 @@ palettes_set_popup_invoker (Gimp *gimp,
gboolean success = TRUE;
gchar *palette_callback;
gchar *palette_name;
ProcRecord *proc;
PaletteSelect *palette_select;
palette_callback = (gchar *) args[0].value.pdb_pointer;
if (palette_callback == NULL || !g_utf8_validate (palette_callback, -1, NULL))
@ -195,24 +181,11 @@ palettes_set_popup_invoker (Gimp *gimp,
if (success)
{
if (! gimp->no_interface &&
(proc = procedural_db_lookup (gimp, palette_callback)) &&
(palette_select = palette_select_get_by_callback (palette_callback)))
{
GimpPalette *active = (GimpPalette *)
gimp_container_get_child_by_name (gimp->palette_factory->container,
palette_name);
if (active)
{
gimp_context_set_palette (palette_select->context, active);
gtk_window_present (GTK_WINDOW (palette_select->shell));
}
else
success = FALSE;
}
else
if (gimp->no_interface ||
! procedural_db_lookup (gimp, palette_callback) ||
! gimp_pdb_dialog_set (gimp, gimp->palette_factory->container,
palette_callback, palette_name,
NULL))
success = FALSE;
}

View File

@ -21,19 +21,15 @@
#include "config.h"
#include <gtk/gtk.h>
#include <glib-object.h>
#include "libgimpbase/gimpbasetypes.h"
#include "pdb-types.h"
#include "gui/gui-types.h"
#include "procedural_db.h"
#include "core/gimp.h"
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h"
#include "core/gimpdatafactory.h"
#include "gui/pattern-select.h"
static ProcRecord patterns_popup_proc;
static ProcRecord patterns_close_popup_proc;
@ -56,7 +52,6 @@ patterns_popup_invoker (Gimp *gimp,
gchar *pattern_callback;
gchar *popup_title;
gchar *initial_pattern;
ProcRecord *proc;
pattern_callback = (gchar *) args[0].value.pdb_pointer;
if (pattern_callback == NULL || !g_utf8_validate (pattern_callback, -1, NULL))
@ -72,13 +67,11 @@ patterns_popup_invoker (Gimp *gimp,
if (success)
{
if (! gimp->no_interface &&
(proc = procedural_db_lookup (gimp, pattern_callback)))
{
pattern_select_new (gimp, context, popup_title,
initial_pattern, pattern_callback);
}
else
if (gimp->no_interface ||
! procedural_db_lookup (gimp, pattern_callback) ||
! gimp_pdb_dialog_new (gimp, context, gimp->pattern_factory->container,
popup_title, pattern_callback, initial_pattern,
NULL))
success = FALSE;
}
@ -127,8 +120,6 @@ patterns_close_popup_invoker (Gimp *gimp,
{
gboolean success = TRUE;
gchar *pattern_callback;
ProcRecord *proc;
PatternSelect *pattern_select;
pattern_callback = (gchar *) args[0].value.pdb_pointer;
if (pattern_callback == NULL || !g_utf8_validate (pattern_callback, -1, NULL))
@ -136,13 +127,10 @@ patterns_close_popup_invoker (Gimp *gimp,
if (success)
{
if (! gimp->no_interface &&
(proc = procedural_db_lookup (gimp, pattern_callback)) &&
(pattern_select = pattern_select_get_by_callback (pattern_callback)))
{
pattern_select_free (pattern_select);
}
else
if (gimp->no_interface ||
! procedural_db_lookup (gimp, pattern_callback) ||
! gimp_pdb_dialog_close (gimp, gimp->pattern_factory->container,
pattern_callback))
success = FALSE;
}
@ -182,8 +170,6 @@ patterns_set_popup_invoker (Gimp *gimp,
gboolean success = TRUE;
gchar *pattern_callback;
gchar *pattern_name;
ProcRecord *proc;
PatternSelect *pattern_select;
pattern_callback = (gchar *) args[0].value.pdb_pointer;
if (pattern_callback == NULL || !g_utf8_validate (pattern_callback, -1, NULL))
@ -195,24 +181,11 @@ patterns_set_popup_invoker (Gimp *gimp,
if (success)
{
if (! gimp->no_interface &&
(proc = procedural_db_lookup (gimp, pattern_callback)) &&
(pattern_select = pattern_select_get_by_callback (pattern_callback)))
{
GimpPattern *active = (GimpPattern *)
gimp_container_get_child_by_name (gimp->pattern_factory->container,
pattern_name);
if (active)
{
gimp_context_set_pattern (pattern_select->context, active);
gtk_window_present (GTK_WINDOW (pattern_select->shell));
}
else
success = FALSE;
}
else
if (gimp->no_interface ||
! procedural_db_lookup (gimp, pattern_callback) ||
! gimp_pdb_dialog_set (gimp, gimp->pattern_factory->container,
pattern_callback, pattern_name,
NULL))
success = FALSE;
}

View File

@ -29,6 +29,8 @@ libappwidgets_a_sources = \
gimpbrusheditor.h \
gimpbrushfactoryview.c \
gimpbrushfactoryview.h \
gimpbrushselect.c \
gimpbrushselect.h \
gimpbufferview.c \
gimpbufferview.h \
gimpcellrenderertoggle.c \
@ -89,6 +91,8 @@ libappwidgets_a_sources = \
gimpdataeditor.h \
gimpdatafactoryview.c \
gimpdatafactoryview.h \
gimpdataselect.c \
gimpdataselect.h \
gimpdeviceinfo.c \
gimpdeviceinfo.h \
gimpdevices.c \
@ -127,10 +131,14 @@ libappwidgets_a_sources = \
gimpfgbgeditor.h \
gimpfiledialog.c \
gimpfiledialog.h \
gimpfontselect.c \
gimpfontselect.h \
gimpfontview.c \
gimpfontview.h \
gimpgradienteditor.c \
gimpgradienteditor.h \
gimpgradientselect.c \
gimpgradientselect.h \
gimpgrideditor.c \
gimpgrideditor.h \
gimphelp.c \
@ -160,8 +168,14 @@ libappwidgets_a_sources = \
gimpnavigationpreview.h \
gimppaletteeditor.c \
gimppaletteeditor.h \
gimppaletteselect.c \
gimppaletteselect.h \
gimppatternfactoryview.c \
gimppatternfactoryview.h \
gimppatternselect.c \
gimppatternselect.h \
gimppdbdialog.c \
gimppdbdialog.h \
gimppluginaction.c \
gimppluginaction.h \
gimppreview.c \

View File

@ -0,0 +1,364 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpbrushselect.c
* Copyright (C) 2004 Michael Natterer <mitch@gimp.org>
*
* 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-types.h"
#include "base/temp-buf.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "core/gimpbrush.h"
#include "pdb/procedural_db.h"
#include "gimpbrushfactoryview.h"
#include "gimpbrushselect.h"
#include "gimpcontainerbox.h"
#include "gimpwidgets-constructors.h"
#include "gimp-intl.h"
enum
{
PROP_0,
PROP_OPACITY,
PROP_PAINT_MODE,
PROP_SPACING
};
static void gimp_brush_select_class_init (GimpBrushSelectClass *klass);
static GObject * gimp_brush_select_constructor (GType type,
guint n_params,
GObjectConstructParam *params);
static void gimp_brush_select_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static Argument * gimp_brush_select_run_callback (GimpPdbDialog *dialog,
GimpObject *object,
gboolean closing,
gint *n_return_vals);
static void gimp_brush_select_opacity_changed (GimpContext *context,
gdouble opacity,
GimpBrushSelect *select);
static void gimp_brush_select_mode_changed (GimpContext *context,
GimpLayerModeEffects paint_mode,
GimpBrushSelect *select);
static void gimp_brush_select_opacity_update (GtkAdjustment *adj,
GimpBrushSelect *select);
static void gimp_brush_select_mode_update (GtkWidget *widget,
GimpBrushSelect *select);
static void gimp_brush_select_spacing_update (GtkAdjustment *adj,
GimpBrushSelect *select);
static GimpDataSelectClass *parent_class = NULL;
GType
gimp_brush_select_get_type (void)
{
static GType dialog_type = 0;
if (! dialog_type)
{
static const GTypeInfo dialog_info =
{
sizeof (GimpBrushSelectClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_brush_select_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpBrushSelect),
0, /* n_preallocs */
NULL /* instance_init */
};
dialog_type = g_type_register_static (GIMP_TYPE_DATA_SELECT,
"GimpBrushSelect",
&dialog_info, 0);
}
return dialog_type;
}
static void
gimp_brush_select_class_init (GimpBrushSelectClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpPdbDialogClass *pdb_class = GIMP_PDB_DIALOG_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->constructor = gimp_brush_select_constructor;
object_class->set_property = gimp_brush_select_set_property;
pdb_class->run_callback = gimp_brush_select_run_callback;
g_object_class_install_property (object_class, PROP_OPACITY,
g_param_spec_double ("opacity", NULL, NULL,
GIMP_OPACITY_TRANSPARENT,
GIMP_OPACITY_OPAQUE,
GIMP_OPACITY_OPAQUE,
G_PARAM_WRITABLE |
G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class, PROP_PAINT_MODE,
g_param_spec_enum ("paint-mode", NULL, NULL,
GIMP_TYPE_LAYER_MODE_EFFECTS,
GIMP_NORMAL_MODE,
G_PARAM_WRITABLE |
G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class, PROP_SPACING,
g_param_spec_int ("spacing", NULL, NULL,
-G_MAXINT, 1000, -1,
G_PARAM_WRITABLE |
G_PARAM_CONSTRUCT));
}
static GObject *
gimp_brush_select_constructor (GType type,
guint n_params,
GObjectConstructParam *params)
{
GObject *object;
GimpPdbDialog *dialog;
GimpBrushSelect *select;
GtkWidget *table;
GtkAdjustment *spacing_adj;
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
dialog = GIMP_PDB_DIALOG (object);
select = GIMP_BRUSH_SELECT (object);
gimp_context_set_opacity (dialog->context, select->initial_opacity);
gimp_context_set_paint_mode (dialog->context, select->initial_mode);
g_signal_connect (dialog->context, "opacity_changed",
G_CALLBACK (gimp_brush_select_opacity_changed),
dialog);
g_signal_connect (dialog->context, "paint_mode_changed",
G_CALLBACK (gimp_brush_select_mode_changed),
dialog);
dialog->view =
gimp_brush_factory_view_new (GIMP_VIEW_TYPE_GRID,
dialog->context->gimp->brush_factory,
GIMP_DATA_SELECT (dialog)->edit_func,
dialog->context,
FALSE,
GIMP_PREVIEW_SIZE_MEDIUM, 1,
dialog->menu_factory);
gimp_container_box_set_size_request (GIMP_CONTAINER_BOX (GIMP_CONTAINER_EDITOR (dialog->view)->view),
5 * (GIMP_PREVIEW_SIZE_MEDIUM + 2),
5 * (GIMP_PREVIEW_SIZE_MEDIUM + 2));
gtk_container_set_border_width (GTK_CONTAINER (dialog->view), 12);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), dialog->view);
gtk_widget_show (dialog->view);
/* Create the frame and the table for the options */
table = GIMP_BRUSH_FACTORY_VIEW (dialog->view)->spacing_scale->parent;
gtk_table_set_col_spacings (GTK_TABLE (table), 6);
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
/* Create the opacity scale widget */
select->opacity_data =
GTK_ADJUSTMENT (gimp_scale_entry_new (GTK_TABLE (table), 0, 1,
_("Opacity:"), -1, 5,
gimp_context_get_opacity (dialog->context) * 100.0,
0.0, 100.0, 1.0, 10.0, 1,
TRUE, 0.0, 0.0,
NULL, NULL));
g_signal_connect (select->opacity_data, "value_changed",
G_CALLBACK (gimp_brush_select_opacity_update),
select);
/* Create the paint mode option menu */
select->paint_mode_menu =
gimp_paint_mode_menu_new (G_CALLBACK (gimp_brush_select_mode_update),
select,
TRUE,
gimp_context_get_paint_mode (dialog->context));
gimp_table_attach_aligned (GTK_TABLE (table), 0, 2,
_("Mode:"), 0.0, 0.5,
select->paint_mode_menu, 2, FALSE);
spacing_adj = GIMP_BRUSH_FACTORY_VIEW (dialog->view)->spacing_adjustment;
/* Use passed spacing instead of brushes default */
if (select->spacing >= 0)
gtk_adjustment_set_value (spacing_adj, select->spacing);
g_signal_connect (spacing_adj, "value_changed",
G_CALLBACK (gimp_brush_select_spacing_update),
select);
gtk_widget_show (table);
return object;
}
static void
gimp_brush_select_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpPdbDialog *dialog = GIMP_PDB_DIALOG (object);
GimpBrushSelect *select = GIMP_BRUSH_SELECT (object);
switch (property_id)
{
case PROP_OPACITY:
if (dialog->view)
gimp_context_set_opacity (dialog->context, g_value_get_double (value));
else
select->initial_opacity = g_value_get_double (value);
break;
case PROP_PAINT_MODE:
if (dialog->view)
gimp_context_set_paint_mode (dialog->context, g_value_get_enum (value));
else
select->initial_mode = g_value_get_enum (value);
break;
case PROP_SPACING:
if (dialog->view)
{
if (g_value_get_int (value) >= 0)
gtk_adjustment_set_value (GIMP_BRUSH_FACTORY_VIEW (dialog->view)->spacing_adjustment,
g_value_get_int (value));
}
else
{
select->spacing = g_value_get_int (value);
}
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static Argument *
gimp_brush_select_run_callback (GimpPdbDialog *dialog,
GimpObject *object,
gboolean closing,
gint *n_return_vals)
{
GimpBrush *brush = GIMP_BRUSH (object);
return procedural_db_run_proc (dialog->context->gimp,
dialog->context,
dialog->callback_name,
n_return_vals,
GIMP_PDB_STRING, object->name,
GIMP_PDB_FLOAT, gimp_context_get_opacity (dialog->context) * 100.0,
GIMP_PDB_INT32, GIMP_BRUSH_SELECT (dialog)->spacing,
GIMP_PDB_INT32, (gint) gimp_context_get_paint_mode (dialog->context),
GIMP_PDB_INT32, brush->mask->width,
GIMP_PDB_INT32, brush->mask->height,
GIMP_PDB_INT32, (brush->mask->width *
brush->mask->height),
GIMP_PDB_INT8ARRAY, temp_buf_data (brush->mask),
GIMP_PDB_INT32, closing,
GIMP_PDB_END);
}
static void
gimp_brush_select_opacity_changed (GimpContext *context,
gdouble opacity,
GimpBrushSelect *select)
{
g_signal_handlers_block_by_func (select->opacity_data,
gimp_brush_select_opacity_update,
select);
gtk_adjustment_set_value (GTK_ADJUSTMENT (select->opacity_data),
opacity * 100.0);
g_signal_handlers_unblock_by_func (select->opacity_data,
gimp_brush_select_opacity_update,
select);
gimp_pdb_dialog_run_callback (GIMP_PDB_DIALOG (select), FALSE);
}
static void
gimp_brush_select_mode_changed (GimpContext *context,
GimpLayerModeEffects paint_mode,
GimpBrushSelect *select)
{
gimp_paint_mode_menu_set_history (GTK_OPTION_MENU (select->paint_mode_menu),
paint_mode);
gimp_pdb_dialog_run_callback (GIMP_PDB_DIALOG (select), FALSE);
}
static void
gimp_brush_select_opacity_update (GtkAdjustment *adjustment,
GimpBrushSelect *select)
{
gimp_context_set_opacity (GIMP_PDB_DIALOG (select)->context,
adjustment->value / 100.0);
}
static void
gimp_brush_select_mode_update (GtkWidget *widget,
GimpBrushSelect *select)
{
GimpLayerModeEffects paint_mode;
paint_mode = (GimpLayerModeEffects)
GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "gimp-item-data"));
gimp_context_set_paint_mode (GIMP_PDB_DIALOG (select)->context, paint_mode);
}
static void
gimp_brush_select_spacing_update (GtkAdjustment *adjustment,
GimpBrushSelect *select)
{
if (select->spacing != adjustment->value)
{
select->spacing = adjustment->value;
gimp_pdb_dialog_run_callback (GIMP_PDB_DIALOG (select), FALSE);
}
}

View File

@ -0,0 +1,63 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpbrushselect.h
* Copyright (C) 2004 Michael Natterer <mitch@gimp.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_BRUSH_SELECT_H__
#define __GIMP_BRUSH_SELECT_H__
#include "gimpdataselect.h"
G_BEGIN_DECLS
#define GIMP_TYPE_BRUSH_SELECT (gimp_brush_select_get_type ())
#define GIMP_BRUSH_SELECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_BRUSH_SELECT, GimpBrushSelect))
#define GIMP_BRUSH_SELECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_BRUSH_SELECT, GimpBrushSelectClass))
#define GIMP_IS_BRUSH_SELECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_BRUSH_SELECT))
#define GIMP_IS_BRUSH_SELECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_BRUSH_SELECT))
#define GIMP_BRUSH_SELECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_BRUSH_SELECT, GimpBrushSelectClass))
typedef struct _GimpBrushSelectClass GimpBrushSelectClass;
struct _GimpBrushSelect
{
GimpDataSelect parent_instance;
gdouble initial_opacity;
GimpLayerModeEffects initial_mode;
gint spacing;
GtkAdjustment *opacity_data;
GtkWidget *paint_mode_menu;
};
struct _GimpBrushSelectClass
{
GimpDataSelectClass parent_class;
};
GType gimp_brush_select_get_type (void) G_GNUC_CONST;
G_END_DECLS
#endif /* __GIMP_BRUSH_SELECT_H__ */

View File

@ -26,10 +26,6 @@
#include "gimpcontainereditor.h"
typedef void (* GimpDataEditFunc) (GimpData *data,
GtkWidget *parent);
#define GIMP_TYPE_DATA_FACTORY_VIEW (gimp_data_factory_view_get_type ())
#define GIMP_DATA_FACTORY_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_DATA_FACTORY_VIEW, GimpDataFactoryView))
#define GIMP_DATA_FACTORY_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_DATA_FACTORY_VIEW, GimpDataFactoryViewClass))

View File

@ -0,0 +1,113 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpdataselect.c
* Copyright (C) 2004 Michael Natterer <mitch@gimp.org>
*
* 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-types.h"
#include "gimpdataselect.h"
enum
{
PROP_0,
PROP_EDIT_FUNC
};
static void gimp_data_select_class_init (GimpDataSelectClass *klass);
static void gimp_data_select_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static GimpPdbDialogClass *parent_class = NULL;
GType
gimp_data_select_get_type (void)
{
static GType dialog_type = 0;
if (! dialog_type)
{
static const GTypeInfo dialog_info =
{
sizeof (GimpDataSelectClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_data_select_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpDataSelect),
0, /* n_preallocs */
NULL, /* instance_init */
};
dialog_type = g_type_register_static (GIMP_TYPE_PDB_DIALOG,
"GimpDataSelect",
&dialog_info,
G_TYPE_FLAG_ABSTRACT);
}
return dialog_type;
}
static void
gimp_data_select_class_init (GimpDataSelectClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->set_property = gimp_data_select_set_property;
g_object_class_install_property (object_class, PROP_EDIT_FUNC,
g_param_spec_pointer ("edit-func",
NULL, NULL,
G_PARAM_WRITABLE |
G_PARAM_CONSTRUCT_ONLY));
}
static void
gimp_data_select_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpDataSelect *select = GIMP_DATA_SELECT (object);
switch (property_id)
{
case PROP_EDIT_FUNC:
select->edit_func = g_value_get_pointer (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}

View File

@ -0,0 +1,58 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpdataselect.h
* Copyright (C) 2004 Michael Natterer <mitch@gimp.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_DATA_SELECT_H__
#define __GIMP_DATA_SELECT_H__
#include "gimppdbdialog.h"
G_BEGIN_DECLS
#define GIMP_TYPE_DATA_SELECT (gimp_data_select_get_type ())
#define GIMP_DATA_SELECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_DATA_SELECT, GimpDataSelect))
#define GIMP_DATA_SELECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_DATA_SELECT, GimpDataSelectClass))
#define GIMP_IS_DATA_SELECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_DATA_SELECT))
#define GIMP_IS_DATA_SELECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_DATA_SELECT))
#define GIMP_DATA_SELECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_DATA_SELECT, GimpDataSelectClass))
typedef struct _GimpDataSelectClass GimpDataSelectClass;
struct _GimpDataSelect
{
GimpPdbDialog parent_instance;
GimpDataEditFunc edit_func;
};
struct _GimpDataSelectClass
{
GimpPdbDialogClass parent_class;
};
GType gimp_data_select_get_type (void) G_GNUC_CONST;
G_END_DECLS
#endif /* __GIMP_DATA_SELECT_H__ */

View File

@ -0,0 +1,140 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpfontselect.c
* Copyright (C) 2004 Michael Natterer <mitch@gimp.org>
*
* 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-types.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "text/gimpfont.h"
#include "pdb/procedural_db.h"
#include "gimpcontainerbox.h"
#include "gimpfontselect.h"
#include "gimpfontview.h"
static void gimp_font_select_class_init (GimpFontSelectClass *klass);
static GObject * gimp_font_select_constructor (GType type,
guint n_params,
GObjectConstructParam *params);
static Argument * gimp_font_select_run_callback (GimpPdbDialog *dialog,
GimpObject *object,
gboolean closing,
gint *n_return_vals);
static GimpPdbDialogClass *parent_class = NULL;
GType
gimp_font_select_get_type (void)
{
static GType dialog_type = 0;
if (! dialog_type)
{
static const GTypeInfo dialog_info =
{
sizeof (GimpFontSelectClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_font_select_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpFontSelect),
0, /* n_preallocs */
NULL /* instance_init */
};
dialog_type = g_type_register_static (GIMP_TYPE_PDB_DIALOG,
"GimpFontSelect",
&dialog_info, 0);
}
return dialog_type;
}
static void
gimp_font_select_class_init (GimpFontSelectClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpPdbDialogClass *pdb_class = GIMP_PDB_DIALOG_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->constructor = gimp_font_select_constructor;
pdb_class->run_callback = gimp_font_select_run_callback;
}
static GObject *
gimp_font_select_constructor (GType type,
guint n_params,
GObjectConstructParam *params)
{
GObject *object;
GimpPdbDialog *dialog;
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
dialog = GIMP_PDB_DIALOG (object);
dialog->view = gimp_font_view_new (GIMP_VIEW_TYPE_LIST,
dialog->context->gimp->fonts,
dialog->context,
GIMP_PREVIEW_SIZE_MEDIUM, 1,
dialog->menu_factory);
gimp_container_box_set_size_request (GIMP_CONTAINER_BOX (GIMP_CONTAINER_EDITOR (dialog->view)->view),
6 * (GIMP_PREVIEW_SIZE_MEDIUM + 2),
6 * (GIMP_PREVIEW_SIZE_MEDIUM + 2));
gtk_container_set_border_width (GTK_CONTAINER (dialog->view), 12);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), dialog->view);
gtk_widget_show (dialog->view);
return object;
}
static Argument *
gimp_font_select_run_callback (GimpPdbDialog *dialog,
GimpObject *object,
gboolean closing,
gint *n_return_vals)
{
return procedural_db_run_proc (dialog->context->gimp,
dialog->context,
dialog->callback_name,
n_return_vals,
GIMP_PDB_STRING, object->name,
GIMP_PDB_INT32, closing,
GIMP_PDB_END);
}

View File

@ -0,0 +1,56 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpfontselect.h
* Copyright (C) 2004 Michael Natterer <mitch@gimp.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_FONT_SELECT_H__
#define __GIMP_FONT_SELECT_H__
#include "gimppdbdialog.h"
G_BEGIN_DECLS
#define GIMP_TYPE_FONT_SELECT (gimp_font_select_get_type ())
#define GIMP_FONT_SELECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_FONT_SELECT, GimpFontSelect))
#define GIMP_FONT_SELECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_FONT_SELECT, GimpFontSelectClass))
#define GIMP_IS_FONT_SELECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_FONT_SELECT))
#define GIMP_IS_FONT_SELECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_FONT_SELECT))
#define GIMP_FONT_SELECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_FONT_SELECT, GimpFontSelectClass))
typedef struct _GimpFontSelectClass GimpFontSelectClass;
struct _GimpFontSelect
{
GimpPdbDialog parent_instance;
};
struct _GimpFontSelectClass
{
GimpPdbDialogClass parent_class;
};
GType gimp_font_select_get_type (void) G_GNUC_CONST;
G_END_DECLS
#endif /* __GIMP_FONT_SELECT_H__ */

View File

@ -0,0 +1,207 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpgradientselect.c
* Copyright (C) 2004 Michael Natterer <mitch@gimp.org>
*
* 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-types.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "core/gimpgradient.h"
#include "pdb/procedural_db.h"
#include "gimpcontainerbox.h"
#include "gimpdatafactoryview.h"
#include "gimpgradientselect.h"
enum
{
PROP_0,
PROP_SAMPLE_SIZE
};
static void gimp_gradient_select_class_init (GimpGradientSelectClass *klass);
static GObject * gimp_gradient_select_constructor (GType type,
guint n_params,
GObjectConstructParam *params);
static void gimp_gradient_select_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static Argument * gimp_gradient_select_run_callback (GimpPdbDialog *dialog,
GimpObject *object,
gboolean closing,
gint *n_return_vals);
static GimpDataSelectClass *parent_class = NULL;
GType
gimp_gradient_select_get_type (void)
{
static GType dialog_type = 0;
if (! dialog_type)
{
static const GTypeInfo dialog_info =
{
sizeof (GimpGradientSelectClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_gradient_select_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpGradientSelect),
0, /* n_preallocs */
NULL /* instance_init */
};
dialog_type = g_type_register_static (GIMP_TYPE_DATA_SELECT,
"GimpGradientSelect",
&dialog_info, 0);
}
return dialog_type;
}
static void
gimp_gradient_select_class_init (GimpGradientSelectClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpPdbDialogClass *pdb_class = GIMP_PDB_DIALOG_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->constructor = gimp_gradient_select_constructor;
object_class->set_property = gimp_gradient_select_set_property;
pdb_class->run_callback = gimp_gradient_select_run_callback;
g_object_class_install_property (object_class, PROP_SAMPLE_SIZE,
g_param_spec_int ("sample-size", NULL, NULL,
0, 10000, 84,
G_PARAM_WRITABLE |
G_PARAM_CONSTRUCT_ONLY));
}
static GObject *
gimp_gradient_select_constructor (GType type,
guint n_params,
GObjectConstructParam *params)
{
GObject *object;
GimpPdbDialog *dialog;
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
dialog = GIMP_PDB_DIALOG (object);
dialog->view =
gimp_data_factory_view_new (GIMP_VIEW_TYPE_LIST,
dialog->context->gimp->gradient_factory,
GIMP_DATA_SELECT (dialog)->edit_func,
dialog->context,
GIMP_PREVIEW_SIZE_MEDIUM, 1,
dialog->menu_factory, "<Gradients>",
"/gradients-popup",
"gradients");
gimp_container_box_set_size_request (GIMP_CONTAINER_BOX (GIMP_CONTAINER_EDITOR (dialog->view)->view),
6 * (GIMP_PREVIEW_SIZE_MEDIUM + 2),
6 * (GIMP_PREVIEW_SIZE_MEDIUM + 2));
gtk_container_set_border_width (GTK_CONTAINER (dialog->view), 12);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), dialog->view);
gtk_widget_show (dialog->view);
return object;
}
static Argument *
gimp_gradient_select_run_callback (GimpPdbDialog *dialog,
GimpObject *object,
gboolean closing,
gint *n_return_vals)
{
GimpGradient *gradient = GIMP_GRADIENT (object);
gdouble *values, *pv;
gdouble pos, delta;
GimpRGB color;
gint i;
i = GIMP_GRADIENT_SELECT (dialog)->sample_size;
pos = 0.0;
delta = 1.0 / (i - 1);
values = g_new (gdouble, 4 * i);
pv = values;
while (i--)
{
gimp_gradient_get_color_at (gradient, pos, FALSE, &color);
*pv++ = color.r;
*pv++ = color.g;
*pv++ = color.b;
*pv++ = color.a;
pos += delta;
}
return procedural_db_run_proc (dialog->context->gimp,
dialog->context,
dialog->callback_name,
n_return_vals,
GIMP_PDB_STRING, GIMP_OBJECT (gradient)->name,
GIMP_PDB_INT32, GIMP_GRADIENT_SELECT (dialog)->sample_size * 4,
GIMP_PDB_FLOATARRAY, values,
GIMP_PDB_INT32, closing,
GIMP_PDB_END);
}
static void
gimp_gradient_select_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpGradientSelect *select = GIMP_GRADIENT_SELECT (object);
switch (property_id)
{
case PROP_SAMPLE_SIZE:
select->sample_size = g_value_get_int (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}

View File

@ -0,0 +1,58 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpgradientselect.h
* Copyright (C) 2004 Michael Natterer <mitch@gimp.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_GRADIENT_SELECT_H__
#define __GIMP_GRADIENT_SELECT_H__
#include "gimpdataselect.h"
G_BEGIN_DECLS
#define GIMP_TYPE_GRADIENT_SELECT (gimp_gradient_select_get_type ())
#define GIMP_GRADIENT_SELECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_GRADIENT_SELECT, GimpGradientSelect))
#define GIMP_GRADIENT_SELECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_GRADIENT_SELECT, GimpGradientSelectClass))
#define GIMP_IS_GRADIENT_SELECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_GRADIENT_SELECT))
#define GIMP_IS_GRADIENT_SELECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_GRADIENT_SELECT))
#define GIMP_GRADIENT_SELECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_GRADIENT_SELECT, GimpGradientSelectClass))
typedef struct _GimpGradientSelectClass GimpGradientSelectClass;
struct _GimpGradientSelect
{
GimpDataSelect parent_instance;
gint sample_size;
};
struct _GimpGradientSelectClass
{
GimpDataSelectClass parent_class;
};
GType gimp_gradient_select_get_type (void) G_GNUC_CONST;
G_END_DECLS
#endif /* __GIMP_GRADIENT_SELECT_H__ */

View File

@ -0,0 +1,154 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimppaletteselect.c
* Copyright (C) 2004 Michael Natterer <mitch@gimp.org>
*
* 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-types.h"
#include "base/temp-buf.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "core/gimppalette.h"
#include "pdb/procedural_db.h"
#include "gimpcontainerbox.h"
#include "gimpdatafactoryview.h"
#include "gimppaletteselect.h"
static void gimp_palette_select_class_init (GimpPaletteSelectClass *klass);
static void gimp_palette_select_init (GimpPaletteSelect *dialog);
static GObject * gimp_palette_select_constructor (GType type,
guint n_params,
GObjectConstructParam *params);
static Argument * gimp_palette_select_run_callback (GimpPdbDialog *dialog,
GimpObject *object,
gboolean closing,
gint *n_return_vals);
static GimpDataSelectClass *parent_class = NULL;
GType
gimp_palette_select_get_type (void)
{
static GType dialog_type = 0;
if (! dialog_type)
{
static const GTypeInfo dialog_info =
{
sizeof (GimpPaletteSelectClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_palette_select_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpPaletteSelect),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_palette_select_init,
};
dialog_type = g_type_register_static (GIMP_TYPE_DATA_SELECT,
"GimpPaletteSelect",
&dialog_info, 0);
}
return dialog_type;
}
static void
gimp_palette_select_class_init (GimpPaletteSelectClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpPdbDialogClass *pdb_class = GIMP_PDB_DIALOG_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->constructor = gimp_palette_select_constructor;
pdb_class->run_callback = gimp_palette_select_run_callback;
}
static void
gimp_palette_select_init (GimpPaletteSelect *dialog)
{
}
static GObject *
gimp_palette_select_constructor (GType type,
guint n_params,
GObjectConstructParam *params)
{
GObject *object;
GimpPdbDialog *dialog;
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
dialog = GIMP_PDB_DIALOG (object);
dialog->view =
gimp_data_factory_view_new (GIMP_VIEW_TYPE_LIST,
dialog->context->gimp->palette_factory,
GIMP_DATA_SELECT (dialog)->edit_func,
dialog->context,
GIMP_PREVIEW_SIZE_MEDIUM, 1,
dialog->menu_factory, "<Palettes>",
"/palettes-popup",
"palettes");
gimp_container_box_set_size_request (GIMP_CONTAINER_BOX (GIMP_CONTAINER_EDITOR (dialog->view)->view),
5 * (GIMP_PREVIEW_SIZE_MEDIUM + 2),
8 * (GIMP_PREVIEW_SIZE_MEDIUM + 2));
gtk_container_set_border_width (GTK_CONTAINER (dialog->view), 12);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), dialog->view);
gtk_widget_show (dialog->view);
return object;
}
static Argument *
gimp_palette_select_run_callback (GimpPdbDialog *dialog,
GimpObject *object,
gboolean closing,
gint *n_return_vals)
{
GimpPalette *palette = GIMP_PALETTE (object);
return procedural_db_run_proc (dialog->context->gimp,
dialog->context,
dialog->callback_name,
n_return_vals,
GIMP_PDB_STRING, GIMP_OBJECT (palette)->name,
GIMP_PDB_INT32, palette->n_colors,
GIMP_PDB_INT32, closing,
GIMP_PDB_END);
}

View File

@ -0,0 +1,56 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimppaletteselect.h
* Copyright (C) 2004 Michael Natterer <mitch@gimp.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_PALETTE_SELECT_H__
#define __GIMP_PALETTE_SELECT_H__
#include "gimpdataselect.h"
G_BEGIN_DECLS
#define GIMP_TYPE_PALETTE_SELECT (gimp_palette_select_get_type ())
#define GIMP_PALETTE_SELECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_PALETTE_SELECT, GimpPaletteSelect))
#define GIMP_PALETTE_SELECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_PALETTE_SELECT, GimpPaletteSelectClass))
#define GIMP_IS_PALETTE_SELECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_PALETTE_SELECT))
#define GIMP_IS_PALETTE_SELECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_PALETTE_SELECT))
#define GIMP_PALETTE_SELECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_PALETTE_SELECT, GimpPaletteSelectClass))
typedef struct _GimpPaletteSelectClass GimpPaletteSelectClass;
struct _GimpPaletteSelect
{
GimpDataSelect parent_instance;
};
struct _GimpPaletteSelectClass
{
GimpDataSelectClass parent_class;
};
GType gimp_palette_select_get_type (void) G_GNUC_CONST;
G_END_DECLS
#endif /* __GIMP_PALETTE_SELECT_H__ */

View File

@ -0,0 +1,154 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimppatternselect.c
* Copyright (C) 2004 Michael Natterer <mitch@gimp.org>
*
* 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-types.h"
#include "base/temp-buf.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "core/gimppattern.h"
#include "pdb/procedural_db.h"
#include "gimpcontainerbox.h"
#include "gimpdatafactoryview.h"
#include "gimppatternselect.h"
static void gimp_pattern_select_class_init (GimpPatternSelectClass *klass);
static GObject * gimp_pattern_select_constructor (GType type,
guint n_params,
GObjectConstructParam *params);
static Argument * gimp_pattern_select_run_callback (GimpPdbDialog *dialog,
GimpObject *object,
gboolean closing,
gint *n_return_vals);
static GimpDataSelectClass *parent_class = NULL;
GType
gimp_pattern_select_get_type (void)
{
static GType dialog_type = 0;
if (! dialog_type)
{
static const GTypeInfo dialog_info =
{
sizeof (GimpPatternSelectClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_pattern_select_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpPatternSelect),
0, /* n_preallocs */
NULL /* instance_init */
};
dialog_type = g_type_register_static (GIMP_TYPE_DATA_SELECT,
"GimpPatternSelect",
&dialog_info, 0);
}
return dialog_type;
}
static void
gimp_pattern_select_class_init (GimpPatternSelectClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpPdbDialogClass *pdb_class = GIMP_PDB_DIALOG_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->constructor = gimp_pattern_select_constructor;
pdb_class->run_callback = gimp_pattern_select_run_callback;
}
static GObject *
gimp_pattern_select_constructor (GType type,
guint n_params,
GObjectConstructParam *params)
{
GObject *object;
GimpPdbDialog *dialog;
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
dialog = GIMP_PDB_DIALOG (object);
dialog->view =
gimp_data_factory_view_new (GIMP_VIEW_TYPE_GRID,
dialog->context->gimp->pattern_factory,
GIMP_DATA_SELECT (dialog)->edit_func,
dialog->context,
GIMP_PREVIEW_SIZE_MEDIUM, 1,
dialog->menu_factory, "<Patterns>",
"/patterns-popup",
"patterns");
gimp_container_box_set_size_request (GIMP_CONTAINER_BOX (GIMP_CONTAINER_EDITOR (dialog->view)->view),
6 * (GIMP_PREVIEW_SIZE_MEDIUM + 2),
6 * (GIMP_PREVIEW_SIZE_MEDIUM + 2));
gtk_container_set_border_width (GTK_CONTAINER (dialog->view), 12);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), dialog->view);
gtk_widget_show (dialog->view);
return object;
}
static Argument *
gimp_pattern_select_run_callback (GimpPdbDialog *dialog,
GimpObject *object,
gboolean closing,
gint *n_return_vals)
{
GimpPattern *pattern = GIMP_PATTERN (object);
return procedural_db_run_proc (dialog->context->gimp,
dialog->context,
dialog->callback_name,
n_return_vals,
GIMP_PDB_STRING, GIMP_OBJECT (pattern)->name,
GIMP_PDB_INT32, pattern->mask->width,
GIMP_PDB_INT32, pattern->mask->height,
GIMP_PDB_INT32, pattern->mask->bytes,
GIMP_PDB_INT32, (pattern->mask->bytes *
pattern->mask->height *
pattern->mask->width),
GIMP_PDB_INT8ARRAY, temp_buf_data (pattern->mask),
GIMP_PDB_INT32, closing,
GIMP_PDB_END);
}

View File

@ -0,0 +1,56 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimppatternselect.h
* Copyright (C) 2004 Michael Natterer <mitch@gimp.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_PATTERN_SELECT_H__
#define __GIMP_PATTERN_SELECT_H__
#include "gimpdataselect.h"
G_BEGIN_DECLS
#define GIMP_TYPE_PATTERN_SELECT (gimp_pattern_select_get_type ())
#define GIMP_PATTERN_SELECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_PATTERN_SELECT, GimpPatternSelect))
#define GIMP_PATTERN_SELECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_PATTERN_SELECT, GimpPatternSelectClass))
#define GIMP_IS_PATTERN_SELECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_PATTERN_SELECT))
#define GIMP_IS_PATTERN_SELECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_PATTERN_SELECT))
#define GIMP_PATTERN_SELECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_PATTERN_SELECT, GimpPatternSelectClass))
typedef struct _GimpPatternSelectClass GimpPatternSelectClass;
struct _GimpPatternSelect
{
GimpDataSelect parent_instance;
};
struct _GimpPatternSelectClass
{
GimpDataSelectClass parent_class;
};
GType gimp_pattern_select_get_type (void) G_GNUC_CONST;
G_END_DECLS
#endif /* __GIMP_PATTERN_SELECT_H__ */

384
app/widgets/gimppdbdialog.c Normal file
View File

@ -0,0 +1,384 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimppdbdialog.c
* Copyright (C) 2004 Michael Natterer <mitch@gimp.org>
*
* 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 <string.h>
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
#include "widgets-types.h"
#include "core/gimpcontext.h"
#include "pdb/procedural_db.h"
#include "gimpmenufactory.h"
#include "gimppdbdialog.h"
#include "gimp-intl.h"
enum
{
PROP_0,
PROP_CONTEXT,
PROP_SELECT_TYPE,
PROP_INITIAL_OBJECT,
PROP_CALLBACK_NAME,
PROP_MENU_FACTORY
};
static void gimp_pdb_dialog_class_init (GimpPdbDialogClass *klass);
static void gimp_pdb_dialog_init (GimpPdbDialog *dialog,
GimpPdbDialogClass *klass);
static GObject * gimp_pdb_dialog_constructor (GType type,
guint n_params,
GObjectConstructParam *params);
static void gimp_pdb_dialog_dispose (GObject *object);
static void gimp_pdb_dialog_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_pdb_dialog_destroy (GtkObject *object);
static void gimp_pdb_dialog_response (GtkDialog *dialog,
gint response_id);
static void gimp_pdb_dialog_context_changed (GimpContext *context,
GimpObject *object,
GimpPdbDialog *dialog);
static GimpDialogClass *parent_class = NULL;
GType
gimp_pdb_dialog_get_type (void)
{
static GType dialog_type = 0;
if (! dialog_type)
{
static const GTypeInfo dialog_info =
{
sizeof (GimpPdbDialogClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_pdb_dialog_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpPdbDialog),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_pdb_dialog_init,
};
dialog_type = g_type_register_static (GIMP_TYPE_DIALOG,
"GimpPdbDialog",
&dialog_info,
G_TYPE_FLAG_ABSTRACT);
}
return dialog_type;
}
static void
gimp_pdb_dialog_class_init (GimpPdbDialogClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (klass);
GtkDialogClass *dialog_class = GTK_DIALOG_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->constructor = gimp_pdb_dialog_constructor;
object_class->dispose = gimp_pdb_dialog_dispose;
object_class->set_property = gimp_pdb_dialog_set_property;
object_class->set_property = gimp_pdb_dialog_set_property;
gtk_object_class->destroy = gimp_pdb_dialog_destroy;
dialog_class->response = gimp_pdb_dialog_response;
klass->run_callback = NULL;
g_object_class_install_property (object_class, PROP_CONTEXT,
g_param_spec_object ("context", NULL, NULL,
GIMP_TYPE_CONTEXT,
G_PARAM_WRITABLE |
G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class, PROP_SELECT_TYPE,
g_param_spec_pointer ("select-type",
NULL, NULL,
G_PARAM_WRITABLE |
G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class, PROP_INITIAL_OBJECT,
g_param_spec_object ("initial-object",
NULL, NULL,
GIMP_TYPE_OBJECT,
G_PARAM_WRITABLE |
G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class, PROP_CALLBACK_NAME,
g_param_spec_string ("callback-name",
NULL, NULL,
NULL,
G_PARAM_WRITABLE |
G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class, PROP_MENU_FACTORY,
g_param_spec_object ("menu-factory",
NULL, NULL,
GIMP_TYPE_MENU_FACTORY,
G_PARAM_WRITABLE |
G_PARAM_CONSTRUCT_ONLY));
}
static void
gimp_pdb_dialog_init (GimpPdbDialog *dialog,
GimpPdbDialogClass *klass)
{
klass->dialogs = g_list_prepend (klass->dialogs, dialog);
gtk_dialog_add_button (GTK_DIALOG (dialog),
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
}
static GObject *
gimp_pdb_dialog_constructor (GType type,
guint n_params,
GObjectConstructParam *params)
{
GObject *object;
GimpPdbDialog *dialog;
const gchar *signal_name;
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
dialog = GIMP_PDB_DIALOG (object);
g_assert (GIMP_IS_CONTEXT (dialog->context));
g_assert (g_type_is_a (dialog->select_type, GIMP_TYPE_OBJECT));
dialog->context = gimp_context_new (dialog->context->gimp,
"pdb selection", /* gtk_window_get_title (GTK_WINDOW (object)), */
NULL);
gimp_context_set_by_type (dialog->context, dialog->select_type,
dialog->initial_object);
dialog->initial_object = NULL;
signal_name = gimp_context_type_to_signal_name (dialog->select_type);
g_signal_connect_object (dialog->context, signal_name,
G_CALLBACK (gimp_pdb_dialog_context_changed),
dialog, 0);
return object;
}
static void
gimp_pdb_dialog_dispose (GObject *object)
{
GimpPdbDialogClass *klass = GIMP_PDB_DIALOG_GET_CLASS (object);
klass->dialogs = g_list_remove (klass->dialogs, object);
G_OBJECT_CLASS (parent_class)->dispose (object);
}
static void
gimp_pdb_dialog_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpPdbDialog *dialog = GIMP_PDB_DIALOG (object);
switch (property_id)
{
case PROP_CONTEXT:
/* don't ref, see constructor */
dialog->context = g_value_get_object (value);
break;
case PROP_SELECT_TYPE:
dialog->select_type = (GType) g_value_get_pointer (value);
break;
case PROP_INITIAL_OBJECT:
/* don't ref, see constructor */
dialog->initial_object = g_value_get_object (value);
break;
case PROP_CALLBACK_NAME:
if (dialog->callback_name)
g_free (dialog->callback_name);
dialog->callback_name = g_value_dup_string (value);
break;
case PROP_MENU_FACTORY:
dialog->menu_factory = (GimpMenuFactory *) g_value_dup_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_pdb_dialog_destroy (GtkObject *object)
{
GimpPdbDialog *dialog = GIMP_PDB_DIALOG (object);
if (dialog->context)
{
g_object_unref (dialog->context);
dialog->context = NULL;
}
if (dialog->callback_name)
{
g_free (dialog->callback_name);
dialog->callback_name = NULL;
}
if (dialog->menu_factory)
{
g_object_unref (dialog->menu_factory);
dialog->menu_factory = NULL;
}
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
static void
gimp_pdb_dialog_response (GtkDialog *gtk_dialog,
gint response_id)
{
GimpPdbDialog *dialog = GIMP_PDB_DIALOG (gtk_dialog);
gimp_pdb_dialog_run_callback (dialog, TRUE);
gtk_widget_destroy (GTK_WIDGET (dialog));
}
void
gimp_pdb_dialog_run_callback (GimpPdbDialog *dialog,
gboolean closing)
{
GimpPdbDialogClass *klass = GIMP_PDB_DIALOG_GET_CLASS (dialog);
GimpObject *object;
object = gimp_context_get_by_type (dialog->context, dialog->select_type);
if (object &&
klass->run_callback &&
dialog->callback_name &&
! dialog->callback_busy)
{
dialog->callback_busy = TRUE;
if (procedural_db_lookup (dialog->context->gimp, dialog->callback_name))
{
Argument *return_vals;
gint n_return_vals;
return_vals = klass->run_callback (dialog, object, closing,
&n_return_vals);
if (! return_vals ||
return_vals[0].value.pdb_int != GIMP_PDB_SUCCESS)
{
g_message (_("Unable to run %s callback. "
"The corresponding plug-in may have crashed."),
g_type_name (G_TYPE_FROM_INSTANCE (dialog)));
}
if (return_vals)
procedural_db_destroy_args (return_vals, n_return_vals);
}
dialog->callback_busy = FALSE;
}
}
GimpPdbDialog *
gimp_pdb_dialog_get_by_callback (GimpPdbDialogClass *klass,
const gchar *callback_name)
{
GList *list;
g_return_val_if_fail (GIMP_IS_PDB_DIALOG_CLASS (klass), NULL);
g_return_val_if_fail (callback_name != NULL, NULL);
for (list = klass->dialogs; list; list = g_list_next (list))
{
GimpPdbDialog *dialog = list->data;
if (dialog->callback_name &&
! strcmp (callback_name, dialog->callback_name))
return dialog;
}
return NULL;
}
void
gimp_pdb_dialogs_check_callback (GimpPdbDialogClass *klass)
{
GList *list;
g_return_if_fail (GIMP_IS_PDB_DIALOG_CLASS (klass));
list = klass->dialogs;
while (list)
{
GimpPdbDialog *dialog = list->data;
list = g_list_next (list);
if (dialog->context && dialog->callback_name)
{
if (! procedural_db_lookup (dialog->context->gimp,
dialog->callback_name))
{
gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
}
}
}
}
/* private functions */
static void
gimp_pdb_dialog_context_changed (GimpContext *context,
GimpObject *object,
GimpPdbDialog *dialog)
{
if (object)
gimp_pdb_dialog_run_callback (dialog, FALSE);
}

View File

@ -0,0 +1,79 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimppdbdialog.h
* Copyright (C) 2004 Michael Natterer <mitch@gimp.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_PDB_DIALOG_H__
#define __GIMP_PDB_DIALOG_H__
#include "libgimpwidgets/gimpdialog.h"
G_BEGIN_DECLS
#define GIMP_TYPE_PDB_DIALOG (gimp_pdb_dialog_get_type ())
#define GIMP_PDB_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_PDB_DIALOG, GimpPdbDialog))
#define GIMP_PDB_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_PDB_DIALOG, GimpPdbDialogClass))
#define GIMP_IS_PDB_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_PDB_DIALOG))
#define GIMP_IS_PDB_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_PDB_DIALOG))
#define GIMP_PDB_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_PDB_DIALOG, GimpPdbDialogClass))
typedef struct _GimpPdbDialogClass GimpPdbDialogClass;
struct _GimpPdbDialog
{
GimpDialog parent_instance;
GimpContext *context;
GType select_type;
GimpObject *initial_object;
gchar *callback_name;
gboolean callback_busy;
GimpMenuFactory *menu_factory;
GtkWidget *view;
};
struct _GimpPdbDialogClass
{
GimpDialogClass parent_class;
GList *dialogs;
Argument * (* run_callback) (GimpPdbDialog *dialog,
GimpObject *object,
gboolean closing,
gint *n_return_vals);
};
GType gimp_pdb_dialog_get_type (void) G_GNUC_CONST;
void gimp_pdb_dialog_run_callback (GimpPdbDialog *dialog,
gboolean closing);
GimpPdbDialog * gimp_pdb_dialog_get_by_callback (GimpPdbDialogClass *klass,
const gchar *callback_name);
void gimp_pdb_dialogs_check_callback (GimpPdbDialogClass *klass);
G_END_DECLS
#endif /* __GIMP_PDB_DIALOG_H__ */

View File

@ -124,6 +124,14 @@ typedef struct _GimpTextEditor GimpTextEditor;
typedef struct _GimpViewableDialog GimpToolDialog;
typedef struct _GimpViewableDialog GimpViewableDialog;
typedef struct _GimpPdbDialog GimpPdbDialog;
typedef struct _GimpDataSelect GimpDataSelect;
typedef struct _GimpBrushSelect GimpBrushSelect;
typedef struct _GimpGradientSelect GimpGradientSelect;
typedef struct _GimpPaletteSelect GimpPaletteSelect;
typedef struct _GimpPatternSelect GimpPatternSelect;
typedef struct _GimpFontSelect GimpFontSelect;
typedef struct _GimpContainerPopup GimpContainerPopup;
typedef struct _GimpViewableButton GimpViewableButton;
@ -158,6 +166,9 @@ typedef struct _GimpSessionInfoAux GimpSessionInfoAux;
/* function types */
typedef void (* GimpDataEditFunc) (GimpData *data,
GtkWidget *parent);
typedef void (* GimpActionGroupSetupFunc) (GimpActionGroup *group);
typedef void (* GimpActionGroupUpdateFunc) (GimpActionGroup *group,
gpointer data);

View File

@ -54,19 +54,16 @@ sub brushes_popup {
);
%invoke = (
vars => [ 'ProcRecord *proc' ],
code => <<'CODE'
{
if (! gimp->no_interface &&
(proc = procedural_db_lookup (gimp, brush_callback)))
{
brush_select_new (gimp, context, popup_title,
initial_brush, brush_callback,
opacity / 100.0,
paint_mode,
spacing);
}
else
if (gimp->no_interface ||
! procedural_db_lookup (gimp, brush_callback) ||
! gimp_pdb_dialog_new (gimp, context, gimp->brush_factory->container,
popup_title, brush_callback, initial_brush,
"opacity", opacity / 100.0,
"paint-mode", paint_mode,
"spacing", spacing,
NULL))
success = FALSE;
}
CODE
@ -86,16 +83,12 @@ sub brushes_close_popup {
);
%invoke = (
vars => [ 'ProcRecord *proc', 'BrushSelect *brush_select' ],
code => <<'CODE'
{
if (! gimp->no_interface &&
(proc = procedural_db_lookup (gimp, brush_callback)) &&
(brush_select = brush_select_get_by_callback (brush_callback)))
{
brush_select_free (brush_select);
}
else
if (gimp->no_interface ||
! procedural_db_lookup (gimp, brush_callback) ||
! gimp_pdb_dialog_close (gimp, gimp->brush_factory->container,
brush_callback))
success = FALSE;
}
CODE
@ -118,46 +111,23 @@ sub brushes_set_popup {
);
%invoke = (
headers => [ qw("widgets/gimpbrushfactoryview.h") ],
vars => [ 'ProcRecord *proc', 'BrushSelect *brush_select' ],
code => <<'CODE'
{
if (! gimp->no_interface &&
(proc = procedural_db_lookup (gimp, brush_callback)) &&
(brush_select = brush_select_get_by_callback (brush_callback)))
{
GimpBrush *active = (GimpBrush *)
gimp_container_get_child_by_name (gimp->brush_factory->container,
brush_name);
if (active)
{
GtkAdjustment *spacing_adj;
spacing_adj = GIMP_BRUSH_FACTORY_VIEW (brush_select->view)->spacing_adjustment;
gimp_context_set_brush (brush_select->context, active);
gimp_context_set_opacity (brush_select->context, opacity / 100.0);
gimp_context_set_paint_mode (brush_select->context, paint_mode);
if (spacing >= 0)
gtk_adjustment_set_value (spacing_adj, spacing);
gtk_window_present (GTK_WINDOW (brush_select->shell));
}
else
success = FALSE;
}
else
if (gimp->no_interface ||
! procedural_db_lookup (gimp, brush_callback) ||
! gimp_pdb_dialog_set (gimp, gimp->brush_factory->container,
brush_callback, brush_name,
"opacity", opacity / 100.0,
"paint-mode", paint_mode,
"spacing", spacing,
NULL))
success = FALSE;
}
CODE
);
}
@headers = qw("core/gimp.h" "core/gimpcontext.h"
"core/gimpcontainer.h" "core/gimpdatafactory.h"
"gui/gui-types.h" "gui/brush-select.h");
@headers = qw("core/gimp.h" "core/gimpdatafactory.h");
@procs = qw(brushes_popup brushes_close_popup brushes_set_popup);
%exports = (app => [@procs], lib => [@procs]);

View File

@ -42,16 +42,13 @@ sub fonts_popup {
);
%invoke = (
vars => [ 'ProcRecord *proc' ],
code => <<'CODE'
{
if (! gimp->no_interface &&
(proc = procedural_db_lookup (gimp, font_callback)))
{
font_select_new (gimp, context, popup_title,
initial_font, font_callback);
}
else
if (gimp->no_interface ||
! procedural_db_lookup (gimp, font_callback) ||
! gimp_pdb_dialog_new (gimp, context, gimp->fonts,
popup_title, font_callback, initial_font,
NULL))
success = FALSE;
}
CODE
@ -71,16 +68,11 @@ sub fonts_close_popup {
);
%invoke = (
vars => [ 'ProcRecord *proc', 'FontSelect *font_select' ],
code => <<'CODE'
{
if (! gimp->no_interface &&
(proc = procedural_db_lookup (gimp, font_callback)) &&
(font_select = font_select_get_by_callback (font_callback)))
{
font_select_free (font_select);
}
else
if (gimp->no_interface ||
! procedural_db_lookup (gimp, font_callback) ||
! gimp_pdb_dialog_close (gimp, gimp->fonts, font_callback))
success = FALSE;
}
CODE
@ -102,35 +94,19 @@ sub fonts_set_popup {
);
%invoke = (
vars => [ 'ProcRecord *proc', 'FontSelect *font_select' ],
code => <<'CODE'
{
if (! gimp->no_interface &&
(proc = procedural_db_lookup (gimp, font_callback)) &&
(font_select = font_select_get_by_callback (font_callback)))
{
GimpFont *active = (GimpFont *)
gimp_container_get_child_by_name (gimp->fonts, font_name);
if (active)
{
gimp_context_set_font (font_select->context, active);
gtk_window_present (GTK_WINDOW (font_select->shell));
}
else
success = FALSE;
}
else
if (gimp->no_interface ||
! procedural_db_lookup (gimp, font_callback) ||
! gimp_pdb_dialog_set (gimp, gimp->fonts, font_callback, font_name,
NULL))
success = FALSE;
}
CODE
);
}
@headers = qw("core/gimp.h" "core/gimpcontext.h"
"core/gimpcontainer.h"
"gui/gui-types.h" "gui/font-select.h");
@headers = qw("core/gimp.h");
@procs = qw(fonts_popup fonts_close_popup fonts_set_popup);
%exports = (app => [@procs], lib => [@procs]);

View File

@ -51,17 +51,14 @@ sub gradients_popup {
);
%invoke = (
vars => [ 'ProcRecord *proc' ],
code => <<'CODE'
{
if (! gimp->no_interface &&
(proc = procedural_db_lookup (gimp, gradient_callback)))
{
gradient_select_new (gimp, context, popup_title,
initial_gradient, gradient_callback,
sample_size);
}
else
if (gimp->no_interface ||
! procedural_db_lookup (gimp, gradient_callback) ||
! gimp_pdb_dialog_new (gimp, context, gimp->gradient_factory->container,
popup_title, gradient_callback, initial_gradient,
"sample-size", sample_size,
NULL))
success = FALSE;
}
CODE
@ -81,16 +78,12 @@ sub gradients_close_popup {
);
%invoke = (
vars => [ 'ProcRecord *prec', 'GradientSelect *gradient_select' ],
code => <<'CODE'
{
if (! gimp->no_interface &&
(prec = procedural_db_lookup (gimp, gradient_callback)) &&
(gradient_select = gradient_select_get_by_callback (gradient_callback)))
{
gradient_select_free (gradient_select);
}
else
if (gimp->no_interface ||
! procedural_db_lookup (gimp, gradient_callback) ||
! gimp_pdb_dialog_close (gimp, gimp->gradient_factory->container,
gradient_callback))
success = FALSE;
}
CODE
@ -112,37 +105,20 @@ sub gradients_set_popup {
);
%invoke = (
vars => [ 'ProcRecord *prec', 'GradientSelect *gradient_select' ],
code => <<'CODE'
{
if (! gimp->no_interface &&
(prec = procedural_db_lookup (gimp, gradient_callback)) &&
(gradient_select = gradient_select_get_by_callback (gradient_callback)))
{
GimpGradient *active = (GimpGradient *)
gimp_container_get_child_by_name (gimp->gradient_factory->container,
gradient_name);
if (active)
{
gimp_context_set_gradient (gradient_select->context, active);
gtk_window_present (GTK_WINDOW (gradient_select->shell));
}
else
success = FALSE;
}
else
if (gimp->no_interface ||
! procedural_db_lookup (gimp, gradient_callback) ||
! gimp_pdb_dialog_set (gimp, gimp->gradient_factory->container,
gradient_callback, gradient_name,
NULL))
success = FALSE;
}
CODE
);
}
@headers = qw("core/gimp.h" "core/gimpcontext.h"
"core/gimpcontainer.h" "core/gimpdatafactory.h"
"core/gimpgradient.h"
"gui/gui-types.h" "gui/gradient-select.h");
@headers = qw("core/gimp.h" "core/gimpdatafactory.h" "core/gimpgradient.h");
@procs = qw(gradients_popup gradients_close_popup gradients_set_popup);
%exports = (app => [@procs], lib => [@procs]);

View File

@ -42,16 +42,13 @@ sub palettes_popup {
);
%invoke = (
vars => [ 'ProcRecord *proc' ],
code => <<'CODE'
{
if (! gimp->no_interface &&
(proc = procedural_db_lookup (gimp, palette_callback)))
{
palette_select_new (gimp, context, popup_title,
initial_palette, palette_callback);
}
else
if (gimp->no_interface ||
! procedural_db_lookup (gimp, palette_callback) ||
! gimp_pdb_dialog_new (gimp, context, gimp->palette_factory->container,
popup_title, palette_callback, initial_palette,
NULL))
success = FALSE;
}
CODE
@ -71,16 +68,12 @@ sub palettes_close_popup {
);
%invoke = (
vars => [ 'ProcRecord *proc', 'PaletteSelect *palette_select' ],
code => <<'CODE'
{
if (! gimp->no_interface &&
(proc = procedural_db_lookup (gimp, palette_callback)) &&
(palette_select = palette_select_get_by_callback (palette_callback)))
{
palette_select_free (palette_select);
}
else
if (gimp->no_interface ||
! procedural_db_lookup (gimp, palette_callback) ||
! gimp_pdb_dialog_close (gimp, gimp->palette_factory->container,
palette_callback))
success = FALSE;
}
CODE
@ -102,36 +95,20 @@ sub palettes_set_popup {
);
%invoke = (
vars => [ 'ProcRecord *proc', 'PaletteSelect *palette_select' ],
code => <<'CODE'
{
if (! gimp->no_interface &&
(proc = procedural_db_lookup (gimp, palette_callback)) &&
(palette_select = palette_select_get_by_callback (palette_callback)))
{
GimpPalette *active = (GimpPalette *)
gimp_container_get_child_by_name (gimp->palette_factory->container,
palette_name);
if (active)
{
gimp_context_set_palette (palette_select->context, active);
gtk_window_present (GTK_WINDOW (palette_select->shell));
}
else
success = FALSE;
}
else
if (gimp->no_interface ||
! procedural_db_lookup (gimp, palette_callback) ||
! gimp_pdb_dialog_set (gimp, gimp->palette_factory->container,
palette_callback, palette_name,
NULL))
success = FALSE;
}
CODE
);
}
@headers = qw("core/gimp.h" "core/gimpcontext.h"
"core/gimpcontainer.h" "core/gimpdatafactory.h"
"gui/gui-types.h" "gui/palette-select.h");
@headers = qw("core/gimp.h" "core/gimpdatafactory.h");
@procs = qw(palettes_popup palettes_close_popup palettes_set_popup);
%exports = (app => [@procs], lib => [@procs]);

View File

@ -41,16 +41,13 @@ sub patterns_popup {
);
%invoke = (
vars => [ 'ProcRecord *proc' ],
code => <<'CODE'
{
if (! gimp->no_interface &&
(proc = procedural_db_lookup (gimp, pattern_callback)))
{
pattern_select_new (gimp, context, popup_title,
initial_pattern, pattern_callback);
}
else
if (gimp->no_interface ||
! procedural_db_lookup (gimp, pattern_callback) ||
! gimp_pdb_dialog_new (gimp, context, gimp->pattern_factory->container,
popup_title, pattern_callback, initial_pattern,
NULL))
success = FALSE;
}
CODE
@ -70,16 +67,12 @@ sub patterns_close_popup {
);
%invoke = (
vars => [ 'ProcRecord *proc', 'PatternSelect *pattern_select' ],
code => <<'CODE'
{
if (! gimp->no_interface &&
(proc = procedural_db_lookup (gimp, pattern_callback)) &&
(pattern_select = pattern_select_get_by_callback (pattern_callback)))
{
pattern_select_free (pattern_select);
}
else
if (gimp->no_interface ||
! procedural_db_lookup (gimp, pattern_callback) ||
! gimp_pdb_dialog_close (gimp, gimp->pattern_factory->container,
pattern_callback))
success = FALSE;
}
CODE
@ -101,36 +94,20 @@ sub patterns_set_popup {
);
%invoke = (
vars => [ 'ProcRecord *proc', 'PatternSelect *pattern_select' ],
code => <<'CODE'
{
if (! gimp->no_interface &&
(proc = procedural_db_lookup (gimp, pattern_callback)) &&
(pattern_select = pattern_select_get_by_callback (pattern_callback)))
{
GimpPattern *active = (GimpPattern *)
gimp_container_get_child_by_name (gimp->pattern_factory->container,
pattern_name);
if (active)
{
gimp_context_set_pattern (pattern_select->context, active);
gtk_window_present (GTK_WINDOW (pattern_select->shell));
}
else
success = FALSE;
}
else
if (gimp->no_interface ||
! procedural_db_lookup (gimp, pattern_callback) ||
! gimp_pdb_dialog_set (gimp, gimp->pattern_factory->container,
pattern_callback, pattern_name,
NULL))
success = FALSE;
}
CODE
);
}
@headers = qw("core/gimp.h" "core/gimpcontext.h"
"core/gimpcontainer.h" "core/gimpdatafactory.h"
"gui/gui-types.h" "gui/pattern-select.h");
@headers = qw("core/gimp.h" "core/gimpdatafactory.h");
@procs = qw(patterns_popup patterns_close_popup patterns_set_popup);
%exports = (app => [@procs], lib => [@procs]);