[gimp] app: Make GimpDockContainer::get_docks() return a new list
- From: Martin Nordholts <martinn src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: Make GimpDockContainer::get_docks() return a new list
- Date: Fri, 13 May 2011 19:28:28 +0000 (UTC)
commit 0f19471e22820e336f9f2966caa1d6a2bdd62aa7
Author: Martin Nordholts <martinn src gnome org>
Date: Wed May 11 18:06:59 2011 +0200
app: Make GimpDockContainer::get_docks() return a new list
Make GimpDockContainer::get_docks() return a new list and not just a
pointer to a list so that GimpImageWindow can implement it (who needs
to merge its two GimpDockColumns lists).
app/gui/gimpuiconfigurer.c | 21 +++++++++++++++------
app/tests/test-ui.c | 11 +++++++++--
app/widgets/gimpdockcontainer.c | 7 +++++++
app/widgets/gimpdockwindow.c | 18 +++++++++---------
app/widgets/gimpsessioninfo.c | 7 ++++++-
5 files changed, 46 insertions(+), 18 deletions(-)
---
diff --git a/app/gui/gimpuiconfigurer.c b/app/gui/gimpuiconfigurer.c
index 2aad4d1..0f2c938 100644
--- a/app/gui/gimpuiconfigurer.c
+++ b/app/gui/gimpuiconfigurer.c
@@ -176,7 +176,7 @@ gimp_ui_configurer_move_docks_to_columns (GimpUIConfigurer *ui_configurer,
dock_window = GIMP_DOCK_WINDOW (dialog_iter->data);
dock_container = GIMP_DOCK_CONTAINER (dock_window);
- docks = g_list_copy (gimp_dock_container_get_docks (dock_container));
+ docks = gimp_dock_container_get_docks (dock_container);
for (dock_iter = docks; dock_iter; dock_iter = dock_iter->next)
{
GimpDock *dock = GIMP_DOCK (dock_iter->data);
@@ -202,12 +202,21 @@ gimp_ui_configurer_move_docks_to_columns (GimpUIConfigurer *ui_configurer,
* complains about invalid reads when the dock window already is
* destroyed
*/
- if (GTK_IS_WIDGET (dock_window) &&
- g_list_length (gimp_dock_container_get_docks (dock_container)) == 0)
+ if (GTK_IS_WIDGET (dock_window))
{
- gimp_dialog_factory_remove_dialog (gimp_dialog_factory_get_singleton (),
- GTK_WIDGET (dock_window));
- gtk_widget_destroy (GTK_WIDGET (dock_window));
+ guint docks_len;
+
+ docks = gimp_dock_container_get_docks (dock_container);
+ docks_len = g_list_length (docks);
+
+ if (docks_len == 0)
+ {
+ gimp_dialog_factory_remove_dialog (gimp_dialog_factory_get_singleton (),
+ GTK_WIDGET (dock_window));
+ gtk_widget_destroy (GTK_WIDGET (dock_window));
+ }
+
+ g_list_free (docks);
}
}
}
diff --git a/app/tests/test-ui.c b/app/tests/test-ui.c
index 60ee3a5..8a1a472 100644
--- a/app/tests/test-ui.c
+++ b/app/tests/test-ui.c
@@ -735,17 +735,24 @@ gimp_ui_not_toolbox_window (GObject *object)
static gboolean
gimp_ui_multicolumn_not_toolbox_window (GObject *object)
{
+ gboolean not_toolbox_window;
GimpDockWindow *dock_window;
GimpDockContainer *dock_container;
+ GList *docks;
if (! GIMP_IS_DOCK_WINDOW (object))
return FALSE;
dock_window = GIMP_DOCK_WINDOW (object);
dock_container = GIMP_DOCK_CONTAINER (object);
+ docks = gimp_dock_container_get_docks (dock_container);
- return (! gimp_dock_window_has_toolbox (dock_window) &&
- g_list_length (gimp_dock_container_get_docks (dock_container)) > 1);
+ not_toolbox_window = (! gimp_dock_window_has_toolbox (dock_window) &&
+ g_list_length (docks) > 1);
+
+ g_list_free (docks);
+
+ return not_toolbox_window;
}
static gboolean
diff --git a/app/widgets/gimpdockcontainer.c b/app/widgets/gimpdockcontainer.c
index 54b9a27..9540495 100644
--- a/app/widgets/gimpdockcontainer.c
+++ b/app/widgets/gimpdockcontainer.c
@@ -68,6 +68,13 @@ gimp_dock_container_iface_base_init (GimpDockContainerInterface *container_iface
container_iface->get_docks = NULL;
}
+/**
+ * gimp_dock_container_get_docks:
+ * @container: A #GimpDockContainer
+ *
+ * Returns: A list of #GimpDock:s in the dock container. Free with
+ * g_list_free() when done.
+ **/
GList *
gimp_dock_container_get_docks (GimpDockContainer *container)
{
diff --git a/app/widgets/gimpdockwindow.c b/app/widgets/gimpdockwindow.c
index 0c3efcb..dca6bd3 100644
--- a/app/widgets/gimpdockwindow.c
+++ b/app/widgets/gimpdockwindow.c
@@ -681,13 +681,6 @@ gimp_dock_window_delete_event (GtkWidget *widget,
return FALSE;
}
-/**
- * gimp_dock_window_get_docks:
- *
- * Get a list of docks in the dock window.
- *
- * Returns:
- **/
static GList *
gimp_dock_window_get_docks (GimpDockContainer *dock_container)
{
@@ -697,7 +690,7 @@ gimp_dock_window_get_docks (GimpDockContainer *dock_container)
dock_window = GIMP_DOCK_WINDOW (dock_container);
- return gimp_dock_columns_get_docks (dock_window->p->dock_columns);
+ return g_list_copy (gimp_dock_columns_get_docks (dock_window->p->dock_columns));
}
static GimpUIManager *
@@ -765,6 +758,8 @@ gimp_dock_window_should_add_to_recent (GimpDockWindow *dock_window)
}
}
+ g_list_free (docks);
+
return should_add;
}
@@ -823,9 +818,12 @@ gimp_dock_window_get_description (GimpDockWindow *dock_window,
gboolean complete)
{
GString *complete_desc = g_string_new (NULL);
+ GList *docks = NULL;
GList *iter = NULL;
- for (iter = gimp_dock_container_get_docks (GIMP_DOCK_CONTAINER (dock_window));
+ docks = gimp_dock_container_get_docks (GIMP_DOCK_CONTAINER (dock_window));
+
+ for (iter = docks;
iter;
iter = g_list_next (iter))
{
@@ -837,6 +835,8 @@ gimp_dock_window_get_description (GimpDockWindow *dock_window,
g_string_append (complete_desc, GIMP_DOCK_COLUMN_SEPARATOR);
}
+ g_list_free (docks);
+
return g_string_free (complete_desc, FALSE /*free_segment*/);
}
diff --git a/app/widgets/gimpsessioninfo.c b/app/widgets/gimpsessioninfo.c
index 8f718ba..5101eec 100644
--- a/app/widgets/gimpsessioninfo.c
+++ b/app/widgets/gimpsessioninfo.c
@@ -750,8 +750,11 @@ gimp_session_info_get_info (GimpSessionInfo *info)
{
GimpDockContainer *dock_container = GIMP_DOCK_CONTAINER (info->p->widget);
GList *iter = NULL;
+ GList *docks;
- for (iter = gimp_dock_container_get_docks (dock_container);
+ docks = gimp_dock_container_get_docks (dock_container);
+
+ for (iter = docks;
iter;
iter = g_list_next (iter))
{
@@ -761,6 +764,8 @@ gimp_session_info_get_info (GimpSessionInfo *info)
g_list_append (info->p->docks,
gimp_session_info_dock_from_widget (dock));
}
+
+ g_list_free (docks);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]