Commit 1db678df authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

take the container's border_width into account.

2005-09-11  Michael Natterer  <mitch@gimp.org>

	* app/widgets/gimpcontainerbox.c
	(gimp_container_box_set_size_request): take the container's
	border_width into account.

	* app/widgets/gimpcontainergridview.c
	(gimp_container_grid_view_init): make sure GTK_SHADOW_IN is set on
	the scrolled window, not on the viewport, so we get the same
	results for list and grid views when using
	gimp_container_box_set_size_request().

	* app/widgets/gimpcontainerpopup.[ch]: added setters and getters
	for view_type and preview_size, don't allow the preview to grow
	larger than the popup.

	* app/widgets/gimpviewablebutton.[ch]: added "popup-view-type" and
	"popup-preview-size" properties and setters/getters.
parent 33f16adf
2005-09-11 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpcontainerbox.c
(gimp_container_box_set_size_request): take the container's
border_width into account.
* app/widgets/gimpcontainergridview.c
(gimp_container_grid_view_init): make sure GTK_SHADOW_IN is set on
the scrolled window, not on the viewport, so we get the same
results for list and grid views when using
gimp_container_box_set_size_request().
* app/widgets/gimpcontainerpopup.[ch]: added setters and getters
for view_type and preview_size, don't allow the preview to grow
larger than the popup.
* app/widgets/gimpviewablebutton.[ch]: added "popup-view-type" and
"popup-preview-size" properties and setters/getters.
2005-09-10 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpviewablebox.c: factored out common code in
......
......@@ -177,8 +177,11 @@ gimp_container_box_set_size_request (GimpContainerBox *box,
&req);
scrollbar_width += req.width;
border_x = box->scrolled_win->style->xthickness * 2 + scrollbar_width;
border_y = box->scrolled_win->style->ythickness * 2;
border_x = GTK_CONTAINER (box)->border_width;
border_y = GTK_CONTAINER (box)->border_width;
border_x += box->scrolled_win->style->xthickness * 2 + scrollbar_width;
border_y += box->scrolled_win->style->ythickness * 2;
gtk_widget_set_size_request (box->scrolled_win,
width > 0 ? width + border_x : -1,
......
......@@ -203,6 +203,8 @@ gimp_container_grid_view_init (GimpContainerGridView *grid_view)
grid_view->visible_rows = 0;
grid_view->selected_item = NULL;
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (box->scrolled_win),
GTK_SHADOW_IN);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (box->scrolled_win),
GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
......@@ -211,6 +213,8 @@ gimp_container_grid_view_init (GimpContainerGridView *grid_view)
grid_view->wrap_box = gtk_hwrap_box_new (FALSE);
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (box->scrolled_win),
grid_view->wrap_box);
gtk_viewport_set_shadow_type (GTK_VIEWPORT (grid_view->wrap_box->parent),
GTK_SHADOW_NONE);
gtk_widget_show (grid_view->wrap_box);
g_signal_connect (grid_view->wrap_box->parent, "size-allocate",
......
......@@ -2,7 +2,7 @@
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpcontainerpopup.c
* Copyright (C) 2003 Michael Natterer <mitch@gimp.org>
* Copyright (C) 2003-2005 Michael Natterer <mitch@gimp.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -466,6 +466,68 @@ gimp_container_popup_show (GimpContainerPopup *popup,
gtk_widget_show (GTK_WIDGET (popup));
}
GimpViewType
gimp_container_popup_get_view_type (GimpContainerPopup *popup)
{
g_return_val_if_fail (GIMP_IS_CONTAINER_POPUP (popup), GIMP_VIEW_TYPE_LIST);
return popup->view_type;
}
void
gimp_container_popup_set_view_type (GimpContainerPopup *popup,
GimpViewType view_type)
{
g_return_if_fail (GIMP_IS_CONTAINER_POPUP (popup));
if (view_type != popup->view_type)
{
popup->view_type = view_type;
gtk_container_remove (GTK_CONTAINER (popup->frame),
GTK_WIDGET (popup->editor));
gimp_container_popup_create_view (popup);
}
}
gint
gimp_container_popup_get_preview_size (GimpContainerPopup *popup)
{
g_return_val_if_fail (GIMP_IS_CONTAINER_POPUP (popup), GIMP_VIEW_SIZE_SMALL);
return popup->preview_size;
}
void
gimp_container_popup_set_preview_size (GimpContainerPopup *popup,
gint preview_size)
{
GtkWidget *scrolled_win;
gint viewport_width;
g_return_if_fail (GIMP_IS_CONTAINER_POPUP (popup));
scrolled_win = GIMP_CONTAINER_BOX (popup->editor->view)->scrolled_win;
viewport_width = GTK_BIN (scrolled_win)->child->allocation.width;
preview_size = CLAMP (preview_size, GIMP_VIEW_SIZE_TINY,
MIN (GIMP_VIEW_SIZE_GIGANTIC,
viewport_width - 2 * popup->preview_border_width));
if (preview_size != popup->preview_size)
{
popup->preview_size = preview_size;
gimp_container_view_set_preview_size (popup->editor->view,
popup->preview_size,
popup->preview_border_width);
}
}
/* private functions */
static void
gimp_container_popup_create_view (GimpContainerPopup *popup)
{
......@@ -533,16 +595,7 @@ gimp_container_popup_smaller_clicked (GtkWidget *button,
preview_size = gimp_container_view_get_preview_size (popup->editor->view,
NULL);
preview_size = MAX (GIMP_VIEW_SIZE_TINY, preview_size * 0.8);
if (preview_size != popup->preview_size)
{
popup->preview_size = preview_size;
gimp_container_view_set_preview_size (popup->editor->view,
popup->preview_size,
popup->preview_border_width);
}
gimp_container_popup_set_preview_size (popup, preview_size * 0.8);
}
static void
......@@ -554,16 +607,7 @@ gimp_container_popup_larger_clicked (GtkWidget *button,
preview_size = gimp_container_view_get_preview_size (popup->editor->view,
NULL);
preview_size = MAX (GIMP_VIEW_SIZE_TINY, preview_size * 1.2);
if (preview_size != popup->preview_size)
{
popup->preview_size = preview_size;
gimp_container_view_set_preview_size (popup->editor->view,
popup->preview_size,
popup->preview_border_width);
}
gimp_container_popup_set_preview_size (popup, preview_size * 1.2);
}
static void
......@@ -577,14 +621,7 @@ gimp_container_popup_view_type_toggled (GtkWidget *button,
view_type = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button),
"gimp-item-data"));
if (view_type != popup->view_type)
{
popup->view_type = view_type;
gtk_container_remove (GTK_CONTAINER (popup->frame),
GTK_WIDGET (popup->editor));
gimp_container_popup_create_view (popup);
}
gimp_container_popup_set_view_type (popup, view_type);
}
}
......
......@@ -2,7 +2,7 @@
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpcontainerpopup.h
* Copyright (C) 2003 Michael Natterer <mitch@gimp.org>
* Copyright (C) 2003-2005 Michael Natterer <mitch@gimp.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -82,5 +82,13 @@ GtkWidget * gimp_container_popup_new (GimpContainer *container,
void gimp_container_popup_show (GimpContainerPopup *popup,
GtkWidget *widget);
GimpViewType gimp_container_popup_get_view_type (GimpContainerPopup *popup);
void gimp_container_popup_set_view_type (GimpContainerPopup *popup,
GimpViewType view_type);
gint gimp_container_popup_get_preview_size (GimpContainerPopup *popup);
void gimp_container_popup_set_preview_size (GimpContainerPopup *popup,
gint preview_size);
#endif /* __GIMP_CONTAINER_POPUP_H__ */
......@@ -2,7 +2,7 @@
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpviewablebutton.c
* Copyright (C) 2003 Michael Natterer <mitch@gimp.org>
* Copyright (C) 2003-2005 Michael Natterer <mitch@gimp.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -40,10 +40,26 @@
#include "gimp-intl.h"
enum
{
PROP_0,
PROP_POPUP_VIEW_TYPE,
PROP_POPUP_PREVIEW_SIZE
};
static void gimp_viewable_button_class_init (GimpViewableButtonClass *klass);
static void gimp_viewable_button_init (GimpViewableButton *button);
static void gimp_viewable_button_destroy (GtkObject *object);
static void gimp_viewable_button_finalize (GObject *object);
static void gimp_viewable_button_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_viewable_button_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static gboolean gimp_viewable_button_scroll_event (GtkWidget *widget,
GdkEventScroll *sevent);
static void gimp_viewable_button_clicked (GtkButton *button);
......@@ -86,19 +102,34 @@ gimp_viewable_button_get_type (void)
static void
gimp_viewable_button_class_init (GimpViewableButtonClass *klass)
{
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
GtkButtonClass *button_class;
object_class = GTK_OBJECT_CLASS (klass);
widget_class = GTK_WIDGET_CLASS (klass);
button_class = GTK_BUTTON_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GtkButtonClass *button_class = GTK_BUTTON_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->destroy = gimp_viewable_button_destroy;
object_class->finalize = gimp_viewable_button_finalize;
object_class->get_property = gimp_viewable_button_get_property;
object_class->set_property = gimp_viewable_button_set_property;
widget_class->scroll_event = gimp_viewable_button_scroll_event;
button_class->clicked = gimp_viewable_button_clicked;
g_object_class_install_property (object_class, PROP_POPUP_VIEW_TYPE,
g_param_spec_enum ("popup-view-type",
NULL, NULL,
GIMP_TYPE_VIEW_TYPE,
GIMP_VIEW_TYPE_LIST,
G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_POPUP_PREVIEW_SIZE,
g_param_spec_int ("popup-preview-size",
NULL, NULL,
GIMP_VIEW_SIZE_TINY,
GIMP_VIEW_SIZE_GIGANTIC,
GIMP_VIEW_SIZE_SMALL,
G_PARAM_READWRITE));
}
static void
......@@ -112,7 +143,7 @@ gimp_viewable_button_init (GimpViewableButton *button)
}
static void
gimp_viewable_button_destroy (GtkObject *object)
gimp_viewable_button_finalize (GObject *object)
{
GimpViewableButton *button = GIMP_VIEWABLE_BUTTON (object);
......@@ -134,7 +165,51 @@ gimp_viewable_button_destroy (GtkObject *object)
button->dialog_tooltip = NULL;
}
GTK_OBJECT_CLASS (parent_class)->destroy (object);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gimp_viewable_button_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpViewableButton *button = GIMP_VIEWABLE_BUTTON (object);
switch (property_id)
{
case PROP_POPUP_VIEW_TYPE:
gimp_viewable_button_set_view_type (button, g_value_get_enum (value));
break;
case PROP_POPUP_PREVIEW_SIZE:
gimp_viewable_button_set_preview_size (button, g_value_get_int (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_viewable_button_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpViewableButton *button = GIMP_VIEWABLE_BUTTON (object);
switch (property_id)
{
case PROP_POPUP_VIEW_TYPE:
g_value_set_enum (value, button->popup_view_type);
break;
case PROP_POPUP_PREVIEW_SIZE:
g_value_set_int (value, button->popup_preview_size);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static gboolean
......@@ -218,8 +293,10 @@ static void
gimp_viewable_button_popup_closed (GimpContainerPopup *popup,
GimpViewableButton *button)
{
button->popup_view_type = popup->view_type;
button->popup_preview_size = popup->preview_size;
gimp_viewable_button_set_view_type (button,
gimp_container_popup_get_view_type (popup));
gimp_viewable_button_set_preview_size (button,
gimp_container_popup_get_preview_size (popup));
}
......@@ -281,11 +358,46 @@ gimp_viewable_button_new (GimpContainer *container,
return GTK_WIDGET (button);
}
GimpViewType
gimp_viewable_button_get_view_type (GimpViewableButton *button)
{
g_return_val_if_fail (GIMP_IS_VIEWABLE_BUTTON (button), GIMP_VIEW_TYPE_LIST);
return button->popup_view_type;
}
void
gimp_viewable_button_set_view_type (GimpViewableButton *button,
GimpViewType view_type)
{
g_return_if_fail (GIMP_IS_VIEWABLE_BUTTON (button));
button->popup_view_type = view_type;
if (view_type != button->popup_view_type)
{
button->popup_view_type = view_type;
g_object_notify (G_OBJECT (button), "popup-view-type");
}
}
gint
gimp_viewable_button_get_preview_size (GimpViewableButton *button)
{
g_return_val_if_fail (GIMP_IS_VIEWABLE_BUTTON (button), GIMP_VIEW_SIZE_SMALL);
return button->popup_preview_size;
}
void
gimp_viewable_button_set_preview_size (GimpViewableButton *button,
gint preview_size)
{
g_return_if_fail (GIMP_IS_VIEWABLE_BUTTON (button));
if (preview_size != button->popup_preview_size)
{
button->popup_preview_size = preview_size;
g_object_notify (G_OBJECT (button), "popup-preview-size");
}
}
......@@ -2,7 +2,7 @@
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpviewablebutton.h
* Copyright (C) 2003 Michael Natterer <mitch@gimp.org>
* Copyright (C) 2003-2005 Michael Natterer <mitch@gimp.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -73,8 +73,14 @@ GtkWidget * gimp_viewable_button_new (GimpContainer *container,
const gchar *dialog_identifier,
const gchar *dialog_stock_id,
const gchar *dialog_tooltip);
void gimp_viewable_button_set_view_type (GimpViewableButton *button,
GimpViewType view_type);
GimpViewType gimp_viewable_button_get_view_type (GimpViewableButton *button);
void gimp_viewable_button_set_view_type (GimpViewableButton *button,
GimpViewType view_type);
gint gimp_viewable_button_get_preview_size (GimpViewableButton *button);
void gimp_viewable_button_set_preview_size (GimpViewableButton *button,
gint preview_size);
G_END_DECLS
......
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