Commit 3adc0816 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

More GimpContainerView chopping:

2004-05-10  Michael Natterer  <mitch@gimp.org>

	More GimpContainerView chopping:

	* app/widgets/gimpcontainerview.[ch]: added
	GimpContainerViewPrivate struct (which is currently puclic :-) and
	removed all members from the GimpContainerView struct. Added
	accessors for "context", "container" and "preview_size /
	preview_border_width". Added macro to get the private struct
	(*not* via G_TYPE_INSTANCE_GET_PRIVATE because that's unavailable
	for interfaces).

	* app/widgets/gimpbrushfactoryview.c
	* app/widgets/gimpbufferview.c
	* app/widgets/gimpchanneltreeview.c
	* app/widgets/gimpcontainerbox.c
	* app/widgets/gimpcontainereditor.c
	* app/widgets/gimpcontainergridview.c
	* app/widgets/gimpcontainerpopup.c
	* app/widgets/gimpcontainertreeview-dnd.c
	* app/widgets/gimpcontainertreeview.c
	* app/widgets/gimpdatafactoryview.c
	* app/widgets/gimpdocumentview.c
	* app/widgets/gimpfontview.c
	* app/widgets/gimpimageview.c
	* app/widgets/gimpitemtreeview.c
	* app/widgets/gimplayertreeview.c
	* app/widgets/gimpsessioninfo.c
	* app/widgets/gimptemplateview.c
	* app/widgets/gimptoolview.c
	* app/actions/brushes-actions.c
	* app/actions/buffers-actions.c
	* app/actions/dockable-actions.c
	* app/actions/dockable-commands.c
	* app/actions/documents-actions.c
	* app/actions/fonts-actions.c
	* app/actions/gradients-actions.c
	* app/actions/gradients-commands.c
	* app/actions/images-actions.c
	* app/actions/palettes-actions.c
	* app/actions/palettes-commands.c
	* app/actions/patterns-actions.c
	* app/actions/templates-actions.c
	* app/actions/tools-actions.c
	* app/actions/tools-commands.c: changed accordingly.
parent c1dc358d
2004-05-10 Michael Natterer <mitch@gimp.org>
More GimpContainerView chopping:
* app/widgets/gimpcontainerview.[ch]: added
GimpContainerViewPrivate struct (which is currently puclic :-) and
removed all members from the GimpContainerView struct. Added
accessors for "context", "container" and "preview_size /
preview_border_width". Added macro to get the private struct
(*not* via G_TYPE_INSTANCE_GET_PRIVATE because that's unavailable
for interfaces).
* app/widgets/gimpbrushfactoryview.c
* app/widgets/gimpbufferview.c
* app/widgets/gimpchanneltreeview.c
* app/widgets/gimpcontainerbox.c
* app/widgets/gimpcontainereditor.c
* app/widgets/gimpcontainergridview.c
* app/widgets/gimpcontainerpopup.c
* app/widgets/gimpcontainertreeview-dnd.c
* app/widgets/gimpcontainertreeview.c
* app/widgets/gimpdatafactoryview.c
* app/widgets/gimpdocumentview.c
* app/widgets/gimpfontview.c
* app/widgets/gimpimageview.c
* app/widgets/gimpitemtreeview.c
* app/widgets/gimplayertreeview.c
* app/widgets/gimpsessioninfo.c
* app/widgets/gimptemplateview.c
* app/widgets/gimptoolview.c
* app/actions/brushes-actions.c
* app/actions/buffers-actions.c
* app/actions/dockable-actions.c
* app/actions/dockable-commands.c
* app/actions/documents-actions.c
* app/actions/fonts-actions.c
* app/actions/gradients-actions.c
* app/actions/gradients-commands.c
* app/actions/images-actions.c
* app/actions/palettes-actions.c
* app/actions/palettes-commands.c
* app/actions/patterns-actions.c
* app/actions/templates-actions.c
* app/actions/tools-actions.c
* app/actions/tools-commands.c: changed accordingly.
2004-05-10 Sven Neumann <sven@gimp.org>
* app/tools/gimpmagnifyoptions.[ch]
......
......@@ -84,12 +84,14 @@ brushes_actions_update (GimpActionGroup *group,
gpointer user_data)
{
GimpContainerEditor *editor;
GimpContext *context;
GimpBrush *brush;
GimpData *data = NULL;
editor = GIMP_CONTAINER_EDITOR (user_data);
editor = GIMP_CONTAINER_EDITOR (user_data);
context = gimp_container_view_get_context (editor->view);
brush = gimp_context_get_brush (editor->view->context);
brush = gimp_context_get_brush (context);
if (brush)
data = GIMP_DATA (brush);
......
......@@ -77,11 +77,13 @@ buffers_actions_update (GimpActionGroup *group,
gpointer data)
{
GimpContainerEditor *editor;
GimpContext *context;
GimpBuffer *buffer;
editor = GIMP_CONTAINER_EDITOR (data);
editor = GIMP_CONTAINER_EDITOR (data);
context = gimp_container_view_get_context (editor->view);
buffer = gimp_context_get_buffer (editor->view->context);
buffer = gimp_context_get_buffer (context);
#define SET_SENSITIVE(action,condition) \
gimp_action_group_set_action_sensitive (group, action, (condition) != 0)
......
......@@ -239,7 +239,7 @@ dockable_actions_update (GimpActionGroup *group,
view = gimp_container_view_get_by_dockable (dockable);
if (view)
preview_size = view->preview_size;
preview_size = gimp_container_view_get_preview_size (view, NULL);
tab_style = dockable->tab_style;
......
......@@ -168,7 +168,8 @@ dockable_toggle_view_cmd_callback (GtkAction *action,
old_view = gimp_container_view_get_by_dockable (dockable);
if (old_view)
preview_size = old_view->preview_size;
preview_size = gimp_container_view_get_preview_size (old_view,
NULL);
new_dockable =
gimp_dialog_factory_dockable_new (dockbook->dock->dialog_factory,
......@@ -216,13 +217,20 @@ dockable_preview_size_cmd_callback (GtkAction *action,
if (dockable)
{
GimpContainerView *view;
GimpContainerView *view = gimp_container_view_get_by_dockable (dockable);
view = gimp_container_view_get_by_dockable (dockable);
if (view)
{
gint old_size;
gint border_width;
old_size = gimp_container_view_get_preview_size (view,
&border_width);
if (view && view->preview_size != preview_size)
gimp_container_view_set_preview_size (view, preview_size,
view->preview_border_width);
if (old_size != preview_size)
gimp_container_view_set_preview_size (view, preview_size,
border_width);
}
}
}
......
......@@ -92,11 +92,13 @@ documents_actions_update (GimpActionGroup *group,
gpointer data)
{
GimpContainerEditor *editor;
GimpContext *context;
GimpImagefile *imagefile;
editor = GIMP_CONTAINER_EDITOR (data);
editor = GIMP_CONTAINER_EDITOR (data);
context = gimp_container_view_get_context (editor->view);
imagefile = gimp_context_get_imagefile (editor->view->context);
imagefile = gimp_context_get_imagefile (context);
#define SET_SENSITIVE(action,condition) \
gimp_action_group_set_action_sensitive (group, action, (condition) != 0)
......
......@@ -64,11 +64,13 @@ fonts_actions_update (GimpActionGroup *group,
gpointer data)
{
GimpContainerEditor *editor;
GimpContext *context;
GimpFont *font;
editor = GIMP_CONTAINER_EDITOR (data);
editor = GIMP_CONTAINER_EDITOR (data);
context = gimp_container_view_get_context (editor->view);
font = gimp_context_get_font (editor->view->context);
font = gimp_context_get_font (context);
#define SET_SENSITIVE(action,condition) \
gimp_action_group_set_action_sensitive (group, action, (condition) != 0)
......
......@@ -91,12 +91,14 @@ gradients_actions_update (GimpActionGroup *group,
gpointer user_data)
{
GimpContainerEditor *editor;
GimpContext *context;
GimpGradient *gradient;
GimpData *data = NULL;
editor = GIMP_CONTAINER_EDITOR (user_data);
editor = GIMP_CONTAINER_EDITOR (user_data);
context = gimp_container_view_get_context (editor->view);
gradient = gimp_context_get_gradient (editor->view->context);
gradient = gimp_context_get_gradient (context);
if (gradient)
data = GIMP_DATA (gradient);
......
......@@ -61,11 +61,14 @@ gradients_save_as_pov_ray_cmd_callback (GtkAction *action,
static void
gradients_save_as_pov_query (GimpContainerEditor *editor)
{
GimpContext *context;
GimpGradient *gradient;
GtkFileChooser *chooser;
gchar *title;
gradient = gimp_context_get_gradient (editor->view->context);
context = gimp_container_view_get_context (editor->view);
gradient = gimp_context_get_gradient (context);
if (! gradient)
return;
......
......@@ -73,11 +73,13 @@ images_actions_update (GimpActionGroup *group,
gpointer data)
{
GimpContainerEditor *editor;
GimpContext *context;
GimpImage *image;
editor = GIMP_CONTAINER_EDITOR (data);
editor = GIMP_CONTAINER_EDITOR (data);
context = gimp_container_view_get_context (editor->view);
image = gimp_context_get_image (editor->view->context);
image = gimp_context_get_image (context);
#define SET_SENSITIVE(action,condition) \
gimp_action_group_set_action_sensitive (group, action, (condition) != 0)
......
......@@ -95,12 +95,14 @@ palettes_actions_update (GimpActionGroup *group,
gpointer user_data)
{
GimpContainerEditor *editor;
GimpContext *context;
GimpPalette *palette;
GimpData *data = NULL;
editor = GIMP_CONTAINER_EDITOR (user_data);
editor = GIMP_CONTAINER_EDITOR (user_data);
context = gimp_container_view_get_context (editor->view);
palette = gimp_context_get_palette (editor->view->context);
palette = gimp_context_get_palette (context);
if (palette)
data = GIMP_DATA (palette);
......
......@@ -55,8 +55,11 @@ palettes_import_palette_cmd_callback (GtkAction *action,
gpointer data)
{
GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data);
GimpContext *context;
palette_import_dialog_show (editor->view->context->gimp);
context = gimp_container_view_get_context (editor->view);
palette_import_dialog_show (context->gimp);
}
void
......
......@@ -84,12 +84,14 @@ patterns_actions_update (GimpActionGroup *group,
gpointer user_data)
{
GimpContainerEditor *editor;
GimpContext *context;
GimpPattern *pattern;
GimpData *data = NULL;
editor = GIMP_CONTAINER_EDITOR (user_data);
editor = GIMP_CONTAINER_EDITOR (user_data);
context = gimp_container_view_get_context (editor->view);
pattern = gimp_context_get_pattern (editor->view->context);
pattern = gimp_context_get_pattern (context);
if (pattern)
data = GIMP_DATA (pattern);
......
......@@ -83,11 +83,13 @@ templates_actions_update (GimpActionGroup *group,
gpointer data)
{
GimpContainerEditor *editor;
GimpContext *context;
GimpTemplate *template;
editor = GIMP_CONTAINER_EDITOR (data);
editor = GIMP_CONTAINER_EDITOR (data);
context = gimp_container_view_get_context (editor->view);
template = gimp_context_get_template (editor->view->context);
template = gimp_context_get_template (context);
#define SET_SENSITIVE(action,condition) \
gimp_action_group_set_action_sensitive (group, action, (condition) != 0)
......
......@@ -165,8 +165,14 @@ tools_actions_update (GimpActionGroup *group,
GimpToolInfo *tool_info = NULL;
if (GIMP_IS_CONTAINER_EDITOR (data))
tool_info =
gimp_context_get_tool (GIMP_CONTAINER_EDITOR (data)->view->context);
{
GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data);
GimpContext *context;
context = gimp_container_view_get_context (editor->view);
tool_info = gimp_context_get_tool (context);
}
#define SET_ACTIVE(action,condition) \
gimp_action_group_set_action_active (group, action, (condition) != 0)
......
......@@ -105,11 +105,14 @@ tools_toggle_visibility_cmd_callback (GtkAction *action,
{
if (GIMP_IS_CONTAINER_EDITOR (data))
{
GimpToolInfo *tool_info;
gboolean active;
GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data);
GimpContext *context;
GimpToolInfo *tool_info;
gboolean active;
tool_info =
gimp_context_get_tool (GIMP_CONTAINER_EDITOR (data)->view->context);
context = gimp_container_view_get_context (editor->view);
tool_info = gimp_context_get_tool (context);
active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
......
......@@ -129,13 +129,16 @@ gimp_brush_factory_view_init (GimpBrushFactoryView *view)
static void
gimp_brush_factory_view_destroy (GtkObject *object)
{
GimpBrushFactoryView *view;
view = GIMP_BRUSH_FACTORY_VIEW (object);
GimpBrushFactoryView *view = GIMP_BRUSH_FACTORY_VIEW (object);
GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (object);
if (view->spacing_changed_handler_id)
{
gimp_container_remove_handler (GIMP_CONTAINER_EDITOR (view)->view->container,
GimpContainer *container;
container = gimp_container_view_get_container (editor->view);
gimp_container_remove_handler (container,
view->spacing_changed_handler_id);
view->spacing_changed_handler_id = 0;
......@@ -189,7 +192,7 @@ gimp_brush_factory_view_new (GimpViewType view_type,
FALSE, FALSE, 0);
factory_view->spacing_changed_handler_id =
gimp_container_add_handler (editor->view->container, "spacing_changed",
gimp_container_add_handler (factory->container, "spacing_changed",
G_CALLBACK (gimp_brush_factory_view_spacing_changed),
factory_view);
......@@ -200,17 +203,16 @@ static void
gimp_brush_factory_view_select_item (GimpContainerEditor *editor,
GimpViewable *viewable)
{
GimpBrushFactoryView *view;
GimpBrushFactoryView *view = GIMP_BRUSH_FACTORY_VIEW (editor);
GimpContainer *container;
gboolean spacing_sensitive = FALSE;
if (GIMP_CONTAINER_EDITOR_CLASS (parent_class)->select_item)
GIMP_CONTAINER_EDITOR_CLASS (parent_class)->select_item (editor, viewable);
view = GIMP_BRUSH_FACTORY_VIEW (editor);
container = gimp_container_view_get_container (editor->view);
if (viewable &&
gimp_container_have (GIMP_CONTAINER_EDITOR (view)->view->container,
GIMP_OBJECT (viewable)))
if (viewable && gimp_container_have (container, GIMP_OBJECT (viewable)))
{
GimpBrush *brush = GIMP_BRUSH (viewable);
......@@ -235,7 +237,12 @@ static void
gimp_brush_factory_view_spacing_changed (GimpBrush *brush,
GimpBrushFactoryView *view)
{
if (brush == GIMP_CONTAINER_EDITOR (view)->view->context->brush)
GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (view);
GimpContext *context;
context = gimp_container_view_get_context (editor->view);
if (brush == gimp_context_get_brush (context))
{
g_signal_handlers_block_by_func (view->spacing_adjustment,
gimp_brush_factory_view_spacing_update,
......@@ -254,7 +261,13 @@ static void
gimp_brush_factory_view_spacing_update (GtkAdjustment *adjustment,
GimpBrushFactoryView *view)
{
GimpBrush *brush = GIMP_CONTAINER_EDITOR (view)->view->context->brush;
GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (view);
GimpContext *context;
GimpBrush *brush;
context = gimp_container_view_get_context (editor->view);
brush = gimp_context_get_brush (context);
if (brush && view->change_brush_spacing)
{
......
......@@ -206,14 +206,18 @@ gimp_buffer_view_paste (GimpBufferView *view,
gboolean paste_into)
{
GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (view);
GimpContainer *container;
GimpContext *context;
GimpBuffer *buffer;
buffer = gimp_context_get_buffer (editor->view->context);
container = gimp_container_view_get_container (editor->view);
context = gimp_container_view_get_context (editor->view);
if (buffer && gimp_container_have (editor->view->container,
GIMP_OBJECT (buffer)))
buffer = gimp_context_get_buffer (context);
if (buffer && gimp_container_have (container, GIMP_OBJECT (buffer)))
{
GimpDisplay *gdisp = gimp_context_get_display (editor->view->context);
GimpDisplay *gdisp = gimp_context_get_display (context);
GimpImage *gimage = NULL;
gint x = -1;
gint y = -1;
......@@ -231,7 +235,7 @@ gimp_buffer_view_paste (GimpBufferView *view,
}
else
{
gimage = gimp_context_get_image (editor->view->context);
gimage = gimp_context_get_image (context);
}
if (gimage)
......@@ -263,14 +267,18 @@ gimp_buffer_view_paste_as_new_clicked (GtkWidget *widget,
GimpBufferView *view)
{
GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (view);
GimpContainer *container;
GimpContext *context;
GimpBuffer *buffer;
buffer = gimp_context_get_buffer (editor->view->context);
container = gimp_container_view_get_container (editor->view);
context = gimp_container_view_get_context (editor->view);
buffer = gimp_context_get_buffer (context);
if (buffer && gimp_container_have (editor->view->container,
GIMP_OBJECT (buffer)))
if (buffer && gimp_container_have (container, GIMP_OBJECT (buffer)))
{
GimpImage *gimage = gimp_context_get_image (editor->view->context);
GimpImage *gimage = gimp_context_get_image (context);
if (gimage)
gimp_edit_paste_as_new (gimage->gimp, gimage, buffer);
......@@ -282,14 +290,18 @@ gimp_buffer_view_delete_clicked (GtkWidget *widget,
GimpBufferView *view)
{
GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (view);
GimpContainer *container;
GimpContext *context;
GimpBuffer *buffer;
buffer = gimp_context_get_buffer (editor->view->context);
container = gimp_container_view_get_container (editor->view);
context = gimp_container_view_get_context (editor->view);
buffer = gimp_context_get_buffer (context);
if (buffer && gimp_container_have (editor->view->container,
GIMP_OBJECT (buffer)))
if (buffer && gimp_container_have (container, GIMP_OBJECT (buffer)))
{
gimp_container_remove (editor->view->container, GIMP_OBJECT (buffer));
gimp_container_remove (container, GIMP_OBJECT (buffer));
}
}
......@@ -298,6 +310,7 @@ gimp_buffer_view_select_item (GimpContainerEditor *editor,
GimpViewable *viewable)
{
GimpBufferView *view = GIMP_BUFFER_VIEW (editor);
GimpContainer *container;
gboolean paste_sensitive = FALSE;
gboolean paste_into_sensitive = FALSE;
gboolean paste_as_new_sensitive = FALSE;
......@@ -306,8 +319,9 @@ gimp_buffer_view_select_item (GimpContainerEditor *editor,
if (GIMP_CONTAINER_EDITOR_CLASS (parent_class)->select_item)
GIMP_CONTAINER_EDITOR_CLASS (parent_class)->select_item (editor, viewable);
if (viewable && gimp_container_have (editor->view->container,
GIMP_OBJECT (viewable)))
container = gimp_container_view_get_container (editor->view);
if (viewable && gimp_container_have (container, GIMP_OBJECT (viewable)))
{
paste_sensitive = TRUE;
paste_into_sensitive = TRUE;
......@@ -326,12 +340,14 @@ gimp_buffer_view_activate_item (GimpContainerEditor *editor,
GimpViewable *viewable)
{
GimpBufferView *view = GIMP_BUFFER_VIEW (editor);
GimpContainer *container;
if (GIMP_CONTAINER_EDITOR_CLASS (parent_class)->activate_item)
GIMP_CONTAINER_EDITOR_CLASS (parent_class)->activate_item (editor, viewable);
if (viewable && gimp_container_have (editor->view->container,
GIMP_OBJECT (viewable)))
container = gimp_container_view_get_container (editor->view);
if (viewable && gimp_container_have (container, GIMP_OBJECT (viewable)))
{
gimp_buffer_view_paste_clicked (NULL, view);
}
......
......@@ -178,14 +178,17 @@ static void
gimp_channel_tree_view_set_image (GimpItemTreeView *item_view,
GimpImage *gimage)
{
GimpChannelTreeView *channel_view;
channel_view = GIMP_CHANNEL_TREE_VIEW (item_view);
GimpChannelTreeView *channel_view = GIMP_CHANNEL_TREE_VIEW (item_view);
if (! channel_view->component_editor)
{
GimpContainerView *view = GIMP_CONTAINER_VIEW (item_view);
gint preview_size;
preview_size = gimp_container_view_get_preview_size (view, NULL);
channel_view->component_editor =
gimp_component_editor_new (GIMP_CONTAINER_VIEW (item_view)->preview_size,
gimp_component_editor_new (preview_size,
GIMP_EDITOR (item_view)->menu_factory);
gtk_box_pack_start (GTK_BOX (item_view), channel_view->component_editor,
FALSE, FALSE, 0);
......@@ -241,15 +244,16 @@ gimp_channel_tree_view_select_item (GimpContainerView *view,
static void
gimp_channel_tree_view_set_preview_size (GimpContainerView *view)
{
GimpChannelTreeView *channel_view;
GimpChannelTreeView *channel_view = GIMP_CHANNEL_TREE_VIEW (view);
gint preview_size;
channel_view = GIMP_CHANNEL_TREE_VIEW (view);
preview_size = gimp_container_view_get_preview_size (view, NULL);
GIMP_CONTAINER_VIEW_CLASS (parent_class)->set_preview_size (view);
if (channel_view->component_editor)
gimp_component_editor_set_preview_size (GIMP_COMPONENT_EDITOR (channel_view->component_editor),
view->preview_size);
preview_size);
}
static void
......
......@@ -102,7 +102,10 @@ gimp_container_box_class_init (GimpContainerBoxClass *klass)
static void
gimp_container_box_init (GimpContainerBox *box)
{
GimpContainerView *view = GIMP_CONTAINER_VIEW (box);
GimpContainerView *view = GIMP_CONTAINER_VIEW (box);
GimpContainerViewPrivate *private;
private = GIMP_CONTAINER_VIEW_GET_PRIVATE (view);
box->scrolled_win = gtk_scrolled_window_new (NULL, NULL);
gtk_box_pack_start (GTK_BOX (box), box->scrolled_win, TRUE, TRUE, 0);
......@@ -111,7 +114,7 @@ gimp_container_box_init (GimpContainerBox *box)
GTK_WIDGET_UNSET_FLAGS (GTK_SCROLLED_WINDOW (box->scrolled_win)->vscrollbar,
GTK_CAN_FOCUS);
view->dnd_widget = box->scrolled_win;
private->dnd_widget = box->scrolled_win;
}
static void
......@@ -129,6 +132,7 @@ gimp_container_box_set_size_request (GimpContainerBox *box,
GimpContainerView *view;
GtkScrolledWindowClass *sw_class;
GtkRequisition req;
gint preview_size;
gint scrollbar_width;
gint border_x;
gint border_y;
......@@ -137,8 +141,10 @@ gimp_container_box_set_size_request (GimpContainerBox *box,
view = GIMP_CONTAINER_VIEW (box);
g_return_if_fail (width <= 0 || width >= view->preview_size);
g_return_if_fail (height <= 0 || height >= view->preview_size);
preview_size = gimp_container_view_get_preview_size (view, NULL);
g_return_if_fail (width <= 0 || width >= preview_size);
g_return_if_fail (height <= 0 || height >= preview_size);
sw_class = GTK_SCROLLED_WINDOW_GET_CLASS (box->scrolled_win);
......@@ -176,6 +182,7 @@ gimp_container_box_get_preview (GimpDocked *docked,
{
GimpContainerBox *box = GIMP_CONTAINER_BOX (docked);
GimpContainerView *view = GIMP_CONTAINER_VIEW (docked);
GimpContainer *container;
GtkWidget *preview;
GdkScreen *screen;
gint width;
......@@ -183,13 +190,15 @@ gimp_container_box_get_preview (GimpDocked *docked,
gint border_width = 1;
const gchar *prop_name;
g_return_val_if_fail (view->container != NULL, NULL);
container = gimp_container_view_get_container (view);
g_return_val_if_fail (container != NULL, NULL);
screen = gtk_widget_get_screen (GTK_WIDGET (box));
gtk_icon_size_lookup_for_settings (gtk_settings_get_for_screen (screen),
size, &width, &height);
prop_name = gimp_context_type_to_prop_name (view->container->children_type);
prop_name = gimp_context_type_to_prop_name (container->children_type);
if (! strcmp (prop_name, "tool") ||
! strcmp (prop_name, "template"))
......
......@@ -259,8 +259,9 @@ static void
gimp_container_editor_real_context_item (GimpContainerEditor *editor,
GimpViewable *viewable)
{
if (viewable && gimp_container_have (editor->view->container,
GIMP_OBJECT (viewable)))
GimpContainer *container = gimp_container_view_get_container (editor->view);
if (viewable && gimp_container_have (container, GIMP_OBJECT (viewable)))
{
GimpEditor *gimp_editor = GIMP_EDITOR (editor->view);
......
......@@ -249,31 +249,32 @@ gimp_container_grid_view_new (GimpContainer *container,
}
static gboolean
gimp_container_grid_view_move_by (GimpContainerGridView *view,
gimp_container_grid_view_move_by (GimpContainerGridView *grid_view,
gint x,
gint y)
{
GimpContainer *container;
GimpViewable *item;
gint index;
GimpContainerView *view = GIMP_CONTAINER_VIEW (grid_view);
GimpContainer *container;
GimpViewable *item;
gint index;
if (! view->selected_item)
if (! grid_view->selected_item)
return FALSE;
container = GIMP_CONTAINER_VIEW (view)->container;
container = gimp_container_view_get_container (view);
item = view->selected_item->viewable;
item = grid_view->selected_item->viewable;
index = gimp_container_get_child_index (container, GIMP_OBJECT (item));
index += x;
index = CLAMP (index, 0, container->num_children - 1);
index += y * view->columns;
index += y * grid_view->columns;
while (index < 0)
index += view->columns;
index += grid_view->columns;
while (index >= container->num_children)
index -= view->columns;
index -= grid_view->columns;
item = (GimpViewable *) gimp_container_get_child_by_index (container, index);
if (item)
......@@ -283,30 +284,32 @@ gimp_container_grid_view_move_by (GimpContainerGridView *view,
}
static gboolean
gimp_container_grid_view_move_cursor (GimpContainerGridView *view,
gimp_container_grid_view_move_cursor (GimpContainerGridView *grid_view,
GtkMovementStep step,
gint count)
{
GimpContainer *container;
GimpViewable *item;
GimpContainerView *view = GIMP_CONTAINER_VIEW (grid_view);
GimpContainer *container;
GimpViewable *item;
if (!GTK_WIDGET_HAS_FOCUS (GTK_WIDGET (view)) || count == 0)
if (! GTK_WIDGET_HAS_FOCUS (GTK_WIDGET (grid_view)) || count == 0)
return FALSE;
container = gimp_container_view_get_container (view);
switch (step)
{
case GTK_MOVEMENT_PAGES:
return gimp_container_grid_view_move_by (view,
0, count * view->visible_rows);
return gimp_container_grid_view_move_by (grid_view, 0,
count * grid_view->visible_rows);
case GTK_MOVEMENT_BUFFER_ENDS:
container = GIMP_CONTAINER_VIEW (view)->container;
count = count < 0 ? 0 : container->num_children - 1;
item = (GimpViewable *) gimp_container_get_child_by_index (container,
count);
if (item)
gimp_container_view_item_selected (GIMP_CONTAINER_VIEW (view), item);
gimp_container_view_item_selected (view, item);
return TRUE;
......@@ -400,10 +403,13 @@ gimp_container_grid_view_insert_item (GimpContainerView *view,
{
GimpContainerGridView *grid_view = GIMP_CONTAINER_GRID_VIEW (view);
GtkWidget *preview;