app: add view-size and view-border-width props to GimpContainerEditor

and remove them from the various public construct() functions.
This commit is contained in:
Michael Natterer 2011-10-09 21:04:49 +02:00
parent bef55fbb66
commit 5f3b3dafb9
14 changed files with 135 additions and 72 deletions

View File

@ -132,15 +132,16 @@ gimp_brush_factory_view_new (GimpViewType view_type,
NULL);
factory_view = g_object_new (GIMP_TYPE_BRUSH_FACTORY_VIEW,
"view-type", view_type,
"data-factory", factory,
"context", context,
"view-type", view_type,
"data-factory", factory,
"context", context,
"view-size", view_size,
"view-border-width", view_border_width,
NULL);
factory_view->change_brush_spacing = change_brush_spacing;
if (! gimp_data_factory_view_construct (GIMP_DATA_FACTORY_VIEW (factory_view),
view_size, view_border_width,
menu_factory, "<Brushes>",
"/brushes-popup",
"brushes"))

View File

@ -127,14 +127,23 @@ gimp_buffer_view_new (GimpViewType view_type,
GtkWidget *frame;
GtkWidget *hbox;
g_return_val_if_fail (GIMP_IS_CONTAINER (container), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (view_size > 0 &&
view_size <= GIMP_VIEWABLE_MAX_PREVIEW_SIZE, FALSE);
g_return_val_if_fail (view_border_width >= 0 &&
view_border_width <= GIMP_VIEW_MAX_BORDER_WIDTH,
FALSE);
buffer_view = g_object_new (GIMP_TYPE_BUFFER_VIEW,
"view-type", view_type,
"container", container,
"context", context,
"view-type", view_type,
"container", container,
"context", context,
"view-size", view_size,
"view-border-width", view_border_width,
NULL);
if (! gimp_container_editor_construct (GIMP_CONTAINER_EDITOR (buffer_view),
view_size, view_border_width,
menu_factory, "<Buffers>",
"/buffers-popup"))
{

View File

@ -46,7 +46,9 @@ enum
PROP_0,
PROP_VIEW_TYPE,
PROP_CONTAINER,
PROP_CONTEXT
PROP_CONTEXT,
PROP_VIEW_SIZE,
PROP_VIEW_BORDER_WIDTH
};
@ -55,6 +57,8 @@ struct _GimpContainerEditorPrivate
GimpViewType view_type;
GimpContainer *container;
GimpContext *context;
gint view_size;
gint view_border_width;
};
@ -145,6 +149,23 @@ gimp_container_editor_class_init (GimpContainerEditorClass *klass)
GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class, PROP_VIEW_SIZE,
g_param_spec_int ("view-size",
NULL, NULL,
1, GIMP_VIEWABLE_MAX_PREVIEW_SIZE,
GIMP_VIEW_SIZE_MEDIUM,
GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class, PROP_VIEW_BORDER_WIDTH,
g_param_spec_int ("view-border-width",
NULL, NULL,
0,
GIMP_VIEW_MAX_BORDER_WIDTH,
1,
GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
g_type_class_add_private (klass, sizeof (GimpContainerEditorPrivate));
}
@ -224,6 +245,14 @@ gimp_container_editor_set_property (GObject *object,
editor->priv->context = g_value_dup_object (value);
break;
case PROP_VIEW_SIZE:
editor->priv->view_size = g_value_get_int (value);
break;
case PROP_VIEW_BORDER_WIDTH:
editor->priv->view_border_width = g_value_get_int (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@ -252,6 +281,14 @@ gimp_container_editor_get_property (GObject *object,
g_value_set_object (value, editor->priv->context);
break;
case PROP_VIEW_SIZE:
g_value_set_int (value, editor->priv->view_size);
break;
case PROP_VIEW_BORDER_WIDTH:
g_value_set_int (value, editor->priv->view_border_width);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@ -260,18 +297,11 @@ gimp_container_editor_get_property (GObject *object,
gboolean
gimp_container_editor_construct (GimpContainerEditor *editor,
gint view_size,
gint view_border_width,
GimpMenuFactory *menu_factory,
const gchar *menu_identifier,
const gchar *ui_identifier)
{
g_return_val_if_fail (GIMP_IS_CONTAINER_EDITOR (editor), FALSE);
g_return_val_if_fail (view_size > 0 &&
view_size <= GIMP_VIEWABLE_MAX_PREVIEW_SIZE, FALSE);
g_return_val_if_fail (view_border_width >= 0 &&
view_border_width <= GIMP_VIEW_MAX_BORDER_WIDTH,
FALSE);
g_return_val_if_fail (menu_factory == NULL ||
GIMP_IS_MENU_FACTORY (menu_factory), FALSE);
@ -282,14 +312,14 @@ gimp_container_editor_construct (GimpContainerEditor *editor,
editor->view =
GIMP_CONTAINER_VIEW (gimp_container_icon_view_new (editor->priv->container,
editor->priv->context,
view_size,
view_border_width));
editor->priv->view_size,
editor->priv->view_border_width));
#else
editor->view =
GIMP_CONTAINER_VIEW (gimp_container_grid_view_new (editor->priv->container,
editor->priv->context,
view_size,
view_border_width));
editor->priv->view_size,
editor->priv->view_border_width));
#endif
break;
@ -297,8 +327,8 @@ gimp_container_editor_construct (GimpContainerEditor *editor,
editor->view =
GIMP_CONTAINER_VIEW (gimp_container_tree_view_new (editor->priv->container,
editor->priv->context,
view_size,
view_border_width));
editor->priv->view_size,
editor->priv->view_border_width));
break;
default:

View File

@ -65,8 +65,6 @@ void gimp_container_editor_set_selection_mode (GimpContainerEditor *
/* protected */
gboolean gimp_container_editor_construct (GimpContainerEditor *editor,
gint view_size,
gint view_border_width,
GimpMenuFactory *menu_factory,
const gchar *menu_identifier,
const gchar *ui_path);

View File

@ -550,14 +550,14 @@ gimp_container_popup_create_view (GimpContainerPopup *popup)
GtkWidget *button;
popup->editor = g_object_new (GIMP_TYPE_CONTAINER_EDITOR,
"view-type", popup->view_type,
"container", popup->container,
"context", popup->context,
"view-type", popup->view_type,
"container", popup->container,
"context", popup->context,
"view-size", popup->view_size,
"view-border-width", popup->view_border_width,
NULL);
gimp_container_editor_construct (popup->editor,
popup->view_size,
popup->view_border_width,
NULL, NULL, NULL);
gimp_container_view_set_reorderable (GIMP_CONTAINER_VIEW (popup->editor->view),

View File

@ -253,16 +253,21 @@ gimp_data_factory_view_new (GimpViewType view_type,
g_return_val_if_fail (GIMP_IS_DATA_FACTORY (factory), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (view_size > 0 &&
view_size <= GIMP_VIEWABLE_MAX_PREVIEW_SIZE, NULL);
g_return_val_if_fail (view_border_width >= 0 &&
view_border_width <= GIMP_VIEW_MAX_BORDER_WIDTH,
NULL);
factory_view = g_object_new (GIMP_TYPE_DATA_FACTORY_VIEW,
"view-type", view_type,
"data-factory", factory,
"context", context,
"view-type", view_type,
"data-factory", factory,
"context", context,
"view-size", view_size,
"view-border-width", view_border_width,
NULL);
if (! gimp_data_factory_view_construct (factory_view,
view_size,
view_border_width,
menu_factory,
menu_identifier,
ui_identifier,
@ -327,8 +332,6 @@ gimp_data_factory_view_have (GimpDataFactoryView *factory_view,
gboolean
gimp_data_factory_view_construct (GimpDataFactoryView *factory_view,
gint view_size,
gint view_border_width,
GimpMenuFactory *menu_factory,
const gchar *menu_identifier,
const gchar *ui_identifier,
@ -338,14 +341,8 @@ gimp_data_factory_view_construct (GimpDataFactoryView *factory_view,
gchar *str;
g_return_val_if_fail (GIMP_IS_DATA_FACTORY_VIEW (factory_view), FALSE);
g_return_val_if_fail (view_size > 0 &&
view_size <= GIMP_VIEWABLE_MAX_PREVIEW_SIZE, FALSE);
g_return_val_if_fail (view_border_width >= 0 &&
view_border_width <= GIMP_VIEW_MAX_BORDER_WIDTH,
FALSE);
if (! gimp_container_editor_construct (GIMP_CONTAINER_EDITOR (factory_view),
view_size, view_border_width,
menu_factory, menu_identifier,
ui_identifier))
{

View File

@ -73,8 +73,6 @@ gboolean gimp_data_factory_view_have (GimpDataFactoryVi
/* protected */
gboolean gimp_data_factory_view_construct (GimpDataFactoryView *factory_view,
gint view_size,
gint view_border_width,
GimpMenuFactory *menu_factory,
const gchar *menu_identifier,
const gchar *ui_identifier,

View File

@ -36,6 +36,7 @@
#include "gimpdnd.h"
#include "gimpeditor.h"
#include "gimpuimanager.h"
#include "gimpviewrenderer.h"
#include "gimpwidgets-utils.h"
#include "gimp-intl.h"
@ -82,15 +83,21 @@ gimp_document_view_new (GimpViewType view_type,
g_return_val_if_fail (GIMP_IS_CONTAINER (container), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (view_size > 0 &&
view_size <= GIMP_VIEWABLE_MAX_PREVIEW_SIZE, FALSE);
g_return_val_if_fail (view_border_width >= 0 &&
view_border_width <= GIMP_VIEW_MAX_BORDER_WIDTH,
FALSE);
document_view = g_object_new (GIMP_TYPE_DOCUMENT_VIEW,
"view-type", view_type,
"container", container,
"context", context,
"view-type", view_type,
"container", container,
"context", context,
"view-size", view_size,
"view-border-width", view_border_width,
NULL);
if (! gimp_container_editor_construct (GIMP_CONTAINER_EDITOR (document_view),
view_size, view_border_width,
menu_factory, "<Documents>",
"/documents-popup"))
{

View File

@ -66,13 +66,14 @@ gimp_dynamics_factory_view_new (GimpViewType view_type,
NULL);
factory_view = g_object_new (GIMP_TYPE_DYNAMICS_FACTORY_VIEW,
"view-type", view_type,
"data-factory", factory,
"context", context,
"view-type", view_type,
"data-factory", factory,
"context", context,
"view-size", view_size,
"view-border-width", view_border_width,
NULL);
if (! gimp_data_factory_view_construct (GIMP_DATA_FACTORY_VIEW (factory_view),
view_size, view_border_width,
menu_factory, "<Dynamics>",
"/dynamics-popup",
"dynamics"))

View File

@ -34,6 +34,7 @@
#include "gimpfontview.h"
#include "gimphelp-ids.h"
#include "gimpuimanager.h"
#include "gimpviewrenderer.h"
#include "gimp-intl.h"
@ -74,15 +75,21 @@ gimp_font_view_new (GimpViewType view_type,
g_return_val_if_fail (GIMP_IS_CONTAINER (container), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (view_size > 0 &&
view_size <= GIMP_VIEWABLE_MAX_PREVIEW_SIZE, NULL);
g_return_val_if_fail (view_border_width >= 0 &&
view_border_width <= GIMP_VIEW_MAX_BORDER_WIDTH,
NULL);
font_view = g_object_new (GIMP_TYPE_FONT_VIEW,
"view-type", view_type,
"container", container,
"context", context,
"view-type", view_type,
"container", container,
"context", context,
"view-size", view_size,
"view-border-width", view_border_width,
NULL);
if (! gimp_container_editor_construct (GIMP_CONTAINER_EDITOR (font_view),
view_size, view_border_width,
menu_factory, "<Fonts>",
"/fonts-popup"))
{

View File

@ -36,6 +36,7 @@
#include "gimpimageview.h"
#include "gimpdnd.h"
#include "gimpuimanager.h"
#include "gimpviewrenderer.h"
#include "gimp-intl.h"
@ -78,15 +79,21 @@ gimp_image_view_new (GimpViewType view_type,
g_return_val_if_fail (GIMP_IS_CONTAINER (container), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (view_size > 0 &&
view_size <= GIMP_VIEWABLE_MAX_PREVIEW_SIZE, NULL);
g_return_val_if_fail (view_border_width >= 0 &&
view_border_width <= GIMP_VIEW_MAX_BORDER_WIDTH,
NULL);
image_view = g_object_new (GIMP_TYPE_IMAGE_VIEW,
"view-type", view_type,
"container", container,
"context", context,
"view-type", view_type,
"container", container,
"context", context,
"view-size", view_size,
"view-border-width", view_border_width,
NULL);
if (! gimp_container_editor_construct (GIMP_CONTAINER_EDITOR (image_view),
view_size, view_border_width,
menu_factory, "<Images>",
"/images-popup"))
{

View File

@ -69,13 +69,14 @@ gimp_pattern_factory_view_new (GimpViewType view_type,
NULL);
factory_view = g_object_new (GIMP_TYPE_PATTERN_FACTORY_VIEW,
"view-type", view_type,
"data-factory", factory,
"context", context,
"view-type", view_type,
"data-factory", factory,
"context", context,
"view-size", view_size,
"view-border-width", view_border_width,
NULL);
if (! gimp_data_factory_view_construct (GIMP_DATA_FACTORY_VIEW (factory_view),
view_size, view_border_width,
menu_factory, "<Patterns>",
"/patterns-popup",
"patterns"))

View File

@ -93,15 +93,21 @@ gimp_template_view_new (GimpViewType view_type,
g_return_val_if_fail (GIMP_IS_CONTAINER (container), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (view_size > 0 &&
view_size <= GIMP_VIEWABLE_MAX_PREVIEW_SIZE, NULL);
g_return_val_if_fail (view_border_width >= 0 &&
view_border_width <= GIMP_VIEW_MAX_BORDER_WIDTH,
NULL);
template_view = g_object_new (GIMP_TYPE_TEMPLATE_VIEW,
"view-type", view_type,
"container", container,
"context", context,
"view-type", view_type,
"container", container,
"context", context,
"view-size", view_size,
"view-border-width", view_border_width,
NULL);
if (! gimp_container_editor_construct (GIMP_CONTAINER_EDITOR (template_view),
view_size, view_border_width,
menu_factory, "<Templates>",
"/templates-popup"))
{

View File

@ -68,13 +68,14 @@ gimp_tool_preset_factory_view_new (GimpViewType view_type,
NULL);
factory_view = g_object_new (GIMP_TYPE_TOOL_PRESET_FACTORY_VIEW,
"view-type", view_type,
"data-factory", factory,
"context", context,
"view-type", view_type,
"data-factory", factory,
"context", context,
"view-size", view_size,
"view-border-width", view_border_width,
NULL);
if (! gimp_data_factory_view_construct (GIMP_DATA_FACTORY_VIEW (factory_view),
view_size, view_border_width,
menu_factory, "<ToolPreset>",
"/tool-preset-popup",
"tool-preset"))