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.
691 lines
22 KiB
C
691 lines
22 KiB
C
/* 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 <gobject/gvaluecollector.h>
|
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
#include "gui-types.h"
|
|
|
|
#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"
|
|
|
|
#include "display/gimpdisplay.h"
|
|
#include "display/gimpdisplay-foreach.h"
|
|
#include "display/gimpdisplayshell.h"
|
|
#include "display/gimpprogress.h"
|
|
|
|
#include "actions/plug-in-actions.h"
|
|
|
|
#include "menus/menus.h"
|
|
#include "menus/plug-in-menus.h"
|
|
|
|
#include "dialogs.h"
|
|
#include "dialogs-constructors.h"
|
|
#include "themes.h"
|
|
|
|
|
|
/* local function prototypes */
|
|
|
|
static void gui_threads_enter (Gimp *gimp);
|
|
static void gui_threads_leave (Gimp *gimp);
|
|
static void gui_set_busy (Gimp *gimp);
|
|
static void gui_unset_busy (Gimp *gimp);
|
|
static void gui_message (Gimp *gimp,
|
|
const gchar *domain,
|
|
const gchar *message);
|
|
static GimpObject * gui_create_display (GimpImage *gimage,
|
|
GimpUnit unit,
|
|
gdouble scale);
|
|
static void gui_menus_init (Gimp *gimp,
|
|
GSList *plug_in_defs,
|
|
const gchar *plugins_domain);
|
|
static void gui_menus_create_entry (Gimp *gimp,
|
|
PlugInProcDef *proc_def);
|
|
static void gui_menus_delete_entry (Gimp *gimp,
|
|
PlugInProcDef *proc_def);
|
|
static GimpProgress * gui_start_progress (Gimp *gimp,
|
|
gint gdisp_ID,
|
|
const gchar *message,
|
|
GCallback cancel_cb,
|
|
gpointer cancel_data);
|
|
static GimpProgress * gui_restart_progress (Gimp *gimp,
|
|
GimpProgress *progress,
|
|
const gchar *message,
|
|
GCallback cancel_cb,
|
|
gpointer cancel_data);
|
|
static void gui_update_progress (Gimp *gimp,
|
|
GimpProgress *progress,
|
|
gdouble percentage);
|
|
static void gui_end_progress (Gimp *gimp,
|
|
GimpProgress *progress);
|
|
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 */
|
|
|
|
void
|
|
gui_vtable_init (Gimp *gimp)
|
|
{
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
|
|
|
gimp->gui_threads_enter_func = gui_threads_enter;
|
|
gimp->gui_threads_leave_func = gui_threads_leave;
|
|
gimp->gui_set_busy_func = gui_set_busy;
|
|
gimp->gui_unset_busy_func = gui_unset_busy;
|
|
gimp->gui_message_func = gui_message;
|
|
gimp->gui_create_display_func = gui_create_display;
|
|
gimp->gui_menus_init_func = gui_menus_init;
|
|
gimp->gui_menus_create_func = gui_menus_create_entry;
|
|
gimp->gui_menus_delete_func = gui_menus_delete_entry;
|
|
gimp->gui_progress_start_func = gui_start_progress;
|
|
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_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;
|
|
}
|
|
|
|
|
|
/* private functions */
|
|
|
|
static void
|
|
gui_threads_enter (Gimp *gimp)
|
|
{
|
|
GDK_THREADS_ENTER ();
|
|
}
|
|
|
|
static void
|
|
gui_threads_leave (Gimp *gimp)
|
|
{
|
|
GDK_THREADS_LEAVE ();
|
|
}
|
|
|
|
static void
|
|
gui_set_busy (Gimp *gimp)
|
|
{
|
|
gimp_displays_set_busy (gimp);
|
|
gimp_dialog_factories_set_busy ();
|
|
|
|
gdk_flush ();
|
|
}
|
|
|
|
static void
|
|
gui_unset_busy (Gimp *gimp)
|
|
{
|
|
gimp_displays_unset_busy (gimp);
|
|
gimp_dialog_factories_unset_busy ();
|
|
|
|
gdk_flush ();
|
|
}
|
|
|
|
static void
|
|
gui_message (Gimp *gimp,
|
|
const gchar *domain,
|
|
const gchar *message)
|
|
{
|
|
if (gimp->message_handler == GIMP_ERROR_CONSOLE)
|
|
{
|
|
GtkWidget *dockable;
|
|
|
|
dockable = gimp_dialog_factory_dialog_raise (global_dock_factory,
|
|
gdk_screen_get_default (),
|
|
"gimp-error-console", -1);
|
|
|
|
if (dockable)
|
|
{
|
|
GimpErrorConsole *console;
|
|
|
|
console = GIMP_ERROR_CONSOLE (GTK_BIN (dockable)->child);
|
|
|
|
gimp_error_console_add (console, GIMP_STOCK_WARNING, domain, message);
|
|
|
|
return;
|
|
}
|
|
|
|
gimp->message_handler = GIMP_MESSAGE_BOX;
|
|
}
|
|
|
|
gimp_message_box (GIMP_STOCK_WARNING, domain, message, NULL, NULL);
|
|
}
|
|
|
|
static GimpObject *
|
|
gui_create_display (GimpImage *gimage,
|
|
GimpUnit unit,
|
|
gdouble scale)
|
|
{
|
|
GimpDisplayShell *shell;
|
|
GimpDisplay *gdisp;
|
|
GList *image_managers;
|
|
|
|
image_managers = gimp_ui_managers_from_name ("<Image>");
|
|
|
|
gdisp = gimp_display_new (gimage, unit, scale,
|
|
global_menu_factory,
|
|
|
|
image_managers->data);
|
|
|
|
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
|
|
|
|
gimp_context_set_display (gimp_get_user_context (gimage->gimp), gdisp);
|
|
|
|
gimp_ui_manager_update (shell->menubar_manager, shell);
|
|
|
|
return GIMP_OBJECT (gdisp);
|
|
}
|
|
|
|
static void
|
|
gui_menus_init (Gimp *gimp,
|
|
GSList *plug_in_defs,
|
|
const gchar *std_plugins_domain)
|
|
{
|
|
plug_in_menus_init (gimp, plug_in_defs, std_plugins_domain);
|
|
}
|
|
|
|
static void
|
|
gui_menus_create_entry (Gimp *gimp,
|
|
PlugInProcDef *proc_def)
|
|
{
|
|
GList *list;
|
|
|
|
for (list = gimp_action_groups_from_name ("plug-in");
|
|
list;
|
|
list = g_list_next (list))
|
|
{
|
|
plug_in_actions_add_proc (list->data, proc_def);
|
|
}
|
|
|
|
for (list = gimp_ui_managers_from_name ("<Image>");
|
|
list;
|
|
list = g_list_next (list))
|
|
{
|
|
GList *path;
|
|
|
|
for (path = proc_def->menu_paths; path; path = g_list_next (path))
|
|
{
|
|
if (! strncmp (path->data, "<Toolbox>", 9))
|
|
{
|
|
plug_in_menus_add_proc (list->data, "/toolbox-menubar",
|
|
proc_def, path->data);
|
|
}
|
|
else if (! strncmp (path->data, "<Image>", 7))
|
|
{
|
|
plug_in_menus_add_proc (list->data, "/image-menubar",
|
|
proc_def, path->data);
|
|
plug_in_menus_add_proc (list->data, "/dummy-menubar/image-popup",
|
|
proc_def, path->data);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
static void
|
|
gui_menus_delete_entry (Gimp *gimp,
|
|
PlugInProcDef *proc_def)
|
|
{
|
|
GList *list;
|
|
|
|
for (list = gimp_ui_managers_from_name ("<Image>");
|
|
list;
|
|
list = g_list_next (list))
|
|
{
|
|
plug_in_menus_remove_proc (list->data, proc_def);
|
|
}
|
|
|
|
for (list = gimp_action_groups_from_name ("plug-in");
|
|
list;
|
|
list = g_list_next (list))
|
|
{
|
|
plug_in_actions_remove_proc (list->data, proc_def);
|
|
}
|
|
}
|
|
|
|
static GimpProgress *
|
|
gui_start_progress (Gimp *gimp,
|
|
gint gdisp_ID,
|
|
const gchar *message,
|
|
GCallback cancel_cb,
|
|
gpointer cancel_data)
|
|
{
|
|
GimpDisplay *gdisp = NULL;
|
|
|
|
if (gdisp_ID > 0)
|
|
gdisp = gimp_display_get_by_ID (gimp, gdisp_ID);
|
|
|
|
return gimp_progress_start (gdisp, message, TRUE, cancel_cb, cancel_data);
|
|
}
|
|
|
|
static GimpProgress *
|
|
gui_restart_progress (Gimp *gimp,
|
|
GimpProgress *progress,
|
|
const gchar *message,
|
|
GCallback cancel_cb,
|
|
gpointer cancel_data)
|
|
{
|
|
return gimp_progress_restart (progress, message, cancel_cb, cancel_data);
|
|
}
|
|
|
|
static void
|
|
gui_update_progress (Gimp *gimp,
|
|
GimpProgress *progress,
|
|
gdouble percentage)
|
|
{
|
|
gimp_progress_update (progress, percentage);
|
|
}
|
|
|
|
static void
|
|
gui_end_progress (Gimp *gimp,
|
|
GimpProgress *progress)
|
|
{
|
|
gimp_progress_end (progress);
|
|
}
|
|
|
|
static const gchar *
|
|
gui_get_program_class (Gimp *gimp)
|
|
{
|
|
return gdk_get_program_class ();
|
|
}
|
|
|
|
static gchar *
|
|
gui_get_display_name (Gimp *gimp,
|
|
gint gdisp_ID,
|
|
gint *monitor_number)
|
|
{
|
|
GimpDisplay *gdisp = NULL;
|
|
GdkScreen *screen;
|
|
gint monitor;
|
|
|
|
if (gdisp_ID > 0)
|
|
gdisp = gimp_display_get_by_ID (gimp, gdisp_ID);
|
|
|
|
if (gdisp)
|
|
{
|
|
screen = gtk_widget_get_screen (gdisp->shell);
|
|
monitor = gdk_screen_get_monitor_at_window (screen,
|
|
gdisp->shell->window);
|
|
}
|
|
else
|
|
{
|
|
gint x, y;
|
|
|
|
gdk_display_get_pointer (gdk_display_get_default (),
|
|
&screen, &x, &y, NULL);
|
|
monitor = gdk_screen_get_monitor_at_point (screen, x, y);
|
|
}
|
|
|
|
*monitor_number = monitor;
|
|
|
|
if (screen)
|
|
return gdk_screen_make_display_name (screen);
|
|
|
|
return NULL;
|
|
}
|
|
|
|
static const gchar *
|
|
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 (¶ms[0].value, G_TYPE_STRING);
|
|
g_value_set_string (¶ms[0].value, title);
|
|
|
|
params[1].name = "role";
|
|
g_value_init (¶ms[1].value, G_TYPE_STRING);
|
|
g_value_set_string (¶ms[1].value, dialog_role);
|
|
|
|
params[2].name = "help-func";
|
|
g_value_init (¶ms[2].value, G_TYPE_POINTER);
|
|
g_value_set_pointer (¶ms[2].value, gimp_standard_help_func);
|
|
|
|
params[3].name = "help-id";
|
|
g_value_init (¶ms[3].value, G_TYPE_STRING);
|
|
g_value_set_string (¶ms[3].value, help_id);
|
|
|
|
params[4].name = "context";
|
|
g_value_init (¶ms[4].value, GIMP_TYPE_CONTEXT);
|
|
g_value_set_object (¶ms[4].value, context);
|
|
|
|
params[5].name = "select-type";
|
|
g_value_init (¶ms[5].value, G_TYPE_POINTER);
|
|
g_value_set_pointer (¶ms[5].value, (gpointer) container->children_type);
|
|
|
|
params[6].name = "initial-object";
|
|
g_value_init (¶ms[6].value, GIMP_TYPE_OBJECT);
|
|
g_value_set_object (¶ms[6].value, object);
|
|
|
|
params[7].name = "callback-name";
|
|
g_value_init (¶ms[7].value, G_TYPE_STRING);
|
|
g_value_set_string (¶ms[7].value, callback_name);
|
|
|
|
params[8].name = "menu-factory";
|
|
g_value_init (¶ms[8].value, GIMP_TYPE_MENU_FACTORY);
|
|
g_value_set_object (¶ms[8].value, global_menu_factory);
|
|
|
|
if (edit_func)
|
|
{
|
|
params[9].name = "edit-func";
|
|
g_value_init (¶ms[9].value, G_TYPE_POINTER);
|
|
g_value_set_pointer (¶ms[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 (¶ms[n_params].value,
|
|
G_PARAM_SPEC_VALUE_TYPE (pspec));
|
|
G_VALUE_COLLECT (¶ms[n_params].value, args, 0, &error);
|
|
if (error)
|
|
{
|
|
g_warning ("%s: %s", G_STRFUNC, error);
|
|
g_free (error);
|
|
g_value_unset (¶ms[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 (¶ms[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);
|
|
}
|