mirror of https://github.com/GNOME/gimp.git
renamed gimp_container_lookup() back to gimp_container_have(). Virtualized
2001-02-04 Michael Natterer <mitch@gimp.org> * app/gimpcontainer.[ch]: renamed gimp_container_lookup() back to gimp_container_have(). Virtualized the "add", "remove", "have" and "foreach" methods and removed the "children" list. * app/gimplist.[ch]: derived from GimpContainer now. * app/Makefile.am * app/gimpdatalist.[ch]: new object: an alphabetically sorted GimpList with unique names. * app/gimpbrushlist.[ch]: removed. It's job is done by the GimpDataList now. * app/brushes.[ch]: new files. Contain the "brushes_()" functions for the global brush list. * app/app_procs.c * app/apptypes.h * app/brush_select.[ch] * app/colormap_dialog.[ch] * app/context_manager.c * app/devices.c * app/gimpbrush.c * app/gimpcontext.c * app/gimpdnd.c * app/info_window.c * app/lc_dialog.c * app/module_db.c * app/nav_window.c * app/pdb/brush_select_cmds.c * app/pdb/brushes_cmds.c * app/tools/by_color_select.c * app/tools/paintbrush.c * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * po/POTFILES.in: changed accordingly.
This commit is contained in:
parent
4f89fddec0
commit
1994facc9e
39
ChangeLog
39
ChangeLog
|
@ -1,3 +1,42 @@
|
|||
2001-02-04 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/gimpcontainer.[ch]: renamed gimp_container_lookup() back
|
||||
to gimp_container_have(). Virtualized the "add", "remove",
|
||||
"have" and "foreach" methods and removed the "children" list.
|
||||
|
||||
* app/gimplist.[ch]: derived from GimpContainer now.
|
||||
|
||||
* app/Makefile.am
|
||||
* app/gimpdatalist.[ch]: new object: an alphabetically sorted
|
||||
GimpList with unique names.
|
||||
|
||||
* app/gimpbrushlist.[ch]: removed. It's job is done by the
|
||||
GimpDataList now.
|
||||
|
||||
* app/brushes.[ch]: new files. Contain the "brushes_()" functions
|
||||
for the global brush list.
|
||||
|
||||
* app/app_procs.c
|
||||
* app/apptypes.h
|
||||
* app/brush_select.[ch]
|
||||
* app/colormap_dialog.[ch]
|
||||
* app/context_manager.c
|
||||
* app/devices.c
|
||||
* app/gimpbrush.c
|
||||
* app/gimpcontext.c
|
||||
* app/gimpdnd.c
|
||||
* app/info_window.c
|
||||
* app/lc_dialog.c
|
||||
* app/module_db.c
|
||||
* app/nav_window.c
|
||||
* app/pdb/brush_select_cmds.c
|
||||
* app/pdb/brushes_cmds.c
|
||||
* app/tools/by_color_select.c
|
||||
* app/tools/paintbrush.c
|
||||
* tools/pdbgen/pdb/brush_select.pdb
|
||||
* tools/pdbgen/pdb/brushes.pdb
|
||||
* po/POTFILES.in: changed accordingly.
|
||||
|
||||
2001-02-04 Nick Lamb <njl195@zepler.org.uk>
|
||||
|
||||
* app/gimpdrawablepreview.c: add <stdlib.h> or <string.h> where needed
|
||||
|
|
|
@ -34,6 +34,8 @@ gimp_SOURCES = \
|
|||
brush_scale.h \
|
||||
brush_select.c \
|
||||
brush_select.h \
|
||||
brushes.c \
|
||||
brushes.h \
|
||||
channels_dialog.c \
|
||||
channels_dialog.h \
|
||||
channel_ops.c \
|
||||
|
@ -104,8 +106,6 @@ gimp_SOURCES = \
|
|||
gimpbrush.h \
|
||||
gimpbrushgenerated.c \
|
||||
gimpbrushgenerated.h \
|
||||
gimpbrushlist.c \
|
||||
gimpbrushlist.h \
|
||||
gimpbrushpipe.c \
|
||||
gimpbrushpipe.h \
|
||||
gimpchannel.c \
|
||||
|
@ -116,6 +116,8 @@ gimp_SOURCES = \
|
|||
gimpcontext.h \
|
||||
gimpcontextpreview.c \
|
||||
gimpcontextpreview.h \
|
||||
gimpdatalist.c \
|
||||
gimpdatalist.h \
|
||||
gimpdnd.c \
|
||||
gimpdnd.h \
|
||||
gimpdrawable.c \
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#include "app_procs.h"
|
||||
#include "batch.h"
|
||||
#include "brush_select.h"
|
||||
#include "brushes.h"
|
||||
#include "color_transfer.h"
|
||||
#include "colormaps.h"
|
||||
#include "context_manager.h"
|
||||
|
@ -55,7 +56,6 @@
|
|||
#include "fileops.h"
|
||||
#include "gdisplay.h"
|
||||
#include "gdisplay_ops.h"
|
||||
#include "gimpbrushlist.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimpimage.h"
|
||||
#include "gimprc.h"
|
||||
|
|
|
@ -35,15 +35,11 @@
|
|||
typedef struct _GimpObject GimpObject;
|
||||
|
||||
typedef struct _GimpContainer GimpContainer;
|
||||
typedef struct _GimpList GimpList;
|
||||
typedef struct _GimpDataList GimpDataList;
|
||||
|
||||
typedef struct _GimpContext GimpContext;
|
||||
|
||||
/* TODO: replace these with GimpContainer */
|
||||
typedef struct _GimpSet GimpSet;
|
||||
typedef guint GimpSetHandlerId;
|
||||
typedef struct _GimpList GimpList;
|
||||
typedef struct _GimpBrushList GimpBrushList;
|
||||
|
||||
|
||||
/* drawable objects */
|
||||
|
||||
|
|
|
@ -30,9 +30,9 @@
|
|||
#include "brush_scale.h"
|
||||
#include "brush_edit.h"
|
||||
#include "brush_select.h"
|
||||
#include "brushes.h"
|
||||
#include "dialog_handler.h"
|
||||
#include "gimpbrushgenerated.h"
|
||||
#include "gimpbrushlist.h"
|
||||
#include "gimpbrushpipe.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimpdnd.h"
|
||||
|
@ -99,14 +99,10 @@ static void brush_select_select (BrushSelect *bsp,
|
|||
|
||||
static void brush_select_brush_dirty_callback (GimpBrush *brush,
|
||||
BrushSelect *bsp);
|
||||
static void connect_signals_to_brush (GimpBrush *brush,
|
||||
BrushSelect *bsp);
|
||||
static void disconnect_signals_from_brush (GimpBrush *brush,
|
||||
BrushSelect *bsp);
|
||||
static void brush_added_callback (GimpBrushList *list,
|
||||
static void brush_added_callback (GimpContainer *container,
|
||||
GimpBrush *brush,
|
||||
BrushSelect *bsp);
|
||||
static void brush_removed_callback (GimpBrushList *list,
|
||||
static void brush_removed_callback (GimpContainer *container,
|
||||
GimpBrush *brush,
|
||||
BrushSelect *bsp);
|
||||
|
||||
|
@ -314,7 +310,7 @@ brush_select_new (gchar *title,
|
|||
|
||||
if (title && init_name && strlen (init_name))
|
||||
{
|
||||
active = gimp_brush_list_get_brush (brush_list, init_name);
|
||||
active = (GimpBrush *) gimp_list_get_child_by_name (brush_list, init_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -528,9 +524,18 @@ brush_select_new (gchar *title,
|
|||
gtk_widget_show (vbox);
|
||||
|
||||
/* add callbacks to keep the display area current */
|
||||
gimp_list_foreach (GIMP_LIST (brush_list),
|
||||
(GFunc) connect_signals_to_brush,
|
||||
bsp);
|
||||
bsp->name_changed_handler_id =
|
||||
gimp_container_add_handler
|
||||
(GIMP_CONTAINER (brush_list), "name_changed",
|
||||
GTK_SIGNAL_FUNC (brush_select_brush_dirty_callback),
|
||||
bsp);
|
||||
|
||||
bsp->dirty_handler_id =
|
||||
gimp_container_add_handler
|
||||
(GIMP_CONTAINER (brush_list), "dirty",
|
||||
GTK_SIGNAL_FUNC (brush_select_brush_dirty_callback),
|
||||
bsp);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (brush_list), "add",
|
||||
GTK_SIGNAL_FUNC (brush_added_callback),
|
||||
bsp);
|
||||
|
@ -594,9 +599,11 @@ brush_select_free (BrushSelect *bsp)
|
|||
gtk_object_unref (GTK_OBJECT (bsp->context));
|
||||
}
|
||||
|
||||
gimp_list_foreach (GIMP_LIST (brush_list),
|
||||
(GFunc) disconnect_signals_from_brush,
|
||||
bsp);
|
||||
gimp_container_remove_handler (GIMP_CONTAINER (brush_list),
|
||||
bsp->name_changed_handler_id);
|
||||
gimp_container_remove_handler (GIMP_CONTAINER (brush_list),
|
||||
bsp->dirty_handler_id);
|
||||
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (brush_list), bsp);
|
||||
|
||||
g_free (bsp);
|
||||
|
@ -828,7 +835,7 @@ brush_select_select (BrushSelect *bsp,
|
|||
gint row, col;
|
||||
gint scroll_offset = 0;
|
||||
|
||||
index = gimp_brush_list_get_brush_index (brush_list, brush);
|
||||
index = gimp_list_get_child_index (brush_list, GIMP_OBJECT (brush));
|
||||
|
||||
if (index < 0)
|
||||
return;
|
||||
|
@ -878,7 +885,7 @@ brush_select_brush_dirty_callback (GimpBrush *brush,
|
|||
if (!bsp || bsp->freeze)
|
||||
return;
|
||||
|
||||
index = gimp_brush_list_get_brush_index (brush_list, brush);
|
||||
index = gimp_list_get_child_index (brush_list, GIMP_OBJECT (brush));
|
||||
redraw = (brush != gimp_context_get_brush (bsp->context));
|
||||
|
||||
clear_brush (bsp, brush,
|
||||
|
@ -892,32 +899,10 @@ brush_select_brush_dirty_callback (GimpBrush *brush,
|
|||
}
|
||||
|
||||
static void
|
||||
connect_signals_to_brush (GimpBrush *brush,
|
||||
BrushSelect *bsp)
|
||||
{
|
||||
gtk_signal_connect (GTK_OBJECT (brush), "dirty",
|
||||
GTK_SIGNAL_FUNC (brush_select_brush_dirty_callback),
|
||||
bsp);
|
||||
gtk_signal_connect (GTK_OBJECT (brush), "name_changed",
|
||||
GTK_SIGNAL_FUNC (brush_select_brush_dirty_callback),
|
||||
bsp);
|
||||
}
|
||||
|
||||
static void
|
||||
disconnect_signals_from_brush (GimpBrush *brush,
|
||||
BrushSelect *bsp)
|
||||
{
|
||||
if (!GTK_OBJECT_DESTROYED (brush))
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (brush), bsp);
|
||||
}
|
||||
|
||||
static void
|
||||
brush_added_callback (GimpBrushList *list,
|
||||
brush_added_callback (GimpContainer *container,
|
||||
GimpBrush *brush,
|
||||
BrushSelect *bsp)
|
||||
{
|
||||
connect_signals_to_brush (brush, bsp);
|
||||
|
||||
if (bsp->freeze)
|
||||
return;
|
||||
|
||||
|
@ -925,12 +910,10 @@ brush_added_callback (GimpBrushList *list,
|
|||
}
|
||||
|
||||
static void
|
||||
brush_removed_callback (GimpBrushList *list,
|
||||
brush_removed_callback (GimpContainer *container,
|
||||
GimpBrush *brush,
|
||||
BrushSelect *bsp)
|
||||
{
|
||||
disconnect_signals_from_brush (brush, bsp);
|
||||
|
||||
if (bsp->freeze)
|
||||
return;
|
||||
|
||||
|
@ -1368,7 +1351,8 @@ do_display_brush (GimpBrush *brush,
|
|||
static void
|
||||
display_brushes (BrushSelect *bsp)
|
||||
{
|
||||
if (brush_list == NULL || gimp_brush_list_length (brush_list) == 0)
|
||||
if (brush_list == NULL ||
|
||||
gimp_container_num_children (GIMP_CONTAINER (brush_list)) == 0)
|
||||
{
|
||||
gtk_widget_set_sensitive (bsp->options_box, FALSE);
|
||||
return;
|
||||
|
@ -1382,7 +1366,9 @@ display_brushes (BrushSelect *bsp)
|
|||
display_setup (bsp);
|
||||
|
||||
brush_counter = 0;
|
||||
gimp_list_foreach (GIMP_LIST (brush_list), (GFunc) do_display_brush, bsp);
|
||||
gimp_container_foreach (GIMP_CONTAINER (brush_list),
|
||||
(GFunc) do_display_brush,
|
||||
bsp);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1506,7 +1492,7 @@ preview_calc_scrollbar (BrushSelect *bsp)
|
|||
gint max;
|
||||
|
||||
bsp->scroll_offset = 0;
|
||||
num_rows = ((gimp_brush_list_length (brush_list) +
|
||||
num_rows = ((gimp_container_num_children (GIMP_CONTAINER (brush_list)) +
|
||||
(bsp->NUM_BRUSH_COLUMNS) - 1)
|
||||
/ (bsp->NUM_BRUSH_COLUMNS));
|
||||
max = num_rows * bsp->cell_width;
|
||||
|
@ -1547,7 +1533,8 @@ brush_select_resize (GtkWidget *widget,
|
|||
bsp->NUM_BRUSH_COLUMNS =
|
||||
(gint) (wid / cell_size);
|
||||
bsp->NUM_BRUSH_ROWS =
|
||||
(gint) ((gimp_brush_list_length (brush_list) + bsp->NUM_BRUSH_COLUMNS - 1) /
|
||||
(gint) ((gimp_container_num_children (GIMP_CONTAINER (brush_list)) +
|
||||
bsp->NUM_BRUSH_COLUMNS - 1) /
|
||||
bsp->NUM_BRUSH_COLUMNS);
|
||||
|
||||
bsp->cell_width = cell_size;
|
||||
|
@ -1580,7 +1567,7 @@ brush_select_events (GtkWidget *widget,
|
|||
index = row * bsp->NUM_BRUSH_COLUMNS + col;
|
||||
|
||||
/* Get the brush and check if it is editable */
|
||||
brush = gimp_brush_list_get_brush_by_index (brush_list, index);
|
||||
brush = GIMP_BRUSH (gimp_list_get_child_by_index (brush_list, index));
|
||||
if (GIMP_IS_BRUSH_GENERATED (brush))
|
||||
brush_select_edit_brush_callback (NULL, bsp);
|
||||
break;
|
||||
|
@ -1592,7 +1579,7 @@ brush_select_events (GtkWidget *widget,
|
|||
row = (bevent->y + bsp->scroll_offset) / bsp->cell_height;
|
||||
index = row * bsp->NUM_BRUSH_COLUMNS + col;
|
||||
|
||||
brush = gimp_brush_list_get_brush_by_index (brush_list, index);
|
||||
brush = (GimpBrush *) gimp_list_get_child_by_index (brush_list, index);
|
||||
|
||||
if (brush)
|
||||
bsp->dnd_brush = brush;
|
||||
|
@ -1719,7 +1706,7 @@ brush_select_scroll_update (GtkAdjustment *adjustment,
|
|||
|
||||
if (active)
|
||||
{
|
||||
index = gimp_brush_list_get_brush_index (brush_list, active);
|
||||
index = gimp_list_get_child_index (brush_list, GIMP_OBJECT (active));
|
||||
if (index < 0)
|
||||
return;
|
||||
row = index / bsp->NUM_BRUSH_COLUMNS;
|
||||
|
@ -1823,7 +1810,8 @@ brush_select_new_brush_callback (GtkWidget *widget,
|
|||
brush = gimp_brush_generated_new (10, .5, 0.0, 1.0);
|
||||
if (brush)
|
||||
{
|
||||
gimp_brush_list_add (brush_list, brush);
|
||||
gimp_container_add (GIMP_CONTAINER (brush_list),
|
||||
GIMP_OBJECT (brush));
|
||||
|
||||
gimp_context_set_brush (bsp->context, brush);
|
||||
|
||||
|
@ -1878,19 +1866,19 @@ brush_select_delete_brush_callback (GtkWidget *widget,
|
|||
|
||||
if (GIMP_IS_BRUSH_GENERATED (brush))
|
||||
{
|
||||
gint index;
|
||||
|
||||
gimp_brush_generated_delete (GIMP_BRUSH_GENERATED (brush));
|
||||
|
||||
brush_select_freeze_all ();
|
||||
|
||||
index = gimp_brush_list_get_brush_index (brush_list, brush);
|
||||
gimp_brush_list_remove (brush_list, GIMP_BRUSH (brush));
|
||||
gimp_container_remove (GIMP_CONTAINER (brush_list),
|
||||
GIMP_OBJECT (brush));
|
||||
gimp_context_refresh_brushes ();
|
||||
|
||||
brush_select_thaw_all ();
|
||||
}
|
||||
else
|
||||
/* this should never happen */
|
||||
g_message (_("Sorry, this brush can't be deleted."));
|
||||
{
|
||||
/* this should never happen */
|
||||
g_message (_("Sorry, this brush can't be deleted."));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,6 +73,9 @@ struct _BrushSelect
|
|||
|
||||
gboolean redraw;
|
||||
gboolean freeze; /* so we don't waste so much time during refresh */
|
||||
|
||||
GQuark name_changed_handler_id;
|
||||
GQuark dirty_handler_id;
|
||||
};
|
||||
|
||||
/* list of active dialogs */
|
||||
|
|
|
@ -0,0 +1,218 @@
|
|||
/* 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 <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "apptypes.h"
|
||||
|
||||
#include "appenv.h"
|
||||
#include "brushes.h"
|
||||
#include "gimpbrushgenerated.h"
|
||||
#include "gimpbrushpipe.h"
|
||||
#include "brush_header.h"
|
||||
#include "brush_select.h"
|
||||
#include "datafiles.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimprc.h"
|
||||
#include "gimplist.h"
|
||||
#include "gimpbrush.h"
|
||||
#include "gimpdatalist.h"
|
||||
|
||||
#include "libgimp/gimpenv.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
/* global variables */
|
||||
GimpList *brush_list = NULL;
|
||||
|
||||
|
||||
/* local function prototypes */
|
||||
static void brushes_brush_load (const gchar *filename);
|
||||
|
||||
|
||||
/* function declarations */
|
||||
void
|
||||
brushes_init (gboolean no_data)
|
||||
{
|
||||
if (brush_list)
|
||||
brushes_free ();
|
||||
else
|
||||
brush_list = GIMP_LIST (gimp_data_list_new (GIMP_TYPE_BRUSH));
|
||||
|
||||
if (brush_path != NULL && !no_data)
|
||||
{
|
||||
brush_select_freeze_all ();
|
||||
|
||||
datafiles_read_directories (brush_path, brushes_brush_load, 0);
|
||||
datafiles_read_directories (brush_vbr_path, brushes_brush_load, 0);
|
||||
|
||||
brush_select_thaw_all ();
|
||||
}
|
||||
|
||||
gimp_context_refresh_brushes ();
|
||||
}
|
||||
|
||||
GimpBrush *
|
||||
brushes_get_standard_brush (void)
|
||||
{
|
||||
static GimpBrush *standard_brush = NULL;
|
||||
|
||||
if (! standard_brush)
|
||||
{
|
||||
standard_brush =
|
||||
GIMP_BRUSH (gimp_brush_generated_new (5.0, 0.5, 0.0, 1.0));
|
||||
|
||||
gimp_object_set_name (GIMP_OBJECT (standard_brush), "Standard");
|
||||
|
||||
/* set ref_count to 2 --> never swap the standard brush */
|
||||
gtk_object_ref (GTK_OBJECT (standard_brush));
|
||||
gtk_object_ref (GTK_OBJECT (standard_brush));
|
||||
gtk_object_sink (GTK_OBJECT (standard_brush));
|
||||
}
|
||||
|
||||
return standard_brush;
|
||||
}
|
||||
|
||||
static void
|
||||
brushes_brush_load (const gchar *filename)
|
||||
{
|
||||
GimpBrush *brush = NULL;
|
||||
|
||||
if (strcmp (&filename[strlen (filename) - 4], ".gbr") == 0 ||
|
||||
strcmp (&filename[strlen (filename) - 4], ".gpb") == 0)
|
||||
{
|
||||
brush = gimp_brush_load (filename);
|
||||
|
||||
if (! brush)
|
||||
g_message (_("Warning: Failed to load brush\n\"%s\""), filename);
|
||||
}
|
||||
else if (strcmp (&filename[strlen(filename) - 4], ".vbr") == 0)
|
||||
{
|
||||
brush = gimp_brush_generated_load (filename);
|
||||
|
||||
if (! brush)
|
||||
g_message (_("Warning: Failed to load brush\n\"%s\""), filename);
|
||||
}
|
||||
else if (strcmp (&filename[strlen (filename) - 4], ".gih") == 0)
|
||||
{
|
||||
brush = gimp_brush_pipe_load (filename);
|
||||
|
||||
if (! brush)
|
||||
g_message (_("Warning: Failed to load brush pipe\n\"%s\""), filename);
|
||||
}
|
||||
|
||||
if (brush != NULL)
|
||||
gimp_container_add (GIMP_CONTAINER (brush_list),
|
||||
GIMP_OBJECT (brush));
|
||||
}
|
||||
|
||||
void
|
||||
brushes_free (void)
|
||||
{
|
||||
GList *vbr_path;
|
||||
gchar *vbr_dir;
|
||||
|
||||
if (!brush_list)
|
||||
return;
|
||||
|
||||
vbr_path = gimp_path_parse (brush_vbr_path, 16, TRUE, NULL);
|
||||
vbr_dir = gimp_path_get_user_writable_dir (vbr_path);
|
||||
gimp_path_free (vbr_path);
|
||||
|
||||
brush_select_freeze_all ();
|
||||
|
||||
while (GIMP_LIST (brush_list)->list)
|
||||
{
|
||||
GimpBrush *brush = GIMP_BRUSH (GIMP_LIST (brush_list)->list->data);
|
||||
|
||||
if (GIMP_IS_BRUSH_GENERATED (brush) && vbr_dir)
|
||||
{
|
||||
gchar *filename = NULL;
|
||||
if (!brush->filename)
|
||||
{
|
||||
FILE *tmp_fp;
|
||||
gint unum = 0;
|
||||
|
||||
if (vbr_dir)
|
||||
{
|
||||
gchar *safe_name;
|
||||
gint i;
|
||||
|
||||
/* make sure we don't create a naughty filename */
|
||||
safe_name = g_strdup (GIMP_OBJECT (brush)->name);
|
||||
if (safe_name[0] == '.')
|
||||
safe_name[0] = '_';
|
||||
for (i = 0; safe_name[i]; i++)
|
||||
if (safe_name[i] == G_DIR_SEPARATOR || isspace(safe_name[i]))
|
||||
safe_name[i] = '_';
|
||||
|
||||
filename = g_strdup_printf ("%s%s.vbr",
|
||||
vbr_dir,
|
||||
safe_name);
|
||||
while ((tmp_fp = fopen (filename, "r")))
|
||||
{ /* make sure we don't overite an existing brush */
|
||||
fclose (tmp_fp);
|
||||
g_free (filename);
|
||||
filename = g_strdup_printf ("%s%s_%d.vbr",
|
||||
vbr_dir, safe_name, unum);
|
||||
unum++;
|
||||
}
|
||||
g_free (safe_name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
filename = g_strdup (brush->filename);
|
||||
if (strlen(filename) < 4 || strcmp (&filename[strlen (filename) - 4],
|
||||
".vbr"))
|
||||
{ /* we only want to save .vbr files, so set filename to null
|
||||
if this isn't a .vbr file */
|
||||
g_free (filename);
|
||||
filename = NULL;
|
||||
}
|
||||
}
|
||||
/* we are (finaly) ready to try to save the generated brush file */
|
||||
if (filename)
|
||||
{
|
||||
gimp_brush_generated_save (GIMP_BRUSH_GENERATED (brush),
|
||||
filename);
|
||||
g_free (filename);
|
||||
}
|
||||
}
|
||||
|
||||
gimp_container_remove (GIMP_CONTAINER (brush_list),
|
||||
GIMP_OBJECT (brush));
|
||||
}
|
||||
|
||||
brush_select_thaw_all ();
|
||||
|
||||
g_free (vbr_dir);
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
/* 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 __BRUSHES_H__
|
||||
#define __BRUSHES_H__
|
||||
|
||||
|
||||
extern GimpList *brush_list;
|
||||
|
||||
|
||||
void brushes_init (gboolean no_data);
|
||||
void brushes_free (void);
|
||||
GimpBrush * brushes_get_standard_brush (void);
|
||||
|
||||
|
||||
#endif /* __BRUSHES_H__ */
|
|
@ -200,26 +200,26 @@ gimp_colormap_dialog_class_init (GimpColormapDialogClass* klass)
|
|||
static void
|
||||
gimp_colormap_dialog_init (GimpColormapDialog *colormap_dialog)
|
||||
{
|
||||
colormap_dialog->image = NULL;
|
||||
colormap_dialog->col_index = 0;
|
||||
colormap_dialog->dnd_col_index = 0;
|
||||
colormap_dialog->vbox = NULL;
|
||||
colormap_dialog->palette = NULL;
|
||||
colormap_dialog->image_menu = NULL;
|
||||
colormap_dialog->popup_menu = NULL;
|
||||
colormap_dialog->option_menu = NULL;
|
||||
colormap_dialog->context = NULL;
|
||||
colormap_dialog->event_handler = 0;
|
||||
colormap_dialog->xn = 0;
|
||||
colormap_dialog->yn = 0;
|
||||
colormap_dialog->cellsize = 0;
|
||||
colormap_dialog->index_spinbutton = NULL;
|
||||
colormap_dialog->index_adjustment = NULL;
|
||||
colormap_dialog->color_entry = NULL;
|
||||
colormap_dialog->rename_handler = 0;
|
||||
colormap_dialog->cmap_changed_handler = 0;
|
||||
colormap_dialog->add_item = NULL;
|
||||
colormap_dialog->color_notebook = NULL;
|
||||
colormap_dialog->image = NULL;
|
||||
colormap_dialog->col_index = 0;
|
||||
colormap_dialog->dnd_col_index = 0;
|
||||
colormap_dialog->vbox = NULL;
|
||||
colormap_dialog->palette = NULL;
|
||||
colormap_dialog->image_menu = NULL;
|
||||
colormap_dialog->popup_menu = NULL;
|
||||
colormap_dialog->option_menu = NULL;
|
||||
colormap_dialog->context = NULL;
|
||||
colormap_dialog->event_handler = 0;
|
||||
colormap_dialog->xn = 0;
|
||||
colormap_dialog->yn = 0;
|
||||
colormap_dialog->cellsize = 0;
|
||||
colormap_dialog->index_spinbutton = NULL;
|
||||
colormap_dialog->index_adjustment = NULL;
|
||||
colormap_dialog->color_entry = NULL;
|
||||
colormap_dialog->rename_handler_id = 0;
|
||||
colormap_dialog->cmap_changed_handler_id = 0;
|
||||
colormap_dialog->add_item = NULL;
|
||||
colormap_dialog->color_notebook = NULL;
|
||||
}
|
||||
|
||||
GimpColormapDialog *
|
||||
|
@ -249,16 +249,19 @@ gimp_colormap_dialog_create (GimpContainer *context)
|
|||
|
||||
NULL);
|
||||
|
||||
ipal->image = NULL;
|
||||
ipal->context = context;
|
||||
ipal->cmap_changed_handler = gimp_container_add_handler (context,
|
||||
"colormap_changed",
|
||||
image_cmap_change_cb,
|
||||
ipal);
|
||||
ipal->rename_handler = gimp_container_add_handler (context,
|
||||
"name_changed",
|
||||
image_rename_cb,
|
||||
ipal);
|
||||
ipal->image = NULL;
|
||||
ipal->context = context;
|
||||
|
||||
ipal->cmap_changed_handler_id =
|
||||
gimp_container_add_handler (context,
|
||||
"colormap_changed",
|
||||
image_cmap_change_cb,
|
||||
ipal);
|
||||
ipal->rename_handler_id =
|
||||
gimp_container_add_handler (context,
|
||||
"name_changed",
|
||||
image_rename_cb,
|
||||
ipal);
|
||||
|
||||
accel_group = gtk_accel_group_new ();
|
||||
gtk_window_set_wmclass (GTK_WINDOW (ipal), "indexed_color_palette", "Gimp");
|
||||
|
@ -878,8 +881,8 @@ ipal_set_image (GimpColormapDialog *ipal,
|
|||
if (!ipal->image)
|
||||
gtk_signal_handler_unblock (GTK_OBJECT (ipal->palette),
|
||||
ipal->event_handler);
|
||||
g_return_if_fail (gimp_container_lookup (ipal->context,
|
||||
GIMP_OBJECT (gimage)));
|
||||
g_return_if_fail (gimp_container_have (ipal->context,
|
||||
GIMP_OBJECT (gimage)));
|
||||
g_return_if_fail (gimp_image_base_type (gimage) == INDEXED);
|
||||
ipal->image = gimage;
|
||||
ipal_draw (ipal);
|
||||
|
|
|
@ -53,8 +53,8 @@ struct _GimpColormapDialog
|
|||
GtkWidget *index_spinbutton;
|
||||
GtkAdjustment *index_adjustment;
|
||||
GtkEntry *color_entry;
|
||||
GimpSetHandlerId rename_handler;
|
||||
GimpSetHandlerId cmap_changed_handler;
|
||||
GQuark rename_handler_id;
|
||||
GQuark cmap_changed_handler_id;
|
||||
GtkWidget *add_item;
|
||||
ColorNotebook *color_notebook;
|
||||
};
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "gimpcontainer.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimpimage.h"
|
||||
#include "gimplist.h"
|
||||
#include "gimprc.h"
|
||||
|
||||
#include "tools/paint_options.h"
|
||||
|
@ -133,8 +134,8 @@ context_manager_init (void)
|
|||
gint i;
|
||||
|
||||
/* Create the context of all existing images */
|
||||
image_context = gimp_container_new (GIMP_TYPE_IMAGE,
|
||||
GIMP_CONTAINER_POLICY_WEAK);
|
||||
image_context = GIMP_CONTAINER (gimp_list_new (GIMP_TYPE_IMAGE,
|
||||
GIMP_CONTAINER_POLICY_WEAK));
|
||||
|
||||
/* Implicitly create the standard context */
|
||||
standard_context = gimp_context_get_standard ();
|
||||
|
|
|
@ -46,7 +46,6 @@
|
|||
|
||||
#include "brush_header.h"
|
||||
#include "gimpbrush.h"
|
||||
#include "gimpbrushlist.h"
|
||||
#include "gimprc.h"
|
||||
#include "patterns.h"
|
||||
#include "pattern_header.h"
|
||||
|
|
|
@ -46,7 +46,6 @@
|
|||
|
||||
#include "brush_header.h"
|
||||
#include "gimpbrush.h"
|
||||
#include "gimpbrushlist.h"
|
||||
#include "gimprc.h"
|
||||
#include "patterns.h"
|
||||
#include "pattern_header.h"
|
||||
|
|
|
@ -39,6 +39,8 @@ enum
|
|||
{
|
||||
ADD,
|
||||
REMOVE,
|
||||
HAVE,
|
||||
FOREACH,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
|
@ -88,7 +90,6 @@ gimp_container_init (GimpContainer *container)
|
|||
container->policy = GIMP_CONTAINER_POLICY_STRONG;
|
||||
container->num_children = 0;
|
||||
|
||||
container->children = NULL;
|
||||
container->handlers = NULL;
|
||||
}
|
||||
|
||||
|
@ -121,12 +122,35 @@ gimp_container_class_init (GimpContainerClass* klass)
|
|||
GTK_TYPE_NONE, 1,
|
||||
GIMP_TYPE_OBJECT);
|
||||
|
||||
container_signals[HAVE] =
|
||||
gtk_signal_new ("have",
|
||||
GTK_RUN_LAST,
|
||||
object_class->type,
|
||||
GTK_SIGNAL_OFFSET (GimpContainerClass,
|
||||
have),
|
||||
gtk_marshal_BOOL__POINTER,
|
||||
GTK_TYPE_BOOL, 1,
|
||||
GIMP_TYPE_OBJECT);
|
||||
|
||||
container_signals[FOREACH] =
|
||||
gtk_signal_new ("foreach",
|
||||
GTK_RUN_FIRST,
|
||||
object_class->type,
|
||||
GTK_SIGNAL_OFFSET (GimpContainerClass,
|
||||
foreach),
|
||||
gtk_marshal_NONE__POINTER_POINTER,
|
||||
GTK_TYPE_NONE, 2,
|
||||
GTK_TYPE_POINTER,
|
||||
GTK_TYPE_POINTER);
|
||||
|
||||
gtk_object_class_add_signals (object_class, container_signals, LAST_SIGNAL);
|
||||
|
||||
object_class->destroy = gimp_container_destroy;
|
||||
|
||||
klass->add = NULL;
|
||||
klass->remove = NULL;
|
||||
klass->add = NULL;
|
||||
klass->remove = NULL;
|
||||
klass->have = NULL;
|
||||
klass->foreach = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -136,12 +160,6 @@ gimp_container_destroy (GtkObject *object)
|
|||
|
||||
container = GIMP_CONTAINER (object);
|
||||
|
||||
while (container->children)
|
||||
{
|
||||
gimp_container_remove (container,
|
||||
GIMP_OBJECT (container->children->data));
|
||||
}
|
||||
|
||||
while (container->handlers)
|
||||
{
|
||||
gimp_container_remove_handler
|
||||
|
@ -164,24 +182,6 @@ gimp_container_child_destroy_callback (GtkObject *object,
|
|||
gimp_container_remove (container, GIMP_OBJECT (object));
|
||||
}
|
||||
|
||||
GimpContainer *
|
||||
gimp_container_new (GtkType children_type,
|
||||
GimpContainerPolicy policy)
|
||||
{
|
||||
GimpContainer *container;
|
||||
|
||||
g_return_val_if_fail (gtk_type_is_a (children_type, GIMP_TYPE_OBJECT), NULL);
|
||||
g_return_val_if_fail (policy == GIMP_CONTAINER_POLICY_STRONG ||
|
||||
policy == GIMP_CONTAINER_POLICY_WEAK, NULL);
|
||||
|
||||
container = gtk_type_new (GIMP_TYPE_CONTAINER);
|
||||
|
||||
container->children_type = children_type;
|
||||
container->policy = policy;
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
GtkType
|
||||
gimp_container_children_type (const GimpContainer *container)
|
||||
{
|
||||
|
@ -215,11 +215,12 @@ gimp_container_add (GimpContainer *container,
|
|||
g_return_val_if_fail (GTK_CHECK_TYPE (object, container->children_type),
|
||||
FALSE);
|
||||
|
||||
if (gimp_container_lookup (container, object))
|
||||
return FALSE;
|
||||
|
||||
container->children = g_list_prepend (container->children, object);
|
||||
container->num_children++;
|
||||
if (gimp_container_have (container, object))
|
||||
{
|
||||
g_warning ("%s(): container already contains object %p",
|
||||
__FUNCTION__, object);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
for (list = container->handlers; list; list = g_list_next (list))
|
||||
{
|
||||
|
@ -248,6 +249,8 @@ gimp_container_add (GimpContainer *container,
|
|||
break;
|
||||
}
|
||||
|
||||
container->num_children++;
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (container), container_signals[ADD], object);
|
||||
|
||||
return TRUE;
|
||||
|
@ -268,8 +271,12 @@ gimp_container_remove (GimpContainer *container,
|
|||
g_return_val_if_fail (GTK_CHECK_TYPE (object, container->children_type),
|
||||
FALSE);
|
||||
|
||||
if (! gimp_container_lookup (container, object))
|
||||
return FALSE;
|
||||
if (! gimp_container_have (container, object))
|
||||
{
|
||||
g_warning ("%s(): container does not contains object %p",
|
||||
__FUNCTION__, object);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
for (list = container->handlers; list; list = g_list_next (list))
|
||||
{
|
||||
|
@ -286,9 +293,6 @@ gimp_container_remove (GimpContainer *container,
|
|||
}
|
||||
}
|
||||
|
||||
container->children = g_list_remove (container->children, object);
|
||||
container->num_children--;
|
||||
|
||||
gtk_object_ref (GTK_OBJECT (object));
|
||||
|
||||
switch (container->policy)
|
||||
|
@ -305,21 +309,32 @@ gimp_container_remove (GimpContainer *container,
|
|||
break;
|
||||
}
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (container), container_signals[REMOVE], object);
|
||||
container->num_children--;
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (container), container_signals[REMOVE],
|
||||
object);
|
||||
|
||||
gtk_object_unref (GTK_OBJECT (object));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
const GList *
|
||||
gimp_container_lookup (const GimpContainer *container,
|
||||
const GimpObject *object)
|
||||
gboolean
|
||||
gimp_container_have (GimpContainer *container,
|
||||
GimpObject *object)
|
||||
{
|
||||
g_return_val_if_fail (container != NULL, NULL);
|
||||
g_return_val_if_fail (GIMP_IS_CONTAINER (container), NULL);
|
||||
gboolean have;
|
||||
|
||||
return g_list_find (container->children, (gpointer) object);
|
||||
g_return_val_if_fail (container != NULL, FALSE);
|
||||
g_return_val_if_fail (GIMP_IS_CONTAINER (container), FALSE);
|
||||
|
||||
if (container->num_children < 1)
|
||||
return FALSE;
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (container), container_signals[HAVE],
|
||||
object, &have);
|
||||
|
||||
return have;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -331,7 +346,24 @@ gimp_container_foreach (GimpContainer *container,
|
|||
g_return_if_fail (GIMP_IS_CONTAINER (container));
|
||||
g_return_if_fail (func != NULL);
|
||||
|
||||
g_list_foreach (container->children, func, user_data);
|
||||
if (container->num_children > 0)
|
||||
gtk_signal_emit (GTK_OBJECT (container), container_signals[FOREACH],
|
||||
func, user_data);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_container_add_handler_foreach_func (GimpObject *object,
|
||||
GimpContainerHandler *handler)
|
||||
{
|
||||
guint handler_id;
|
||||
|
||||
handler_id = gtk_signal_connect (GTK_OBJECT (object),
|
||||
handler->signame,
|
||||
handler->func,
|
||||
handler->user_data);
|
||||
|
||||
gtk_object_set_data_by_id (GTK_OBJECT (object), handler->quark,
|
||||
GUINT_TO_POINTER (handler_id));
|
||||
}
|
||||
|
||||
GQuark
|
||||
|
@ -341,10 +373,7 @@ gimp_container_add_handler (GimpContainer *container,
|
|||
gpointer callback_data)
|
||||
{
|
||||
GimpContainerHandler *handler;
|
||||
GtkObject *object;
|
||||
GList *list;
|
||||
gchar *key;
|
||||
guint handler_id;
|
||||
|
||||
g_return_val_if_fail (container != NULL, 0);
|
||||
g_return_val_if_fail (GIMP_IS_CONTAINER (container), 0);
|
||||
|
@ -368,30 +397,37 @@ gimp_container_add_handler (GimpContainer *container,
|
|||
|
||||
container->handlers = g_list_prepend (container->handlers, handler);
|
||||
|
||||
for (list = container->children; list; list = g_list_next (list))
|
||||
{
|
||||
object = GTK_OBJECT (list->data);
|
||||
|
||||
handler_id = gtk_signal_connect (object,
|
||||
handler->signame,
|
||||
handler->func,
|
||||
handler->user_data);
|
||||
|
||||
gtk_object_set_data_by_id (object, handler->quark,
|
||||
GUINT_TO_POINTER (handler_id));
|
||||
}
|
||||
gimp_container_foreach (container,
|
||||
(GFunc) gimp_container_add_handler_foreach_func,
|
||||
handler);
|
||||
|
||||
return handler->quark;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_container_remove_handler_foreach_func (GimpObject *object,
|
||||
GimpContainerHandler *handler)
|
||||
{
|
||||
guint handler_id;
|
||||
|
||||
handler_id =
|
||||
GPOINTER_TO_UINT (gtk_object_get_data_by_id (GTK_OBJECT (object),
|
||||
handler->quark));
|
||||
|
||||
if (handler_id)
|
||||
{
|
||||
gtk_signal_disconnect (GTK_OBJECT (object), handler_id);
|
||||
|
||||
gtk_object_set_data_by_id (GTK_OBJECT (object), handler->quark, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_container_remove_handler (GimpContainer *container,
|
||||
GQuark id)
|
||||
{
|
||||
GimpContainerHandler *handler;
|
||||
GtkObject *object;
|
||||
GList *list;
|
||||
guint handler_id;
|
||||
|
||||
g_return_if_fail (container != NULL);
|
||||
g_return_if_fail (GIMP_IS_CONTAINER (container));
|
||||
|
@ -411,20 +447,9 @@ gimp_container_remove_handler (GimpContainer *container,
|
|||
return;
|
||||
}
|
||||
|
||||
for (list = container->children; list; list = g_list_next (list))
|
||||
{
|
||||
object = GTK_OBJECT (list->data);
|
||||
|
||||
handler_id = GPOINTER_TO_UINT
|
||||
(gtk_object_get_data_by_id (object, handler->quark));
|
||||
|
||||
if (handler_id)
|
||||
{
|
||||
gtk_signal_disconnect (object, handler_id);
|
||||
|
||||
gtk_object_set_data_by_id (object, handler->quark, NULL);
|
||||
}
|
||||
}
|
||||
gimp_container_foreach (container,
|
||||
(GFunc) gimp_container_remove_handler_foreach_func,
|
||||
handler);
|
||||
|
||||
container->handlers = g_list_remove (container->handlers, handler);
|
||||
|
||||
|
|
|
@ -48,8 +48,6 @@ struct _GimpContainer
|
|||
GimpContainerPolicy policy;
|
||||
gint num_children;
|
||||
|
||||
GList *children;
|
||||
|
||||
/* private */
|
||||
GList *handlers;
|
||||
};
|
||||
|
@ -58,16 +56,19 @@ struct _GimpContainerClass
|
|||
{
|
||||
GimpObjectClass parent_class;
|
||||
|
||||
void (* add) (GimpContainer *container,
|
||||
GimpObject *object);
|
||||
void (* remove) (GimpContainer *container,
|
||||
GimpObject *object);
|
||||
void (* add) (GimpContainer *container,
|
||||
GimpObject *object);
|
||||
void (* remove) (GimpContainer *container,
|
||||
GimpObject *object);
|
||||
gboolean (* have) (GimpContainer *container,
|
||||
GimpObject *object);
|
||||
void (* foreach) (GimpContainer *container,
|
||||
GFunc func,
|
||||
gpointer user_data);
|
||||
};
|
||||
|
||||
|
||||
GtkType gimp_container_get_type (void);
|
||||
GimpContainer * gimp_container_new (GtkType children_type,
|
||||
GimpContainerPolicy policy);
|
||||
|
||||
GtkType gimp_container_children_type (const GimpContainer *container);
|
||||
GimpContainerPolicy gimp_container_policy (const GimpContainer *container);
|
||||
|
@ -78,8 +79,8 @@ gboolean gimp_container_add (GimpContainer *container,
|
|||
gboolean gimp_container_remove (GimpContainer *container,
|
||||
GimpObject *object);
|
||||
|
||||
const GList * gimp_container_lookup (const GimpContainer *container,
|
||||
const GimpObject *object);
|
||||
gboolean gimp_container_have (GimpContainer *container,
|
||||
GimpObject *object);
|
||||
void gimp_container_foreach (GimpContainer *container,
|
||||
GFunc func,
|
||||
gpointer user_data);
|
||||
|
|
|
@ -26,11 +26,12 @@
|
|||
|
||||
#include "apptypes.h"
|
||||
|
||||
#include "brushes.h"
|
||||
#include "context_manager.h"
|
||||
#include "gdisplay.h"
|
||||
#include "gimpbrush.h"
|
||||
#include "gimpbrushlist.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimplist.h"
|
||||
#include "gimpmarshal.h"
|
||||
#include "gimprc.h"
|
||||
#include "gradient_header.h"
|
||||
|
@ -871,9 +872,9 @@ gimp_context_image_changed (GimpContext *context)
|
|||
|
||||
/* handle disappearing images */
|
||||
static void
|
||||
gimp_context_image_removed (GimpSet *set,
|
||||
GimpImage *image,
|
||||
GimpContext *context)
|
||||
gimp_context_image_removed (GimpContainer *container,
|
||||
GimpImage *image,
|
||||
GimpContext *context)
|
||||
{
|
||||
if (context->image == image)
|
||||
gimp_context_real_set_image (context, NULL);
|
||||
|
@ -1346,7 +1347,7 @@ gimp_context_brush_dirty (GimpBrush *brush,
|
|||
|
||||
/* the active brush disappeared */
|
||||
static void
|
||||
gimp_context_brush_removed (GimpBrushList *brush_list,
|
||||
gimp_context_brush_removed (GimpContainer *brush_list,
|
||||
GimpBrush *brush,
|
||||
GimpContext *context)
|
||||
{
|
||||
|
@ -1454,15 +1455,16 @@ gimp_context_refresh_brush (GimpContext *context,
|
|||
if (! context->brush_name)
|
||||
context->brush_name = g_strdup (default_brush);
|
||||
|
||||
if ((brush = gimp_brush_list_get_brush (brush_list, context->brush_name)))
|
||||
if ((brush = (GimpBrush *) gimp_list_get_child_by_name (brush_list,
|
||||
context->brush_name)))
|
||||
{
|
||||
gimp_context_real_set_brush (context, brush);
|
||||
return;
|
||||
}
|
||||
|
||||
if (gimp_brush_list_length (brush_list))
|
||||
if (gimp_container_num_children (GIMP_CONTAINER (brush_list)))
|
||||
gimp_context_real_set_brush
|
||||
(context, gimp_brush_list_get_brush_by_index (brush_list, 0));
|
||||
(context, GIMP_BRUSH (gimp_list_get_child_by_index (brush_list, 0)));
|
||||
else
|
||||
gimp_context_real_set_brush (context, brushes_get_standard_brush ());
|
||||
}
|
||||
|
|
|
@ -0,0 +1,250 @@
|
|||
/* 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 <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpmath/gimpmath.h"
|
||||
|
||||
#include "apptypes.h"
|
||||
|
||||
#include "appenv.h"
|
||||
#include "gimpdatalist.h"
|
||||
|
||||
|
||||
static void gimp_data_list_class_init (GimpDataListClass *klass);
|
||||
static void gimp_data_list_init (GimpDataList *list);
|
||||
static void gimp_data_list_add (GimpContainer *container,
|
||||
GimpObject *object);
|
||||
static void gimp_data_list_remove (GimpContainer *container,
|
||||
GimpObject *object);
|
||||
|
||||
static void gimp_data_list_uniquefy_data_name (GimpDataList *data_list,
|
||||
GimpObject *object);
|
||||
static void gimp_data_list_object_renamed_callabck (GimpObject *object,
|
||||
GimpDataList *data_list);
|
||||
static gint gimp_data_list_data_compare_func (gconstpointer first,
|
||||
gconstpointer second);
|
||||
|
||||
|
||||
static GimpListClass *parent_class = NULL;
|
||||
|
||||
|
||||
GtkType
|
||||
gimp_data_list_get_type (void)
|
||||
{
|
||||
static GtkType type = 0;
|
||||
|
||||
if (!type)
|
||||
{
|
||||
GtkTypeInfo info =
|
||||
{
|
||||
"GimpDataList",
|
||||
sizeof (GimpDataList),
|
||||
sizeof (GimpDataListClass),
|
||||
(GtkClassInitFunc) gimp_data_list_class_init,
|
||||
(GtkObjectInitFunc) gimp_data_list_init,
|
||||
/* reserved_1 */ NULL,
|
||||
/* reserved_2 */ NULL,
|
||||
(GtkClassInitFunc) NULL
|
||||
};
|
||||
|
||||
type = gtk_type_unique (GIMP_TYPE_LIST, &info);
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_data_list_class_init (GimpDataListClass *klass)
|
||||
{
|
||||
GimpContainerClass *container_class;
|
||||
|
||||
container_class = (GimpContainerClass *) klass;
|
||||
|
||||
parent_class = gtk_type_class (GIMP_TYPE_LIST);
|
||||
|
||||
container_class->add = gimp_data_list_add;
|
||||
container_class->remove = gimp_data_list_remove;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_data_list_init (GimpDataList *list)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_data_list_add (GimpContainer *container,
|
||||
GimpObject *object)
|
||||
{
|
||||
GimpList *list;
|
||||
|
||||
list = GIMP_LIST (container);
|
||||
|
||||
gimp_data_list_uniquefy_data_name (GIMP_DATA_LIST (container), object);
|
||||
|
||||
list->list = g_list_insert_sorted (list->list, object,
|
||||
gimp_data_list_data_compare_func);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (object), "name_changed",
|
||||
GTK_SIGNAL_FUNC (gimp_data_list_object_renamed_callabck),
|
||||
container);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_data_list_remove (GimpContainer *container,
|
||||
GimpObject *object)
|
||||
{
|
||||
GimpList *list;
|
||||
|
||||
list = GIMP_LIST (container);
|
||||
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (object),
|
||||
gimp_data_list_object_renamed_callabck,
|
||||
container);
|
||||
|
||||
list->list = g_list_remove (list->list, object);
|
||||
}
|
||||
|
||||
GimpDataList *
|
||||
gimp_data_list_new (GtkType children_type)
|
||||
|
||||
{
|
||||
GimpDataList *list;
|
||||
|
||||
g_return_val_if_fail (gtk_type_is_a (children_type, GIMP_TYPE_OBJECT), NULL);
|
||||
|
||||
list = GIMP_DATA_LIST (gtk_type_new (GIMP_TYPE_DATA_LIST));
|
||||
|
||||
GIMP_CONTAINER (list)->children_type = children_type;
|
||||
GIMP_CONTAINER (list)->policy = GIMP_CONTAINER_POLICY_STRONG;
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_data_list_uniquefy_data_name (GimpDataList *data_list,
|
||||
GimpObject *object)
|
||||
{
|
||||
GList *base_list;
|
||||
GList *list;
|
||||
GList *list2;
|
||||
GimpObject *object2;
|
||||
gint unique_ext = 0;
|
||||
gchar *new_name = NULL;
|
||||
gchar *ext;
|
||||
|
||||
g_return_if_fail (GIMP_IS_DATA_LIST (data_list));
|
||||
g_return_if_fail (GIMP_IS_OBJECT (object));
|
||||
|
||||
base_list = GIMP_LIST (data_list)->list;
|
||||
|
||||
for (list = base_list; list; list = g_list_next (list))
|
||||
{
|
||||
object2 = GIMP_OBJECT (list->data);
|
||||
|
||||
if (object != object2 &&
|
||||
strcmp (gimp_object_get_name (GIMP_OBJECT (object)),
|
||||
gimp_object_get_name (GIMP_OBJECT (object2))) == 0)
|
||||
{
|
||||
ext = strrchr (GIMP_OBJECT (object)->name, '#');
|
||||
|
||||
if (ext)
|
||||
{
|
||||
gchar *ext_str;
|
||||
|
||||
unique_ext = atoi (ext + 1);
|
||||
|
||||
ext_str = g_strdup_printf ("%d", unique_ext);
|
||||
|
||||
/* check if the extension really is of the form "#<n>" */
|
||||
if (! strcmp (ext_str, ext + 1))
|
||||
{
|
||||
*ext = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
unique_ext = 0;
|
||||
}
|
||||
|
||||
g_free (ext_str);
|
||||
}
|
||||
else
|
||||
{
|
||||
unique_ext = 0;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
unique_ext++;
|
||||
|
||||
g_free (new_name);
|
||||
|
||||
new_name = g_strdup_printf ("%s#%d",
|
||||
GIMP_OBJECT (object)->name,
|
||||
unique_ext);
|
||||
|
||||
for (list2 = base_list; list2; list2 = g_list_next (list2))
|
||||
{
|
||||
object2 = GIMP_OBJECT (list2->data);
|
||||
|
||||
if (object == object2)
|
||||
continue;
|
||||
|
||||
if (! strcmp (GIMP_OBJECT (object2)->name, new_name))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (list2);
|
||||
|
||||
gimp_object_set_name (GIMP_OBJECT (object), new_name);
|
||||
g_free (new_name);
|
||||
|
||||
if (gimp_container_have (GIMP_CONTAINER (data_list), object))
|
||||
{
|
||||
gtk_object_ref (GTK_OBJECT (object));
|
||||
gimp_container_remove (GIMP_CONTAINER (data_list), object);
|
||||
gimp_container_add (GIMP_CONTAINER (data_list), object);
|
||||
gtk_object_unref (GTK_OBJECT (object));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_data_list_object_renamed_callabck (GimpObject *object,
|
||||
GimpDataList *data_list)
|
||||
{
|
||||
gimp_data_list_uniquefy_data_name (data_list, object);
|
||||
}
|
||||
|
||||
static gint
|
||||
gimp_data_list_data_compare_func (gconstpointer first,
|
||||
gconstpointer second)
|
||||
{
|
||||
return strcmp (((const GimpObject *) first)->name,
|
||||
((const GimpObject *) second)->name);
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/* 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 __GIMP_DATA_LIST_H__
|
||||
#define __GIMP_DATA_LIST_H__
|
||||
|
||||
|
||||
#include "gimplist.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_DATA_LIST (gimp_data_list_get_type ())
|
||||
#define GIMP_DATA_LIST(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_DATA_LIST, GimpDataList))
|
||||
#define GIMP_DATA_LIST_CLASS(klass) (GTK_CHECK_CLASS_CAST (klass, GIMP_TYPE_DATA_LIST, GimpDataListClass))
|
||||
#define GIMP_IS_DATA_LIST(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_DATA_LIST))
|
||||
#define GIMP_IS_DATA_LIST_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_DATA_LIST))
|
||||
|
||||
|
||||
typedef struct _GimpDataListClass GimpDataListClass;
|
||||
|
||||
struct _GimpDataList
|
||||
{
|
||||
GimpList parent_instance;
|
||||
};
|
||||
|
||||
struct _GimpDataListClass
|
||||
{
|
||||
GimpListClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
GtkType gimp_data_list_get_type (void);
|
||||
GimpDataList * gimp_data_list_new (GtkType children_type);
|
||||
|
||||
|
||||
#endif /* __GIMP_DATA_LIST_H__ */
|
|
@ -18,95 +18,31 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "apptypes.h"
|
||||
|
||||
#include "gimpobject.h"
|
||||
#include "gimpcontainer.h"
|
||||
#include "gimplist.h"
|
||||
|
||||
|
||||
/* code mostly ripped from nether's gimpset class */
|
||||
|
||||
enum
|
||||
{
|
||||
ADD,
|
||||
REMOVE,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
static guint gimp_list_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
static GimpObjectClass *parent_class = NULL;
|
||||
static void gimp_list_class_init (GimpListClass *klass);
|
||||
static void gimp_list_init (GimpList *list);
|
||||
static void gimp_list_destroy (GtkObject *object);
|
||||
static void gimp_list_add (GimpContainer *container,
|
||||
GimpObject *object);
|
||||
static void gimp_list_remove (GimpContainer *container,
|
||||
GimpObject *object);
|
||||
static gboolean gimp_list_have (GimpContainer *container,
|
||||
GimpObject *object);
|
||||
static void gimp_list_foreach (GimpContainer *container,
|
||||
GFunc func,
|
||||
gpointer user_data);
|
||||
|
||||
|
||||
static void gimp_list_add_func (GimpList *list,
|
||||
gpointer object);
|
||||
static void gimp_list_remove_func (GimpList *list,
|
||||
gpointer object);
|
||||
static GimpContainerClass *parent_class = NULL;
|
||||
|
||||
|
||||
static void
|
||||
gimp_list_destroy (GtkObject *object)
|
||||
{
|
||||
GimpList *list = GIMP_LIST (object);
|
||||
|
||||
while (list->list) /* ought to put a sanity check in here... */
|
||||
{
|
||||
gimp_list_remove (list, list->list->data);
|
||||
}
|
||||
g_slist_free (list->list);
|
||||
|
||||
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
||||
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_list_init (GimpList *list)
|
||||
{
|
||||
list->list = NULL;
|
||||
list->type = GTK_TYPE_OBJECT;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_list_class_init (GimpListClass *klass)
|
||||
{
|
||||
GtkObjectClass *object_class;
|
||||
|
||||
object_class = (GtkObjectClass *) klass;
|
||||
|
||||
parent_class = gtk_type_class (GIMP_TYPE_OBJECT);
|
||||
|
||||
gimp_list_signals[ADD]=
|
||||
gtk_signal_new ("add",
|
||||
GTK_RUN_FIRST,
|
||||
object_class->type,
|
||||
GTK_SIGNAL_OFFSET (GimpListClass,
|
||||
add),
|
||||
gtk_marshal_NONE__POINTER,
|
||||
GTK_TYPE_NONE, 1,
|
||||
GTK_TYPE_POINTER);
|
||||
|
||||
gimp_list_signals[REMOVE]=
|
||||
gtk_signal_new ("remove",
|
||||
GTK_RUN_FIRST,
|
||||
object_class->type,
|
||||
GTK_SIGNAL_OFFSET (GimpListClass,
|
||||
remove),
|
||||
gtk_marshal_NONE__POINTER,
|
||||
GTK_TYPE_NONE, 1,
|
||||
GTK_TYPE_POINTER);
|
||||
|
||||
gtk_object_class_add_signals (object_class, gimp_list_signals, LAST_SIGNAL);
|
||||
|
||||
object_class->destroy = gimp_list_destroy;
|
||||
|
||||
klass->add = gimp_list_add_func;
|
||||
klass->remove = gimp_list_remove_func;
|
||||
}
|
||||
|
||||
GtkType
|
||||
gimp_list_get_type (void)
|
||||
{
|
||||
|
@ -126,123 +62,164 @@ gimp_list_get_type (void)
|
|||
(GtkClassInitFunc) NULL
|
||||
};
|
||||
|
||||
list_type = gtk_type_unique (GIMP_TYPE_OBJECT, &list_info);
|
||||
list_type = gtk_type_unique (GIMP_TYPE_CONTAINER, &list_info);
|
||||
}
|
||||
|
||||
return list_type;
|
||||
}
|
||||
|
||||
GimpList *
|
||||
gimp_list_new (GtkType type,
|
||||
gboolean weak)
|
||||
static void
|
||||
gimp_list_class_init (GimpListClass *klass)
|
||||
{
|
||||
GtkObjectClass *object_class;
|
||||
GimpContainerClass *container_class;
|
||||
|
||||
object_class = (GtkObjectClass *) klass;
|
||||
container_class = (GimpContainerClass *) klass;
|
||||
|
||||
parent_class = gtk_type_class (GIMP_TYPE_CONTAINER);
|
||||
|
||||
object_class->destroy = gimp_list_destroy;
|
||||
|
||||
container_class->add = gimp_list_add;
|
||||
container_class->remove = gimp_list_remove;
|
||||
container_class->have = gimp_list_have;
|
||||
container_class->foreach = gimp_list_foreach;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_list_init (GimpList *list)
|
||||
{
|
||||
list->list = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_list_destroy (GtkObject *object)
|
||||
{
|
||||
GimpList *list;
|
||||
|
||||
list = GIMP_LIST (object);
|
||||
|
||||
while (list->list)
|
||||
{
|
||||
gimp_container_remove (GIMP_CONTAINER (list),
|
||||
GIMP_OBJECT (list->list->data));
|
||||
}
|
||||
|
||||
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
||||
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_list_add (GimpContainer *container,
|
||||
GimpObject *object)
|
||||
{
|
||||
GimpList *list;
|
||||
|
||||
list = GIMP_LIST (container);
|
||||
|
||||
list->list = g_list_prepend (list->list, object);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_list_remove (GimpContainer *container,
|
||||
GimpObject *object)
|
||||
{
|
||||
GimpList *list;
|
||||
|
||||
list = GIMP_LIST (container);
|
||||
|
||||
list->list = g_list_remove (list->list, object);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_list_have (GimpContainer *container,
|
||||
GimpObject *object)
|
||||
{
|
||||
GimpList *list;
|
||||
|
||||
list = GIMP_LIST (container);
|
||||
|
||||
return g_list_find (list->list, object) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_list_foreach (GimpContainer *container,
|
||||
GFunc func,
|
||||
gpointer user_data)
|
||||
{
|
||||
GimpList *list;
|
||||
|
||||
list = GIMP_LIST (container);
|
||||
|
||||
g_list_foreach (list->list, func, user_data);
|
||||
}
|
||||
|
||||
GimpList *
|
||||
gimp_list_new (GtkType children_type,
|
||||
GimpContainerPolicy policy)
|
||||
{
|
||||
GimpList *list;
|
||||
|
||||
g_return_val_if_fail (gtk_type_is_a (children_type, GIMP_TYPE_OBJECT), NULL);
|
||||
g_return_val_if_fail (policy == GIMP_CONTAINER_POLICY_STRONG ||
|
||||
policy == GIMP_CONTAINER_POLICY_WEAK, NULL);
|
||||
|
||||
list = gtk_type_new (GIMP_TYPE_LIST);
|
||||
|
||||
list->type = type;
|
||||
list->weak = weak;
|
||||
GIMP_CONTAINER (list)->children_type = children_type;
|
||||
GIMP_CONTAINER (list)->policy = policy;
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_list_destroy_cb (GtkObject *object,
|
||||
gpointer data)
|
||||
GimpObject *
|
||||
gimp_list_get_child_by_name (const GimpList *list,
|
||||
const gchar *name)
|
||||
{
|
||||
GimpList *list;
|
||||
GimpObject *object;
|
||||
GList *glist;
|
||||
|
||||
list = GIMP_LIST (data);
|
||||
g_return_val_if_fail (list != NULL, NULL);
|
||||
g_return_val_if_fail (GIMP_IS_LIST (list), NULL);
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
|
||||
gimp_list_remove (list, object);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_list_add_func (GimpList *list,
|
||||
gpointer object)
|
||||
{
|
||||
list->list = g_slist_prepend (list->list, object);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_list_remove_func (GimpList *list,
|
||||
gpointer object)
|
||||
{
|
||||
list->list = g_slist_remove (list->list, object);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_list_add (GimpList *list,
|
||||
gpointer object)
|
||||
{
|
||||
g_return_val_if_fail (list, FALSE);
|
||||
g_return_val_if_fail (GTK_CHECK_TYPE (object, list->type), FALSE);
|
||||
|
||||
if (g_slist_find (list->list, object))
|
||||
return FALSE;
|
||||
|
||||
if (list->weak)
|
||||
for (glist = list->list; glist; glist = g_list_next (glist))
|
||||
{
|
||||
gtk_signal_connect (GTK_OBJECT (object), "destroy",
|
||||
GTK_SIGNAL_FUNC (gimp_list_destroy_cb),
|
||||
list);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_object_ref (GTK_OBJECT (object));
|
||||
gtk_object_sink (GTK_OBJECT (object));
|
||||
object = (GimpObject *) glist->data;
|
||||
|
||||
if (! strcmp (object->name, name))
|
||||
return object;
|
||||
}
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (list), gimp_list_signals[ADD], object);
|
||||
|
||||
return TRUE;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_list_remove (GimpList *list,
|
||||
gpointer object)
|
||||
GimpObject *
|
||||
gimp_list_get_child_by_index (const GimpList *list,
|
||||
gint index)
|
||||
{
|
||||
g_return_val_if_fail (list, FALSE);
|
||||
GList *glist;
|
||||
|
||||
if (!g_slist_find (list->list, object))
|
||||
{
|
||||
g_warning ("gimp_list_remove: can't find val");
|
||||
return FALSE;
|
||||
}
|
||||
g_return_val_if_fail (list != NULL, NULL);
|
||||
g_return_val_if_fail (GIMP_IS_LIST (list), NULL);
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (list), gimp_list_signals[REMOVE], object);
|
||||
glist = g_list_nth (list->list, index);
|
||||
|
||||
if (list->weak)
|
||||
{
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (object),
|
||||
GTK_SIGNAL_FUNC (gimp_list_destroy_cb),
|
||||
list);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_object_unref (GTK_OBJECT (object));
|
||||
}
|
||||
if (glist)
|
||||
return (GimpObject *) glist->data;
|
||||
|
||||
return TRUE;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_list_have (GimpList *list,
|
||||
gpointer object)
|
||||
gint
|
||||
gimp_list_get_child_index (const GimpList *list,
|
||||
const GimpObject *object)
|
||||
{
|
||||
return g_slist_find (list->list, object) ? TRUE : FALSE;
|
||||
}
|
||||
g_return_val_if_fail (list != NULL, 0);
|
||||
g_return_val_if_fail (GIMP_IS_LIST (list), 0);
|
||||
g_return_val_if_fail (object != NULL, 0);
|
||||
g_return_val_if_fail (GIMP_IS_OBJECT (list), 0);
|
||||
|
||||
void
|
||||
gimp_list_foreach (GimpList *list,
|
||||
GFunc func,
|
||||
gpointer user_data)
|
||||
{
|
||||
g_slist_foreach (list->list, func, user_data);
|
||||
}
|
||||
|
||||
GtkType
|
||||
gimp_list_type (GimpList *list)
|
||||
{
|
||||
return list->type;
|
||||
return g_list_index (list->list, (gpointer) object);
|
||||
}
|
||||
|
|
|
@ -20,14 +20,7 @@
|
|||
#define __GIMP_LIST_H__
|
||||
|
||||
|
||||
#include "gimpobject.h"
|
||||
|
||||
|
||||
/* GimpList - a typed list of objects with signals for adding and
|
||||
* removing of stuff. If it is weak, destroyed objects get removed
|
||||
* automatically. If it is not, it refs them so they won't be freed
|
||||
* till they are removed. (Though they can be destroyed, of course)
|
||||
*/
|
||||
#include "gimpcontainer.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_LIST (gimp_list_get_type ())
|
||||
|
@ -41,39 +34,27 @@ typedef struct _GimpListClass GimpListClass;
|
|||
|
||||
struct _GimpList
|
||||
{
|
||||
GimpObject parent_instance;
|
||||
GimpContainer parent_instance;
|
||||
|
||||
GtkType type;
|
||||
GSList *list;
|
||||
gboolean weak;
|
||||
GList *list;
|
||||
};
|
||||
|
||||
struct _GimpListClass
|
||||
{
|
||||
GimpObjectClass parent_class;
|
||||
|
||||
void (* add) (GimpList *list,
|
||||
gpointer object);
|
||||
void (* remove) (GimpList *list,
|
||||
gpointer object);
|
||||
GimpContainerClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
GtkType gimp_list_get_type (void);
|
||||
GtkType gimp_list_get_type (void);
|
||||
GimpList * gimp_list_new (GtkType children_type,
|
||||
GimpContainerPolicy policy);
|
||||
|
||||
GimpList * gimp_list_new (GtkType type,
|
||||
gboolean weak);
|
||||
|
||||
GtkType gimp_list_type (GimpList *list);
|
||||
gboolean gimp_list_add (GimpList *list,
|
||||
gpointer object);
|
||||
gboolean gimp_list_remove (GimpList *list,
|
||||
gpointer object);
|
||||
gboolean gimp_list_have (GimpList *list,
|
||||
gpointer object);
|
||||
void gimp_list_foreach (GimpList *list,
|
||||
GFunc func,
|
||||
gpointer user_data);
|
||||
GimpObject * gimp_list_get_child_by_name (const GimpList *list,
|
||||
const gchar *name);
|
||||
GimpObject * gimp_list_get_child_by_index (const GimpList *list,
|
||||
gint index);
|
||||
gint gimp_list_get_child_index (const GimpList *list,
|
||||
const GimpObject *object);
|
||||
|
||||
|
||||
#endif /* __GIMP_LIST_H__ */
|
||||
|
|
|
@ -29,13 +29,14 @@
|
|||
#include "apptypes.h"
|
||||
|
||||
#include "appenv.h"
|
||||
#include "brushes.h"
|
||||
#include "devices.h"
|
||||
#include "dialog_handler.h"
|
||||
#include "gimpbrush.h"
|
||||
#include "gimpcontextpreview.h"
|
||||
#include "gimpdnd.h"
|
||||
#include "gimpbrushlist.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimplist.h"
|
||||
#include "gimprc.h"
|
||||
#include "gradient.h"
|
||||
#include "gradient_header.h"
|
||||
|
@ -466,7 +467,7 @@ devices_rc_update (gchar *name,
|
|||
{
|
||||
GimpBrush *brush;
|
||||
|
||||
brush = gimp_brush_list_get_brush (brush_list, brush_name);
|
||||
brush = (GimpBrush *) gimp_list_get_child_by_name (brush_list, brush_name);
|
||||
|
||||
if (brush)
|
||||
{
|
||||
|
|
|
@ -345,7 +345,7 @@ info_window_change_display (GimpContext *context, /* NOT USED */
|
|||
|
||||
gimage = gdisp->gimage;
|
||||
|
||||
if (gimage && gimp_container_lookup (image_context, GIMP_OBJECT (gimage)))
|
||||
if (gimage && gimp_container_have (image_context, GIMP_OBJECT (gimage)))
|
||||
{
|
||||
iwd->gdisp = gdisp;
|
||||
info_window_update (gdisp);
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
#include "module_db.h"
|
||||
#include "gimprc.h"
|
||||
#include "datafiles.h"
|
||||
#include "gimpcontainer.h"
|
||||
#include "gimplist.h"
|
||||
|
||||
#include "libgimp/gimpenv.h"
|
||||
#include "libgimp/gimpmodule.h"
|
||||
|
@ -215,8 +215,8 @@ module_db_init (void)
|
|||
|
||||
/* Load and initialize gimp modules */
|
||||
|
||||
modules = gimp_container_new (MODULE_INFO_TYPE,
|
||||
GIMP_CONTAINER_POLICY_WEAK);
|
||||
modules = GIMP_CONTAINER (gimp_list_new (MODULE_INFO_TYPE,
|
||||
GIMP_CONTAINER_POLICY_WEAK));
|
||||
|
||||
if (g_module_supported ())
|
||||
datafiles_read_directories (module_path,
|
||||
|
|
|
@ -1325,7 +1325,7 @@ nav_window_change_display (GimpContext *context, /* NOT USED */
|
|||
|
||||
gimage = gdisp->gimage;
|
||||
|
||||
if (gimage && gimp_container_lookup (image_context, GIMP_OBJECT (gimage)))
|
||||
if (gimage && gimp_container_have (image_context, GIMP_OBJECT (gimage)))
|
||||
{
|
||||
iwd->gdisp = gdisp;
|
||||
|
||||
|
|
|
@ -1325,7 +1325,7 @@ nav_window_change_display (GimpContext *context, /* NOT USED */
|
|||
|
||||
gimage = gdisp->gimage;
|
||||
|
||||
if (gimage && gimp_container_lookup (image_context, GIMP_OBJECT (gimage)))
|
||||
if (gimage && gimp_container_have (image_context, GIMP_OBJECT (gimage)))
|
||||
{
|
||||
iwd->gdisp = gdisp;
|
||||
|
||||
|
|
|
@ -46,7 +46,6 @@
|
|||
|
||||
#include "brush_header.h"
|
||||
#include "gimpbrush.h"
|
||||
#include "gimpbrushlist.h"
|
||||
#include "gimprc.h"
|
||||
#include "patterns.h"
|
||||
#include "pattern_header.h"
|
||||
|
|
|
@ -1,485 +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 <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_DIRENT_H
|
||||
#include <dirent.h>
|
||||
#endif
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpmath/gimpmath.h"
|
||||
|
||||
#include "apptypes.h"
|
||||
|
||||
#include "appenv.h"
|
||||
#include "gimpbrushgenerated.h"
|
||||
#include "gimpbrushpipe.h"
|
||||
#include "brush_header.h"
|
||||
#include "brush_select.h"
|
||||
#include "datafiles.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimprc.h"
|
||||
#include "gimplist.h"
|
||||
#include "gimpbrush.h"
|
||||
#include "gimpbrushlist.h"
|
||||
|
||||
#include "libgimp/gimpenv.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
/* global variables */
|
||||
GimpBrushList *brush_list = NULL;
|
||||
|
||||
|
||||
/* local function prototypes */
|
||||
static void brushes_brush_load (const gchar *filename);
|
||||
|
||||
static gint brush_compare_func (gconstpointer first,
|
||||
gconstpointer second);
|
||||
|
||||
|
||||
/* class functions */
|
||||
static GimpListClass* parent_class = NULL;
|
||||
|
||||
|
||||
static void
|
||||
gimp_brush_list_add_func (GimpList *list,
|
||||
gpointer val)
|
||||
{
|
||||
list->list = g_slist_insert_sorted (list->list, val, brush_compare_func);
|
||||
GIMP_BRUSH_LIST (list)->num_brushes++;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_brush_list_remove_func (GimpList *list,
|
||||
gpointer val)
|
||||
{
|
||||
list->list = g_slist_remove (list->list, val);
|
||||
|
||||
GIMP_BRUSH_LIST (list)->num_brushes--;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_brush_list_class_init (GimpBrushListClass *klass)
|
||||
{
|
||||
GimpListClass *gimp_list_class;
|
||||
|
||||
gimp_list_class = (GimpListClass *) klass;
|
||||
|
||||
parent_class = gtk_type_class (GIMP_TYPE_LIST);
|
||||
|
||||
gimp_list_class->add = gimp_brush_list_add_func;
|
||||
gimp_list_class->remove = gimp_brush_list_remove_func;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_brush_list_init (GimpBrushList *list)
|
||||
{
|
||||
list->num_brushes = 0;
|
||||
}
|
||||
|
||||
GtkType
|
||||
gimp_brush_list_get_type (void)
|
||||
{
|
||||
static GtkType type = 0;
|
||||
|
||||
if (!type)
|
||||
{
|
||||
GtkTypeInfo info =
|
||||
{
|
||||
"GimpBrushList",
|
||||
sizeof (GimpBrushList),
|
||||
sizeof (GimpBrushListClass),
|
||||
(GtkClassInitFunc) gimp_brush_list_class_init,
|
||||
(GtkObjectInitFunc) gimp_brush_list_init,
|
||||
/* reserved_1 */ NULL,
|
||||
/* reserved_2 */ NULL,
|
||||
(GtkClassInitFunc) NULL
|
||||
};
|
||||
|
||||
type = gtk_type_unique (GIMP_TYPE_LIST, &info);
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
GimpBrushList *
|
||||
gimp_brush_list_new (void)
|
||||
{
|
||||
GimpBrushList *list;
|
||||
|
||||
list = GIMP_BRUSH_LIST (gtk_type_new (GIMP_TYPE_BRUSH_LIST));
|
||||
|
||||
GIMP_LIST (list)->type = GIMP_TYPE_BRUSH;
|
||||
GIMP_LIST (list)->weak = FALSE;
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/* function declarations */
|
||||
void
|
||||
brushes_init (gboolean no_data)
|
||||
{
|
||||
if (brush_list)
|
||||
brushes_free ();
|
||||
else
|
||||
brush_list = gimp_brush_list_new ();
|
||||
|
||||
if (brush_path != NULL && !no_data)
|
||||
{
|
||||
brush_select_freeze_all ();
|
||||
|
||||
datafiles_read_directories (brush_path, brushes_brush_load, 0);
|
||||
datafiles_read_directories (brush_vbr_path, brushes_brush_load, 0);
|
||||
|
||||
brush_select_thaw_all ();
|
||||
}
|
||||
|
||||
gimp_context_refresh_brushes ();
|
||||
}
|
||||
|
||||
GimpBrush *
|
||||
brushes_get_standard_brush (void)
|
||||
{
|
||||
static GimpBrush *standard_brush = NULL;
|
||||
|
||||
if (! standard_brush)
|
||||
{
|
||||
standard_brush =
|
||||
GIMP_BRUSH (gimp_brush_generated_new (5.0, 0.5, 0.0, 1.0));
|
||||
|
||||
gimp_object_set_name (GIMP_OBJECT (standard_brush), "Standard");
|
||||
|
||||
/* set ref_count to 2 --> never swap the standard brush */
|
||||
gtk_object_ref (GTK_OBJECT (standard_brush));
|
||||
gtk_object_ref (GTK_OBJECT (standard_brush));
|
||||
gtk_object_sink (GTK_OBJECT (standard_brush));
|
||||
}
|
||||
|
||||
return standard_brush;
|
||||
}
|
||||
|
||||
static void
|
||||
brushes_brush_load (const gchar *filename)
|
||||
{
|
||||
GimpBrush *brush;
|
||||
|
||||
if (strcmp (&filename[strlen (filename) - 4], ".gbr") == 0 ||
|
||||
strcmp (&filename[strlen (filename) - 4], ".gpb") == 0)
|
||||
{
|
||||
brush = gimp_brush_load (filename);
|
||||
|
||||
if (brush != NULL)
|
||||
gimp_brush_list_add (brush_list, brush);
|
||||
else
|
||||
g_message (_("Warning: Failed to load brush\n\"%s\""), filename);
|
||||
}
|
||||
else if (strcmp (&filename[strlen(filename) - 4], ".vbr") == 0)
|
||||
{
|
||||
brush = gimp_brush_generated_load (filename);
|
||||
|
||||
if (brush != NULL)
|
||||
gimp_brush_list_add (brush_list, GIMP_BRUSH (brush));
|
||||
else
|
||||
g_message (_("Warning: Failed to load brush\n\"%s\""), filename);
|
||||
}
|
||||
else if (strcmp (&filename[strlen (filename) - 4], ".gih") == 0)
|
||||
{
|
||||
brush = gimp_brush_pipe_load (filename);
|
||||
|
||||
if (brush != NULL)
|
||||
gimp_brush_list_add (brush_list, GIMP_BRUSH (brush));
|
||||
else
|
||||
g_message (_("Warning: Failed to load brush pipe\n\"%s\""), filename);
|
||||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
brush_compare_func (gconstpointer first,
|
||||
gconstpointer second)
|
||||
{
|
||||
return strcmp (((const GimpObject *) first)->name,
|
||||
((const GimpObject *) second)->name);
|
||||
}
|
||||
|
||||
void
|
||||
brushes_free (void)
|
||||
{
|
||||
GList *vbr_path;
|
||||
gchar *vbr_dir;
|
||||
|
||||
if (!brush_list)
|
||||
return;
|
||||
|
||||
vbr_path = gimp_path_parse (brush_vbr_path, 16, TRUE, NULL);
|
||||
vbr_dir = gimp_path_get_user_writable_dir (vbr_path);
|
||||
gimp_path_free (vbr_path);
|
||||
|
||||
brush_select_freeze_all ();
|
||||
|
||||
while (GIMP_LIST (brush_list)->list)
|
||||
{
|
||||
GimpBrush *brush = GIMP_BRUSH (GIMP_LIST (brush_list)->list->data);
|
||||
|
||||
if (GIMP_IS_BRUSH_GENERATED (brush) && vbr_dir)
|
||||
{
|
||||
gchar *filename = NULL;
|
||||
if (!brush->filename)
|
||||
{
|
||||
FILE *tmp_fp;
|
||||
gint unum = 0;
|
||||
|
||||
if (vbr_dir)
|
||||
{
|
||||
gchar *safe_name;
|
||||
gint i;
|
||||
|
||||
/* make sure we don't create a naughty filename */
|
||||
safe_name = g_strdup (GIMP_OBJECT (brush)->name);
|
||||
if (safe_name[0] == '.')
|
||||
safe_name[0] = '_';
|
||||
for (i = 0; safe_name[i]; i++)
|
||||
if (safe_name[i] == G_DIR_SEPARATOR || isspace(safe_name[i]))
|
||||
safe_name[i] = '_';
|
||||
|
||||
filename = g_strdup_printf ("%s%s.vbr",
|
||||
vbr_dir,
|
||||
safe_name);
|
||||
while ((tmp_fp = fopen (filename, "r")))
|
||||
{ /* make sure we don't overite an existing brush */
|
||||
fclose (tmp_fp);
|
||||
g_free (filename);
|
||||
filename = g_strdup_printf ("%s%s_%d.vbr",
|
||||
vbr_dir, safe_name, unum);
|
||||
unum++;
|
||||
}
|
||||
g_free (safe_name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
filename = g_strdup (brush->filename);
|
||||
if (strlen(filename) < 4 || strcmp (&filename[strlen (filename) - 4],
|
||||
".vbr"))
|
||||
{ /* we only want to save .vbr files, so set filename to null
|
||||
if this isn't a .vbr file */
|
||||
g_free (filename);
|
||||
filename = NULL;
|
||||
}
|
||||
}
|
||||
/* we are (finaly) ready to try to save the generated brush file */
|
||||
if (filename)
|
||||
{
|
||||
gimp_brush_generated_save (GIMP_BRUSH_GENERATED (brush),
|
||||
filename);
|
||||
g_free (filename);
|
||||
}
|
||||
}
|
||||
|
||||
gimp_brush_list_remove (brush_list, brush);
|
||||
}
|
||||
|
||||
brush_select_thaw_all ();
|
||||
|
||||
g_free (vbr_dir);
|
||||
}
|
||||
|
||||
gint
|
||||
gimp_brush_list_get_brush_index (GimpBrushList *brush_list,
|
||||
GimpBrush *brush)
|
||||
{
|
||||
/* FIXME: make a gimp_list function that does this? */
|
||||
return g_slist_index (GIMP_LIST (brush_list)->list, brush);
|
||||
}
|
||||
|
||||
GimpBrush *
|
||||
gimp_brush_list_get_brush_by_index (GimpBrushList *brush_list,
|
||||
gint index)
|
||||
{
|
||||
GimpBrush *brush = NULL;
|
||||
GSList *list;
|
||||
|
||||
/* FIXME: make a gimp_list function that does this? */
|
||||
list = g_slist_nth (GIMP_LIST (brush_list)->list, index);
|
||||
if (list)
|
||||
brush = (GimpBrush *) list->data;
|
||||
|
||||
return brush;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_brush_list_uniquefy_brush_name (GimpBrushList *brush_list,
|
||||
GimpBrush *brush)
|
||||
{
|
||||
GSList *list;
|
||||
GSList *list2;
|
||||
GSList *base_list;
|
||||
GimpBrush *brush2;
|
||||
gint unique_ext = 0;
|
||||
gchar *new_name = NULL;
|
||||
gchar *ext;
|
||||
|
||||
g_return_if_fail (GIMP_IS_BRUSH_LIST (brush_list));
|
||||
g_return_if_fail (GIMP_IS_BRUSH (brush));
|
||||
|
||||
base_list = GIMP_LIST (brush_list)->list;
|
||||
|
||||
for (list = base_list; list; list = g_slist_next (list))
|
||||
{
|
||||
brush2 = GIMP_BRUSH (list->data);
|
||||
|
||||
if (brush != brush2 &&
|
||||
strcmp (gimp_object_get_name (GIMP_OBJECT (brush)),
|
||||
gimp_object_get_name (GIMP_OBJECT (brush2))) == 0)
|
||||
{
|
||||
ext = strrchr (GIMP_OBJECT (brush)->name, '#');
|
||||
|
||||
if (ext)
|
||||
{
|
||||
gchar *ext_str;
|
||||
|
||||
unique_ext = atoi (ext + 1);
|
||||
|
||||
ext_str = g_strdup_printf ("%d", unique_ext);
|
||||
|
||||
/* check if the extension really is of the form "#<n>" */
|
||||
if (! strcmp (ext_str, ext + 1))
|
||||
{
|
||||
*ext = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
unique_ext = 0;
|
||||
}
|
||||
|
||||
g_free (ext_str);
|
||||
}
|
||||
else
|
||||
{
|
||||
unique_ext = 0;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
unique_ext++;
|
||||
|
||||
g_free (new_name);
|
||||
|
||||
new_name = g_strdup_printf ("%s#%d",
|
||||
GIMP_OBJECT (brush)->name,
|
||||
unique_ext);
|
||||
|
||||
for (list2 = base_list; list2; list2 = g_slist_next (list2))
|
||||
{
|
||||
brush2 = GIMP_BRUSH (list2->data);
|
||||
|
||||
if (brush == brush2)
|
||||
continue;
|
||||
|
||||
if (! strcmp (GIMP_OBJECT (brush2)->name, new_name))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (list2);
|
||||
|
||||
gimp_object_set_name (GIMP_OBJECT (brush), new_name);
|
||||
g_free (new_name);
|
||||
|
||||
if (gimp_list_have (GIMP_LIST (brush_list), brush))
|
||||
{
|
||||
gtk_object_ref (GTK_OBJECT (brush));
|
||||
gimp_brush_list_remove (brush_list, brush);
|
||||
gimp_brush_list_add (brush_list, brush);
|
||||
gtk_object_unref (GTK_OBJECT (brush));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
brush_renamed (GimpBrush *brush,
|
||||
GimpBrushList *brush_list)
|
||||
{
|
||||
gimp_brush_list_uniquefy_brush_name (brush_list, brush);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_brush_list_add (GimpBrushList *brush_list,
|
||||
GimpBrush *brush)
|
||||
{
|
||||
gimp_brush_list_uniquefy_brush_name (brush_list, brush);
|
||||
gimp_list_add (GIMP_LIST (brush_list), brush);
|
||||
gtk_signal_connect (GTK_OBJECT (brush), "name_changed",
|
||||
GTK_SIGNAL_FUNC (brush_renamed),
|
||||
brush_list);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_brush_list_remove (GimpBrushList *brush_list,
|
||||
GimpBrush *brush)
|
||||
{
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (brush), brush_list);
|
||||
|
||||
gimp_list_remove (GIMP_LIST (brush_list), brush);
|
||||
}
|
||||
|
||||
gint
|
||||
gimp_brush_list_length (GimpBrushList *brush_list)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_BRUSH_LIST (brush_list), 0);
|
||||
|
||||
return brush_list->num_brushes;
|
||||
}
|
||||
|
||||
GimpBrush *
|
||||
gimp_brush_list_get_brush (GimpBrushList *blist,
|
||||
const gchar *name)
|
||||
{
|
||||
GimpObject *object;
|
||||
GSList *list;
|
||||
|
||||
if (blist == NULL || name == NULL)
|
||||
return NULL;
|
||||
|
||||
for (list = GIMP_LIST (blist)->list; list; list = g_slist_next (list))
|
||||
{
|
||||
object = (GimpObject *) list->data;
|
||||
|
||||
if (!strcmp (object->name, name))
|
||||
return GIMP_BRUSH (object);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -1,77 +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 __GIMP_BRUSH_LIST_H__
|
||||
#define __GIMP_BRUSH_LIST_H__
|
||||
|
||||
|
||||
#include "gimplist.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_BRUSH_LIST (gimp_brush_list_get_type ())
|
||||
#define GIMP_BRUSH_LIST(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_BRUSH_LIST, GimpBrushList))
|
||||
#define GIMP_BRUSH_LIST_CLASS(klass) (GTK_CHECK_CLASS_CAST (klass, GIMP_TYPE_BRUSH_LIST, GimpBrushListClass))
|
||||
#define GIMP_IS_BRUSH_LIST(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_BRUSH_LIST))
|
||||
#define GIMP_IS_BRUSH_LIST_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_BRUSH_LIST))
|
||||
|
||||
|
||||
|
||||
typedef struct _GimpBrushListClass GimpBrushListClass;
|
||||
|
||||
struct _GimpBrushList
|
||||
{
|
||||
GimpList parent_instance;
|
||||
|
||||
gint num_brushes;
|
||||
};
|
||||
|
||||
struct _GimpBrushListClass
|
||||
{
|
||||
GimpListClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
/* global variables */
|
||||
extern GimpBrushList *brush_list;
|
||||
|
||||
|
||||
/* function declarations */
|
||||
GimpBrushList * gimp_brush_list_new (void);
|
||||
GtkType gimp_brush_list_get_type (void);
|
||||
gint gimp_brush_list_length (GimpBrushList *list);
|
||||
|
||||
void gimp_brush_list_add (GimpBrushList *list,
|
||||
GimpBrush *brush);
|
||||
void gimp_brush_list_remove (GimpBrushList *list,
|
||||
GimpBrush *brush);
|
||||
|
||||
GimpBrush * gimp_brush_list_get_brush (GimpBrushList *list,
|
||||
const gchar *name);
|
||||
GimpBrush * gimp_brush_list_get_brush_by_index (GimpBrushList *list,
|
||||
gint index);
|
||||
|
||||
gint gimp_brush_list_get_brush_index (GimpBrushList *list,
|
||||
GimpBrush *brush);
|
||||
|
||||
|
||||
void brushes_init (gboolean no_data);
|
||||
void brushes_free (void);
|
||||
GimpBrush * brushes_get_standard_brush (void);
|
||||
|
||||
|
||||
#endif /* __GIMP_BRUSH_LIST_H__ */
|
|
@ -39,6 +39,8 @@ enum
|
|||
{
|
||||
ADD,
|
||||
REMOVE,
|
||||
HAVE,
|
||||
FOREACH,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
|
@ -88,7 +90,6 @@ gimp_container_init (GimpContainer *container)
|
|||
container->policy = GIMP_CONTAINER_POLICY_STRONG;
|
||||
container->num_children = 0;
|
||||
|
||||
container->children = NULL;
|
||||
container->handlers = NULL;
|
||||
}
|
||||
|
||||
|
@ -121,12 +122,35 @@ gimp_container_class_init (GimpContainerClass* klass)
|
|||
GTK_TYPE_NONE, 1,
|
||||
GIMP_TYPE_OBJECT);
|
||||
|
||||
container_signals[HAVE] =
|
||||
gtk_signal_new ("have",
|
||||
GTK_RUN_LAST,
|
||||
object_class->type,
|
||||
GTK_SIGNAL_OFFSET (GimpContainerClass,
|
||||
have),
|
||||
gtk_marshal_BOOL__POINTER,
|
||||
GTK_TYPE_BOOL, 1,
|
||||
GIMP_TYPE_OBJECT);
|
||||
|
||||
container_signals[FOREACH] =
|
||||
gtk_signal_new ("foreach",
|
||||
GTK_RUN_FIRST,
|
||||
object_class->type,
|
||||
GTK_SIGNAL_OFFSET (GimpContainerClass,
|
||||
foreach),
|
||||
gtk_marshal_NONE__POINTER_POINTER,
|
||||
GTK_TYPE_NONE, 2,
|
||||
GTK_TYPE_POINTER,
|
||||
GTK_TYPE_POINTER);
|
||||
|
||||
gtk_object_class_add_signals (object_class, container_signals, LAST_SIGNAL);
|
||||
|
||||
object_class->destroy = gimp_container_destroy;
|
||||
|
||||
klass->add = NULL;
|
||||
klass->remove = NULL;
|
||||
klass->add = NULL;
|
||||
klass->remove = NULL;
|
||||
klass->have = NULL;
|
||||
klass->foreach = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -136,12 +160,6 @@ gimp_container_destroy (GtkObject *object)
|
|||
|
||||
container = GIMP_CONTAINER (object);
|
||||
|
||||
while (container->children)
|
||||
{
|
||||
gimp_container_remove (container,
|
||||
GIMP_OBJECT (container->children->data));
|
||||
}
|
||||
|
||||
while (container->handlers)
|
||||
{
|
||||
gimp_container_remove_handler
|
||||
|
@ -164,24 +182,6 @@ gimp_container_child_destroy_callback (GtkObject *object,
|
|||
gimp_container_remove (container, GIMP_OBJECT (object));
|
||||
}
|
||||
|
||||
GimpContainer *
|
||||
gimp_container_new (GtkType children_type,
|
||||
GimpContainerPolicy policy)
|
||||
{
|
||||
GimpContainer *container;
|
||||
|
||||
g_return_val_if_fail (gtk_type_is_a (children_type, GIMP_TYPE_OBJECT), NULL);
|
||||
g_return_val_if_fail (policy == GIMP_CONTAINER_POLICY_STRONG ||
|
||||
policy == GIMP_CONTAINER_POLICY_WEAK, NULL);
|
||||
|
||||
container = gtk_type_new (GIMP_TYPE_CONTAINER);
|
||||
|
||||
container->children_type = children_type;
|
||||
container->policy = policy;
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
GtkType
|
||||
gimp_container_children_type (const GimpContainer *container)
|
||||
{
|
||||
|
@ -215,11 +215,12 @@ gimp_container_add (GimpContainer *container,
|
|||
g_return_val_if_fail (GTK_CHECK_TYPE (object, container->children_type),
|
||||
FALSE);
|
||||
|
||||
if (gimp_container_lookup (container, object))
|
||||
return FALSE;
|
||||
|
||||
container->children = g_list_prepend (container->children, object);
|
||||
container->num_children++;
|
||||
if (gimp_container_have (container, object))
|
||||
{
|
||||
g_warning ("%s(): container already contains object %p",
|
||||
__FUNCTION__, object);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
for (list = container->handlers; list; list = g_list_next (list))
|
||||
{
|
||||
|
@ -248,6 +249,8 @@ gimp_container_add (GimpContainer *container,
|
|||
break;
|
||||
}
|
||||
|
||||
container->num_children++;
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (container), container_signals[ADD], object);
|
||||
|
||||
return TRUE;
|
||||
|
@ -268,8 +271,12 @@ gimp_container_remove (GimpContainer *container,
|
|||
g_return_val_if_fail (GTK_CHECK_TYPE (object, container->children_type),
|
||||
FALSE);
|
||||
|
||||
if (! gimp_container_lookup (container, object))
|
||||
return FALSE;
|
||||
if (! gimp_container_have (container, object))
|
||||
{
|
||||
g_warning ("%s(): container does not contains object %p",
|
||||
__FUNCTION__, object);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
for (list = container->handlers; list; list = g_list_next (list))
|
||||
{
|
||||
|
@ -286,9 +293,6 @@ gimp_container_remove (GimpContainer *container,
|
|||
}
|
||||
}
|
||||
|
||||
container->children = g_list_remove (container->children, object);
|
||||
container->num_children--;
|
||||
|
||||
gtk_object_ref (GTK_OBJECT (object));
|
||||
|
||||
switch (container->policy)
|
||||
|
@ -305,21 +309,32 @@ gimp_container_remove (GimpContainer *container,
|
|||
break;
|
||||
}
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (container), container_signals[REMOVE], object);
|
||||
container->num_children--;
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (container), container_signals[REMOVE],
|
||||
object);
|
||||
|
||||
gtk_object_unref (GTK_OBJECT (object));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
const GList *
|
||||
gimp_container_lookup (const GimpContainer *container,
|
||||
const GimpObject *object)
|
||||
gboolean
|
||||
gimp_container_have (GimpContainer *container,
|
||||
GimpObject *object)
|
||||
{
|
||||
g_return_val_if_fail (container != NULL, NULL);
|
||||
g_return_val_if_fail (GIMP_IS_CONTAINER (container), NULL);
|
||||
gboolean have;
|
||||
|
||||
return g_list_find (container->children, (gpointer) object);
|
||||
g_return_val_if_fail (container != NULL, FALSE);
|
||||
g_return_val_if_fail (GIMP_IS_CONTAINER (container), FALSE);
|
||||
|
||||
if (container->num_children < 1)
|
||||
return FALSE;
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (container), container_signals[HAVE],
|
||||
object, &have);
|
||||
|
||||
return have;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -331,7 +346,24 @@ gimp_container_foreach (GimpContainer *container,
|
|||
g_return_if_fail (GIMP_IS_CONTAINER (container));
|
||||
g_return_if_fail (func != NULL);
|
||||
|
||||
g_list_foreach (container->children, func, user_data);
|
||||
if (container->num_children > 0)
|
||||
gtk_signal_emit (GTK_OBJECT (container), container_signals[FOREACH],
|
||||
func, user_data);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_container_add_handler_foreach_func (GimpObject *object,
|
||||
GimpContainerHandler *handler)
|
||||
{
|
||||
guint handler_id;
|
||||
|
||||
handler_id = gtk_signal_connect (GTK_OBJECT (object),
|
||||
handler->signame,
|
||||
handler->func,
|
||||
handler->user_data);
|
||||
|
||||
gtk_object_set_data_by_id (GTK_OBJECT (object), handler->quark,
|
||||
GUINT_TO_POINTER (handler_id));
|
||||
}
|
||||
|
||||
GQuark
|
||||
|
@ -341,10 +373,7 @@ gimp_container_add_handler (GimpContainer *container,
|
|||
gpointer callback_data)
|
||||
{
|
||||
GimpContainerHandler *handler;
|
||||
GtkObject *object;
|
||||
GList *list;
|
||||
gchar *key;
|
||||
guint handler_id;
|
||||
|
||||
g_return_val_if_fail (container != NULL, 0);
|
||||
g_return_val_if_fail (GIMP_IS_CONTAINER (container), 0);
|
||||
|
@ -368,30 +397,37 @@ gimp_container_add_handler (GimpContainer *container,
|
|||
|
||||
container->handlers = g_list_prepend (container->handlers, handler);
|
||||
|
||||
for (list = container->children; list; list = g_list_next (list))
|
||||
{
|
||||
object = GTK_OBJECT (list->data);
|
||||
|
||||
handler_id = gtk_signal_connect (object,
|
||||
handler->signame,
|
||||
handler->func,
|
||||
handler->user_data);
|
||||
|
||||
gtk_object_set_data_by_id (object, handler->quark,
|
||||
GUINT_TO_POINTER (handler_id));
|
||||
}
|
||||
gimp_container_foreach (container,
|
||||
(GFunc) gimp_container_add_handler_foreach_func,
|
||||
handler);
|
||||
|
||||
return handler->quark;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_container_remove_handler_foreach_func (GimpObject *object,
|
||||
GimpContainerHandler *handler)
|
||||
{
|
||||
guint handler_id;
|
||||
|
||||
handler_id =
|
||||
GPOINTER_TO_UINT (gtk_object_get_data_by_id (GTK_OBJECT (object),
|
||||
handler->quark));
|
||||
|
||||
if (handler_id)
|
||||
{
|
||||
gtk_signal_disconnect (GTK_OBJECT (object), handler_id);
|
||||
|
||||
gtk_object_set_data_by_id (GTK_OBJECT (object), handler->quark, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_container_remove_handler (GimpContainer *container,
|
||||
GQuark id)
|
||||
{
|
||||
GimpContainerHandler *handler;
|
||||
GtkObject *object;
|
||||
GList *list;
|
||||
guint handler_id;
|
||||
|
||||
g_return_if_fail (container != NULL);
|
||||
g_return_if_fail (GIMP_IS_CONTAINER (container));
|
||||
|
@ -411,20 +447,9 @@ gimp_container_remove_handler (GimpContainer *container,
|
|||
return;
|
||||
}
|
||||
|
||||
for (list = container->children; list; list = g_list_next (list))
|
||||
{
|
||||
object = GTK_OBJECT (list->data);
|
||||
|
||||
handler_id = GPOINTER_TO_UINT
|
||||
(gtk_object_get_data_by_id (object, handler->quark));
|
||||
|
||||
if (handler_id)
|
||||
{
|
||||
gtk_signal_disconnect (object, handler_id);
|
||||
|
||||
gtk_object_set_data_by_id (object, handler->quark, NULL);
|
||||
}
|
||||
}
|
||||
gimp_container_foreach (container,
|
||||
(GFunc) gimp_container_remove_handler_foreach_func,
|
||||
handler);
|
||||
|
||||
container->handlers = g_list_remove (container->handlers, handler);
|
||||
|
||||
|
|
|
@ -48,8 +48,6 @@ struct _GimpContainer
|
|||
GimpContainerPolicy policy;
|
||||
gint num_children;
|
||||
|
||||
GList *children;
|
||||
|
||||
/* private */
|
||||
GList *handlers;
|
||||
};
|
||||
|
@ -58,16 +56,19 @@ struct _GimpContainerClass
|
|||
{
|
||||
GimpObjectClass parent_class;
|
||||
|
||||
void (* add) (GimpContainer *container,
|
||||
GimpObject *object);
|
||||
void (* remove) (GimpContainer *container,
|
||||
GimpObject *object);
|
||||
void (* add) (GimpContainer *container,
|
||||
GimpObject *object);
|
||||
void (* remove) (GimpContainer *container,
|
||||
GimpObject *object);
|
||||
gboolean (* have) (GimpContainer *container,
|
||||
GimpObject *object);
|
||||
void (* foreach) (GimpContainer *container,
|
||||
GFunc func,
|
||||
gpointer user_data);
|
||||
};
|
||||
|
||||
|
||||
GtkType gimp_container_get_type (void);
|
||||
GimpContainer * gimp_container_new (GtkType children_type,
|
||||
GimpContainerPolicy policy);
|
||||
|
||||
GtkType gimp_container_children_type (const GimpContainer *container);
|
||||
GimpContainerPolicy gimp_container_policy (const GimpContainer *container);
|
||||
|
@ -78,8 +79,8 @@ gboolean gimp_container_add (GimpContainer *container,
|
|||
gboolean gimp_container_remove (GimpContainer *container,
|
||||
GimpObject *object);
|
||||
|
||||
const GList * gimp_container_lookup (const GimpContainer *container,
|
||||
const GimpObject *object);
|
||||
gboolean gimp_container_have (GimpContainer *container,
|
||||
GimpObject *object);
|
||||
void gimp_container_foreach (GimpContainer *container,
|
||||
GFunc func,
|
||||
gpointer user_data);
|
||||
|
|
|
@ -26,11 +26,12 @@
|
|||
|
||||
#include "apptypes.h"
|
||||
|
||||
#include "brushes.h"
|
||||
#include "context_manager.h"
|
||||
#include "gdisplay.h"
|
||||
#include "gimpbrush.h"
|
||||
#include "gimpbrushlist.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimplist.h"
|
||||
#include "gimpmarshal.h"
|
||||
#include "gimprc.h"
|
||||
#include "gradient_header.h"
|
||||
|
@ -871,9 +872,9 @@ gimp_context_image_changed (GimpContext *context)
|
|||
|
||||
/* handle disappearing images */
|
||||
static void
|
||||
gimp_context_image_removed (GimpSet *set,
|
||||
GimpImage *image,
|
||||
GimpContext *context)
|
||||
gimp_context_image_removed (GimpContainer *container,
|
||||
GimpImage *image,
|
||||
GimpContext *context)
|
||||
{
|
||||
if (context->image == image)
|
||||
gimp_context_real_set_image (context, NULL);
|
||||
|
@ -1346,7 +1347,7 @@ gimp_context_brush_dirty (GimpBrush *brush,
|
|||
|
||||
/* the active brush disappeared */
|
||||
static void
|
||||
gimp_context_brush_removed (GimpBrushList *brush_list,
|
||||
gimp_context_brush_removed (GimpContainer *brush_list,
|
||||
GimpBrush *brush,
|
||||
GimpContext *context)
|
||||
{
|
||||
|
@ -1454,15 +1455,16 @@ gimp_context_refresh_brush (GimpContext *context,
|
|||
if (! context->brush_name)
|
||||
context->brush_name = g_strdup (default_brush);
|
||||
|
||||
if ((brush = gimp_brush_list_get_brush (brush_list, context->brush_name)))
|
||||
if ((brush = (GimpBrush *) gimp_list_get_child_by_name (brush_list,
|
||||
context->brush_name)))
|
||||
{
|
||||
gimp_context_real_set_brush (context, brush);
|
||||
return;
|
||||
}
|
||||
|
||||
if (gimp_brush_list_length (brush_list))
|
||||
if (gimp_container_num_children (GIMP_CONTAINER (brush_list)))
|
||||
gimp_context_real_set_brush
|
||||
(context, gimp_brush_list_get_brush_by_index (brush_list, 0));
|
||||
(context, GIMP_BRUSH (gimp_list_get_child_by_index (brush_list, 0)));
|
||||
else
|
||||
gimp_context_real_set_brush (context, brushes_get_standard_brush ());
|
||||
}
|
||||
|
|
|
@ -0,0 +1,250 @@
|
|||
/* 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 <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpmath/gimpmath.h"
|
||||
|
||||
#include "apptypes.h"
|
||||
|
||||
#include "appenv.h"
|
||||
#include "gimpdatalist.h"
|
||||
|
||||
|
||||
static void gimp_data_list_class_init (GimpDataListClass *klass);
|
||||
static void gimp_data_list_init (GimpDataList *list);
|
||||
static void gimp_data_list_add (GimpContainer *container,
|
||||
GimpObject *object);
|
||||
static void gimp_data_list_remove (GimpContainer *container,
|
||||
GimpObject *object);
|
||||
|
||||
static void gimp_data_list_uniquefy_data_name (GimpDataList *data_list,
|
||||
GimpObject *object);
|
||||
static void gimp_data_list_object_renamed_callabck (GimpObject *object,
|
||||
GimpDataList *data_list);
|
||||
static gint gimp_data_list_data_compare_func (gconstpointer first,
|
||||
gconstpointer second);
|
||||
|
||||
|
||||
static GimpListClass *parent_class = NULL;
|
||||
|
||||
|
||||
GtkType
|
||||
gimp_data_list_get_type (void)
|
||||
{
|
||||
static GtkType type = 0;
|
||||
|
||||
if (!type)
|
||||
{
|
||||
GtkTypeInfo info =
|
||||
{
|
||||
"GimpDataList",
|
||||
sizeof (GimpDataList),
|
||||
sizeof (GimpDataListClass),
|
||||
(GtkClassInitFunc) gimp_data_list_class_init,
|
||||
(GtkObjectInitFunc) gimp_data_list_init,
|
||||
/* reserved_1 */ NULL,
|
||||
/* reserved_2 */ NULL,
|
||||
(GtkClassInitFunc) NULL
|
||||
};
|
||||
|
||||
type = gtk_type_unique (GIMP_TYPE_LIST, &info);
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_data_list_class_init (GimpDataListClass *klass)
|
||||
{
|
||||
GimpContainerClass *container_class;
|
||||
|
||||
container_class = (GimpContainerClass *) klass;
|
||||
|
||||
parent_class = gtk_type_class (GIMP_TYPE_LIST);
|
||||
|
||||
container_class->add = gimp_data_list_add;
|
||||
container_class->remove = gimp_data_list_remove;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_data_list_init (GimpDataList *list)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_data_list_add (GimpContainer *container,
|
||||
GimpObject *object)
|
||||
{
|
||||
GimpList *list;
|
||||
|
||||
list = GIMP_LIST (container);
|
||||
|
||||
gimp_data_list_uniquefy_data_name (GIMP_DATA_LIST (container), object);
|
||||
|
||||
list->list = g_list_insert_sorted (list->list, object,
|
||||
gimp_data_list_data_compare_func);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (object), "name_changed",
|
||||
GTK_SIGNAL_FUNC (gimp_data_list_object_renamed_callabck),
|
||||
container);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_data_list_remove (GimpContainer *container,
|
||||
GimpObject *object)
|
||||
{
|
||||
GimpList *list;
|
||||
|
||||
list = GIMP_LIST (container);
|
||||
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (object),
|
||||
gimp_data_list_object_renamed_callabck,
|
||||
container);
|
||||
|
||||
list->list = g_list_remove (list->list, object);
|
||||
}
|
||||
|
||||
GimpDataList *
|
||||
gimp_data_list_new (GtkType children_type)
|
||||
|
||||
{
|
||||
GimpDataList *list;
|
||||
|
||||
g_return_val_if_fail (gtk_type_is_a (children_type, GIMP_TYPE_OBJECT), NULL);
|
||||
|
||||
list = GIMP_DATA_LIST (gtk_type_new (GIMP_TYPE_DATA_LIST));
|
||||
|
||||
GIMP_CONTAINER (list)->children_type = children_type;
|
||||
GIMP_CONTAINER (list)->policy = GIMP_CONTAINER_POLICY_STRONG;
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_data_list_uniquefy_data_name (GimpDataList *data_list,
|
||||
GimpObject *object)
|
||||
{
|
||||
GList *base_list;
|
||||
GList *list;
|
||||
GList *list2;
|
||||
GimpObject *object2;
|
||||
gint unique_ext = 0;
|
||||
gchar *new_name = NULL;
|
||||
gchar *ext;
|
||||
|
||||
g_return_if_fail (GIMP_IS_DATA_LIST (data_list));
|
||||
g_return_if_fail (GIMP_IS_OBJECT (object));
|
||||
|
||||
base_list = GIMP_LIST (data_list)->list;
|
||||
|
||||
for (list = base_list; list; list = g_list_next (list))
|
||||
{
|
||||
object2 = GIMP_OBJECT (list->data);
|
||||
|
||||
if (object != object2 &&
|
||||
strcmp (gimp_object_get_name (GIMP_OBJECT (object)),
|
||||
gimp_object_get_name (GIMP_OBJECT (object2))) == 0)
|
||||
{
|
||||
ext = strrchr (GIMP_OBJECT (object)->name, '#');
|
||||
|
||||
if (ext)
|
||||
{
|
||||
gchar *ext_str;
|
||||
|
||||
unique_ext = atoi (ext + 1);
|
||||
|
||||
ext_str = g_strdup_printf ("%d", unique_ext);
|
||||
|
||||
/* check if the extension really is of the form "#<n>" */
|
||||
if (! strcmp (ext_str, ext + 1))
|
||||
{
|
||||
*ext = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
unique_ext = 0;
|
||||
}
|
||||
|
||||
g_free (ext_str);
|
||||
}
|
||||
else
|
||||
{
|
||||
unique_ext = 0;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
unique_ext++;
|
||||
|
||||
g_free (new_name);
|
||||
|
||||
new_name = g_strdup_printf ("%s#%d",
|
||||
GIMP_OBJECT (object)->name,
|
||||
unique_ext);
|
||||
|
||||
for (list2 = base_list; list2; list2 = g_list_next (list2))
|
||||
{
|
||||
object2 = GIMP_OBJECT (list2->data);
|
||||
|
||||
if (object == object2)
|
||||
continue;
|
||||
|
||||
if (! strcmp (GIMP_OBJECT (object2)->name, new_name))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (list2);
|
||||
|
||||
gimp_object_set_name (GIMP_OBJECT (object), new_name);
|
||||
g_free (new_name);
|
||||
|
||||
if (gimp_container_have (GIMP_CONTAINER (data_list), object))
|
||||
{
|
||||
gtk_object_ref (GTK_OBJECT (object));
|
||||
gimp_container_remove (GIMP_CONTAINER (data_list), object);
|
||||
gimp_container_add (GIMP_CONTAINER (data_list), object);
|
||||
gtk_object_unref (GTK_OBJECT (object));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_data_list_object_renamed_callabck (GimpObject *object,
|
||||
GimpDataList *data_list)
|
||||
{
|
||||
gimp_data_list_uniquefy_data_name (data_list, object);
|
||||
}
|
||||
|
||||
static gint
|
||||
gimp_data_list_data_compare_func (gconstpointer first,
|
||||
gconstpointer second)
|
||||
{
|
||||
return strcmp (((const GimpObject *) first)->name,
|
||||
((const GimpObject *) second)->name);
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/* 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 __GIMP_DATA_LIST_H__
|
||||
#define __GIMP_DATA_LIST_H__
|
||||
|
||||
|
||||
#include "gimplist.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_DATA_LIST (gimp_data_list_get_type ())
|
||||
#define GIMP_DATA_LIST(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_DATA_LIST, GimpDataList))
|
||||
#define GIMP_DATA_LIST_CLASS(klass) (GTK_CHECK_CLASS_CAST (klass, GIMP_TYPE_DATA_LIST, GimpDataListClass))
|
||||
#define GIMP_IS_DATA_LIST(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_DATA_LIST))
|
||||
#define GIMP_IS_DATA_LIST_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_DATA_LIST))
|
||||
|
||||
|
||||
typedef struct _GimpDataListClass GimpDataListClass;
|
||||
|
||||
struct _GimpDataList
|
||||
{
|
||||
GimpList parent_instance;
|
||||
};
|
||||
|
||||
struct _GimpDataListClass
|
||||
{
|
||||
GimpListClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
GtkType gimp_data_list_get_type (void);
|
||||
GimpDataList * gimp_data_list_new (GtkType children_type);
|
||||
|
||||
|
||||
#endif /* __GIMP_DATA_LIST_H__ */
|
|
@ -27,14 +27,15 @@
|
|||
|
||||
#include "apptypes.h"
|
||||
|
||||
#include "brushes.h"
|
||||
#include "fileops.h"
|
||||
#include "gimpimage.h"
|
||||
#include "gimpbrush.h"
|
||||
#include "gimpcontextpreview.h"
|
||||
#include "gimpdnd.h"
|
||||
#include "gimpbrushlist.h"
|
||||
#include "gimpdrawable.h"
|
||||
#include "gimpdrawablepreview.h"
|
||||
#include "gimplist.h"
|
||||
#include "gimprc.h"
|
||||
#include "gradient.h"
|
||||
#include "gradient_header.h"
|
||||
|
@ -660,7 +661,7 @@ gimp_dnd_set_brush_data (GtkWidget *widget,
|
|||
if (strcmp (name, "Standard") == 0)
|
||||
brush = brushes_get_standard_brush ();
|
||||
else
|
||||
brush = gimp_brush_list_get_brush (brush_list, name);
|
||||
brush = (GimpBrush *) gimp_list_get_child_by_name (brush_list, name);
|
||||
|
||||
if (brush)
|
||||
(* (GimpDndDropBrushFunc) set_brush_func) (widget, brush, set_brush_data);
|
||||
|
|
309
app/gimplist.c
309
app/gimplist.c
|
@ -18,95 +18,31 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "apptypes.h"
|
||||
|
||||
#include "gimpobject.h"
|
||||
#include "gimpcontainer.h"
|
||||
#include "gimplist.h"
|
||||
|
||||
|
||||
/* code mostly ripped from nether's gimpset class */
|
||||
|
||||
enum
|
||||
{
|
||||
ADD,
|
||||
REMOVE,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
static guint gimp_list_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
static GimpObjectClass *parent_class = NULL;
|
||||
static void gimp_list_class_init (GimpListClass *klass);
|
||||
static void gimp_list_init (GimpList *list);
|
||||
static void gimp_list_destroy (GtkObject *object);
|
||||
static void gimp_list_add (GimpContainer *container,
|
||||
GimpObject *object);
|
||||
static void gimp_list_remove (GimpContainer *container,
|
||||
GimpObject *object);
|
||||
static gboolean gimp_list_have (GimpContainer *container,
|
||||
GimpObject *object);
|
||||
static void gimp_list_foreach (GimpContainer *container,
|
||||
GFunc func,
|
||||
gpointer user_data);
|
||||
|
||||
|
||||
static void gimp_list_add_func (GimpList *list,
|
||||
gpointer object);
|
||||
static void gimp_list_remove_func (GimpList *list,
|
||||
gpointer object);
|
||||
static GimpContainerClass *parent_class = NULL;
|
||||
|
||||
|
||||
static void
|
||||
gimp_list_destroy (GtkObject *object)
|
||||
{
|
||||
GimpList *list = GIMP_LIST (object);
|
||||
|
||||
while (list->list) /* ought to put a sanity check in here... */
|
||||
{
|
||||
gimp_list_remove (list, list->list->data);
|
||||
}
|
||||
g_slist_free (list->list);
|
||||
|
||||
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
||||
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_list_init (GimpList *list)
|
||||
{
|
||||
list->list = NULL;
|
||||
list->type = GTK_TYPE_OBJECT;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_list_class_init (GimpListClass *klass)
|
||||
{
|
||||
GtkObjectClass *object_class;
|
||||
|
||||
object_class = (GtkObjectClass *) klass;
|
||||
|
||||
parent_class = gtk_type_class (GIMP_TYPE_OBJECT);
|
||||
|
||||
gimp_list_signals[ADD]=
|
||||
gtk_signal_new ("add",
|
||||
GTK_RUN_FIRST,
|
||||
object_class->type,
|
||||
GTK_SIGNAL_OFFSET (GimpListClass,
|
||||
add),
|
||||
gtk_marshal_NONE__POINTER,
|
||||
GTK_TYPE_NONE, 1,
|
||||
GTK_TYPE_POINTER);
|
||||
|
||||
gimp_list_signals[REMOVE]=
|
||||
gtk_signal_new ("remove",
|
||||
GTK_RUN_FIRST,
|
||||
object_class->type,
|
||||
GTK_SIGNAL_OFFSET (GimpListClass,
|
||||
remove),
|
||||
gtk_marshal_NONE__POINTER,
|
||||
GTK_TYPE_NONE, 1,
|
||||
GTK_TYPE_POINTER);
|
||||
|
||||
gtk_object_class_add_signals (object_class, gimp_list_signals, LAST_SIGNAL);
|
||||
|
||||
object_class->destroy = gimp_list_destroy;
|
||||
|
||||
klass->add = gimp_list_add_func;
|
||||
klass->remove = gimp_list_remove_func;
|
||||
}
|
||||
|
||||
GtkType
|
||||
gimp_list_get_type (void)
|
||||
{
|
||||
|
@ -126,123 +62,164 @@ gimp_list_get_type (void)
|
|||
(GtkClassInitFunc) NULL
|
||||
};
|
||||
|
||||
list_type = gtk_type_unique (GIMP_TYPE_OBJECT, &list_info);
|
||||
list_type = gtk_type_unique (GIMP_TYPE_CONTAINER, &list_info);
|
||||
}
|
||||
|
||||
return list_type;
|
||||
}
|
||||
|
||||
GimpList *
|
||||
gimp_list_new (GtkType type,
|
||||
gboolean weak)
|
||||
static void
|
||||
gimp_list_class_init (GimpListClass *klass)
|
||||
{
|
||||
GtkObjectClass *object_class;
|
||||
GimpContainerClass *container_class;
|
||||
|
||||
object_class = (GtkObjectClass *) klass;
|
||||
container_class = (GimpContainerClass *) klass;
|
||||
|
||||
parent_class = gtk_type_class (GIMP_TYPE_CONTAINER);
|
||||
|
||||
object_class->destroy = gimp_list_destroy;
|
||||
|
||||
container_class->add = gimp_list_add;
|
||||
container_class->remove = gimp_list_remove;
|
||||
container_class->have = gimp_list_have;
|
||||
container_class->foreach = gimp_list_foreach;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_list_init (GimpList *list)
|
||||
{
|
||||
list->list = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_list_destroy (GtkObject *object)
|
||||
{
|
||||
GimpList *list;
|
||||
|
||||
list = GIMP_LIST (object);
|
||||
|
||||
while (list->list)
|
||||
{
|
||||
gimp_container_remove (GIMP_CONTAINER (list),
|
||||
GIMP_OBJECT (list->list->data));
|
||||
}
|
||||
|
||||
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
||||
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_list_add (GimpContainer *container,
|
||||
GimpObject *object)
|
||||
{
|
||||
GimpList *list;
|
||||
|
||||
list = GIMP_LIST (container);
|
||||
|
||||
list->list = g_list_prepend (list->list, object);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_list_remove (GimpContainer *container,
|
||||
GimpObject *object)
|
||||
{
|
||||
GimpList *list;
|
||||
|
||||
list = GIMP_LIST (container);
|
||||
|
||||
list->list = g_list_remove (list->list, object);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_list_have (GimpContainer *container,
|
||||
GimpObject *object)
|
||||
{
|
||||
GimpList *list;
|
||||
|
||||
list = GIMP_LIST (container);
|
||||
|
||||
return g_list_find (list->list, object) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_list_foreach (GimpContainer *container,
|
||||
GFunc func,
|
||||
gpointer user_data)
|
||||
{
|
||||
GimpList *list;
|
||||
|
||||
list = GIMP_LIST (container);
|
||||
|
||||
g_list_foreach (list->list, func, user_data);
|
||||
}
|
||||
|
||||
GimpList *
|
||||
gimp_list_new (GtkType children_type,
|
||||
GimpContainerPolicy policy)
|
||||
{
|
||||
GimpList *list;
|
||||
|
||||
g_return_val_if_fail (gtk_type_is_a (children_type, GIMP_TYPE_OBJECT), NULL);
|
||||
g_return_val_if_fail (policy == GIMP_CONTAINER_POLICY_STRONG ||
|
||||
policy == GIMP_CONTAINER_POLICY_WEAK, NULL);
|
||||
|
||||
list = gtk_type_new (GIMP_TYPE_LIST);
|
||||
|
||||
list->type = type;
|
||||
list->weak = weak;
|
||||
GIMP_CONTAINER (list)->children_type = children_type;
|
||||
GIMP_CONTAINER (list)->policy = policy;
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_list_destroy_cb (GtkObject *object,
|
||||
gpointer data)
|
||||
GimpObject *
|
||||
gimp_list_get_child_by_name (const GimpList *list,
|
||||
const gchar *name)
|
||||
{
|
||||
GimpList *list;
|
||||
GimpObject *object;
|
||||
GList *glist;
|
||||
|
||||
list = GIMP_LIST (data);
|
||||
g_return_val_if_fail (list != NULL, NULL);
|
||||
g_return_val_if_fail (GIMP_IS_LIST (list), NULL);
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
|
||||
gimp_list_remove (list, object);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_list_add_func (GimpList *list,
|
||||
gpointer object)
|
||||
{
|
||||
list->list = g_slist_prepend (list->list, object);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_list_remove_func (GimpList *list,
|
||||
gpointer object)
|
||||
{
|
||||
list->list = g_slist_remove (list->list, object);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_list_add (GimpList *list,
|
||||
gpointer object)
|
||||
{
|
||||
g_return_val_if_fail (list, FALSE);
|
||||
g_return_val_if_fail (GTK_CHECK_TYPE (object, list->type), FALSE);
|
||||
|
||||
if (g_slist_find (list->list, object))
|
||||
return FALSE;
|
||||
|
||||
if (list->weak)
|
||||
for (glist = list->list; glist; glist = g_list_next (glist))
|
||||
{
|
||||
gtk_signal_connect (GTK_OBJECT (object), "destroy",
|
||||
GTK_SIGNAL_FUNC (gimp_list_destroy_cb),
|
||||
list);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_object_ref (GTK_OBJECT (object));
|
||||
gtk_object_sink (GTK_OBJECT (object));
|
||||
object = (GimpObject *) glist->data;
|
||||
|
||||
if (! strcmp (object->name, name))
|
||||
return object;
|
||||
}
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (list), gimp_list_signals[ADD], object);
|
||||
|
||||
return TRUE;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_list_remove (GimpList *list,
|
||||
gpointer object)
|
||||
GimpObject *
|
||||
gimp_list_get_child_by_index (const GimpList *list,
|
||||
gint index)
|
||||
{
|
||||
g_return_val_if_fail (list, FALSE);
|
||||
GList *glist;
|
||||
|
||||
if (!g_slist_find (list->list, object))
|
||||
{
|
||||
g_warning ("gimp_list_remove: can't find val");
|
||||
return FALSE;
|
||||
}
|
||||
g_return_val_if_fail (list != NULL, NULL);
|
||||
g_return_val_if_fail (GIMP_IS_LIST (list), NULL);
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (list), gimp_list_signals[REMOVE], object);
|
||||
glist = g_list_nth (list->list, index);
|
||||
|
||||
if (list->weak)
|
||||
{
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (object),
|
||||
GTK_SIGNAL_FUNC (gimp_list_destroy_cb),
|
||||
list);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_object_unref (GTK_OBJECT (object));
|
||||
}
|
||||
if (glist)
|
||||
return (GimpObject *) glist->data;
|
||||
|
||||
return TRUE;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_list_have (GimpList *list,
|
||||
gpointer object)
|
||||
gint
|
||||
gimp_list_get_child_index (const GimpList *list,
|
||||
const GimpObject *object)
|
||||
{
|
||||
return g_slist_find (list->list, object) ? TRUE : FALSE;
|
||||
}
|
||||
g_return_val_if_fail (list != NULL, 0);
|
||||
g_return_val_if_fail (GIMP_IS_LIST (list), 0);
|
||||
g_return_val_if_fail (object != NULL, 0);
|
||||
g_return_val_if_fail (GIMP_IS_OBJECT (list), 0);
|
||||
|
||||
void
|
||||
gimp_list_foreach (GimpList *list,
|
||||
GFunc func,
|
||||
gpointer user_data)
|
||||
{
|
||||
g_slist_foreach (list->list, func, user_data);
|
||||
}
|
||||
|
||||
GtkType
|
||||
gimp_list_type (GimpList *list)
|
||||
{
|
||||
return list->type;
|
||||
return g_list_index (list->list, (gpointer) object);
|
||||
}
|
||||
|
|
|
@ -20,14 +20,7 @@
|
|||
#define __GIMP_LIST_H__
|
||||
|
||||
|
||||
#include "gimpobject.h"
|
||||
|
||||
|
||||
/* GimpList - a typed list of objects with signals for adding and
|
||||
* removing of stuff. If it is weak, destroyed objects get removed
|
||||
* automatically. If it is not, it refs them so they won't be freed
|
||||
* till they are removed. (Though they can be destroyed, of course)
|
||||
*/
|
||||
#include "gimpcontainer.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_LIST (gimp_list_get_type ())
|
||||
|
@ -41,39 +34,27 @@ typedef struct _GimpListClass GimpListClass;
|
|||
|
||||
struct _GimpList
|
||||
{
|
||||
GimpObject parent_instance;
|
||||
GimpContainer parent_instance;
|
||||
|
||||
GtkType type;
|
||||
GSList *list;
|
||||
gboolean weak;
|
||||
GList *list;
|
||||
};
|
||||
|
||||
struct _GimpListClass
|
||||
{
|
||||
GimpObjectClass parent_class;
|
||||
|
||||
void (* add) (GimpList *list,
|
||||
gpointer object);
|
||||
void (* remove) (GimpList *list,
|
||||
gpointer object);
|
||||
GimpContainerClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
GtkType gimp_list_get_type (void);
|
||||
GtkType gimp_list_get_type (void);
|
||||
GimpList * gimp_list_new (GtkType children_type,
|
||||
GimpContainerPolicy policy);
|
||||
|
||||
GimpList * gimp_list_new (GtkType type,
|
||||
gboolean weak);
|
||||
|
||||
GtkType gimp_list_type (GimpList *list);
|
||||
gboolean gimp_list_add (GimpList *list,
|
||||
gpointer object);
|
||||
gboolean gimp_list_remove (GimpList *list,
|
||||
gpointer object);
|
||||
gboolean gimp_list_have (GimpList *list,
|
||||
gpointer object);
|
||||
void gimp_list_foreach (GimpList *list,
|
||||
GFunc func,
|
||||
gpointer user_data);
|
||||
GimpObject * gimp_list_get_child_by_name (const GimpList *list,
|
||||
const gchar *name);
|
||||
GimpObject * gimp_list_get_child_by_index (const GimpList *list,
|
||||
gint index);
|
||||
gint gimp_list_get_child_index (const GimpList *list,
|
||||
const GimpObject *object);
|
||||
|
||||
|
||||
#endif /* __GIMP_LIST_H__ */
|
||||
|
|
|
@ -30,9 +30,9 @@
|
|||
#include "brush_scale.h"
|
||||
#include "brush_edit.h"
|
||||
#include "brush_select.h"
|
||||
#include "brushes.h"
|
||||
#include "dialog_handler.h"
|
||||
#include "gimpbrushgenerated.h"
|
||||
#include "gimpbrushlist.h"
|
||||
#include "gimpbrushpipe.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimpdnd.h"
|
||||
|
@ -99,14 +99,10 @@ static void brush_select_select (BrushSelect *bsp,
|
|||
|
||||
static void brush_select_brush_dirty_callback (GimpBrush *brush,
|
||||
BrushSelect *bsp);
|
||||
static void connect_signals_to_brush (GimpBrush *brush,
|
||||
BrushSelect *bsp);
|
||||
static void disconnect_signals_from_brush (GimpBrush *brush,
|
||||
BrushSelect *bsp);
|
||||
static void brush_added_callback (GimpBrushList *list,
|
||||
static void brush_added_callback (GimpContainer *container,
|
||||
GimpBrush *brush,
|
||||
BrushSelect *bsp);
|
||||
static void brush_removed_callback (GimpBrushList *list,
|
||||
static void brush_removed_callback (GimpContainer *container,
|
||||
GimpBrush *brush,
|
||||
BrushSelect *bsp);
|
||||
|
||||
|
@ -314,7 +310,7 @@ brush_select_new (gchar *title,
|
|||
|
||||
if (title && init_name && strlen (init_name))
|
||||
{
|
||||
active = gimp_brush_list_get_brush (brush_list, init_name);
|
||||
active = (GimpBrush *) gimp_list_get_child_by_name (brush_list, init_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -528,9 +524,18 @@ brush_select_new (gchar *title,
|
|||
gtk_widget_show (vbox);
|
||||
|
||||
/* add callbacks to keep the display area current */
|
||||
gimp_list_foreach (GIMP_LIST (brush_list),
|
||||
(GFunc) connect_signals_to_brush,
|
||||
bsp);
|
||||
bsp->name_changed_handler_id =
|
||||
gimp_container_add_handler
|
||||
(GIMP_CONTAINER (brush_list), "name_changed",
|
||||
GTK_SIGNAL_FUNC (brush_select_brush_dirty_callback),
|
||||
bsp);
|
||||
|
||||
bsp->dirty_handler_id =
|
||||
gimp_container_add_handler
|
||||
(GIMP_CONTAINER (brush_list), "dirty",
|
||||
GTK_SIGNAL_FUNC (brush_select_brush_dirty_callback),
|
||||
bsp);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (brush_list), "add",
|
||||
GTK_SIGNAL_FUNC (brush_added_callback),
|
||||
bsp);
|
||||
|
@ -594,9 +599,11 @@ brush_select_free (BrushSelect *bsp)
|
|||
gtk_object_unref (GTK_OBJECT (bsp->context));
|
||||
}
|
||||
|
||||
gimp_list_foreach (GIMP_LIST (brush_list),
|
||||
(GFunc) disconnect_signals_from_brush,
|
||||
bsp);
|
||||
gimp_container_remove_handler (GIMP_CONTAINER (brush_list),
|
||||
bsp->name_changed_handler_id);
|
||||
gimp_container_remove_handler (GIMP_CONTAINER (brush_list),
|
||||
bsp->dirty_handler_id);
|
||||
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (brush_list), bsp);
|
||||
|
||||
g_free (bsp);
|
||||
|
@ -828,7 +835,7 @@ brush_select_select (BrushSelect *bsp,
|
|||
gint row, col;
|
||||
gint scroll_offset = 0;
|
||||
|
||||
index = gimp_brush_list_get_brush_index (brush_list, brush);
|
||||
index = gimp_list_get_child_index (brush_list, GIMP_OBJECT (brush));
|
||||
|
||||
if (index < 0)
|
||||
return;
|
||||
|
@ -878,7 +885,7 @@ brush_select_brush_dirty_callback (GimpBrush *brush,
|
|||
if (!bsp || bsp->freeze)
|
||||
return;
|
||||
|
||||
index = gimp_brush_list_get_brush_index (brush_list, brush);
|
||||
index = gimp_list_get_child_index (brush_list, GIMP_OBJECT (brush));
|
||||
redraw = (brush != gimp_context_get_brush (bsp->context));
|
||||
|
||||
clear_brush (bsp, brush,
|
||||
|
@ -892,32 +899,10 @@ brush_select_brush_dirty_callback (GimpBrush *brush,
|
|||
}
|
||||
|
||||
static void
|
||||
connect_signals_to_brush (GimpBrush *brush,
|
||||
BrushSelect *bsp)
|
||||
{
|
||||
gtk_signal_connect (GTK_OBJECT (brush), "dirty",
|
||||
GTK_SIGNAL_FUNC (brush_select_brush_dirty_callback),
|
||||
bsp);
|
||||
gtk_signal_connect (GTK_OBJECT (brush), "name_changed",
|
||||
GTK_SIGNAL_FUNC (brush_select_brush_dirty_callback),
|
||||
bsp);
|
||||
}
|
||||
|
||||
static void
|
||||
disconnect_signals_from_brush (GimpBrush *brush,
|
||||
BrushSelect *bsp)
|
||||
{
|
||||
if (!GTK_OBJECT_DESTROYED (brush))
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (brush), bsp);
|
||||
}
|
||||
|
||||
static void
|
||||
brush_added_callback (GimpBrushList *list,
|
||||
brush_added_callback (GimpContainer *container,
|
||||
GimpBrush *brush,
|
||||
BrushSelect *bsp)
|
||||
{
|
||||
connect_signals_to_brush (brush, bsp);
|
||||
|
||||
if (bsp->freeze)
|
||||
return;
|
||||
|
||||
|
@ -925,12 +910,10 @@ brush_added_callback (GimpBrushList *list,
|
|||
}
|
||||
|
||||
static void
|
||||
brush_removed_callback (GimpBrushList *list,
|
||||
brush_removed_callback (GimpContainer *container,
|
||||
GimpBrush *brush,
|
||||
BrushSelect *bsp)
|
||||
{
|
||||
disconnect_signals_from_brush (brush, bsp);
|
||||
|
||||
if (bsp->freeze)
|
||||
return;
|
||||
|
||||
|
@ -1368,7 +1351,8 @@ do_display_brush (GimpBrush *brush,
|
|||
static void
|
||||
display_brushes (BrushSelect *bsp)
|
||||
{
|
||||
if (brush_list == NULL || gimp_brush_list_length (brush_list) == 0)
|
||||
if (brush_list == NULL ||
|
||||
gimp_container_num_children (GIMP_CONTAINER (brush_list)) == 0)
|
||||
{
|
||||
gtk_widget_set_sensitive (bsp->options_box, FALSE);
|
||||
return;
|
||||
|
@ -1382,7 +1366,9 @@ display_brushes (BrushSelect *bsp)
|
|||
display_setup (bsp);
|
||||
|
||||
brush_counter = 0;
|
||||
gimp_list_foreach (GIMP_LIST (brush_list), (GFunc) do_display_brush, bsp);
|
||||
gimp_container_foreach (GIMP_CONTAINER (brush_list),
|
||||
(GFunc) do_display_brush,
|
||||
bsp);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1506,7 +1492,7 @@ preview_calc_scrollbar (BrushSelect *bsp)
|
|||
gint max;
|
||||
|
||||
bsp->scroll_offset = 0;
|
||||
num_rows = ((gimp_brush_list_length (brush_list) +
|
||||
num_rows = ((gimp_container_num_children (GIMP_CONTAINER (brush_list)) +
|
||||
(bsp->NUM_BRUSH_COLUMNS) - 1)
|
||||
/ (bsp->NUM_BRUSH_COLUMNS));
|
||||
max = num_rows * bsp->cell_width;
|
||||
|
@ -1547,7 +1533,8 @@ brush_select_resize (GtkWidget *widget,
|
|||
bsp->NUM_BRUSH_COLUMNS =
|
||||
(gint) (wid / cell_size);
|
||||
bsp->NUM_BRUSH_ROWS =
|
||||
(gint) ((gimp_brush_list_length (brush_list) + bsp->NUM_BRUSH_COLUMNS - 1) /
|
||||
(gint) ((gimp_container_num_children (GIMP_CONTAINER (brush_list)) +
|
||||
bsp->NUM_BRUSH_COLUMNS - 1) /
|
||||
bsp->NUM_BRUSH_COLUMNS);
|
||||
|
||||
bsp->cell_width = cell_size;
|
||||
|
@ -1580,7 +1567,7 @@ brush_select_events (GtkWidget *widget,
|
|||
index = row * bsp->NUM_BRUSH_COLUMNS + col;
|
||||
|
||||
/* Get the brush and check if it is editable */
|
||||
brush = gimp_brush_list_get_brush_by_index (brush_list, index);
|
||||
brush = GIMP_BRUSH (gimp_list_get_child_by_index (brush_list, index));
|
||||
if (GIMP_IS_BRUSH_GENERATED (brush))
|
||||
brush_select_edit_brush_callback (NULL, bsp);
|
||||
break;
|
||||
|
@ -1592,7 +1579,7 @@ brush_select_events (GtkWidget *widget,
|
|||
row = (bevent->y + bsp->scroll_offset) / bsp->cell_height;
|
||||
index = row * bsp->NUM_BRUSH_COLUMNS + col;
|
||||
|
||||
brush = gimp_brush_list_get_brush_by_index (brush_list, index);
|
||||
brush = (GimpBrush *) gimp_list_get_child_by_index (brush_list, index);
|
||||
|
||||
if (brush)
|
||||
bsp->dnd_brush = brush;
|
||||
|
@ -1719,7 +1706,7 @@ brush_select_scroll_update (GtkAdjustment *adjustment,
|
|||
|
||||
if (active)
|
||||
{
|
||||
index = gimp_brush_list_get_brush_index (brush_list, active);
|
||||
index = gimp_list_get_child_index (brush_list, GIMP_OBJECT (active));
|
||||
if (index < 0)
|
||||
return;
|
||||
row = index / bsp->NUM_BRUSH_COLUMNS;
|
||||
|
@ -1823,7 +1810,8 @@ brush_select_new_brush_callback (GtkWidget *widget,
|
|||
brush = gimp_brush_generated_new (10, .5, 0.0, 1.0);
|
||||
if (brush)
|
||||
{
|
||||
gimp_brush_list_add (brush_list, brush);
|
||||
gimp_container_add (GIMP_CONTAINER (brush_list),
|
||||
GIMP_OBJECT (brush));
|
||||
|
||||
gimp_context_set_brush (bsp->context, brush);
|
||||
|
||||
|
@ -1878,19 +1866,19 @@ brush_select_delete_brush_callback (GtkWidget *widget,
|
|||
|
||||
if (GIMP_IS_BRUSH_GENERATED (brush))
|
||||
{
|
||||
gint index;
|
||||
|
||||
gimp_brush_generated_delete (GIMP_BRUSH_GENERATED (brush));
|
||||
|
||||
brush_select_freeze_all ();
|
||||
|
||||
index = gimp_brush_list_get_brush_index (brush_list, brush);
|
||||
gimp_brush_list_remove (brush_list, GIMP_BRUSH (brush));
|
||||
gimp_container_remove (GIMP_CONTAINER (brush_list),
|
||||
GIMP_OBJECT (brush));
|
||||
gimp_context_refresh_brushes ();
|
||||
|
||||
brush_select_thaw_all ();
|
||||
}
|
||||
else
|
||||
/* this should never happen */
|
||||
g_message (_("Sorry, this brush can't be deleted."));
|
||||
{
|
||||
/* this should never happen */
|
||||
g_message (_("Sorry, this brush can't be deleted."));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,6 +73,9 @@ struct _BrushSelect
|
|||
|
||||
gboolean redraw;
|
||||
gboolean freeze; /* so we don't waste so much time during refresh */
|
||||
|
||||
GQuark name_changed_handler_id;
|
||||
GQuark dirty_handler_id;
|
||||
};
|
||||
|
||||
/* list of active dialogs */
|
||||
|
|
|
@ -200,26 +200,26 @@ gimp_colormap_dialog_class_init (GimpColormapDialogClass* klass)
|
|||
static void
|
||||
gimp_colormap_dialog_init (GimpColormapDialog *colormap_dialog)
|
||||
{
|
||||
colormap_dialog->image = NULL;
|
||||
colormap_dialog->col_index = 0;
|
||||
colormap_dialog->dnd_col_index = 0;
|
||||
colormap_dialog->vbox = NULL;
|
||||
colormap_dialog->palette = NULL;
|
||||
colormap_dialog->image_menu = NULL;
|
||||
colormap_dialog->popup_menu = NULL;
|
||||
colormap_dialog->option_menu = NULL;
|
||||
colormap_dialog->context = NULL;
|
||||
colormap_dialog->event_handler = 0;
|
||||
colormap_dialog->xn = 0;
|
||||
colormap_dialog->yn = 0;
|
||||
colormap_dialog->cellsize = 0;
|
||||
colormap_dialog->index_spinbutton = NULL;
|
||||
colormap_dialog->index_adjustment = NULL;
|
||||
colormap_dialog->color_entry = NULL;
|
||||
colormap_dialog->rename_handler = 0;
|
||||
colormap_dialog->cmap_changed_handler = 0;
|
||||
colormap_dialog->add_item = NULL;
|
||||
colormap_dialog->color_notebook = NULL;
|
||||
colormap_dialog->image = NULL;
|
||||
colormap_dialog->col_index = 0;
|
||||
colormap_dialog->dnd_col_index = 0;
|
||||
colormap_dialog->vbox = NULL;
|
||||
colormap_dialog->palette = NULL;
|
||||
colormap_dialog->image_menu = NULL;
|
||||
colormap_dialog->popup_menu = NULL;
|
||||
colormap_dialog->option_menu = NULL;
|
||||
colormap_dialog->context = NULL;
|
||||
colormap_dialog->event_handler = 0;
|
||||
colormap_dialog->xn = 0;
|
||||
colormap_dialog->yn = 0;
|
||||
colormap_dialog->cellsize = 0;
|
||||
colormap_dialog->index_spinbutton = NULL;
|
||||
colormap_dialog->index_adjustment = NULL;
|
||||
colormap_dialog->color_entry = NULL;
|
||||
colormap_dialog->rename_handler_id = 0;
|
||||
colormap_dialog->cmap_changed_handler_id = 0;
|
||||
colormap_dialog->add_item = NULL;
|
||||
colormap_dialog->color_notebook = NULL;
|
||||
}
|
||||
|
||||
GimpColormapDialog *
|
||||
|
@ -249,16 +249,19 @@ gimp_colormap_dialog_create (GimpContainer *context)
|
|||
|
||||
NULL);
|
||||
|
||||
ipal->image = NULL;
|
||||
ipal->context = context;
|
||||
ipal->cmap_changed_handler = gimp_container_add_handler (context,
|
||||
"colormap_changed",
|
||||
image_cmap_change_cb,
|
||||
ipal);
|
||||
ipal->rename_handler = gimp_container_add_handler (context,
|
||||
"name_changed",
|
||||
image_rename_cb,
|
||||
ipal);
|
||||
ipal->image = NULL;
|
||||
ipal->context = context;
|
||||
|
||||
ipal->cmap_changed_handler_id =
|
||||
gimp_container_add_handler (context,
|
||||
"colormap_changed",
|
||||
image_cmap_change_cb,
|
||||
ipal);
|
||||
ipal->rename_handler_id =
|
||||
gimp_container_add_handler (context,
|
||||
"name_changed",
|
||||
image_rename_cb,
|
||||
ipal);
|
||||
|
||||
accel_group = gtk_accel_group_new ();
|
||||
gtk_window_set_wmclass (GTK_WINDOW (ipal), "indexed_color_palette", "Gimp");
|
||||
|
@ -878,8 +881,8 @@ ipal_set_image (GimpColormapDialog *ipal,
|
|||
if (!ipal->image)
|
||||
gtk_signal_handler_unblock (GTK_OBJECT (ipal->palette),
|
||||
ipal->event_handler);
|
||||
g_return_if_fail (gimp_container_lookup (ipal->context,
|
||||
GIMP_OBJECT (gimage)));
|
||||
g_return_if_fail (gimp_container_have (ipal->context,
|
||||
GIMP_OBJECT (gimage)));
|
||||
g_return_if_fail (gimp_image_base_type (gimage) == INDEXED);
|
||||
ipal->image = gimage;
|
||||
ipal_draw (ipal);
|
||||
|
|
|
@ -53,8 +53,8 @@ struct _GimpColormapDialog
|
|||
GtkWidget *index_spinbutton;
|
||||
GtkAdjustment *index_adjustment;
|
||||
GtkEntry *color_entry;
|
||||
GimpSetHandlerId rename_handler;
|
||||
GimpSetHandlerId cmap_changed_handler;
|
||||
GQuark rename_handler_id;
|
||||
GQuark cmap_changed_handler_id;
|
||||
GtkWidget *add_item;
|
||||
ColorNotebook *color_notebook;
|
||||
};
|
||||
|
|
|
@ -29,13 +29,14 @@
|
|||
#include "apptypes.h"
|
||||
|
||||
#include "appenv.h"
|
||||
#include "brushes.h"
|
||||
#include "devices.h"
|
||||
#include "dialog_handler.h"
|
||||
#include "gimpbrush.h"
|
||||
#include "gimpcontextpreview.h"
|
||||
#include "gimpdnd.h"
|
||||
#include "gimpbrushlist.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimplist.h"
|
||||
#include "gimprc.h"
|
||||
#include "gradient.h"
|
||||
#include "gradient_header.h"
|
||||
|
@ -466,7 +467,7 @@ devices_rc_update (gchar *name,
|
|||
{
|
||||
GimpBrush *brush;
|
||||
|
||||
brush = gimp_brush_list_get_brush (brush_list, brush_name);
|
||||
brush = (GimpBrush *) gimp_list_get_child_by_name (brush_list, brush_name);
|
||||
|
||||
if (brush)
|
||||
{
|
||||
|
|
|
@ -345,7 +345,7 @@ info_window_change_display (GimpContext *context, /* NOT USED */
|
|||
|
||||
gimage = gdisp->gimage;
|
||||
|
||||
if (gimage && gimp_container_lookup (image_context, GIMP_OBJECT (gimage)))
|
||||
if (gimage && gimp_container_have (image_context, GIMP_OBJECT (gimage)))
|
||||
{
|
||||
iwd->gdisp = gdisp;
|
||||
info_window_update (gdisp);
|
||||
|
|
|
@ -29,13 +29,14 @@
|
|||
#include "apptypes.h"
|
||||
|
||||
#include "appenv.h"
|
||||
#include "brushes.h"
|
||||
#include "devices.h"
|
||||
#include "dialog_handler.h"
|
||||
#include "gimpbrush.h"
|
||||
#include "gimpcontextpreview.h"
|
||||
#include "gimpdnd.h"
|
||||
#include "gimpbrushlist.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimplist.h"
|
||||
#include "gimprc.h"
|
||||
#include "gradient.h"
|
||||
#include "gradient_header.h"
|
||||
|
@ -466,7 +467,7 @@ devices_rc_update (gchar *name,
|
|||
{
|
||||
GimpBrush *brush;
|
||||
|
||||
brush = gimp_brush_list_get_brush (brush_list, brush_name);
|
||||
brush = (GimpBrush *) gimp_list_get_child_by_name (brush_list, brush_name);
|
||||
|
||||
if (brush)
|
||||
{
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
#include "module_db.h"
|
||||
#include "gimprc.h"
|
||||
#include "datafiles.h"
|
||||
#include "gimpcontainer.h"
|
||||
#include "gimplist.h"
|
||||
|
||||
#include "libgimp/gimpenv.h"
|
||||
#include "libgimp/gimpmodule.h"
|
||||
|
@ -215,8 +215,8 @@ module_db_init (void)
|
|||
|
||||
/* Load and initialize gimp modules */
|
||||
|
||||
modules = gimp_container_new (MODULE_INFO_TYPE,
|
||||
GIMP_CONTAINER_POLICY_WEAK);
|
||||
modules = GIMP_CONTAINER (gimp_list_new (MODULE_INFO_TYPE,
|
||||
GIMP_CONTAINER_POLICY_WEAK));
|
||||
|
||||
if (g_module_supported ())
|
||||
datafiles_read_directories (module_path,
|
||||
|
|
|
@ -345,7 +345,7 @@ info_window_change_display (GimpContext *context, /* NOT USED */
|
|||
|
||||
gimage = gdisp->gimage;
|
||||
|
||||
if (gimage && gimp_container_lookup (image_context, GIMP_OBJECT (gimage)))
|
||||
if (gimage && gimp_container_have (image_context, GIMP_OBJECT (gimage)))
|
||||
{
|
||||
iwd->gdisp = gdisp;
|
||||
info_window_update (gdisp);
|
||||
|
|
|
@ -355,7 +355,7 @@ lc_dialog_image_menu_preview_update_callback (GtkWidget *widget,
|
|||
"menu_preview_gimage");
|
||||
|
||||
if (menu_preview && gimage && gimage_to_update == gimage &&
|
||||
gimp_container_lookup (image_context, (GimpObject *) gimage))
|
||||
gimp_container_have (image_context, (GimpObject *) gimage))
|
||||
{
|
||||
/* Must update the preview? */
|
||||
lc_dialog_fill_preview_with_thumb (menu_preview,
|
||||
|
@ -745,7 +745,7 @@ lc_dialog_change_image (GimpContext *context,
|
|||
if (! lc_dialog || ! lc_dialog->auto_follow_active)
|
||||
return;
|
||||
|
||||
if (gimage && gimp_container_lookup (image_context, GIMP_OBJECT (gimage)))
|
||||
if (gimage && gimp_container_have (image_context, GIMP_OBJECT (gimage)))
|
||||
{
|
||||
lc_dialog_update (gimage);
|
||||
lc_dialog_update_image_list ();
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
#include "module_db.h"
|
||||
#include "gimprc.h"
|
||||
#include "datafiles.h"
|
||||
#include "gimpcontainer.h"
|
||||
#include "gimplist.h"
|
||||
|
||||
#include "libgimp/gimpenv.h"
|
||||
#include "libgimp/gimpmodule.h"
|
||||
|
@ -215,8 +215,8 @@ module_db_init (void)
|
|||
|
||||
/* Load and initialize gimp modules */
|
||||
|
||||
modules = gimp_container_new (MODULE_INFO_TYPE,
|
||||
GIMP_CONTAINER_POLICY_WEAK);
|
||||
modules = GIMP_CONTAINER (gimp_list_new (MODULE_INFO_TYPE,
|
||||
GIMP_CONTAINER_POLICY_WEAK));
|
||||
|
||||
if (g_module_supported ())
|
||||
datafiles_read_directories (module_path,
|
||||
|
|
|
@ -1325,7 +1325,7 @@ nav_window_change_display (GimpContext *context, /* NOT USED */
|
|||
|
||||
gimage = gdisp->gimage;
|
||||
|
||||
if (gimage && gimp_container_lookup (image_context, GIMP_OBJECT (gimage)))
|
||||
if (gimage && gimp_container_have (image_context, GIMP_OBJECT (gimage)))
|
||||
{
|
||||
iwd->gdisp = gdisp;
|
||||
|
||||
|
|
|
@ -28,8 +28,10 @@
|
|||
#include "procedural_db.h"
|
||||
|
||||
#include "brush_select.h"
|
||||
#include "gimpbrushlist.h"
|
||||
#include "brushes.h"
|
||||
#include "gimpbrush.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimplist.h"
|
||||
|
||||
static ProcRecord brushes_popup_proc;
|
||||
static ProcRecord brushes_close_popup_proc;
|
||||
|
@ -253,10 +255,12 @@ brushes_set_popup_invoker (Argument *args)
|
|||
if ((prec = procedural_db_lookup (name)) &&
|
||||
(bsp = brush_get_brushselect (name)))
|
||||
{
|
||||
GimpBrush *active = gimp_brush_list_get_brush (brush_list, brush_name);
|
||||
GimpObject *object = gimp_list_get_child_by_name (brush_list, brush_name);
|
||||
|
||||
if (active)
|
||||
if (object)
|
||||
{
|
||||
GimpBrush *active = GIMP_BRUSH (object);
|
||||
|
||||
/* Updating the context updates the widgets as well */
|
||||
|
||||
gimp_context_set_brush (bsp->context, active);
|
||||
|
|
|
@ -27,8 +27,8 @@
|
|||
#include "apptypes.h"
|
||||
#include "procedural_db.h"
|
||||
|
||||
#include "brushes.h"
|
||||
#include "gimpbrush.h"
|
||||
#include "gimpbrushlist.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimplist.h"
|
||||
#include "temp_buf.h"
|
||||
|
@ -160,7 +160,7 @@ brushes_set_brush_invoker (Argument *args)
|
|||
{
|
||||
gboolean success = TRUE;
|
||||
gchar *name;
|
||||
GimpBrush *brush;
|
||||
GimpObject *object;
|
||||
|
||||
name = (gchar *) args[0].value.pdb_pointer;
|
||||
if (name == NULL)
|
||||
|
@ -168,10 +168,10 @@ brushes_set_brush_invoker (Argument *args)
|
|||
|
||||
if (success)
|
||||
{
|
||||
brush = gimp_brush_list_get_brush (brush_list, name);
|
||||
object = gimp_list_get_child_by_name (brush_list, name);
|
||||
|
||||
if (brush)
|
||||
gimp_context_set_brush (NULL, brush);
|
||||
if (object)
|
||||
gimp_context_set_brush (NULL, GIMP_BRUSH (object));
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
@ -441,10 +441,10 @@ brushes_list_invoker (Argument *args)
|
|||
gboolean success = TRUE;
|
||||
Argument *return_args;
|
||||
gchar **brushes;
|
||||
GSList *list = NULL;
|
||||
GList *list = NULL;
|
||||
int i = 0;
|
||||
|
||||
brushes = g_new (char *, brush_list->num_brushes);
|
||||
brushes = g_new (char *, GIMP_CONTAINER (brush_list)->num_children);
|
||||
|
||||
success = (list = GIMP_LIST (brush_list)->list) != NULL;
|
||||
|
||||
|
@ -458,7 +458,7 @@ brushes_list_invoker (Argument *args)
|
|||
|
||||
if (success)
|
||||
{
|
||||
return_args[1].value.pdb_int = brush_list->num_brushes;
|
||||
return_args[1].value.pdb_int = GIMP_CONTAINER (brush_list)->num_children;
|
||||
return_args[2].value.pdb_pointer = brushes;
|
||||
}
|
||||
|
||||
|
@ -513,11 +513,11 @@ brushes_get_brush_data_invoker (Argument *args)
|
|||
{
|
||||
if (strlen (name))
|
||||
{
|
||||
GSList *list;
|
||||
GList *list;
|
||||
|
||||
success = FALSE;
|
||||
|
||||
for (list = GIMP_LIST (brush_list)->list; list; list = g_slist_next (list))
|
||||
for (list = GIMP_LIST (brush_list)->list; list; list = g_list_next (list))
|
||||
{
|
||||
brush = (GimpBrush *) list->data;
|
||||
|
||||
|
|
|
@ -1144,8 +1144,8 @@ by_color_select_close_callback (GtkWidget *widget,
|
|||
|
||||
gimp_dialog_hide (bcd->shell);
|
||||
|
||||
if (bcd->gimage && gimp_container_lookup (image_context,
|
||||
GIMP_OBJECT (bcd->gimage)))
|
||||
if (bcd->gimage && gimp_container_have (image_context,
|
||||
GIMP_OBJECT (bcd->gimage)))
|
||||
{
|
||||
bcd->gimage->by_color_select = FALSE;
|
||||
}
|
||||
|
|
|
@ -1144,8 +1144,8 @@ by_color_select_close_callback (GtkWidget *widget,
|
|||
|
||||
gimp_dialog_hide (bcd->shell);
|
||||
|
||||
if (bcd->gimage && gimp_container_lookup (image_context,
|
||||
GIMP_OBJECT (bcd->gimage)))
|
||||
if (bcd->gimage && gimp_container_have (image_context,
|
||||
GIMP_OBJECT (bcd->gimage)))
|
||||
{
|
||||
bcd->gimage->by_color_select = FALSE;
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
#include "drawable.h"
|
||||
#include "gdisplay.h"
|
||||
#include "gimpbrushlist.h"
|
||||
#include "gimpbrush.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimpimage.h"
|
||||
|
|
|
@ -200,26 +200,26 @@ gimp_colormap_dialog_class_init (GimpColormapDialogClass* klass)
|
|||
static void
|
||||
gimp_colormap_dialog_init (GimpColormapDialog *colormap_dialog)
|
||||
{
|
||||
colormap_dialog->image = NULL;
|
||||
colormap_dialog->col_index = 0;
|
||||
colormap_dialog->dnd_col_index = 0;
|
||||
colormap_dialog->vbox = NULL;
|
||||
colormap_dialog->palette = NULL;
|
||||
colormap_dialog->image_menu = NULL;
|
||||
colormap_dialog->popup_menu = NULL;
|
||||
colormap_dialog->option_menu = NULL;
|
||||
colormap_dialog->context = NULL;
|
||||
colormap_dialog->event_handler = 0;
|
||||
colormap_dialog->xn = 0;
|
||||
colormap_dialog->yn = 0;
|
||||
colormap_dialog->cellsize = 0;
|
||||
colormap_dialog->index_spinbutton = NULL;
|
||||
colormap_dialog->index_adjustment = NULL;
|
||||
colormap_dialog->color_entry = NULL;
|
||||
colormap_dialog->rename_handler = 0;
|
||||
colormap_dialog->cmap_changed_handler = 0;
|
||||
colormap_dialog->add_item = NULL;
|
||||
colormap_dialog->color_notebook = NULL;
|
||||
colormap_dialog->image = NULL;
|
||||
colormap_dialog->col_index = 0;
|
||||
colormap_dialog->dnd_col_index = 0;
|
||||
colormap_dialog->vbox = NULL;
|
||||
colormap_dialog->palette = NULL;
|
||||
colormap_dialog->image_menu = NULL;
|
||||
colormap_dialog->popup_menu = NULL;
|
||||
colormap_dialog->option_menu = NULL;
|
||||
colormap_dialog->context = NULL;
|
||||
colormap_dialog->event_handler = 0;
|
||||
colormap_dialog->xn = 0;
|
||||
colormap_dialog->yn = 0;
|
||||
colormap_dialog->cellsize = 0;
|
||||
colormap_dialog->index_spinbutton = NULL;
|
||||
colormap_dialog->index_adjustment = NULL;
|
||||
colormap_dialog->color_entry = NULL;
|
||||
colormap_dialog->rename_handler_id = 0;
|
||||
colormap_dialog->cmap_changed_handler_id = 0;
|
||||
colormap_dialog->add_item = NULL;
|
||||
colormap_dialog->color_notebook = NULL;
|
||||
}
|
||||
|
||||
GimpColormapDialog *
|
||||
|
@ -249,16 +249,19 @@ gimp_colormap_dialog_create (GimpContainer *context)
|
|||
|
||||
NULL);
|
||||
|
||||
ipal->image = NULL;
|
||||
ipal->context = context;
|
||||
ipal->cmap_changed_handler = gimp_container_add_handler (context,
|
||||
"colormap_changed",
|
||||
image_cmap_change_cb,
|
||||
ipal);
|
||||
ipal->rename_handler = gimp_container_add_handler (context,
|
||||
"name_changed",
|
||||
image_rename_cb,
|
||||
ipal);
|
||||
ipal->image = NULL;
|
||||
ipal->context = context;
|
||||
|
||||
ipal->cmap_changed_handler_id =
|
||||
gimp_container_add_handler (context,
|
||||
"colormap_changed",
|
||||
image_cmap_change_cb,
|
||||
ipal);
|
||||
ipal->rename_handler_id =
|
||||
gimp_container_add_handler (context,
|
||||
"name_changed",
|
||||
image_rename_cb,
|
||||
ipal);
|
||||
|
||||
accel_group = gtk_accel_group_new ();
|
||||
gtk_window_set_wmclass (GTK_WINDOW (ipal), "indexed_color_palette", "Gimp");
|
||||
|
@ -878,8 +881,8 @@ ipal_set_image (GimpColormapDialog *ipal,
|
|||
if (!ipal->image)
|
||||
gtk_signal_handler_unblock (GTK_OBJECT (ipal->palette),
|
||||
ipal->event_handler);
|
||||
g_return_if_fail (gimp_container_lookup (ipal->context,
|
||||
GIMP_OBJECT (gimage)));
|
||||
g_return_if_fail (gimp_container_have (ipal->context,
|
||||
GIMP_OBJECT (gimage)));
|
||||
g_return_if_fail (gimp_image_base_type (gimage) == INDEXED);
|
||||
ipal->image = gimage;
|
||||
ipal_draw (ipal);
|
||||
|
|
|
@ -53,8 +53,8 @@ struct _GimpColormapDialog
|
|||
GtkWidget *index_spinbutton;
|
||||
GtkAdjustment *index_adjustment;
|
||||
GtkEntry *color_entry;
|
||||
GimpSetHandlerId rename_handler;
|
||||
GimpSetHandlerId cmap_changed_handler;
|
||||
GQuark rename_handler_id;
|
||||
GQuark cmap_changed_handler_id;
|
||||
GtkWidget *add_item;
|
||||
ColorNotebook *color_notebook;
|
||||
};
|
||||
|
|
|
@ -29,13 +29,14 @@
|
|||
#include "apptypes.h"
|
||||
|
||||
#include "appenv.h"
|
||||
#include "brushes.h"
|
||||
#include "devices.h"
|
||||
#include "dialog_handler.h"
|
||||
#include "gimpbrush.h"
|
||||
#include "gimpcontextpreview.h"
|
||||
#include "gimpdnd.h"
|
||||
#include "gimpbrushlist.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimplist.h"
|
||||
#include "gimprc.h"
|
||||
#include "gradient.h"
|
||||
#include "gradient_header.h"
|
||||
|
@ -466,7 +467,7 @@ devices_rc_update (gchar *name,
|
|||
{
|
||||
GimpBrush *brush;
|
||||
|
||||
brush = gimp_brush_list_get_brush (brush_list, brush_name);
|
||||
brush = (GimpBrush *) gimp_list_get_child_by_name (brush_list, brush_name);
|
||||
|
||||
if (brush)
|
||||
{
|
||||
|
|
|
@ -29,13 +29,14 @@
|
|||
#include "apptypes.h"
|
||||
|
||||
#include "appenv.h"
|
||||
#include "brushes.h"
|
||||
#include "devices.h"
|
||||
#include "dialog_handler.h"
|
||||
#include "gimpbrush.h"
|
||||
#include "gimpcontextpreview.h"
|
||||
#include "gimpdnd.h"
|
||||
#include "gimpbrushlist.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimplist.h"
|
||||
#include "gimprc.h"
|
||||
#include "gradient.h"
|
||||
#include "gradient_header.h"
|
||||
|
@ -466,7 +467,7 @@ devices_rc_update (gchar *name,
|
|||
{
|
||||
GimpBrush *brush;
|
||||
|
||||
brush = gimp_brush_list_get_brush (brush_list, brush_name);
|
||||
brush = (GimpBrush *) gimp_list_get_child_by_name (brush_list, brush_name);
|
||||
|
||||
if (brush)
|
||||
{
|
||||
|
|
|
@ -27,14 +27,15 @@
|
|||
|
||||
#include "apptypes.h"
|
||||
|
||||
#include "brushes.h"
|
||||
#include "fileops.h"
|
||||
#include "gimpimage.h"
|
||||
#include "gimpbrush.h"
|
||||
#include "gimpcontextpreview.h"
|
||||
#include "gimpdnd.h"
|
||||
#include "gimpbrushlist.h"
|
||||
#include "gimpdrawable.h"
|
||||
#include "gimpdrawablepreview.h"
|
||||
#include "gimplist.h"
|
||||
#include "gimprc.h"
|
||||
#include "gradient.h"
|
||||
#include "gradient_header.h"
|
||||
|
@ -660,7 +661,7 @@ gimp_dnd_set_brush_data (GtkWidget *widget,
|
|||
if (strcmp (name, "Standard") == 0)
|
||||
brush = brushes_get_standard_brush ();
|
||||
else
|
||||
brush = gimp_brush_list_get_brush (brush_list, name);
|
||||
brush = (GimpBrush *) gimp_list_get_child_by_name (brush_list, name);
|
||||
|
||||
if (brush)
|
||||
(* (GimpDndDropBrushFunc) set_brush_func) (widget, brush, set_brush_data);
|
||||
|
|
|
@ -125,17 +125,19 @@ sub brushes_set_popup {
|
|||
);
|
||||
|
||||
%invoke = (
|
||||
headers => [ qw("gimpbrushlist.h") ],
|
||||
headers => [ qw("brushes.h" "gimpbrush.h" "gimplist.h") ],
|
||||
vars => [ 'ProcRecord *prec', 'BrushSelect *bsp' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
if ((prec = procedural_db_lookup (name)) &&
|
||||
(bsp = brush_get_brushselect (name)))
|
||||
{
|
||||
GimpBrush *active = gimp_brush_list_get_brush (brush_list, brush_name);
|
||||
GimpObject *object = gimp_list_get_child_by_name (brush_list, brush_name);
|
||||
|
||||
if (active)
|
||||
if (object)
|
||||
{
|
||||
GimpBrush *active = GIMP_BRUSH (object);
|
||||
|
||||
/* Updating the context updates the widgets as well */
|
||||
|
||||
gimp_context_set_brush (bsp->context, active);
|
||||
|
|
|
@ -132,13 +132,13 @@ HELP
|
|||
@inargs = ( &brush_arg );
|
||||
|
||||
%invoke = (
|
||||
vars => [ 'GimpBrush *brush' ],
|
||||
vars => [ 'GimpObject *object' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
brush = gimp_brush_list_get_brush (brush_list, name);
|
||||
object = gimp_list_get_child_by_name (brush_list, name);
|
||||
|
||||
if (brush)
|
||||
gimp_context_set_brush (NULL, brush);
|
||||
if (object)
|
||||
gimp_context_set_brush (NULL, GIMP_BRUSH (object));
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
@ -262,14 +262,14 @@ HELP
|
|||
alias => 'brushes',
|
||||
array => { name => 'num_brushes',
|
||||
desc => 'The number of brushes in the brush list',
|
||||
alias => 'brush_list->num_brushes', no_declare => 1 } }
|
||||
alias => 'GIMP_CONTAINER (brush_list)->num_children', no_declare => 1 } }
|
||||
);
|
||||
|
||||
%invoke = (
|
||||
vars => [ 'GSList *list = NULL', 'int i = 0' ],
|
||||
vars => [ 'GList *list = NULL', 'int i = 0' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
brushes = g_new (char *, brush_list->num_brushes);
|
||||
brushes = g_new (char *, GIMP_CONTAINER (brush_list)->num_children);
|
||||
|
||||
success = (list = GIMP_LIST (brush_list)->list) != NULL;
|
||||
|
||||
|
@ -325,11 +325,11 @@ HELP
|
|||
{
|
||||
if (strlen (name))
|
||||
{
|
||||
GSList *list;
|
||||
GList *list;
|
||||
|
||||
success = FALSE;
|
||||
|
||||
for (list = GIMP_LIST (brush_list)->list; list; list = g_slist_next (list))
|
||||
for (list = GIMP_LIST (brush_list)->list; list; list = g_list_next (list))
|
||||
{
|
||||
brush = (GimpBrush *) list->data;
|
||||
|
||||
|
@ -354,7 +354,8 @@ CODE
|
|||
);
|
||||
}
|
||||
|
||||
@headers = qw("gimplist.h" "gimpbrush.h" "gimpbrushlist.h" "gimpcontext.h" "temp_buf.h");
|
||||
@headers = qw("brushes.h" "gimplist.h" "gimpbrush.h" "gimpcontext.h"
|
||||
"temp_buf.h");
|
||||
|
||||
@procs = qw(brushes_refresh brushes_get_brush brushes_set_brush
|
||||
brushes_get_opacity brushes_set_opacity brushes_get_spacing
|
||||
|
|
Loading…
Reference in New Issue