Commit a4b0297b authored by Martin Nordholts's avatar Martin Nordholts

New helper functions to lesser level of indirection in client code.

* app/widgets/gimpdatafactoryview.[ch]
(gimp_data_factory_view_have)
(gimp_data_factory_view_get_children_type)
(gimp_data_factory_view_has_data_new_func): New helper functions
to lesser level of indirection in client code.

* app/actions/data-commands.c: Use them.

svn path=/trunk/; revision=27814
parent 7f733cee
2008-12-20 Martin Nordholts <martinn@svn.gnome.org>
* app/widgets/gimpdatafactoryview.[ch]
(gimp_data_factory_view_have)
(gimp_data_factory_view_get_children_type)
(gimp_data_factory_view_has_data_new_func): New helper functions
to lesser level of indirection in client code.
* app/actions/data-commands.c: Use them.
2008-12-20 Martin Nordholts <martinn@svn.gnome.org>
* app/widgets/gimpdatafactoryview.[ch]: Make instance members
......
......@@ -82,7 +82,7 @@ data_open_as_image_cmd_callback (GtkAction *action,
data = (GimpData *)
gimp_context_get_by_type (context,
gimp_container_get_children_type (gimp_data_factory_get_container (gimp_data_factory_view_get_data_factory (view))));
gimp_data_factory_view_get_children_type (view));
if (data && data->filename)
{
......@@ -122,7 +122,7 @@ data_new_cmd_callback (GtkAction *action,
{
GimpDataFactoryView *view = GIMP_DATA_FACTORY_VIEW (user_data);
if (gimp_data_factory_has_data_new_func (gimp_data_factory_view_get_data_factory (view)))
if (gimp_data_factory_view_has_data_new_func (view))
{
GimpContext *context;
GimpData *data;
......@@ -135,7 +135,7 @@ data_new_cmd_callback (GtkAction *action,
if (data)
{
gimp_context_set_by_type (context,
gimp_container_get_children_type (gimp_data_factory_get_container (gimp_data_factory_view_get_data_factory (view))),
gimp_data_factory_view_get_children_type (view),
GIMP_OBJECT (data));
gtk_button_clicked (GTK_BUTTON (gimp_data_factory_view_get_edit_button (view)));
......@@ -155,10 +155,10 @@ data_duplicate_cmd_callback (GtkAction *action,
data = (GimpData *)
gimp_context_get_by_type (context,
gimp_container_get_children_type (gimp_data_factory_get_container (gimp_data_factory_view_get_data_factory (view))));
gimp_data_factory_view_get_children_type (view));
if (data && gimp_container_have (gimp_data_factory_get_container (gimp_data_factory_view_get_data_factory (view)),
GIMP_OBJECT (data)))
if (data && gimp_data_factory_view_have (view,
GIMP_OBJECT (data)))
{
GimpData *new_data;
......@@ -167,7 +167,7 @@ data_duplicate_cmd_callback (GtkAction *action,
if (new_data)
{
gimp_context_set_by_type (context,
gimp_container_get_children_type (gimp_data_factory_get_container (gimp_data_factory_view_get_data_factory (view))),
gimp_data_factory_view_get_children_type (view),
GIMP_OBJECT (new_data));
gtk_button_clicked (GTK_BUTTON (gimp_data_factory_view_get_edit_button (view)));
......@@ -187,7 +187,7 @@ data_copy_location_cmd_callback (GtkAction *action,
data = (GimpData *)
gimp_context_get_by_type (context,
gimp_container_get_children_type (gimp_data_factory_get_container (gimp_data_factory_view_get_data_factory (view))));
gimp_data_factory_view_get_children_type (view));
if (data && data->filename && *data->filename)
{
......@@ -214,10 +214,12 @@ data_delete_cmd_callback (GtkAction *action,
data = (GimpData *)
gimp_context_get_by_type (context,
gimp_container_get_children_type (gimp_data_factory_get_container (gimp_data_factory_view_get_data_factory (view))));
gimp_data_factory_view_get_children_type (view));
if (data && data->deletable && gimp_container_have (gimp_data_factory_get_container (gimp_data_factory_view_get_data_factory (view)),
GIMP_OBJECT (data)))
if (data &&
data->deletable &&
gimp_data_factory_view_have (view,
GIMP_OBJECT (data)))
{
GimpDataDeleteData *delete_data;
GtkWidget *dialog;
......@@ -288,10 +290,10 @@ data_edit_cmd_callback (GtkAction *action,
data = (GimpData *)
gimp_context_get_by_type (context,
gimp_container_get_children_type (gimp_data_factory_get_container (gimp_data_factory_view_get_data_factory (view))));
gimp_data_factory_view_get_children_type (view));
if (data && gimp_container_have (gimp_data_factory_get_container (gimp_data_factory_view_get_data_factory (view)),
GIMP_OBJECT (data)))
if (data && gimp_data_factory_view_have (view,
GIMP_OBJECT (data)))
{
GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (view));
GtkWidget *dockable;
......
......@@ -156,6 +156,32 @@ gimp_data_factory_view_get_data_factory (GimpDataFactoryView *factory_view)
return factory_view->priv->factory;
}
GType
gimp_data_factory_view_get_children_type (GimpDataFactoryView *factory_view)
{
g_return_val_if_fail (GIMP_IS_DATA_FACTORY_VIEW (factory_view), G_TYPE_NONE);
return gimp_container_get_children_type (gimp_data_factory_get_container (factory_view->priv->factory));
}
gboolean
gimp_data_factory_view_has_data_new_func (GimpDataFactoryView *factory_view)
{
g_return_val_if_fail (GIMP_IS_DATA_FACTORY_VIEW (factory_view), FALSE);
return gimp_data_factory_has_data_new_func (factory_view->priv->factory);
}
gboolean
gimp_data_factory_view_have (GimpDataFactoryView *factory_view,
GimpObject *object)
{
g_return_val_if_fail (GIMP_IS_DATA_FACTORY_VIEW (factory_view), FALSE);
return gimp_container_have (gimp_data_factory_get_container (factory_view->priv->factory),
object);
}
gboolean
gimp_data_factory_view_construct (GimpDataFactoryView *factory_view,
GimpViewType view_type,
......@@ -210,7 +236,7 @@ gimp_data_factory_view_construct (GimpDataFactoryView *factory_view,
str, NULL);
g_free (str);
if (gimp_data_factory_has_data_new_func (factory_view->priv->factory))
if (gimp_data_factory_view_has_data_new_func (factory_view))
{
str = g_strdup_printf ("%s-new", action_group);
factory_view->priv->new_button =
......@@ -262,8 +288,8 @@ gimp_data_factory_view_activate_item (GimpContainerEditor *editor,
if (GIMP_CONTAINER_EDITOR_CLASS (parent_class)->activate_item)
GIMP_CONTAINER_EDITOR_CLASS (parent_class)->activate_item (editor, viewable);
if (data && gimp_container_have (gimp_data_factory_get_container (view->priv->factory),
GIMP_OBJECT (data)))
if (data && gimp_data_factory_view_have (view,
GIMP_OBJECT (data)))
{
if (view->priv->edit_button && GTK_WIDGET_SENSITIVE (view->priv->edit_button))
gtk_button_clicked (GTK_BUTTON (view->priv->edit_button));
......
......@@ -65,6 +65,10 @@ GtkWidget * gimp_data_factory_view_new (GimpViewType
GtkWidget * gimp_data_factory_view_get_edit_button (GimpDataFactoryView *factory_view);
GtkWidget * gimp_data_factory_view_get_duplicate_button (GimpDataFactoryView *factory_view);
GimpDataFactory * gimp_data_factory_view_get_data_factory (GimpDataFactoryView *factory_view);
GType gimp_data_factory_view_get_children_type (GimpDataFactoryView *factory_view);
gboolean gimp_data_factory_view_has_data_new_func (GimpDataFactoryView *factory_view);
gboolean gimp_data_factory_view_have (GimpDataFactoryView *factory_view,
GimpObject *object);
/* protected */
......
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