[gimp] app: Add a 'restore_func' to GimpDialogFactoryEntry
- From: Martin Nordholts <martinn src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: Add a 'restore_func' to GimpDialogFactoryEntry
- Date: Fri, 27 May 2011 20:03:32 +0000 (UTC)
commit 396d5fd5e8b531e29f0de7e5a4bdec11a9cd980a
Author: Martin Nordholts <martinn src gnome org>
Date: Fri May 27 17:16:04 2011 +0200
app: Add a 'restore_func' to GimpDialogFactoryEntry
In gimp_session_info_restore() there is code to create a dialog from a
session info. GimpSessionInfo lives in the widgets module. Thus we
can't add restoration code that depends on a higher level module. In
particular, we can't add code to restore docks in an GimpImageWindow
since GimpImageWindow lives in the display module. And we need such
code to be able to restore a single-window mode session.
Since dialogs are defined in the dialogs module, it makes sense to
also have the code that restores a dialog in that module.
So, add a 'restore_func' member to GimpRestoreDialogFunc of type
GimpRestoreDialogFunc and move the code there.
app/dialogs/dialogs.c | 231 +++++++++++++++++++++++++--------------
app/widgets/gimpdialogfactory.c | 32 +++---
app/widgets/gimpdialogfactory.h | 30 +++---
app/widgets/gimpsessioninfo.c | 34 ++----
app/widgets/gimpsessioninfo.h | 1 +
app/widgets/widgets-types.h | 31 +++---
6 files changed, 210 insertions(+), 149 deletions(-)
---
diff --git a/app/dialogs/dialogs.c b/app/dialogs/dialogs.c
index 32a3a82..aaa29e4 100644
--- a/app/dialogs/dialogs.c
+++ b/app/dialogs/dialogs.c
@@ -28,6 +28,8 @@
#include "dialogs-types.h"
+#include "config/gimpguiconfig.h"
+
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "core/gimplist.h"
@@ -37,11 +39,14 @@
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpmenufactory.h"
#include "widgets/gimpsessioninfo.h"
+#include "widgets/gimpsessioninfo-aux.h"
#include "widgets/gimptoolbox.h"
#include "dialogs.h"
#include "dialogs-constructors.h"
+#include "gimp-log.h"
+
#include "gimp-intl.h"
@@ -49,100 +54,106 @@ GimpContainer *global_recent_docks = NULL;
#define FOREIGN(id, singleton, remember_size) \
- { id /* identifier */, \
- NULL /* name */, \
- NULL /* blurb */, \
- NULL /* stock_id */, \
- NULL /* help_id */, \
- NULL /* new_func */, \
- 0 /* view_size */, \
- singleton /* singleton */, \
- TRUE /* session_managed */, \
- remember_size /* remember_size */, \
- FALSE /* remember_if_open */, \
- TRUE /* hideable */, \
- FALSE /* image_window */, \
- FALSE /* dockable */}
+ { id /* identifier */, \
+ NULL /* name */, \
+ NULL /* blurb */, \
+ NULL /* stock_id */, \
+ NULL /* help_id */, \
+ NULL /* new_func */, \
+ dialogs_restore_dialog /* restore_func */, \
+ 0 /* view_size */, \
+ singleton /* singleton */, \
+ TRUE /* session_managed */, \
+ remember_size /* remember_size */, \
+ FALSE /* remember_if_open */, \
+ TRUE /* hideable */, \
+ FALSE /* image_window */, \
+ FALSE /* dockable */}
#define IMAGE_WINDOW(id, singleton, remember_size) \
- { id /* identifier */, \
- NULL /* name */, \
- NULL /* blurb */, \
- NULL /* stock_id */, \
- NULL /* help_id */, \
- NULL /* new_func */, \
- 0 /* view_size */, \
- singleton /* singleton */, \
- TRUE /* session_managed */, \
- remember_size /* remember_size */, \
- FALSE /* remember_if_open */, \
- FALSE /* hideable */, \
- TRUE /* image_window */, \
- FALSE /* dockable */}
+ { id /* identifier */, \
+ NULL /* name */, \
+ NULL /* blurb */, \
+ NULL /* stock_id */, \
+ NULL /* help_id */, \
+ NULL /* new_func */, \
+ NULL /* restore_func */, \
+ 0 /* view_size */, \
+ singleton /* singleton */, \
+ TRUE /* session_managed */, \
+ remember_size /* remember_size */, \
+ FALSE /* remember_if_open */, \
+ FALSE /* hideable */, \
+ TRUE /* image_window */, \
+ FALSE /* dockable */}
#define TOPLEVEL(id, new_func, singleton, session_managed, remember_size) \
- { id /* identifier */, \
- NULL /* name */, \
- NULL /* blurb */, \
- NULL /* stock_id */, \
- NULL /* help_id */, \
- new_func /* new_func */, \
- 0 /* view_size */, \
- singleton /* singleton */, \
- session_managed /* session_managed */, \
- remember_size /* remember_size */, \
- FALSE /* remember_if_open */, \
- TRUE /* hideable */, \
- FALSE /* image_window */, \
- FALSE /* dockable */}
+ { id /* identifier */, \
+ NULL /* name */, \
+ NULL /* blurb */, \
+ NULL /* stock_id */, \
+ NULL /* help_id */, \
+ new_func /* new_func */, \
+ dialogs_restore_dialog /* restore_func */, \
+ 0 /* view_size */, \
+ singleton /* singleton */, \
+ session_managed /* session_managed */, \
+ remember_size /* remember_size */, \
+ FALSE /* remember_if_open */, \
+ TRUE /* hideable */, \
+ FALSE /* image_window */, \
+ FALSE /* dockable */}
#define DOCKABLE(id, name, blurb, stock_id, help_id, new_func, view_size, singleton) \
- { id /* identifier */, \
- name /* name */, \
- blurb /* blurb */, \
- stock_id /* stock_id */, \
- help_id /* help_id */, \
- new_func /* new_func */, \
- view_size /* view_size */, \
- singleton /* singleton */, \
- FALSE /* session_managed */, \
- FALSE /* remember_size */, \
- TRUE /* remember_if_open */, \
- TRUE /* hideable */, \
- FALSE /* image_window */, \
- TRUE /* dockable */}
+ { id /* identifier */, \
+ name /* name */, \
+ blurb /* blurb */, \
+ stock_id /* stock_id */, \
+ help_id /* help_id */, \
+ new_func /* new_func */, \
+ NULL /* restore_func */, \
+ view_size /* view_size */, \
+ singleton /* singleton */, \
+ FALSE /* session_managed */, \
+ FALSE /* remember_size */, \
+ TRUE /* remember_if_open */, \
+ TRUE /* hideable */, \
+ FALSE /* image_window */, \
+ TRUE /* dockable */}
#define DOCK(id, new_func) \
- { id /* identifier */, \
- NULL /* name */, \
- NULL /* blurb */, \
- NULL /* stock_id */, \
- NULL /* help_id */, \
- new_func /* new_func */, \
- 0 /* view_size */, \
- FALSE /* singleton */, \
- FALSE /* session_managed */, \
- FALSE /* remember_size */, \
- FALSE /* remember_if_open */, \
- TRUE /* hideable */, \
- FALSE /* image_window */, \
- FALSE /* dockable */}
+ { id /* identifier */, \
+ NULL /* name */, \
+ NULL /* blurb */, \
+ NULL /* stock_id */, \
+ NULL /* help_id */, \
+ new_func /* new_func */, \
+ dialogs_restore_dialog /* restore_func */, \
+ 0 /* view_size */, \
+ FALSE /* singleton */, \
+ FALSE /* session_managed */, \
+ FALSE /* remember_size */, \
+ FALSE /* remember_if_open */, \
+ TRUE /* hideable */, \
+ FALSE /* image_window */, \
+ FALSE /* dockable */}
#define DOCK_WINDOW(id, new_func) \
- { id /* identifier */, \
- NULL /* name */, \
- NULL /* blurb */, \
- NULL /* stock_id */, \
- NULL /* help_id */, \
- new_func /* new_func */, \
- 0 /* view_size */, \
- FALSE /* singleton */, \
- TRUE /* session_managed */, \
- TRUE /* remember_size */, \
- TRUE /* remember_if_open */, \
- TRUE /* hideable */, \
- FALSE /* image_window */, \
- FALSE /* dockable */}
+ { id /* identifier */, \
+ NULL /* name */, \
+ NULL /* blurb */, \
+ NULL /* stock_id */, \
+ NULL /* help_id */, \
+ new_func /* new_func */, \
+ dialogs_restore_dialog /* restore_func */, \
+ 0 /* view_size */, \
+ FALSE /* singleton */, \
+ TRUE /* session_managed */, \
+ TRUE /* remember_size */, \
+ TRUE /* remember_if_open */, \
+ TRUE /* hideable */, \
+ FALSE /* image_window */, \
+ FALSE /* dockable */}
#define LISTGRID(id, name, blurb, stock_id, help_id, view_size) \
{ "gimp-"#id"-list" /* identifier */, \
@@ -151,6 +162,7 @@ GimpContainer *global_recent_docks = NULL;
stock_id /* stock_id */, \
help_id /* help_id */, \
dialogs_##id##_list_view_new /* new_func */, \
+ NULL /* restore_func */, \
view_size /* view_size */, \
FALSE /* singleton */, \
FALSE /* session_managed */, \
@@ -165,6 +177,7 @@ GimpContainer *global_recent_docks = NULL;
stock_id /* stock_id */, \
help_id /* help_id */, \
dialogs_##id##_grid_view_new /* new_func */, \
+ NULL /* restore_func */, \
view_size /* view_size */, \
FALSE /* singleton */, \
FALSE /* session_managed */, \
@@ -181,6 +194,7 @@ GimpContainer *global_recent_docks = NULL;
stock_id /* stock_id */, \
help_id /* help_id */, \
dialogs_##new_func##_list_view_new /* new_func */, \
+ NULL /* restore_func */, \
view_size /* view_size */, \
FALSE /* singleton */, \
FALSE /* session_managed */, \
@@ -191,6 +205,11 @@ GimpContainer *global_recent_docks = NULL;
TRUE /* dockable */}
+static GtkWidget * dialogs_restore_dialog (GimpDialogFactory *factory,
+ GdkScreen *screen,
+ GimpSessionInfo *info);
+
+
static const GimpDialogFactoryEntry entries[] =
{
/* foreign toplevels without constructor */
@@ -386,6 +405,49 @@ static const GimpDialogFactoryEntry entries[] =
TRUE, TRUE)
};
+/**
+ * dialogs_restore_dialog:
+ * @factory:
+ * @screen:
+ * @info:
+ *
+ * Creates a top level widget based on the given session info object
+ * in which other widgets later can be be put, typically also restored
+ * from the same session info object.
+ *
+ * Returns:
+ **/
+static GtkWidget *
+dialogs_restore_dialog (GimpDialogFactory *factory,
+ GdkScreen *screen,
+ GimpSessionInfo *info)
+{
+ GtkWidget *dialog;
+ GimpCoreConfig *config = gimp_dialog_factory_get_context (factory)->gimp->config;
+
+ GIMP_LOG (DIALOG_FACTORY, "restoring toplevel \"%s\" (info %p)",
+ gimp_session_info_get_factory_entry (info)->identifier,
+ info);
+
+ dialog =
+ gimp_dialog_factory_dialog_new (factory, screen,
+ NULL /*ui_manager*/,
+ gimp_session_info_get_factory_entry (info)->identifier,
+ gimp_session_info_get_factory_entry (info)->view_size,
+ ! GIMP_GUI_CONFIG (config)->hide_docks);
+
+ g_object_set_data (G_OBJECT (dialog), GIMP_DIALOG_VISIBILITY_KEY,
+ GINT_TO_POINTER (GIMP_GUI_CONFIG (config)->hide_docks ?
+ GIMP_DIALOG_VISIBILITY_HIDDEN :
+ GIMP_DIALOG_VISIBILITY_VISIBLE));
+
+ if (dialog && gimp_session_info_get_aux_info (info))
+ gimp_session_info_aux_set_list (dialog,
+ gimp_session_info_get_aux_info (info));
+
+ return dialog;
+}
+
/* public functions */
@@ -412,6 +474,7 @@ dialogs_init (Gimp *gimp,
entries[i].stock_id,
entries[i].help_id,
entries[i].new_func,
+ entries[i].restore_func,
entries[i].view_size,
entries[i].singleton,
entries[i].session_managed,
diff --git a/app/widgets/gimpdialogfactory.c b/app/widgets/gimpdialogfactory.c
index 23e64cd..1f0ff41 100644
--- a/app/widgets/gimpdialogfactory.c
+++ b/app/widgets/gimpdialogfactory.c
@@ -260,21 +260,22 @@ gimp_dialog_factory_new (const gchar *name,
}
void
-gimp_dialog_factory_register_entry (GimpDialogFactory *factory,
- const gchar *identifier,
- const gchar *name,
- const gchar *blurb,
- const gchar *stock_id,
- const gchar *help_id,
- GimpDialogNewFunc new_func,
- gint view_size,
- gboolean singleton,
- gboolean session_managed,
- gboolean remember_size,
- gboolean remember_if_open,
- gboolean hideable,
- gboolean image_window,
- gboolean dockable)
+gimp_dialog_factory_register_entry (GimpDialogFactory *factory,
+ const gchar *identifier,
+ const gchar *name,
+ const gchar *blurb,
+ const gchar *stock_id,
+ const gchar *help_id,
+ GimpDialogNewFunc new_func,
+ GimpDialogRestoreFunc restore_func,
+ gint view_size,
+ gboolean singleton,
+ gboolean session_managed,
+ gboolean remember_size,
+ gboolean remember_if_open,
+ gboolean hideable,
+ gboolean image_window,
+ gboolean dockable)
{
GimpDialogFactoryEntry *entry;
@@ -289,6 +290,7 @@ gimp_dialog_factory_register_entry (GimpDialogFactory *factory,
entry->stock_id = g_strdup (stock_id);
entry->help_id = g_strdup (help_id);
entry->new_func = new_func;
+ entry->restore_func = restore_func;
entry->view_size = view_size;
entry->singleton = singleton ? TRUE : FALSE;
entry->session_managed = session_managed ? TRUE : FALSE;
diff --git a/app/widgets/gimpdialogfactory.h b/app/widgets/gimpdialogfactory.h
index f8c3f9e..66c6d10 100644
--- a/app/widgets/gimpdialogfactory.h
+++ b/app/widgets/gimpdialogfactory.h
@@ -48,28 +48,29 @@ typedef GtkWidget * (* GimpDialogNewFunc) (GimpDialogFactory *factory,
struct _GimpDialogFactoryEntry
{
- gchar *identifier;
- gchar *name;
- gchar *blurb;
- gchar *stock_id;
- gchar *help_id;
+ gchar *identifier;
+ gchar *name;
+ gchar *blurb;
+ gchar *stock_id;
+ gchar *help_id;
- GimpDialogNewFunc new_func;
- gint view_size;
+ GimpDialogNewFunc new_func;
+ GimpDialogRestoreFunc restore_func;
+ gint view_size;
- gboolean singleton;
- gboolean session_managed;
- gboolean remember_size;
- gboolean remember_if_open;
+ gboolean singleton;
+ gboolean session_managed;
+ gboolean remember_size;
+ gboolean remember_if_open;
/* If TRUE the visibility of the dialog is toggleable */
- gboolean hideable;
+ gboolean hideable;
/* If TRUE the entry is for a GimpImageWindow, FALSE otherwise */
- gboolean image_window;
+ gboolean image_window;
/* If TRUE the entry is for a dockable, FALSE otherwise */
- gboolean dockable;
+ gboolean dockable;
};
@@ -120,6 +121,7 @@ void gimp_dialog_factory_register_entry (GimpDialogFactory
const gchar *stock_id,
const gchar *help_id,
GimpDialogNewFunc new_func,
+ GimpDialogRestoreFunc restore_func,
gint view_size,
gboolean singleton,
gboolean session_managed,
diff --git a/app/widgets/gimpsessioninfo.c b/app/widgets/gimpsessioninfo.c
index 9f0d479..7851df6 100644
--- a/app/widgets/gimpsessioninfo.c
+++ b/app/widgets/gimpsessioninfo.c
@@ -481,29 +481,11 @@ gimp_session_info_restore (GimpSessionInfo *info,
info->p->screen = DEFAULT_SCREEN;
if (info->p->factory_entry &&
- ! info->p->factory_entry->dockable &&
- ! info->p->factory_entry->image_window)
+ info->p->factory_entry->restore_func)
{
- GimpCoreConfig *config = gimp_dialog_factory_get_context (factory)->gimp->config;
-
- GIMP_LOG (DIALOG_FACTORY, "restoring toplevel \"%s\" (info %p)",
- info->p->factory_entry->identifier,
- info);
-
- dialog =
- gimp_dialog_factory_dialog_new (factory, screen,
- NULL /*ui_manager*/,
- info->p->factory_entry->identifier,
- info->p->factory_entry->view_size,
- ! GIMP_GUI_CONFIG (config)->hide_docks);
-
- g_object_set_data (G_OBJECT (dialog), GIMP_DIALOG_VISIBILITY_KEY,
- GINT_TO_POINTER (GIMP_GUI_CONFIG (config)->hide_docks ?
- GIMP_DIALOG_VISIBILITY_HIDDEN :
- GIMP_DIALOG_VISIBILITY_VISIBLE));
-
- if (dialog && info->p->aux_info)
- gimp_session_info_aux_set_list (dialog, info->p->aux_info);
+ dialog = info->p->factory_entry->restore_func (factory,
+ screen,
+ info);
}
/* We expect expect there to always be docks. In sessionrc files
@@ -795,6 +777,14 @@ gimp_session_info_get_info_with_widget (GimpSessionInfo *info,
gimp_session_info_set_widget (info, old_widget);
}
+GList *
+gimp_session_info_get_aux_info (GimpSessionInfo *info)
+{
+ g_return_val_if_fail (GIMP_IS_SESSION_INFO (info), NULL);
+
+ return info->p->aux_info;
+}
+
void
gimp_session_info_clear_info (GimpSessionInfo *info)
{
diff --git a/app/widgets/gimpsessioninfo.h b/app/widgets/gimpsessioninfo.h
index bf2d787..eb29e5a 100644
--- a/app/widgets/gimpsessioninfo.h
+++ b/app/widgets/gimpsessioninfo.h
@@ -66,6 +66,7 @@ void gimp_session_info_read_geometry (GimpSe
void gimp_session_info_get_info (GimpSessionInfo *info);
void gimp_session_info_get_info_with_widget (GimpSessionInfo *info,
GtkWidget *widget);
+GList * gimp_session_info_get_aux_info (GimpSessionInfo *info);
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);
diff --git a/app/widgets/widgets-types.h b/app/widgets/widgets-types.h
index 022c5aa..aaf5f12 100644
--- a/app/widgets/widgets-types.h
+++ b/app/widgets/widgets-types.h
@@ -260,20 +260,23 @@ typedef struct _GimpDialogFactoryEntry GimpDialogFactoryEntry;
/* function types */
-typedef void (* GimpActionGroupSetupFunc) (GimpActionGroup *group);
-typedef void (* GimpActionGroupUpdateFunc) (GimpActionGroup *group,
- gpointer data);
-
-typedef void (* GimpUIManagerSetupFunc) (GimpUIManager *manager,
- const gchar *ui_path);
-
-typedef void (* GimpMenuPositionFunc) (GtkMenu *menu,
- gint *x,
- gint *y,
- gpointer data);
-typedef gboolean (* GimpPanedBoxDroppedFunc) (GtkWidget *source,
- gint insert_index,
- gpointer data);
+typedef GtkWidget * (* GimpDialogRestoreFunc) (GimpDialogFactory *factory,
+ GdkScreen *screen,
+ GimpSessionInfo *info);
+typedef void (* GimpActionGroupSetupFunc) (GimpActionGroup *group);
+typedef void (* GimpActionGroupUpdateFunc) (GimpActionGroup *group,
+ gpointer data);
+
+typedef void (* GimpUIManagerSetupFunc) (GimpUIManager *manager,
+ const gchar *ui_path);
+
+typedef void (* GimpMenuPositionFunc) (GtkMenu *menu,
+ gint *x,
+ gint *y,
+ gpointer data);
+typedef gboolean (* GimpPanedBoxDroppedFunc) (GtkWidget *source,
+ gint insert_index,
+ gpointer data);
/* temp hack as replacement for GdkSegment */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]