[gimp/soc-2010-cage-2] app: some toolbox cleanup
- From: Michael Muré <mmure src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/soc-2010-cage-2] app: some toolbox cleanup
- Date: Thu, 30 Dec 2010 18:11:31 +0000 (UTC)
commit 3fc58a447bdb632a27f66430ee262448dde7f4e0
Author: Michael Natterer <mitch gimp org>
Date: Sat Nov 20 15:18:09 2010 +0100
app: some toolbox cleanup
Add precondition checks and assertions for needed members and remove
unused API.
app/widgets/gimptoolbox-dnd.c | 22 +++++++++++---------
app/widgets/gimptoolbox-dnd.h | 3 +-
app/widgets/gimptoolbox.c | 44 +++++++++++++++-------------------------
app/widgets/gimptoolbox.h | 6 +---
app/widgets/gimptoolpalette.c | 8 +++++++
5 files changed, 41 insertions(+), 42 deletions(-)
---
diff --git a/app/widgets/gimptoolbox-dnd.c b/app/widgets/gimptoolbox-dnd.c
index 3a1be5a..dcc3d92 100644
--- a/app/widgets/gimptoolbox-dnd.c
+++ b/app/widgets/gimptoolbox-dnd.c
@@ -84,11 +84,13 @@ static void gimp_toolbox_drop_pixbuf (GtkWidget *widget,
/* public functions */
void
-gimp_toolbox_dnd_init (GimpToolbox *toolbox)
+gimp_toolbox_dnd_init (GimpToolbox *toolbox,
+ GtkWidget *vbox)
{
GimpContext *context = NULL;
g_return_if_fail (GIMP_IS_TOOLBOX (toolbox));
+ g_return_if_fail (GTK_IS_BOX (vbox));
context = gimp_toolbox_get_context (toolbox);
@@ -107,39 +109,39 @@ gimp_toolbox_dnd_init (GimpToolbox *toolbox)
* manually, otherwise we would not be able to give the drag handler
* a chance to handle drag events
*/
- gtk_drag_dest_set (gimp_toolbox_get_vbox (toolbox),
+ gtk_drag_dest_set (vbox,
0, NULL, 0,
GDK_ACTION_COPY | GDK_ACTION_MOVE);
- gimp_dnd_uri_list_dest_add (gimp_toolbox_get_vbox (toolbox),
+ gimp_dnd_uri_list_dest_add (vbox,
gimp_toolbox_drop_uri_list,
context);
- gimp_dnd_viewable_dest_add (gimp_toolbox_get_vbox (toolbox),
+ gimp_dnd_viewable_dest_add (vbox,
GIMP_TYPE_LAYER,
gimp_toolbox_drop_drawable,
context);
- gimp_dnd_viewable_dest_add (gimp_toolbox_get_vbox (toolbox),
+ gimp_dnd_viewable_dest_add (vbox,
GIMP_TYPE_LAYER_MASK,
gimp_toolbox_drop_drawable,
context);
- gimp_dnd_viewable_dest_add (gimp_toolbox_get_vbox (toolbox),
+ gimp_dnd_viewable_dest_add (vbox,
GIMP_TYPE_CHANNEL,
gimp_toolbox_drop_drawable,
context);
- gimp_dnd_viewable_dest_add (gimp_toolbox_get_vbox (toolbox),
+ gimp_dnd_viewable_dest_add (vbox,
GIMP_TYPE_TOOL_INFO,
gimp_toolbox_drop_tool,
context);
- gimp_dnd_viewable_dest_add (gimp_toolbox_get_vbox (toolbox),
+ gimp_dnd_viewable_dest_add (vbox,
GIMP_TYPE_BUFFER,
gimp_toolbox_drop_buffer,
context);
- gimp_dnd_component_dest_add (gimp_toolbox_get_vbox (toolbox),
+ gimp_dnd_component_dest_add (vbox,
gimp_toolbox_drop_component,
context);
- gimp_dnd_pixbuf_dest_add (gimp_toolbox_get_vbox (toolbox),
+ gimp_dnd_pixbuf_dest_add (vbox,
gimp_toolbox_drop_pixbuf,
context);
}
diff --git a/app/widgets/gimptoolbox-dnd.h b/app/widgets/gimptoolbox-dnd.h
index fd14b23..49b8f24 100644
--- a/app/widgets/gimptoolbox-dnd.h
+++ b/app/widgets/gimptoolbox-dnd.h
@@ -19,7 +19,8 @@
#define __GIMP_TOOLBOX_DND_H__
-void gimp_toolbox_dnd_init (GimpToolbox *toolbox);
+void gimp_toolbox_dnd_init (GimpToolbox *toolbox,
+ GtkWidget *vbox);
#endif /* __GIMP_TOOLBOX_DND_H__ */
diff --git a/app/widgets/gimptoolbox.c b/app/widgets/gimptoolbox.c
index 9d7abba..d00b5d4 100644
--- a/app/widgets/gimptoolbox.c
+++ b/app/widgets/gimptoolbox.c
@@ -222,6 +222,10 @@ gimp_toolbox_constructed (GObject *object)
GdkDisplay *display;
GList *list;
+ g_assert (GIMP_IS_CONTEXT (toolbox->p->context));
+ g_assert (GIMP_IS_UI_MANAGER (toolbox->p->ui_manager));
+ g_assert (GIMP_IS_DIALOG_FACTORY (toolbox->p->dialog_factory));
+
config = GIMP_GUI_CONFIG (toolbox->p->context->gimp->config);
main_vbox = gimp_dock_get_main_vbox (GIMP_DOCK (toolbox));
@@ -313,7 +317,8 @@ gimp_toolbox_constructed (GObject *object)
GDK_EXTENSION_EVENTS_CURSOR);
}
- toolbox->p->color_area = toolbox_create_color_area (toolbox, toolbox->p->context);
+ toolbox->p->color_area = toolbox_create_color_area (toolbox,
+ toolbox->p->context);
gtk_wrap_box_pack_wrapped (GTK_WRAP_BOX (toolbox->p->area_wbox),
toolbox->p->color_area,
TRUE, TRUE, FALSE, TRUE, TRUE);
@@ -334,7 +339,8 @@ gimp_toolbox_constructed (GObject *object)
G_CALLBACK (toolbox_area_notify),
toolbox->p->foo_area, 0);
- toolbox->p->image_area = toolbox_create_image_area (toolbox, toolbox->p->context);
+ toolbox->p->image_area = toolbox_create_image_area (toolbox,
+ toolbox->p->context);
gtk_wrap_box_pack (GTK_WRAP_BOX (toolbox->p->area_wbox), toolbox->p->image_area,
TRUE, TRUE, FALSE, TRUE);
if (config->toolbox_image_area)
@@ -344,7 +350,7 @@ gimp_toolbox_constructed (GObject *object)
G_CALLBACK (toolbox_area_notify),
toolbox->p->image_area, 0);
- gimp_toolbox_dnd_init (GIMP_TOOLBOX (toolbox));
+ gimp_toolbox_dnd_init (GIMP_TOOLBOX (toolbox), toolbox->p->vbox);
gimp_toolbox_style_set (GTK_WIDGET (toolbox),
gtk_widget_get_style (GTK_WIDGET (toolbox)));
@@ -441,7 +447,6 @@ gimp_toolbox_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
GimpToolbox *toolbox = GIMP_TOOLBOX (widget);
- Gimp *gimp;
GimpGuiConfig *config;
GtkRequisition color_requisition;
GtkRequisition foo_requisition;
@@ -454,12 +459,7 @@ gimp_toolbox_size_allocate (GtkWidget *widget,
GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
- if (! gimp_toolbox_get_context (toolbox))
- return;
-
- gimp = gimp_toolbox_get_context (toolbox)->gimp;
-
- config = GIMP_GUI_CONFIG (gimp->config);
+ config = GIMP_GUI_CONFIG (toolbox->p->context->gimp->config);
gtk_widget_size_request (toolbox->p->color_area, &color_requisition);
gtk_widget_size_request (toolbox->p->foo_area, &foo_requisition);
@@ -506,6 +506,8 @@ static gboolean
gimp_toolbox_button_press_event (GtkWidget *widget,
GdkEventButton *event)
{
+ GimpToolbox *toolbox = GIMP_TOOLBOX (widget);
+
if (event->type == GDK_BUTTON_PRESS && event->button == 2)
{
GtkClipboard *clipboard;
@@ -513,7 +515,7 @@ gimp_toolbox_button_press_event (GtkWidget *widget,
clipboard = gtk_widget_get_clipboard (widget, GDK_SELECTION_PRIMARY);
gtk_clipboard_request_text (clipboard,
toolbox_paste_received,
- g_object_ref (gimp_toolbox_get_context (GIMP_TOOLBOX (widget))));
+ g_object_ref (toolbox->p->context));
return TRUE;
}
@@ -686,6 +688,10 @@ gimp_toolbox_new (GimpDialogFactory *factory,
GimpContext *context,
GimpUIManager *ui_manager)
{
+ g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (factory), NULL);
+ g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
+ g_return_val_if_fail (GIMP_IS_UI_MANAGER (ui_manager), NULL);
+
return g_object_new (GIMP_TYPE_TOOLBOX,
"dialog-factory", factory,
"context", context,
@@ -709,22 +715,6 @@ gimp_toolbox_get_dialog_factory (GimpToolbox *toolbox)
return toolbox->p->dialog_factory;
}
-GimpUIManager *
-gimp_toolbox_get_ui_manager (GimpToolbox *toolbox)
-{
- g_return_val_if_fail (GIMP_IS_TOOLBOX (toolbox), NULL);
-
- return toolbox->p->ui_manager;
-}
-
-GtkWidget *
-gimp_toolbox_get_vbox (GimpToolbox *toolbox)
-{
- g_return_val_if_fail (GIMP_IS_TOOLBOX (toolbox), NULL);
-
- return toolbox->p->vbox;
-}
-
void
gimp_toolbox_set_drag_handler (GimpToolbox *toolbox,
GimpPanedBox *drag_handler)
diff --git a/app/widgets/gimptoolbox.h b/app/widgets/gimptoolbox.h
index a404715..bad7332 100644
--- a/app/widgets/gimptoolbox.h
+++ b/app/widgets/gimptoolbox.h
@@ -47,13 +47,11 @@ struct _GimpToolboxClass
GType gimp_toolbox_get_type (void) G_GNUC_CONST;
-GtkWidget * gimp_toolbox_new (GimpDialogFactory *factory,
+GtkWidget * gimp_toolbox_new (GimpDialogFactory *factory,
GimpContext *context,
GimpUIManager *ui_manager);
-GimpContext * gimp_toolbox_get_context (GimpToolbox *toolbox);
+GimpContext * gimp_toolbox_get_context (GimpToolbox *toolbox);
GimpDialogFactory * gimp_toolbox_get_dialog_factory (GimpToolbox *toolbox);
-GimpUIManager * gimp_toolbox_get_ui_manager (GimpToolbox *toolbox);
-GtkWidget * gimp_toolbox_get_vbox (GimpToolbox *toolbox);
void gimp_toolbox_set_drag_handler (GimpToolbox *toolbox,
GimpPanedBox *drag_handler);
diff --git a/app/widgets/gimptoolpalette.c b/app/widgets/gimptoolpalette.c
index 636d059..17a2843 100644
--- a/app/widgets/gimptoolpalette.c
+++ b/app/widgets/gimptoolpalette.c
@@ -174,6 +174,10 @@ gimp_tool_palette_constructed (GObject *object)
GList *list;
GSList *item_group = NULL;
+ g_assert (GIMP_IS_CONTEXT (private->context));
+ g_assert (GIMP_IS_UI_MANAGER (private->ui_manager));
+ g_assert (GIMP_IS_DIALOG_FACTORY (private->dialog_factory));
+
group = gtk_tool_item_group_new (_("Tools"));
gtk_tool_item_group_set_label_widget (GTK_TOOL_ITEM_GROUP (group), NULL);
gtk_container_add (GTK_CONTAINER (object), group);
@@ -434,6 +438,10 @@ gimp_tool_palette_new (GimpContext *context,
GimpUIManager *ui_manager,
GimpDialogFactory *dialog_factory)
{
+ g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
+ g_return_val_if_fail (GIMP_IS_UI_MANAGER (ui_manager), NULL);
+ g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (dialog_factory), NULL);
+
return g_object_new (GIMP_TYPE_TOOL_PALETTE,
"context", context,
"ui-manager", ui_manager,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]