[gimp] app: Add and use gimp_session_info_get_info_with_widget()



commit 6d421f9d4dcce00b832233c6745a4c76256e8375
Author: Martin Nordholts <martinn src gnome org>
Date:   Mon May 9 18:27:32 2011 +0200

    app: Add and use gimp_session_info_get_info_with_widget()
    
    Add and use helper function
    gimp_session_info_get_info_with_widget(). Might need it for
    GimpImageWindow later...

 app/widgets/gimpdockwindow.c  |    4 +---
 app/widgets/gimpsessioninfo.c |   25 +++++++++++++++++++++++++
 app/widgets/gimpsessioninfo.h |    2 ++
 3 files changed, 28 insertions(+), 3 deletions(-)
---
diff --git a/app/widgets/gimpdockwindow.c b/app/widgets/gimpdockwindow.c
index 5f161b6..ebf4d7b 100644
--- a/app/widgets/gimpdockwindow.c
+++ b/app/widgets/gimpdockwindow.c
@@ -666,9 +666,7 @@ gimp_dock_window_delete_event (GtkWidget   *widget,
   gimp_object_set_name (GIMP_OBJECT (info), name);
   g_free (name);
 
-  gimp_session_info_set_widget (info, GTK_WIDGET (dock_window));
-  gimp_session_info_get_info (info);
-  gimp_session_info_set_widget (info, NULL);
+  gimp_session_info_get_info_with_widget (info, GTK_WIDGET (dock_window));
 
   entry_name = (gimp_dock_window_has_toolbox (dock_window) ?
                 "gimp-toolbox-window" :
diff --git a/app/widgets/gimpsessioninfo.c b/app/widgets/gimpsessioninfo.c
index 6033579..052ca73 100644
--- a/app/widgets/gimpsessioninfo.c
+++ b/app/widgets/gimpsessioninfo.c
@@ -760,6 +760,31 @@ gimp_session_info_get_info (GimpSessionInfo *info)
     }
 }
 
+/**
+ * gimp_session_info_get_info_with_widget:
+ * @info:
+ * @widget: #GtkWidget to use
+ *
+ * Temporarily sets @widget on @info and calls
+ * gimp_session_info_get_info(), then restores the old widget that was
+ * set.
+ **/
+void
+gimp_session_info_get_info_with_widget (GimpSessionInfo *info,
+                                        GtkWidget       *widget)
+{
+  GtkWidget *old_widget;
+
+  g_return_if_fail (GIMP_IS_SESSION_INFO (info));
+  g_return_if_fail (GTK_IS_WIDGET (widget));
+
+  old_widget = gimp_session_info_get_widget (info);
+
+  gimp_session_info_set_widget (info, widget);
+  gimp_session_info_get_info (info);
+  gimp_session_info_set_widget (info, old_widget);
+}
+
 void
 gimp_session_info_clear_info (GimpSessionInfo *info)
 {
diff --git a/app/widgets/gimpsessioninfo.h b/app/widgets/gimpsessioninfo.h
index 3dbe8ca..bf2d787 100644
--- a/app/widgets/gimpsessioninfo.h
+++ b/app/widgets/gimpsessioninfo.h
@@ -64,6 +64,8 @@ void                     gimp_session_info_restore                       (GimpSe
 void                     gimp_session_info_apply_geometry                (GimpSessionInfo        *info);
 void                     gimp_session_info_read_geometry                 (GimpSessionInfo        *info);
 void                     gimp_session_info_get_info                      (GimpSessionInfo        *info);
+void                     gimp_session_info_get_info_with_widget          (GimpSessionInfo        *info,
+                                                                          GtkWidget              *widget);
 void                     gimp_session_info_clear_info                    (GimpSessionInfo        *info);
 gboolean                 gimp_session_info_is_singleton                  (GimpSessionInfo        *info);
 gboolean                 gimp_session_info_is_session_managed            (GimpSessionInfo        *info);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]