2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2001-02-05 23:22:20 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2001-04-22 08:38:56 +08:00
|
|
|
* gimpcontainerview.c
|
2009-07-29 01:15:36 +08:00
|
|
|
* Copyright (C) 2001-2009 Michael Natterer <mitch@gimp.org>
|
2001-04-22 08:38:56 +08:00
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2001-02-05 23:22:20 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2001-02-05 23:22:20 +08:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2009-01-18 06:28:01 +08:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2001-02-05 23:22:20 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2003-10-11 05:24:12 +08:00
|
|
|
#include <string.h>
|
|
|
|
|
2001-02-05 23:22:20 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2001-08-05 04:38:54 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2001-05-08 11:48:54 +08:00
|
|
|
#include "widgets-types.h"
|
2001-02-05 23:22:20 +08:00
|
|
|
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpcontainer.h"
|
|
|
|
#include "core/gimpcontext.h"
|
|
|
|
#include "core/gimpmarshal.h"
|
2009-08-05 02:19:13 +08:00
|
|
|
#include "core/gimptreehandler.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpviewable.h"
|
|
|
|
|
2001-02-05 23:22:20 +08:00
|
|
|
#include "gimpcontainerview.h"
|
2001-02-19 03:44:28 +08:00
|
|
|
#include "gimpdnd.h"
|
2004-08-26 06:31:44 +08:00
|
|
|
#include "gimpviewrenderer.h"
|
2001-05-08 11:48:54 +08:00
|
|
|
|
2001-02-06 03:10:40 +08:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
2001-02-07 23:01:52 +08:00
|
|
|
SELECT_ITEM,
|
2001-02-19 03:44:28 +08:00
|
|
|
ACTIVATE_ITEM,
|
2001-04-29 23:23:01 +08:00
|
|
|
CONTEXT_ITEM,
|
2001-02-06 03:10:40 +08:00
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2004-05-24 22:51:15 +08:00
|
|
|
#define GIMP_CONTAINER_VIEW_GET_PRIVATE(obj) (gimp_container_view_get_private ((GimpContainerView *) (obj)))
|
|
|
|
|
|
|
|
|
2004-05-11 07:22:39 +08:00
|
|
|
typedef struct _GimpContainerViewPrivate GimpContainerViewPrivate;
|
|
|
|
|
|
|
|
struct _GimpContainerViewPrivate
|
|
|
|
{
|
2009-08-05 02:19:13 +08:00
|
|
|
GimpContainer *container;
|
|
|
|
GimpContext *context;
|
2004-05-11 07:22:39 +08:00
|
|
|
|
2009-08-05 02:19:13 +08:00
|
|
|
GHashTable *item_hash;
|
2004-05-11 07:22:39 +08:00
|
|
|
|
2009-08-05 02:19:13 +08:00
|
|
|
gint view_size;
|
|
|
|
gint view_border_width;
|
|
|
|
gboolean reorderable;
|
2001-08-04 03:43:19 +08:00
|
|
|
|
2004-05-11 07:22:39 +08:00
|
|
|
/* initialized by subclass */
|
2009-08-05 02:19:13 +08:00
|
|
|
GtkWidget *dnd_widget;
|
2003-12-22 00:11:06 +08:00
|
|
|
|
2009-08-05 02:19:13 +08:00
|
|
|
GimpTreeHandler *name_changed_handler;
|
2004-05-11 07:22:39 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static void gimp_container_view_iface_base_init (GimpContainerViewInterface *view_iface);
|
|
|
|
|
|
|
|
static GimpContainerViewPrivate *
|
|
|
|
gimp_container_view_get_private (GimpContainerView *view);
|
2001-02-06 03:10:40 +08:00
|
|
|
|
2001-03-12 01:24:47 +08:00
|
|
|
static void gimp_container_view_real_set_container (GimpContainerView *view,
|
2004-08-26 06:31:44 +08:00
|
|
|
GimpContainer *container);
|
2006-08-29 03:40:20 +08:00
|
|
|
static void gimp_container_view_real_set_context (GimpContainerView *view,
|
|
|
|
GimpContext *context);
|
2001-03-12 01:24:47 +08:00
|
|
|
|
2004-05-28 18:49:56 +08:00
|
|
|
static void gimp_container_view_clear_items (GimpContainerView *view);
|
|
|
|
static void gimp_container_view_real_clear_items (GimpContainerView *view);
|
|
|
|
|
2009-07-28 22:38:18 +08:00
|
|
|
static void gimp_container_view_add_container (GimpContainerView *view,
|
|
|
|
GimpContainer *container);
|
2004-05-28 18:49:56 +08:00
|
|
|
static void gimp_container_view_add_foreach (GimpViewable *viewable,
|
|
|
|
GimpContainerView *view);
|
|
|
|
static void gimp_container_view_add (GimpContainerView *view,
|
|
|
|
GimpViewable *viewable,
|
|
|
|
GimpContainer *container);
|
2009-07-28 22:38:18 +08:00
|
|
|
|
|
|
|
static void gimp_container_view_remove_container (GimpContainerView *view,
|
|
|
|
GimpContainer *container);
|
|
|
|
static void gimp_container_view_remove_foreach (GimpViewable *viewable,
|
|
|
|
GimpContainerView *view);
|
2004-05-28 18:49:56 +08:00
|
|
|
static void gimp_container_view_remove (GimpContainerView *view,
|
|
|
|
GimpViewable *viewable,
|
|
|
|
GimpContainer *container);
|
2009-07-28 22:38:18 +08:00
|
|
|
|
2004-05-28 18:49:56 +08:00
|
|
|
static void gimp_container_view_reorder (GimpContainerView *view,
|
|
|
|
GimpViewable *viewable,
|
|
|
|
gint new_index,
|
|
|
|
GimpContainer *container);
|
|
|
|
|
|
|
|
static void gimp_container_view_freeze (GimpContainerView *view,
|
|
|
|
GimpContainer *container);
|
|
|
|
static void gimp_container_view_thaw (GimpContainerView *view,
|
|
|
|
GimpContainer *container);
|
|
|
|
static void gimp_container_view_name_changed (GimpViewable *viewable,
|
|
|
|
GimpContainerView *view);
|
2003-10-19 00:23:15 +08:00
|
|
|
|
2009-07-29 03:02:32 +08:00
|
|
|
static void gimp_container_view_connect_context (GimpContainerView *view);
|
|
|
|
static void gimp_container_view_disconnect_context (GimpContainerView *view);
|
|
|
|
|
2001-08-05 04:38:54 +08:00
|
|
|
static void gimp_container_view_context_changed (GimpContext *context,
|
2004-08-26 06:31:44 +08:00
|
|
|
GimpViewable *viewable,
|
|
|
|
GimpContainerView *view);
|
2001-08-05 04:38:54 +08:00
|
|
|
static void gimp_container_view_viewable_dropped (GtkWidget *widget,
|
2004-12-31 22:36:30 +08:00
|
|
|
gint x,
|
|
|
|
gint y,
|
2004-08-26 06:31:44 +08:00
|
|
|
GimpViewable *viewable,
|
|
|
|
gpointer data);
|
2001-08-05 04:38:54 +08:00
|
|
|
static void gimp_container_view_button_viewable_dropped (GtkWidget *widget,
|
2004-12-31 22:36:30 +08:00
|
|
|
gint x,
|
|
|
|
gint y,
|
2004-08-26 06:31:44 +08:00
|
|
|
GimpViewable *viewable,
|
|
|
|
gpointer data);
|
2001-02-07 23:01:52 +08:00
|
|
|
|
2001-02-05 23:22:20 +08:00
|
|
|
|
2004-05-11 07:22:39 +08:00
|
|
|
static guint view_signals[LAST_SIGNAL] = { 0 };
|
2001-02-05 23:22:20 +08:00
|
|
|
|
|
|
|
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
GType
|
2004-05-11 07:22:39 +08:00
|
|
|
gimp_container_view_interface_get_type (void)
|
2001-02-05 23:22:20 +08:00
|
|
|
{
|
2004-05-11 07:22:39 +08:00
|
|
|
static GType iface_type = 0;
|
2001-02-05 23:22:20 +08:00
|
|
|
|
2004-05-11 07:22:39 +08:00
|
|
|
if (! iface_type)
|
2001-02-05 23:22:20 +08:00
|
|
|
{
|
2006-10-18 21:17:50 +08:00
|
|
|
const GTypeInfo iface_info =
|
2001-02-05 23:22:20 +08:00
|
|
|
{
|
2004-05-11 07:22:39 +08:00
|
|
|
sizeof (GimpContainerViewInterface),
|
2004-05-28 18:49:56 +08:00
|
|
|
(GBaseInitFunc) gimp_container_view_iface_base_init,
|
|
|
|
(GBaseFinalizeFunc) NULL,
|
2001-02-05 23:22:20 +08:00
|
|
|
};
|
2003-10-11 05:24:12 +08:00
|
|
|
|
2004-05-11 07:22:39 +08:00
|
|
|
iface_type = g_type_register_static (G_TYPE_INTERFACE,
|
|
|
|
"GimpContainerViewInterface",
|
|
|
|
&iface_info,
|
|
|
|
0);
|
|
|
|
|
|
|
|
g_type_interface_add_prerequisite (iface_type, GTK_TYPE_WIDGET);
|
2001-02-05 23:22:20 +08:00
|
|
|
}
|
|
|
|
|
2004-05-11 07:22:39 +08:00
|
|
|
return iface_type;
|
2001-02-05 23:22:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-05-11 07:22:39 +08:00
|
|
|
gimp_container_view_iface_base_init (GimpContainerViewInterface *view_iface)
|
2001-02-05 23:22:20 +08:00
|
|
|
{
|
2004-05-11 07:22:39 +08:00
|
|
|
if (view_iface->set_container)
|
|
|
|
return;
|
2001-02-05 23:22:20 +08:00
|
|
|
|
2001-02-07 23:01:52 +08:00
|
|
|
view_signals[SELECT_ITEM] =
|
2005-05-27 21:05:26 +08:00
|
|
|
g_signal_new ("select-item",
|
2004-05-11 07:22:39 +08:00
|
|
|
G_TYPE_FROM_INTERFACE (view_iface),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (GimpContainerViewInterface, select_item),
|
|
|
|
NULL, NULL,
|
|
|
|
gimp_marshal_BOOLEAN__OBJECT_POINTER,
|
|
|
|
G_TYPE_BOOLEAN, 2,
|
|
|
|
GIMP_TYPE_OBJECT,
|
|
|
|
G_TYPE_POINTER);
|
2001-02-07 23:01:52 +08:00
|
|
|
|
2001-02-19 03:44:28 +08:00
|
|
|
view_signals[ACTIVATE_ITEM] =
|
2005-05-27 21:05:26 +08:00
|
|
|
g_signal_new ("activate-item",
|
2004-05-11 07:22:39 +08:00
|
|
|
G_TYPE_FROM_INTERFACE (view_iface),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GimpContainerViewInterface, activate_item),
|
|
|
|
NULL, NULL,
|
|
|
|
gimp_marshal_VOID__OBJECT_POINTER,
|
|
|
|
G_TYPE_NONE, 2,
|
|
|
|
GIMP_TYPE_OBJECT,
|
|
|
|
G_TYPE_POINTER);
|
2001-02-19 03:44:28 +08:00
|
|
|
|
2001-04-29 23:23:01 +08:00
|
|
|
view_signals[CONTEXT_ITEM] =
|
2005-05-27 21:05:26 +08:00
|
|
|
g_signal_new ("context-item",
|
2004-05-11 07:22:39 +08:00
|
|
|
G_TYPE_FROM_INTERFACE (view_iface),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GimpContainerViewInterface, context_item),
|
|
|
|
NULL, NULL,
|
|
|
|
gimp_marshal_VOID__OBJECT_POINTER,
|
|
|
|
G_TYPE_NONE, 2,
|
|
|
|
GIMP_TYPE_OBJECT,
|
|
|
|
G_TYPE_POINTER);
|
|
|
|
|
2009-09-17 01:53:13 +08:00
|
|
|
view_iface->select_item = NULL;
|
|
|
|
view_iface->activate_item = NULL;
|
|
|
|
view_iface->context_item = NULL;
|
|
|
|
|
|
|
|
view_iface->set_container = gimp_container_view_real_set_container;
|
|
|
|
view_iface->set_context = gimp_container_view_real_set_context;
|
|
|
|
view_iface->insert_item = NULL;
|
|
|
|
view_iface->insert_item_after = NULL;
|
|
|
|
view_iface->remove_item = NULL;
|
|
|
|
view_iface->reorder_item = NULL;
|
|
|
|
view_iface->rename_item = NULL;
|
|
|
|
view_iface->clear_items = gimp_container_view_real_clear_items;
|
|
|
|
view_iface->set_view_size = NULL;
|
|
|
|
|
|
|
|
view_iface->insert_data_free = NULL;
|
|
|
|
view_iface->model_is_tree = FALSE;
|
2004-05-11 07:22:39 +08:00
|
|
|
|
|
|
|
g_object_interface_install_property (view_iface,
|
|
|
|
g_param_spec_object ("container",
|
|
|
|
NULL, NULL,
|
|
|
|
GIMP_TYPE_CONTAINER,
|
2006-01-19 04:29:40 +08:00
|
|
|
GIMP_PARAM_READWRITE));
|
2004-05-11 07:22:39 +08:00
|
|
|
|
|
|
|
g_object_interface_install_property (view_iface,
|
|
|
|
g_param_spec_object ("context",
|
|
|
|
NULL, NULL,
|
|
|
|
GIMP_TYPE_CONTEXT,
|
2006-01-19 04:29:40 +08:00
|
|
|
GIMP_PARAM_READWRITE));
|
2004-05-11 07:22:39 +08:00
|
|
|
|
|
|
|
g_object_interface_install_property (view_iface,
|
|
|
|
g_param_spec_boolean ("reorderable",
|
|
|
|
NULL, NULL,
|
|
|
|
FALSE,
|
2006-01-19 04:29:40 +08:00
|
|
|
GIMP_PARAM_READWRITE));
|
2004-05-28 18:49:56 +08:00
|
|
|
|
|
|
|
g_object_interface_install_property (view_iface,
|
2006-01-17 18:08:50 +08:00
|
|
|
g_param_spec_int ("view-size",
|
2004-05-28 18:49:56 +08:00
|
|
|
NULL, NULL,
|
|
|
|
1, GIMP_VIEWABLE_MAX_PREVIEW_SIZE,
|
2004-08-29 19:58:05 +08:00
|
|
|
GIMP_VIEW_SIZE_MEDIUM,
|
2006-01-19 04:29:40 +08:00
|
|
|
GIMP_PARAM_READWRITE |
|
2005-03-18 08:31:29 +08:00
|
|
|
G_PARAM_CONSTRUCT));
|
2004-05-28 18:49:56 +08:00
|
|
|
|
|
|
|
g_object_interface_install_property (view_iface,
|
2006-01-17 18:08:50 +08:00
|
|
|
g_param_spec_int ("view-border-width",
|
2004-05-28 18:49:56 +08:00
|
|
|
NULL, NULL,
|
2006-01-19 04:29:40 +08:00
|
|
|
0,
|
|
|
|
GIMP_VIEW_MAX_BORDER_WIDTH,
|
2004-05-28 18:49:56 +08:00
|
|
|
1,
|
2006-01-19 04:29:40 +08:00
|
|
|
GIMP_PARAM_READWRITE |
|
2005-03-18 08:31:29 +08:00
|
|
|
G_PARAM_CONSTRUCT));
|
2003-12-22 00:11:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-05-28 18:49:56 +08:00
|
|
|
gimp_container_view_private_dispose (GimpContainerView *view,
|
2004-05-11 07:22:39 +08:00
|
|
|
GimpContainerViewPrivate *private)
|
2003-12-22 00:11:06 +08:00
|
|
|
{
|
2004-05-11 01:16:50 +08:00
|
|
|
if (private->container)
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
gimp_container_view_set_container (view, NULL);
|
2001-02-08 12:16:41 +08:00
|
|
|
|
2004-05-11 01:16:50 +08:00
|
|
|
if (private->context)
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
gimp_container_view_set_context (view, NULL);
|
2004-05-11 07:22:39 +08:00
|
|
|
}
|
2001-02-08 12:16:41 +08:00
|
|
|
|
2004-05-11 07:22:39 +08:00
|
|
|
static void
|
|
|
|
gimp_container_view_private_finalize (GimpContainerViewPrivate *private)
|
|
|
|
{
|
2009-07-26 00:21:23 +08:00
|
|
|
if (private->item_hash)
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
{
|
2009-07-26 00:21:23 +08:00
|
|
|
g_hash_table_destroy (private->item_hash);
|
|
|
|
private->item_hash = NULL;
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
}
|
2001-02-08 12:16:41 +08:00
|
|
|
|
2007-05-23 02:08:42 +08:00
|
|
|
g_slice_free (GimpContainerViewPrivate, private);
|
2001-02-05 23:22:20 +08:00
|
|
|
}
|
2001-02-06 03:10:40 +08:00
|
|
|
|
2004-05-11 07:22:39 +08:00
|
|
|
static GimpContainerViewPrivate *
|
2004-05-11 01:16:50 +08:00
|
|
|
gimp_container_view_get_private (GimpContainerView *view)
|
|
|
|
{
|
|
|
|
GimpContainerViewPrivate *private;
|
|
|
|
|
2004-05-11 07:22:39 +08:00
|
|
|
static GQuark private_key = 0;
|
2004-05-11 01:16:50 +08:00
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_CONTAINER_VIEW (view), NULL);
|
|
|
|
|
2004-05-11 07:22:39 +08:00
|
|
|
if (! private_key)
|
|
|
|
private_key = g_quark_from_static_string ("gimp-container-view-private");
|
2004-05-11 01:16:50 +08:00
|
|
|
|
2004-05-11 07:22:39 +08:00
|
|
|
private = g_object_get_qdata ((GObject *) view, private_key);
|
2004-05-11 01:16:50 +08:00
|
|
|
|
|
|
|
if (! private)
|
|
|
|
{
|
2004-05-11 07:22:39 +08:00
|
|
|
GimpContainerViewInterface *view_iface;
|
|
|
|
|
|
|
|
view_iface = GIMP_CONTAINER_VIEW_GET_INTERFACE (view);
|
2004-05-11 01:16:50 +08:00
|
|
|
|
2007-05-23 02:08:42 +08:00
|
|
|
private = g_slice_new0 (GimpContainerViewPrivate);
|
2004-05-11 01:16:50 +08:00
|
|
|
|
2006-01-17 18:08:50 +08:00
|
|
|
private->view_border_width = 1;
|
2004-05-11 01:16:50 +08:00
|
|
|
|
2009-07-28 21:01:57 +08:00
|
|
|
private->item_hash = g_hash_table_new_full (g_direct_hash,
|
|
|
|
g_direct_equal,
|
|
|
|
NULL,
|
|
|
|
view_iface->insert_data_free);
|
|
|
|
|
2004-05-11 07:22:39 +08:00
|
|
|
g_object_set_qdata_full ((GObject *) view, private_key, private,
|
|
|
|
(GDestroyNotify) gimp_container_view_private_finalize);
|
|
|
|
|
|
|
|
g_signal_connect (view, "destroy",
|
2004-05-28 18:49:56 +08:00
|
|
|
G_CALLBACK (gimp_container_view_private_dispose),
|
2004-05-11 07:22:39 +08:00
|
|
|
private);
|
2004-05-11 01:16:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return private;
|
|
|
|
}
|
|
|
|
|
2005-08-16 19:40:04 +08:00
|
|
|
/**
|
|
|
|
* gimp_container_view_install_properties:
|
|
|
|
* @klass: the class structure for a type deriving from #GObject
|
|
|
|
*
|
|
|
|
* Installs the necessary properties for a class implementing
|
|
|
|
* #GimpContainerView. A #GimpContainerViewProp property is installed
|
|
|
|
* for each property, using the values from the #GimpContainerViewProp
|
|
|
|
* enumeration. The caller must make sure itself that the enumeration
|
|
|
|
* values don't collide with some other property values they
|
|
|
|
* are using (that's what %GIMP_CONTAINER_VIEW_PROP_LAST is good for).
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
gimp_container_view_install_properties (GObjectClass *klass)
|
|
|
|
{
|
|
|
|
g_object_class_override_property (klass,
|
|
|
|
GIMP_CONTAINER_VIEW_PROP_CONTAINER,
|
|
|
|
"container");
|
|
|
|
g_object_class_override_property (klass,
|
|
|
|
GIMP_CONTAINER_VIEW_PROP_CONTEXT,
|
|
|
|
"context");
|
|
|
|
g_object_class_override_property (klass,
|
|
|
|
GIMP_CONTAINER_VIEW_PROP_REORDERABLE,
|
|
|
|
"reorderable");
|
|
|
|
g_object_class_override_property (klass,
|
2006-01-17 18:08:50 +08:00
|
|
|
GIMP_CONTAINER_VIEW_PROP_VIEW_SIZE,
|
|
|
|
"view-size");
|
2005-08-16 19:40:04 +08:00
|
|
|
g_object_class_override_property (klass,
|
2006-01-17 18:08:50 +08:00
|
|
|
GIMP_CONTAINER_VIEW_PROP_VIEW_BORDER_WIDTH,
|
|
|
|
"view-border-width");
|
2005-08-16 19:40:04 +08:00
|
|
|
}
|
|
|
|
|
2004-05-11 01:16:50 +08:00
|
|
|
GimpContainer *
|
|
|
|
gimp_container_view_get_container (GimpContainerView *view)
|
|
|
|
{
|
|
|
|
GimpContainerViewPrivate *private;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_CONTAINER_VIEW (view), NULL);
|
|
|
|
|
|
|
|
private = GIMP_CONTAINER_VIEW_GET_PRIVATE (view);
|
|
|
|
|
|
|
|
return private->container;
|
|
|
|
}
|
|
|
|
|
2001-02-06 03:10:40 +08:00
|
|
|
void
|
|
|
|
gimp_container_view_set_container (GimpContainerView *view,
|
2004-08-26 06:31:44 +08:00
|
|
|
GimpContainer *container)
|
2001-02-06 03:10:40 +08:00
|
|
|
{
|
2004-05-11 01:16:50 +08:00
|
|
|
GimpContainerViewPrivate *private;
|
|
|
|
|
2001-02-06 03:10:40 +08:00
|
|
|
g_return_if_fail (GIMP_IS_CONTAINER_VIEW (view));
|
2003-04-05 05:16:58 +08:00
|
|
|
g_return_if_fail (container == NULL || GIMP_IS_CONTAINER (container));
|
2008-02-01 19:49:12 +08:00
|
|
|
if (container)
|
2008-11-21 07:43:58 +08:00
|
|
|
g_return_if_fail (g_type_is_a (gimp_container_get_children_type (container),
|
2008-02-01 19:49:12 +08:00
|
|
|
GIMP_TYPE_VIEWABLE));
|
2001-02-06 03:10:40 +08:00
|
|
|
|
2004-05-11 01:16:50 +08:00
|
|
|
private = GIMP_CONTAINER_VIEW_GET_PRIVATE (view);
|
|
|
|
|
|
|
|
if (container != private->container)
|
2003-12-22 00:11:06 +08:00
|
|
|
{
|
2004-05-11 07:22:39 +08:00
|
|
|
GIMP_CONTAINER_VIEW_GET_INTERFACE (view)->set_container (view, container);
|
2003-12-22 00:11:06 +08:00
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (view), "container");
|
|
|
|
}
|
2001-03-12 01:24:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_container_view_real_set_container (GimpContainerView *view,
|
2004-08-26 06:31:44 +08:00
|
|
|
GimpContainer *container)
|
2001-03-12 01:24:47 +08:00
|
|
|
{
|
2004-05-11 01:16:50 +08:00
|
|
|
GimpContainerViewPrivate *private = GIMP_CONTAINER_VIEW_GET_PRIVATE (view);
|
|
|
|
|
|
|
|
if (private->container)
|
2001-02-06 03:10:40 +08:00
|
|
|
{
|
2001-03-06 21:28:39 +08:00
|
|
|
gimp_container_view_select_item (view, NULL);
|
2001-02-08 12:16:41 +08:00
|
|
|
|
2009-07-28 22:38:18 +08:00
|
|
|
/* freeze/thaw is only supported for the toplevel container */
|
2004-05-11 01:16:50 +08:00
|
|
|
g_signal_handlers_disconnect_by_func (private->container,
|
2004-08-26 06:31:44 +08:00
|
|
|
gimp_container_view_freeze,
|
|
|
|
view);
|
2004-05-11 01:16:50 +08:00
|
|
|
g_signal_handlers_disconnect_by_func (private->container,
|
2004-08-26 06:31:44 +08:00
|
|
|
gimp_container_view_thaw,
|
|
|
|
view);
|
2001-02-06 03:10:40 +08:00
|
|
|
|
2009-07-28 22:38:18 +08:00
|
|
|
if (! gimp_container_frozen (private->container))
|
|
|
|
gimp_container_view_remove_container (view, private->container);
|
|
|
|
|
2004-05-11 01:16:50 +08:00
|
|
|
if (private->context)
|
2009-07-29 03:02:32 +08:00
|
|
|
gimp_container_view_disconnect_context (view);
|
2001-02-06 03:10:40 +08:00
|
|
|
}
|
|
|
|
|
2004-05-11 01:16:50 +08:00
|
|
|
private->container = container;
|
2001-02-06 03:10:40 +08:00
|
|
|
|
2004-05-11 01:16:50 +08:00
|
|
|
if (private->container)
|
2001-02-06 03:10:40 +08:00
|
|
|
{
|
2009-07-28 22:38:18 +08:00
|
|
|
if (! gimp_container_frozen (private->container))
|
|
|
|
gimp_container_view_add_container (view, private->container);
|
2001-02-06 03:10:40 +08:00
|
|
|
|
2009-07-28 22:38:18 +08:00
|
|
|
/* freeze/thaw is only supported for the toplevel container */
|
2004-05-11 01:16:50 +08:00
|
|
|
g_signal_connect_object (private->container, "freeze",
|
2004-08-26 06:31:44 +08:00
|
|
|
G_CALLBACK (gimp_container_view_freeze),
|
|
|
|
view,
|
|
|
|
G_CONNECT_SWAPPED);
|
2004-05-11 01:16:50 +08:00
|
|
|
g_signal_connect_object (private->container, "thaw",
|
2004-08-26 06:31:44 +08:00
|
|
|
G_CALLBACK (gimp_container_view_thaw),
|
|
|
|
view,
|
|
|
|
G_CONNECT_SWAPPED);
|
2001-02-18 05:20:10 +08:00
|
|
|
|
2004-05-11 01:16:50 +08:00
|
|
|
if (private->context)
|
2009-07-29 03:02:32 +08:00
|
|
|
gimp_container_view_connect_context (view);
|
2001-02-07 23:01:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-05-11 01:16:50 +08:00
|
|
|
GimpContext *
|
|
|
|
gimp_container_view_get_context (GimpContainerView *view)
|
2003-03-27 01:49:42 +08:00
|
|
|
{
|
2004-05-11 01:16:50 +08:00
|
|
|
GimpContainerViewPrivate *private;
|
2003-03-27 01:49:42 +08:00
|
|
|
|
2004-05-11 01:16:50 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_CONTAINER_VIEW (view), NULL);
|
2003-03-27 01:49:42 +08:00
|
|
|
|
2004-05-11 01:16:50 +08:00
|
|
|
private = GIMP_CONTAINER_VIEW_GET_PRIVATE (view);
|
2003-03-27 01:49:42 +08:00
|
|
|
|
2004-05-11 01:16:50 +08:00
|
|
|
return private->context;
|
2003-03-27 01:49:42 +08:00
|
|
|
}
|
|
|
|
|
2001-02-07 23:01:52 +08:00
|
|
|
void
|
|
|
|
gimp_container_view_set_context (GimpContainerView *view,
|
2004-08-26 06:31:44 +08:00
|
|
|
GimpContext *context)
|
2001-02-07 23:01:52 +08:00
|
|
|
{
|
2004-05-11 01:16:50 +08:00
|
|
|
GimpContainerViewPrivate *private;
|
|
|
|
|
2001-02-07 23:01:52 +08:00
|
|
|
g_return_if_fail (GIMP_IS_CONTAINER_VIEW (view));
|
2006-08-29 03:40:20 +08:00
|
|
|
g_return_if_fail (context == NULL || GIMP_IS_CONTEXT (context));
|
2001-02-07 23:01:52 +08:00
|
|
|
|
2004-05-11 01:16:50 +08:00
|
|
|
private = GIMP_CONTAINER_VIEW_GET_PRIVATE (view);
|
|
|
|
|
2006-08-29 03:40:20 +08:00
|
|
|
if (context != private->context)
|
|
|
|
{
|
|
|
|
GIMP_CONTAINER_VIEW_GET_INTERFACE (view)->set_context (view, context);
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (view), "context");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_container_view_real_set_context (GimpContainerView *view,
|
|
|
|
GimpContext *context)
|
|
|
|
{
|
|
|
|
GimpContainerViewPrivate *private = GIMP_CONTAINER_VIEW_GET_PRIVATE (view);
|
2001-02-07 23:01:52 +08:00
|
|
|
|
2004-05-11 01:16:50 +08:00
|
|
|
if (private->context)
|
2001-02-07 23:01:52 +08:00
|
|
|
{
|
2004-05-11 01:16:50 +08:00
|
|
|
if (private->container)
|
2009-07-29 03:02:32 +08:00
|
|
|
gimp_container_view_disconnect_context (view);
|
2001-02-19 03:44:28 +08:00
|
|
|
|
2004-05-11 01:16:50 +08:00
|
|
|
g_object_unref (private->context);
|
2001-02-07 23:01:52 +08:00
|
|
|
}
|
|
|
|
|
2004-05-11 01:16:50 +08:00
|
|
|
private->context = context;
|
2001-02-07 23:01:52 +08:00
|
|
|
|
2004-05-11 01:16:50 +08:00
|
|
|
if (private->context)
|
2001-02-07 23:01:52 +08:00
|
|
|
{
|
2004-05-11 01:16:50 +08:00
|
|
|
g_object_ref (private->context);
|
2001-02-07 23:01:52 +08:00
|
|
|
|
2004-05-11 01:16:50 +08:00
|
|
|
if (private->container)
|
2009-07-29 03:02:32 +08:00
|
|
|
gimp_container_view_connect_context (view);
|
2001-02-06 03:10:40 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-05-11 01:16:50 +08:00
|
|
|
gint
|
2006-01-17 18:08:50 +08:00
|
|
|
gimp_container_view_get_view_size (GimpContainerView *view,
|
|
|
|
gint *view_border_width)
|
2004-05-11 01:16:50 +08:00
|
|
|
{
|
|
|
|
GimpContainerViewPrivate *private;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_CONTAINER_VIEW (view), 0);
|
|
|
|
|
|
|
|
private = GIMP_CONTAINER_VIEW_GET_PRIVATE (view);
|
|
|
|
|
2006-01-17 18:08:50 +08:00
|
|
|
if (view_border_width)
|
|
|
|
*view_border_width = private->view_border_width;
|
2004-05-11 01:16:50 +08:00
|
|
|
|
2006-01-17 18:08:50 +08:00
|
|
|
return private->view_size;
|
2004-05-11 01:16:50 +08:00
|
|
|
}
|
|
|
|
|
2001-02-06 07:14:14 +08:00
|
|
|
void
|
2006-01-17 18:08:50 +08:00
|
|
|
gimp_container_view_set_view_size (GimpContainerView *view,
|
|
|
|
gint view_size,
|
|
|
|
gint view_border_width)
|
2001-02-06 07:14:14 +08:00
|
|
|
{
|
2004-05-11 01:16:50 +08:00
|
|
|
GimpContainerViewPrivate *private;
|
|
|
|
|
2001-02-06 07:14:14 +08:00
|
|
|
g_return_if_fail (GIMP_IS_CONTAINER_VIEW (view));
|
2006-01-17 18:08:50 +08:00
|
|
|
g_return_if_fail (view_size > 0 &&
|
|
|
|
view_size <= GIMP_VIEWABLE_MAX_PREVIEW_SIZE);
|
|
|
|
g_return_if_fail (view_border_width >= 0 &&
|
|
|
|
view_border_width <= GIMP_VIEW_MAX_BORDER_WIDTH);
|
2001-02-06 07:14:14 +08:00
|
|
|
|
2004-05-11 01:16:50 +08:00
|
|
|
private = GIMP_CONTAINER_VIEW_GET_PRIVATE (view);
|
|
|
|
|
2006-01-17 18:08:50 +08:00
|
|
|
if (private->view_size != view_size ||
|
|
|
|
private->view_border_width != view_border_width)
|
2001-08-07 20:42:23 +08:00
|
|
|
{
|
2006-01-17 18:08:50 +08:00
|
|
|
private->view_size = view_size;
|
|
|
|
private->view_border_width = view_border_width;
|
2001-05-04 06:19:17 +08:00
|
|
|
|
2006-01-17 18:08:50 +08:00
|
|
|
GIMP_CONTAINER_VIEW_GET_INTERFACE (view)->set_view_size (view);
|
2004-05-28 18:49:56 +08:00
|
|
|
|
|
|
|
g_object_freeze_notify (G_OBJECT (view));
|
2006-01-17 18:08:50 +08:00
|
|
|
g_object_notify (G_OBJECT (view), "view-size");
|
|
|
|
g_object_notify (G_OBJECT (view), "view-border-width");
|
2004-05-28 18:49:56 +08:00
|
|
|
g_object_thaw_notify (G_OBJECT (view));
|
2001-08-07 20:42:23 +08:00
|
|
|
}
|
2001-05-04 06:19:17 +08:00
|
|
|
}
|
2001-02-06 07:14:14 +08:00
|
|
|
|
2004-05-11 07:22:39 +08:00
|
|
|
gboolean
|
|
|
|
gimp_container_view_get_reorderable (GimpContainerView *view)
|
|
|
|
{
|
|
|
|
GimpContainerViewPrivate *private;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_CONTAINER_VIEW (view), FALSE);
|
|
|
|
|
|
|
|
private = GIMP_CONTAINER_VIEW_GET_PRIVATE (view);
|
|
|
|
|
|
|
|
return private->reorderable;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_container_view_set_reorderable (GimpContainerView *view,
|
|
|
|
gboolean reorderable)
|
|
|
|
{
|
|
|
|
GimpContainerViewPrivate *private;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_CONTAINER_VIEW (view));
|
|
|
|
|
|
|
|
private = GIMP_CONTAINER_VIEW_GET_PRIVATE (view);
|
|
|
|
|
|
|
|
private->reorderable = reorderable ? TRUE : FALSE;
|
2004-05-28 18:49:56 +08:00
|
|
|
g_object_notify (G_OBJECT (view), "reorderable");
|
2004-05-11 07:22:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget *
|
|
|
|
gimp_container_view_get_dnd_widget (GimpContainerView *view)
|
|
|
|
{
|
|
|
|
GimpContainerViewPrivate *private;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_CONTAINER_VIEW (view), NULL);
|
|
|
|
|
|
|
|
private = GIMP_CONTAINER_VIEW_GET_PRIVATE (view);
|
|
|
|
|
|
|
|
return private->dnd_widget;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_container_view_set_dnd_widget (GimpContainerView *view,
|
|
|
|
GtkWidget *dnd_widget)
|
|
|
|
{
|
|
|
|
GimpContainerViewPrivate *private;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_CONTAINER_VIEW (view));
|
|
|
|
g_return_if_fail (dnd_widget == NULL || GTK_IS_WIDGET (dnd_widget));
|
|
|
|
|
|
|
|
private = GIMP_CONTAINER_VIEW_GET_PRIVATE (view);
|
|
|
|
|
|
|
|
private->dnd_widget = dnd_widget;
|
|
|
|
}
|
|
|
|
|
2001-08-05 04:38:54 +08:00
|
|
|
void
|
|
|
|
gimp_container_view_enable_dnd (GimpContainerView *view,
|
2004-08-26 06:31:44 +08:00
|
|
|
GtkButton *button,
|
|
|
|
GType children_type)
|
2001-08-05 04:38:54 +08:00
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_CONTAINER_VIEW (view));
|
|
|
|
g_return_if_fail (GTK_IS_BUTTON (button));
|
|
|
|
|
2002-09-02 22:39:08 +08:00
|
|
|
gimp_dnd_viewable_dest_add (GTK_WIDGET (button),
|
2004-08-26 06:31:44 +08:00
|
|
|
children_type,
|
|
|
|
gimp_container_view_button_viewable_dropped,
|
|
|
|
view);
|
2001-08-05 04:38:54 +08:00
|
|
|
}
|
|
|
|
|
2003-05-18 21:28:27 +08:00
|
|
|
gboolean
|
2001-02-07 23:01:52 +08:00
|
|
|
gimp_container_view_select_item (GimpContainerView *view,
|
2004-08-26 06:31:44 +08:00
|
|
|
GimpViewable *viewable)
|
2001-02-07 23:01:52 +08:00
|
|
|
{
|
2004-05-11 01:16:50 +08:00
|
|
|
GimpContainerViewPrivate *private;
|
|
|
|
gboolean success = FALSE;
|
2004-06-02 20:49:16 +08:00
|
|
|
gpointer insert_data;
|
2003-05-18 21:28:27 +08:00
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_CONTAINER_VIEW (view), FALSE);
|
|
|
|
g_return_val_if_fail (viewable == NULL || GIMP_IS_VIEWABLE (viewable), FALSE);
|
2001-02-07 23:01:52 +08:00
|
|
|
|
2004-05-11 01:16:50 +08:00
|
|
|
private = GIMP_CONTAINER_VIEW_GET_PRIVATE (view);
|
|
|
|
|
2009-07-28 21:01:57 +08:00
|
|
|
insert_data = g_hash_table_lookup (private->item_hash, viewable);
|
2003-03-23 00:26:11 +08:00
|
|
|
|
2004-06-02 20:49:16 +08:00
|
|
|
g_signal_emit (view, view_signals[SELECT_ITEM], 0,
|
|
|
|
viewable, insert_data, &success);
|
2003-05-18 21:28:27 +08:00
|
|
|
|
|
|
|
return success;
|
2001-02-07 23:01:52 +08:00
|
|
|
}
|
|
|
|
|
2001-02-19 03:44:28 +08:00
|
|
|
void
|
|
|
|
gimp_container_view_activate_item (GimpContainerView *view,
|
2004-08-26 06:31:44 +08:00
|
|
|
GimpViewable *viewable)
|
2001-02-19 03:44:28 +08:00
|
|
|
{
|
2004-05-11 01:16:50 +08:00
|
|
|
GimpContainerViewPrivate *private;
|
2004-06-02 20:49:16 +08:00
|
|
|
gpointer insert_data;
|
2004-05-11 01:16:50 +08:00
|
|
|
|
2001-02-19 03:44:28 +08:00
|
|
|
g_return_if_fail (GIMP_IS_CONTAINER_VIEW (view));
|
|
|
|
g_return_if_fail (GIMP_IS_VIEWABLE (viewable));
|
|
|
|
|
2004-05-11 01:16:50 +08:00
|
|
|
private = GIMP_CONTAINER_VIEW_GET_PRIVATE (view);
|
|
|
|
|
2009-07-28 21:01:57 +08:00
|
|
|
insert_data = g_hash_table_lookup (private->item_hash, viewable);
|
2001-02-19 03:44:28 +08:00
|
|
|
|
2004-06-02 20:49:16 +08:00
|
|
|
g_signal_emit (view, view_signals[ACTIVATE_ITEM], 0,
|
|
|
|
viewable, insert_data);
|
2001-02-19 03:44:28 +08:00
|
|
|
}
|
|
|
|
|
2001-04-29 23:23:01 +08:00
|
|
|
void
|
|
|
|
gimp_container_view_context_item (GimpContainerView *view,
|
2004-08-26 06:31:44 +08:00
|
|
|
GimpViewable *viewable)
|
2001-04-29 23:23:01 +08:00
|
|
|
{
|
2004-05-11 01:16:50 +08:00
|
|
|
GimpContainerViewPrivate *private;
|
2004-06-02 20:49:16 +08:00
|
|
|
gpointer insert_data;
|
2004-05-11 01:16:50 +08:00
|
|
|
|
2001-04-29 23:23:01 +08:00
|
|
|
g_return_if_fail (GIMP_IS_CONTAINER_VIEW (view));
|
|
|
|
g_return_if_fail (GIMP_IS_VIEWABLE (viewable));
|
|
|
|
|
2004-05-11 01:16:50 +08:00
|
|
|
private = GIMP_CONTAINER_VIEW_GET_PRIVATE (view);
|
|
|
|
|
2009-07-28 21:01:57 +08:00
|
|
|
insert_data = g_hash_table_lookup (private->item_hash, viewable);
|
2001-04-29 23:23:01 +08:00
|
|
|
|
2004-06-02 20:49:16 +08:00
|
|
|
g_signal_emit (view, view_signals[CONTEXT_ITEM], 0,
|
|
|
|
viewable, insert_data);
|
2001-04-29 23:23:01 +08:00
|
|
|
}
|
|
|
|
|
2004-05-11 07:22:39 +08:00
|
|
|
gpointer
|
|
|
|
gimp_container_view_lookup (GimpContainerView *view,
|
|
|
|
GimpViewable *viewable)
|
|
|
|
{
|
|
|
|
GimpContainerViewPrivate *private;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_CONTAINER_VIEW (view), NULL);
|
2004-10-10 22:33:01 +08:00
|
|
|
g_return_val_if_fail (viewable == NULL || GIMP_IS_VIEWABLE (viewable), NULL);
|
|
|
|
|
|
|
|
/* we handle the NULL viewable here as a workaround for bug #149906 */
|
|
|
|
if (! viewable)
|
|
|
|
return NULL;
|
2004-05-11 07:22:39 +08:00
|
|
|
|
|
|
|
private = GIMP_CONTAINER_VIEW_GET_PRIVATE (view);
|
|
|
|
|
2009-07-28 21:01:57 +08:00
|
|
|
return g_hash_table_lookup (private->item_hash, viewable);
|
2004-05-11 07:22:39 +08:00
|
|
|
}
|
|
|
|
|
2003-05-18 21:28:27 +08:00
|
|
|
gboolean
|
2001-02-07 23:01:52 +08:00
|
|
|
gimp_container_view_item_selected (GimpContainerView *view,
|
2004-08-26 06:31:44 +08:00
|
|
|
GimpViewable *viewable)
|
2001-02-07 23:01:52 +08:00
|
|
|
{
|
2004-05-11 01:16:50 +08:00
|
|
|
GimpContainerViewPrivate *private;
|
|
|
|
gboolean success;
|
2001-02-07 23:01:52 +08:00
|
|
|
|
2003-05-18 21:28:27 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_CONTAINER_VIEW (view), FALSE);
|
|
|
|
g_return_val_if_fail (GIMP_IS_VIEWABLE (viewable), FALSE);
|
2003-03-23 00:26:11 +08:00
|
|
|
|
2004-05-11 01:16:50 +08:00
|
|
|
private = GIMP_CONTAINER_VIEW_GET_PRIVATE (view);
|
|
|
|
|
2004-05-13 02:36:33 +08:00
|
|
|
/* HACK */
|
|
|
|
if (private->container && private->context)
|
|
|
|
{
|
2009-03-08 18:46:32 +08:00
|
|
|
GType children_type;
|
2006-09-01 05:40:16 +08:00
|
|
|
const gchar *signal_name;
|
|
|
|
|
2009-03-08 18:46:32 +08:00
|
|
|
children_type = gimp_container_get_children_type (private->container);
|
|
|
|
signal_name = gimp_context_type_to_signal_name (children_type);
|
2004-05-13 02:36:33 +08:00
|
|
|
|
2006-09-01 05:40:16 +08:00
|
|
|
if (signal_name)
|
|
|
|
{
|
|
|
|
gimp_context_set_by_type (private->context, children_type,
|
|
|
|
GIMP_OBJECT (viewable));
|
|
|
|
return TRUE;
|
|
|
|
}
|
2004-05-13 02:36:33 +08:00
|
|
|
}
|
|
|
|
|
2003-05-18 21:28:27 +08:00
|
|
|
success = gimp_container_view_select_item (view, viewable);
|
|
|
|
|
2004-05-13 02:36:33 +08:00
|
|
|
#if 0
|
2004-05-11 01:16:50 +08:00
|
|
|
if (success && private->container && private->context)
|
2003-03-23 00:26:11 +08:00
|
|
|
{
|
|
|
|
GimpContext *context;
|
2009-03-08 18:46:32 +08:00
|
|
|
GType children_type;
|
2001-02-07 23:01:52 +08:00
|
|
|
|
2004-05-11 01:16:50 +08:00
|
|
|
/* ref and remember the context because private->context may
|
2003-03-23 00:26:11 +08:00
|
|
|
* become NULL by calling gimp_context_set_by_type()
|
|
|
|
*/
|
2009-03-08 18:46:32 +08:00
|
|
|
context = g_object_ref (private->context);
|
|
|
|
children_type = gimp_container_get_children_type (private->container);
|
2003-03-23 00:26:11 +08:00
|
|
|
|
|
|
|
g_signal_handlers_block_by_func (context,
|
|
|
|
gimp_container_view_context_changed,
|
|
|
|
view);
|
|
|
|
|
2009-03-08 18:46:32 +08:00
|
|
|
gimp_context_set_by_type (context, children_type, GIMP_OBJECT (viewable));
|
2003-03-23 00:26:11 +08:00
|
|
|
|
|
|
|
g_signal_handlers_unblock_by_func (context,
|
|
|
|
gimp_container_view_context_changed,
|
|
|
|
view);
|
|
|
|
|
|
|
|
g_object_unref (context);
|
|
|
|
}
|
2004-05-13 02:36:33 +08:00
|
|
|
#endif
|
2003-05-18 21:28:27 +08:00
|
|
|
|
|
|
|
return success;
|
2001-02-07 23:01:52 +08:00
|
|
|
}
|
|
|
|
|
2001-02-19 03:44:28 +08:00
|
|
|
void
|
2001-02-27 22:14:13 +08:00
|
|
|
gimp_container_view_item_activated (GimpContainerView *view,
|
2004-08-26 06:31:44 +08:00
|
|
|
GimpViewable *viewable)
|
2001-02-19 03:44:28 +08:00
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_CONTAINER_VIEW (view));
|
|
|
|
g_return_if_fail (GIMP_IS_VIEWABLE (viewable));
|
|
|
|
|
|
|
|
gimp_container_view_activate_item (view, viewable);
|
|
|
|
}
|
|
|
|
|
2001-04-29 23:23:01 +08:00
|
|
|
void
|
|
|
|
gimp_container_view_item_context (GimpContainerView *view,
|
2004-08-26 06:31:44 +08:00
|
|
|
GimpViewable *viewable)
|
2001-04-29 23:23:01 +08:00
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_CONTAINER_VIEW (view));
|
|
|
|
g_return_if_fail (GIMP_IS_VIEWABLE (viewable));
|
|
|
|
|
|
|
|
gimp_container_view_context_item (view, viewable);
|
|
|
|
}
|
|
|
|
|
2004-05-11 20:13:31 +08:00
|
|
|
void
|
|
|
|
gimp_container_view_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GimpContainerView *view = GIMP_CONTAINER_VIEW (object);
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case GIMP_CONTAINER_VIEW_PROP_CONTAINER:
|
|
|
|
gimp_container_view_set_container (view, g_value_get_object (value));
|
|
|
|
break;
|
|
|
|
case GIMP_CONTAINER_VIEW_PROP_CONTEXT:
|
|
|
|
gimp_container_view_set_context (view, g_value_get_object (value));
|
|
|
|
break;
|
|
|
|
case GIMP_CONTAINER_VIEW_PROP_REORDERABLE:
|
|
|
|
gimp_container_view_set_reorderable (view, g_value_get_boolean (value));
|
|
|
|
break;
|
2006-01-17 18:08:50 +08:00
|
|
|
case GIMP_CONTAINER_VIEW_PROP_VIEW_SIZE:
|
|
|
|
case GIMP_CONTAINER_VIEW_PROP_VIEW_BORDER_WIDTH:
|
2004-05-28 18:49:56 +08:00
|
|
|
{
|
|
|
|
gint size, border;
|
|
|
|
|
2006-01-17 18:08:50 +08:00
|
|
|
size = gimp_container_view_get_view_size (view, &border);
|
2004-05-28 18:49:56 +08:00
|
|
|
|
2006-01-17 18:08:50 +08:00
|
|
|
if (property_id == GIMP_CONTAINER_VIEW_PROP_VIEW_SIZE)
|
2004-05-28 18:49:56 +08:00
|
|
|
size = g_value_get_int (value);
|
|
|
|
else
|
|
|
|
border = g_value_get_int (value);
|
|
|
|
|
2006-01-17 18:08:50 +08:00
|
|
|
gimp_container_view_set_view_size (view, size, border);
|
2004-05-28 18:49:56 +08:00
|
|
|
}
|
|
|
|
break;
|
2004-05-11 20:13:31 +08:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_container_view_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GimpContainerView *view = GIMP_CONTAINER_VIEW (object);
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case GIMP_CONTAINER_VIEW_PROP_CONTAINER:
|
|
|
|
g_value_set_object (value, gimp_container_view_get_container (view));
|
|
|
|
break;
|
|
|
|
case GIMP_CONTAINER_VIEW_PROP_CONTEXT:
|
|
|
|
g_value_set_object (value, gimp_container_view_get_context (view));
|
|
|
|
break;
|
|
|
|
case GIMP_CONTAINER_VIEW_PROP_REORDERABLE:
|
|
|
|
g_value_set_boolean (value, gimp_container_view_get_reorderable (view));
|
|
|
|
break;
|
2006-01-17 18:08:50 +08:00
|
|
|
case GIMP_CONTAINER_VIEW_PROP_VIEW_SIZE:
|
|
|
|
case GIMP_CONTAINER_VIEW_PROP_VIEW_BORDER_WIDTH:
|
2004-05-28 18:49:56 +08:00
|
|
|
{
|
|
|
|
gint size, border;
|
|
|
|
|
2006-01-17 18:08:50 +08:00
|
|
|
size = gimp_container_view_get_view_size (view, &border);
|
2004-05-28 18:49:56 +08:00
|
|
|
|
2006-01-17 18:08:50 +08:00
|
|
|
if (property_id == GIMP_CONTAINER_VIEW_PROP_VIEW_SIZE)
|
2004-05-28 18:49:56 +08:00
|
|
|
g_value_set_int (value, size);
|
|
|
|
else
|
|
|
|
g_value_set_int (value, border);
|
|
|
|
}
|
|
|
|
break;
|
2004-05-11 20:13:31 +08:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-06 03:10:40 +08:00
|
|
|
static void
|
2001-02-08 12:16:41 +08:00
|
|
|
gimp_container_view_clear_items (GimpContainerView *view)
|
2001-02-06 03:10:40 +08:00
|
|
|
{
|
2004-05-11 07:22:39 +08:00
|
|
|
GIMP_CONTAINER_VIEW_GET_INTERFACE (view)->clear_items (view);
|
2001-02-06 03:10:40 +08:00
|
|
|
}
|
|
|
|
|
2001-02-08 12:16:41 +08:00
|
|
|
static void
|
|
|
|
gimp_container_view_real_clear_items (GimpContainerView *view)
|
|
|
|
{
|
2004-06-02 20:49:16 +08:00
|
|
|
GimpContainerViewPrivate *private = GIMP_CONTAINER_VIEW_GET_PRIVATE (view);
|
2001-02-08 12:16:41 +08:00
|
|
|
|
2009-07-28 21:01:57 +08:00
|
|
|
g_hash_table_remove_all (private->item_hash);
|
2001-02-08 12:16:41 +08:00
|
|
|
}
|
|
|
|
|
2009-07-28 22:38:18 +08:00
|
|
|
static void
|
|
|
|
gimp_container_view_add_container (GimpContainerView *view,
|
|
|
|
GimpContainer *container)
|
|
|
|
{
|
2009-07-29 01:08:07 +08:00
|
|
|
GimpContainerViewPrivate *private = GIMP_CONTAINER_VIEW_GET_PRIVATE (view);
|
|
|
|
|
2009-07-28 22:38:18 +08:00
|
|
|
gimp_container_foreach (container,
|
|
|
|
(GFunc) gimp_container_view_add_foreach,
|
|
|
|
view);
|
|
|
|
|
2009-08-05 02:19:13 +08:00
|
|
|
if (container == private->container)
|
|
|
|
{
|
|
|
|
GType children_type;
|
|
|
|
GimpViewableClass *viewable_class;
|
2009-07-29 01:08:07 +08:00
|
|
|
|
2009-08-05 02:19:13 +08:00
|
|
|
children_type = gimp_container_get_children_type (container);
|
|
|
|
viewable_class = g_type_class_ref (children_type);
|
2009-07-29 01:08:07 +08:00
|
|
|
|
2009-08-05 02:19:13 +08:00
|
|
|
private->name_changed_handler =
|
|
|
|
gimp_tree_handler_connect (container,
|
|
|
|
viewable_class->name_changed_signal,
|
|
|
|
G_CALLBACK (gimp_container_view_name_changed),
|
|
|
|
view);
|
2009-07-29 01:08:07 +08:00
|
|
|
|
2009-08-05 02:19:13 +08:00
|
|
|
g_type_class_unref (viewable_class);
|
|
|
|
}
|
2009-07-29 01:08:07 +08:00
|
|
|
|
2009-07-28 22:38:18 +08:00
|
|
|
g_signal_connect_object (container, "add",
|
|
|
|
G_CALLBACK (gimp_container_view_add),
|
|
|
|
view,
|
|
|
|
G_CONNECT_SWAPPED);
|
|
|
|
g_signal_connect_object (container, "remove",
|
|
|
|
G_CALLBACK (gimp_container_view_remove),
|
|
|
|
view,
|
|
|
|
G_CONNECT_SWAPPED);
|
|
|
|
g_signal_connect_object (container, "reorder",
|
|
|
|
G_CALLBACK (gimp_container_view_reorder),
|
|
|
|
view,
|
|
|
|
G_CONNECT_SWAPPED);
|
|
|
|
}
|
|
|
|
|
2001-02-06 03:10:40 +08:00
|
|
|
static void
|
|
|
|
gimp_container_view_add_foreach (GimpViewable *viewable,
|
2004-08-26 06:31:44 +08:00
|
|
|
GimpContainerView *view)
|
2001-02-06 03:10:40 +08:00
|
|
|
{
|
2004-06-02 20:49:16 +08:00
|
|
|
GimpContainerViewInterface *view_iface;
|
|
|
|
GimpContainerViewPrivate *private;
|
2009-08-02 01:13:35 +08:00
|
|
|
GimpViewable *parent;
|
|
|
|
GimpContainer *children;
|
|
|
|
gpointer parent_insert_data = NULL;
|
2004-06-02 20:49:16 +08:00
|
|
|
gpointer insert_data;
|
|
|
|
|
|
|
|
view_iface = GIMP_CONTAINER_VIEW_GET_INTERFACE (view);
|
|
|
|
private = GIMP_CONTAINER_VIEW_GET_PRIVATE (view);
|
|
|
|
|
2009-08-02 01:13:35 +08:00
|
|
|
parent = gimp_viewable_get_parent (viewable);
|
|
|
|
|
|
|
|
if (parent)
|
|
|
|
parent_insert_data = g_hash_table_lookup (private->item_hash, parent);
|
|
|
|
|
|
|
|
insert_data = view_iface->insert_item (view, viewable,
|
|
|
|
parent_insert_data, -1);
|
2001-02-06 03:10:40 +08:00
|
|
|
|
2009-07-26 00:21:23 +08:00
|
|
|
g_hash_table_insert (private->item_hash, viewable, insert_data);
|
2009-08-02 01:13:35 +08:00
|
|
|
|
2009-09-17 01:53:13 +08:00
|
|
|
if (view_iface->insert_item_after)
|
|
|
|
view_iface->insert_item_after (view, viewable, insert_data);
|
|
|
|
|
2009-08-02 01:13:35 +08:00
|
|
|
children = gimp_viewable_get_children (viewable);
|
|
|
|
|
|
|
|
if (children)
|
|
|
|
gimp_container_view_add_container (view, children);
|
2001-02-06 03:10:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_container_view_add (GimpContainerView *view,
|
2004-08-26 06:31:44 +08:00
|
|
|
GimpViewable *viewable,
|
|
|
|
GimpContainer *container)
|
2001-02-06 03:10:40 +08:00
|
|
|
{
|
2004-06-02 20:49:16 +08:00
|
|
|
GimpContainerViewInterface *view_iface;
|
|
|
|
GimpContainerViewPrivate *private;
|
2009-08-02 01:13:35 +08:00
|
|
|
GimpViewable *parent;
|
|
|
|
GimpContainer *children;
|
|
|
|
gpointer parent_insert_data = NULL;
|
2004-06-02 20:49:16 +08:00
|
|
|
gpointer insert_data;
|
|
|
|
gint index;
|
2001-02-06 03:10:40 +08:00
|
|
|
|
2004-06-02 20:49:16 +08:00
|
|
|
view_iface = GIMP_CONTAINER_VIEW_GET_INTERFACE (view);
|
|
|
|
private = GIMP_CONTAINER_VIEW_GET_PRIVATE (view);
|
|
|
|
|
2001-02-06 03:10:40 +08:00
|
|
|
index = gimp_container_get_child_index (container,
|
|
|
|
GIMP_OBJECT (viewable));
|
|
|
|
|
2009-08-02 01:13:35 +08:00
|
|
|
parent = gimp_viewable_get_parent (viewable);
|
|
|
|
|
|
|
|
if (parent)
|
|
|
|
parent_insert_data = g_hash_table_lookup (private->item_hash, parent);
|
|
|
|
|
|
|
|
insert_data = view_iface->insert_item (view, viewable,
|
2009-08-04 06:13:58 +08:00
|
|
|
parent_insert_data, index);
|
2004-06-02 20:49:16 +08:00
|
|
|
|
2009-07-26 00:21:23 +08:00
|
|
|
g_hash_table_insert (private->item_hash, viewable, insert_data);
|
2009-08-02 01:13:35 +08:00
|
|
|
|
2009-09-17 01:53:13 +08:00
|
|
|
if (view_iface->insert_item_after)
|
|
|
|
view_iface->insert_item_after (view, viewable, insert_data);
|
|
|
|
|
2009-08-02 01:13:35 +08:00
|
|
|
children = gimp_viewable_get_children (viewable);
|
|
|
|
|
|
|
|
if (children)
|
|
|
|
gimp_container_view_add_container (view, children);
|
2001-02-06 03:10:40 +08:00
|
|
|
}
|
|
|
|
|
2009-07-28 22:38:18 +08:00
|
|
|
static void
|
|
|
|
gimp_container_view_remove_container (GimpContainerView *view,
|
|
|
|
GimpContainer *container)
|
|
|
|
{
|
2009-08-04 05:42:55 +08:00
|
|
|
GimpContainerViewInterface *view_iface;
|
|
|
|
GimpContainerViewPrivate *private;
|
|
|
|
|
|
|
|
view_iface = GIMP_CONTAINER_VIEW_GET_INTERFACE (view);
|
|
|
|
private = GIMP_CONTAINER_VIEW_GET_PRIVATE (view);
|
2009-07-29 01:08:07 +08:00
|
|
|
|
2009-08-05 02:19:13 +08:00
|
|
|
if (container == private->container)
|
|
|
|
{
|
|
|
|
gimp_tree_handler_disconnect (private->name_changed_handler);
|
|
|
|
private->name_changed_handler = NULL;
|
|
|
|
}
|
2009-07-28 22:38:18 +08:00
|
|
|
|
|
|
|
g_signal_handlers_disconnect_by_func (container,
|
|
|
|
gimp_container_view_add,
|
|
|
|
view);
|
|
|
|
g_signal_handlers_disconnect_by_func (container,
|
|
|
|
gimp_container_view_remove,
|
|
|
|
view);
|
|
|
|
g_signal_handlers_disconnect_by_func (container,
|
|
|
|
gimp_container_view_reorder,
|
|
|
|
view);
|
|
|
|
|
2009-08-04 05:42:55 +08:00
|
|
|
if (! view_iface->model_is_tree && container == private->container)
|
2009-07-28 22:38:18 +08:00
|
|
|
{
|
|
|
|
gimp_container_view_clear_items (view);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gimp_container_foreach (container,
|
|
|
|
(GFunc) gimp_container_view_remove_foreach,
|
|
|
|
view);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_container_view_remove_foreach (GimpViewable *viewable,
|
|
|
|
GimpContainerView *view)
|
|
|
|
{
|
|
|
|
gimp_container_view_remove (view, viewable, NULL);
|
|
|
|
}
|
|
|
|
|
2001-02-06 03:10:40 +08:00
|
|
|
static void
|
|
|
|
gimp_container_view_remove (GimpContainerView *view,
|
2004-08-26 06:31:44 +08:00
|
|
|
GimpViewable *viewable,
|
2009-07-28 22:38:18 +08:00
|
|
|
GimpContainer *unused)
|
2001-02-06 03:10:40 +08:00
|
|
|
{
|
2004-05-11 01:16:50 +08:00
|
|
|
GimpContainerViewPrivate *private = GIMP_CONTAINER_VIEW_GET_PRIVATE (view);
|
2009-08-02 01:13:35 +08:00
|
|
|
GimpContainer *children;
|
2004-05-11 01:16:50 +08:00
|
|
|
gpointer insert_data;
|
2001-02-06 03:10:40 +08:00
|
|
|
|
2009-08-02 01:13:35 +08:00
|
|
|
children = gimp_viewable_get_children (viewable);
|
|
|
|
|
|
|
|
if (children)
|
|
|
|
gimp_container_view_remove_container (view, children);
|
|
|
|
|
2009-07-26 00:21:23 +08:00
|
|
|
insert_data = g_hash_table_lookup (private->item_hash, viewable);
|
2001-02-06 03:10:40 +08:00
|
|
|
|
|
|
|
if (insert_data)
|
|
|
|
{
|
2004-05-11 07:22:39 +08:00
|
|
|
GIMP_CONTAINER_VIEW_GET_INTERFACE (view)->remove_item (view,
|
|
|
|
viewable,
|
|
|
|
insert_data);
|
2003-02-25 11:19:55 +08:00
|
|
|
|
2009-07-26 00:21:23 +08:00
|
|
|
g_hash_table_remove (private->item_hash, viewable);
|
2001-02-06 03:10:40 +08:00
|
|
|
}
|
|
|
|
}
|
2001-02-07 23:01:52 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
static void
|
|
|
|
gimp_container_view_reorder (GimpContainerView *view,
|
2004-08-26 06:31:44 +08:00
|
|
|
GimpViewable *viewable,
|
|
|
|
gint new_index,
|
|
|
|
GimpContainer *container)
|
2001-02-18 05:20:10 +08:00
|
|
|
{
|
2004-05-11 01:16:50 +08:00
|
|
|
GimpContainerViewPrivate *private = GIMP_CONTAINER_VIEW_GET_PRIVATE (view);
|
|
|
|
gpointer insert_data;
|
2001-02-18 05:20:10 +08:00
|
|
|
|
2009-07-26 00:21:23 +08:00
|
|
|
insert_data = g_hash_table_lookup (private->item_hash, viewable);
|
2001-02-18 05:20:10 +08:00
|
|
|
|
|
|
|
if (insert_data)
|
|
|
|
{
|
2004-05-11 07:22:39 +08:00
|
|
|
GIMP_CONTAINER_VIEW_GET_INTERFACE (view)->reorder_item (view,
|
|
|
|
viewable,
|
|
|
|
new_index,
|
|
|
|
insert_data);
|
2001-02-18 05:20:10 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-10-19 00:23:15 +08:00
|
|
|
static void
|
|
|
|
gimp_container_view_freeze (GimpContainerView *view,
|
|
|
|
GimpContainer *container)
|
|
|
|
{
|
2009-07-28 22:38:18 +08:00
|
|
|
gimp_container_view_remove_container (view, container);
|
2003-10-19 00:23:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_container_view_thaw (GimpContainerView *view,
|
|
|
|
GimpContainer *container)
|
|
|
|
{
|
2004-05-11 07:22:39 +08:00
|
|
|
GimpContainerViewPrivate *private = GIMP_CONTAINER_VIEW_GET_PRIVATE (view);
|
2004-05-11 01:16:50 +08:00
|
|
|
|
2009-07-28 22:38:18 +08:00
|
|
|
gimp_container_view_add_container (view, container);
|
2003-10-19 00:23:15 +08:00
|
|
|
|
2004-05-11 07:22:39 +08:00
|
|
|
if (private->context)
|
2003-10-19 00:23:15 +08:00
|
|
|
{
|
2009-07-29 01:15:36 +08:00
|
|
|
GType children_type;
|
2006-09-01 05:40:16 +08:00
|
|
|
const gchar *signal_name;
|
|
|
|
|
2009-07-29 01:15:36 +08:00
|
|
|
children_type = gimp_container_get_children_type (private->container);
|
|
|
|
signal_name = gimp_context_type_to_signal_name (children_type);
|
2006-09-01 05:40:16 +08:00
|
|
|
|
|
|
|
if (signal_name)
|
|
|
|
{
|
|
|
|
GimpObject *object;
|
2003-10-19 00:23:15 +08:00
|
|
|
|
2006-09-01 05:40:16 +08:00
|
|
|
object = gimp_context_get_by_type (private->context, children_type);
|
2003-10-19 00:23:15 +08:00
|
|
|
|
2006-09-01 05:40:16 +08:00
|
|
|
gimp_container_view_select_item (view, GIMP_VIEWABLE (object));
|
|
|
|
}
|
2003-10-19 00:23:15 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-01-30 00:34:41 +08:00
|
|
|
static void
|
|
|
|
gimp_container_view_name_changed (GimpViewable *viewable,
|
|
|
|
GimpContainerView *view)
|
|
|
|
{
|
2004-05-11 01:16:50 +08:00
|
|
|
GimpContainerViewPrivate *private = GIMP_CONTAINER_VIEW_GET_PRIVATE (view);
|
|
|
|
gpointer insert_data;
|
2004-01-30 00:34:41 +08:00
|
|
|
|
2009-07-26 00:21:23 +08:00
|
|
|
insert_data = g_hash_table_lookup (private->item_hash, viewable);
|
2004-01-30 00:34:41 +08:00
|
|
|
|
|
|
|
if (insert_data)
|
|
|
|
{
|
2004-05-11 07:22:39 +08:00
|
|
|
GIMP_CONTAINER_VIEW_GET_INTERFACE (view)->rename_item (view,
|
|
|
|
viewable,
|
|
|
|
insert_data);
|
2004-01-30 00:34:41 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-29 03:02:32 +08:00
|
|
|
static void
|
|
|
|
gimp_container_view_connect_context (GimpContainerView *view)
|
|
|
|
{
|
|
|
|
GimpContainerViewPrivate *private = GIMP_CONTAINER_VIEW_GET_PRIVATE (view);
|
|
|
|
GType children_type;
|
|
|
|
const gchar *signal_name;
|
|
|
|
|
|
|
|
children_type = gimp_container_get_children_type (private->container);
|
|
|
|
signal_name = gimp_context_type_to_signal_name (children_type);
|
|
|
|
|
|
|
|
if (signal_name)
|
|
|
|
{
|
|
|
|
g_signal_connect_object (private->context, signal_name,
|
|
|
|
G_CALLBACK (gimp_container_view_context_changed),
|
|
|
|
view,
|
|
|
|
0);
|
|
|
|
|
|
|
|
if (private->dnd_widget)
|
|
|
|
gimp_dnd_viewable_dest_add (private->dnd_widget,
|
|
|
|
children_type,
|
|
|
|
gimp_container_view_viewable_dropped,
|
|
|
|
view);
|
|
|
|
|
|
|
|
if (! gimp_container_frozen (private->container))
|
|
|
|
{
|
|
|
|
GimpObject *object = gimp_context_get_by_type (private->context,
|
|
|
|
children_type);
|
|
|
|
|
|
|
|
gimp_container_view_select_item (view, GIMP_VIEWABLE (object));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_container_view_disconnect_context (GimpContainerView *view)
|
|
|
|
{
|
|
|
|
GimpContainerViewPrivate *private = GIMP_CONTAINER_VIEW_GET_PRIVATE (view);
|
|
|
|
GType children_type;
|
|
|
|
const gchar *signal_name;
|
|
|
|
|
|
|
|
children_type = gimp_container_get_children_type (private->container);
|
|
|
|
signal_name = gimp_context_type_to_signal_name (children_type);
|
|
|
|
|
|
|
|
if (signal_name)
|
|
|
|
{
|
|
|
|
g_signal_handlers_disconnect_by_func (private->context,
|
|
|
|
gimp_container_view_context_changed,
|
|
|
|
view);
|
|
|
|
|
|
|
|
if (private->dnd_widget)
|
|
|
|
{
|
|
|
|
gtk_drag_dest_unset (private->dnd_widget);
|
|
|
|
gimp_dnd_viewable_dest_remove (private->dnd_widget,
|
|
|
|
children_type);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-07 23:01:52 +08:00
|
|
|
static void
|
|
|
|
gimp_container_view_context_changed (GimpContext *context,
|
2004-08-26 06:31:44 +08:00
|
|
|
GimpViewable *viewable,
|
|
|
|
GimpContainerView *view)
|
2001-02-07 23:01:52 +08:00
|
|
|
{
|
2004-05-13 02:36:33 +08:00
|
|
|
if (! gimp_container_view_select_item (view, viewable))
|
|
|
|
g_warning ("%s: select_item() failed (should not happen)", G_STRFUNC);
|
2001-02-07 23:01:52 +08:00
|
|
|
}
|
2001-02-19 03:44:28 +08:00
|
|
|
|
|
|
|
static void
|
2001-08-05 04:38:54 +08:00
|
|
|
gimp_container_view_viewable_dropped (GtkWidget *widget,
|
2004-12-31 22:36:30 +08:00
|
|
|
gint x,
|
|
|
|
gint y,
|
2004-08-26 06:31:44 +08:00
|
|
|
GimpViewable *viewable,
|
|
|
|
gpointer data)
|
2001-02-19 03:44:28 +08:00
|
|
|
{
|
2004-05-11 07:22:39 +08:00
|
|
|
GimpContainerView *view = GIMP_CONTAINER_VIEW (data);
|
|
|
|
GimpContainerViewPrivate *private = GIMP_CONTAINER_VIEW_GET_PRIVATE (view);
|
2001-02-19 03:44:28 +08:00
|
|
|
|
2004-05-13 02:36:33 +08:00
|
|
|
if (viewable && private->container &&
|
|
|
|
gimp_container_have (private->container, GIMP_OBJECT (viewable)))
|
|
|
|
{
|
|
|
|
gimp_container_view_item_selected (view, viewable);
|
|
|
|
}
|
2001-02-19 03:44:28 +08:00
|
|
|
}
|
2001-08-05 04:38:54 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_container_view_button_viewable_dropped (GtkWidget *widget,
|
2004-12-31 22:36:30 +08:00
|
|
|
gint x,
|
|
|
|
gint y,
|
2004-08-26 06:31:44 +08:00
|
|
|
GimpViewable *viewable,
|
|
|
|
gpointer data)
|
2001-08-05 04:38:54 +08:00
|
|
|
{
|
2004-05-11 07:22:39 +08:00
|
|
|
GimpContainerView *view = GIMP_CONTAINER_VIEW (data);
|
|
|
|
GimpContainerViewPrivate *private = GIMP_CONTAINER_VIEW_GET_PRIVATE (view);
|
2001-08-05 04:38:54 +08:00
|
|
|
|
2004-05-11 07:22:39 +08:00
|
|
|
if (viewable && private->container &&
|
|
|
|
gimp_container_have (private->container, GIMP_OBJECT (viewable)))
|
2001-08-05 04:38:54 +08:00
|
|
|
{
|
|
|
|
gimp_container_view_item_selected (view, viewable);
|
|
|
|
|
|
|
|
gtk_button_clicked (GTK_BUTTON (widget));
|
|
|
|
}
|
|
|
|
}
|