mirror of https://github.com/GNOME/gimp.git
app: Handle special case "Toolbox" in GimpSingleWindowStrategy
The special case isn't pretty, but the current design can't handle it nicely. This is not the first special case for the toolbox.
This commit is contained in:
parent
066cdf6d74
commit
3ce4c49314
|
@ -23,19 +23,24 @@
|
|||
|
||||
#include "actions-types.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
|
||||
#include "widgets/gimpactiongroup.h"
|
||||
#include "widgets/gimpdialogfactory.h"
|
||||
#include "widgets/gimphelp-ids.h"
|
||||
#include "widgets/gimpsessioninfo.h"
|
||||
#include "widgets/gimptoolbox.h"
|
||||
|
||||
#include "display/gimpimagewindow.h"
|
||||
|
||||
#include "actions.h"
|
||||
#include "dialogs-actions.h"
|
||||
#include "dialogs-commands.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
static gboolean dialogs_actions_toolbox_exists (void);
|
||||
static gboolean dialogs_actions_toolbox_exists (Gimp *gimp);
|
||||
|
||||
|
||||
const GimpStringActionEntry dialogs_dockable_actions[] =
|
||||
|
@ -264,18 +269,34 @@ static const GimpStringActionEntry dialogs_toplevel_actions[] =
|
|||
|
||||
|
||||
static gboolean
|
||||
dialogs_actions_toolbox_exists (void)
|
||||
dialogs_actions_toolbox_exists (Gimp *gimp)
|
||||
{
|
||||
GimpDialogFactory *factory = gimp_dialog_factory_get_singleton ();
|
||||
GtkWidget *widget = NULL;
|
||||
GimpSessionInfo *info = NULL;
|
||||
GimpDialogFactory *factory = gimp_dialog_factory_get_singleton ();
|
||||
GimpSessionInfo *info = NULL;
|
||||
GList *windows = gimp ? gimp_get_image_windows (gimp) : 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);
|
||||
|
||||
if (info)
|
||||
widget = gimp_session_info_get_widget (info);
|
||||
/* Then in image windows */
|
||||
if (! toolbox_found)
|
||||
{
|
||||
for (iter = windows; iter; iter = g_list_next (iter))
|
||||
{
|
||||
GimpImageWindow *window = GIMP_IMAGE_WINDOW (windows->data);
|
||||
|
||||
if (gimp_image_window_has_toolbox (window))
|
||||
{
|
||||
toolbox_found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return widget != NULL;
|
||||
return toolbox_found;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -296,10 +317,11 @@ void
|
|||
dialogs_actions_update (GimpActionGroup *group,
|
||||
gpointer data)
|
||||
{
|
||||
Gimp *gimp = action_data_get_gimp (data);
|
||||
const gchar *toolbox_label = NULL;
|
||||
const gchar *toolbox_tooltip = NULL;
|
||||
|
||||
if (dialogs_actions_toolbox_exists ())
|
||||
if (dialogs_actions_toolbox_exists (gimp))
|
||||
{
|
||||
toolbox_label = _("Toolbox");
|
||||
toolbox_tooltip = _("Raise the toolbox");
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "widgets/gimpsessioninfo-aux.h"
|
||||
#include "widgets/gimpsessionmanaged.h"
|
||||
#include "widgets/gimpsessioninfo-dock.h"
|
||||
#include "widgets/gimptoolbox.h"
|
||||
#include "widgets/gimpuimanager.h"
|
||||
#include "widgets/gimpview.h"
|
||||
|
||||
|
@ -1169,6 +1170,41 @@ gimp_image_window_is_iconified (GimpImageWindow *window)
|
|||
return (private->window_state & GDK_WINDOW_STATE_ICONIFIED) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_image_window_has_toolbox:
|
||||
* @window:
|
||||
*
|
||||
* Returns: %TRUE if the image window contains a GimpToolbox.
|
||||
**/
|
||||
gboolean
|
||||
gimp_image_window_has_toolbox (GimpImageWindow *window)
|
||||
{
|
||||
GimpImageWindowPrivate *private;
|
||||
GList *iter = NULL;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE_WINDOW (window), FALSE);
|
||||
|
||||
private = GIMP_IMAGE_WINDOW_GET_PRIVATE (window);
|
||||
|
||||
for (iter = gimp_dock_columns_get_docks (GIMP_DOCK_COLUMNS (private->left_docks));
|
||||
iter;
|
||||
iter = g_list_next (iter))
|
||||
{
|
||||
if (GIMP_IS_TOOLBOX (iter->data))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
for (iter = gimp_dock_columns_get_docks (GIMP_DOCK_COLUMNS (private->right_docks));
|
||||
iter;
|
||||
iter = g_list_next (iter))
|
||||
{
|
||||
if (GIMP_IS_TOOLBOX (iter->data))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_window_shrink_wrap (GimpImageWindow *window,
|
||||
gboolean grow_only)
|
||||
|
|
|
@ -82,6 +82,8 @@ gboolean gimp_image_window_get_show_statusbar (GimpImageWindow *win
|
|||
|
||||
gboolean gimp_image_window_is_iconified (GimpImageWindow *window);
|
||||
|
||||
gboolean gimp_image_window_has_toolbox (GimpImageWindow *window);
|
||||
|
||||
void gimp_image_window_shrink_wrap (GimpImageWindow *window,
|
||||
gboolean grow_only);
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <gegl.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
|
@ -27,8 +29,10 @@
|
|||
|
||||
#include "core/gimp.h"
|
||||
|
||||
#include "widgets/gimpdockcolumns.h"
|
||||
#include "widgets/gimpdialogfactory.h"
|
||||
#include "widgets/gimpdock.h"
|
||||
#include "widgets/gimpdockbook.h"
|
||||
#include "widgets/gimpdockcolumns.h"
|
||||
|
||||
#include "display/gimpimagewindow.h"
|
||||
|
||||
|
@ -75,8 +79,7 @@ gimp_single_window_strategy_create_dockable_dialog (GimpWindowStrategy *strategy
|
|||
const gchar *identifiers)
|
||||
{
|
||||
GList *windows = gimp_get_image_windows (gimp);
|
||||
GtkWidget *dockbook;
|
||||
GtkWidget *dockable;
|
||||
GtkWidget *widget;
|
||||
GimpImageWindow *window;
|
||||
|
||||
g_return_val_if_fail (g_list_length (windows) > 0, NULL);
|
||||
|
@ -84,27 +87,54 @@ gimp_single_window_strategy_create_dockable_dialog (GimpWindowStrategy *strategy
|
|||
/* In single-window mode, there should only be one window... */
|
||||
window = GIMP_IMAGE_WINDOW (windows->data);
|
||||
|
||||
/* There shall not is more than one window in single-window mode */
|
||||
dockbook = gimp_image_window_get_default_dockbook (window);
|
||||
|
||||
if (! dockbook)
|
||||
if (strcmp ("gimp-toolbox", identifiers) == 0)
|
||||
{
|
||||
GimpDockColumns *dock_columns;
|
||||
/* Only allow one toolbox... */
|
||||
if (! gimp_image_window_has_toolbox (window))
|
||||
{
|
||||
GimpDockColumns *columns;
|
||||
GimpUIManager *ui_manager = gimp_image_window_get_ui_manager (window);
|
||||
|
||||
/* No dock, need to add one */
|
||||
dock_columns = gimp_image_window_get_right_docks (window);
|
||||
gimp_dock_columns_prepare_dockbook (dock_columns,
|
||||
-1 /*index*/,
|
||||
&dockbook);
|
||||
widget = gimp_dialog_factory_dialog_new (factory,
|
||||
screen,
|
||||
ui_manager,
|
||||
"gimp-toolbox",
|
||||
-1 /*view_size*/,
|
||||
FALSE /*present*/);
|
||||
gtk_widget_show (widget);
|
||||
|
||||
columns = gimp_image_window_get_left_docks (window);
|
||||
gimp_dock_columns_add_dock (columns,
|
||||
GIMP_DOCK (widget),
|
||||
-1 /*index*/);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GtkWidget *dockbook;
|
||||
|
||||
dockbook = gimp_image_window_get_default_dockbook (window);
|
||||
|
||||
if (! dockbook)
|
||||
{
|
||||
GimpDockColumns *dock_columns;
|
||||
|
||||
/* No dock, need to add one */
|
||||
dock_columns = gimp_image_window_get_right_docks (window);
|
||||
gimp_dock_columns_prepare_dockbook (dock_columns,
|
||||
-1 /*index*/,
|
||||
&dockbook);
|
||||
}
|
||||
|
||||
widget = gimp_dockbook_add_from_dialog_factory (GIMP_DOCKBOOK (dockbook),
|
||||
identifiers,
|
||||
-1 /*index*/);
|
||||
}
|
||||
|
||||
dockable = gimp_dockbook_add_from_dialog_factory (GIMP_DOCKBOOK (dockbook),
|
||||
identifiers,
|
||||
-1 /*index*/);
|
||||
|
||||
g_list_free (windows);
|
||||
|
||||
return dockable;
|
||||
return widget;
|
||||
}
|
||||
|
||||
GimpObject *
|
||||
|
|
Loading…
Reference in New Issue