
2003-11-14 Michael Natterer <mitch@gimp.org> * libgimpwidgets/gimpquerybox.c * app/widgets/gimpwidgets-utils.c: configure the labels in the message dialog and the query boxes to do automatic word wrapping to be HIG compliant. * app/app_procs.c * app/batch.c * app/config/gimpconfig-deserialize.c * app/config/gimpconfig-path.c * app/config/gimpconfig-utils.c * app/config/gimpconfigwriter.c * app/config/gimpscanner.c * app/core/gimpbrush.c * app/core/gimpbrushgenerated.c * app/core/gimpbrushpipe.c * app/core/gimpdatafactory.c * app/core/gimpgradient.c * app/core/gimpimage-merge.c * app/core/gimpimage.c * app/core/gimpimagefile.c * app/core/gimplayer-floating-sel.c * app/core/gimppalette.c * app/core/gimppattern.c * app/core/gimpselection.c * app/display/gimpdisplayshell.c * app/file/file-utils.c * app/gui/brush-select.c * app/gui/dialogs-commands.c * app/gui/drawable-commands.c * app/gui/edit-commands.c * app/gui/file-commands.c * app/gui/file-new-dialog.c * app/gui/font-select.c * app/gui/gradient-select.c * app/gui/gui.c * app/gui/image-commands.c * app/gui/layers-commands.c * app/gui/palette-select.c * app/gui/palettes-commands.c * app/gui/pattern-select.c * app/gui/preferences-dialog.c * app/gui/select-commands.c * app/gui/stroke-dialog.c * app/gui/tool-options-menu.c * app/gui/vectors-commands.c * app/gui/view-commands.c * app/plug-in/plug-in-message.c * app/plug-in/plug-in.c * app/plug-in/plug-ins.c * app/text/gimptextlayer-xcf.c * app/text/gimptextlayer.c * app/tools/gimpcurvestool.c * app/tools/gimphuesaturationtool.c * app/tools/gimplevelstool.c * app/tools/gimptransformtool.c * app/vectors/gimpvectors-export.c * app/widgets/gimpdatafactoryview.c * app/widgets/gimphelp.c * app/widgets/gimptemplateview.c * app/widgets/gimptooloptionseditor.c * app/xcf/xcf.c * tools/pdbgen/pdb/image.pdb: removed explicit newlines from messages. Reduced number of translatable strings by making many file error messages the same. Quote single words and filenames with 'foo', not "foo". Replaced some more "drawable" by "layer". General message cleanup and consistency check. * app/pdb/image_cmds.c: regenerated.
277 lines
7.3 KiB
C
277 lines
7.3 KiB
C
/* 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/gimpcontainerview.h"
|
|
#include "widgets/gimpdatafactoryview.h"
|
|
#include "widgets/gimphelp-ids.h"
|
|
|
|
#include "dialogs-constructors.h"
|
|
#include "menus.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,
|
|
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 (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 (gimp_get_current_context (gimp));
|
|
|
|
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>");
|
|
|
|
gimp_container_view_set_size_request (GIMP_CONTAINER_VIEW (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), 6);
|
|
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;
|
|
PaletteSelect *psp;
|
|
|
|
for (list = palette_active_dialogs; list; list = g_slist_next (list))
|
|
{
|
|
psp = (PaletteSelect *) list->data;
|
|
|
|
if (psp->callback_name && ! strcmp (callback_name, psp->callback_name))
|
|
return psp;
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
void
|
|
palette_select_dialogs_check (void)
|
|
{
|
|
PaletteSelect *psp;
|
|
GSList *list;
|
|
|
|
list = palette_active_dialogs;
|
|
|
|
while (list)
|
|
{
|
|
psp = (PaletteSelect *) 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 && 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 nreturn_vals;
|
|
|
|
return_vals =
|
|
procedural_db_run_proc (psp->context->gimp,
|
|
psp->callback_name,
|
|
&nreturn_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, nreturn_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);
|
|
}
|