[gimp] app: Add GimpSessionInfo getters and setters
- From: Martin Nordholts <martinn src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gimp] app: Add GimpSessionInfo getters and setters
- Date: Sun, 20 Sep 2009 15:04:47 +0000 (UTC)
commit 8bfcd14f9a2282d59b26494aeba02d0db9283060
Author: Martin Nordholts <martinn src gnome org>
Date: Sun Sep 20 14:51:03 2009 +0200
app: Add GimpSessionInfo getters and setters
app/actions/context-commands.c | 8 ++--
app/display/gimpdisplayshell-cursor.c | 8 ++--
app/display/gimpdisplayshell.c | 4 +-
app/gui/gui-message.c | 4 +-
app/gui/gui.c | 4 +-
app/gui/session.c | 21 ++++++---
app/tools/gimpcolortool.c | 8 ++--
app/widgets/gimpdialogfactory.c | 64 +++++++++++++++-------------
app/widgets/gimpdockwindow.c | 4 +-
app/widgets/gimpsessioninfo.c | 74 +++++++++++++++++++++++++++++++++
app/widgets/gimpsessioninfo.h | 37 +++++++++++-----
11 files changed, 167 insertions(+), 69 deletions(-)
---
diff --git a/app/actions/context-commands.c b/app/actions/context-commands.c
index 3a08c3a..068cd8c 100644
--- a/app/actions/context-commands.c
+++ b/app/actions/context-commands.c
@@ -871,8 +871,8 @@ context_get_palette_editor (void)
info = gimp_dialog_factory_find_session_info (dialog_factory,
"gimp-palette-editor");
- if (info && info->widget)
- return GIMP_PALETTE_EDITOR (gtk_bin_get_child (GTK_BIN (info->widget)));
+ if (info && gimp_session_info_get_widget (info))
+ return GIMP_PALETTE_EDITOR (gtk_bin_get_child (GTK_BIN (gimp_session_info_get_widget (info))));
return NULL;
}
@@ -889,8 +889,8 @@ context_get_colormap_editor (void)
info = gimp_dialog_factory_find_session_info (dialog_factory,
"gimp-indexed-palette");
- if (info && info->widget)
- return GIMP_COLORMAP_EDITOR (gtk_bin_get_child (GTK_BIN (info->widget)));
+ if (info && gimp_session_info_get_widget (info))
+ return GIMP_COLORMAP_EDITOR (gtk_bin_get_child (GTK_BIN (gimp_session_info_get_widget (info))));
return NULL;
}
diff --git a/app/display/gimpdisplayshell-cursor.c b/app/display/gimpdisplayshell-cursor.c
index 9aa7acb..d20ddbd 100644
--- a/app/display/gimpdisplayshell-cursor.c
+++ b/app/display/gimpdisplayshell-cursor.c
@@ -165,11 +165,11 @@ gimp_display_shell_update_cursor (GimpDisplayShell *shell,
factory = gimp_dialog_factory_from_name ("dock");
session_info = gimp_dialog_factory_find_session_info (factory,
"gimp-cursor-view");
- if (session_info && session_info->widget)
+ if (session_info && gimp_session_info_get_widget (session_info))
{
GtkWidget *cursor_view;
- cursor_view = gtk_bin_get_child (GTK_BIN (session_info->widget));
+ cursor_view = gtk_bin_get_child (GTK_BIN (gimp_session_info_get_widget (session_info)));
if (cursor_view)
{
@@ -201,11 +201,11 @@ gimp_display_shell_clear_cursor (GimpDisplayShell *shell)
factory = gimp_dialog_factory_from_name ("dock");
session_info = gimp_dialog_factory_find_session_info (factory,
"gimp-cursor-view");
- if (session_info && session_info->widget)
+ if (session_info && gimp_session_info_get_widget (session_info))
{
GtkWidget *cursor_view;
- cursor_view = gtk_bin_get_child (GTK_BIN (session_info->widget));
+ cursor_view = gtk_bin_get_child (GTK_BIN (gimp_session_info_get_widget (session_info)));
if (cursor_view)
gimp_cursor_view_clear_cursor (GIMP_CURSOR_VIEW (cursor_view));
diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c
index cb2b27d..37435a1 100644
--- a/app/display/gimpdisplayshell.c
+++ b/app/display/gimpdisplayshell.c
@@ -1428,8 +1428,8 @@ gimp_display_shell_empty (GimpDisplayShell *shell)
if (session_info)
{
- width = session_info->width;
- height = session_info->height;
+ width = gimp_session_info_get_width (session_info);
+ height = gimp_session_info_get_height (session_info);
}
else
{
diff --git a/app/gui/gui-message.c b/app/gui/gui-message.c
index c6b3879..0763e3e 100644
--- a/app/gui/gui-message.c
+++ b/app/gui/gui-message.c
@@ -105,8 +105,8 @@ gui_message_error_console (GimpMessageSeverity severity,
info = gimp_dialog_factory_find_session_info (global_dock_factory,
"gimp-error-console");
- if (info && GIMP_IS_DOCKABLE (info->widget))
- dockable = info->widget;
+ if (info && GIMP_IS_DOCKABLE (gimp_session_info_get_widget (info)))
+ dockable = gimp_session_info_get_widget (info);
}
if (! dockable)
diff --git a/app/gui/gui.c b/app/gui/gui.c
index aced289..af3b9c4 100644
--- a/app/gui/gui.c
+++ b/app/gui/gui.c
@@ -675,11 +675,11 @@ gui_device_change_notify (Gimp *gimp)
session_info = gimp_dialog_factory_find_session_info (global_dock_factory,
"gimp-device-status");
- if (session_info && session_info->widget)
+ if (session_info && gimp_session_info_get_widget (session_info))
{
GtkWidget *device_status;
- device_status = gtk_bin_get_child (GTK_BIN (session_info->widget));
+ device_status = gtk_bin_get_child (GTK_BIN (gimp_session_info_get_widget (session_info)));
gimp_device_status_update (GIMP_DEVICE_STATUS (device_status));
}
diff --git a/app/gui/session.c b/app/gui/session.c
index 710dcee..b8c72ff 100644
--- a/app/gui/session.c
+++ b/app/gui/session.c
@@ -153,13 +153,20 @@ session_init (Gimp *gimp)
*/
if (!g_str_equal (entry_name, "dock"))
{
- info->factory_entry = gimp_dialog_factory_find_entry (factory,
- entry_name);
-
- /* If we expected a dialog factory entry but failed
- * to find one, skip to add this session info object
- */
- skip = (info->factory_entry == NULL);
+ GimpDialogFactoryEntry *entry =
+ gimp_dialog_factory_find_entry (factory,
+ entry_name);
+ if (entry)
+ {
+ gimp_session_info_set_factory_entry (info, entry);
+ }
+ else
+ {
+ /* If we expected a dialog factory entry but failed
+ * to find one, skip to add this session info object
+ */
+ skip = TRUE;
+ }
}
g_free (entry_name);
diff --git a/app/tools/gimpcolortool.c b/app/tools/gimpcolortool.c
index 51d1415..4f57dee 100644
--- a/app/tools/gimpcolortool.c
+++ b/app/tools/gimpcolortool.c
@@ -646,11 +646,11 @@ gimp_color_tool_real_picked (GimpColorTool *color_tool,
{
info = gimp_dialog_factory_find_session_info (dialog_factory,
"gimp-indexed-palette");
- if (info && info->widget)
+ if (info && gimp_session_info_get_widget (info))
{
GimpColormapEditor *editor;
- editor = GIMP_COLORMAP_EDITOR (gtk_bin_get_child (GTK_BIN (info->widget)));
+ editor = GIMP_COLORMAP_EDITOR (gtk_bin_get_child (GTK_BIN (gimp_session_info_get_widget (info))));
gimp_colormap_editor_set_index (editor, color_index, NULL);
}
@@ -660,12 +660,12 @@ gimp_color_tool_real_picked (GimpColorTool *color_tool,
{
info = gimp_dialog_factory_find_session_info (dialog_factory,
"gimp-palette-editor");
- if (info && info->widget)
+ if (info && gimp_session_info_get_widget (info))
{
GimpPaletteEditor *editor;
gint index;
- editor = GIMP_PALETTE_EDITOR (gtk_bin_get_child (GTK_BIN (info->widget)));
+ editor = GIMP_PALETTE_EDITOR (gtk_bin_get_child (GTK_BIN (gimp_session_info_get_widget (info))));
index = gimp_palette_editor_get_index (editor, color);
if (index != -1)
diff --git a/app/widgets/gimpdialogfactory.c b/app/widgets/gimpdialogfactory.c
index cff0ef2..5b9b3cf 100644
--- a/app/widgets/gimpdialogfactory.c
+++ b/app/widgets/gimpdialogfactory.c
@@ -387,8 +387,9 @@ gimp_dialog_factory_find_session_info (GimpDialogFactory *factory,
{
GimpSessionInfo *info = list->data;
- if (info->factory_entry &&
- g_str_equal (identifier, info->factory_entry->identifier))
+ if (gimp_session_info_get_factory_entry (info) &&
+ g_str_equal (identifier,
+ gimp_session_info_get_factory_entry (info)->identifier))
{
return info;
}
@@ -472,7 +473,7 @@ gimp_dialog_factory_dialog_new_internal (GimpDialogFactory *factory,
info = gimp_dialog_factory_find_session_info (factory, identifier);
if (info)
- dialog = info->widget;
+ dialog = gimp_session_info_get_widget (info);
}
/* create the dialog if it was not found */
@@ -682,7 +683,7 @@ gimp_dialog_factory_dialog_raise (GimpDialogFactory *factory,
GimpSessionInfo *info;
info = gimp_dialog_factory_find_session_info (factory, ids[i]);
- if (info && info->widget)
+ if (info && gimp_session_info_get_widget (info))
break;
}
@@ -821,9 +822,9 @@ gimp_dialog_factory_add_dialog (GimpDialogFactory *factory,
{
GimpSessionInfo *current_info = list->data;
- if (current_info->factory_entry == entry)
+ if (gimp_session_info_get_factory_entry (current_info) == entry)
{
- if (current_info->widget)
+ if (gimp_session_info_get_widget (current_info))
{
if (gimp_session_info_is_singleton (current_info))
{
@@ -832,7 +833,8 @@ gimp_dialog_factory_add_dialog (GimpDialogFactory *factory,
GIMP_LOG (DIALOG_FACTORY,
"corrupt session info: %p (widget %p)",
- current_info, current_info->widget);
+ current_info,
+ gimp_session_info_get_widget (current_info));
return;
}
@@ -840,11 +842,11 @@ gimp_dialog_factory_add_dialog (GimpDialogFactory *factory,
continue;
}
- current_info->widget = dialog;
+ gimp_session_info_set_widget (current_info, dialog);
GIMP_LOG (DIALOG_FACTORY,
"updating session info %p (widget %p) for %s \"%s\"",
- current_info, current_info->widget,
+ current_info, gimp_session_info_get_widget (current_info),
toplevel ? "toplevel" : "dockable",
entry->identifier);
@@ -864,15 +866,15 @@ gimp_dialog_factory_add_dialog (GimpDialogFactory *factory,
{
info = gimp_session_info_new ();
- info->widget = dialog;
+ gimp_session_info_set_widget (info, dialog);
GIMP_LOG (DIALOG_FACTORY,
"creating session info %p (widget %p) for %s \"%s\"",
- info, info->widget,
+ info, gimp_session_info_get_widget (info),
toplevel ? "toplevel" : "dockable",
entry->identifier);
- info->factory_entry = entry;
+ gimp_session_info_set_factory_entry (info, entry);
/* if we create a new session info, we never call
* gimp_session_info_apply_geometry(), but still the
@@ -896,14 +898,14 @@ gimp_dialog_factory_add_dialog (GimpDialogFactory *factory,
GimpSessionInfo *current_info = list->data;
/* take the first empty slot */
- if (! current_info->factory_entry &&
- ! current_info->widget)
+ if (! gimp_session_info_get_factory_entry (current_info) &&
+ ! gimp_session_info_get_widget (current_info))
{
- current_info->widget = dialog;
+ gimp_session_info_set_widget (current_info, dialog);
GIMP_LOG (DIALOG_FACTORY,
"updating session info %p (widget %p) for dock",
- current_info, current_info->widget);
+ current_info, gimp_session_info_get_widget (current_info));
gimp_session_info_apply_geometry (current_info);
@@ -917,11 +919,11 @@ gimp_dialog_factory_add_dialog (GimpDialogFactory *factory,
{
info = gimp_session_info_new ();
- info->widget = dialog;
+ gimp_session_info_set_widget (info, dialog);
GIMP_LOG (DIALOG_FACTORY,
"creating session info %p (widget %p) for dock",
- info, info->widget);
+ info, gimp_session_info_get_widget (info));
/* let new docks appear at the pointer position */
gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
@@ -1032,14 +1034,14 @@ gimp_dialog_factory_remove_dialog (GimpDialogFactory *factory,
{
GimpSessionInfo *session_info = list->data;
- if (session_info->widget == dialog)
+ if (gimp_session_info_get_widget (session_info) == dialog)
{
GIMP_LOG (DIALOG_FACTORY,
"clearing session info %p (widget %p) for \"%s\"",
- session_info, session_info->widget,
+ session_info, gimp_session_info_get_widget (session_info),
entry ? entry->identifier : "dock");
- session_info->widget = NULL;
+ gimp_session_info_set_widget (session_info, NULL);
gimp_dialog_factory_unset_widget_data (dialog);
@@ -1375,7 +1377,7 @@ gimp_dialog_factory_dialog_configure (GtkWidget *dialog,
{
GimpSessionInfo *session_info = list->data;
- if (session_info->widget == dialog)
+ if (gimp_session_info_get_widget (session_info) == dialog)
{
gimp_session_info_read_geometry (session_info);
@@ -1383,8 +1385,10 @@ gimp_dialog_factory_dialog_configure (GtkWidget *dialog,
"updated session info for \"%s\" from window geometry "
"(x=%d y=%d %dx%d)",
entry ? entry->identifier : "dock",
- session_info->x, session_info->y,
- session_info->width, session_info->height);
+ gimp_session_info_get_x (session_info),
+ gimp_session_info_get_y (session_info),
+ gimp_session_info_get_width (session_info),
+ gimp_session_info_get_height (session_info));
break;
}
@@ -1411,15 +1415,15 @@ gimp_dialog_factories_save_foreach (gconstpointer key,
if (! gimp_session_info_is_session_managed (info))
continue;
- if (info->widget)
+ if (gimp_session_info_get_widget (info))
gimp_session_info_get_info (info);
gimp_config_writer_open (writer, "session-info");
gimp_config_writer_string (writer,
gimp_object_get_name (factory));
gimp_config_writer_string (writer,
- info->factory_entry ?
- info->factory_entry->identifier :
+ gimp_session_info_get_factory_entry (info) ?
+ gimp_session_info_get_factory_entry (info)->identifier :
"dock");
GIMP_CONFIG_GET_INTERFACE (info)->serialize (GIMP_CONFIG (info),
@@ -1428,7 +1432,7 @@ gimp_dialog_factories_save_foreach (gconstpointer key,
gimp_config_writer_close (writer);
- if (info->widget)
+ if (gimp_session_info_get_widget (info))
gimp_session_info_clear_info (info);
}
}
@@ -1444,7 +1448,7 @@ gimp_dialog_factories_restore_foreach (gconstpointer key,
{
GimpSessionInfo *info = infos->data;
- if (info->open)
+ if (gimp_session_info_get_open (info))
{
gimp_session_info_restore (info, factory);
gimp_session_info_clear_info (info);
@@ -1463,7 +1467,7 @@ gimp_dialog_factories_clear_foreach (gconstpointer key,
{
GimpSessionInfo *info = list->data;
- if (info->widget)
+ if (gimp_session_info_get_widget (info))
continue;
/* FIXME: implement session info deletion */
diff --git a/app/widgets/gimpdockwindow.c b/app/widgets/gimpdockwindow.c
index 9973a55..d8f073a 100644
--- a/app/widgets/gimpdockwindow.c
+++ b/app/widgets/gimpdockwindow.c
@@ -434,9 +434,9 @@ gimp_dock_window_delete_event (GtkWidget *widget,
gimp_object_set_name (GIMP_OBJECT (info),
gtk_window_get_title (GTK_WINDOW (dock_window)));
- info->widget = GTK_WIDGET (dock);
+ gimp_session_info_set_widget (info, GTK_WIDGET (dock));
gimp_session_info_get_info (info);
- info->widget = NULL;
+ gimp_session_info_set_widget (info, NULL);
gimp_container_add (global_recent_docks, GIMP_OBJECT (info));
g_object_unref (info);
diff --git a/app/widgets/gimpsessioninfo.c b/app/widgets/gimpsessioninfo.c
index 55bbd26..b2ee187 100644
--- a/app/widgets/gimpsessioninfo.c
+++ b/app/widgets/gimpsessioninfo.c
@@ -654,3 +654,77 @@ gimp_session_info_get_remember_if_open (GimpSessionInfo *info)
(info->factory_entry &&
info->factory_entry->remember_if_open));
}
+
+GtkWidget *
+gimp_session_info_get_widget (GimpSessionInfo *info)
+{
+ g_return_val_if_fail (GIMP_IS_SESSION_INFO (info), FALSE);
+
+ return info->widget;
+}
+
+void
+gimp_session_info_set_widget (GimpSessionInfo *info,
+ GtkWidget *widget)
+{
+ g_return_if_fail (GIMP_IS_SESSION_INFO (info));
+
+ info->widget = widget;
+}
+
+GimpDialogFactoryEntry *
+gimp_session_info_get_factory_entry (GimpSessionInfo *info)
+{
+ g_return_val_if_fail (GIMP_IS_SESSION_INFO (info), FALSE);
+
+ return info->factory_entry;
+}
+
+void
+gimp_session_info_set_factory_entry (GimpSessionInfo *info,
+ GimpDialogFactoryEntry *entry)
+{
+ g_return_if_fail (GIMP_IS_SESSION_INFO (info));
+
+ info->factory_entry = entry;
+}
+
+gboolean
+gimp_session_info_get_open (GimpSessionInfo *info)
+{
+ g_return_val_if_fail (GIMP_IS_SESSION_INFO (info), FALSE);
+
+ return info->open;
+}
+
+gint
+gimp_session_info_get_x (GimpSessionInfo *info)
+{
+ g_return_val_if_fail (GIMP_IS_SESSION_INFO (info), 0);
+
+ return info->x;
+}
+
+gint
+gimp_session_info_get_y (GimpSessionInfo *info)
+{
+ g_return_val_if_fail (GIMP_IS_SESSION_INFO (info), 0);
+
+ return info->y;
+}
+
+gint
+gimp_session_info_get_width (GimpSessionInfo *info)
+{
+ g_return_val_if_fail (GIMP_IS_SESSION_INFO (info), 0);
+
+ return info->width;
+}
+
+gint
+gimp_session_info_get_height (GimpSessionInfo *info)
+{
+ g_return_val_if_fail (GIMP_IS_SESSION_INFO (info), 0);
+
+ return info->height;
+}
diff --git a/app/widgets/gimpsessioninfo.h b/app/widgets/gimpsessioninfo.h
index 124976b..7c6d494 100644
--- a/app/widgets/gimpsessioninfo.h
+++ b/app/widgets/gimpsessioninfo.h
@@ -74,18 +74,31 @@ struct _GimpSessionInfoClass
};
-GType gimp_session_info_get_type (void) G_GNUC_CONST;
-GimpSessionInfo * gimp_session_info_new (void);
-void gimp_session_info_restore (GimpSessionInfo *info,
- GimpDialogFactory *factory);
-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_clear_info (GimpSessionInfo *info);
-gboolean gimp_session_info_is_singleton (GimpSessionInfo *info);
-gboolean gimp_session_info_is_session_managed (GimpSessionInfo *info);
-gboolean gimp_session_info_get_remember_size (GimpSessionInfo *info);
-gboolean gimp_session_info_get_remember_if_open (GimpSessionInfo *info);
+GType gimp_session_info_get_type (void) G_GNUC_CONST;
+GimpSessionInfo * gimp_session_info_new (void);
+void gimp_session_info_restore (GimpSessionInfo *info,
+ GimpDialogFactory *factory);
+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_clear_info (GimpSessionInfo *info);
+gboolean gimp_session_info_is_singleton (GimpSessionInfo *info);
+gboolean gimp_session_info_is_session_managed (GimpSessionInfo *info);
+gboolean gimp_session_info_get_remember_size (GimpSessionInfo *info);
+gboolean gimp_session_info_get_remember_if_open (GimpSessionInfo *info);
+GtkWidget * gimp_session_info_get_widget (GimpSessionInfo *info);
+void gimp_session_info_set_widget (GimpSessionInfo *info,
+ GtkWidget *widget);
+GimpDialogFactoryEntry * gimp_session_info_get_factory_entry (GimpSessionInfo *info);
+void gimp_session_info_set_factory_entry (GimpSessionInfo *info,
+ GimpDialogFactoryEntry *entry);
+gboolean gimp_session_info_get_open (GimpSessionInfo *info);
+void gimp_session_info_append_book (GimpSessionInfo *info,
+ GimpSessionInfoBook *book);
+gint gimp_session_info_get_x (GimpSessionInfo *info);
+gint gimp_session_info_get_y (GimpSessionInfo *info);
+gint gimp_session_info_get_width (GimpSessionInfo *info);
+gint gimp_session_info_get_height (GimpSessionInfo *info);
#endif /* __GIMP_SESSION_INFO_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]