Commit 7642715c authored by Jehan's avatar Jehan Committed by Michael Natterer

app: allow setting parent for dialogs created by GimpDialogFactory.

Fixes a bunch of:
> Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged.
parent 4cac8373
......@@ -48,6 +48,7 @@ dialogs_create_toplevel_cmd_callback (GtkAction *action,
gimp_dialog_factory_dialog_new (gimp_dialog_factory_get_singleton (),
gimp_widget_get_monitor (widget),
NULL /*ui_manager*/,
widget,
value, -1, TRUE);
}
......
......@@ -150,6 +150,7 @@ file_open_location_cmd_callback (GtkAction *action,
gimp_dialog_factory_dialog_new (gimp_dialog_factory_get_singleton (),
gimp_widget_get_monitor (widget),
NULL /*ui_manager*/,
widget,
"gimp-file-open-location-dialog", -1, TRUE);
}
......@@ -463,6 +464,7 @@ file_close_all_cmd_callback (GtkAction *action,
gimp_dialog_factory_dialog_raise (gimp_dialog_factory_get_singleton (),
gimp_widget_get_monitor (widget),
widget,
"gimp-close-all-dialog", -1);
}
}
......@@ -556,6 +558,7 @@ file_open_dialog_show (Gimp *gimp,
dialog = gimp_dialog_factory_dialog_new (gimp_dialog_factory_get_singleton (),
gimp_widget_get_monitor (parent),
NULL /*ui_manager*/,
parent,
"gimp-file-open-dialog", -1, FALSE);
if (dialog)
......@@ -609,6 +612,7 @@ file_save_dialog_show (Gimp *gimp,
dialog = gimp_dialog_factory_dialog_new (gimp_dialog_factory_get_singleton (),
gimp_widget_get_monitor (parent),
NULL /*ui_manager*/,
parent,
"gimp-file-save-dialog",
-1, FALSE);
......@@ -690,6 +694,7 @@ file_export_dialog_show (Gimp *gimp,
dialog = gimp_dialog_factory_dialog_new (gimp_dialog_factory_get_singleton (),
gimp_widget_get_monitor (parent),
NULL /*ui_manager*/,
parent,
"gimp-file-export-dialog",
-1, FALSE);
......
......@@ -190,6 +190,7 @@ image_new_cmd_callback (GtkAction *action,
dialog = gimp_dialog_factory_dialog_new (gimp_dialog_factory_get_singleton (),
gimp_widget_get_monitor (widget),
NULL /*ui_manager*/,
widget,
"gimp-image-new-dialog", -1, FALSE);
if (dialog)
......
......@@ -63,6 +63,7 @@ palettes_import_cmd_callback (GtkAction *action,
gimp_dialog_factory_dialog_new (gimp_dialog_factory_get_singleton (),
gimp_widget_get_monitor (widget),
NULL /*ui_manager*/,
widget,
"gimp-palette-import-dialog", -1, TRUE);
}
......
......@@ -459,8 +459,11 @@ dialogs_restore_dialog (GimpDialogFactory *factory,
GdkMonitor *monitor,
GimpSessionInfo *info)
{
GtkWidget *dialog;
GimpCoreConfig *config = gimp_dialog_factory_get_context (factory)->gimp->config;
GtkWidget *dialog;
Gimp *gimp = gimp_dialog_factory_get_context (factory)->gimp;
GimpCoreConfig *config = gimp->config;
GimpDisplay *display = GIMP_DISPLAY (gimp_get_empty_display (gimp));
GimpDisplayShell *shell = gimp_display_get_shell (display);
GIMP_LOG (DIALOG_FACTORY, "restoring toplevel \"%s\" (info %p)",
gimp_session_info_get_factory_entry (info)->identifier,
......@@ -469,6 +472,7 @@ dialogs_restore_dialog (GimpDialogFactory *factory,
dialog =
gimp_dialog_factory_dialog_new (factory, monitor,
NULL /*ui_manager*/,
GTK_WIDGET (gimp_display_shell_get_window (shell)),
gimp_session_info_get_factory_entry (info)->identifier,
gimp_session_info_get_factory_entry (info)->view_size,
! GIMP_GUI_CONFIG (config)->hide_docks);
......
......@@ -571,6 +571,7 @@ prefs_input_devices_dialog (GtkWidget *widget,
{
gimp_dialog_factory_dialog_raise (gimp_dialog_factory_get_singleton (),
gimp_widget_get_monitor (widget),
widget,
"gimp-input-devices-dialog", 0);
}
......@@ -580,6 +581,7 @@ prefs_keyboard_shortcuts_dialog (GtkWidget *widget,
{
gimp_dialog_factory_dialog_raise (gimp_dialog_factory_get_singleton (),
gimp_widget_get_monitor (widget),
widget,
"gimp-keyboard-shortcuts-dialog", 0);
}
......
......@@ -71,7 +71,7 @@ gimp_multi_window_strategy_show_dockable_dialog (GimpWindowStrategy *strategy,
GdkMonitor *monitor,
const gchar *identifiers)
{
return gimp_dialog_factory_dialog_raise (factory, monitor,
return gimp_dialog_factory_dialog_raise (factory, monitor, NULL,
identifiers, -1);
}
......
......@@ -96,6 +96,7 @@ gimp_single_window_strategy_show_dockable_dialog (GimpWindowStrategy *strategy,
widget = gimp_dialog_factory_dialog_new (factory, monitor,
ui_manager,
GTK_WIDGET (window),
"gimp-toolbox",
-1 /*view_size*/,
FALSE /*present*/);
......@@ -111,6 +112,7 @@ gimp_single_window_strategy_show_dockable_dialog (GimpWindowStrategy *strategy,
{
/* if the dialog is already open, simply raise it */
return gimp_dialog_factory_dialog_raise (factory, monitor,
GTK_WIDGET (window),
identifiers, -1);
}
else
......
......@@ -374,6 +374,7 @@ gimp_ui_configurer_move_docks_to_window (GimpUIConfigurer *ui_configurer,
gimp_dialog_factory_dialog_new (gimp_dialog_factory_get_singleton (),
monitor,
NULL /*ui_manager*/,
GTK_WIDGET (dock_columns),
(contains_toolbox ?
"gimp-toolbox-window" :
"gimp-dock-window"),
......
......@@ -457,6 +457,7 @@ global_error_dialog (void)
return gimp_dialog_factory_dialog_new (gimp_dialog_factory_get_singleton (),
monitor,
NULL /*ui_manager*/,
NULL,
"gimp-error-dialog", -1,
FALSE);
}
......@@ -470,6 +471,7 @@ global_critical_dialog (void)
dialog = gimp_dialog_factory_dialog_new (gimp_dialog_factory_get_singleton (),
monitor,
NULL /*ui_manager*/,
NULL,
"gimp-critical-dialog", -1,
FALSE);
g_signal_handlers_disconnect_by_func (dialog,
......
......@@ -718,13 +718,20 @@ gui_exit_callback (Gimp *gimp,
if (! force && gimp_displays_dirty (gimp))
{
GdkMonitor *monitor;
GimpContext *context = gimp_get_user_context (gimp);
GimpDisplay *display = gimp_context_get_display (context);
GdkMonitor *monitor = gimp_get_monitor_at_pointer ();
GtkWidget *parent = NULL;
monitor = gimp_get_monitor_at_pointer ();
if (display)
{
GimpDisplayShell *shell = gimp_display_get_shell (display);
parent = GTK_WIDGET (gimp_display_shell_get_window (shell));
}
gimp_dialog_factory_dialog_raise (gimp_dialog_factory_get_singleton (),
monitor,
"gimp-quit-dialog", -1);
monitor, parent, "gimp-quit-dialog", -1);
return TRUE; /* stop exit for now */
}
......
......@@ -307,6 +307,7 @@ gimp_test_utils_create_image_from_dialog (Gimp *gimp)
new_image_dialog =
gimp_dialog_factory_dialog_raise (gimp_dialog_factory_get_singleton (),
gdk_display_get_monitor (gdk_display_get_default (), 0),
NULL,
"gimp-image-new-dialog",
-1 /*view_size*/);
......
......@@ -117,6 +117,7 @@ tool_options_editor_updates (gconstpointer data)
gtk_widget_get_screen (toplevel),
gimp_widget_get_monitor (toplevel),
NULL /*ui_manager*/,
toplevel,
"gimp-tool-options",
-1 /*view_size*/,
FALSE /*present*/);
......
......@@ -423,6 +423,7 @@ gimp_dialog_factory_dialog_sane (GimpDialogFactory *factory,
* @monitor:
* @context:
* @ui_manager:
* @parent:
* @identifier:
* @view_size:
* @return_existing: If %TRUE, (or if the dialog is a singleton),
......@@ -443,6 +444,7 @@ gimp_dialog_factory_dialog_new_internal (GimpDialogFactory *factory,
GdkMonitor *monitor,
GimpContext *context,
GimpUIManager *ui_manager,
GtkWidget *parent,
const gchar *identifier,
gint view_size,
gboolean return_existing,
......@@ -514,6 +516,7 @@ gimp_dialog_factory_dialog_new_internal (GimpDialogFactory *factory,
dock_window = gimp_dialog_factory_dialog_new (factory,
monitor,
NULL /*ui_manager*/,
parent,
"gimp-toolbox-window",
-1 /*view_size*/,
FALSE /*present*/);
......@@ -631,6 +634,17 @@ gimp_dialog_factory_dialog_new_internal (GimpDialogFactory *factory,
gtk_window_set_screen (GTK_WINDOW (dialog),
gdk_display_get_default_screen (gdk_monitor_get_display (monitor)));
if (parent)
{
GtkWidget *parent_toplevel = gtk_widget_get_toplevel (parent);
if (GTK_IS_WINDOW (parent_toplevel))
{
gtk_window_set_transient_for (GTK_WINDOW (dialog),
GTK_WINDOW (parent_toplevel));
}
}
toplevel = dialog;
}
else if (GIMP_IS_DOCK (dialog))
......@@ -676,6 +690,8 @@ gimp_dialog_factory_dialog_new_internal (GimpDialogFactory *factory,
* @factory: a #GimpDialogFactory
* @monitor the #GdkMonitor the dialog should appear on
* @ui_manager: A #GimpUIManager, if applicable.
* @parent: The parent widget, from which the call originated, if
* applicable, NULL otherwise.
* @identifier: the identifier of the dialog as registered with
* gimp_dialog_factory_register_entry()
* @view_size: the initial preview size
......@@ -691,6 +707,7 @@ GtkWidget *
gimp_dialog_factory_dialog_new (GimpDialogFactory *factory,
GdkMonitor *monitor,
GimpUIManager *ui_manager,
GtkWidget *parent,
const gchar *identifier,
gint view_size,
gboolean present)
......@@ -703,6 +720,7 @@ gimp_dialog_factory_dialog_new (GimpDialogFactory *factory,
monitor,
factory->p->context,
ui_manager,
parent,
identifier,
view_size,
FALSE /*return_existing*/,
......@@ -760,6 +778,8 @@ gimp_dialog_factory_add_session_info (GimpDialogFactory *factory,
* gimp_dialog_factory_dialog_raise:
* @factory: a #GimpDialogFactory
* @monitor: the #GdkMonitor the dialog should appear on
* @parent: the #GtkWidget from which the raised dialog
* originated, if applicable, #NULL otherwise.
* @identifiers: a '|' separated list of identifiers of dialogs as
* registered with gimp_dialog_factory_register_entry()
* @view_size: the initial preview size if a dialog needs to be created
......@@ -775,6 +795,7 @@ gimp_dialog_factory_add_session_info (GimpDialogFactory *factory,
GtkWidget *
gimp_dialog_factory_dialog_raise (GimpDialogFactory *factory,
GdkMonitor *monitor,
GtkWidget *parent,
const gchar *identifiers,
gint view_size)
{
......@@ -803,6 +824,7 @@ gimp_dialog_factory_dialog_raise (GimpDialogFactory *factory,
monitor,
NULL,
NULL,
parent,
ids[i] ? ids[i] : ids[0],
view_size,
TRUE /*return_existing*/,
......@@ -845,6 +867,7 @@ gimp_dialog_factory_dockable_new (GimpDialogFactory *factory,
gimp_widget_get_monitor (GTK_WIDGET (dock)),
gimp_dock_get_context (dock),
gimp_dock_get_ui_manager (dock),
NULL,
identifier,
view_size,
FALSE /*return_existing*/,
......
......@@ -140,6 +140,7 @@ GtkWidget * gimp_dialog_factory_find_widget (GimpDialogFactory
GtkWidget * gimp_dialog_factory_dialog_new (GimpDialogFactory *factory,
GdkMonitor *monitor,
GimpUIManager *ui_manager,
GtkWidget *parent,
const gchar *identifier,
gint view_size,
gboolean present);
......@@ -151,6 +152,7 @@ void gimp_dialog_factory_add_session_info (GimpDialogFactory
GimpSessionInfo *info);
GtkWidget * gimp_dialog_factory_dialog_raise (GimpDialogFactory *factory,
GdkMonitor *monitor,
GtkWidget *parent,
const gchar *identifiers,
gint view_size);
GtkWidget * gimp_dialog_factory_dockable_new (GimpDialogFactory *factory,
......
......@@ -290,6 +290,7 @@ gimp_session_info_dock_restore (GimpSessionInfoDock *dock_info,
ui_manager = gimp_dock_container_get_ui_manager (dock_container);
dock = gimp_dialog_factory_dialog_new (factory, monitor,
ui_manager,
NULL,
dock_info->dock_type,
-1 /*view_size*/,
FALSE /*present*/);
......
......@@ -1364,6 +1364,7 @@ gimp_dock_with_window_new (GimpDialogFactory *factory,
*/
dock_window = gimp_dialog_factory_dialog_new (factory, monitor,
NULL /*ui_manager*/,
NULL,
(toolbox ?
"gimp-toolbox-window" :
"gimp-dock-window"),
......@@ -1374,6 +1375,7 @@ gimp_dock_with_window_new (GimpDialogFactory *factory,
ui_manager = gimp_dock_container_get_ui_manager (dock_container);
dock = gimp_dialog_factory_dialog_new (factory, monitor,
ui_manager,
dock_window,
(toolbox ?
"gimp-toolbox" :
"gimp-dock"),
......
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