gimp/app/widgets/gimpbrushfactoryview.c
Michael Natterer d81b47ce70 removed GimpFillType.
2001-06-29  Michael Natterer  <mitch@gimp.org>

	* app/appenums.h: removed GimpFillType.

	* app/gimprc.c: parse the session-info's new "aux-info" field.

	* app/global_edit.[ch]: removed the old "Paste Named" dialog and
	prefixed all functions with "gimp_".

	* app/core/core-types.h: added GimpFillType.

	* app/core/gimpbrush.[ch]: new signal "spacing_changed".

	* app/gui/Makefile.am
	* app/gui/tools-commands.[ch]: one more file cut out of commands.[ch].

	* app/gui/commands.[ch]: removed the tools stuff here.

	* app/gui/brush-select.[ch]
	* app/gui/dialogs-constructors.c: use the new GimpBrushFactoryView
	(see below).

	* app/gui/dialogs-commands.[ch]
	* app/gui/menus.[ch]:

	- Made it 64bit safe again by passing the dialog factory's
	  identifiers as GQuarks, not as guints created by GPOINTER_TO_UINT().
	- Added a "gchar *quark_string" field to GimpItemFactoryEntry
	  which gets transformed into a GQuark by menus_create_item().
	- Added SEPARATOR() and BRANCH() macros which make the *_entries[]
	  arrays more readable.
	- Added a menu item to show/hide GimpImageDock's image menu.
	- Removed file_last_opened_cmd_callback().

	* app/gui/edit-commands.c: the global_edit functions are "gimp_"
	prefixed now.

	* app/gui/file-commands.[ch]: added file_last_opened_cmd_callback()
	here.

	* app/widgets/Makefile.am
	* app/widgets/widgets-types.h
	* app/widgets/gimpbrushfactoryview.[ch]: new widget: a
	GimpDataFactory subclass with a "spacing" scale.

	* app/widgets/gimpcontainereditor.[ch]:

	- Connect to the GimpContainerView's "select_item",
	  "activate_item" and "context_item" signals here once instead of
	  in each subclass and dispatch them via new virtual functions.
	- Added a convenience function which makes DND to the buttons much
	  less painful for subclasses.

	* app/widgets/gimpbufferview.c
	* app/widgets/gimpdatafactoryview.[ch]: changed accordingly.

	* app/widgets/gimpdialogfactory.[ch]:

	- Added gimp_dialog_factory_dialog_raise() which can raise
	  toplevel dialogs _and_ dockables (and creates them if they are
	  not open yet).
	- Keep track of all created dialogs (not only toplevels).
	- Added an "aux_info" field to GimpSessionInfo which is a GList of
	  gchar* and is saved in sessionrc.
	- Remember if GimpImageDock's image menu is visible by using an
	  aux_info string.
	- The code did not become nicer with all those new constraints. I
	  have to add comments before I forget how it works.

	* app/widgets/gimpdockbook.c: set the state of the "Show Image Menu"
	menu item before popping up the item factory.

	* app/widgets/gimpimagedock.[ch]: added
	gimp_image_dock_set_show_image_meu().

	* plug-ins/gdyntext/gdyntext.c
	* plug-ins/perl/examples/fit-text
	* plug-ins/perl/examples/terral_text
	* plug-ins/perl/examples/tex-to-float: register all text rendering
	plug-ins under <Image>/Filters/Text

	* app/pdb/brush_select_cmds.c
	* app/pdb/drawable_cmds.c
	* app/pdb/edit_cmds.c
	* tools/pdbgen/pdb/brush_select.pdb
	* tools/pdbgen/pdb/edit.pdb
	* tools/pdbgen/enums.pl
	* po/POTFILES.in: changed according to all the stuff above.
2001-06-29 19:25:03 +00:00

271 lines
8.1 KiB
C

/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpbrushfactoryview.c
* Copyright (C) 2001 Michael Natterer
*
* 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 "libgimpmath/gimpmath.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "widgets-types.h"
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h"
#include "core/gimpbrush.h"
#include "core/gimpbrushgenerated.h"
#include "core/gimpdatafactory.h"
#include "core/gimpmarshal.h"
#include "gimpcontainerview.h"
#include "gimpbrushfactoryview.h"
#include "libgimp/gimpintl.h"
static void gimp_brush_factory_view_class_init (GimpBrushFactoryViewClass *klass);
static void gimp_brush_factory_view_init (GimpBrushFactoryView *view);
static void gimp_brush_factory_view_destroy (GtkObject *object);
static void gimp_brush_factory_view_select_item (GimpContainerEditor *editor,
GimpViewable *viewable);
static void gimp_brush_factory_view_spacing_changed (GimpBrush *brush,
GimpBrushFactoryView *view);
static void gimp_brush_factory_view_spacing_update (GtkAdjustment *adjustment,
GimpBrushFactoryView *view);
static GimpDataFactoryViewClass *parent_class = NULL;
GtkType
gimp_brush_factory_view_get_type (void)
{
static guint view_type = 0;
if (! view_type)
{
GtkTypeInfo view_info =
{
"GimpBrushFactoryView",
sizeof (GimpBrushFactoryView),
sizeof (GimpBrushFactoryViewClass),
(GtkClassInitFunc) gimp_brush_factory_view_class_init,
(GtkObjectInitFunc) gimp_brush_factory_view_init,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL
};
view_type = gtk_type_unique (GIMP_TYPE_DATA_FACTORY_VIEW, &view_info);
}
return view_type;
}
static void
gimp_brush_factory_view_class_init (GimpBrushFactoryViewClass *klass)
{
GtkObjectClass *object_class;
GimpContainerEditorClass *editor_class;
object_class = (GtkObjectClass *) klass;
editor_class = (GimpContainerEditorClass *) klass;
parent_class = gtk_type_class (GIMP_TYPE_DATA_FACTORY_VIEW);
object_class->destroy = gimp_brush_factory_view_destroy;
editor_class->select_item = gimp_brush_factory_view_select_item;
}
static void
gimp_brush_factory_view_init (GimpBrushFactoryView *view)
{
GtkWidget *table;
table = gtk_table_new (1, 2, FALSE);
gtk_table_set_col_spacing (GTK_TABLE (table), 0, 4);
gtk_box_pack_end (GTK_BOX (view), table, FALSE, FALSE, 0);
gtk_widget_show (table);
view->spacing_adjustment =
GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 1.0, 1000.0, 1.0, 1.0, 0.0));
view->spacing_scale = gtk_hscale_new (view->spacing_adjustment);
gtk_scale_set_value_pos (GTK_SCALE (view->spacing_scale), GTK_POS_TOP);
gtk_range_set_update_policy (GTK_RANGE (view->spacing_scale),
GTK_UPDATE_DELAYED);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
_("Spacing:"), 1.0, 1.0,
view->spacing_scale, 1, FALSE);
gtk_signal_connect (GTK_OBJECT (view->spacing_adjustment), "value_changed",
GTK_SIGNAL_FUNC (gimp_brush_factory_view_spacing_update),
view);
view->spacing_changed_handler_id = 0;
}
static void
gimp_brush_factory_view_destroy (GtkObject *object)
{
GimpBrushFactoryView *view;
view = GIMP_BRUSH_FACTORY_VIEW (object);
if (view->spacing_changed_handler_id)
{
gimp_container_remove_handler
(GIMP_CONTAINER_EDITOR (view)->view->container,
view->spacing_changed_handler_id);
view->spacing_changed_handler_id = 0;
}
if (GTK_OBJECT_CLASS (parent_class)->destroy)
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
GtkWidget *
gimp_brush_factory_view_new (GimpViewType view_type,
GimpDataFactory *factory,
GimpDataEditFunc edit_func,
GimpContext *context,
gboolean change_brush_spacing,
gint preview_size,
gint min_items_x,
gint min_items_y)
{
GimpBrushFactoryView *factory_view;
GimpContainerEditor *editor;
g_return_val_if_fail (factory != NULL, NULL);
g_return_val_if_fail (GIMP_IS_DATA_FACTORY (factory), NULL);
g_return_val_if_fail (preview_size > 0 && preview_size <= 64, NULL);
g_return_val_if_fail (min_items_x > 0 && min_items_x <= 64, NULL);
g_return_val_if_fail (min_items_y > 0 && min_items_y <= 64, NULL);
factory_view = gtk_type_new (GIMP_TYPE_BRUSH_FACTORY_VIEW);
factory_view->change_brush_spacing = change_brush_spacing;
if (! gimp_data_factory_view_construct (GIMP_DATA_FACTORY_VIEW (factory_view),
view_type,
factory,
edit_func,
context,
preview_size,
min_items_x,
min_items_y))
{
gtk_object_unref (GTK_OBJECT (factory_view));
return NULL;
}
editor = GIMP_CONTAINER_EDITOR (factory_view);
gimp_container_add_handler
(editor->view->container, "spacing_changed",
GTK_SIGNAL_FUNC (gimp_brush_factory_view_spacing_changed),
factory_view);
return GTK_WIDGET (factory_view);
}
static void
gimp_brush_factory_view_select_item (GimpContainerEditor *editor,
GimpViewable *viewable)
{
GimpBrushFactoryView *view;
GimpBrush *brush;
gboolean edit_sensitive = FALSE;
gboolean spacing_sensitive = FALSE;
if (GIMP_CONTAINER_EDITOR_CLASS (parent_class)->select_item)
GIMP_CONTAINER_EDITOR_CLASS (parent_class)->select_item (editor, viewable);
view = GIMP_BRUSH_FACTORY_VIEW (editor);
brush = GIMP_BRUSH (viewable);
if (brush &&
gimp_container_have (GIMP_CONTAINER_EDITOR (view)->view->container,
GIMP_OBJECT (brush)))
{
edit_sensitive = GIMP_IS_BRUSH_GENERATED (brush);
spacing_sensitive = TRUE;
gtk_signal_handler_block_by_func (GTK_OBJECT (view->spacing_adjustment),
gimp_brush_factory_view_spacing_update,
view);
gtk_adjustment_set_value (view->spacing_adjustment,
gimp_brush_get_spacing (brush));
gtk_signal_handler_unblock_by_func (GTK_OBJECT (view->spacing_adjustment),
gimp_brush_factory_view_spacing_update,
view);
}
gtk_widget_set_sensitive (GIMP_DATA_FACTORY_VIEW (view)->edit_button,
edit_sensitive);
gtk_widget_set_sensitive (view->spacing_scale, spacing_sensitive);
}
static void
gimp_brush_factory_view_spacing_changed (GimpBrush *brush,
GimpBrushFactoryView *view)
{
if (brush == GIMP_CONTAINER_EDITOR (view)->view->context->brush)
{
gtk_signal_handler_block_by_func (GTK_OBJECT (view->spacing_adjustment),
gimp_brush_factory_view_spacing_update,
view);
gtk_adjustment_set_value (view->spacing_adjustment,
gimp_brush_get_spacing (brush));
gtk_signal_handler_unblock_by_func (GTK_OBJECT (view->spacing_adjustment),
gimp_brush_factory_view_spacing_update,
view);
}
}
static void
gimp_brush_factory_view_spacing_update (GtkAdjustment *adjustment,
GimpBrushFactoryView *view)
{
GimpBrush *brush;
brush = GIMP_CONTAINER_EDITOR (view)->view->context->brush;
if (brush && view->change_brush_spacing)
{
gtk_signal_handler_block_by_func (GTK_OBJECT (brush),
gimp_brush_factory_view_spacing_changed,
view);
gimp_brush_set_spacing (brush, adjustment->value);
gtk_signal_handler_unblock_by_func (GTK_OBJECT (brush),
gimp_brush_factory_view_spacing_changed,
view);
}
}