Files
gimp/app/gui/font-select.c
Michael Natterer 6eb772946b libgimpwidgets/gimpquerybox.c configure the labels in the message dialog
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.
2003-11-14 15:33:40 +00:00

261 lines
7.2 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 "text/gimpfont.h"
#include "pdb/procedural_db.h"
#include "widgets/gimpcontainertreeview.h"
#include "widgets/gimphelp-ids.h"
#include "dialogs-constructors.h"
#include "menus.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,
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 (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 (gimp_get_current_context (gimp));
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,
FALSE);
gimp_container_view_set_size_request (GIMP_CONTAINER_VIEW (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), 4);
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;
FontSelect *font_select;
for (list = font_active_dialogs; list; list = g_slist_next (list))
{
font_select = (FontSelect *) 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)
{
FontSelect *font_select;
GSList *list;
list = font_active_dialogs;
while (list)
{
font_select = (FontSelect *) 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 && 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 nreturn_vals;
return_vals =
procedural_db_run_proc (font_select->context->gimp,
font_select->callback_name,
&nreturn_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, nreturn_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);
}