mirror of https://github.com/GNOME/gimp.git
added "set_by_type", "get_by_type" and "changed_by_type" methods which
2001-02-07 Michael Natterer <mitch@gimp.org> * app/gimpcontext.[ch]: added "set_by_type", "get_by_type" and "changed_by_type" methods which take a GtkType and decide from that if to manipulate the Brush, Pattern etc. * app/gimpcontainerview.[ch] * app/gimpcontainergridview.[ch] * app/gimpcontainerlistview.[ch]: added a GimpContext to the views which is used to manage the active item. * app/commands.c: pass the user_context to the test views. * app/gimpbrushpreview.c * app/gimppatternpreview.c * app/gimppreview.[ch]: added a virtual "needs_popup" method which returns a boolen indicating if the viewable is already fully visible. * app/gimage.[ch]: removed gimage_foreach() and some other functions which can easily be done be gimp_container_foreach(). Removed gimage_delete(). * app/fileops.c * app/gdisplay.c * app/lc_dialog.c * app/nav_window.c * app/palette_import.c * app/preferences_dialog.c * app/xcf.c * app/pdb/image_cmds.c * tools/pdbgen/pdb/image.pdb: changed accordingly. Switched from "disp_count" refcounting to real GtkObject refcounting for GimpImages.
This commit is contained in:
parent
3675004ef6
commit
c827d40a2c
35
ChangeLog
35
ChangeLog
|
@ -1,3 +1,38 @@
|
|||
2001-02-07 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/gimpcontext.[ch]: added "set_by_type", "get_by_type" and
|
||||
"changed_by_type" methods which take a GtkType and decide from
|
||||
that if to manipulate the Brush, Pattern etc.
|
||||
|
||||
* app/gimpcontainerview.[ch]
|
||||
* app/gimpcontainergridview.[ch]
|
||||
* app/gimpcontainerlistview.[ch]: added a GimpContext to the views
|
||||
which is used to manage the active item.
|
||||
|
||||
* app/commands.c: pass the user_context to the test views.
|
||||
|
||||
* app/gimpbrushpreview.c
|
||||
* app/gimppatternpreview.c
|
||||
* app/gimppreview.[ch]: added a virtual "needs_popup" method which
|
||||
returns a boolen indicating if the viewable is already fully
|
||||
visible.
|
||||
|
||||
* app/gimage.[ch]: removed gimage_foreach() and some other
|
||||
functions which can easily be done be gimp_container_foreach().
|
||||
Removed gimage_delete().
|
||||
|
||||
* app/fileops.c
|
||||
* app/gdisplay.c
|
||||
* app/lc_dialog.c
|
||||
* app/nav_window.c
|
||||
* app/palette_import.c
|
||||
* app/preferences_dialog.c
|
||||
* app/xcf.c
|
||||
* app/pdb/image_cmds.c
|
||||
* tools/pdbgen/pdb/image.pdb: changed accordingly. Switched from
|
||||
"disp_count" refcounting to real GtkObject refcounting for
|
||||
GimpImages.
|
||||
|
||||
2001-02-07 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/gimpbrush.[ch]
|
||||
|
|
|
@ -1332,6 +1332,7 @@ static void
|
|||
container_view_new (gboolean list,
|
||||
gchar *title,
|
||||
GimpContainer *container,
|
||||
GimpContext *context,
|
||||
gint preview_width,
|
||||
gint preview_height)
|
||||
{
|
||||
|
@ -1354,6 +1355,7 @@ container_view_new (gboolean list,
|
|||
if (list)
|
||||
{
|
||||
view = gimp_container_list_view_new (container,
|
||||
context,
|
||||
preview_width,
|
||||
preview_height,
|
||||
4, 4);
|
||||
|
@ -1361,6 +1363,7 @@ container_view_new (gboolean list,
|
|||
else
|
||||
{
|
||||
view = gimp_container_grid_view_new (container,
|
||||
context,
|
||||
preview_width,
|
||||
preview_height,
|
||||
4, 4);
|
||||
|
@ -1386,42 +1389,60 @@ void
|
|||
dialogs_test_image_container_list_view_cmd_callback (GtkWidget *widget,
|
||||
gpointer client_data)
|
||||
{
|
||||
container_view_new (TRUE, "Image List", image_context, 64, 64);
|
||||
container_view_new (TRUE, "Image List",
|
||||
image_context,
|
||||
gimp_context_get_user (),
|
||||
64, 64);
|
||||
}
|
||||
|
||||
void
|
||||
dialogs_test_pattern_container_list_view_cmd_callback (GtkWidget *widget,
|
||||
gpointer client_data)
|
||||
{
|
||||
container_view_new (TRUE, "Pattern List", global_pattern_list, 24, 24);
|
||||
container_view_new (TRUE, "Pattern List",
|
||||
global_pattern_list,
|
||||
gimp_context_get_user (),
|
||||
24, 24);
|
||||
}
|
||||
|
||||
void
|
||||
dialogs_test_brush_container_list_view_cmd_callback (GtkWidget *widget,
|
||||
gpointer client_data)
|
||||
{
|
||||
container_view_new (TRUE, "Brush List", global_brush_list, 24, 24);
|
||||
container_view_new (TRUE, "Brush List",
|
||||
global_brush_list,
|
||||
gimp_context_get_user (),
|
||||
24, 24);
|
||||
}
|
||||
|
||||
void
|
||||
dialogs_test_image_container_grid_view_cmd_callback (GtkWidget *widget,
|
||||
gpointer client_data)
|
||||
{
|
||||
container_view_new (FALSE, "Image Grid", image_context, 64, 64);
|
||||
container_view_new (FALSE, "Image Grid",
|
||||
image_context,
|
||||
gimp_context_get_user (),
|
||||
64, 64);
|
||||
}
|
||||
|
||||
void
|
||||
dialogs_test_pattern_container_grid_view_cmd_callback (GtkWidget *widget,
|
||||
gpointer client_data)
|
||||
{
|
||||
container_view_new (FALSE, "Pattern Grid", global_pattern_list, 24, 24);
|
||||
container_view_new (FALSE, "Pattern Grid",
|
||||
global_pattern_list,
|
||||
gimp_context_get_user (),
|
||||
24, 24);
|
||||
}
|
||||
|
||||
void
|
||||
dialogs_test_brush_container_grid_view_cmd_callback (GtkWidget *widget,
|
||||
gpointer client_data)
|
||||
{
|
||||
container_view_new (FALSE, "Brush Grid", global_brush_list, 32, 32);
|
||||
container_view_new (FALSE, "Brush Grid",
|
||||
global_brush_list,
|
||||
gimp_context_get_user (),
|
||||
32, 32);
|
||||
}
|
||||
|
||||
/***** Help *****/
|
||||
|
|
|
@ -1332,6 +1332,7 @@ static void
|
|||
container_view_new (gboolean list,
|
||||
gchar *title,
|
||||
GimpContainer *container,
|
||||
GimpContext *context,
|
||||
gint preview_width,
|
||||
gint preview_height)
|
||||
{
|
||||
|
@ -1354,6 +1355,7 @@ container_view_new (gboolean list,
|
|||
if (list)
|
||||
{
|
||||
view = gimp_container_list_view_new (container,
|
||||
context,
|
||||
preview_width,
|
||||
preview_height,
|
||||
4, 4);
|
||||
|
@ -1361,6 +1363,7 @@ container_view_new (gboolean list,
|
|||
else
|
||||
{
|
||||
view = gimp_container_grid_view_new (container,
|
||||
context,
|
||||
preview_width,
|
||||
preview_height,
|
||||
4, 4);
|
||||
|
@ -1386,42 +1389,60 @@ void
|
|||
dialogs_test_image_container_list_view_cmd_callback (GtkWidget *widget,
|
||||
gpointer client_data)
|
||||
{
|
||||
container_view_new (TRUE, "Image List", image_context, 64, 64);
|
||||
container_view_new (TRUE, "Image List",
|
||||
image_context,
|
||||
gimp_context_get_user (),
|
||||
64, 64);
|
||||
}
|
||||
|
||||
void
|
||||
dialogs_test_pattern_container_list_view_cmd_callback (GtkWidget *widget,
|
||||
gpointer client_data)
|
||||
{
|
||||
container_view_new (TRUE, "Pattern List", global_pattern_list, 24, 24);
|
||||
container_view_new (TRUE, "Pattern List",
|
||||
global_pattern_list,
|
||||
gimp_context_get_user (),
|
||||
24, 24);
|
||||
}
|
||||
|
||||
void
|
||||
dialogs_test_brush_container_list_view_cmd_callback (GtkWidget *widget,
|
||||
gpointer client_data)
|
||||
{
|
||||
container_view_new (TRUE, "Brush List", global_brush_list, 24, 24);
|
||||
container_view_new (TRUE, "Brush List",
|
||||
global_brush_list,
|
||||
gimp_context_get_user (),
|
||||
24, 24);
|
||||
}
|
||||
|
||||
void
|
||||
dialogs_test_image_container_grid_view_cmd_callback (GtkWidget *widget,
|
||||
gpointer client_data)
|
||||
{
|
||||
container_view_new (FALSE, "Image Grid", image_context, 64, 64);
|
||||
container_view_new (FALSE, "Image Grid",
|
||||
image_context,
|
||||
gimp_context_get_user (),
|
||||
64, 64);
|
||||
}
|
||||
|
||||
void
|
||||
dialogs_test_pattern_container_grid_view_cmd_callback (GtkWidget *widget,
|
||||
gpointer client_data)
|
||||
{
|
||||
container_view_new (FALSE, "Pattern Grid", global_pattern_list, 24, 24);
|
||||
container_view_new (FALSE, "Pattern Grid",
|
||||
global_pattern_list,
|
||||
gimp_context_get_user (),
|
||||
24, 24);
|
||||
}
|
||||
|
||||
void
|
||||
dialogs_test_brush_container_grid_view_cmd_callback (GtkWidget *widget,
|
||||
gpointer client_data)
|
||||
{
|
||||
container_view_new (FALSE, "Brush Grid", global_brush_list, 32, 32);
|
||||
container_view_new (FALSE, "Brush Grid",
|
||||
global_brush_list,
|
||||
gimp_context_get_user (),
|
||||
32, 32);
|
||||
}
|
||||
|
||||
/***** Help *****/
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "gimpbrush.h"
|
||||
#include "gimpcontainer.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimpimage.h"
|
||||
#include "gimpmarshal.h"
|
||||
#include "gimppattern.h"
|
||||
#include "gimprc.h"
|
||||
|
@ -41,6 +42,10 @@
|
|||
#include "temp_buf.h"
|
||||
|
||||
|
||||
typedef void (* GimpContextCopyArgFunc) (GimpContext *src,
|
||||
GimpContext *dest);
|
||||
|
||||
|
||||
#define context_return_if_fail(context) \
|
||||
g_return_if_fail ((context) != NULL); \
|
||||
g_return_if_fail (GIMP_IS_CONTEXT (context))
|
||||
|
@ -56,10 +61,19 @@
|
|||
while (!(((context)->defined_args) & arg_mask) && (context)->parent) \
|
||||
(context) = (context)->parent
|
||||
|
||||
typedef void (* GimpContextCopyArgFunc) (GimpContext *src, GimpContext *dest);
|
||||
|
||||
/* local function prototypes */
|
||||
|
||||
static void gimp_context_class_init (GimpContextClass *klass);
|
||||
static void gimp_context_init (GimpContext *context);
|
||||
static void gimp_context_destroy (GtkObject *object);
|
||||
static void gimp_context_set_arg (GtkObject *object,
|
||||
GtkArg *arg,
|
||||
guint arg_id);
|
||||
static void gimp_context_get_arg (GtkObject *object,
|
||||
GtkArg *arg,
|
||||
guint arg_id);
|
||||
|
||||
/* image */
|
||||
static void gimp_context_real_set_image (GimpContext *context,
|
||||
GimpImage *image);
|
||||
|
@ -130,7 +144,8 @@ static void gimp_context_real_set_gradient (GimpContext *context,
|
|||
static void gimp_context_copy_gradient (GimpContext *src,
|
||||
GimpContext *dest);
|
||||
|
||||
/* arguments */
|
||||
|
||||
/* arguments & signals */
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -147,6 +162,21 @@ enum
|
|||
ARG_GRADIENT
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
IMAGE_CHANGED,
|
||||
DISPLAY_CHANGED,
|
||||
TOOL_CHANGED,
|
||||
FOREGROUND_CHANGED,
|
||||
BACKGROUND_CHANGED,
|
||||
OPACITY_CHANGED,
|
||||
PAINT_MODE_CHANGED,
|
||||
BRUSH_CHANGED,
|
||||
PATTERN_CHANGED,
|
||||
GRADIENT_CHANGED,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
static gchar *gimp_context_arg_names[] =
|
||||
{
|
||||
"GimpContext::image",
|
||||
|
@ -175,25 +205,20 @@ static GimpContextCopyArgFunc gimp_context_copy_arg_funcs[] =
|
|||
gimp_context_copy_gradient
|
||||
};
|
||||
|
||||
/* signals */
|
||||
|
||||
enum
|
||||
static GtkType gimp_context_arg_types[] =
|
||||
{
|
||||
IMAGE_CHANGED,
|
||||
DISPLAY_CHANGED,
|
||||
TOOL_CHANGED,
|
||||
FOREGROUND_CHANGED,
|
||||
BACKGROUND_CHANGED,
|
||||
OPACITY_CHANGED,
|
||||
PAINT_MODE_CHANGED,
|
||||
BRUSH_CHANGED,
|
||||
PATTERN_CHANGED,
|
||||
GRADIENT_CHANGED,
|
||||
LAST_SIGNAL
|
||||
0,
|
||||
GTK_TYPE_NONE,
|
||||
GTK_TYPE_NONE,
|
||||
GTK_TYPE_NONE,
|
||||
GTK_TYPE_NONE,
|
||||
GTK_TYPE_NONE,
|
||||
GTK_TYPE_NONE,
|
||||
0,
|
||||
0,
|
||||
GTK_TYPE_NONE
|
||||
};
|
||||
|
||||
static guint gimp_context_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
static gchar *gimp_context_signal_names[] =
|
||||
{
|
||||
"image_changed",
|
||||
|
@ -222,6 +247,9 @@ static GtkSignalFunc gimp_context_signal_handlers[] =
|
|||
gimp_context_real_set_gradient
|
||||
};
|
||||
|
||||
|
||||
static guint gimp_context_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
static GimpObjectClass * parent_class = NULL;
|
||||
|
||||
/* the currently active context */
|
||||
|
@ -239,165 +267,10 @@ static GimpContext *standard_context = NULL;
|
|||
/* the list of all contexts */
|
||||
static GSList *context_list = NULL;
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* private functions *******************************************************/
|
||||
|
||||
static void
|
||||
gimp_context_set_arg (GtkObject *object,
|
||||
GtkArg *arg,
|
||||
guint arg_id)
|
||||
{
|
||||
GimpContext *context;
|
||||
|
||||
context = GIMP_CONTEXT (object);
|
||||
|
||||
switch (arg_id)
|
||||
{
|
||||
case ARG_IMAGE:
|
||||
gimp_context_set_image (context, GTK_VALUE_POINTER (*arg));
|
||||
break;
|
||||
case ARG_DISPLAY:
|
||||
gimp_context_set_display (context, GTK_VALUE_POINTER (*arg));
|
||||
break;
|
||||
case ARG_TOOL:
|
||||
gimp_context_set_tool (context, GTK_VALUE_INT (*arg));
|
||||
break;
|
||||
case ARG_FOREGROUND:
|
||||
gimp_context_set_foreground (context, GTK_VALUE_POINTER (*arg));
|
||||
break;
|
||||
case ARG_BACKGROUND:
|
||||
gimp_context_set_background (context, GTK_VALUE_POINTER (*arg));
|
||||
break;
|
||||
case ARG_OPACITY:
|
||||
gimp_context_set_opacity (context, GTK_VALUE_DOUBLE (*arg));
|
||||
break;
|
||||
case ARG_PAINT_MODE:
|
||||
gimp_context_set_paint_mode (context, GTK_VALUE_INT (*arg));
|
||||
break;
|
||||
case ARG_BRUSH:
|
||||
gimp_context_set_brush (context, GTK_VALUE_POINTER (*arg));
|
||||
break;
|
||||
case ARG_PATTERN:
|
||||
gimp_context_set_pattern (context, GTK_VALUE_POINTER (*arg));
|
||||
break;
|
||||
case ARG_GRADIENT:
|
||||
gimp_context_set_gradient (context, GTK_VALUE_POINTER (*arg));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_context_get_arg (GtkObject *object,
|
||||
GtkArg *arg,
|
||||
guint arg_id)
|
||||
{
|
||||
GimpContext *context;
|
||||
|
||||
context = GIMP_CONTEXT (object);
|
||||
|
||||
switch (arg_id)
|
||||
{
|
||||
case ARG_IMAGE:
|
||||
GTK_VALUE_POINTER (*arg) = gimp_context_get_image (context);
|
||||
break;
|
||||
case ARG_DISPLAY:
|
||||
GTK_VALUE_POINTER (*arg) = gimp_context_get_display (context);
|
||||
break;
|
||||
case ARG_TOOL:
|
||||
GTK_VALUE_INT (*arg) = gimp_context_get_tool (context);
|
||||
break;
|
||||
case ARG_FOREGROUND:
|
||||
gimp_context_get_foreground (context, GTK_VALUE_POINTER (*arg));
|
||||
break;
|
||||
case ARG_BACKGROUND:
|
||||
gimp_context_get_background (context, GTK_VALUE_POINTER (*arg));
|
||||
break;
|
||||
case ARG_OPACITY:
|
||||
GTK_VALUE_DOUBLE (*arg) = gimp_context_get_opacity (context);
|
||||
break;
|
||||
case ARG_PAINT_MODE:
|
||||
GTK_VALUE_INT (*arg) = gimp_context_get_paint_mode (context);
|
||||
break;
|
||||
case ARG_BRUSH:
|
||||
GTK_VALUE_POINTER (*arg) = gimp_context_get_brush (context);
|
||||
break;
|
||||
case ARG_PATTERN:
|
||||
GTK_VALUE_POINTER (*arg) = gimp_context_get_pattern (context);
|
||||
break;
|
||||
case ARG_GRADIENT:
|
||||
GTK_VALUE_POINTER (*arg) = gimp_context_get_gradient (context);
|
||||
break;
|
||||
default:
|
||||
arg->type = GTK_TYPE_INVALID;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_context_destroy (GtkObject *object)
|
||||
{
|
||||
GimpContext *context;
|
||||
|
||||
context = GIMP_CONTEXT (object);
|
||||
|
||||
if (context->parent)
|
||||
gimp_context_unset_parent (context);
|
||||
|
||||
if (context->image)
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (image_context), context);
|
||||
|
||||
if (context->display)
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (context->display->shell),
|
||||
context);
|
||||
|
||||
if (context->brush)
|
||||
{
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (context->brush),
|
||||
gimp_context_brush_dirty,
|
||||
context);
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (global_brush_list),
|
||||
gimp_context_brush_removed,
|
||||
context);
|
||||
gtk_object_unref (GTK_OBJECT (context->brush));
|
||||
}
|
||||
|
||||
if (context->brush_name)
|
||||
{
|
||||
g_free (context->brush_name);
|
||||
context->brush_name = NULL;
|
||||
}
|
||||
|
||||
if (context->pattern)
|
||||
{
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (context->pattern),
|
||||
gimp_context_pattern_dirty,
|
||||
context);
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (global_pattern_list),
|
||||
gimp_context_pattern_removed,
|
||||
context);
|
||||
gtk_object_unref (GTK_OBJECT (context->pattern));
|
||||
}
|
||||
|
||||
if (context->pattern_name)
|
||||
{
|
||||
g_free (context->pattern_name);
|
||||
context->pattern_name = NULL;
|
||||
}
|
||||
|
||||
if (context->gradient_name)
|
||||
{
|
||||
g_free (context->gradient_name);
|
||||
context->gradient_name = NULL;
|
||||
}
|
||||
|
||||
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
||||
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
||||
|
||||
context_list = g_slist_remove (context_list, context);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_context_class_init (GimpContextClass *klass)
|
||||
{
|
||||
|
@ -407,26 +280,40 @@ gimp_context_class_init (GimpContextClass *klass)
|
|||
|
||||
parent_class = gtk_type_class (GIMP_TYPE_OBJECT);
|
||||
|
||||
gimp_context_arg_types[GIMP_CONTEXT_ARG_IMAGE] = GIMP_TYPE_IMAGE;
|
||||
gimp_context_arg_types[GIMP_CONTEXT_ARG_BRUSH] = GIMP_TYPE_BRUSH;
|
||||
gimp_context_arg_types[GIMP_CONTEXT_ARG_PATTERN] = GIMP_TYPE_PATTERN;
|
||||
|
||||
gtk_object_add_arg_type (gimp_context_arg_names[IMAGE_CHANGED],
|
||||
GTK_TYPE_POINTER, GTK_ARG_READWRITE, ARG_IMAGE);
|
||||
GTK_TYPE_POINTER, GTK_ARG_READWRITE,
|
||||
ARG_IMAGE);
|
||||
gtk_object_add_arg_type (gimp_context_arg_names[DISPLAY_CHANGED],
|
||||
GTK_TYPE_POINTER, GTK_ARG_READWRITE, ARG_DISPLAY);
|
||||
GTK_TYPE_POINTER, GTK_ARG_READWRITE,
|
||||
ARG_DISPLAY);
|
||||
gtk_object_add_arg_type (gimp_context_arg_names[TOOL_CHANGED],
|
||||
GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_TOOL);
|
||||
GTK_TYPE_INT, GTK_ARG_READWRITE,
|
||||
ARG_TOOL);
|
||||
gtk_object_add_arg_type (gimp_context_arg_names[FOREGROUND_CHANGED],
|
||||
GTK_TYPE_POINTER, GTK_ARG_READWRITE, ARG_FOREGROUND);
|
||||
GTK_TYPE_POINTER, GTK_ARG_READWRITE,
|
||||
ARG_FOREGROUND);
|
||||
gtk_object_add_arg_type (gimp_context_arg_names[BACKGROUND_CHANGED],
|
||||
GTK_TYPE_POINTER, GTK_ARG_READWRITE, ARG_BACKGROUND);
|
||||
GTK_TYPE_POINTER, GTK_ARG_READWRITE,
|
||||
ARG_BACKGROUND);
|
||||
gtk_object_add_arg_type (gimp_context_arg_names[OPACITY_CHANGED],
|
||||
GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_OPACITY);
|
||||
GTK_TYPE_DOUBLE, GTK_ARG_READWRITE,
|
||||
ARG_OPACITY);
|
||||
gtk_object_add_arg_type (gimp_context_arg_names[PAINT_MODE_CHANGED],
|
||||
GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_PAINT_MODE);
|
||||
GTK_TYPE_INT, GTK_ARG_READWRITE,
|
||||
ARG_PAINT_MODE);
|
||||
gtk_object_add_arg_type (gimp_context_arg_names[BRUSH_CHANGED],
|
||||
GTK_TYPE_POINTER, GTK_ARG_READWRITE, ARG_BRUSH);
|
||||
GTK_TYPE_POINTER, GTK_ARG_READWRITE,
|
||||
ARG_BRUSH);
|
||||
gtk_object_add_arg_type (gimp_context_arg_names[PATTERN_CHANGED],
|
||||
GTK_TYPE_POINTER, GTK_ARG_READWRITE, ARG_PATTERN);
|
||||
GTK_TYPE_POINTER, GTK_ARG_READWRITE,
|
||||
ARG_PATTERN);
|
||||
gtk_object_add_arg_type (gimp_context_arg_names[GRADIENT_CHANGED],
|
||||
GTK_TYPE_POINTER, GTK_ARG_READWRITE, ARG_GRADIENT);
|
||||
GTK_TYPE_POINTER, GTK_ARG_READWRITE,
|
||||
ARG_GRADIENT);
|
||||
|
||||
gimp_context_signals[IMAGE_CHANGED] =
|
||||
gtk_signal_new (gimp_context_signal_names[IMAGE_CHANGED],
|
||||
|
@ -577,6 +464,162 @@ gimp_context_init (GimpContext *context)
|
|||
context_list = g_slist_prepend (context_list, context);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_context_destroy (GtkObject *object)
|
||||
{
|
||||
GimpContext *context;
|
||||
|
||||
context = GIMP_CONTEXT (object);
|
||||
|
||||
if (context->parent)
|
||||
gimp_context_unset_parent (context);
|
||||
|
||||
if (context->image)
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (image_context), context);
|
||||
|
||||
if (context->display)
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (context->display->shell),
|
||||
context);
|
||||
|
||||
if (context->brush)
|
||||
{
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (context->brush),
|
||||
gimp_context_brush_dirty,
|
||||
context);
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (global_brush_list),
|
||||
gimp_context_brush_removed,
|
||||
context);
|
||||
gtk_object_unref (GTK_OBJECT (context->brush));
|
||||
}
|
||||
|
||||
if (context->brush_name)
|
||||
{
|
||||
g_free (context->brush_name);
|
||||
context->brush_name = NULL;
|
||||
}
|
||||
|
||||
if (context->pattern)
|
||||
{
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (context->pattern),
|
||||
gimp_context_pattern_dirty,
|
||||
context);
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (global_pattern_list),
|
||||
gimp_context_pattern_removed,
|
||||
context);
|
||||
gtk_object_unref (GTK_OBJECT (context->pattern));
|
||||
}
|
||||
|
||||
if (context->pattern_name)
|
||||
{
|
||||
g_free (context->pattern_name);
|
||||
context->pattern_name = NULL;
|
||||
}
|
||||
|
||||
if (context->gradient_name)
|
||||
{
|
||||
g_free (context->gradient_name);
|
||||
context->gradient_name = NULL;
|
||||
}
|
||||
|
||||
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
||||
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
||||
|
||||
context_list = g_slist_remove (context_list, context);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_context_set_arg (GtkObject *object,
|
||||
GtkArg *arg,
|
||||
guint arg_id)
|
||||
{
|
||||
GimpContext *context;
|
||||
|
||||
context = GIMP_CONTEXT (object);
|
||||
|
||||
switch (arg_id)
|
||||
{
|
||||
case ARG_IMAGE:
|
||||
gimp_context_set_image (context, GTK_VALUE_POINTER (*arg));
|
||||
break;
|
||||
case ARG_DISPLAY:
|
||||
gimp_context_set_display (context, GTK_VALUE_POINTER (*arg));
|
||||
break;
|
||||
case ARG_TOOL:
|
||||
gimp_context_set_tool (context, GTK_VALUE_INT (*arg));
|
||||
break;
|
||||
case ARG_FOREGROUND:
|
||||
gimp_context_set_foreground (context, GTK_VALUE_POINTER (*arg));
|
||||
break;
|
||||
case ARG_BACKGROUND:
|
||||
gimp_context_set_background (context, GTK_VALUE_POINTER (*arg));
|
||||
break;
|
||||
case ARG_OPACITY:
|
||||
gimp_context_set_opacity (context, GTK_VALUE_DOUBLE (*arg));
|
||||
break;
|
||||
case ARG_PAINT_MODE:
|
||||
gimp_context_set_paint_mode (context, GTK_VALUE_INT (*arg));
|
||||
break;
|
||||
case ARG_BRUSH:
|
||||
gimp_context_set_brush (context, GTK_VALUE_POINTER (*arg));
|
||||
break;
|
||||
case ARG_PATTERN:
|
||||
gimp_context_set_pattern (context, GTK_VALUE_POINTER (*arg));
|
||||
break;
|
||||
case ARG_GRADIENT:
|
||||
gimp_context_set_gradient (context, GTK_VALUE_POINTER (*arg));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_context_get_arg (GtkObject *object,
|
||||
GtkArg *arg,
|
||||
guint arg_id)
|
||||
{
|
||||
GimpContext *context;
|
||||
|
||||
context = GIMP_CONTEXT (object);
|
||||
|
||||
switch (arg_id)
|
||||
{
|
||||
case ARG_IMAGE:
|
||||
GTK_VALUE_POINTER (*arg) = gimp_context_get_image (context);
|
||||
break;
|
||||
case ARG_DISPLAY:
|
||||
GTK_VALUE_POINTER (*arg) = gimp_context_get_display (context);
|
||||
break;
|
||||
case ARG_TOOL:
|
||||
GTK_VALUE_INT (*arg) = gimp_context_get_tool (context);
|
||||
break;
|
||||
case ARG_FOREGROUND:
|
||||
gimp_context_get_foreground (context, GTK_VALUE_POINTER (*arg));
|
||||
break;
|
||||
case ARG_BACKGROUND:
|
||||
gimp_context_get_background (context, GTK_VALUE_POINTER (*arg));
|
||||
break;
|
||||
case ARG_OPACITY:
|
||||
GTK_VALUE_DOUBLE (*arg) = gimp_context_get_opacity (context);
|
||||
break;
|
||||
case ARG_PAINT_MODE:
|
||||
GTK_VALUE_INT (*arg) = gimp_context_get_paint_mode (context);
|
||||
break;
|
||||
case ARG_BRUSH:
|
||||
GTK_VALUE_POINTER (*arg) = gimp_context_get_brush (context);
|
||||
break;
|
||||
case ARG_PATTERN:
|
||||
GTK_VALUE_POINTER (*arg) = gimp_context_get_pattern (context);
|
||||
break;
|
||||
case ARG_GRADIENT:
|
||||
GTK_VALUE_POINTER (*arg) = gimp_context_get_gradient (context);
|
||||
break;
|
||||
default:
|
||||
arg->type = GTK_TYPE_INVALID;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* public functions ********************************************************/
|
||||
|
||||
|
@ -863,6 +906,89 @@ gimp_context_copy_args (GimpContext *src,
|
|||
|
||||
/* attribute access functions */
|
||||
|
||||
/*****************************************************************************/
|
||||
/* manipulate by GtkType ***************************************************/
|
||||
|
||||
GimpContextArgType
|
||||
gimp_context_type_to_arg (GtkType type)
|
||||
{
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < GIMP_CONTEXT_NUM_ARGS; i++)
|
||||
{
|
||||
if (gimp_context_arg_types[i] == type)
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
const gchar *
|
||||
gimp_context_type_to_signal_name (GtkType type)
|
||||
{
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < GIMP_CONTEXT_NUM_ARGS; i++)
|
||||
{
|
||||
if (gimp_context_arg_types[i] == type)
|
||||
return gimp_context_signal_names[i];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GimpObject *
|
||||
gimp_context_get_by_type (GimpContext *context,
|
||||
GtkType type)
|
||||
{
|
||||
GimpContextArgType arg;
|
||||
GimpObject *object = NULL;
|
||||
|
||||
context_check_current (context);
|
||||
context_return_val_if_fail (context, NULL);
|
||||
g_return_val_if_fail ((arg = gimp_context_type_to_arg (type)) != -1, NULL);
|
||||
|
||||
gtk_object_get (GTK_OBJECT (context),
|
||||
gimp_context_arg_names[arg], &object,
|
||||
NULL);
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_context_set_by_type (GimpContext *context,
|
||||
GtkType type,
|
||||
GimpObject *object)
|
||||
{
|
||||
GimpContextArgType arg;
|
||||
|
||||
context_check_current (context);
|
||||
context_return_if_fail (context);
|
||||
g_return_if_fail ((arg = gimp_context_type_to_arg (type)) != -1);
|
||||
|
||||
gtk_object_set (GTK_OBJECT (context),
|
||||
gimp_context_arg_names[arg], object,
|
||||
NULL);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_context_changed_by_type (GimpContext *context,
|
||||
GtkType type)
|
||||
{
|
||||
GimpContextArgType arg;
|
||||
GimpObject *object;
|
||||
|
||||
context_check_current (context);
|
||||
context_return_if_fail (context);
|
||||
g_return_if_fail ((arg = gimp_context_type_to_arg (type)) != -1);
|
||||
|
||||
object = gimp_context_get_by_type (context, type);
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (context),
|
||||
gimp_context_signals[arg],
|
||||
object);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* image *******************************************************************/
|
||||
|
||||
|
|
|
@ -197,6 +197,17 @@ void gimp_context_copy_args (GimpContext *src,
|
|||
GimpContext *dest,
|
||||
GimpContextArgMask args_mask);
|
||||
|
||||
/* manipulate by GtkType */
|
||||
GimpContextArgType gimp_context_type_to_arg (GtkType type);
|
||||
const gchar * gimp_context_type_to_signal_name (GtkType type);
|
||||
GimpObject * gimp_context_get_by_type (GimpContext *context,
|
||||
GtkType type);
|
||||
void gimp_context_set_by_type (GimpContext *context,
|
||||
GtkType type,
|
||||
GimpObject *object);
|
||||
void gimp_context_changed_by_type (GimpContext *context,
|
||||
GtkType type);
|
||||
|
||||
/* image */
|
||||
GimpImage * gimp_context_get_image (GimpContext *context);
|
||||
void gimp_context_set_image (GimpContext *context,
|
||||
|
|
|
@ -127,7 +127,7 @@ gdisplay_new (GimpImage *gimage,
|
|||
guint scale)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
gchar title [MAX_TITLE_BUF];
|
||||
gchar title [MAX_TITLE_BUF];
|
||||
|
||||
/* If there isn't an interface, never create a gdisplay */
|
||||
if (no_interface)
|
||||
|
@ -215,6 +215,9 @@ gdisplay_new (GimpImage *gimage,
|
|||
gimage->instance_count++; /* this is obsolete */
|
||||
gimage->disp_count++;
|
||||
|
||||
gtk_object_ref (GTK_OBJECT (gimage));
|
||||
gtk_object_sink (GTK_OBJECT (gimage));
|
||||
|
||||
lc_dialog_preview_update (gimage);
|
||||
|
||||
/* We're interested in clean and dirty signals so we can update the
|
||||
|
@ -420,7 +423,7 @@ gdisplay_delete (GDisplay *gdisp)
|
|||
|
||||
/* free the gimage */
|
||||
gdisp->gimage->disp_count--;
|
||||
gimage_delete (gdisp->gimage);
|
||||
gtk_object_unref (GTK_OBJECT (gdisp->gimage));
|
||||
|
||||
if (gdisp->nav_popup)
|
||||
nav_popup_free (gdisp->nav_popup);
|
||||
|
@ -2367,7 +2370,7 @@ gdisplay_reconnect (GDisplay *gdisp,
|
|||
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (gdisp->gimage), gdisp);
|
||||
gdisp->gimage->disp_count--;
|
||||
gimage_delete (gdisp->gimage);
|
||||
gtk_object_unref (GTK_OBJECT (gdisp->gimage));
|
||||
|
||||
instance = gimage->instance_count;
|
||||
gimage->instance_count++;
|
||||
|
@ -2376,6 +2379,9 @@ gdisplay_reconnect (GDisplay *gdisp,
|
|||
gdisp->gimage = gimage;
|
||||
gdisp->instance = instance;
|
||||
|
||||
gtk_object_ref (GTK_OBJECT (gimage));
|
||||
gtk_object_sink (GTK_OBJECT (gimage));
|
||||
|
||||
/* reconnect our clean / dirty signals */
|
||||
gtk_signal_connect (GTK_OBJECT (gimage), "dirty",
|
||||
GTK_SIGNAL_FUNC(gdisplay_cleandirty_handler), gdisp);
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
#include "context_manager.h"
|
||||
#include "gimage.h"
|
||||
#include "gimpcontainer.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimpimage.h"
|
||||
#include "gimppalette.h"
|
||||
|
@ -45,16 +46,14 @@
|
|||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
/* New palette code... */
|
||||
|
||||
#define IMPORT_PREVIEW_WIDTH 80
|
||||
#define IMPORT_PREVIEW_HEIGHT 80
|
||||
#define MAX_IMAGE_COLORS (10000*2)
|
||||
#define MAX_IMAGE_COLORS (10000 * 2)
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GRAD_IMPORT = 0,
|
||||
IMAGE_IMPORT = 1,
|
||||
GRAD_IMPORT = 0,
|
||||
IMAGE_IMPORT = 1,
|
||||
INDEXED_IMPORT = 2
|
||||
} ImportType;
|
||||
|
||||
|
@ -317,11 +316,15 @@ palette_import_image_menu_activate (gint redo,
|
|||
/* Get list of images */
|
||||
if (import_dialog->import_type == INDEXED_IMPORT)
|
||||
{
|
||||
gimage_foreach (palette_import_gimlist_indexed_cb, &list);
|
||||
gimp_container_foreach (image_context,
|
||||
palette_import_gimlist_indexed_cb,
|
||||
&list);
|
||||
}
|
||||
else
|
||||
{
|
||||
gimage_foreach (palette_import_gimlist_cb, &list);
|
||||
gimp_container_foreach (image_context,
|
||||
palette_import_gimlist_cb,
|
||||
&list);
|
||||
}
|
||||
|
||||
num_images = g_slist_length (list);
|
||||
|
@ -445,11 +448,15 @@ palette_import_image_count (ImportType type)
|
|||
|
||||
if (type == INDEXED_IMPORT)
|
||||
{
|
||||
gimage_foreach (palette_import_gimlist_indexed_cb, &list);
|
||||
gimp_container_foreach (image_context,
|
||||
palette_import_gimlist_indexed_cb,
|
||||
&list);
|
||||
}
|
||||
else
|
||||
{
|
||||
gimage_foreach (palette_import_gimlist_cb, &list);
|
||||
gimp_container_foreach (image_context,
|
||||
palette_import_gimlist_cb,
|
||||
&list);
|
||||
}
|
||||
|
||||
num_images = g_slist_length (list);
|
||||
|
|
|
@ -32,8 +32,9 @@
|
|||
#include "cursorutil.h"
|
||||
#include "gdisplay_ops.h"
|
||||
#include "gdisplay.h"
|
||||
#include "gimage.h"
|
||||
#include "gimpcontainer.h"
|
||||
#include "gimphelp.h"
|
||||
#include "gimpimage.h"
|
||||
#include "gimprc.h"
|
||||
#include "image_render.h"
|
||||
#include "lc_dialog.h"
|
||||
|
@ -907,8 +908,12 @@ prefs_cancel_callback (GtkWidget *widget,
|
|||
transparency_size = old_transparency_size;
|
||||
|
||||
render_setup (transparency_type, transparency_size);
|
||||
gimage_foreach ((GFunc) gimp_image_invalidate_layer_previews, NULL);
|
||||
gimage_invalidate_previews ();
|
||||
gimp_container_foreach (image_context,
|
||||
(GFunc) gimp_image_invalidate_layer_previews,
|
||||
NULL);
|
||||
gimp_container_foreach (image_context,
|
||||
(GFunc) gimp_viewable_invalidate_preview,
|
||||
NULL);
|
||||
gdisplays_expose_full ();
|
||||
gdisplays_flush ();
|
||||
}
|
||||
|
@ -994,8 +999,12 @@ prefs_toggle_callback (GtkWidget *widget,
|
|||
*val = (gint) gtk_object_get_user_data (GTK_OBJECT (widget));
|
||||
|
||||
render_setup (transparency_type, transparency_size);
|
||||
gimage_foreach ((GFunc) gimp_image_invalidate_layer_previews, NULL);
|
||||
gimage_invalidate_previews ();
|
||||
gimp_container_foreach (image_context,
|
||||
(GFunc) gimp_image_invalidate_layer_previews,
|
||||
NULL);
|
||||
gimp_container_foreach (image_context,
|
||||
(GFunc) gimp_viewable_invalidate_preview,
|
||||
NULL);
|
||||
gdisplays_expose_full ();
|
||||
gdisplays_flush ();
|
||||
}
|
||||
|
|
|
@ -127,7 +127,7 @@ gdisplay_new (GimpImage *gimage,
|
|||
guint scale)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
gchar title [MAX_TITLE_BUF];
|
||||
gchar title [MAX_TITLE_BUF];
|
||||
|
||||
/* If there isn't an interface, never create a gdisplay */
|
||||
if (no_interface)
|
||||
|
@ -215,6 +215,9 @@ gdisplay_new (GimpImage *gimage,
|
|||
gimage->instance_count++; /* this is obsolete */
|
||||
gimage->disp_count++;
|
||||
|
||||
gtk_object_ref (GTK_OBJECT (gimage));
|
||||
gtk_object_sink (GTK_OBJECT (gimage));
|
||||
|
||||
lc_dialog_preview_update (gimage);
|
||||
|
||||
/* We're interested in clean and dirty signals so we can update the
|
||||
|
@ -420,7 +423,7 @@ gdisplay_delete (GDisplay *gdisp)
|
|||
|
||||
/* free the gimage */
|
||||
gdisp->gimage->disp_count--;
|
||||
gimage_delete (gdisp->gimage);
|
||||
gtk_object_unref (GTK_OBJECT (gdisp->gimage));
|
||||
|
||||
if (gdisp->nav_popup)
|
||||
nav_popup_free (gdisp->nav_popup);
|
||||
|
@ -2367,7 +2370,7 @@ gdisplay_reconnect (GDisplay *gdisp,
|
|||
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (gdisp->gimage), gdisp);
|
||||
gdisp->gimage->disp_count--;
|
||||
gimage_delete (gdisp->gimage);
|
||||
gtk_object_unref (GTK_OBJECT (gdisp->gimage));
|
||||
|
||||
instance = gimage->instance_count;
|
||||
gimage->instance_count++;
|
||||
|
@ -2376,6 +2379,9 @@ gdisplay_reconnect (GDisplay *gdisp,
|
|||
gdisp->gimage = gimage;
|
||||
gdisp->instance = instance;
|
||||
|
||||
gtk_object_ref (GTK_OBJECT (gimage));
|
||||
gtk_object_sink (GTK_OBJECT (gimage));
|
||||
|
||||
/* reconnect our clean / dirty signals */
|
||||
gtk_signal_connect (GTK_OBJECT (gimage), "dirty",
|
||||
GTK_SIGNAL_FUNC(gdisplay_cleandirty_handler), gdisp);
|
||||
|
|
|
@ -1532,7 +1532,7 @@ nav_window_get_gdisp (void)
|
|||
GDisplay *gdisp = NULL;
|
||||
GimpImage *gimage;
|
||||
|
||||
gimage_foreach (gimlist_cb, &list);
|
||||
gimp_container_foreach (image_context, gimlist_cb, &list);
|
||||
|
||||
if (!list)
|
||||
return NULL;
|
||||
|
|
|
@ -1532,7 +1532,7 @@ nav_window_get_gdisp (void)
|
|||
GDisplay *gdisp = NULL;
|
||||
GimpImage *gimage;
|
||||
|
||||
gimage_foreach (gimlist_cb, &list);
|
||||
gimp_container_foreach (image_context, gimlist_cb, &list);
|
||||
|
||||
if (!list)
|
||||
return NULL;
|
||||
|
|
|
@ -1641,7 +1641,7 @@ file_open_genbutton_callback (GtkWidget *widget,
|
|||
}
|
||||
set_preview (full_filename, RGBbuf, RGBbuf_w, RGBbuf_h);
|
||||
|
||||
gimage_delete (gimage_to_be_thumbed);
|
||||
gtk_object_unref (GTK_OBJECT (gimage_to_be_thumbed));
|
||||
|
||||
if (RGBbuf)
|
||||
g_free (RGBbuf);
|
||||
|
|
|
@ -127,7 +127,7 @@ gdisplay_new (GimpImage *gimage,
|
|||
guint scale)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
gchar title [MAX_TITLE_BUF];
|
||||
gchar title [MAX_TITLE_BUF];
|
||||
|
||||
/* If there isn't an interface, never create a gdisplay */
|
||||
if (no_interface)
|
||||
|
@ -215,6 +215,9 @@ gdisplay_new (GimpImage *gimage,
|
|||
gimage->instance_count++; /* this is obsolete */
|
||||
gimage->disp_count++;
|
||||
|
||||
gtk_object_ref (GTK_OBJECT (gimage));
|
||||
gtk_object_sink (GTK_OBJECT (gimage));
|
||||
|
||||
lc_dialog_preview_update (gimage);
|
||||
|
||||
/* We're interested in clean and dirty signals so we can update the
|
||||
|
@ -420,7 +423,7 @@ gdisplay_delete (GDisplay *gdisp)
|
|||
|
||||
/* free the gimage */
|
||||
gdisp->gimage->disp_count--;
|
||||
gimage_delete (gdisp->gimage);
|
||||
gtk_object_unref (GTK_OBJECT (gdisp->gimage));
|
||||
|
||||
if (gdisp->nav_popup)
|
||||
nav_popup_free (gdisp->nav_popup);
|
||||
|
@ -2367,7 +2370,7 @@ gdisplay_reconnect (GDisplay *gdisp,
|
|||
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (gdisp->gimage), gdisp);
|
||||
gdisp->gimage->disp_count--;
|
||||
gimage_delete (gdisp->gimage);
|
||||
gtk_object_unref (GTK_OBJECT (gdisp->gimage));
|
||||
|
||||
instance = gimage->instance_count;
|
||||
gimage->instance_count++;
|
||||
|
@ -2376,6 +2379,9 @@ gdisplay_reconnect (GDisplay *gdisp,
|
|||
gdisp->gimage = gimage;
|
||||
gdisp->instance = instance;
|
||||
|
||||
gtk_object_ref (GTK_OBJECT (gimage));
|
||||
gtk_object_sink (GTK_OBJECT (gimage));
|
||||
|
||||
/* reconnect our clean / dirty signals */
|
||||
gtk_signal_connect (GTK_OBJECT (gimage), "dirty",
|
||||
GTK_SIGNAL_FUNC(gdisplay_cleandirty_handler), gdisp);
|
||||
|
|
65
app/gimage.c
65
app/gimage.c
|
@ -92,38 +92,6 @@ gimage_new (gint width,
|
|||
return gimage;
|
||||
}
|
||||
|
||||
|
||||
/* Ack, GimpImages have their own ref counts! This is going to cause
|
||||
trouble.. It should be pretty easy to convert to proper GtkObject
|
||||
ref counting, though. */
|
||||
|
||||
/* This caused trouble indeed. The ref_count was only used by the
|
||||
displays showing the image, so I renamed it to disp_count to
|
||||
make clear that it should only be used for display references.
|
||||
(Sven, 23.01.2000) */
|
||||
|
||||
void
|
||||
gimage_delete (GimpImage *gimage)
|
||||
{
|
||||
if (gimage->disp_count <= 0)
|
||||
gtk_object_unref (GTK_OBJECT (gimage));
|
||||
}
|
||||
|
||||
static void
|
||||
gimage_invalidate_previews_foreach_func (gpointer image,
|
||||
gpointer user_data)
|
||||
{
|
||||
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (image));
|
||||
}
|
||||
|
||||
void
|
||||
gimage_invalidate_previews (void)
|
||||
{
|
||||
gimp_container_foreach (image_context,
|
||||
gimage_invalidate_previews_foreach_func,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gimage_dirty_handler (GimpImage *gimage)
|
||||
{
|
||||
|
@ -141,29 +109,6 @@ gimage_dirty_handler (GimpImage *gimage)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimlist_cb (gpointer image,
|
||||
gpointer data)
|
||||
{
|
||||
GSList **list = (GSList **) data;
|
||||
|
||||
*list = g_slist_prepend (*list, image);
|
||||
}
|
||||
|
||||
gint
|
||||
gimage_image_count (void)
|
||||
{
|
||||
GSList *list = NULL;
|
||||
gint num_images = 0;
|
||||
|
||||
gimage_foreach (gimlist_cb, &list);
|
||||
num_images = g_slist_length (list);
|
||||
|
||||
g_slist_free (list);
|
||||
|
||||
return num_images;
|
||||
}
|
||||
|
||||
static void
|
||||
gimage_destroy_handler (GimpImage *gimage)
|
||||
{
|
||||
|
@ -180,7 +125,8 @@ gimage_destroy_handler (GimpImage *gimage)
|
|||
|
||||
g_list_free (gimage->guides);
|
||||
|
||||
if (gimage_image_count () == 1) /* This is the last image */
|
||||
/* check if this is the last image */
|
||||
if (gimp_container_num_children (image_context) == 1)
|
||||
{
|
||||
dialog_show_toolbox ();
|
||||
}
|
||||
|
@ -289,10 +235,3 @@ gimage_set_layer_mask_show (GimpImage *gimage,
|
|||
gimp_drawable_width (GIMP_DRAWABLE (layer)),
|
||||
gimp_drawable_height (GIMP_DRAWABLE (layer)));
|
||||
}
|
||||
|
||||
void
|
||||
gimage_foreach (GFunc func,
|
||||
gpointer user_data)
|
||||
{
|
||||
gimp_container_foreach (image_context, func, user_data);
|
||||
}
|
||||
|
|
|
@ -26,8 +26,7 @@
|
|||
GImage * gimage_new (gint width,
|
||||
gint height,
|
||||
GimpImageBaseType base_type);
|
||||
void gimage_delete (GImage *gimage);
|
||||
void gimage_invalidate_previews (void);
|
||||
|
||||
void gimage_set_layer_mask_apply (GImage *gimage,
|
||||
GimpLayer *layer);
|
||||
void gimage_set_layer_mask_edit (GImage *gimage,
|
||||
|
@ -35,8 +34,6 @@ void gimage_set_layer_mask_edit (GImage *gimage,
|
|||
gboolean edit);
|
||||
void gimage_set_layer_mask_show (GImage *gimage,
|
||||
GimpLayer *layer);
|
||||
void gimage_foreach (GFunc func,
|
||||
gpointer user_data);
|
||||
|
||||
|
||||
extern guint32 next_guide_id;
|
||||
|
|
|
@ -36,6 +36,7 @@ static void gimp_brush_preview_init (GimpBrushPreview *preview);
|
|||
|
||||
static TempBuf * gimp_brush_preview_create_preview (GimpPreview *preview);
|
||||
static GtkWidget * gimp_brush_preview_create_popup (GimpPreview *preview);
|
||||
static gboolean gimp_brush_preview_needs_popup (GimpPreview *preview);
|
||||
|
||||
|
||||
static GimpPreviewClass *parent_class = NULL;
|
||||
|
@ -79,6 +80,7 @@ gimp_brush_preview_class_init (GimpBrushPreviewClass *klass)
|
|||
|
||||
preview_class->create_preview = gimp_brush_preview_create_preview;
|
||||
preview_class->create_popup = gimp_brush_preview_create_popup;
|
||||
preview_class->needs_popup = gimp_brush_preview_needs_popup;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -225,3 +227,25 @@ gimp_brush_preview_create_popup (GimpPreview *preview)
|
|||
popup_height,
|
||||
FALSE, FALSE);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_brush_preview_needs_popup (GimpPreview *preview)
|
||||
{
|
||||
GimpBrush *brush;
|
||||
gint brush_width;
|
||||
gint brush_height;
|
||||
gint width;
|
||||
gint height;
|
||||
|
||||
brush = GIMP_BRUSH (preview->viewable);
|
||||
brush_width = brush->mask->width;
|
||||
brush_height = brush->mask->height;
|
||||
|
||||
width = GTK_WIDGET (preview)->requisition.width;
|
||||
height = GTK_WIDGET (preview)->requisition.height;
|
||||
|
||||
if (brush_width > width || brush_height > height)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "colormaps.h"
|
||||
#include "gimpcontainer.h"
|
||||
#include "gimpcontainergridview.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimppreview.h"
|
||||
#include "gimpconstrainedhwrapbox.h"
|
||||
|
||||
|
@ -44,6 +45,8 @@ static void gimp_container_grid_view_remove_item (GimpContainerView *v
|
|||
gpointer insert_data);
|
||||
static void gimp_container_grid_view_clear_items (GimpContainerView *view);
|
||||
static void gimp_container_grid_view_set_preview_size (GimpContainerView *view);
|
||||
static void gimp_container_grid_view_item_selected (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
|
||||
static GimpContainerViewClass *parent_class = NULL;
|
||||
|
@ -146,6 +149,7 @@ gimp_container_grid_view_destroy (GtkObject *object)
|
|||
|
||||
GtkWidget *
|
||||
gimp_container_grid_view_new (GimpContainer *container,
|
||||
GimpContext *context,
|
||||
gint preview_width,
|
||||
gint preview_height,
|
||||
gint min_items_x,
|
||||
|
@ -156,6 +160,7 @@ gimp_container_grid_view_new (GimpContainer *container,
|
|||
|
||||
g_return_val_if_fail (container != NULL, NULL);
|
||||
g_return_val_if_fail (GIMP_IS_CONTAINER (container), NULL);
|
||||
g_return_val_if_fail (! context || GIMP_IS_CONTEXT (context), NULL);
|
||||
g_return_val_if_fail (preview_width > 0 && preview_width <= 64, NULL);
|
||||
g_return_val_if_fail (preview_height > 0 && preview_height <= 64, NULL);
|
||||
g_return_val_if_fail (min_items_x > 0 && min_items_x <= 64, NULL);
|
||||
|
@ -174,6 +179,8 @@ gimp_container_grid_view_new (GimpContainer *container,
|
|||
|
||||
gimp_container_view_set_container (view, container);
|
||||
|
||||
gimp_container_view_set_context (view, context);
|
||||
|
||||
return GTK_WIDGET (grid_view);
|
||||
}
|
||||
|
||||
|
@ -200,6 +207,10 @@ gimp_container_grid_view_insert_item (GimpContainerView *view,
|
|||
|
||||
gtk_widget_show (preview);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (preview), "clicked",
|
||||
GTK_SIGNAL_FUNC (gimp_container_grid_view_item_selected),
|
||||
view);
|
||||
|
||||
return (gpointer) preview;
|
||||
}
|
||||
|
||||
|
@ -251,3 +262,11 @@ gimp_container_grid_view_set_preview_size (GimpContainerView *view)
|
|||
|
||||
gtk_widget_queue_resize (grid_view->wrap_box);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_container_grid_view_item_selected (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
gimp_container_view_item_selected (GIMP_CONTAINER_VIEW (data),
|
||||
GIMP_PREVIEW (widget)->viewable);
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@ struct _GimpContainerGridViewClass
|
|||
|
||||
GtkType gimp_container_grid_view_get_type (void);
|
||||
GtkWidget * gimp_container_grid_view_new (GimpContainer *container,
|
||||
GimpContext *context,
|
||||
gint preview_width,
|
||||
gint preview_height,
|
||||
gint min_items_x,
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "appenv.h"
|
||||
#include "gimpcontainer.h"
|
||||
#include "gimpcontainerlistview.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimplist.h"
|
||||
#include "gimppreview.h"
|
||||
|
||||
|
@ -41,11 +42,17 @@ static gpointer gimp_container_list_view_insert_item (GimpContainerView *v
|
|||
static void gimp_container_list_view_remove_item (GimpContainerView *view,
|
||||
GimpViewable *viewable,
|
||||
gpointer insert_data);
|
||||
static void gimp_container_list_view_select_item (GimpContainerView *view,
|
||||
GimpViewable *viewable,
|
||||
gpointer insert_data);
|
||||
static void gimp_container_list_view_clear_items (GimpContainerView *view);
|
||||
static void gimp_container_list_view_set_preview_size (GimpContainerView *view);
|
||||
|
||||
static void gimp_container_list_view_name_changed (GimpContainerListView *list_view,
|
||||
GimpViewable *viewable);
|
||||
static void gimp_container_list_view_item_selected (GtkWidget *widget,
|
||||
GtkWidget *child,
|
||||
gpointer data);
|
||||
|
||||
|
||||
static GimpContainerViewClass *parent_class = NULL;
|
||||
|
@ -92,6 +99,7 @@ gimp_container_list_view_class_init (GimpContainerListViewClass *klass)
|
|||
|
||||
container_view_class->insert_item = gimp_container_list_view_insert_item;
|
||||
container_view_class->remove_item = gimp_container_list_view_remove_item;
|
||||
container_view_class->select_item = gimp_container_list_view_select_item;
|
||||
container_view_class->clear_items = gimp_container_list_view_clear_items;
|
||||
container_view_class->set_preview_size = gimp_container_list_view_set_preview_size;
|
||||
}
|
||||
|
@ -121,6 +129,10 @@ gimp_container_list_view_init (GimpContainerListView *list_view)
|
|||
GTK_WIDGET_UNSET_FLAGS (GTK_SCROLLED_WINDOW (scrolled_win)->vscrollbar,
|
||||
GTK_CAN_FOCUS);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (list_view->gtk_list), "select_child",
|
||||
GTK_SIGNAL_FUNC (gimp_container_list_view_item_selected),
|
||||
list_view);
|
||||
|
||||
gtk_widget_show (list_view->gtk_list);
|
||||
gtk_widget_show (scrolled_win);
|
||||
}
|
||||
|
@ -138,6 +150,7 @@ gimp_container_list_view_destroy (GtkObject *object)
|
|||
|
||||
GtkWidget *
|
||||
gimp_container_list_view_new (GimpContainer *container,
|
||||
GimpContext *context,
|
||||
gint preview_width,
|
||||
gint preview_height,
|
||||
gint min_items_x,
|
||||
|
@ -148,6 +161,7 @@ gimp_container_list_view_new (GimpContainer *container,
|
|||
|
||||
g_return_val_if_fail (container != NULL, NULL);
|
||||
g_return_val_if_fail (GIMP_IS_CONTAINER (container), NULL);
|
||||
g_return_val_if_fail (! context || GIMP_IS_CONTEXT (context), NULL);
|
||||
g_return_val_if_fail (preview_width > 0 && preview_width <= 64, NULL);
|
||||
g_return_val_if_fail (preview_height > 0 && preview_height <= 64, NULL);
|
||||
g_return_val_if_fail (min_items_x > 0 && min_items_x <= 64, NULL);
|
||||
|
@ -166,6 +180,8 @@ gimp_container_list_view_new (GimpContainer *container,
|
|||
|
||||
gimp_container_view_set_container (view, container);
|
||||
|
||||
gimp_container_view_set_context (view, context);
|
||||
|
||||
return GTK_WIDGET (list_view);
|
||||
}
|
||||
|
||||
|
@ -243,6 +259,31 @@ gimp_container_list_view_remove_item (GimpContainerView *view,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_container_list_view_select_item (GimpContainerView *view,
|
||||
GimpViewable *viewable,
|
||||
gpointer insert_data)
|
||||
{
|
||||
GimpContainerListView *list_view;
|
||||
GtkWidget *list_item;
|
||||
|
||||
list_view = GIMP_CONTAINER_LIST_VIEW (view);
|
||||
list_item = GTK_WIDGET (insert_data);
|
||||
|
||||
if (list_item)
|
||||
{
|
||||
gtk_signal_handler_block_by_func (GTK_OBJECT (list_view->gtk_list),
|
||||
gimp_container_list_view_item_selected,
|
||||
list_view);
|
||||
|
||||
gtk_list_select_child (GTK_LIST (list_view->gtk_list), list_item);
|
||||
|
||||
gtk_signal_handler_unblock_by_func (GTK_OBJECT (list_view->gtk_list),
|
||||
gimp_container_list_view_item_selected,
|
||||
list_view);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_container_list_view_clear_items (GimpContainerView *view)
|
||||
{
|
||||
|
@ -299,3 +340,17 @@ gimp_container_list_view_name_changed (GimpContainerListView *list_view,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_container_list_view_item_selected (GtkWidget *widget,
|
||||
GtkWidget *child,
|
||||
gpointer data)
|
||||
{
|
||||
GimpViewable *viewable;
|
||||
|
||||
viewable = GIMP_PREVIEW (gtk_object_get_data (GTK_OBJECT (child),
|
||||
"preview"))->viewable;
|
||||
|
||||
gimp_container_view_item_selected (GIMP_CONTAINER_VIEW (data),
|
||||
viewable);
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ struct _GimpContainerListViewClass
|
|||
|
||||
GtkType gimp_container_list_view_get_type (void);
|
||||
GtkWidget * gimp_container_list_view_new (GimpContainer *container,
|
||||
GimpContext *context,
|
||||
gint preview_width,
|
||||
gint preview_height,
|
||||
gint min_items_x,
|
||||
|
|
|
@ -24,13 +24,16 @@
|
|||
|
||||
#include "gimpcontainer.h"
|
||||
#include "gimpcontainerview.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimpmarshal.h"
|
||||
#include "gimpviewable.h"
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
INSERT_ITEM,
|
||||
REMOVE_ITEM,
|
||||
SELECT_ITEM,
|
||||
CLEAR_ITEMS,
|
||||
SET_PREVIEW_SIZE,
|
||||
LAST_SIGNAL
|
||||
|
@ -52,6 +55,10 @@ static void gimp_container_view_remove (GimpContainerView *view,
|
|||
GimpViewable *viewable,
|
||||
GimpContainer *container);
|
||||
|
||||
static void gimp_container_view_context_changed (GimpContext *context,
|
||||
GimpViewable *viewable,
|
||||
GimpContainerView *view);
|
||||
|
||||
|
||||
static guint view_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
|
@ -114,6 +121,17 @@ gimp_container_view_class_init (GimpContainerViewClass *klass)
|
|||
GIMP_TYPE_OBJECT,
|
||||
GTK_TYPE_POINTER);
|
||||
|
||||
view_signals[SELECT_ITEM] =
|
||||
gtk_signal_new ("select_item",
|
||||
GTK_RUN_FIRST,
|
||||
object_class->type,
|
||||
GTK_SIGNAL_OFFSET (GimpContainerViewClass,
|
||||
select_item),
|
||||
gtk_marshal_NONE__POINTER_POINTER,
|
||||
GTK_TYPE_NONE, 2,
|
||||
GIMP_TYPE_OBJECT,
|
||||
GTK_TYPE_POINTER);
|
||||
|
||||
view_signals[CLEAR_ITEMS] =
|
||||
gtk_signal_new ("clear_items",
|
||||
GTK_RUN_FIRST,
|
||||
|
@ -135,13 +153,21 @@ gimp_container_view_class_init (GimpContainerViewClass *klass)
|
|||
gtk_object_class_add_signals (object_class, view_signals, LAST_SIGNAL);
|
||||
|
||||
object_class->destroy = gimp_container_view_destroy;
|
||||
|
||||
klass->insert_item = NULL;
|
||||
klass->remove_item = NULL;
|
||||
klass->select_item = NULL;
|
||||
klass->clear_items = NULL;
|
||||
klass->set_preview_size = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_container_view_init (GimpContainerView *view)
|
||||
{
|
||||
view->container = NULL;
|
||||
view->hash_table = NULL;
|
||||
view->container = NULL;
|
||||
view->context = NULL;
|
||||
|
||||
view->hash_table = NULL;
|
||||
|
||||
view->preview_width = 0;
|
||||
view->preview_height = 0;
|
||||
|
@ -181,6 +207,13 @@ gimp_container_view_set_container (GimpContainerView *view,
|
|||
g_hash_table_destroy (view->hash_table);
|
||||
|
||||
gimp_container_view_clear (view);
|
||||
|
||||
if (view->context)
|
||||
{
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (view->context),
|
||||
gimp_container_view_context_changed,
|
||||
view);
|
||||
}
|
||||
}
|
||||
|
||||
view->container = container;
|
||||
|
@ -202,6 +235,61 @@ gimp_container_view_set_container (GimpContainerView *view,
|
|||
(GTK_OBJECT (container), "remove",
|
||||
GTK_SIGNAL_FUNC (gimp_container_view_remove),
|
||||
GTK_OBJECT (view));
|
||||
|
||||
if (view->context)
|
||||
{
|
||||
gtk_signal_connect
|
||||
(GTK_OBJECT (view->context),
|
||||
gimp_context_type_to_signal_name (view->container->children_type),
|
||||
GTK_SIGNAL_FUNC (gimp_container_view_context_changed),
|
||||
view);
|
||||
|
||||
gimp_container_view_select_item
|
||||
(view,
|
||||
GIMP_VIEWABLE
|
||||
(gimp_context_get_by_type (view->context,
|
||||
view->container->children_type)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_container_view_set_context (GimpContainerView *view,
|
||||
GimpContext *context)
|
||||
{
|
||||
g_return_if_fail (view != NULL);
|
||||
g_return_if_fail (GIMP_IS_CONTAINER_VIEW (view));
|
||||
g_return_if_fail (! context || GIMP_IS_CONTEXT (context));
|
||||
|
||||
if (context == view->context)
|
||||
return;
|
||||
|
||||
if (view->context)
|
||||
{
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (view->context),
|
||||
gimp_container_view_context_changed,
|
||||
view);
|
||||
}
|
||||
|
||||
view->context = context;
|
||||
|
||||
if (view->context && view->container)
|
||||
{
|
||||
GimpObject *object;
|
||||
const gchar *signal_name;
|
||||
|
||||
signal_name =
|
||||
gimp_context_type_to_signal_name (view->container->children_type);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (view->context), signal_name,
|
||||
GTK_SIGNAL_FUNC (gimp_container_view_context_changed),
|
||||
view);
|
||||
|
||||
object = gimp_context_get_by_type (view->context,
|
||||
view->container->children_type);
|
||||
|
||||
if (object)
|
||||
gimp_container_view_select_item (view, GIMP_VIEWABLE (object));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -221,6 +309,43 @@ gimp_container_view_set_preview_size (GimpContainerView *view,
|
|||
gtk_signal_emit (GTK_OBJECT (view), view_signals[SET_PREVIEW_SIZE]);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_container_view_select_item (GimpContainerView *view,
|
||||
GimpViewable *viewable)
|
||||
{
|
||||
gpointer insert_data;
|
||||
|
||||
g_return_if_fail (view != NULL);
|
||||
g_return_if_fail (GIMP_IS_CONTAINER_VIEW (view));
|
||||
g_return_if_fail (viewable != NULL);
|
||||
g_return_if_fail (GIMP_IS_VIEWABLE (viewable));
|
||||
|
||||
insert_data = g_hash_table_lookup (view->hash_table, viewable);
|
||||
|
||||
if (insert_data)
|
||||
{
|
||||
gtk_signal_emit (GTK_OBJECT (view), view_signals[SELECT_ITEM],
|
||||
viewable, insert_data);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_container_view_item_selected (GimpContainerView *view,
|
||||
GimpViewable *viewable)
|
||||
{
|
||||
g_return_if_fail (view != NULL);
|
||||
g_return_if_fail (GIMP_IS_CONTAINER_VIEW (view));
|
||||
g_return_if_fail (viewable != NULL);
|
||||
g_return_if_fail (GIMP_IS_VIEWABLE (viewable));
|
||||
|
||||
if (! (view->container && view->context))
|
||||
return;
|
||||
|
||||
gimp_context_set_by_type (view->context,
|
||||
view->container->children_type,
|
||||
GIMP_OBJECT (viewable));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_container_view_clear (GimpContainerView *view)
|
||||
{
|
||||
|
@ -273,3 +398,19 @@ gimp_container_view_remove (GimpContainerView *view,
|
|||
viewable, insert_data);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_container_view_context_changed (GimpContext *context,
|
||||
GimpViewable *viewable,
|
||||
GimpContainerView *view)
|
||||
{
|
||||
gpointer insert_data;
|
||||
|
||||
insert_data = g_hash_table_lookup (view->hash_table, viewable);
|
||||
|
||||
if (insert_data)
|
||||
{
|
||||
gtk_signal_emit (GTK_OBJECT (view), view_signals[SELECT_ITEM],
|
||||
viewable, insert_data);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ struct _GimpContainerView
|
|||
GtkVBox parent_instance;
|
||||
|
||||
GimpContainer *container;
|
||||
GimpContext *context;
|
||||
|
||||
GHashTable *hash_table;
|
||||
|
||||
|
@ -55,6 +56,9 @@ struct _GimpContainerViewClass
|
|||
void (* remove_item) (GimpContainerView *view,
|
||||
GimpViewable *object,
|
||||
gpointer insert_data);
|
||||
void (* select_item) (GimpContainerView *view,
|
||||
GimpViewable *object,
|
||||
gpointer insert_data);
|
||||
void (* clear_items) (GimpContainerView *view);
|
||||
void (* set_preview_size) (GimpContainerView *view);
|
||||
};
|
||||
|
@ -64,9 +68,19 @@ GtkType gimp_container_view_get_type (void);
|
|||
|
||||
void gimp_container_view_set_container (GimpContainerView *view,
|
||||
GimpContainer *container);
|
||||
void gimp_container_view_set_context (GimpContainerView *view,
|
||||
GimpContext *context);
|
||||
void gimp_container_view_set_preview_size (GimpContainerView *view,
|
||||
gint width,
|
||||
gint height);
|
||||
void gimp_container_view_select_item (GimpContainerView *view,
|
||||
GimpViewable *viewable);
|
||||
|
||||
|
||||
/* private */
|
||||
|
||||
void gimp_container_view_item_selected (GimpContainerView *view,
|
||||
GimpViewable *item);
|
||||
|
||||
|
||||
#endif /* __GIMP_CONTAINER_VIEW_H__ */
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "gimpbrush.h"
|
||||
#include "gimpcontainer.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimpimage.h"
|
||||
#include "gimpmarshal.h"
|
||||
#include "gimppattern.h"
|
||||
#include "gimprc.h"
|
||||
|
@ -41,6 +42,10 @@
|
|||
#include "temp_buf.h"
|
||||
|
||||
|
||||
typedef void (* GimpContextCopyArgFunc) (GimpContext *src,
|
||||
GimpContext *dest);
|
||||
|
||||
|
||||
#define context_return_if_fail(context) \
|
||||
g_return_if_fail ((context) != NULL); \
|
||||
g_return_if_fail (GIMP_IS_CONTEXT (context))
|
||||
|
@ -56,10 +61,19 @@
|
|||
while (!(((context)->defined_args) & arg_mask) && (context)->parent) \
|
||||
(context) = (context)->parent
|
||||
|
||||
typedef void (* GimpContextCopyArgFunc) (GimpContext *src, GimpContext *dest);
|
||||
|
||||
/* local function prototypes */
|
||||
|
||||
static void gimp_context_class_init (GimpContextClass *klass);
|
||||
static void gimp_context_init (GimpContext *context);
|
||||
static void gimp_context_destroy (GtkObject *object);
|
||||
static void gimp_context_set_arg (GtkObject *object,
|
||||
GtkArg *arg,
|
||||
guint arg_id);
|
||||
static void gimp_context_get_arg (GtkObject *object,
|
||||
GtkArg *arg,
|
||||
guint arg_id);
|
||||
|
||||
/* image */
|
||||
static void gimp_context_real_set_image (GimpContext *context,
|
||||
GimpImage *image);
|
||||
|
@ -130,7 +144,8 @@ static void gimp_context_real_set_gradient (GimpContext *context,
|
|||
static void gimp_context_copy_gradient (GimpContext *src,
|
||||
GimpContext *dest);
|
||||
|
||||
/* arguments */
|
||||
|
||||
/* arguments & signals */
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -147,6 +162,21 @@ enum
|
|||
ARG_GRADIENT
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
IMAGE_CHANGED,
|
||||
DISPLAY_CHANGED,
|
||||
TOOL_CHANGED,
|
||||
FOREGROUND_CHANGED,
|
||||
BACKGROUND_CHANGED,
|
||||
OPACITY_CHANGED,
|
||||
PAINT_MODE_CHANGED,
|
||||
BRUSH_CHANGED,
|
||||
PATTERN_CHANGED,
|
||||
GRADIENT_CHANGED,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
static gchar *gimp_context_arg_names[] =
|
||||
{
|
||||
"GimpContext::image",
|
||||
|
@ -175,25 +205,20 @@ static GimpContextCopyArgFunc gimp_context_copy_arg_funcs[] =
|
|||
gimp_context_copy_gradient
|
||||
};
|
||||
|
||||
/* signals */
|
||||
|
||||
enum
|
||||
static GtkType gimp_context_arg_types[] =
|
||||
{
|
||||
IMAGE_CHANGED,
|
||||
DISPLAY_CHANGED,
|
||||
TOOL_CHANGED,
|
||||
FOREGROUND_CHANGED,
|
||||
BACKGROUND_CHANGED,
|
||||
OPACITY_CHANGED,
|
||||
PAINT_MODE_CHANGED,
|
||||
BRUSH_CHANGED,
|
||||
PATTERN_CHANGED,
|
||||
GRADIENT_CHANGED,
|
||||
LAST_SIGNAL
|
||||
0,
|
||||
GTK_TYPE_NONE,
|
||||
GTK_TYPE_NONE,
|
||||
GTK_TYPE_NONE,
|
||||
GTK_TYPE_NONE,
|
||||
GTK_TYPE_NONE,
|
||||
GTK_TYPE_NONE,
|
||||
0,
|
||||
0,
|
||||
GTK_TYPE_NONE
|
||||
};
|
||||
|
||||
static guint gimp_context_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
static gchar *gimp_context_signal_names[] =
|
||||
{
|
||||
"image_changed",
|
||||
|
@ -222,6 +247,9 @@ static GtkSignalFunc gimp_context_signal_handlers[] =
|
|||
gimp_context_real_set_gradient
|
||||
};
|
||||
|
||||
|
||||
static guint gimp_context_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
static GimpObjectClass * parent_class = NULL;
|
||||
|
||||
/* the currently active context */
|
||||
|
@ -239,165 +267,10 @@ static GimpContext *standard_context = NULL;
|
|||
/* the list of all contexts */
|
||||
static GSList *context_list = NULL;
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* private functions *******************************************************/
|
||||
|
||||
static void
|
||||
gimp_context_set_arg (GtkObject *object,
|
||||
GtkArg *arg,
|
||||
guint arg_id)
|
||||
{
|
||||
GimpContext *context;
|
||||
|
||||
context = GIMP_CONTEXT (object);
|
||||
|
||||
switch (arg_id)
|
||||
{
|
||||
case ARG_IMAGE:
|
||||
gimp_context_set_image (context, GTK_VALUE_POINTER (*arg));
|
||||
break;
|
||||
case ARG_DISPLAY:
|
||||
gimp_context_set_display (context, GTK_VALUE_POINTER (*arg));
|
||||
break;
|
||||
case ARG_TOOL:
|
||||
gimp_context_set_tool (context, GTK_VALUE_INT (*arg));
|
||||
break;
|
||||
case ARG_FOREGROUND:
|
||||
gimp_context_set_foreground (context, GTK_VALUE_POINTER (*arg));
|
||||
break;
|
||||
case ARG_BACKGROUND:
|
||||
gimp_context_set_background (context, GTK_VALUE_POINTER (*arg));
|
||||
break;
|
||||
case ARG_OPACITY:
|
||||
gimp_context_set_opacity (context, GTK_VALUE_DOUBLE (*arg));
|
||||
break;
|
||||
case ARG_PAINT_MODE:
|
||||
gimp_context_set_paint_mode (context, GTK_VALUE_INT (*arg));
|
||||
break;
|
||||
case ARG_BRUSH:
|
||||
gimp_context_set_brush (context, GTK_VALUE_POINTER (*arg));
|
||||
break;
|
||||
case ARG_PATTERN:
|
||||
gimp_context_set_pattern (context, GTK_VALUE_POINTER (*arg));
|
||||
break;
|
||||
case ARG_GRADIENT:
|
||||
gimp_context_set_gradient (context, GTK_VALUE_POINTER (*arg));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_context_get_arg (GtkObject *object,
|
||||
GtkArg *arg,
|
||||
guint arg_id)
|
||||
{
|
||||
GimpContext *context;
|
||||
|
||||
context = GIMP_CONTEXT (object);
|
||||
|
||||
switch (arg_id)
|
||||
{
|
||||
case ARG_IMAGE:
|
||||
GTK_VALUE_POINTER (*arg) = gimp_context_get_image (context);
|
||||
break;
|
||||
case ARG_DISPLAY:
|
||||
GTK_VALUE_POINTER (*arg) = gimp_context_get_display (context);
|
||||
break;
|
||||
case ARG_TOOL:
|
||||
GTK_VALUE_INT (*arg) = gimp_context_get_tool (context);
|
||||
break;
|
||||
case ARG_FOREGROUND:
|
||||
gimp_context_get_foreground (context, GTK_VALUE_POINTER (*arg));
|
||||
break;
|
||||
case ARG_BACKGROUND:
|
||||
gimp_context_get_background (context, GTK_VALUE_POINTER (*arg));
|
||||
break;
|
||||
case ARG_OPACITY:
|
||||
GTK_VALUE_DOUBLE (*arg) = gimp_context_get_opacity (context);
|
||||
break;
|
||||
case ARG_PAINT_MODE:
|
||||
GTK_VALUE_INT (*arg) = gimp_context_get_paint_mode (context);
|
||||
break;
|
||||
case ARG_BRUSH:
|
||||
GTK_VALUE_POINTER (*arg) = gimp_context_get_brush (context);
|
||||
break;
|
||||
case ARG_PATTERN:
|
||||
GTK_VALUE_POINTER (*arg) = gimp_context_get_pattern (context);
|
||||
break;
|
||||
case ARG_GRADIENT:
|
||||
GTK_VALUE_POINTER (*arg) = gimp_context_get_gradient (context);
|
||||
break;
|
||||
default:
|
||||
arg->type = GTK_TYPE_INVALID;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_context_destroy (GtkObject *object)
|
||||
{
|
||||
GimpContext *context;
|
||||
|
||||
context = GIMP_CONTEXT (object);
|
||||
|
||||
if (context->parent)
|
||||
gimp_context_unset_parent (context);
|
||||
|
||||
if (context->image)
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (image_context), context);
|
||||
|
||||
if (context->display)
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (context->display->shell),
|
||||
context);
|
||||
|
||||
if (context->brush)
|
||||
{
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (context->brush),
|
||||
gimp_context_brush_dirty,
|
||||
context);
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (global_brush_list),
|
||||
gimp_context_brush_removed,
|
||||
context);
|
||||
gtk_object_unref (GTK_OBJECT (context->brush));
|
||||
}
|
||||
|
||||
if (context->brush_name)
|
||||
{
|
||||
g_free (context->brush_name);
|
||||
context->brush_name = NULL;
|
||||
}
|
||||
|
||||
if (context->pattern)
|
||||
{
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (context->pattern),
|
||||
gimp_context_pattern_dirty,
|
||||
context);
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (global_pattern_list),
|
||||
gimp_context_pattern_removed,
|
||||
context);
|
||||
gtk_object_unref (GTK_OBJECT (context->pattern));
|
||||
}
|
||||
|
||||
if (context->pattern_name)
|
||||
{
|
||||
g_free (context->pattern_name);
|
||||
context->pattern_name = NULL;
|
||||
}
|
||||
|
||||
if (context->gradient_name)
|
||||
{
|
||||
g_free (context->gradient_name);
|
||||
context->gradient_name = NULL;
|
||||
}
|
||||
|
||||
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
||||
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
||||
|
||||
context_list = g_slist_remove (context_list, context);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_context_class_init (GimpContextClass *klass)
|
||||
{
|
||||
|
@ -407,26 +280,40 @@ gimp_context_class_init (GimpContextClass *klass)
|
|||
|
||||
parent_class = gtk_type_class (GIMP_TYPE_OBJECT);
|
||||
|
||||
gimp_context_arg_types[GIMP_CONTEXT_ARG_IMAGE] = GIMP_TYPE_IMAGE;
|
||||
gimp_context_arg_types[GIMP_CONTEXT_ARG_BRUSH] = GIMP_TYPE_BRUSH;
|
||||
gimp_context_arg_types[GIMP_CONTEXT_ARG_PATTERN] = GIMP_TYPE_PATTERN;
|
||||
|
||||
gtk_object_add_arg_type (gimp_context_arg_names[IMAGE_CHANGED],
|
||||
GTK_TYPE_POINTER, GTK_ARG_READWRITE, ARG_IMAGE);
|
||||
GTK_TYPE_POINTER, GTK_ARG_READWRITE,
|
||||
ARG_IMAGE);
|
||||
gtk_object_add_arg_type (gimp_context_arg_names[DISPLAY_CHANGED],
|
||||
GTK_TYPE_POINTER, GTK_ARG_READWRITE, ARG_DISPLAY);
|
||||
GTK_TYPE_POINTER, GTK_ARG_READWRITE,
|
||||
ARG_DISPLAY);
|
||||
gtk_object_add_arg_type (gimp_context_arg_names[TOOL_CHANGED],
|
||||
GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_TOOL);
|
||||
GTK_TYPE_INT, GTK_ARG_READWRITE,
|
||||
ARG_TOOL);
|
||||
gtk_object_add_arg_type (gimp_context_arg_names[FOREGROUND_CHANGED],
|
||||
GTK_TYPE_POINTER, GTK_ARG_READWRITE, ARG_FOREGROUND);
|
||||
GTK_TYPE_POINTER, GTK_ARG_READWRITE,
|
||||
ARG_FOREGROUND);
|
||||
gtk_object_add_arg_type (gimp_context_arg_names[BACKGROUND_CHANGED],
|
||||
GTK_TYPE_POINTER, GTK_ARG_READWRITE, ARG_BACKGROUND);
|
||||
GTK_TYPE_POINTER, GTK_ARG_READWRITE,
|
||||
ARG_BACKGROUND);
|
||||
gtk_object_add_arg_type (gimp_context_arg_names[OPACITY_CHANGED],
|
||||
GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_OPACITY);
|
||||
GTK_TYPE_DOUBLE, GTK_ARG_READWRITE,
|
||||
ARG_OPACITY);
|
||||
gtk_object_add_arg_type (gimp_context_arg_names[PAINT_MODE_CHANGED],
|
||||
GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_PAINT_MODE);
|
||||
GTK_TYPE_INT, GTK_ARG_READWRITE,
|
||||
ARG_PAINT_MODE);
|
||||
gtk_object_add_arg_type (gimp_context_arg_names[BRUSH_CHANGED],
|
||||
GTK_TYPE_POINTER, GTK_ARG_READWRITE, ARG_BRUSH);
|
||||
GTK_TYPE_POINTER, GTK_ARG_READWRITE,
|
||||
ARG_BRUSH);
|
||||
gtk_object_add_arg_type (gimp_context_arg_names[PATTERN_CHANGED],
|
||||
GTK_TYPE_POINTER, GTK_ARG_READWRITE, ARG_PATTERN);
|
||||
GTK_TYPE_POINTER, GTK_ARG_READWRITE,
|
||||
ARG_PATTERN);
|
||||
gtk_object_add_arg_type (gimp_context_arg_names[GRADIENT_CHANGED],
|
||||
GTK_TYPE_POINTER, GTK_ARG_READWRITE, ARG_GRADIENT);
|
||||
GTK_TYPE_POINTER, GTK_ARG_READWRITE,
|
||||
ARG_GRADIENT);
|
||||
|
||||
gimp_context_signals[IMAGE_CHANGED] =
|
||||
gtk_signal_new (gimp_context_signal_names[IMAGE_CHANGED],
|
||||
|
@ -577,6 +464,162 @@ gimp_context_init (GimpContext *context)
|
|||
context_list = g_slist_prepend (context_list, context);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_context_destroy (GtkObject *object)
|
||||
{
|
||||
GimpContext *context;
|
||||
|
||||
context = GIMP_CONTEXT (object);
|
||||
|
||||
if (context->parent)
|
||||
gimp_context_unset_parent (context);
|
||||
|
||||
if (context->image)
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (image_context), context);
|
||||
|
||||
if (context->display)
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (context->display->shell),
|
||||
context);
|
||||
|
||||
if (context->brush)
|
||||
{
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (context->brush),
|
||||
gimp_context_brush_dirty,
|
||||
context);
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (global_brush_list),
|
||||
gimp_context_brush_removed,
|
||||
context);
|
||||
gtk_object_unref (GTK_OBJECT (context->brush));
|
||||
}
|
||||
|
||||
if (context->brush_name)
|
||||
{
|
||||
g_free (context->brush_name);
|
||||
context->brush_name = NULL;
|
||||
}
|
||||
|
||||
if (context->pattern)
|
||||
{
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (context->pattern),
|
||||
gimp_context_pattern_dirty,
|
||||
context);
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (global_pattern_list),
|
||||
gimp_context_pattern_removed,
|
||||
context);
|
||||
gtk_object_unref (GTK_OBJECT (context->pattern));
|
||||
}
|
||||
|
||||
if (context->pattern_name)
|
||||
{
|
||||
g_free (context->pattern_name);
|
||||
context->pattern_name = NULL;
|
||||
}
|
||||
|
||||
if (context->gradient_name)
|
||||
{
|
||||
g_free (context->gradient_name);
|
||||
context->gradient_name = NULL;
|
||||
}
|
||||
|
||||
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
||||
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
||||
|
||||
context_list = g_slist_remove (context_list, context);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_context_set_arg (GtkObject *object,
|
||||
GtkArg *arg,
|
||||
guint arg_id)
|
||||
{
|
||||
GimpContext *context;
|
||||
|
||||
context = GIMP_CONTEXT (object);
|
||||
|
||||
switch (arg_id)
|
||||
{
|
||||
case ARG_IMAGE:
|
||||
gimp_context_set_image (context, GTK_VALUE_POINTER (*arg));
|
||||
break;
|
||||
case ARG_DISPLAY:
|
||||
gimp_context_set_display (context, GTK_VALUE_POINTER (*arg));
|
||||
break;
|
||||
case ARG_TOOL:
|
||||
gimp_context_set_tool (context, GTK_VALUE_INT (*arg));
|
||||
break;
|
||||
case ARG_FOREGROUND:
|
||||
gimp_context_set_foreground (context, GTK_VALUE_POINTER (*arg));
|
||||
break;
|
||||
case ARG_BACKGROUND:
|
||||
gimp_context_set_background (context, GTK_VALUE_POINTER (*arg));
|
||||
break;
|
||||
case ARG_OPACITY:
|
||||
gimp_context_set_opacity (context, GTK_VALUE_DOUBLE (*arg));
|
||||
break;
|
||||
case ARG_PAINT_MODE:
|
||||
gimp_context_set_paint_mode (context, GTK_VALUE_INT (*arg));
|
||||
break;
|
||||
case ARG_BRUSH:
|
||||
gimp_context_set_brush (context, GTK_VALUE_POINTER (*arg));
|
||||
break;
|
||||
case ARG_PATTERN:
|
||||
gimp_context_set_pattern (context, GTK_VALUE_POINTER (*arg));
|
||||
break;
|
||||
case ARG_GRADIENT:
|
||||
gimp_context_set_gradient (context, GTK_VALUE_POINTER (*arg));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_context_get_arg (GtkObject *object,
|
||||
GtkArg *arg,
|
||||
guint arg_id)
|
||||
{
|
||||
GimpContext *context;
|
||||
|
||||
context = GIMP_CONTEXT (object);
|
||||
|
||||
switch (arg_id)
|
||||
{
|
||||
case ARG_IMAGE:
|
||||
GTK_VALUE_POINTER (*arg) = gimp_context_get_image (context);
|
||||
break;
|
||||
case ARG_DISPLAY:
|
||||
GTK_VALUE_POINTER (*arg) = gimp_context_get_display (context);
|
||||
break;
|
||||
case ARG_TOOL:
|
||||
GTK_VALUE_INT (*arg) = gimp_context_get_tool (context);
|
||||
break;
|
||||
case ARG_FOREGROUND:
|
||||
gimp_context_get_foreground (context, GTK_VALUE_POINTER (*arg));
|
||||
break;
|
||||
case ARG_BACKGROUND:
|
||||
gimp_context_get_background (context, GTK_VALUE_POINTER (*arg));
|
||||
break;
|
||||
case ARG_OPACITY:
|
||||
GTK_VALUE_DOUBLE (*arg) = gimp_context_get_opacity (context);
|
||||
break;
|
||||
case ARG_PAINT_MODE:
|
||||
GTK_VALUE_INT (*arg) = gimp_context_get_paint_mode (context);
|
||||
break;
|
||||
case ARG_BRUSH:
|
||||
GTK_VALUE_POINTER (*arg) = gimp_context_get_brush (context);
|
||||
break;
|
||||
case ARG_PATTERN:
|
||||
GTK_VALUE_POINTER (*arg) = gimp_context_get_pattern (context);
|
||||
break;
|
||||
case ARG_GRADIENT:
|
||||
GTK_VALUE_POINTER (*arg) = gimp_context_get_gradient (context);
|
||||
break;
|
||||
default:
|
||||
arg->type = GTK_TYPE_INVALID;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* public functions ********************************************************/
|
||||
|
||||
|
@ -863,6 +906,89 @@ gimp_context_copy_args (GimpContext *src,
|
|||
|
||||
/* attribute access functions */
|
||||
|
||||
/*****************************************************************************/
|
||||
/* manipulate by GtkType ***************************************************/
|
||||
|
||||
GimpContextArgType
|
||||
gimp_context_type_to_arg (GtkType type)
|
||||
{
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < GIMP_CONTEXT_NUM_ARGS; i++)
|
||||
{
|
||||
if (gimp_context_arg_types[i] == type)
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
const gchar *
|
||||
gimp_context_type_to_signal_name (GtkType type)
|
||||
{
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < GIMP_CONTEXT_NUM_ARGS; i++)
|
||||
{
|
||||
if (gimp_context_arg_types[i] == type)
|
||||
return gimp_context_signal_names[i];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GimpObject *
|
||||
gimp_context_get_by_type (GimpContext *context,
|
||||
GtkType type)
|
||||
{
|
||||
GimpContextArgType arg;
|
||||
GimpObject *object = NULL;
|
||||
|
||||
context_check_current (context);
|
||||
context_return_val_if_fail (context, NULL);
|
||||
g_return_val_if_fail ((arg = gimp_context_type_to_arg (type)) != -1, NULL);
|
||||
|
||||
gtk_object_get (GTK_OBJECT (context),
|
||||
gimp_context_arg_names[arg], &object,
|
||||
NULL);
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_context_set_by_type (GimpContext *context,
|
||||
GtkType type,
|
||||
GimpObject *object)
|
||||
{
|
||||
GimpContextArgType arg;
|
||||
|
||||
context_check_current (context);
|
||||
context_return_if_fail (context);
|
||||
g_return_if_fail ((arg = gimp_context_type_to_arg (type)) != -1);
|
||||
|
||||
gtk_object_set (GTK_OBJECT (context),
|
||||
gimp_context_arg_names[arg], object,
|
||||
NULL);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_context_changed_by_type (GimpContext *context,
|
||||
GtkType type)
|
||||
{
|
||||
GimpContextArgType arg;
|
||||
GimpObject *object;
|
||||
|
||||
context_check_current (context);
|
||||
context_return_if_fail (context);
|
||||
g_return_if_fail ((arg = gimp_context_type_to_arg (type)) != -1);
|
||||
|
||||
object = gimp_context_get_by_type (context, type);
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (context),
|
||||
gimp_context_signals[arg],
|
||||
object);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* image *******************************************************************/
|
||||
|
||||
|
|
|
@ -197,6 +197,17 @@ void gimp_context_copy_args (GimpContext *src,
|
|||
GimpContext *dest,
|
||||
GimpContextArgMask args_mask);
|
||||
|
||||
/* manipulate by GtkType */
|
||||
GimpContextArgType gimp_context_type_to_arg (GtkType type);
|
||||
const gchar * gimp_context_type_to_signal_name (GtkType type);
|
||||
GimpObject * gimp_context_get_by_type (GimpContext *context,
|
||||
GtkType type);
|
||||
void gimp_context_set_by_type (GimpContext *context,
|
||||
GtkType type,
|
||||
GimpObject *object);
|
||||
void gimp_context_changed_by_type (GimpContext *context,
|
||||
GtkType type);
|
||||
|
||||
/* image */
|
||||
GimpImage * gimp_context_get_image (GimpContext *context);
|
||||
void gimp_context_set_image (GimpContext *context,
|
||||
|
|
|
@ -34,6 +34,7 @@ static void gimp_pattern_preview_class_init (GimpPatternPreviewClass *klass);
|
|||
static void gimp_pattern_preview_init (GimpPatternPreview *preview);
|
||||
|
||||
static GtkWidget * gimp_pattern_preview_create_popup (GimpPreview *preview);
|
||||
static gboolean gimp_pattern_preview_needs_popup (GimpPreview *preview);
|
||||
|
||||
|
||||
static GimpPreviewClass *parent_class = NULL;
|
||||
|
@ -76,6 +77,7 @@ gimp_pattern_preview_class_init (GimpPatternPreviewClass *klass)
|
|||
parent_class = gtk_type_class (GIMP_TYPE_PREVIEW);
|
||||
|
||||
preview_class->create_popup = gimp_pattern_preview_create_popup;
|
||||
preview_class->needs_popup = gimp_pattern_preview_needs_popup;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -97,3 +99,25 @@ gimp_pattern_preview_create_popup (GimpPreview *preview)
|
|||
popup_height,
|
||||
FALSE, FALSE);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_pattern_preview_needs_popup (GimpPreview *preview)
|
||||
{
|
||||
GimpPattern *pattern;
|
||||
gint pattern_width;
|
||||
gint pattern_height;
|
||||
gint width;
|
||||
gint height;
|
||||
|
||||
pattern = GIMP_PATTERN (preview->viewable);
|
||||
pattern_width = pattern->mask->width;
|
||||
pattern_height = pattern->mask->height;
|
||||
|
||||
width = GTK_WIDGET (preview)->requisition.width;
|
||||
height = GTK_WIDGET (preview)->requisition.height;
|
||||
|
||||
if (pattern_width > width || pattern_height > height)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -58,6 +58,7 @@ enum
|
|||
CLICKED,
|
||||
CREATE_PREVIEW,
|
||||
CREATE_POPUP,
|
||||
NEEDS_POPUP,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
|
@ -80,6 +81,8 @@ static TempBuf * gimp_preview_create_preview (GimpPreview *preview)
|
|||
static TempBuf * gimp_preview_real_create_preview (GimpPreview *preview);
|
||||
static GtkWidget * gimp_preview_create_popup (GimpPreview *preview);
|
||||
static GtkWidget * gimp_preview_real_create_popup (GimpPreview *preview);
|
||||
static gboolean gimp_preview_needs_popup (GimpPreview *preview);
|
||||
static gboolean gimp_preview_real_needs_popup (GimpPreview *preview);
|
||||
|
||||
static void gimp_preview_popup_show (GimpPreview *preview,
|
||||
gint x,
|
||||
|
@ -157,6 +160,15 @@ gimp_preview_class_init (GimpPreviewClass *klass)
|
|||
gimp_marshal_POINTER__NONE,
|
||||
GTK_TYPE_POINTER, 0);
|
||||
|
||||
preview_signals[NEEDS_POPUP] =
|
||||
gtk_signal_new ("needs_popup",
|
||||
GTK_RUN_LAST,
|
||||
object_class->type,
|
||||
GTK_SIGNAL_OFFSET (GimpPreviewClass,
|
||||
needs_popup),
|
||||
gtk_marshal_BOOL__NONE,
|
||||
GTK_TYPE_BOOL, 0);
|
||||
|
||||
gtk_object_class_add_signals (object_class, preview_signals, LAST_SIGNAL);
|
||||
|
||||
object_class->destroy = gimp_preview_destroy;
|
||||
|
@ -170,6 +182,7 @@ gimp_preview_class_init (GimpPreviewClass *klass)
|
|||
klass->clicked = NULL;
|
||||
klass->create_preview = gimp_preview_real_create_preview;
|
||||
klass->create_popup = gimp_preview_real_create_popup;
|
||||
klass->needs_popup = gimp_preview_real_needs_popup;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -282,7 +295,7 @@ gimp_preview_button_press_event (GtkWidget *widget,
|
|||
{
|
||||
gtk_grab_add (widget);
|
||||
|
||||
if (preview->show_popup)
|
||||
if (preview->show_popup && gimp_preview_needs_popup (preview))
|
||||
{
|
||||
gimp_preview_popup_show (preview,
|
||||
bevent->x,
|
||||
|
@ -413,6 +426,23 @@ gimp_preview_real_create_popup (GimpPreview *preview)
|
|||
FALSE, FALSE);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_preview_needs_popup (GimpPreview *preview)
|
||||
{
|
||||
gboolean needs_popup = FALSE;
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (preview), preview_signals[NEEDS_POPUP],
|
||||
&needs_popup);
|
||||
|
||||
return needs_popup;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_preview_real_needs_popup (GimpPreview *preview)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_preview_popup_timeout (GimpPreview *preview)
|
||||
{
|
||||
|
|
|
@ -63,6 +63,7 @@ struct _GimpPreviewClass
|
|||
void (* clicked) (GimpPreview *preview);
|
||||
TempBuf * (* create_preview) (GimpPreview *preview);
|
||||
GtkWidget * (* create_popup) (GimpPreview *preview);
|
||||
gboolean (* needs_popup) (GimpPreview *preview);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1332,6 +1332,7 @@ static void
|
|||
container_view_new (gboolean list,
|
||||
gchar *title,
|
||||
GimpContainer *container,
|
||||
GimpContext *context,
|
||||
gint preview_width,
|
||||
gint preview_height)
|
||||
{
|
||||
|
@ -1354,6 +1355,7 @@ container_view_new (gboolean list,
|
|||
if (list)
|
||||
{
|
||||
view = gimp_container_list_view_new (container,
|
||||
context,
|
||||
preview_width,
|
||||
preview_height,
|
||||
4, 4);
|
||||
|
@ -1361,6 +1363,7 @@ container_view_new (gboolean list,
|
|||
else
|
||||
{
|
||||
view = gimp_container_grid_view_new (container,
|
||||
context,
|
||||
preview_width,
|
||||
preview_height,
|
||||
4, 4);
|
||||
|
@ -1386,42 +1389,60 @@ void
|
|||
dialogs_test_image_container_list_view_cmd_callback (GtkWidget *widget,
|
||||
gpointer client_data)
|
||||
{
|
||||
container_view_new (TRUE, "Image List", image_context, 64, 64);
|
||||
container_view_new (TRUE, "Image List",
|
||||
image_context,
|
||||
gimp_context_get_user (),
|
||||
64, 64);
|
||||
}
|
||||
|
||||
void
|
||||
dialogs_test_pattern_container_list_view_cmd_callback (GtkWidget *widget,
|
||||
gpointer client_data)
|
||||
{
|
||||
container_view_new (TRUE, "Pattern List", global_pattern_list, 24, 24);
|
||||
container_view_new (TRUE, "Pattern List",
|
||||
global_pattern_list,
|
||||
gimp_context_get_user (),
|
||||
24, 24);
|
||||
}
|
||||
|
||||
void
|
||||
dialogs_test_brush_container_list_view_cmd_callback (GtkWidget *widget,
|
||||
gpointer client_data)
|
||||
{
|
||||
container_view_new (TRUE, "Brush List", global_brush_list, 24, 24);
|
||||
container_view_new (TRUE, "Brush List",
|
||||
global_brush_list,
|
||||
gimp_context_get_user (),
|
||||
24, 24);
|
||||
}
|
||||
|
||||
void
|
||||
dialogs_test_image_container_grid_view_cmd_callback (GtkWidget *widget,
|
||||
gpointer client_data)
|
||||
{
|
||||
container_view_new (FALSE, "Image Grid", image_context, 64, 64);
|
||||
container_view_new (FALSE, "Image Grid",
|
||||
image_context,
|
||||
gimp_context_get_user (),
|
||||
64, 64);
|
||||
}
|
||||
|
||||
void
|
||||
dialogs_test_pattern_container_grid_view_cmd_callback (GtkWidget *widget,
|
||||
gpointer client_data)
|
||||
{
|
||||
container_view_new (FALSE, "Pattern Grid", global_pattern_list, 24, 24);
|
||||
container_view_new (FALSE, "Pattern Grid",
|
||||
global_pattern_list,
|
||||
gimp_context_get_user (),
|
||||
24, 24);
|
||||
}
|
||||
|
||||
void
|
||||
dialogs_test_brush_container_grid_view_cmd_callback (GtkWidget *widget,
|
||||
gpointer client_data)
|
||||
{
|
||||
container_view_new (FALSE, "Brush Grid", global_brush_list, 32, 32);
|
||||
container_view_new (FALSE, "Brush Grid",
|
||||
global_brush_list,
|
||||
gimp_context_get_user (),
|
||||
32, 32);
|
||||
}
|
||||
|
||||
/***** Help *****/
|
||||
|
|
|
@ -1332,6 +1332,7 @@ static void
|
|||
container_view_new (gboolean list,
|
||||
gchar *title,
|
||||
GimpContainer *container,
|
||||
GimpContext *context,
|
||||
gint preview_width,
|
||||
gint preview_height)
|
||||
{
|
||||
|
@ -1354,6 +1355,7 @@ container_view_new (gboolean list,
|
|||
if (list)
|
||||
{
|
||||
view = gimp_container_list_view_new (container,
|
||||
context,
|
||||
preview_width,
|
||||
preview_height,
|
||||
4, 4);
|
||||
|
@ -1361,6 +1363,7 @@ container_view_new (gboolean list,
|
|||
else
|
||||
{
|
||||
view = gimp_container_grid_view_new (container,
|
||||
context,
|
||||
preview_width,
|
||||
preview_height,
|
||||
4, 4);
|
||||
|
@ -1386,42 +1389,60 @@ void
|
|||
dialogs_test_image_container_list_view_cmd_callback (GtkWidget *widget,
|
||||
gpointer client_data)
|
||||
{
|
||||
container_view_new (TRUE, "Image List", image_context, 64, 64);
|
||||
container_view_new (TRUE, "Image List",
|
||||
image_context,
|
||||
gimp_context_get_user (),
|
||||
64, 64);
|
||||
}
|
||||
|
||||
void
|
||||
dialogs_test_pattern_container_list_view_cmd_callback (GtkWidget *widget,
|
||||
gpointer client_data)
|
||||
{
|
||||
container_view_new (TRUE, "Pattern List", global_pattern_list, 24, 24);
|
||||
container_view_new (TRUE, "Pattern List",
|
||||
global_pattern_list,
|
||||
gimp_context_get_user (),
|
||||
24, 24);
|
||||
}
|
||||
|
||||
void
|
||||
dialogs_test_brush_container_list_view_cmd_callback (GtkWidget *widget,
|
||||
gpointer client_data)
|
||||
{
|
||||
container_view_new (TRUE, "Brush List", global_brush_list, 24, 24);
|
||||
container_view_new (TRUE, "Brush List",
|
||||
global_brush_list,
|
||||
gimp_context_get_user (),
|
||||
24, 24);
|
||||
}
|
||||
|
||||
void
|
||||
dialogs_test_image_container_grid_view_cmd_callback (GtkWidget *widget,
|
||||
gpointer client_data)
|
||||
{
|
||||
container_view_new (FALSE, "Image Grid", image_context, 64, 64);
|
||||
container_view_new (FALSE, "Image Grid",
|
||||
image_context,
|
||||
gimp_context_get_user (),
|
||||
64, 64);
|
||||
}
|
||||
|
||||
void
|
||||
dialogs_test_pattern_container_grid_view_cmd_callback (GtkWidget *widget,
|
||||
gpointer client_data)
|
||||
{
|
||||
container_view_new (FALSE, "Pattern Grid", global_pattern_list, 24, 24);
|
||||
container_view_new (FALSE, "Pattern Grid",
|
||||
global_pattern_list,
|
||||
gimp_context_get_user (),
|
||||
24, 24);
|
||||
}
|
||||
|
||||
void
|
||||
dialogs_test_brush_container_grid_view_cmd_callback (GtkWidget *widget,
|
||||
gpointer client_data)
|
||||
{
|
||||
container_view_new (FALSE, "Brush Grid", global_brush_list, 32, 32);
|
||||
container_view_new (FALSE, "Brush Grid",
|
||||
global_brush_list,
|
||||
gimp_context_get_user (),
|
||||
32, 32);
|
||||
}
|
||||
|
||||
/***** Help *****/
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
#include "context_manager.h"
|
||||
#include "gimage.h"
|
||||
#include "gimpcontainer.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimpimage.h"
|
||||
#include "gimppalette.h"
|
||||
|
@ -45,16 +46,14 @@
|
|||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
/* New palette code... */
|
||||
|
||||
#define IMPORT_PREVIEW_WIDTH 80
|
||||
#define IMPORT_PREVIEW_HEIGHT 80
|
||||
#define MAX_IMAGE_COLORS (10000*2)
|
||||
#define MAX_IMAGE_COLORS (10000 * 2)
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GRAD_IMPORT = 0,
|
||||
IMAGE_IMPORT = 1,
|
||||
GRAD_IMPORT = 0,
|
||||
IMAGE_IMPORT = 1,
|
||||
INDEXED_IMPORT = 2
|
||||
} ImportType;
|
||||
|
||||
|
@ -317,11 +316,15 @@ palette_import_image_menu_activate (gint redo,
|
|||
/* Get list of images */
|
||||
if (import_dialog->import_type == INDEXED_IMPORT)
|
||||
{
|
||||
gimage_foreach (palette_import_gimlist_indexed_cb, &list);
|
||||
gimp_container_foreach (image_context,
|
||||
palette_import_gimlist_indexed_cb,
|
||||
&list);
|
||||
}
|
||||
else
|
||||
{
|
||||
gimage_foreach (palette_import_gimlist_cb, &list);
|
||||
gimp_container_foreach (image_context,
|
||||
palette_import_gimlist_cb,
|
||||
&list);
|
||||
}
|
||||
|
||||
num_images = g_slist_length (list);
|
||||
|
@ -445,11 +448,15 @@ palette_import_image_count (ImportType type)
|
|||
|
||||
if (type == INDEXED_IMPORT)
|
||||
{
|
||||
gimage_foreach (palette_import_gimlist_indexed_cb, &list);
|
||||
gimp_container_foreach (image_context,
|
||||
palette_import_gimlist_indexed_cb,
|
||||
&list);
|
||||
}
|
||||
else
|
||||
{
|
||||
gimage_foreach (palette_import_gimlist_cb, &list);
|
||||
gimp_container_foreach (image_context,
|
||||
palette_import_gimlist_cb,
|
||||
&list);
|
||||
}
|
||||
|
||||
num_images = g_slist_length (list);
|
||||
|
|
|
@ -32,8 +32,9 @@
|
|||
#include "cursorutil.h"
|
||||
#include "gdisplay_ops.h"
|
||||
#include "gdisplay.h"
|
||||
#include "gimage.h"
|
||||
#include "gimpcontainer.h"
|
||||
#include "gimphelp.h"
|
||||
#include "gimpimage.h"
|
||||
#include "gimprc.h"
|
||||
#include "image_render.h"
|
||||
#include "lc_dialog.h"
|
||||
|
@ -907,8 +908,12 @@ prefs_cancel_callback (GtkWidget *widget,
|
|||
transparency_size = old_transparency_size;
|
||||
|
||||
render_setup (transparency_type, transparency_size);
|
||||
gimage_foreach ((GFunc) gimp_image_invalidate_layer_previews, NULL);
|
||||
gimage_invalidate_previews ();
|
||||
gimp_container_foreach (image_context,
|
||||
(GFunc) gimp_image_invalidate_layer_previews,
|
||||
NULL);
|
||||
gimp_container_foreach (image_context,
|
||||
(GFunc) gimp_viewable_invalidate_preview,
|
||||
NULL);
|
||||
gdisplays_expose_full ();
|
||||
gdisplays_flush ();
|
||||
}
|
||||
|
@ -994,8 +999,12 @@ prefs_toggle_callback (GtkWidget *widget,
|
|||
*val = (gint) gtk_object_get_user_data (GTK_OBJECT (widget));
|
||||
|
||||
render_setup (transparency_type, transparency_size);
|
||||
gimage_foreach ((GFunc) gimp_image_invalidate_layer_previews, NULL);
|
||||
gimage_invalidate_previews ();
|
||||
gimp_container_foreach (image_context,
|
||||
(GFunc) gimp_image_invalidate_layer_previews,
|
||||
NULL);
|
||||
gimp_container_foreach (image_context,
|
||||
(GFunc) gimp_viewable_invalidate_preview,
|
||||
NULL);
|
||||
gdisplays_expose_full ();
|
||||
gdisplays_flush ();
|
||||
}
|
||||
|
|
|
@ -655,7 +655,9 @@ lc_dialog_create_image_menu (GimpImage **def,
|
|||
|
||||
*default_index = -1;
|
||||
|
||||
gimage_foreach (lc_dialog_create_image_menu_callback, &data);
|
||||
gimp_container_foreach (image_context,
|
||||
lc_dialog_create_image_menu_callback,
|
||||
&data);
|
||||
|
||||
if (! data.num_items)
|
||||
{
|
||||
|
|
|
@ -1532,7 +1532,7 @@ nav_window_get_gdisp (void)
|
|||
GDisplay *gdisp = NULL;
|
||||
GimpImage *gimage;
|
||||
|
||||
gimage_foreach (gimlist_cb, &list);
|
||||
gimp_container_foreach (image_context, gimlist_cb, &list);
|
||||
|
||||
if (!list)
|
||||
return NULL;
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
#include "context_manager.h"
|
||||
#include "gimage.h"
|
||||
#include "gimpcontainer.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimpimage.h"
|
||||
#include "gimppalette.h"
|
||||
|
@ -45,16 +46,14 @@
|
|||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
/* New palette code... */
|
||||
|
||||
#define IMPORT_PREVIEW_WIDTH 80
|
||||
#define IMPORT_PREVIEW_HEIGHT 80
|
||||
#define MAX_IMAGE_COLORS (10000*2)
|
||||
#define MAX_IMAGE_COLORS (10000 * 2)
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GRAD_IMPORT = 0,
|
||||
IMAGE_IMPORT = 1,
|
||||
GRAD_IMPORT = 0,
|
||||
IMAGE_IMPORT = 1,
|
||||
INDEXED_IMPORT = 2
|
||||
} ImportType;
|
||||
|
||||
|
@ -317,11 +316,15 @@ palette_import_image_menu_activate (gint redo,
|
|||
/* Get list of images */
|
||||
if (import_dialog->import_type == INDEXED_IMPORT)
|
||||
{
|
||||
gimage_foreach (palette_import_gimlist_indexed_cb, &list);
|
||||
gimp_container_foreach (image_context,
|
||||
palette_import_gimlist_indexed_cb,
|
||||
&list);
|
||||
}
|
||||
else
|
||||
{
|
||||
gimage_foreach (palette_import_gimlist_cb, &list);
|
||||
gimp_container_foreach (image_context,
|
||||
palette_import_gimlist_cb,
|
||||
&list);
|
||||
}
|
||||
|
||||
num_images = g_slist_length (list);
|
||||
|
@ -445,11 +448,15 @@ palette_import_image_count (ImportType type)
|
|||
|
||||
if (type == INDEXED_IMPORT)
|
||||
{
|
||||
gimage_foreach (palette_import_gimlist_indexed_cb, &list);
|
||||
gimp_container_foreach (image_context,
|
||||
palette_import_gimlist_indexed_cb,
|
||||
&list);
|
||||
}
|
||||
else
|
||||
{
|
||||
gimage_foreach (palette_import_gimlist_cb, &list);
|
||||
gimp_container_foreach (image_context,
|
||||
palette_import_gimlist_cb,
|
||||
&list);
|
||||
}
|
||||
|
||||
num_images = g_slist_length (list);
|
||||
|
|
|
@ -27,11 +27,13 @@
|
|||
#include "apptypes.h"
|
||||
#include "procedural_db.h"
|
||||
|
||||
#include "context_manager.h"
|
||||
#include "cursorutil.h"
|
||||
#include "drawable.h"
|
||||
#include "gdisplay.h"
|
||||
#include "gimage.h"
|
||||
#include "gimpchannel.h"
|
||||
#include "gimpcontainer.h"
|
||||
#include "gimpimage.h"
|
||||
#include "gimplayer.h"
|
||||
#include "gimplayermask.h"
|
||||
|
@ -184,7 +186,7 @@ image_list_invoker (Argument *args)
|
|||
GSList *list = NULL;
|
||||
int i;
|
||||
|
||||
gimage_foreach (gimlist_cb, &list);
|
||||
gimp_container_foreach (image_context, gimlist_cb, &list);
|
||||
num_images = g_slist_length (list);
|
||||
|
||||
if (num_images)
|
||||
|
@ -464,7 +466,7 @@ image_delete_invoker (Argument *args)
|
|||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
gimage_delete (gimage);
|
||||
gtk_object_sink (GTK_OBJECT (gimage));
|
||||
|
||||
return procedural_db_return_args (&image_delete_proc, success);
|
||||
}
|
||||
|
|
|
@ -32,8 +32,9 @@
|
|||
#include "cursorutil.h"
|
||||
#include "gdisplay_ops.h"
|
||||
#include "gdisplay.h"
|
||||
#include "gimage.h"
|
||||
#include "gimpcontainer.h"
|
||||
#include "gimphelp.h"
|
||||
#include "gimpimage.h"
|
||||
#include "gimprc.h"
|
||||
#include "image_render.h"
|
||||
#include "lc_dialog.h"
|
||||
|
@ -907,8 +908,12 @@ prefs_cancel_callback (GtkWidget *widget,
|
|||
transparency_size = old_transparency_size;
|
||||
|
||||
render_setup (transparency_type, transparency_size);
|
||||
gimage_foreach ((GFunc) gimp_image_invalidate_layer_previews, NULL);
|
||||
gimage_invalidate_previews ();
|
||||
gimp_container_foreach (image_context,
|
||||
(GFunc) gimp_image_invalidate_layer_previews,
|
||||
NULL);
|
||||
gimp_container_foreach (image_context,
|
||||
(GFunc) gimp_viewable_invalidate_preview,
|
||||
NULL);
|
||||
gdisplays_expose_full ();
|
||||
gdisplays_flush ();
|
||||
}
|
||||
|
@ -994,8 +999,12 @@ prefs_toggle_callback (GtkWidget *widget,
|
|||
*val = (gint) gtk_object_get_user_data (GTK_OBJECT (widget));
|
||||
|
||||
render_setup (transparency_type, transparency_size);
|
||||
gimage_foreach ((GFunc) gimp_image_invalidate_layer_previews, NULL);
|
||||
gimage_invalidate_previews ();
|
||||
gimp_container_foreach (image_context,
|
||||
(GFunc) gimp_image_invalidate_layer_previews,
|
||||
NULL);
|
||||
gimp_container_foreach (image_context,
|
||||
(GFunc) gimp_viewable_invalidate_preview,
|
||||
NULL);
|
||||
gdisplays_expose_full ();
|
||||
gdisplays_flush ();
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ static void gimp_brush_preview_init (GimpBrushPreview *preview);
|
|||
|
||||
static TempBuf * gimp_brush_preview_create_preview (GimpPreview *preview);
|
||||
static GtkWidget * gimp_brush_preview_create_popup (GimpPreview *preview);
|
||||
static gboolean gimp_brush_preview_needs_popup (GimpPreview *preview);
|
||||
|
||||
|
||||
static GimpPreviewClass *parent_class = NULL;
|
||||
|
@ -79,6 +80,7 @@ gimp_brush_preview_class_init (GimpBrushPreviewClass *klass)
|
|||
|
||||
preview_class->create_preview = gimp_brush_preview_create_preview;
|
||||
preview_class->create_popup = gimp_brush_preview_create_popup;
|
||||
preview_class->needs_popup = gimp_brush_preview_needs_popup;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -225,3 +227,25 @@ gimp_brush_preview_create_popup (GimpPreview *preview)
|
|||
popup_height,
|
||||
FALSE, FALSE);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_brush_preview_needs_popup (GimpPreview *preview)
|
||||
{
|
||||
GimpBrush *brush;
|
||||
gint brush_width;
|
||||
gint brush_height;
|
||||
gint width;
|
||||
gint height;
|
||||
|
||||
brush = GIMP_BRUSH (preview->viewable);
|
||||
brush_width = brush->mask->width;
|
||||
brush_height = brush->mask->height;
|
||||
|
||||
width = GTK_WIDGET (preview)->requisition.width;
|
||||
height = GTK_WIDGET (preview)->requisition.height;
|
||||
|
||||
if (brush_width > width || brush_height > height)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "colormaps.h"
|
||||
#include "gimpcontainer.h"
|
||||
#include "gimpcontainergridview.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimppreview.h"
|
||||
#include "gimpconstrainedhwrapbox.h"
|
||||
|
||||
|
@ -44,6 +45,8 @@ static void gimp_container_grid_view_remove_item (GimpContainerView *v
|
|||
gpointer insert_data);
|
||||
static void gimp_container_grid_view_clear_items (GimpContainerView *view);
|
||||
static void gimp_container_grid_view_set_preview_size (GimpContainerView *view);
|
||||
static void gimp_container_grid_view_item_selected (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
|
||||
static GimpContainerViewClass *parent_class = NULL;
|
||||
|
@ -146,6 +149,7 @@ gimp_container_grid_view_destroy (GtkObject *object)
|
|||
|
||||
GtkWidget *
|
||||
gimp_container_grid_view_new (GimpContainer *container,
|
||||
GimpContext *context,
|
||||
gint preview_width,
|
||||
gint preview_height,
|
||||
gint min_items_x,
|
||||
|
@ -156,6 +160,7 @@ gimp_container_grid_view_new (GimpContainer *container,
|
|||
|
||||
g_return_val_if_fail (container != NULL, NULL);
|
||||
g_return_val_if_fail (GIMP_IS_CONTAINER (container), NULL);
|
||||
g_return_val_if_fail (! context || GIMP_IS_CONTEXT (context), NULL);
|
||||
g_return_val_if_fail (preview_width > 0 && preview_width <= 64, NULL);
|
||||
g_return_val_if_fail (preview_height > 0 && preview_height <= 64, NULL);
|
||||
g_return_val_if_fail (min_items_x > 0 && min_items_x <= 64, NULL);
|
||||
|
@ -174,6 +179,8 @@ gimp_container_grid_view_new (GimpContainer *container,
|
|||
|
||||
gimp_container_view_set_container (view, container);
|
||||
|
||||
gimp_container_view_set_context (view, context);
|
||||
|
||||
return GTK_WIDGET (grid_view);
|
||||
}
|
||||
|
||||
|
@ -200,6 +207,10 @@ gimp_container_grid_view_insert_item (GimpContainerView *view,
|
|||
|
||||
gtk_widget_show (preview);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (preview), "clicked",
|
||||
GTK_SIGNAL_FUNC (gimp_container_grid_view_item_selected),
|
||||
view);
|
||||
|
||||
return (gpointer) preview;
|
||||
}
|
||||
|
||||
|
@ -251,3 +262,11 @@ gimp_container_grid_view_set_preview_size (GimpContainerView *view)
|
|||
|
||||
gtk_widget_queue_resize (grid_view->wrap_box);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_container_grid_view_item_selected (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
gimp_container_view_item_selected (GIMP_CONTAINER_VIEW (data),
|
||||
GIMP_PREVIEW (widget)->viewable);
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@ struct _GimpContainerGridViewClass
|
|||
|
||||
GtkType gimp_container_grid_view_get_type (void);
|
||||
GtkWidget * gimp_container_grid_view_new (GimpContainer *container,
|
||||
GimpContext *context,
|
||||
gint preview_width,
|
||||
gint preview_height,
|
||||
gint min_items_x,
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "appenv.h"
|
||||
#include "gimpcontainer.h"
|
||||
#include "gimpcontainerlistview.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimplist.h"
|
||||
#include "gimppreview.h"
|
||||
|
||||
|
@ -41,11 +42,17 @@ static gpointer gimp_container_list_view_insert_item (GimpContainerView *v
|
|||
static void gimp_container_list_view_remove_item (GimpContainerView *view,
|
||||
GimpViewable *viewable,
|
||||
gpointer insert_data);
|
||||
static void gimp_container_list_view_select_item (GimpContainerView *view,
|
||||
GimpViewable *viewable,
|
||||
gpointer insert_data);
|
||||
static void gimp_container_list_view_clear_items (GimpContainerView *view);
|
||||
static void gimp_container_list_view_set_preview_size (GimpContainerView *view);
|
||||
|
||||
static void gimp_container_list_view_name_changed (GimpContainerListView *list_view,
|
||||
GimpViewable *viewable);
|
||||
static void gimp_container_list_view_item_selected (GtkWidget *widget,
|
||||
GtkWidget *child,
|
||||
gpointer data);
|
||||
|
||||
|
||||
static GimpContainerViewClass *parent_class = NULL;
|
||||
|
@ -92,6 +99,7 @@ gimp_container_list_view_class_init (GimpContainerListViewClass *klass)
|
|||
|
||||
container_view_class->insert_item = gimp_container_list_view_insert_item;
|
||||
container_view_class->remove_item = gimp_container_list_view_remove_item;
|
||||
container_view_class->select_item = gimp_container_list_view_select_item;
|
||||
container_view_class->clear_items = gimp_container_list_view_clear_items;
|
||||
container_view_class->set_preview_size = gimp_container_list_view_set_preview_size;
|
||||
}
|
||||
|
@ -121,6 +129,10 @@ gimp_container_list_view_init (GimpContainerListView *list_view)
|
|||
GTK_WIDGET_UNSET_FLAGS (GTK_SCROLLED_WINDOW (scrolled_win)->vscrollbar,
|
||||
GTK_CAN_FOCUS);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (list_view->gtk_list), "select_child",
|
||||
GTK_SIGNAL_FUNC (gimp_container_list_view_item_selected),
|
||||
list_view);
|
||||
|
||||
gtk_widget_show (list_view->gtk_list);
|
||||
gtk_widget_show (scrolled_win);
|
||||
}
|
||||
|
@ -138,6 +150,7 @@ gimp_container_list_view_destroy (GtkObject *object)
|
|||
|
||||
GtkWidget *
|
||||
gimp_container_list_view_new (GimpContainer *container,
|
||||
GimpContext *context,
|
||||
gint preview_width,
|
||||
gint preview_height,
|
||||
gint min_items_x,
|
||||
|
@ -148,6 +161,7 @@ gimp_container_list_view_new (GimpContainer *container,
|
|||
|
||||
g_return_val_if_fail (container != NULL, NULL);
|
||||
g_return_val_if_fail (GIMP_IS_CONTAINER (container), NULL);
|
||||
g_return_val_if_fail (! context || GIMP_IS_CONTEXT (context), NULL);
|
||||
g_return_val_if_fail (preview_width > 0 && preview_width <= 64, NULL);
|
||||
g_return_val_if_fail (preview_height > 0 && preview_height <= 64, NULL);
|
||||
g_return_val_if_fail (min_items_x > 0 && min_items_x <= 64, NULL);
|
||||
|
@ -166,6 +180,8 @@ gimp_container_list_view_new (GimpContainer *container,
|
|||
|
||||
gimp_container_view_set_container (view, container);
|
||||
|
||||
gimp_container_view_set_context (view, context);
|
||||
|
||||
return GTK_WIDGET (list_view);
|
||||
}
|
||||
|
||||
|
@ -243,6 +259,31 @@ gimp_container_list_view_remove_item (GimpContainerView *view,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_container_list_view_select_item (GimpContainerView *view,
|
||||
GimpViewable *viewable,
|
||||
gpointer insert_data)
|
||||
{
|
||||
GimpContainerListView *list_view;
|
||||
GtkWidget *list_item;
|
||||
|
||||
list_view = GIMP_CONTAINER_LIST_VIEW (view);
|
||||
list_item = GTK_WIDGET (insert_data);
|
||||
|
||||
if (list_item)
|
||||
{
|
||||
gtk_signal_handler_block_by_func (GTK_OBJECT (list_view->gtk_list),
|
||||
gimp_container_list_view_item_selected,
|
||||
list_view);
|
||||
|
||||
gtk_list_select_child (GTK_LIST (list_view->gtk_list), list_item);
|
||||
|
||||
gtk_signal_handler_unblock_by_func (GTK_OBJECT (list_view->gtk_list),
|
||||
gimp_container_list_view_item_selected,
|
||||
list_view);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_container_list_view_clear_items (GimpContainerView *view)
|
||||
{
|
||||
|
@ -299,3 +340,17 @@ gimp_container_list_view_name_changed (GimpContainerListView *list_view,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_container_list_view_item_selected (GtkWidget *widget,
|
||||
GtkWidget *child,
|
||||
gpointer data)
|
||||
{
|
||||
GimpViewable *viewable;
|
||||
|
||||
viewable = GIMP_PREVIEW (gtk_object_get_data (GTK_OBJECT (child),
|
||||
"preview"))->viewable;
|
||||
|
||||
gimp_container_view_item_selected (GIMP_CONTAINER_VIEW (data),
|
||||
viewable);
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ struct _GimpContainerListViewClass
|
|||
|
||||
GtkType gimp_container_list_view_get_type (void);
|
||||
GtkWidget * gimp_container_list_view_new (GimpContainer *container,
|
||||
GimpContext *context,
|
||||
gint preview_width,
|
||||
gint preview_height,
|
||||
gint min_items_x,
|
||||
|
|
|
@ -24,13 +24,16 @@
|
|||
|
||||
#include "gimpcontainer.h"
|
||||
#include "gimpcontainerview.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimpmarshal.h"
|
||||
#include "gimpviewable.h"
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
INSERT_ITEM,
|
||||
REMOVE_ITEM,
|
||||
SELECT_ITEM,
|
||||
CLEAR_ITEMS,
|
||||
SET_PREVIEW_SIZE,
|
||||
LAST_SIGNAL
|
||||
|
@ -52,6 +55,10 @@ static void gimp_container_view_remove (GimpContainerView *view,
|
|||
GimpViewable *viewable,
|
||||
GimpContainer *container);
|
||||
|
||||
static void gimp_container_view_context_changed (GimpContext *context,
|
||||
GimpViewable *viewable,
|
||||
GimpContainerView *view);
|
||||
|
||||
|
||||
static guint view_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
|
@ -114,6 +121,17 @@ gimp_container_view_class_init (GimpContainerViewClass *klass)
|
|||
GIMP_TYPE_OBJECT,
|
||||
GTK_TYPE_POINTER);
|
||||
|
||||
view_signals[SELECT_ITEM] =
|
||||
gtk_signal_new ("select_item",
|
||||
GTK_RUN_FIRST,
|
||||
object_class->type,
|
||||
GTK_SIGNAL_OFFSET (GimpContainerViewClass,
|
||||
select_item),
|
||||
gtk_marshal_NONE__POINTER_POINTER,
|
||||
GTK_TYPE_NONE, 2,
|
||||
GIMP_TYPE_OBJECT,
|
||||
GTK_TYPE_POINTER);
|
||||
|
||||
view_signals[CLEAR_ITEMS] =
|
||||
gtk_signal_new ("clear_items",
|
||||
GTK_RUN_FIRST,
|
||||
|
@ -135,13 +153,21 @@ gimp_container_view_class_init (GimpContainerViewClass *klass)
|
|||
gtk_object_class_add_signals (object_class, view_signals, LAST_SIGNAL);
|
||||
|
||||
object_class->destroy = gimp_container_view_destroy;
|
||||
|
||||
klass->insert_item = NULL;
|
||||
klass->remove_item = NULL;
|
||||
klass->select_item = NULL;
|
||||
klass->clear_items = NULL;
|
||||
klass->set_preview_size = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_container_view_init (GimpContainerView *view)
|
||||
{
|
||||
view->container = NULL;
|
||||
view->hash_table = NULL;
|
||||
view->container = NULL;
|
||||
view->context = NULL;
|
||||
|
||||
view->hash_table = NULL;
|
||||
|
||||
view->preview_width = 0;
|
||||
view->preview_height = 0;
|
||||
|
@ -181,6 +207,13 @@ gimp_container_view_set_container (GimpContainerView *view,
|
|||
g_hash_table_destroy (view->hash_table);
|
||||
|
||||
gimp_container_view_clear (view);
|
||||
|
||||
if (view->context)
|
||||
{
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (view->context),
|
||||
gimp_container_view_context_changed,
|
||||
view);
|
||||
}
|
||||
}
|
||||
|
||||
view->container = container;
|
||||
|
@ -202,6 +235,61 @@ gimp_container_view_set_container (GimpContainerView *view,
|
|||
(GTK_OBJECT (container), "remove",
|
||||
GTK_SIGNAL_FUNC (gimp_container_view_remove),
|
||||
GTK_OBJECT (view));
|
||||
|
||||
if (view->context)
|
||||
{
|
||||
gtk_signal_connect
|
||||
(GTK_OBJECT (view->context),
|
||||
gimp_context_type_to_signal_name (view->container->children_type),
|
||||
GTK_SIGNAL_FUNC (gimp_container_view_context_changed),
|
||||
view);
|
||||
|
||||
gimp_container_view_select_item
|
||||
(view,
|
||||
GIMP_VIEWABLE
|
||||
(gimp_context_get_by_type (view->context,
|
||||
view->container->children_type)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_container_view_set_context (GimpContainerView *view,
|
||||
GimpContext *context)
|
||||
{
|
||||
g_return_if_fail (view != NULL);
|
||||
g_return_if_fail (GIMP_IS_CONTAINER_VIEW (view));
|
||||
g_return_if_fail (! context || GIMP_IS_CONTEXT (context));
|
||||
|
||||
if (context == view->context)
|
||||
return;
|
||||
|
||||
if (view->context)
|
||||
{
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (view->context),
|
||||
gimp_container_view_context_changed,
|
||||
view);
|
||||
}
|
||||
|
||||
view->context = context;
|
||||
|
||||
if (view->context && view->container)
|
||||
{
|
||||
GimpObject *object;
|
||||
const gchar *signal_name;
|
||||
|
||||
signal_name =
|
||||
gimp_context_type_to_signal_name (view->container->children_type);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (view->context), signal_name,
|
||||
GTK_SIGNAL_FUNC (gimp_container_view_context_changed),
|
||||
view);
|
||||
|
||||
object = gimp_context_get_by_type (view->context,
|
||||
view->container->children_type);
|
||||
|
||||
if (object)
|
||||
gimp_container_view_select_item (view, GIMP_VIEWABLE (object));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -221,6 +309,43 @@ gimp_container_view_set_preview_size (GimpContainerView *view,
|
|||
gtk_signal_emit (GTK_OBJECT (view), view_signals[SET_PREVIEW_SIZE]);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_container_view_select_item (GimpContainerView *view,
|
||||
GimpViewable *viewable)
|
||||
{
|
||||
gpointer insert_data;
|
||||
|
||||
g_return_if_fail (view != NULL);
|
||||
g_return_if_fail (GIMP_IS_CONTAINER_VIEW (view));
|
||||
g_return_if_fail (viewable != NULL);
|
||||
g_return_if_fail (GIMP_IS_VIEWABLE (viewable));
|
||||
|
||||
insert_data = g_hash_table_lookup (view->hash_table, viewable);
|
||||
|
||||
if (insert_data)
|
||||
{
|
||||
gtk_signal_emit (GTK_OBJECT (view), view_signals[SELECT_ITEM],
|
||||
viewable, insert_data);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_container_view_item_selected (GimpContainerView *view,
|
||||
GimpViewable *viewable)
|
||||
{
|
||||
g_return_if_fail (view != NULL);
|
||||
g_return_if_fail (GIMP_IS_CONTAINER_VIEW (view));
|
||||
g_return_if_fail (viewable != NULL);
|
||||
g_return_if_fail (GIMP_IS_VIEWABLE (viewable));
|
||||
|
||||
if (! (view->container && view->context))
|
||||
return;
|
||||
|
||||
gimp_context_set_by_type (view->context,
|
||||
view->container->children_type,
|
||||
GIMP_OBJECT (viewable));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_container_view_clear (GimpContainerView *view)
|
||||
{
|
||||
|
@ -273,3 +398,19 @@ gimp_container_view_remove (GimpContainerView *view,
|
|||
viewable, insert_data);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_container_view_context_changed (GimpContext *context,
|
||||
GimpViewable *viewable,
|
||||
GimpContainerView *view)
|
||||
{
|
||||
gpointer insert_data;
|
||||
|
||||
insert_data = g_hash_table_lookup (view->hash_table, viewable);
|
||||
|
||||
if (insert_data)
|
||||
{
|
||||
gtk_signal_emit (GTK_OBJECT (view), view_signals[SELECT_ITEM],
|
||||
viewable, insert_data);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ struct _GimpContainerView
|
|||
GtkVBox parent_instance;
|
||||
|
||||
GimpContainer *container;
|
||||
GimpContext *context;
|
||||
|
||||
GHashTable *hash_table;
|
||||
|
||||
|
@ -55,6 +56,9 @@ struct _GimpContainerViewClass
|
|||
void (* remove_item) (GimpContainerView *view,
|
||||
GimpViewable *object,
|
||||
gpointer insert_data);
|
||||
void (* select_item) (GimpContainerView *view,
|
||||
GimpViewable *object,
|
||||
gpointer insert_data);
|
||||
void (* clear_items) (GimpContainerView *view);
|
||||
void (* set_preview_size) (GimpContainerView *view);
|
||||
};
|
||||
|
@ -64,9 +68,19 @@ GtkType gimp_container_view_get_type (void);
|
|||
|
||||
void gimp_container_view_set_container (GimpContainerView *view,
|
||||
GimpContainer *container);
|
||||
void gimp_container_view_set_context (GimpContainerView *view,
|
||||
GimpContext *context);
|
||||
void gimp_container_view_set_preview_size (GimpContainerView *view,
|
||||
gint width,
|
||||
gint height);
|
||||
void gimp_container_view_select_item (GimpContainerView *view,
|
||||
GimpViewable *viewable);
|
||||
|
||||
|
||||
/* private */
|
||||
|
||||
void gimp_container_view_item_selected (GimpContainerView *view,
|
||||
GimpViewable *item);
|
||||
|
||||
|
||||
#endif /* __GIMP_CONTAINER_VIEW_H__ */
|
||||
|
|
|
@ -34,6 +34,7 @@ static void gimp_pattern_preview_class_init (GimpPatternPreviewClass *klass);
|
|||
static void gimp_pattern_preview_init (GimpPatternPreview *preview);
|
||||
|
||||
static GtkWidget * gimp_pattern_preview_create_popup (GimpPreview *preview);
|
||||
static gboolean gimp_pattern_preview_needs_popup (GimpPreview *preview);
|
||||
|
||||
|
||||
static GimpPreviewClass *parent_class = NULL;
|
||||
|
@ -76,6 +77,7 @@ gimp_pattern_preview_class_init (GimpPatternPreviewClass *klass)
|
|||
parent_class = gtk_type_class (GIMP_TYPE_PREVIEW);
|
||||
|
||||
preview_class->create_popup = gimp_pattern_preview_create_popup;
|
||||
preview_class->needs_popup = gimp_pattern_preview_needs_popup;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -97,3 +99,25 @@ gimp_pattern_preview_create_popup (GimpPreview *preview)
|
|||
popup_height,
|
||||
FALSE, FALSE);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_pattern_preview_needs_popup (GimpPreview *preview)
|
||||
{
|
||||
GimpPattern *pattern;
|
||||
gint pattern_width;
|
||||
gint pattern_height;
|
||||
gint width;
|
||||
gint height;
|
||||
|
||||
pattern = GIMP_PATTERN (preview->viewable);
|
||||
pattern_width = pattern->mask->width;
|
||||
pattern_height = pattern->mask->height;
|
||||
|
||||
width = GTK_WIDGET (preview)->requisition.width;
|
||||
height = GTK_WIDGET (preview)->requisition.height;
|
||||
|
||||
if (pattern_width > width || pattern_height > height)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -58,6 +58,7 @@ enum
|
|||
CLICKED,
|
||||
CREATE_PREVIEW,
|
||||
CREATE_POPUP,
|
||||
NEEDS_POPUP,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
|
@ -80,6 +81,8 @@ static TempBuf * gimp_preview_create_preview (GimpPreview *preview)
|
|||
static TempBuf * gimp_preview_real_create_preview (GimpPreview *preview);
|
||||
static GtkWidget * gimp_preview_create_popup (GimpPreview *preview);
|
||||
static GtkWidget * gimp_preview_real_create_popup (GimpPreview *preview);
|
||||
static gboolean gimp_preview_needs_popup (GimpPreview *preview);
|
||||
static gboolean gimp_preview_real_needs_popup (GimpPreview *preview);
|
||||
|
||||
static void gimp_preview_popup_show (GimpPreview *preview,
|
||||
gint x,
|
||||
|
@ -157,6 +160,15 @@ gimp_preview_class_init (GimpPreviewClass *klass)
|
|||
gimp_marshal_POINTER__NONE,
|
||||
GTK_TYPE_POINTER, 0);
|
||||
|
||||
preview_signals[NEEDS_POPUP] =
|
||||
gtk_signal_new ("needs_popup",
|
||||
GTK_RUN_LAST,
|
||||
object_class->type,
|
||||
GTK_SIGNAL_OFFSET (GimpPreviewClass,
|
||||
needs_popup),
|
||||
gtk_marshal_BOOL__NONE,
|
||||
GTK_TYPE_BOOL, 0);
|
||||
|
||||
gtk_object_class_add_signals (object_class, preview_signals, LAST_SIGNAL);
|
||||
|
||||
object_class->destroy = gimp_preview_destroy;
|
||||
|
@ -170,6 +182,7 @@ gimp_preview_class_init (GimpPreviewClass *klass)
|
|||
klass->clicked = NULL;
|
||||
klass->create_preview = gimp_preview_real_create_preview;
|
||||
klass->create_popup = gimp_preview_real_create_popup;
|
||||
klass->needs_popup = gimp_preview_real_needs_popup;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -282,7 +295,7 @@ gimp_preview_button_press_event (GtkWidget *widget,
|
|||
{
|
||||
gtk_grab_add (widget);
|
||||
|
||||
if (preview->show_popup)
|
||||
if (preview->show_popup && gimp_preview_needs_popup (preview))
|
||||
{
|
||||
gimp_preview_popup_show (preview,
|
||||
bevent->x,
|
||||
|
@ -413,6 +426,23 @@ gimp_preview_real_create_popup (GimpPreview *preview)
|
|||
FALSE, FALSE);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_preview_needs_popup (GimpPreview *preview)
|
||||
{
|
||||
gboolean needs_popup = FALSE;
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (preview), preview_signals[NEEDS_POPUP],
|
||||
&needs_popup);
|
||||
|
||||
return needs_popup;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_preview_real_needs_popup (GimpPreview *preview)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_preview_popup_timeout (GimpPreview *preview)
|
||||
{
|
||||
|
|
|
@ -63,6 +63,7 @@ struct _GimpPreviewClass
|
|||
void (* clicked) (GimpPreview *preview);
|
||||
TempBuf * (* create_preview) (GimpPreview *preview);
|
||||
GtkWidget * (* create_popup) (GimpPreview *preview);
|
||||
gboolean (* needs_popup) (GimpPreview *preview);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -58,6 +58,7 @@ enum
|
|||
CLICKED,
|
||||
CREATE_PREVIEW,
|
||||
CREATE_POPUP,
|
||||
NEEDS_POPUP,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
|
@ -80,6 +81,8 @@ static TempBuf * gimp_preview_create_preview (GimpPreview *preview)
|
|||
static TempBuf * gimp_preview_real_create_preview (GimpPreview *preview);
|
||||
static GtkWidget * gimp_preview_create_popup (GimpPreview *preview);
|
||||
static GtkWidget * gimp_preview_real_create_popup (GimpPreview *preview);
|
||||
static gboolean gimp_preview_needs_popup (GimpPreview *preview);
|
||||
static gboolean gimp_preview_real_needs_popup (GimpPreview *preview);
|
||||
|
||||
static void gimp_preview_popup_show (GimpPreview *preview,
|
||||
gint x,
|
||||
|
@ -157,6 +160,15 @@ gimp_preview_class_init (GimpPreviewClass *klass)
|
|||
gimp_marshal_POINTER__NONE,
|
||||
GTK_TYPE_POINTER, 0);
|
||||
|
||||
preview_signals[NEEDS_POPUP] =
|
||||
gtk_signal_new ("needs_popup",
|
||||
GTK_RUN_LAST,
|
||||
object_class->type,
|
||||
GTK_SIGNAL_OFFSET (GimpPreviewClass,
|
||||
needs_popup),
|
||||
gtk_marshal_BOOL__NONE,
|
||||
GTK_TYPE_BOOL, 0);
|
||||
|
||||
gtk_object_class_add_signals (object_class, preview_signals, LAST_SIGNAL);
|
||||
|
||||
object_class->destroy = gimp_preview_destroy;
|
||||
|
@ -170,6 +182,7 @@ gimp_preview_class_init (GimpPreviewClass *klass)
|
|||
klass->clicked = NULL;
|
||||
klass->create_preview = gimp_preview_real_create_preview;
|
||||
klass->create_popup = gimp_preview_real_create_popup;
|
||||
klass->needs_popup = gimp_preview_real_needs_popup;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -282,7 +295,7 @@ gimp_preview_button_press_event (GtkWidget *widget,
|
|||
{
|
||||
gtk_grab_add (widget);
|
||||
|
||||
if (preview->show_popup)
|
||||
if (preview->show_popup && gimp_preview_needs_popup (preview))
|
||||
{
|
||||
gimp_preview_popup_show (preview,
|
||||
bevent->x,
|
||||
|
@ -413,6 +426,23 @@ gimp_preview_real_create_popup (GimpPreview *preview)
|
|||
FALSE, FALSE);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_preview_needs_popup (GimpPreview *preview)
|
||||
{
|
||||
gboolean needs_popup = FALSE;
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (preview), preview_signals[NEEDS_POPUP],
|
||||
&needs_popup);
|
||||
|
||||
return needs_popup;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_preview_real_needs_popup (GimpPreview *preview)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_preview_popup_timeout (GimpPreview *preview)
|
||||
{
|
||||
|
|
|
@ -63,6 +63,7 @@ struct _GimpPreviewClass
|
|||
void (* clicked) (GimpPreview *preview);
|
||||
TempBuf * (* create_preview) (GimpPreview *preview);
|
||||
GtkWidget * (* create_popup) (GimpPreview *preview);
|
||||
gboolean (* needs_popup) (GimpPreview *preview);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ static void gimp_brush_preview_init (GimpBrushPreview *preview);
|
|||
|
||||
static TempBuf * gimp_brush_preview_create_preview (GimpPreview *preview);
|
||||
static GtkWidget * gimp_brush_preview_create_popup (GimpPreview *preview);
|
||||
static gboolean gimp_brush_preview_needs_popup (GimpPreview *preview);
|
||||
|
||||
|
||||
static GimpPreviewClass *parent_class = NULL;
|
||||
|
@ -79,6 +80,7 @@ gimp_brush_preview_class_init (GimpBrushPreviewClass *klass)
|
|||
|
||||
preview_class->create_preview = gimp_brush_preview_create_preview;
|
||||
preview_class->create_popup = gimp_brush_preview_create_popup;
|
||||
preview_class->needs_popup = gimp_brush_preview_needs_popup;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -225,3 +227,25 @@ gimp_brush_preview_create_popup (GimpPreview *preview)
|
|||
popup_height,
|
||||
FALSE, FALSE);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_brush_preview_needs_popup (GimpPreview *preview)
|
||||
{
|
||||
GimpBrush *brush;
|
||||
gint brush_width;
|
||||
gint brush_height;
|
||||
gint width;
|
||||
gint height;
|
||||
|
||||
brush = GIMP_BRUSH (preview->viewable);
|
||||
brush_width = brush->mask->width;
|
||||
brush_height = brush->mask->height;
|
||||
|
||||
width = GTK_WIDGET (preview)->requisition.width;
|
||||
height = GTK_WIDGET (preview)->requisition.height;
|
||||
|
||||
if (brush_width > width || brush_height > height)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -58,6 +58,7 @@ enum
|
|||
CLICKED,
|
||||
CREATE_PREVIEW,
|
||||
CREATE_POPUP,
|
||||
NEEDS_POPUP,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
|
@ -80,6 +81,8 @@ static TempBuf * gimp_preview_create_preview (GimpPreview *preview)
|
|||
static TempBuf * gimp_preview_real_create_preview (GimpPreview *preview);
|
||||
static GtkWidget * gimp_preview_create_popup (GimpPreview *preview);
|
||||
static GtkWidget * gimp_preview_real_create_popup (GimpPreview *preview);
|
||||
static gboolean gimp_preview_needs_popup (GimpPreview *preview);
|
||||
static gboolean gimp_preview_real_needs_popup (GimpPreview *preview);
|
||||
|
||||
static void gimp_preview_popup_show (GimpPreview *preview,
|
||||
gint x,
|
||||
|
@ -157,6 +160,15 @@ gimp_preview_class_init (GimpPreviewClass *klass)
|
|||
gimp_marshal_POINTER__NONE,
|
||||
GTK_TYPE_POINTER, 0);
|
||||
|
||||
preview_signals[NEEDS_POPUP] =
|
||||
gtk_signal_new ("needs_popup",
|
||||
GTK_RUN_LAST,
|
||||
object_class->type,
|
||||
GTK_SIGNAL_OFFSET (GimpPreviewClass,
|
||||
needs_popup),
|
||||
gtk_marshal_BOOL__NONE,
|
||||
GTK_TYPE_BOOL, 0);
|
||||
|
||||
gtk_object_class_add_signals (object_class, preview_signals, LAST_SIGNAL);
|
||||
|
||||
object_class->destroy = gimp_preview_destroy;
|
||||
|
@ -170,6 +182,7 @@ gimp_preview_class_init (GimpPreviewClass *klass)
|
|||
klass->clicked = NULL;
|
||||
klass->create_preview = gimp_preview_real_create_preview;
|
||||
klass->create_popup = gimp_preview_real_create_popup;
|
||||
klass->needs_popup = gimp_preview_real_needs_popup;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -282,7 +295,7 @@ gimp_preview_button_press_event (GtkWidget *widget,
|
|||
{
|
||||
gtk_grab_add (widget);
|
||||
|
||||
if (preview->show_popup)
|
||||
if (preview->show_popup && gimp_preview_needs_popup (preview))
|
||||
{
|
||||
gimp_preview_popup_show (preview,
|
||||
bevent->x,
|
||||
|
@ -413,6 +426,23 @@ gimp_preview_real_create_popup (GimpPreview *preview)
|
|||
FALSE, FALSE);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_preview_needs_popup (GimpPreview *preview)
|
||||
{
|
||||
gboolean needs_popup = FALSE;
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (preview), preview_signals[NEEDS_POPUP],
|
||||
&needs_popup);
|
||||
|
||||
return needs_popup;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_preview_real_needs_popup (GimpPreview *preview)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_preview_popup_timeout (GimpPreview *preview)
|
||||
{
|
||||
|
|
|
@ -63,6 +63,7 @@ struct _GimpPreviewClass
|
|||
void (* clicked) (GimpPreview *preview);
|
||||
TempBuf * (* create_preview) (GimpPreview *preview);
|
||||
GtkWidget * (* create_popup) (GimpPreview *preview);
|
||||
gboolean (* needs_popup) (GimpPreview *preview);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -58,6 +58,7 @@ enum
|
|||
CLICKED,
|
||||
CREATE_PREVIEW,
|
||||
CREATE_POPUP,
|
||||
NEEDS_POPUP,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
|
@ -80,6 +81,8 @@ static TempBuf * gimp_preview_create_preview (GimpPreview *preview)
|
|||
static TempBuf * gimp_preview_real_create_preview (GimpPreview *preview);
|
||||
static GtkWidget * gimp_preview_create_popup (GimpPreview *preview);
|
||||
static GtkWidget * gimp_preview_real_create_popup (GimpPreview *preview);
|
||||
static gboolean gimp_preview_needs_popup (GimpPreview *preview);
|
||||
static gboolean gimp_preview_real_needs_popup (GimpPreview *preview);
|
||||
|
||||
static void gimp_preview_popup_show (GimpPreview *preview,
|
||||
gint x,
|
||||
|
@ -157,6 +160,15 @@ gimp_preview_class_init (GimpPreviewClass *klass)
|
|||
gimp_marshal_POINTER__NONE,
|
||||
GTK_TYPE_POINTER, 0);
|
||||
|
||||
preview_signals[NEEDS_POPUP] =
|
||||
gtk_signal_new ("needs_popup",
|
||||
GTK_RUN_LAST,
|
||||
object_class->type,
|
||||
GTK_SIGNAL_OFFSET (GimpPreviewClass,
|
||||
needs_popup),
|
||||
gtk_marshal_BOOL__NONE,
|
||||
GTK_TYPE_BOOL, 0);
|
||||
|
||||
gtk_object_class_add_signals (object_class, preview_signals, LAST_SIGNAL);
|
||||
|
||||
object_class->destroy = gimp_preview_destroy;
|
||||
|
@ -170,6 +182,7 @@ gimp_preview_class_init (GimpPreviewClass *klass)
|
|||
klass->clicked = NULL;
|
||||
klass->create_preview = gimp_preview_real_create_preview;
|
||||
klass->create_popup = gimp_preview_real_create_popup;
|
||||
klass->needs_popup = gimp_preview_real_needs_popup;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -282,7 +295,7 @@ gimp_preview_button_press_event (GtkWidget *widget,
|
|||
{
|
||||
gtk_grab_add (widget);
|
||||
|
||||
if (preview->show_popup)
|
||||
if (preview->show_popup && gimp_preview_needs_popup (preview))
|
||||
{
|
||||
gimp_preview_popup_show (preview,
|
||||
bevent->x,
|
||||
|
@ -413,6 +426,23 @@ gimp_preview_real_create_popup (GimpPreview *preview)
|
|||
FALSE, FALSE);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_preview_needs_popup (GimpPreview *preview)
|
||||
{
|
||||
gboolean needs_popup = FALSE;
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (preview), preview_signals[NEEDS_POPUP],
|
||||
&needs_popup);
|
||||
|
||||
return needs_popup;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_preview_real_needs_popup (GimpPreview *preview)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_preview_popup_timeout (GimpPreview *preview)
|
||||
{
|
||||
|
|
|
@ -63,6 +63,7 @@ struct _GimpPreviewClass
|
|||
void (* clicked) (GimpPreview *preview);
|
||||
TempBuf * (* create_preview) (GimpPreview *preview);
|
||||
GtkWidget * (* create_popup) (GimpPreview *preview);
|
||||
gboolean (* needs_popup) (GimpPreview *preview);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ static void gimp_brush_preview_init (GimpBrushPreview *preview);
|
|||
|
||||
static TempBuf * gimp_brush_preview_create_preview (GimpPreview *preview);
|
||||
static GtkWidget * gimp_brush_preview_create_popup (GimpPreview *preview);
|
||||
static gboolean gimp_brush_preview_needs_popup (GimpPreview *preview);
|
||||
|
||||
|
||||
static GimpPreviewClass *parent_class = NULL;
|
||||
|
@ -79,6 +80,7 @@ gimp_brush_preview_class_init (GimpBrushPreviewClass *klass)
|
|||
|
||||
preview_class->create_preview = gimp_brush_preview_create_preview;
|
||||
preview_class->create_popup = gimp_brush_preview_create_popup;
|
||||
preview_class->needs_popup = gimp_brush_preview_needs_popup;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -225,3 +227,25 @@ gimp_brush_preview_create_popup (GimpPreview *preview)
|
|||
popup_height,
|
||||
FALSE, FALSE);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_brush_preview_needs_popup (GimpPreview *preview)
|
||||
{
|
||||
GimpBrush *brush;
|
||||
gint brush_width;
|
||||
gint brush_height;
|
||||
gint width;
|
||||
gint height;
|
||||
|
||||
brush = GIMP_BRUSH (preview->viewable);
|
||||
brush_width = brush->mask->width;
|
||||
brush_height = brush->mask->height;
|
||||
|
||||
width = GTK_WIDGET (preview)->requisition.width;
|
||||
height = GTK_WIDGET (preview)->requisition.height;
|
||||
|
||||
if (brush_width > width || brush_height > height)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -1808,7 +1808,7 @@ xcf_load_image (XcfInfo *info)
|
|||
g_message ("XCF: This file is corrupt! I could not even\n"
|
||||
"salvage any partial image data from it.");
|
||||
|
||||
gimage_delete (gimage);
|
||||
gtk_object_unref (GTK_OBJECT (gimage));
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -1808,7 +1808,7 @@ xcf_load_image (XcfInfo *info)
|
|||
g_message ("XCF: This file is corrupt! I could not even\n"
|
||||
"salvage any partial image data from it.");
|
||||
|
||||
gimage_delete (gimage);
|
||||
gtk_object_unref (GTK_OBJECT (gimage));
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -228,7 +228,7 @@ HELP
|
|||
$help .= ' in the GIMP.';
|
||||
|
||||
for ($invoke{code}) {
|
||||
s/list = .*$/gimage_foreach (gimlist_cb, &list);/m;
|
||||
s/list = .*$/gimp_container_foreach (image_context, gimlist_cb, &list);/m;
|
||||
s/DRAWABLE/IMAGE/;
|
||||
s/gimp_drawable_get_ID/pdb_image_to_id/;
|
||||
}
|
||||
|
@ -347,7 +347,7 @@ HELP
|
|||
|
||||
@inargs = ( &std_image_arg );
|
||||
|
||||
%invoke = ( code => 'gimage_delete (gimage);' );
|
||||
%invoke = ( code => 'gtk_object_sink (GTK_OBJECT (gimage));' );
|
||||
}
|
||||
|
||||
sub image_free_shadow {
|
||||
|
@ -1433,8 +1433,9 @@ CODE
|
|||
}
|
||||
|
||||
|
||||
@headers = qw(<string.h> "gimage.h" "libgimpmath/gimpmath.h"
|
||||
"temp_buf.h" "libgimp/gimplimits.h" "libgimp/gimpintl.h");
|
||||
@headers = qw(<string.h> "gimage.h" "context_manager.h" "gimpcontainer.h"
|
||||
"libgimpmath/gimpmath.h" "temp_buf.h" "libgimp/gimplimits.h"
|
||||
"libgimp/gimpintl.h");
|
||||
|
||||
$extra{app}->{code} = <<'CODE';
|
||||
/* Yuup, this is somewhat unsmooth, to say the least */
|
||||
|
|
Loading…
Reference in New Issue