Commit bb30140a authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

treeviewized and undeprecated.



2002-03-16  Michael Natterer  <mitch@gimp.org>

	* app/display/gimpdisplayshell-filter-dialog.c: treeviewized
	and undeprecated.

	* app/widgets/Makefile.am
	* app/widgets/gimpconstrainedhwrapbox.[ch]: removed this hack.

	* app/widgets/gimpcontainergridview.[ch]: added "rows" and
	"columns" fields, connect to the viewport's "size_allocate" signal
	and set the size_request of the wrap_box in the callback.
parent 63593ca3
......@@ -143,8 +143,6 @@ libappwidgets_a_sources = @STRIP_BEGIN@ \
gtkhwrapbox.h \
gtkvwrapbox.c \
gtkvwrapbox.h \
gimpconstrainedhwrapbox.c \
gimpconstrainedhwrapbox.h \
@STRIP_END@
libappwidgets_a_built_sources = @STRIP_BEGIN@ \
......
This diff is collapsed.
/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* GtkHWrapBox: Horizontal wrapping box widget
* Copyright (C) 1999 Tim Janik
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#ifdef __GNUC__
#warning GTK_DISABLE_DEPRECATED
#endif
#undef GTK_DISABLE_DEPRECATED
#include <gtk/gtk.h>
#include "gimpconstrainedhwrapbox.h"
static void gimp_constrained_hwrap_box_class_init (GimpConstrainedHWrapBoxClass *klass);
static void gimp_constrained_hwrap_box_init (GimpConstrainedHWrapBox *hwbox);
static void gimp_constrained_hwrap_box_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static void gimp_constrained_hwrap_box_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static GtkHWrapBoxClass *parent_class = NULL;
GtkType
gimp_constrained_hwrap_box_get_type (void)
{
static GtkType constrained_hwrap_box_type = 0;
if (! constrained_hwrap_box_type)
{
static const GtkTypeInfo constrained_hwrap_box_info =
{
"GimpConstrainedHWrapBox",
sizeof (GimpConstrainedHWrapBox),
sizeof (GimpConstrainedHWrapBoxClass),
(GtkClassInitFunc) gimp_constrained_hwrap_box_class_init,
(GtkObjectInitFunc) gimp_constrained_hwrap_box_init,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL,
};
constrained_hwrap_box_type = gtk_type_unique (GTK_TYPE_HWRAP_BOX,
&constrained_hwrap_box_info);
}
return constrained_hwrap_box_type;
}
static void
gimp_constrained_hwrap_box_class_init (GimpConstrainedHWrapBoxClass *class)
{
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
object_class = GTK_OBJECT_CLASS (class);
widget_class = GTK_WIDGET_CLASS (class);
parent_class = gtk_type_class (GTK_TYPE_HWRAP_BOX);
widget_class->size_request = gimp_constrained_hwrap_box_size_request;
widget_class->size_allocate = gimp_constrained_hwrap_box_size_allocate;
}
static void
gimp_constrained_hwrap_box_init (GimpConstrainedHWrapBox *hwbox)
{
hwbox->rows = 1;
hwbox->columns = 1;
}
GtkWidget*
gimp_constrained_hwrap_box_new (gboolean homogeneous)
{
GimpConstrainedHWrapBox *hwbox;
hwbox = GIMP_CONSTRAINED_HWRAP_BOX (gtk_widget_new (GIMP_TYPE_CONSTRAINED_HWRAP_BOX, NULL));
GTK_WRAP_BOX (hwbox)->homogeneous = homogeneous ? TRUE : FALSE;
return GTK_WIDGET (hwbox);
}
static void
gimp_constrained_hwrap_box_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
GtkWrapBox *wbox = GTK_WRAP_BOX (widget);
g_return_if_fail (requisition != NULL);
if (widget->parent &&
GTK_IS_VIEWPORT (widget->parent) &&
widget->parent->parent &&
GTK_IS_SCROLLED_WINDOW (widget->parent->parent) &&
wbox->children &&
wbox->children->widget)
{
GtkWidget *scrolled_win;
gint child_width;
gint child_height;
gint viewport_width;
gint columns;
gint rows;
scrolled_win = widget->parent->parent;
child_width = wbox->children->widget->requisition.width;
child_height = wbox->children->widget->requisition.height;
viewport_width =
(scrolled_win->allocation.width -
GTK_SCROLLED_WINDOW (scrolled_win)->vscrollbar->allocation.width -
GTK_SCROLLED_WINDOW_GET_CLASS (scrolled_win)->scrollbar_spacing -
scrolled_win->style->xthickness * 2);
columns =
(viewport_width + wbox->hspacing) / (child_width + wbox->hspacing);
columns = MAX (1, columns);
requisition->width = (child_width + wbox->hspacing) * columns;
rows = wbox->n_children / columns;
if (rows * columns < wbox->n_children)
rows++;
requisition->height = (child_height + wbox->vspacing) * rows;
GIMP_CONSTRAINED_HWRAP_BOX (wbox)->columns = columns;
GIMP_CONSTRAINED_HWRAP_BOX (wbox)->rows = rows;
}
else if (GTK_WIDGET_CLASS (parent_class)->size_request)
{
GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition);
GIMP_CONSTRAINED_HWRAP_BOX (wbox)->columns = 1;
GIMP_CONSTRAINED_HWRAP_BOX (wbox)->rows = 1;
}
}
static void
gimp_constrained_hwrap_box_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
GtkWrapBox *wbox = GTK_WRAP_BOX (widget);
g_return_if_fail (allocation != NULL);
if (widget->parent &&
GTK_IS_VIEWPORT (widget->parent) &&
widget->parent->parent &&
GTK_IS_SCROLLED_WINDOW (widget->parent->parent) &&
wbox->children &&
wbox->children->widget)
{
GtkWidget *scrolled_win;
gint child_width;
gint child_height;
gint viewport_width;
gint columns;
gint rows;
scrolled_win = widget->parent->parent;
child_width = wbox->children->widget->requisition.width;
child_height = wbox->children->widget->requisition.height;
viewport_width =
(scrolled_win->allocation.width -
GTK_SCROLLED_WINDOW (scrolled_win)->vscrollbar->allocation.width -
GTK_SCROLLED_WINDOW_GET_CLASS (scrolled_win)->scrollbar_spacing -
scrolled_win->style->xthickness * 2);
allocation->width = viewport_width;
columns =
(viewport_width + wbox->hspacing) / (child_width + wbox->hspacing);
columns = MAX (1, columns);
rows = wbox->n_children / columns;
if (rows * columns < wbox->n_children)
rows++;
GIMP_CONSTRAINED_HWRAP_BOX (wbox)->columns = columns;
GIMP_CONSTRAINED_HWRAP_BOX (wbox)->rows = rows;
}
else
{
GIMP_CONSTRAINED_HWRAP_BOX (wbox)->columns = 1;
GIMP_CONSTRAINED_HWRAP_BOX (wbox)->rows = 1;
}
if (GTK_WIDGET_CLASS (parent_class)->size_allocate)
GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
}
/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* GtkHWrapBox: Horizontal wrapping box widget
* Copyright (C) 1999 Tim Janik
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_CONSTRAINED_HWRAP_BOX_H__
#define __GIMP_CONSTRAINED_HWRAP_BOX_H__
#include "gtkhwrapbox.h"
#define GIMP_TYPE_CONSTRAINED_HWRAP_BOX (gimp_constrained_hwrap_box_get_type ())
#define GIMP_CONSTRAINED_HWRAP_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_CONSTRAINED_HWRAP_BOX, GimpConstrainedHWrapBox))
#define GIMP_CONSTRAINED_HWRAP_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_CONSTRAINED_HWRAP_BOX, GimpConstrainedHWrapBoxClass))
#define GIMP_IS_CONSTRAINED_HWRAP_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_CONSTRAINED_HWRAP_BOX))
#define GIMP_IS_CONSTRAINED_HWRAP_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CONSTRAINED_HWRAP_BOX))
#define GIMP_CONSTRAINED_HWRAP_BOX_GET_CLASS(obj) (GIMP_CONSTRAINED_HWRAP_BOX_CLASS (((GtkObject *) (obj))->klass))
typedef struct _GimpConstrainedHWrapBox GimpConstrainedHWrapBox;
typedef struct _GimpConstrainedHWrapBoxClass GimpConstrainedHWrapBoxClass;
struct _GimpConstrainedHWrapBox
{
GtkHWrapBox parent_instance;
gint rows;
gint columns;
};
struct _GimpConstrainedHWrapBoxClass
{
GtkHWrapBoxClass parent_class;
};
GtkType gimp_constrained_hwrap_box_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_constrained_hwrap_box_new (gboolean homogeneous);
#endif /* __GTK_CONSTRAINED_HWRAP_BOX_H__ */
......@@ -34,7 +34,7 @@
#include "gimpcontainergridview.h"
#include "gimppreview.h"
#include "gimpconstrainedhwrapbox.h"
#include "gtkhwrapbox.h"
#include "libgimp/gimpintl.h"
......@@ -67,6 +67,10 @@ static void gimp_container_grid_view_highlight_item (GimpContainerView *v
GimpViewable *viewable,
gpointer insert_data);
static void gimp_container_grid_view_vieport_resized (GtkWidget *widget,
GtkAllocation *allocation,
GimpContainerGridView *view);
static GimpContainerViewClass *parent_class = NULL;
......@@ -125,6 +129,9 @@ gimp_container_grid_view_class_init (GimpContainerGridViewClass *klass)
static void
gimp_container_grid_view_init (GimpContainerGridView *grid_view)
{
grid_view->rows = 1;
grid_view->columns = 1;
grid_view->name_label = gtk_label_new (_("(None)"));
gtk_misc_set_alignment (GTK_MISC (grid_view->name_label), 0.0, 0.5);
gtk_misc_set_padding (GTK_MISC (grid_view->name_label),
......@@ -143,18 +150,19 @@ gimp_container_grid_view_init (GimpContainerGridView *grid_view)
GIMP_CONTAINER_VIEW (grid_view)->dnd_widget = grid_view->scrolled_win;
grid_view->wrap_box = gimp_constrained_hwrap_box_new (FALSE);
gtk_wrap_box_set_aspect_ratio (GTK_WRAP_BOX (grid_view->wrap_box),
1.0 / 256.0);
gtk_scrolled_window_add_with_viewport
(GTK_SCROLLED_WINDOW (grid_view->scrolled_win),
grid_view->wrap_box);
grid_view->wrap_box = gtk_hwrap_box_new (FALSE);
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (grid_view->scrolled_win),
grid_view->wrap_box);
gtk_widget_show (grid_view->wrap_box);
g_signal_connect (G_OBJECT (grid_view->wrap_box->parent), "size_allocate",
G_CALLBACK (gimp_container_grid_view_vieport_resized),
grid_view);
gtk_container_set_focus_vadjustment
(GTK_CONTAINER (grid_view->wrap_box->parent),
gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW
(grid_view->scrolled_win)));
gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW
(grid_view->scrolled_win)));
GTK_WIDGET_UNSET_FLAGS (GTK_SCROLLED_WINDOW
(grid_view->scrolled_win)->vscrollbar,
......@@ -393,7 +401,7 @@ gimp_container_grid_view_highlight_item (GimpContainerView *view,
index = gimp_container_get_child_index (view->container,
GIMP_OBJECT (viewable));
row = index / GIMP_CONSTRAINED_HWRAP_BOX (grid_view->wrap_box)->columns;
row = index / grid_view->columns;
if (row * item_height < adj->value)
{
......@@ -430,3 +438,51 @@ gimp_container_grid_view_highlight_item (GimpContainerView *view,
g_object_set_data (G_OBJECT (view), "last_selected_item", preview);
}
static void
gimp_container_grid_view_vieport_resized (GtkWidget *widget,
GtkAllocation *allocation,
GimpContainerGridView *grid_view)
{
GimpContainerView *view;
view = GIMP_CONTAINER_VIEW (grid_view);
if (view->container)
{
GList *children;
gint n_children;
children = gtk_container_get_children (GTK_CONTAINER (grid_view->wrap_box));
n_children = g_list_length (children);
if (children)
{
GtkRequisition preview_requisition;
gint columns;
gint rows;
gtk_widget_size_request (GTK_WIDGET (children->data),
&preview_requisition);
g_list_free (children);
columns = MAX (1, allocation->width / preview_requisition.width);
rows = n_children / columns;
if (n_children % columns)
rows++;
if ((rows != grid_view->rows) || (columns != grid_view->columns))
{
grid_view->rows = rows;
grid_view->columns = columns;
gtk_widget_set_size_request (grid_view->wrap_box,
columns * preview_requisition.width,
rows * preview_requisition.height);
}
}
}
}
......@@ -44,6 +44,9 @@ struct _GimpContainerGridView
GtkWidget *scrolled_win;
GtkWidget *wrap_box;
gint rows;
gint columns;
};
struct _GimpContainerGridViewClass
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment