Commit 2b0c0513 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

renamed gimp_dialog_factories_idle() and _unidle() to

2003-10-13  Michael Natterer  <mitch@gimp.org>

	* app/widgets/gimpdialogfactory.[ch]: renamed
	gimp_dialog_factories_idle() and _unidle() to
	gimp_dialog_factories_set_busy() and _unset_busy().
	Added utility function gimp_dialog_factory_set_widget_data() and
	public API gimp_dialog_factory_from_widget() so we don't need to
	g_object_[set|get]_data() with magic keys all over the place.

	* app/widgets/gimpsessioninfo.c
	* app/gui/dialogs-commands.c
	* app/gui/dialogs-menu.c
	* app/gui/gui-vtable.c: changed accordingly.

	* app/widgets/gimpsessioninfo.c: remember active page of all dock
	notebooks in sessionrc.

	* app/widgets/gimpsessioninfo.h: cleaned up the session info structs.
parent b687abd5
2003-10-13 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpdialogfactory.[ch]: renamed
gimp_dialog_factories_idle() and _unidle() to
gimp_dialog_factories_set_busy() and _unset_busy().
Added utility function gimp_dialog_factory_set_widget_data() and
public API gimp_dialog_factory_from_widget() so we don't need to
g_object_[set|get]_data() with magic keys all over the place.
* app/widgets/gimpsessioninfo.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-menu.c
* app/gui/gui-vtable.c: changed accordingly.
* app/widgets/gimpsessioninfo.c: remember active page of all dock
notebooks in sessionrc.
* app/widgets/gimpsessioninfo.h: cleaned up the session info structs.
2003-10-13 Sven Neumann <sven@gimp.org>
 
* plug-ins/common/snoise.c: clamp x and y sizes to sane values.
......@@ -201,8 +201,7 @@ dialogs_toggle_view_cmd_callback (GtkWidget *widget,
{
GimpDialogFactoryEntry *entry;
entry = g_object_get_data (G_OBJECT (dockable),
"gimp-dialog-factory-entry");
gimp_dialog_factory_from_widget (GTK_WIDGET (dockable), &entry);
if (entry)
{
......
......@@ -201,8 +201,7 @@ dialogs_toggle_view_cmd_callback (GtkWidget *widget,
{
GimpDialogFactoryEntry *entry;
entry = g_object_get_data (G_OBJECT (dockable),
"gimp-dialog-factory-entry");
gimp_dialog_factory_from_widget (GTK_WIDGET (dockable), &entry);
if (entry)
{
......
......@@ -229,7 +229,7 @@ dialogs_menu_update (GtkItemFactory *factory,
return;
}
entry = g_object_get_data (G_OBJECT (dockable), "gimp-dialog-factory-entry");
gimp_dialog_factory_from_widget (GTK_WIDGET (dockable), &entry);
if (entry)
{
......
......@@ -128,7 +128,7 @@ static void
gui_set_busy (Gimp *gimp)
{
gimp_displays_set_busy (gimp);
gimp_dialog_factories_idle ();
gimp_dialog_factories_set_busy ();
gdk_flush ();
}
......@@ -137,7 +137,7 @@ static void
gui_unset_busy (Gimp *gimp)
{
gimp_displays_unset_busy (gimp);
gimp_dialog_factories_unidle ();
gimp_dialog_factories_unset_busy ();
gdk_flush ();
}
......
......@@ -71,6 +71,9 @@ static void gimp_dialog_factory_init (GimpDialogFactory *factory);
static void gimp_dialog_factory_dispose (GObject *object);
static void gimp_dialog_factory_finalize (GObject *object);
static void gimp_dialog_factory_set_widget_data (GtkWidget *dialog,
GimpDialogFactory *factory,
GimpDialogFactoryEntry *entry);
static gboolean gimp_dialog_factory_set_user_pos (GtkWidget *dialog,
GdkEventConfigure *cevent,
gpointer data);
......@@ -92,10 +95,10 @@ static void gimp_dialog_factories_hide_foreach (gconstpointer key,
static void gimp_dialog_factories_show_foreach (gconstpointer key,
GimpDialogFactory *factory,
gpointer data);
static void gimp_dialog_factories_idle_foreach (gconstpointer key,
static void gimp_dialog_factories_set_busy_foreach (gconstpointer key,
GimpDialogFactory *factory,
gpointer data);
static void gimp_dialog_factories_unidle_foreach (gconstpointer key,
static void gimp_dialog_factories_unset_busy_foreach(gconstpointer key,
GimpDialogFactory *factory,
gpointer data);
......@@ -456,10 +459,7 @@ gimp_dialog_factory_dialog_new_internal (GimpDialogFactory *factory,
if (dialog)
{
g_object_set_data (G_OBJECT (dialog), "gimp-dialog-factory",
factory);
g_object_set_data (G_OBJECT (dialog), "gimp-dialog-factory-entry",
entry);
gimp_dialog_factory_set_widget_data (dialog, factory, entry);
/* If we created a dock before, the newly created dialog is
* supposed to be a GimpDockable.
......@@ -659,7 +659,7 @@ gimp_dialog_factory_dock_new (GimpDialogFactory *factory)
if (dock)
{
g_object_set_data (G_OBJECT (dock), "gimp-dialog-factory", factory);
gimp_dialog_factory_set_widget_data (dock, factory, NULL);
gimp_dialog_factory_add_dialog (factory, dock);
}
......@@ -685,9 +685,7 @@ gimp_dialog_factory_add_dialog (GimpDialogFactory *factory,
return;
}
dialog_factory = g_object_get_data (G_OBJECT (dialog),
"gimp-dialog-factory");
entry = g_object_get_data (G_OBJECT (dialog), "gimp-dialog-factory-entry");
dialog_factory = gimp_dialog_factory_from_widget (dialog, &entry);
if (! (dialog_factory && (entry || GIMP_IS_DOCK (dialog))))
{
......@@ -857,9 +855,7 @@ gimp_dialog_factory_add_foreign (GimpDialogFactory *factory,
g_return_if_fail (GTK_IS_WIDGET (dialog));
g_return_if_fail (GTK_WIDGET_TOPLEVEL (dialog));
dialog_factory = g_object_get_data (G_OBJECT (dialog),
"gimp-dialog-factory");
entry = g_object_get_data (G_OBJECT (dialog), "gimp-dialog-factory-entry");
dialog_factory = gimp_dialog_factory_from_widget (dialog, &entry);
if (dialog_factory || entry)
{
......@@ -884,10 +880,7 @@ gimp_dialog_factory_add_foreign (GimpDialogFactory *factory,
return;
}
g_object_set_data (G_OBJECT (dialog), "gimp-dialog-factory",
factory);
g_object_set_data (G_OBJECT (dialog), "gimp-dialog-factory-entry",
entry);
gimp_dialog_factory_set_widget_data (dialog, factory, entry);
gimp_dialog_factory_add_dialog (factory, dialog);
}
......@@ -912,9 +905,7 @@ gimp_dialog_factory_remove_dialog (GimpDialogFactory *factory,
factory->open_dialogs = g_list_remove (factory->open_dialogs, dialog);
dialog_factory = g_object_get_data (G_OBJECT (dialog),
"gimp-dialog-factory");
entry = g_object_get_data (G_OBJECT (dialog), "gimp-dialog-factory-entry");
dialog_factory = gimp_dialog_factory_from_widget (dialog, &entry);
if (! (dialog_factory && (entry || GIMP_IS_DOCK (dialog))))
{
......@@ -1046,32 +1037,82 @@ gimp_dialog_factories_toggle (GimpDialogFactory *toolbox_factory)
}
void
gimp_dialog_factories_idle (void)
gimp_dialog_factories_set_busy (void)
{
GimpDialogFactoryClass *factory_class;
factory_class = g_type_class_peek (GIMP_TYPE_DIALOG_FACTORY);
g_hash_table_foreach (factory_class->factories,
(GHFunc) gimp_dialog_factories_idle_foreach,
(GHFunc) gimp_dialog_factories_set_busy_foreach,
NULL);
}
void
gimp_dialog_factories_unidle (void)
gimp_dialog_factories_unset_busy (void)
{
GimpDialogFactoryClass *factory_class;
factory_class = g_type_class_peek (GIMP_TYPE_DIALOG_FACTORY);
g_hash_table_foreach (factory_class->factories,
(GHFunc) gimp_dialog_factories_unidle_foreach,
(GHFunc) gimp_dialog_factories_unset_busy_foreach,
NULL);
}
static GQuark gimp_dialog_factory_key = 0;
static GQuark gimp_dialog_factory_entry_key = 0;
GimpDialogFactory *
gimp_dialog_factory_from_widget (GtkWidget *dialog,
GimpDialogFactoryEntry **entry)
{
g_return_val_if_fail (GTK_IS_WIDGET (dialog), NULL);
if (! gimp_dialog_factory_key)
{
gimp_dialog_factory_key =
g_quark_from_static_string ("gimp-dialog-factory");
gimp_dialog_factory_entry_key =
g_quark_from_static_string ("gimp-dialog-factory-entry");
}
if (entry)
*entry = g_object_get_qdata (G_OBJECT (dialog),
gimp_dialog_factory_entry_key);
return g_object_get_qdata (G_OBJECT (dialog), gimp_dialog_factory_key);
}
/* private functions */
void
gimp_dialog_factory_set_widget_data (GtkWidget *dialog,
GimpDialogFactory *factory,
GimpDialogFactoryEntry *entry)
{
g_return_if_fail (GTK_IS_WIDGET (dialog));
g_return_if_fail (GIMP_IS_DIALOG_FACTORY (factory));
if (! gimp_dialog_factory_key)
{
gimp_dialog_factory_key =
g_quark_from_static_string ("gimp-dialog-factory");
gimp_dialog_factory_entry_key =
g_quark_from_static_string ("gimp-dialog-factory-entry");
}
g_object_set_qdata (G_OBJECT (dialog), gimp_dialog_factory_key, factory);
if (entry)
g_object_set_qdata (G_OBJECT (dialog), gimp_dialog_factory_entry_key,
entry);
}
static gboolean
gimp_dialog_factory_set_user_pos (GtkWidget *dialog,
GdkEventConfigure *cevent,
......@@ -1094,7 +1135,6 @@ gimp_dialog_factory_dialog_configure (GtkWidget *dialog,
{
GimpDialogFactory *dialog_factory;
GimpDialogFactoryEntry *entry;
GimpSessionInfo *session_info;
GList *list;
if (! g_list_find (factory->open_dialogs, dialog))
......@@ -1103,9 +1143,7 @@ gimp_dialog_factory_dialog_configure (GtkWidget *dialog,
return FALSE;
}
dialog_factory = g_object_get_data (G_OBJECT (dialog),
"gimp-dialog-factory");
entry = g_object_get_data (G_OBJECT (dialog), "gimp-dialog-factory-entry");
dialog_factory = gimp_dialog_factory_from_widget (dialog, &entry);
if (! dialog_factory || ! entry)
{
......@@ -1123,7 +1161,7 @@ gimp_dialog_factory_dialog_configure (GtkWidget *dialog,
for (list = factory->session_infos; list; list = g_list_next (list))
{
session_info = (GimpSessionInfo *) list->data;
GimpSessionInfo *session_info = list->data;
if (session_info->widget == dialog)
{
......@@ -1200,6 +1238,9 @@ gimp_dialog_factories_clear_foreach (gconstpointer key,
}
}
#define GIMP_DIALOG_VISIBILITY_KEY "gimp-dialog-visibility"
static void
gimp_dialog_factories_hide_foreach (gconstpointer key,
GimpDialogFactory *factory,
......@@ -1225,7 +1266,7 @@ gimp_dialog_factories_hide_foreach (gconstpointer key,
}
g_object_set_data (G_OBJECT (list->data),
"gimp-dialog-visibility",
GIMP_DIALOG_VISIBILITY_KEY,
GINT_TO_POINTER (visibility));
}
}
......@@ -1246,7 +1287,7 @@ gimp_dialog_factories_show_foreach (gconstpointer key,
visibility =
GPOINTER_TO_INT (g_object_get_data (G_OBJECT (list->data),
"gimp-dialog-visibility"));
GIMP_DIALOG_VISIBILITY_KEY));
if (! GTK_WIDGET_VISIBLE (list->data) &&
visibility == GIMP_DIALOG_VISIBILITY_VISIBLE)
......@@ -1258,9 +1299,9 @@ gimp_dialog_factories_show_foreach (gconstpointer key,
}
static void
gimp_dialog_factories_idle_foreach (gconstpointer key,
GimpDialogFactory *factory,
gpointer data)
gimp_dialog_factories_set_busy_foreach (gconstpointer key,
GimpDialogFactory *factory,
gpointer data)
{
GdkCursor *cursor;
GList *list;
......@@ -1283,9 +1324,9 @@ gimp_dialog_factories_idle_foreach (gconstpointer key,
}
static void
gimp_dialog_factories_unidle_foreach (gconstpointer key,
GimpDialogFactory *factory,
gpointer data)
gimp_dialog_factories_unset_busy_foreach (gconstpointer key,
GimpDialogFactory *factory,
gpointer data)
{
GList *list;
......
......@@ -128,8 +128,12 @@ void gimp_dialog_factories_session_clear (void);
void gimp_dialog_factories_toggle (GimpDialogFactory *toolbox_factory);
void gimp_dialog_factories_idle (void);
void gimp_dialog_factories_unidle (void);
void gimp_dialog_factories_set_busy (void);
void gimp_dialog_factories_unset_busy (void);
GimpDialogFactory *
gimp_dialog_factory_from_widget (GtkWidget *dialog,
GimpDialogFactoryEntry **entry);
#endif /* __GIMP_DIALOG_FACTORY_H__ */
......@@ -51,6 +51,7 @@ enum
SESSION_INFO_BOOK,
SESSION_INFO_BOOK_POSITION,
SESSION_INFO_BOOK_CURRENT_PAGE,
SESSION_INFO_DOCKABLE,
SESSION_INFO_DOCKABLE_TAB_STYLE,
......@@ -83,7 +84,7 @@ gimp_session_info_free (GimpSessionInfo *info)
if (info->aux_info)
{
g_list_foreach (info->aux_info, (GFunc) g_free, NULL);
g_list_foreach (info->aux_info, (GFunc) gimp_session_info_aux_free, NULL);
g_list_free (info->aux_info);
}
......@@ -121,7 +122,8 @@ gimp_session_info_dockable_free (GimpSessionInfoDockable *dockable)
if (dockable->aux_info)
{
g_list_foreach (dockable->aux_info, (GFunc) g_free, NULL);
g_list_foreach (dockable->aux_info, (GFunc) gimp_session_info_aux_free,
NULL);
g_list_free (dockable->aux_info);
}
......@@ -244,6 +246,7 @@ gimp_session_info_save (GimpSessionInfo *info,
GimpDockbook *dockbook = books->data;
GList *children;
GList *pages;
gint current_page;
gimp_config_writer_open (writer, "book");
......@@ -260,6 +263,12 @@ gimp_session_info_save (GimpSessionInfo *info,
}
}
current_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (dockbook));
gimp_config_writer_open (writer, "current-page");
gimp_config_writer_printf (writer, "%d", current_page);
gimp_config_writer_close (writer);
children = gtk_container_get_children (GTK_CONTAINER (dockbook));
for (pages = children; pages; pages = g_list_next (pages))
......@@ -267,8 +276,7 @@ gimp_session_info_save (GimpSessionInfo *info,
GimpDockable *dockable = pages->data;
GimpDialogFactoryEntry *entry;
entry = g_object_get_data (G_OBJECT (dockable),
"gimp-dialog-factory-entry");
gimp_dialog_factory_from_widget (GTK_WIDGET (dockable), &entry);
if (entry)
{
......@@ -374,6 +382,8 @@ gimp_session_info_deserialize (GScanner *scanner,
g_scanner_scope_add_symbol (scanner, SESSION_INFO_BOOK, "position",
GINT_TO_POINTER (SESSION_INFO_BOOK_POSITION));
g_scanner_scope_add_symbol (scanner, SESSION_INFO_BOOK, "current-page",
GINT_TO_POINTER (SESSION_INFO_BOOK_CURRENT_PAGE));
g_scanner_scope_add_symbol (scanner, SESSION_INFO_BOOK, "dockable",
GINT_TO_POINTER (SESSION_INFO_DOCKABLE));
......@@ -506,6 +516,7 @@ gimp_session_info_deserialize (GScanner *scanner,
g_scanner_scope_remove_symbol (scanner, SESSION_INFO_DOCK, "book");
g_scanner_scope_remove_symbol (scanner, SESSION_INFO_BOOK, "position");
g_scanner_scope_remove_symbol (scanner, SESSION_INFO_BOOK, "current-page");
g_scanner_scope_remove_symbol (scanner, SESSION_INFO_BOOK, "dockable");
g_scanner_scope_remove_symbol (scanner, SESSION_INFO_DOCKABLE, "tab-style");
......@@ -606,6 +617,14 @@ gimp_session_info_restore (GimpSessionInfo *info,
gimp_dockbook_add (GIMP_DOCKBOOK (dockbook),
GIMP_DOCKABLE (dockable), -1);
}
if ((book_info->current_page > 0) &&
(book_info->current_page <
gtk_notebook_get_n_pages (GTK_NOTEBOOK (dockbook))))
{
gtk_notebook_set_current_page (GTK_NOTEBOOK (dockbook),
book_info->current_page);
}
}
for (books = info->books; books; books = g_list_next (books))
......@@ -776,6 +795,12 @@ session_info_book_deserialize (GScanner *scanner,
goto error;
break;
case SESSION_INFO_BOOK_CURRENT_PAGE:
token = G_TOKEN_INT;
if (! gimp_scanner_parse_int (scanner, &book->current_page))
goto error;
break;
case SESSION_INFO_DOCKABLE:
g_scanner_set_scope (scanner, SESSION_INFO_DOCKABLE);
token = session_info_dockable_deserialize (scanner, book);
......
......@@ -29,27 +29,30 @@ struct _GimpSessionInfo
gint y;
gint width;
gint height;
GtkWidget *widget;
/* only valid while restoring and saving the session */
gboolean open;
gboolean open; /* only valid while restoring and saving the session */
/* dialog specific list of GimpSessionInfoAux */
GList *aux_info; /* dialog specific list of GimpSessionInfoAux */
GList *aux_info;
GtkWidget *widget;
/* only one of these is valid */
GimpDialogFactoryEntry *toplevel_entry;
GimpDialogFactoryEntry *dockable_entry;
GList *books; /* GList of GimpSessionInfoBook */
/* list of GimpSessionInfoBook */
GList *books;
};
struct _GimpSessionInfoBook
{
gint position;
GList *dockables; /* GList of GimpSessionInfoDockable */
gint current_page;
GtkWidget *widget;
GtkWidget *widget; /* only used while restoring the session */
/* list of GimpSessionInfoDockable */
GList *dockables;
};
struct _GimpSessionInfoDockable
......@@ -58,7 +61,6 @@ struct _GimpSessionInfoDockable
GimpTabStyle tab_style;
gint preview_size;
/* dialog specific list of GimpSessionInfoAux */
GList *aux_info;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment