[gimp/gimp-2-10] app: add gimp_dialog_factory_position_dialog()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] app: add gimp_dialog_factory_position_dialog()
- Date: Mon, 27 May 2019 12:47:09 +0000 (UTC)
commit eb99c1a82fa02949242c6d55ba8838b81f44f13d
Author: Michael Natterer <mitch gimp org>
Date: Mon May 27 14:15:09 2019 +0200
app: add gimp_dialog_factory_position_dialog()
which is the logic that used to be in color_area_color_clicked()
factored out to proper API. It makes sure that a dialog that was
visible before (and was only hidden not destroyed) appears at the same
point on the same monitor as before. See issue #1093.
(cherry picked from commit ebb6b08e621c302f55ec7209485f85270ccb3498)
app/widgets/gimpdialogfactory.c | 58 ++++++++++++++++++++++++++++++++++++
app/widgets/gimpdialogfactory.h | 21 +++++++++++++
app/widgets/gimptoolbox-color-area.c | 35 ++++------------------
3 files changed, 84 insertions(+), 30 deletions(-)
---
diff --git a/app/widgets/gimpdialogfactory.c b/app/widgets/gimpdialogfactory.c
index 35811d0ee2..0eebc86790 100644
--- a/app/widgets/gimpdialogfactory.c
+++ b/app/widgets/gimpdialogfactory.c
@@ -1050,6 +1050,64 @@ gimp_dialog_factory_add_foreign (GimpDialogFactory *factory,
gimp_dialog_factory_add_dialog (factory, dialog, screen, monitor);
}
+/**
+ * gimp_dialog_factory_position_dialog:
+ * @factory:
+ * @identifier:
+ * @dialog:
+ * @screen:
+ * @monitor:
+ *
+ * We correctly position all newly created dialog via
+ * gimp_dialog_factory_add_dialog(), but some dialogs (like various
+ * color dialogs) are never destroyed but created only once per
+ * session. On re-showing, whatever window managing magic kicks in and
+ * the dialog sometimes goes where it shouldn't.
+ *
+ * This function correctly positions a dialog on re-showing so it
+ * appears where it was before it was hidden.
+ *
+ * See https://gitlab.gnome.org/GNOME/gimp/issues/1093
+ **/
+void
+gimp_dialog_factory_position_dialog (GimpDialogFactory *factory,
+ const gchar *identifier,
+ GtkWidget *dialog,
+ GdkScreen *screen,
+ gint monitor)
+{
+ GimpSessionInfo *info;
+ GimpGuiConfig *gui_config;
+
+ g_return_if_fail (GIMP_IS_DIALOG_FACTORY (factory));
+ g_return_if_fail (identifier != NULL);
+ g_return_if_fail (GTK_IS_WIDGET (dialog));
+ g_return_if_fail (gtk_widget_is_toplevel (dialog));
+ g_return_if_fail (GDK_IS_SCREEN (screen));
+
+ info = gimp_dialog_factory_find_session_info (factory, identifier);
+
+ if (! info)
+ {
+ g_warning ("%s: no session info found for \"%s\"",
+ G_STRFUNC, identifier);
+ return;
+ }
+
+ if (gimp_session_info_get_widget (info) != dialog)
+ {
+ g_warning ("%s: session info for \"%s\" is for a different widget",
+ G_STRFUNC, identifier);
+ return;
+ }
+
+ gui_config = GIMP_GUI_CONFIG (factory->p->context->gimp->config);
+
+ gimp_session_info_apply_geometry (info,
+ screen, monitor,
+ gui_config->restore_monitor);
+}
+
void
gimp_dialog_factory_remove_dialog (GimpDialogFactory *factory,
GtkWidget *dialog)
diff --git a/app/widgets/gimpdialogfactory.h b/app/widgets/gimpdialogfactory.h
index b9f4c868fd..52d6d48df8 100644
--- a/app/widgets/gimpdialogfactory.h
+++ b/app/widgets/gimpdialogfactory.h
@@ -114,6 +114,7 @@ GType gimp_dialog_factory_get_type (void) G_GNUC_CONST
GimpDialogFactory * gimp_dialog_factory_new (const gchar *name,
GimpContext *context,
GimpMenuFactory *menu_factory);
+
void gimp_dialog_factory_register_entry (GimpDialogFactory *factory,
const gchar *identifier,
const gchar *name,
@@ -130,6 +131,7 @@ void gimp_dialog_factory_register_entry (GimpDialogFactory
gboolean hideable,
gboolean image_window,
gboolean dockable);
+
GimpDialogFactoryEntry *
gimp_dialog_factory_find_entry (GimpDialogFactory *factory,
const gchar *identifier);
@@ -137,6 +139,7 @@ GimpSessionInfo * gimp_dialog_factory_find_session_info (GimpDialogFactory
const gchar *identifier);
GtkWidget * gimp_dialog_factory_find_widget (GimpDialogFactory *factory,
const gchar *identifiers);
+
GtkWidget * gimp_dialog_factory_dialog_new (GimpDialogFactory *factory,
GdkScreen *screen,
gint monitor,
@@ -144,21 +147,26 @@ GtkWidget * gimp_dialog_factory_dialog_new (GimpDialogFactory
const gchar *identifier,
gint view_size,
gboolean present);
+
GimpContext * gimp_dialog_factory_get_context (GimpDialogFactory *factory);
GimpMenuFactory * gimp_dialog_factory_get_menu_factory (GimpDialogFactory *factory);
GList * gimp_dialog_factory_get_open_dialogs (GimpDialogFactory *factory);
+
GList * gimp_dialog_factory_get_session_infos (GimpDialogFactory *factory);
void gimp_dialog_factory_add_session_info (GimpDialogFactory *factory,
GimpSessionInfo *info);
+
GtkWidget * gimp_dialog_factory_dialog_raise (GimpDialogFactory *factory,
GdkScreen *screen,
gint monitor,
const gchar *identifiers,
gint view_size);
+
GtkWidget * gimp_dialog_factory_dockable_new (GimpDialogFactory *factory,
GimpDock *dock,
const gchar *identifier,
gint view_size);
+
void gimp_dialog_factory_add_dialog (GimpDialogFactory *factory,
GtkWidget *dialog,
GdkScreen *screen,
@@ -168,23 +176,36 @@ void gimp_dialog_factory_add_foreign (GimpDialogFactory
GtkWidget *dialog,
GdkScreen *screen,
gint monitor);
+
+void gimp_dialog_factory_position_dialog (GimpDialogFactory *factory,
+ const gchar *identifier,
+ GtkWidget *dialog,
+ GdkScreen *screen,
+ gint monitor);
void gimp_dialog_factory_remove_dialog (GimpDialogFactory *factory,
GtkWidget *dialog);
+
void gimp_dialog_factory_hide_dialog (GtkWidget *dialog);
+
void gimp_dialog_factory_save (GimpDialogFactory *factory,
GimpConfigWriter *writer);
void gimp_dialog_factory_restore (GimpDialogFactory *factory,
GdkScreen *screen,
gint monitor);
+
void gimp_dialog_factory_set_state (GimpDialogFactory *factory,
GimpDialogsState state);
GimpDialogsState gimp_dialog_factory_get_state (GimpDialogFactory *factory);
+
void gimp_dialog_factory_show_with_display (GimpDialogFactory *factory);
void gimp_dialog_factory_hide_with_display (GimpDialogFactory *factory);
+
void gimp_dialog_factory_set_busy (GimpDialogFactory *factory);
void gimp_dialog_factory_unset_busy (GimpDialogFactory *factory);
+
GimpDialogFactory * gimp_dialog_factory_from_widget (GtkWidget *dialog,
GimpDialogFactoryEntry **entry);
+
void gimp_dialog_factory_set_has_min_size (GtkWindow *window,
gboolean has_min_size);
gboolean gimp_dialog_factory_get_has_min_size (GtkWindow *window);
diff --git a/app/widgets/gimptoolbox-color-area.c b/app/widgets/gimptoolbox-color-area.c
index 46a5ecdba5..ab2b72ea03 100644
--- a/app/widgets/gimptoolbox-color-area.c
+++ b/app/widgets/gimptoolbox-color-area.c
@@ -249,36 +249,11 @@ color_area_color_clicked (GimpFgBgEditor *editor,
}
else if (! gtk_widget_get_visible (color_dialog))
{
- /* See https://gitlab.gnome.org/GNOME/gimp/issues/1093
- *
- * We correctly position all newly created dialog via
- * gimp_dialog_factory_add_dialog(), but the color dialog is
- * special, it's never destroyed but created only once per
- * session. On re-showing, whatever window managing magic kicks
- * in and the dialog sometimes goes where it shouldn't.
- *
- * The code below belongs into GimpDialogFactory, perhaps a new
- * function gimp_dialog_factory_position_dialog() and does the
- * same positioning logic as add_dialog().
- */
- GimpDialogFactory *dialog_factory = gimp_dialog_factory_get_singleton ();
- GimpSessionInfo *info;
-
- info = gimp_dialog_factory_find_session_info (dialog_factory,
- "gimp-toolbox-color-dialog");
-
- if (gimp_session_info_get_widget (info) == color_dialog)
- {
- GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (editor));
- gint monitor = gimp_widget_get_monitor (GTK_WIDGET (editor));
- GimpGuiConfig *gui_config;
-
- gui_config = GIMP_GUI_CONFIG (context->gimp->config);
-
- gimp_session_info_apply_geometry (info,
- screen, monitor,
- gui_config->restore_monitor);
- }
+ gimp_dialog_factory_position_dialog (gimp_dialog_factory_get_singleton (),
+ "gimp-toolbox-color-dialog",
+ color_dialog,
+ gtk_widget_get_screen (GTK_WIDGET (editor)),
+ gimp_widget_get_monitor (GTK_WIDGET (editor)));
}
gtk_window_set_title (GTK_WINDOW (color_dialog), title);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]