Commit 7f733cee authored by Martin Nordholts's avatar Martin Nordholts

Make instance members private and add getters for accessed members.

* app/widgets/gimpdatafactoryview.[ch]: Make instance members
private and add getters for accessed members.

(gimp_data_factory_view_get_edit_button)
(gimp_data_factory_view_get_duplicate_button)
(gimp_data_factory_view_get_data_factory): New getters.

* app/actions/data-commands.c
* app/widgets/gimppatternfactoryview.c: Use new getters.

svn path=/trunk/; revision=27813
parent 4981816c
2008-12-20 Martin Nordholts <martinn@svn.gnome.org>
* app/widgets/gimpdatafactoryview.[ch]: Make instance members
private and add getters for accessed members.
(gimp_data_factory_view_get_edit_button)
(gimp_data_factory_view_get_duplicate_button)
(gimp_data_factory_view_get_data_factory): New getters.
* app/actions/data-commands.c
* app/widgets/gimppatternfactoryview.c: Use new getters.
2008-12-19 Martin Nordholts <martinn@svn.gnome.org>
* app/core/gimpdatafactory.[ch]: Make instance members private and
......
......@@ -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 (view->factory)));
gimp_container_get_children_type (gimp_data_factory_get_container (gimp_data_factory_view_get_data_factory (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 (view->factory))
if (gimp_data_factory_has_data_new_func (gimp_data_factory_view_get_data_factory (view)))
{
GimpContext *context;
GimpData *data;
......@@ -130,15 +130,15 @@ data_new_cmd_callback (GtkAction *action,
context =
gimp_container_view_get_context (GIMP_CONTAINER_EDITOR (view)->view);
data = gimp_data_factory_data_new (view->factory, _("Untitled"));
data = gimp_data_factory_data_new (gimp_data_factory_view_get_data_factory (view), _("Untitled"));
if (data)
{
gimp_context_set_by_type (context,
gimp_container_get_children_type (gimp_data_factory_get_container (view->factory)),
gimp_container_get_children_type (gimp_data_factory_get_container (gimp_data_factory_view_get_data_factory (view))),
GIMP_OBJECT (data));
gtk_button_clicked (GTK_BUTTON (view->edit_button));
gtk_button_clicked (GTK_BUTTON (gimp_data_factory_view_get_edit_button (view)));
}
}
}
......@@ -155,22 +155,22 @@ data_duplicate_cmd_callback (GtkAction *action,
data = (GimpData *)
gimp_context_get_by_type (context,
gimp_container_get_children_type (gimp_data_factory_get_container (view->factory)));
gimp_container_get_children_type (gimp_data_factory_get_container (gimp_data_factory_view_get_data_factory (view))));
if (data && gimp_container_have (gimp_data_factory_get_container (view->factory),
if (data && gimp_container_have (gimp_data_factory_get_container (gimp_data_factory_view_get_data_factory (view)),
GIMP_OBJECT (data)))
{
GimpData *new_data;
new_data = gimp_data_factory_data_duplicate (view->factory, data);
new_data = gimp_data_factory_data_duplicate (gimp_data_factory_view_get_data_factory (view), data);
if (new_data)
{
gimp_context_set_by_type (context,
gimp_container_get_children_type (gimp_data_factory_get_container (view->factory)),
gimp_container_get_children_type (gimp_data_factory_get_container (gimp_data_factory_view_get_data_factory (view))),
GIMP_OBJECT (new_data));
gtk_button_clicked (GTK_BUTTON (view->edit_button));
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 (view->factory)));
gimp_container_get_children_type (gimp_data_factory_get_container (gimp_data_factory_view_get_data_factory (view))));
if (data && data->filename && *data->filename)
{
......@@ -214,9 +214,9 @@ data_delete_cmd_callback (GtkAction *action,
data = (GimpData *)
gimp_context_get_by_type (context,
gimp_container_get_children_type (gimp_data_factory_get_container (view->factory)));
gimp_container_get_children_type (gimp_data_factory_get_container (gimp_data_factory_view_get_data_factory (view))));
if (data && data->deletable && gimp_container_have (gimp_data_factory_get_container (view->factory),
if (data && data->deletable && gimp_container_have (gimp_data_factory_get_container (gimp_data_factory_view_get_data_factory (view)),
GIMP_OBJECT (data)))
{
GimpDataDeleteData *delete_data;
......@@ -271,7 +271,7 @@ data_refresh_cmd_callback (GtkAction *action,
return_if_no_gimp (gimp, user_data);
gimp_set_busy (gimp);
gimp_data_factory_data_refresh (view->factory);
gimp_data_factory_data_refresh (gimp_data_factory_view_get_data_factory (view));
gimp_unset_busy (gimp);
}
......@@ -288,9 +288,9 @@ data_edit_cmd_callback (GtkAction *action,
data = (GimpData *)
gimp_context_get_by_type (context,
gimp_container_get_children_type (gimp_data_factory_get_container (view->factory)));
gimp_container_get_children_type (gimp_data_factory_get_container (gimp_data_factory_view_get_data_factory (view))));
if (data && gimp_container_have (gimp_data_factory_get_container (view->factory),
if (data && gimp_container_have (gimp_data_factory_get_container (gimp_data_factory_view_get_data_factory (view)),
GIMP_OBJECT (data)))
{
GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (view));
......@@ -316,7 +316,7 @@ data_delete_confirm_response (GtkWidget *dialog,
if (response_id == GTK_RESPONSE_OK)
{
GimpDataFactory *factory = delete_data->view->factory;
GimpDataFactory *factory = gimp_data_factory_view_get_data_factory (delete_data->view);
GimpData *data = delete_data->data;
GimpObject *new_active;
GError *error = NULL;
......
......@@ -50,6 +50,18 @@
#include "gimp-intl.h"
struct _GimpDataFactoryViewPriv
{
GimpDataFactory *factory;
GtkWidget *edit_button;
GtkWidget *new_button;
GtkWidget *duplicate_button;
GtkWidget *delete_button;
GtkWidget *refresh_button;
};
static void gimp_data_factory_view_activate_item (GimpContainerEditor *editor,
GimpViewable *viewable);
static void gimp_data_factory_view_tree_name_edited (GtkCellRendererText *cell,
......@@ -70,16 +82,21 @@ gimp_data_factory_view_class_init (GimpDataFactoryViewClass *klass)
GimpContainerEditorClass *editor_class = GIMP_CONTAINER_EDITOR_CLASS (klass);
editor_class->activate_item = gimp_data_factory_view_activate_item;
g_type_class_add_private (klass, sizeof (GimpDataFactoryViewPriv));
}
static void
gimp_data_factory_view_init (GimpDataFactoryView *view)
{
view->edit_button = NULL;
view->new_button = NULL;
view->duplicate_button = NULL;
view->delete_button = NULL;
view->refresh_button = NULL;
view->priv = G_TYPE_INSTANCE_GET_PRIVATE (view,
GIMP_TYPE_DATA_FACTORY_VIEW,
GimpDataFactoryViewPriv);
view->priv->edit_button = NULL;
view->priv->new_button = NULL;
view->priv->duplicate_button = NULL;
view->priv->delete_button = NULL;
view->priv->refresh_button = NULL;
}
GtkWidget *
......@@ -115,6 +132,30 @@ gimp_data_factory_view_new (GimpViewType view_type,
return GTK_WIDGET (factory_view);
}
GtkWidget *
gimp_data_factory_view_get_edit_button (GimpDataFactoryView *factory_view)
{
g_return_val_if_fail (GIMP_IS_DATA_FACTORY_VIEW (factory_view), NULL);
return factory_view->priv->edit_button;
}
GtkWidget *
gimp_data_factory_view_get_duplicate_button (GimpDataFactoryView *factory_view)
{
g_return_val_if_fail (GIMP_IS_DATA_FACTORY_VIEW (factory_view), NULL);
return factory_view->priv->duplicate_button;
}
GimpDataFactory *
gimp_data_factory_view_get_data_factory (GimpDataFactoryView *factory_view)
{
g_return_val_if_fail (GIMP_IS_DATA_FACTORY_VIEW (factory_view), NULL);
return factory_view->priv->factory;
}
gboolean
gimp_data_factory_view_construct (GimpDataFactoryView *factory_view,
GimpViewType view_type,
......@@ -138,7 +179,7 @@ gimp_data_factory_view_construct (GimpDataFactoryView *factory_view,
view_border_width <= GIMP_VIEW_MAX_BORDER_WIDTH,
FALSE);
factory_view->factory = factory;
factory_view->priv->factory = factory;
if (! gimp_container_editor_construct (GIMP_CONTAINER_EDITOR (factory_view),
view_type,
......@@ -164,46 +205,46 @@ gimp_data_factory_view_construct (GimpDataFactoryView *factory_view,
}
str = g_strdup_printf ("%s-edit", action_group);
factory_view->edit_button =
factory_view->priv->edit_button =
gimp_editor_add_action_button (GIMP_EDITOR (editor->view), action_group,
str, NULL);
g_free (str);
if (gimp_data_factory_has_data_new_func (factory_view->factory))
if (gimp_data_factory_has_data_new_func (factory_view->priv->factory))
{
str = g_strdup_printf ("%s-new", action_group);
factory_view->new_button =
factory_view->priv->new_button =
gimp_editor_add_action_button (GIMP_EDITOR (editor->view), action_group,
str, NULL);
g_free (str);
}
str = g_strdup_printf ("%s-duplicate", action_group);
factory_view->duplicate_button =
factory_view->priv->duplicate_button =
gimp_editor_add_action_button (GIMP_EDITOR (editor->view), action_group,
str, NULL);
g_free (str);
str = g_strdup_printf ("%s-delete", action_group);
factory_view->delete_button =
factory_view->priv->delete_button =
gimp_editor_add_action_button (GIMP_EDITOR (editor->view), action_group,
str, NULL);
g_free (str);
str = g_strdup_printf ("%s-refresh", action_group);
factory_view->refresh_button =
factory_view->priv->refresh_button =
gimp_editor_add_action_button (GIMP_EDITOR (editor->view), action_group,
str, NULL);
g_free (str);
gimp_container_view_enable_dnd (editor->view,
GTK_BUTTON (factory_view->edit_button),
GTK_BUTTON (factory_view->priv->edit_button),
gimp_container_get_children_type (gimp_data_factory_get_container (factory)));
gimp_container_view_enable_dnd (editor->view,
GTK_BUTTON (factory_view->duplicate_button),
GTK_BUTTON (factory_view->priv->duplicate_button),
gimp_container_get_children_type (gimp_data_factory_get_container (factory)));
gimp_container_view_enable_dnd (editor->view,
GTK_BUTTON (factory_view->delete_button),
GTK_BUTTON (factory_view->priv->delete_button),
gimp_container_get_children_type (gimp_data_factory_get_container (factory)));
gimp_ui_manager_update (GIMP_EDITOR (editor->view)->ui_manager, editor);
......@@ -221,11 +262,11 @@ 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->factory),
if (data && gimp_container_have (gimp_data_factory_get_container (view->priv->factory),
GIMP_OBJECT (data)))
{
if (view->edit_button && GTK_WIDGET_SENSITIVE (view->edit_button))
gtk_button_clicked (GTK_BUTTON (view->edit_button));
if (view->priv->edit_button && GTK_WIDGET_SENSITIVE (view->priv->edit_button))
gtk_button_clicked (GTK_BUTTON (view->priv->edit_button));
}
}
......
......@@ -35,18 +35,13 @@
typedef struct _GimpDataFactoryViewClass GimpDataFactoryViewClass;
typedef struct _GimpDataFactoryViewPriv GimpDataFactoryViewPriv;
struct _GimpDataFactoryView
{
GimpContainerEditor parent_instance;
GimpContainerEditor parent_instance;
GimpDataFactory *factory;
GtkWidget *edit_button;
GtkWidget *new_button;
GtkWidget *duplicate_button;
GtkWidget *delete_button;
GtkWidget *refresh_button;
GimpDataFactoryViewPriv *priv;
};
struct _GimpDataFactoryViewClass
......@@ -55,31 +50,35 @@ struct _GimpDataFactoryViewClass
};
GType gimp_data_factory_view_get_type (void) G_GNUC_CONST;
GType gimp_data_factory_view_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_data_factory_view_new (GimpViewType view_type,
GimpDataFactory *factory,
GimpContext *context,
gint view_size,
gint view_border_width,
GimpMenuFactory *menu_factory,
const gchar *menu_identifier,
const gchar *ui_identifier,
const gchar *action_group);
GtkWidget * gimp_data_factory_view_new (GimpViewType view_type,
GimpDataFactory *factory,
GimpContext *context,
gint view_size,
gint view_border_width,
GimpMenuFactory *menu_factory,
const gchar *menu_identifier,
const gchar *ui_identifier,
const gchar *action_group);
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);
/* protected */
gboolean gimp_data_factory_view_construct (GimpDataFactoryView *factory_view,
GimpViewType view_type,
GimpDataFactory *factory,
GimpContext *context,
gint view_size,
gint view_border_width,
GimpMenuFactory *menu_factory,
const gchar *menu_identifier,
const gchar *ui_identifier,
const gchar *action_group);
gboolean gimp_data_factory_view_construct (GimpDataFactoryView *factory_view,
GimpViewType view_type,
GimpDataFactory *factory,
GimpContext *context,
gint view_size,
gint view_border_width,
GimpMenuFactory *menu_factory,
const gchar *menu_identifier,
const gchar *ui_identifier,
const gchar *action_group);
#endif /* __GIMP_DATA_FACTORY_VIEW_H__ */
......@@ -90,8 +90,8 @@ gimp_pattern_factory_view_new (GimpViewType view_type,
"patterns", "patterns-open-as-image",
NULL);
gtk_widget_hide (GIMP_DATA_FACTORY_VIEW (factory_view)->edit_button);
gtk_widget_hide (GIMP_DATA_FACTORY_VIEW (factory_view)->duplicate_button);
gtk_widget_hide (gimp_data_factory_view_get_edit_button (GIMP_DATA_FACTORY_VIEW (factory_view)));
gtk_widget_hide (gimp_data_factory_view_get_duplicate_button (GIMP_DATA_FACTORY_VIEW (factory_view)));
return GTK_WIDGET (factory_view);
}
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