[gimp] app: Add and use gimp_dialog_factory_find_widget()
- From: Martin Nordholts <martinn src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: Add and use gimp_dialog_factory_find_widget()
- Date: Tue, 10 Jan 2012 18:48:32 +0000 (UTC)
commit 64d2dc122a8f98d33af6e20805c4e1279cf518c0
Author: Martin Nordholts <martinn src gnome org>
Date: Tue Jan 10 19:33:42 2012 +0100
app: Add and use gimp_dialog_factory_find_widget()
app/actions/context-commands.c | 20 ++++++++++----------
app/actions/dialogs-actions.c | 5 ++---
app/display/gimpdisplayshell-cursor.c | 22 +++++++++++-----------
app/gui/gui-message.c | 12 +++++-------
app/tools/gimpcolortool.c | 18 +++++++++---------
app/widgets/gimpdialogfactory.c | 29 +++++++++++++++++++----------
app/widgets/gimpdialogfactory.h | 2 ++
7 files changed, 58 insertions(+), 50 deletions(-)
---
diff --git a/app/actions/context-commands.c b/app/actions/context-commands.c
index 88464a1..98de785 100644
--- a/app/actions/context-commands.c
+++ b/app/actions/context-commands.c
@@ -868,14 +868,14 @@ context_set_color_index (gint index,
static GimpPaletteEditor *
context_get_palette_editor (void)
{
- GimpSessionInfo *info = NULL;
+ GtkWidget *widget;
g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (gimp_dialog_factory_get_singleton ()), NULL);
- info = gimp_dialog_factory_find_session_info (gimp_dialog_factory_get_singleton (),
- "gimp-palette-editor");
- if (info && gimp_session_info_get_widget (info))
- return GIMP_PALETTE_EDITOR (gtk_bin_get_child (GTK_BIN (gimp_session_info_get_widget (info))));
+ widget = gimp_dialog_factory_find_widget (gimp_dialog_factory_get_singleton (),
+ "gimp-palette-editor");
+ if (widget)
+ return GIMP_PALETTE_EDITOR (gtk_bin_get_child (GTK_BIN (widget)));
return NULL;
}
@@ -883,14 +883,14 @@ context_get_palette_editor (void)
static GimpColormapEditor *
context_get_colormap_editor (void)
{
- GimpSessionInfo *info = NULL;
+ GtkWidget *widget;
g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (gimp_dialog_factory_get_singleton ()), NULL);
- info = gimp_dialog_factory_find_session_info (gimp_dialog_factory_get_singleton (),
- "gimp-indexed-palette");
- if (info && gimp_session_info_get_widget (info))
- return GIMP_COLORMAP_EDITOR (gtk_bin_get_child (GTK_BIN (gimp_session_info_get_widget (info))));
+ widget = gimp_dialog_factory_find_widget (gimp_dialog_factory_get_singleton (),
+ "gimp-indexed-palette");
+ if (widget)
+ return GIMP_COLORMAP_EDITOR (gtk_bin_get_child (GTK_BIN (widget)));
return NULL;
}
diff --git a/app/actions/dialogs-actions.c b/app/actions/dialogs-actions.c
index 5321e3d..535b87f 100644
--- a/app/actions/dialogs-actions.c
+++ b/app/actions/dialogs-actions.c
@@ -272,13 +272,12 @@ static gboolean
dialogs_actions_toolbox_exists (Gimp *gimp)
{
GimpDialogFactory *factory = gimp_dialog_factory_get_singleton ();
- GimpSessionInfo *info = NULL;
gboolean toolbox_found = FALSE;
GList *iter;
/* First look in session managed windows */
- info = gimp_dialog_factory_find_session_info (factory, "gimp-toolbox-window");
- toolbox_found = info && gimp_session_info_get_widget (info);
+ toolbox_found =
+ gimp_dialog_factory_find_widget (factory, "gimp-toolbox-window") != NULL;
/* Then in image windows */
if (! toolbox_found)
diff --git a/app/display/gimpdisplayshell-cursor.c b/app/display/gimpdisplayshell-cursor.c
index b7087cb..9c23e3d 100644
--- a/app/display/gimpdisplayshell-cursor.c
+++ b/app/display/gimpdisplayshell-cursor.c
@@ -126,7 +126,7 @@ gimp_display_shell_update_software_cursor (GimpDisplayShell *shell,
gdouble image_y)
{
GimpStatusbar *statusbar;
- GimpSessionInfo *session_info;
+ GtkWidget *widget;
GimpImage *image;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
@@ -159,13 +159,13 @@ gimp_display_shell_update_software_cursor (GimpDisplayShell *shell,
gimp_statusbar_update_cursor (statusbar, precision, image_x, image_y);
- session_info = gimp_dialog_factory_find_session_info (gimp_dialog_factory_get_singleton (),
- "gimp-cursor-view");
- if (session_info && gimp_session_info_get_widget (session_info))
+ widget = gimp_dialog_factory_find_widget (gimp_dialog_factory_get_singleton (),
+ "gimp-cursor-view");
+ if (widget)
{
GtkWidget *cursor_view;
- cursor_view = gtk_bin_get_child (GTK_BIN (gimp_session_info_get_widget (session_info)));
+ cursor_view = gtk_bin_get_child (GTK_BIN (widget));
if (cursor_view)
{
@@ -187,8 +187,8 @@ gimp_display_shell_update_software_cursor (GimpDisplayShell *shell,
void
gimp_display_shell_clear_software_cursor (GimpDisplayShell *shell)
{
- GimpStatusbar *statusbar;
- GimpSessionInfo *session_info;
+ GimpStatusbar *statusbar;
+ GtkWidget *widget;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
@@ -198,13 +198,13 @@ gimp_display_shell_clear_software_cursor (GimpDisplayShell *shell)
gimp_statusbar_clear_cursor (statusbar);
- session_info = gimp_dialog_factory_find_session_info (gimp_dialog_factory_get_singleton (),
- "gimp-cursor-view");
- if (session_info && gimp_session_info_get_widget (session_info))
+ widget = gimp_dialog_factory_find_widget (gimp_dialog_factory_get_singleton (),
+ "gimp-cursor-view");
+ if (widget)
{
GtkWidget *cursor_view;
- cursor_view = gtk_bin_get_child (GTK_BIN (gimp_session_info_get_widget (session_info)));
+ cursor_view = gtk_bin_get_child (GTK_BIN (widget));
if (cursor_view)
gimp_cursor_view_clear_cursor (GIMP_CURSOR_VIEW (cursor_view));
diff --git a/app/gui/gui-message.c b/app/gui/gui-message.c
index 3b1d159..69c86d5 100644
--- a/app/gui/gui-message.c
+++ b/app/gui/gui-message.c
@@ -98,13 +98,11 @@ gui_message_error_console (GimpMessageSeverity severity,
/* try to avoid raising the error console for not so severe messages */
if (severity < GIMP_MESSAGE_ERROR)
{
- GimpSessionInfo *info;
-
- info = gimp_dialog_factory_find_session_info (gimp_dialog_factory_get_singleton (),
- "gimp-error-console");
-
- if (info && GIMP_IS_DOCKABLE (gimp_session_info_get_widget (info)))
- dockable = gimp_session_info_get_widget (info);
+ GtkWidget *widget =
+ gimp_dialog_factory_find_widget (gimp_dialog_factory_get_singleton (),
+ "gimp-error-console");
+ if (GIMP_IS_DOCKABLE (widget))
+ dockable = widget;
}
if (! dockable)
diff --git a/app/tools/gimpcolortool.c b/app/tools/gimpcolortool.c
index 60b0bfb..0cc7e29 100644
--- a/app/tools/gimpcolortool.c
+++ b/app/tools/gimpcolortool.c
@@ -607,17 +607,17 @@ gimp_color_tool_real_picked (GimpColorTool *color_tool,
if (color_tool->pick_mode == GIMP_COLOR_PICK_MODE_FOREGROUND ||
color_tool->pick_mode == GIMP_COLOR_PICK_MODE_BACKGROUND)
{
- GimpSessionInfo *info;
+ GtkWidget *widget;
if (GIMP_IMAGE_TYPE_IS_INDEXED (sample_type))
{
- info = gimp_dialog_factory_find_session_info (gimp_dialog_factory_get_singleton (),
- "gimp-indexed-palette");
- if (info && gimp_session_info_get_widget (info))
+ widget = gimp_dialog_factory_find_widget (gimp_dialog_factory_get_singleton (),
+ "gimp-indexed-palette");
+ if (widget)
{
GimpColormapEditor *editor;
- editor = GIMP_COLORMAP_EDITOR (gtk_bin_get_child (GTK_BIN (gimp_session_info_get_widget (info))));
+ editor = GIMP_COLORMAP_EDITOR (gtk_bin_get_child (GTK_BIN (widget)));
gimp_colormap_editor_set_index (editor, color_index, NULL);
}
@@ -625,14 +625,14 @@ gimp_color_tool_real_picked (GimpColorTool *color_tool,
if (TRUE)
{
- info = gimp_dialog_factory_find_session_info (gimp_dialog_factory_get_singleton (),
- "gimp-palette-editor");
- if (info && gimp_session_info_get_widget (info))
+ widget = gimp_dialog_factory_find_widget (gimp_dialog_factory_get_singleton (),
+ "gimp-palette-editor");
+ if (widget)
{
GimpPaletteEditor *editor;
gint index;
- editor = GIMP_PALETTE_EDITOR (gtk_bin_get_child (GTK_BIN (gimp_session_info_get_widget (info))));
+ editor = GIMP_PALETTE_EDITOR (gtk_bin_get_child (GTK_BIN (widget)));
index = gimp_palette_editor_get_index (editor, color);
if (index != -1)
diff --git a/app/widgets/gimpdialogfactory.c b/app/widgets/gimpdialogfactory.c
index ad49791..d23dc32 100644
--- a/app/widgets/gimpdialogfactory.c
+++ b/app/widgets/gimpdialogfactory.c
@@ -348,6 +348,23 @@ gimp_dialog_factory_find_session_info (GimpDialogFactory *factory,
return NULL;
}
+GtkWidget *
+gimp_dialog_factory_find_widget (GimpDialogFactory *factory,
+ const gchar *identifier)
+{
+ GimpSessionInfo *info;
+
+ g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (factory), NULL);
+ g_return_val_if_fail (identifier != NULL, NULL);
+
+ info = gimp_dialog_factory_find_session_info (factory, identifier);
+
+ if (info)
+ return gimp_session_info_get_widget (info);
+ else
+ return NULL;
+}
+
/**
* gimp_dialog_factory_dialog_sane:
* @factory:
@@ -419,12 +436,7 @@ gimp_dialog_factory_dialog_new_internal (GimpDialogFactory *factory,
/* a singleton dialog is always returned if it already exisits */
if (return_existing || entry->singleton)
{
- GimpSessionInfo *info;
-
- info = gimp_dialog_factory_find_session_info (factory, identifier);
-
- if (info)
- dialog = gimp_session_info_get_widget (info);
+ dialog = gimp_dialog_factory_find_widget (factory, identifier);
}
/* create the dialog if it was not found */
@@ -737,10 +749,7 @@ gimp_dialog_factory_dialog_raise (GimpDialogFactory *factory,
for (i = 0; ids[i]; i++)
{
- GimpSessionInfo *info;
-
- info = gimp_dialog_factory_find_session_info (factory, ids[i]);
- if (info && gimp_session_info_get_widget (info))
+ if (gimp_dialog_factory_find_widget (factory, ids[i]))
break;
}
diff --git a/app/widgets/gimpdialogfactory.h b/app/widgets/gimpdialogfactory.h
index 66c6d10..a99e590 100644
--- a/app/widgets/gimpdialogfactory.h
+++ b/app/widgets/gimpdialogfactory.h
@@ -135,6 +135,8 @@ GimpDialogFactoryEntry *
const gchar *identifier);
GimpSessionInfo * gimp_dialog_factory_find_session_info (GimpDialogFactory *factory,
const gchar *identifier);
+GtkWidget * gimp_dialog_factory_find_widget (GimpDialogFactory *factory,
+ const gchar *identifier);
GtkWidget * gimp_dialog_factory_dialog_new (GimpDialogFactory *factory,
GdkScreen *screen,
GimpUIManager *ui_manager,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]