app: Make hideability a per entry rather than per dialog factory thing

This commit is contained in:
Martin Nordholts 2010-02-20 10:32:50 +01:00
parent 8b458fb591
commit 993d2df338
3 changed files with 25 additions and 14 deletions

View File

@ -60,6 +60,7 @@ GimpContainer *global_recent_docks = NULL;
TRUE /* session_managed */, \
remember_size /* remember_size */, \
FALSE /* remember_if_open */, \
TRUE /* hideable */, \
FALSE /* dockable */}
#define TOPLEVEL(id, new_func, singleton, session_managed, remember_size) \
@ -74,6 +75,7 @@ GimpContainer *global_recent_docks = NULL;
session_managed /* session_managed */, \
remember_size /* remember_size */, \
FALSE /* remember_if_open */, \
TRUE /* hideable */, \
FALSE /* dockable */}
#define DOCKABLE(id, name, blurb, stock_id, help_id, new_func, view_size, singleton) \
@ -88,6 +90,7 @@ GimpContainer *global_recent_docks = NULL;
FALSE /* session_managed */, \
FALSE /* remember_size */, \
TRUE /* remember_if_open */, \
TRUE /* hideable */, \
TRUE /* dockable */}
#define DOCK(id, new_func) \
@ -102,6 +105,7 @@ GimpContainer *global_recent_docks = NULL;
FALSE /* session_managed */, \
FALSE /* remember_size */, \
FALSE /* remember_if_open */, \
TRUE /* hideable */, \
FALSE /* dockable */}
#define DOCK_WINDOW(id, new_func) \
@ -116,6 +120,7 @@ GimpContainer *global_recent_docks = NULL;
TRUE /* session_managed */, \
TRUE /* remember_size */, \
TRUE /* remember_if_open */, \
TRUE /* hideable */, \
FALSE /* dockable */}
#define LISTGRID(id, name, blurb, stock_id, help_id, view_size) \
@ -130,6 +135,7 @@ GimpContainer *global_recent_docks = NULL;
FALSE /* session_managed */, \
FALSE /* remember_size */, \
TRUE /* remember_if_open */, \
TRUE /* hideable */, \
TRUE /* dockable */}, \
{ "gimp-"#id"-grid" /* identifier */, \
name /* name */, \
@ -142,6 +148,7 @@ GimpContainer *global_recent_docks = NULL;
FALSE /* session_managed */, \
FALSE /* remember_size */, \
TRUE /* remember_if_open */, \
TRUE /* hideable */, \
TRUE /* dockable */}
#define LIST(id, name, blurb, stock_id, help_id, view_size) \
@ -156,6 +163,7 @@ GimpContainer *global_recent_docks = NULL;
FALSE /* session_managed */, \
FALSE /* remember_size */, \
TRUE /* remember_if_open */, \
TRUE /* hideable */, \
TRUE /* dockable */}
@ -357,14 +365,12 @@ dialogs_init (Gimp *gimp,
/* Toplevel */
global_dialog_factory = gimp_dialog_factory_new ("toplevel",
gimp_get_user_context (gimp),
menu_factory,
TRUE);
menu_factory);
/* Display */
global_display_factory = gimp_dialog_factory_new ("display",
gimp_get_user_context (gimp),
menu_factory,
FALSE);
menu_factory);
for (i = 0; i < G_N_ELEMENTS (entries); i++)
@ -380,6 +386,7 @@ dialogs_init (Gimp *gimp,
entries[i].session_managed,
entries[i].remember_size,
entries[i].remember_if_open,
entries[i].hideable,
entries[i].dockable);
gimp_dialog_factory_register_entry (global_display_factory,
@ -392,6 +399,7 @@ dialogs_init (Gimp *gimp,
TRUE,
TRUE,
FALSE,
FALSE,
FALSE);
global_recent_docks = gimp_list_new (GIMP_TYPE_SESSION_INFO, FALSE);

View File

@ -69,8 +69,6 @@ struct _GimpDialogFactoryPrivate
GList *session_infos;
GList *registered_dialogs;
gboolean toggle_visibility;
};
@ -249,8 +247,7 @@ gimp_dialog_factory_finalize (GObject *object)
GimpDialogFactory *
gimp_dialog_factory_new (const gchar *name,
GimpContext *context,
GimpMenuFactory *menu_factory,
gboolean toggle_visibility)
GimpMenuFactory *menu_factory)
{
GimpDialogFactory *factory;
gpointer key;
@ -278,7 +275,6 @@ gimp_dialog_factory_new (const gchar *name,
factory->p->context = context;
factory->p->menu_factory = menu_factory;
factory->p->toggle_visibility = toggle_visibility;
return factory;
}
@ -314,6 +310,7 @@ gimp_dialog_factory_register_entry (GimpDialogFactory *factory,
gboolean session_managed,
gboolean remember_size,
gboolean remember_if_open,
gboolean hideable,
gboolean dockable)
{
GimpDialogFactoryEntry *entry;
@ -334,6 +331,7 @@ gimp_dialog_factory_register_entry (GimpDialogFactory *factory,
entry->session_managed = session_managed ? TRUE : FALSE;
entry->remember_size = remember_size ? TRUE : FALSE;
entry->remember_if_open = remember_if_open ? TRUE : FALSE;
entry->hideable = hideable ? TRUE : FALSE;
entry->dockable = dockable ? TRUE : FALSE;
factory->p->registered_dialogs = g_list_prepend (factory->p->registered_dialogs,
@ -1517,17 +1515,19 @@ gimp_dialog_factories_hide_foreach (gconstpointer key,
{
GList *list;
if (! factory->p->toggle_visibility)
return;
for (list = factory->p->open_dialogs; list; list = g_list_next (list))
{
GtkWidget *widget = list->data;
if (GTK_IS_WIDGET (widget) && gtk_widget_is_toplevel (widget))
{
GimpDialogFactoryEntry *entry = NULL;
GimpDialogVisibilityState visibility = GIMP_DIALOG_VISIBILITY_UNKNOWN;
gimp_dialog_factory_from_widget (widget, &entry);
if (! entry->hideable)
continue;
if (gtk_widget_get_visible (widget))
{
visibility = GIMP_DIALOG_VISIBILITY_VISIBLE;

View File

@ -61,6 +61,9 @@ struct _GimpDialogFactoryEntry
gboolean remember_size;
gboolean remember_if_open;
/* If TRUE the visibility of the dialog is toggleable */
gboolean hideable;
/* If TRUE the entry is for a dockable, FALSE otherwise */
gboolean dockable;
};
@ -107,8 +110,7 @@ struct _GimpDialogFactoryClass
GType gimp_dialog_factory_get_type (void) G_GNUC_CONST;
GimpDialogFactory * gimp_dialog_factory_new (const gchar *name,
GimpContext *context,
GimpMenuFactory *menu_factory,
gboolean toggle_visibility);
GimpMenuFactory *menu_factory);
GimpDialogFactory * gimp_dialog_factory_from_name (const gchar *name);
void gimp_dialog_factory_register_entry (GimpDialogFactory *factory,
const gchar *identifier,
@ -122,6 +124,7 @@ void gimp_dialog_factory_register_entry (GimpDialogFactory
gboolean session_managed,
gboolean remember_size,
gboolean remember_if_open,
gboolean hideable,
gboolean dockable);
GimpDialogFactoryEntry *
gimp_dialog_factory_find_entry (GimpDialogFactory *factory,