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.
This commit is contained in:
@ -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"
|
||||
|
||||
|
||||
@ -55,6 +60,7 @@ GimpContainer *global_recent_docks = NULL;
|
||||
NULL /* stock_id */, \
|
||||
NULL /* help_id */, \
|
||||
NULL /* new_func */, \
|
||||
dialogs_restore_dialog /* restore_func */, \
|
||||
0 /* view_size */, \
|
||||
singleton /* singleton */, \
|
||||
TRUE /* session_managed */, \
|
||||
@ -71,6 +77,7 @@ GimpContainer *global_recent_docks = NULL;
|
||||
NULL /* stock_id */, \
|
||||
NULL /* help_id */, \
|
||||
NULL /* new_func */, \
|
||||
NULL /* restore_func */, \
|
||||
0 /* view_size */, \
|
||||
singleton /* singleton */, \
|
||||
TRUE /* session_managed */, \
|
||||
@ -87,6 +94,7 @@ GimpContainer *global_recent_docks = NULL;
|
||||
NULL /* stock_id */, \
|
||||
NULL /* help_id */, \
|
||||
new_func /* new_func */, \
|
||||
dialogs_restore_dialog /* restore_func */, \
|
||||
0 /* view_size */, \
|
||||
singleton /* singleton */, \
|
||||
session_managed /* session_managed */, \
|
||||
@ -103,6 +111,7 @@ GimpContainer *global_recent_docks = NULL;
|
||||
stock_id /* stock_id */, \
|
||||
help_id /* help_id */, \
|
||||
new_func /* new_func */, \
|
||||
NULL /* restore_func */, \
|
||||
view_size /* view_size */, \
|
||||
singleton /* singleton */, \
|
||||
FALSE /* session_managed */, \
|
||||
@ -119,6 +128,7 @@ GimpContainer *global_recent_docks = NULL;
|
||||
NULL /* stock_id */, \
|
||||
NULL /* help_id */, \
|
||||
new_func /* new_func */, \
|
||||
dialogs_restore_dialog /* restore_func */, \
|
||||
0 /* view_size */, \
|
||||
FALSE /* singleton */, \
|
||||
FALSE /* session_managed */, \
|
||||
@ -135,6 +145,7 @@ GimpContainer *global_recent_docks = NULL;
|
||||
NULL /* stock_id */, \
|
||||
NULL /* help_id */, \
|
||||
new_func /* new_func */, \
|
||||
dialogs_restore_dialog /* restore_func */, \
|
||||
0 /* view_size */, \
|
||||
FALSE /* singleton */, \
|
||||
TRUE /* session_managed */, \
|
||||
@ -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,
|
||||
|
@ -267,6 +267,7 @@ gimp_dialog_factory_register_entry (GimpDialogFactory *factory,
|
||||
const gchar *stock_id,
|
||||
const gchar *help_id,
|
||||
GimpDialogNewFunc new_func,
|
||||
GimpDialogRestoreFunc restore_func,
|
||||
gint view_size,
|
||||
gboolean singleton,
|
||||
gboolean session_managed,
|
||||
@ -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;
|
||||
|
@ -55,6 +55,7 @@ struct _GimpDialogFactoryEntry
|
||||
gchar *help_id;
|
||||
|
||||
GimpDialogNewFunc new_func;
|
||||
GimpDialogRestoreFunc restore_func;
|
||||
gint view_size;
|
||||
|
||||
gboolean singleton;
|
||||
@ -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,
|
||||
|
@ -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,
|
||||
dialog = info->p->factory_entry->restore_func (factory,
|
||||
screen,
|
||||
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);
|
||||
}
|
||||
|
||||
/* 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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
@ -260,6 +260,9 @@ typedef struct _GimpDialogFactoryEntry GimpDialogFactoryEntry;
|
||||
|
||||
/* function types */
|
||||
|
||||
typedef GtkWidget * (* GimpDialogRestoreFunc) (GimpDialogFactory *factory,
|
||||
GdkScreen *screen,
|
||||
GimpSessionInfo *info);
|
||||
typedef void (* GimpActionGroupSetupFunc) (GimpActionGroup *group);
|
||||
typedef void (* GimpActionGroupUpdateFunc) (GimpActionGroup *group,
|
||||
gpointer data);
|
||||
|
Reference in New Issue
Block a user