[gimp] app: remove more GimpDock and GimpDockbook API in favor of GtkNotebook
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: remove more GimpDock and GimpDockbook API in favor of GtkNotebook
- Date: Fri, 8 Jun 2018 00:42:28 +0000 (UTC)
commit 655b17061971a4985bcafa2d0ac88cc2eb964227
Author: Michael Natterer <mitch gimp org>
Date: Fri Jun 8 02:40:31 2018 +0200
app: remove more GimpDock and GimpDockbook API in favor of GtkNotebook
mostly adding/removing widgets, use the plain GTK+ APIs instead.
Also, cleanup and cruft removal.
app/actions/dockable-commands.c | 26 +++---
app/display/gimpsinglewindowstrategy.c | 3 +-
app/widgets/gimpdialogfactory.c | 16 ++--
app/widgets/gimpdock.c | 49 ++---------
app/widgets/gimpdock.h | 10 +--
app/widgets/gimpdockable.c | 8 +-
app/widgets/gimpdockbook.c | 151 +++++++++------------------------
app/widgets/gimpdockbook.h | 38 ++++-----
app/widgets/gimpdockcolumns.c | 4 +-
app/widgets/gimpsessioninfo-book.c | 5 +-
10 files changed, 100 insertions(+), 210 deletions(-)
---
diff --git a/app/actions/dockable-commands.c b/app/actions/dockable-commands.c
index a257470157..92ea4cc1d6 100644
--- a/app/actions/dockable-commands.c
+++ b/app/actions/dockable-commands.c
@@ -50,9 +50,7 @@ dockable_add_tab_cmd_callback (GtkAction *action,
{
GimpDockbook *dockbook = GIMP_DOCKBOOK (data);
- gimp_dockbook_add_from_dialog_factory (dockbook,
- value /*identifiers*/,
- -1);
+ gimp_dockbook_add_from_dialog_factory (dockbook, value);
}
void
@@ -63,12 +61,8 @@ dockable_close_tab_cmd_callback (GtkAction *action,
GimpDockable *dockable = dockable_get_current (dockbook);
if (dockable)
- {
- g_object_ref (dockable);
- gimp_dockbook_remove (dockbook, dockable);
- gtk_widget_destroy (GTK_WIDGET (dockable));
- g_object_unref (dockable);
- }
+ gtk_container_remove (GTK_CONTAINER (dockbook),
+ GTK_WIDGET (dockable));
}
void
@@ -191,17 +185,17 @@ dockable_toggle_view_cmd_callback (GtkAction *action,
*/
if (! gimp_dockable_get_dockbook (GIMP_DOCKABLE (new_dockable)))
{
- gimp_dockbook_add (dockbook, GIMP_DOCKABLE (new_dockable),
- page_num);
+ gtk_notebook_insert_page (GTK_NOTEBOOK (dockbook),
+ new_dockable, NULL,
+ page_num);
+ gtk_widget_show (new_dockable);
- g_object_ref (dockable);
- gimp_dockbook_remove (dockbook, dockable);
- gtk_widget_destroy (GTK_WIDGET (dockable));
- g_object_unref (dockable);
+ gtk_container_remove (GTK_CONTAINER (dockbook),
+ dockable);
gtk_notebook_set_current_page (GTK_NOTEBOOK (dockbook),
page_num);
- }
+ }
}
}
diff --git a/app/display/gimpsinglewindowstrategy.c b/app/display/gimpsinglewindowstrategy.c
index cfe2932e16..702b987422 100644
--- a/app/display/gimpsinglewindowstrategy.c
+++ b/app/display/gimpsinglewindowstrategy.c
@@ -133,8 +133,7 @@ gimp_single_window_strategy_show_dockable_dialog (GimpWindowStrategy *strategy,
}
widget = gimp_dockbook_add_from_dialog_factory (GIMP_DOCKBOOK (dockbook),
- identifiers,
- -1 /*index*/);
+ identifiers);
}
diff --git a/app/widgets/gimpdialogfactory.c b/app/widgets/gimpdialogfactory.c
index c506f310cf..0def254523 100644
--- a/app/widgets/gimpdialogfactory.c
+++ b/app/widgets/gimpdialogfactory.c
@@ -483,8 +483,9 @@ gimp_dialog_factory_dialog_new_internal (GimpDialogFactory *factory,
/* create the dialog if it was not found */
if (! dialog)
{
- GtkWidget *dock = NULL;
- GtkWidget *dock_window = NULL;
+ GtkWidget *dock = NULL;
+ GtkWidget *dockbook = NULL;
+ GtkWidget *dock_window = NULL;
/* What follows is special-case code for some entires. At some
* point we might want to abstract this block of code away.
@@ -493,16 +494,12 @@ gimp_dialog_factory_dialog_new_internal (GimpDialogFactory *factory,
{
if (entry->dockable)
{
- GtkWidget *dockbook;
-
/* It doesn't make sense to have a dockable without a dock
* so create one. Create a new dock _before_ creating the
* dialog. We do this because the new dockable needs to be
* created in its dock's context.
*/
- dock = gimp_dock_with_window_new (factory,
- monitor,
- FALSE /*toolbox*/);
+ dock = gimp_dock_with_window_new (factory, monitor, FALSE);
dockbook = gimp_dockbook_new (factory->p->menu_factory);
gimp_dock_add_book (GIMP_DOCK (dock),
@@ -565,8 +562,9 @@ gimp_dialog_factory_dialog_new_internal (GimpDialogFactory *factory,
{
if (GIMP_IS_DOCKABLE (dialog))
{
- gimp_dock_add (GIMP_DOCK (dock), GIMP_DOCKABLE (dialog),
- 0, 0);
+ gtk_notebook_append_page (GTK_NOTEBOOK (dockbook),
+ dialog, NULL);
+ gtk_widget_show (dialog);
gtk_widget_show (dock);
}
diff --git a/app/widgets/gimpdock.c b/app/widgets/gimpdock.c
index b410a79eaf..dbe6b5c4bc 100644
--- a/app/widgets/gimpdock.c
+++ b/app/widgets/gimpdock.c
@@ -291,14 +291,10 @@ gimp_dock_dropped_cb (GtkWidget *notebook,
*/
if (gimp_dockbook_get_dock (dockbook) == dock)
{
- GList *children;
- gint n_books;
- gint n_dockables;
+ GList *children = gtk_container_get_children (GTK_CONTAINER (dockable));
+ gint n_dockables = g_list_length (children);
+ gint n_books = g_list_length (gimp_dock_get_dockbooks (dock));
- n_books = g_list_length (gimp_dock_get_dockbooks (dock));
-
- children = gtk_container_get_children (GTK_CONTAINER (gimp_dockable_get_dockbook (dockable)));
- n_dockables = g_list_length (children);
g_list_free (children);
if (n_books == 1 && n_dockables == 1)
@@ -315,7 +311,7 @@ gimp_dock_dropped_cb (GtkWidget *notebook,
gimp_dock_add_book (dock, GIMP_DOCKBOOK (new_dockbook), insert_index);
/* Add the dockable to new new dockbook */
- gimp_dockbook_add (GIMP_DOCKBOOK (new_dockbook), dockable, -1);
+ gtk_notebook_append_page (GTK_NOTEBOOK (new_dockbook), child, NULL);
g_object_unref (dockable);
return TRUE;
@@ -560,14 +556,6 @@ gimp_dock_get_vbox (GimpDock *dock)
return dock->p->paned_vbox;
}
-gint
-gimp_dock_get_id (GimpDock *dock)
-{
- g_return_val_if_fail (GIMP_IS_DOCK (dock), 0);
-
- return dock->p->ID;
-}
-
void
gimp_dock_set_id (GimpDock *dock,
gint ID)
@@ -577,33 +565,12 @@ gimp_dock_set_id (GimpDock *dock,
dock->p->ID = ID;
}
-void
-gimp_dock_add (GimpDock *dock,
- GimpDockable *dockable,
- gint section,
- gint position)
-{
- GimpDockbook *dockbook;
-
- g_return_if_fail (GIMP_IS_DOCK (dock));
- g_return_if_fail (GIMP_IS_DOCKABLE (dockable));
- g_return_if_fail (gimp_dockable_get_dockbook (dockable) == NULL);
-
- dockbook = GIMP_DOCKBOOK (dock->p->dockbooks->data);
-
- gimp_dockbook_add (dockbook, dockable, position);
-}
-
-void
-gimp_dock_remove (GimpDock *dock,
- GimpDockable *dockable)
+gint
+gimp_dock_get_id (GimpDock *dock)
{
- g_return_if_fail (GIMP_IS_DOCK (dock));
- g_return_if_fail (GIMP_IS_DOCKABLE (dockable));
- g_return_if_fail (gimp_dockable_get_dockbook (dockable) != NULL);
- g_return_if_fail (gimp_dockbook_get_dock (gimp_dockable_get_dockbook (dockable)) == dock);
+ g_return_val_if_fail (GIMP_IS_DOCK (dock), 0);
- gimp_dockbook_remove (gimp_dockable_get_dockbook (dockable), dockable);
+ return dock->p->ID;
}
void
diff --git a/app/widgets/gimpdock.h b/app/widgets/gimpdock.h
index 6d26b150df..0485507b7f 100644
--- a/app/widgets/gimpdock.h
+++ b/app/widgets/gimpdock.h
@@ -95,16 +95,10 @@ GList * gimp_dock_get_dockbooks (GimpDock *dock);
gint gimp_dock_get_n_dockables (GimpDock *dock);
GtkWidget * gimp_dock_get_main_vbox (GimpDock *dock);
GtkWidget * gimp_dock_get_vbox (GimpDock *dock);
-gint gimp_dock_get_id (GimpDock *dock);
+
void gimp_dock_set_id (GimpDock *dock,
gint ID);
-
-void gimp_dock_add (GimpDock *dock,
- GimpDockable *dockable,
- gint book,
- gint index);
-void gimp_dock_remove (GimpDock *dock,
- GimpDockable *dockable);
+gint gimp_dock_get_id (GimpDock *dock);
void gimp_dock_add_book (GimpDock *dock,
GimpDockbook *dockbook,
diff --git a/app/widgets/gimpdockable.c b/app/widgets/gimpdockable.c
index cd9529f441..168761b46a 100644
--- a/app/widgets/gimpdockable.c
+++ b/app/widgets/gimpdockable.c
@@ -582,8 +582,12 @@ gimp_dockable_detach (GimpDockable *dockable)
g_object_ref (dockable);
- gimp_dockbook_remove (dockable->p->dockbook, dockable);
- gimp_dockbook_add (GIMP_DOCKBOOK (dockbook), dockable, 0);
+ gtk_container_remove (GTK_CONTAINER (dockable->p->dockbook),
+ GTK_WIDGET (dockable));
+
+ gtk_notebook_append_page (GTK_NOTEBOOK (dockbook),
+ GTK_WIDGET (dockable), NULL);
+ gtk_widget_show (GTK_WIDGET (dockable));
g_object_unref (dockable);
diff --git a/app/widgets/gimpdockbook.c b/app/widgets/gimpdockbook.c
index b2af18c818..b64ee34e4f 100644
--- a/app/widgets/gimpdockbook.c
+++ b/app/widgets/gimpdockbook.c
@@ -86,45 +86,44 @@ struct _GimpDockbookPrivate
};
-static void gimp_dockbook_dispose (GObject *object);
-static void gimp_dockbook_finalize (GObject *object);
-
-static gboolean gimp_dockbook_drag_motion (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time);
-static gboolean gimp_dockbook_drag_drop (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time);
-static gboolean gimp_dockbook_popup_menu (GtkWidget *widget);
-
-static GtkNotebook *gimp_dockbook_create_window (GtkNotebook *notebook,
- GtkWidget *page,
- gint x,
- gint y);
-static void gimp_dockbook_page_added (GtkNotebook *notebook,
- GtkWidget *child,
- guint page_num);
-static void gimp_dockbook_page_removed (GtkNotebook *notebook,
- GtkWidget *child,
- guint page_num);
-static void gimp_dockbook_page_reordered (GtkNotebook *notebook,
- GtkWidget *child,
- guint page_num);
-
-static gboolean gimp_dockbook_menu_button_press (GimpDockbook *dockbook,
- GdkEventButton *bevent,
- GtkWidget *button);
-static gboolean gimp_dockbook_show_menu (GimpDockbook *dockbook);
-static void gimp_dockbook_menu_end (GimpDockable *dockable);
-static void gimp_dockbook_tab_locked_notify (GimpDockable *dockable,
- GParamSpec *pspec,
- GimpDockbook *dockbook);
-static void gimp_dockbook_help_func (const gchar *help_id,
- gpointer help_data);
+static void gimp_dockbook_finalize (GObject *object);
+
+static gboolean gimp_dockbook_drag_motion (GtkWidget *widget,
+ GdkDragContext *context,
+ gint x,
+ gint y,
+ guint time);
+static gboolean gimp_dockbook_drag_drop (GtkWidget *widget,
+ GdkDragContext *context,
+ gint x,
+ gint y,
+ guint time);
+static gboolean gimp_dockbook_popup_menu (GtkWidget *widget);
+
+static GtkNotebook *gimp_dockbook_create_window (GtkNotebook *notebook,
+ GtkWidget *page,
+ gint x,
+ gint y);
+static void gimp_dockbook_page_added (GtkNotebook *notebook,
+ GtkWidget *child,
+ guint page_num);
+static void gimp_dockbook_page_removed (GtkNotebook *notebook,
+ GtkWidget *child,
+ guint page_num);
+static void gimp_dockbook_page_reordered (GtkNotebook *notebook,
+ GtkWidget *child,
+ guint page_num);
+
+static gboolean gimp_dockbook_menu_button_press (GimpDockbook *dockbook,
+ GdkEventButton *bevent,
+ GtkWidget *button);
+static gboolean gimp_dockbook_show_menu (GimpDockbook *dockbook);
+static void gimp_dockbook_menu_end (GimpDockable *dockable);
+static void gimp_dockbook_tab_locked_notify (GimpDockable *dockable,
+ GParamSpec *pspec,
+ GimpDockbook *dockbook);
+static void gimp_dockbook_help_func (const gchar *help_id,
+ gpointer help_data);
G_DEFINE_TYPE (GimpDockbook, gimp_dockbook, GTK_TYPE_NOTEBOOK)
@@ -173,7 +172,6 @@ gimp_dockbook_class_init (GimpDockbookClass *klass)
G_TYPE_NONE, 1,
GIMP_TYPE_DOCKABLE);
- object_class->dispose = gimp_dockbook_dispose;
object_class->finalize = gimp_dockbook_finalize;
widget_class->drag_motion = gimp_dockbook_drag_motion;
@@ -247,30 +245,6 @@ gimp_dockbook_init (GimpDockbook *dockbook)
dockbook);
}
-static void
-gimp_dockbook_dispose (GObject *object)
-{
- GimpDockbook *dockbook = GIMP_DOCKBOOK (object);
- GList *children;
- GList *list;
-
- children = gtk_container_get_children (GTK_CONTAINER (object));
-
- for (list = children; list; list = g_list_next (list))
- {
- GimpDockable *dockable = list->data;
-
- g_object_ref (dockable);
- gimp_dockbook_remove (dockbook, dockable);
- gtk_widget_destroy (GTK_WIDGET (dockable));
- g_object_unref (dockable);
- }
-
- g_list_free (children);
-
- G_OBJECT_CLASS (parent_class)->dispose (object);
-}
-
static void
gimp_dockbook_finalize (GObject *object)
{
@@ -685,47 +659,16 @@ gimp_dockbook_get_ui_manager (GimpDockbook *dockbook)
return dockbook->p->ui_manager;
}
-void
-gimp_dockbook_add (GimpDockbook *dockbook,
- GimpDockable *dockable,
- gint position)
-{
- g_return_if_fail (GIMP_IS_DOCKBOOK (dockbook));
- g_return_if_fail (dockbook->p->dock != NULL);
- g_return_if_fail (GIMP_IS_DOCKABLE (dockable));
- g_return_if_fail (gimp_dockable_get_dockbook (dockable) == NULL);
-
- GIMP_LOG (DND, "Adding GimpDockable %p to GimpDockbook %p", dockable, dockbook);
-
- if (position == -1)
- {
- gtk_notebook_append_page (GTK_NOTEBOOK (dockbook),
- GTK_WIDGET (dockable),
- NULL);
- }
- else
- {
- gtk_notebook_insert_page (GTK_NOTEBOOK (dockbook),
- GTK_WIDGET (dockable),
- NULL,
- position);
- }
-
- gtk_widget_show (GTK_WIDGET (dockable));
-}
-
/**
* gimp_dockbook_add_from_dialog_factory:
* @dockbook: The #DockBook
* @identifiers: The dockable identifier(s)
- * @position: The insert position
*
* Add a dockable from the dialog factory associated with the dockbook.
**/
GtkWidget *
gimp_dockbook_add_from_dialog_factory (GimpDockbook *dockbook,
- const gchar *identifiers,
- gint position)
+ const gchar *identifiers)
{
GtkWidget *dockable;
GimpDock *dock;
@@ -754,24 +697,12 @@ gimp_dockbook_add_from_dialog_factory (GimpDockbook *dockbook,
* attached to a dockbook.
*/
if (dockable && ! gimp_dockable_get_dockbook (GIMP_DOCKABLE (dockable)))
- gimp_dockbook_add (dockbook, GIMP_DOCKABLE (dockable), position);
+ gtk_notebook_append_page (GTK_NOTEBOOK (dockbook),
+ dockable, NULL);
return dockable;
}
-void
-gimp_dockbook_remove (GimpDockbook *dockbook,
- GimpDockable *dockable)
-{
- g_return_if_fail (GIMP_IS_DOCKBOOK (dockbook));
- g_return_if_fail (GIMP_IS_DOCKABLE (dockable));
- g_return_if_fail (gimp_dockable_get_dockbook (dockable) == dockbook);
-
- GIMP_LOG (DND, "Removing GimpDockable %p from GimpDockbook %p", dockable, dockbook);
-
- gtk_container_remove (GTK_CONTAINER (dockbook), GTK_WIDGET (dockable));
-}
-
/**
* gimp_dockbook_update_with_context:
* @dockbook:
diff --git a/app/widgets/gimpdockbook.h b/app/widgets/gimpdockbook.h
index 7c0f26e11b..ac041333f6 100644
--- a/app/widgets/gimpdockbook.h
+++ b/app/widgets/gimpdockbook.h
@@ -59,26 +59,24 @@ struct _GimpDockbookClass
};
-GType gimp_dockbook_get_type (void) G_GNUC_CONST;
-GtkWidget * gimp_dockbook_new (GimpMenuFactory *menu_factory);
-GimpDock * gimp_dockbook_get_dock (GimpDockbook *dockbook);
-void gimp_dockbook_set_dock (GimpDockbook *dockbook,
- GimpDock *dock);
-GimpUIManager * gimp_dockbook_get_ui_manager (GimpDockbook *dockbook);
-void gimp_dockbook_add (GimpDockbook *dockbook,
- GimpDockable *dockable,
- gint position);
-GtkWidget * gimp_dockbook_add_from_dialog_factory (GimpDockbook *dockbook,
- const gchar *identifiers,
- gint position);
-void gimp_dockbook_remove (GimpDockbook *dockbook,
- GimpDockable *dockable);
-void gimp_dockbook_update_with_context (GimpDockbook *dockbook,
- GimpContext *context);
-GtkWidget * gimp_dockbook_create_tab_widget (GimpDockbook *dockbook,
- GimpDockable *dockable);
-void gimp_dockbook_set_drag_handler (GimpDockbook *dockbook,
- GimpPanedBox *drag_handler);
+GType gimp_dockbook_get_type (void) G_GNUC_CONST;
+GtkWidget * gimp_dockbook_new (GimpMenuFactory *menu_factory);
+
+void gimp_dockbook_set_dock (GimpDockbook *dockbook,
+ GimpDock *dock);
+GimpDock * gimp_dockbook_get_dock (GimpDockbook *dockbook);
+
+GimpUIManager * gimp_dockbook_get_ui_manager (GimpDockbook *dockbook);
+
+GtkWidget * gimp_dockbook_add_from_dialog_factory (GimpDockbook *dockbook,
+ const gchar *identifiers);
+
+void gimp_dockbook_update_with_context (GimpDockbook *dockbook,
+ GimpContext *context);
+GtkWidget * gimp_dockbook_create_tab_widget (GimpDockbook *dockbook,
+ GimpDockable *dockable);
+void gimp_dockbook_set_drag_handler (GimpDockbook *dockbook,
+ GimpPanedBox *drag_handler);
#endif /* __GIMP_DOCKBOOK_H__ */
diff --git a/app/widgets/gimpdockcolumns.c b/app/widgets/gimpdockcolumns.c
index e22eb63e12..112b290a9b 100644
--- a/app/widgets/gimpdockcolumns.c
+++ b/app/widgets/gimpdockcolumns.c
@@ -304,8 +304,10 @@ gimp_dock_columns_dropped_cb (GtkWidget *notebook,
/* Move the dockable to the new dockbook */
g_object_ref (new_dockbook);
g_object_ref (dockable);
+
gtk_notebook_detach_tab (GTK_NOTEBOOK (notebook), child);
- gimp_dockbook_add (GIMP_DOCKBOOK (new_dockbook), dockable, -1);
+ gtk_notebook_append_page (GTK_NOTEBOOK (new_dockbook), child, NULL);
+
g_object_unref (dockable);
g_object_unref (new_dockbook);
diff --git a/app/widgets/gimpsessioninfo-book.c b/app/widgets/gimpsessioninfo-book.c
index 4291bc4b60..f6ab7aaa82 100644
--- a/app/widgets/gimpsessioninfo-book.c
+++ b/app/widgets/gimpsessioninfo-book.c
@@ -265,7 +265,10 @@ gimp_session_info_book_restore (GimpSessionInfoBook *info,
if (dockable)
{
- gimp_dockbook_add (GIMP_DOCKBOOK (dockbook), dockable, -1);
+ gtk_notebook_append_page (GTK_NOTEBOOK (dockbook),
+ GTK_WIDGET (dockable), NULL);
+ gtk_widget_show (GTK_WIDGET (dockable));
+
n_dockables++;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]