[gimp] app: Move toolbox special casing into dialog factory
- From: Martin Nordholts <martinn src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: Move toolbox special casing into dialog factory
- Date: Tue, 2 Mar 2010 21:36:33 +0000 (UTC)
commit 798e2e67e9089d55e5dd999f3c47a1b2de5078c0
Author: Martin Nordholts <martinn src gnome org>
Date: Tue Mar 2 22:31:01 2010 +0100
app: Move toolbox special casing into dialog factory
Move toolbox special casing into
gimp_dialog_factory_dialog_new_internal() and on the fly fix problems
with double toolboxes appearing and sometimes not appearing.
app/actions/dialogs-actions.c | 6 +++
app/actions/windows-actions.c | 6 ---
app/actions/windows-commands.c | 29 --------------
app/actions/windows-commands.h | 3 -
app/gui/gui.c | 2 -
app/widgets/gimpdialogfactory.c | 78 ++++++++++++++++++++++++++++++--------
menus/image-menu.xml.in | 4 +-
7 files changed, 69 insertions(+), 59 deletions(-)
---
diff --git a/app/actions/dialogs-actions.c b/app/actions/dialogs-actions.c
index a51c7fc..2a578a2 100644
--- a/app/actions/dialogs-actions.c
+++ b/app/actions/dialogs-actions.c
@@ -34,6 +34,12 @@
const GimpStringActionEntry dialogs_dockable_actions[] =
{
+ { "dialogs-toolbox", NULL,
+ NC_("windows-action", "Tool_box"), "<control>B",
+ NC_("windows-action", "Raise the toolbox"),
+ "gimp-toolbox",
+ GIMP_HELP_TOOLBOX },
+
{ "dialogs-tool-options", GIMP_STOCK_TOOL_OPTIONS,
NC_("dialogs-action", "Tool _Options"), NULL,
NC_("dialogs-action", "Open the tool options dialog"),
diff --git a/app/actions/windows-actions.c b/app/actions/windows-actions.c
index adf4572..cb0d460 100644
--- a/app/actions/windows-actions.c
+++ b/app/actions/windows-actions.c
@@ -87,12 +87,6 @@ static const GimpActionEntry windows_actions[] =
"_Recently Closed Docks") },
{ "windows-dialogs-menu", NULL, NC_("windows-action",
"_Dockable Dialogs") },
-
- { "windows-show-toolbox", NULL,
- NC_("windows-action", "Tool_box"), "<control>B",
- NC_("windows-action", "Raise the toolbox"),
- G_CALLBACK (windows_show_toolbox_cmd_callback),
- GIMP_HELP_TOOLBOX }
};
static const GimpToggleActionEntry windows_toggle_actions[] =
diff --git a/app/actions/windows-commands.c b/app/actions/windows-commands.c
index 16f2024..864a04c 100644
--- a/app/actions/windows-commands.c
+++ b/app/actions/windows-commands.c
@@ -43,13 +43,6 @@
void
-windows_show_toolbox_cmd_callback (GtkAction *action,
- gpointer data)
-{
- windows_show_toolbox ();
-}
-
-void
windows_hide_docks_cmd_callback (GtkAction *action,
gpointer data)
{
@@ -124,25 +117,3 @@ windows_open_recent_cmd_callback (GtkAction *action,
gimp_session_info_restore (info, gimp_dialog_factory_get_singleton ());
gimp_session_info_clear_info (info);
}
-
-void
-windows_show_toolbox (void)
-{
- GtkWidget *toolbox = NULL;
-
- if (! dialogs_get_toolbox ())
- {
- toolbox = gimp_dock_with_window_new (gimp_dialog_factory_get_singleton (),
- gdk_screen_get_default (),
- TRUE /*toolbox*/);
-
- gtk_widget_show (toolbox);
- }
- else
- {
- toolbox = dialogs_get_toolbox ();
-
- if (toolbox)
- gtk_window_present (GTK_WINDOW (toolbox));
- }
-}
diff --git a/app/actions/windows-commands.h b/app/actions/windows-commands.h
index 4715033..cd3a594 100644
--- a/app/actions/windows-commands.h
+++ b/app/actions/windows-commands.h
@@ -19,8 +19,6 @@
#define __WINDOWS_COMMANDS_H__
-void windows_show_toolbox_cmd_callback (GtkAction *action,
- gpointer data);
void windows_hide_docks_cmd_callback (GtkAction *action,
gpointer data);
void windows_use_single_window_mode_cmd_callback (GtkAction *action,
@@ -31,7 +29,6 @@ void windows_show_dock_cmd_callback (GtkAction *action,
gpointer data);
void windows_open_recent_cmd_callback (GtkAction *action,
gpointer data);
-void windows_show_toolbox (void);
#endif /* __WINDOWS_COMMANDS_H__ */
diff --git a/app/gui/gui.c b/app/gui/gui.c
index 70148a3..64edc01 100644
--- a/app/gui/gui.c
+++ b/app/gui/gui.c
@@ -539,8 +539,6 @@ gui_restore_after_callback (Gimp *gimp,
if (gui_config->restore_session)
session_restore (gimp);
- windows_show_toolbox ();
-
/* move keyboard focus to the display */
gtk_window_present (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (shell))));
}
diff --git a/app/widgets/gimpdialogfactory.c b/app/widgets/gimpdialogfactory.c
index cbaafcd..270f820 100644
--- a/app/widgets/gimpdialogfactory.c
+++ b/app/widgets/gimpdialogfactory.c
@@ -410,27 +410,42 @@ gimp_dialog_factory_dialog_new_internal (GimpDialogFactory *factory,
if (! dialog)
{
GtkWidget *dock = NULL;
+ GtkWidget *dock_window = NULL;
gboolean called_from_raise = FALSE;
called_from_raise = (context == NULL);
-
- if (entry->dockable && called_from_raise)
+
+ /* What follows is special-case code for some entires. At some
+ * point we might want to abstract this block of code away.
+ */
+ if (called_from_raise)
{
- GtkWidget *dockbook;
+ if (entry->dockable)
+ {
+ GtkWidget *dockbook;
- /* It doesn't make sense to have a dockable without a dock
- * so create one. Create a new dock _before_ creating the
- * dialog. We do this because the new dockable needs to be
- * created in its dock's context.
- */
- dock = gimp_dock_with_window_new (factory,
- screen,
- FALSE /*toolbox*/);
- dockbook = gimp_dockbook_new (factory->p->menu_factory);
-
- gimp_dock_add_book (GIMP_DOCK (dock),
- GIMP_DOCKBOOK (dockbook),
- 0);
+ /* It doesn't make sense to have a dockable without a dock
+ * so create one. Create a new dock _before_ creating the
+ * dialog. We do this because the new dockable needs to be
+ * created in its dock's context.
+ */
+ dock = gimp_dock_with_window_new (factory,
+ screen,
+ FALSE /*toolbox*/);
+ dockbook = gimp_dockbook_new (factory->p->menu_factory);
+
+ gimp_dock_add_book (GIMP_DOCK (dock),
+ GIMP_DOCKBOOK (dockbook),
+ 0);
+ }
+ else if (strcmp ("gimp-toolbox", entry->identifier) == 0)
+ {
+ dock_window = gimp_dialog_factory_dialog_new (factory,
+ screen,
+ "gimp-toolbox-window",
+ -1 /*view_size*/,
+ FALSE /*present*/);
+ }
}
/* Create the new dialog in the appropriate context which is
@@ -488,6 +503,31 @@ gimp_dialog_factory_dialog_new_internal (GimpDialogFactory *factory,
dock = NULL;
}
}
+ else if (dock_window)
+ {
+ if (GIMP_IS_DOCK (dialog))
+ {
+ gimp_dock_window_add_dock (GIMP_DOCK_WINDOW (dock_window),
+ GIMP_DOCK (dialog),
+ -1 /*index*/);
+
+ gtk_widget_set_visible (dialog, present);
+ gtk_widget_set_visible (dock_window, present);
+ }
+ else
+ {
+ g_warning ("%s: GimpDialogFactory is a dock factory entry "
+ "but constructor for \"%s\" did not return a "
+ "GimpDock",
+ G_STRFUNC, identifier);
+
+ gtk_widget_destroy (dialog);
+ gtk_widget_destroy (dock_window);
+
+ dialog = NULL;
+ dock_window = NULL;
+ }
+ }
}
else if (dock)
{
@@ -514,6 +554,10 @@ gimp_dialog_factory_dialog_new_internal (GimpDialogFactory *factory,
toplevel = dialog;
}
+ else if (GIMP_IS_DOCK (dialog))
+ {
+ toplevel = gtk_widget_get_toplevel (dialog);
+ }
else if (GIMP_IS_DOCKABLE (dialog))
{
GimpDockable *dockable = GIMP_DOCKABLE (dialog);
diff --git a/menus/image-menu.xml.in b/menus/image-menu.xml.in
index 105def3..4baa2ef 100644
--- a/menus/image-menu.xml.in
+++ b/menus/image-menu.xml.in
@@ -580,7 +580,7 @@
<menuitem action="tools-text" />
<menuitem action="tools-gegl" />
<separator />
- <menuitem action="windows-show-toolbox" />
+ <menuitem action="dialogs-toolbox" />
<menuitem action="context-colors-default" />
<menuitem action="context-colors-swap" />
</menu>
@@ -640,7 +640,7 @@
<placeholder name="Images" />
<separator />
<placeholder name="Docks">
- <menuitem action="windows-show-toolbox" />
+ <menuitem action="dialogs-toolbox" />
</placeholder>
<separator />
<menuitem action="windows-hide-docks" />
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]