From 76afd9776931a270c521eb3c59e8620984b93ba2 Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Tue, 25 Mar 2008 10:50:42 +0000 Subject: [PATCH] app/core/gimp-gui.[ch] added gimp_get_empty_display() to the vtable. 2008-03-25 Sven Neumann * app/core/gimp-gui.[ch] * app/gui/gui-vtable.c: added gimp_get_empty_display() to the vtable. * app/file/file-open.c (file_open_from_command_line): use the empty display as progress window when opening an image from the command-line or via the DBus interface. svn path=/trunk/; revision=25219 --- ChangeLog | 9 +++++++++ app/core/gimp-gui.c | 11 ++++++++++ app/core/gimp-gui.h | 2 ++ app/file/file-open.c | 5 +++-- app/gui/gui-vtable.c | 48 ++++++++++++++++++++++---------------------- 5 files changed, 49 insertions(+), 26 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6996ed5f15..1289b06a50 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2008-03-25 Sven Neumann + + * app/core/gimp-gui.[ch] + * app/gui/gui-vtable.c: added gimp_get_empty_display() to the vtable. + + * app/file/file-open.c (file_open_from_command_line): use the + empty display as progress window when opening an image from the + command-line or via the DBus interface. + 2008-03-25 Michael Natterer * app/actions/image-actions.c: remove "image-new-from-image" diff --git a/app/core/gimp-gui.c b/app/core/gimp-gui.c index 4e4d208b8e..4096c16acd 100644 --- a/app/core/gimp-gui.c +++ b/app/core/gimp-gui.c @@ -237,6 +237,17 @@ gimp_get_theme_dir (Gimp *gimp) return NULL; } +GimpObject * +gimp_get_empty_display (Gimp *gimp) +{ + g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); + + if (gimp->gui.get_empty_display) + return gimp->gui.get_empty_display (gimp); + + return NULL; +} + GimpObject * gimp_get_display_by_ID (Gimp *gimp, gint ID) diff --git a/app/core/gimp-gui.h b/app/core/gimp-gui.h index 16af1416a6..533bd0b695 100644 --- a/app/core/gimp-gui.h +++ b/app/core/gimp-gui.h @@ -47,6 +47,7 @@ struct _GimpGui gint *monitor_number); const gchar * (* get_theme_dir) (Gimp *gimp); + GimpObject * (* get_empty_display) (Gimp *gimp); GimpObject * (* display_get_by_id) (Gimp *gimp, gint ID); gint (* display_get_id) (GimpObject *display); @@ -96,6 +97,7 @@ void gimp_gui_ungrab (Gimp *gimp); void gimp_threads_enter (Gimp *gimp); void gimp_threads_leave (Gimp *gimp); +GimpObject * gimp_get_empty_display (Gimp *gimp); GimpObject * gimp_get_display_by_ID (Gimp *gimp, gint ID); gint gimp_get_display_ID (Gimp *gimp, diff --git a/app/file/file-open.c b/app/file/file-open.c index 6ae08086dc..8f79b5c03f 100644 --- a/app/file/file-open.c +++ b/app/file/file-open.c @@ -481,11 +481,12 @@ file_open_from_command_line (Gimp *gimp, if (uri) { GimpImage *image; + GimpObject *display = gimp_get_empty_display (gimp); GimpPDBStatusType status; image = file_open_with_display (gimp, gimp_get_user_context (gimp), - NULL, + GIMP_PROGRESS (display), uri, as_new, &status, &error); @@ -497,7 +498,7 @@ file_open_from_command_line (Gimp *gimp, { gchar *filename = file_utils_uri_display_name (uri); - gimp_message (gimp, NULL, GIMP_MESSAGE_ERROR, + gimp_message (gimp, G_OBJECT (display), GIMP_MESSAGE_ERROR, _("Opening '%s' failed: %s"), filename, error->message); g_clear_error (&error); diff --git a/app/gui/gui-vtable.c b/app/gui/gui-vtable.c index 10504e4373..d657838d4c 100644 --- a/app/gui/gui-vtable.c +++ b/app/gui/gui-vtable.c @@ -89,6 +89,7 @@ static gchar * gui_get_display_name (Gimp *gimp, gint display_ID, gint *monitor_number); static const gchar * gui_get_theme_dir (Gimp *gimp); +static GimpObject * gui_get_empty_display (Gimp *gimp); static GimpObject * gui_display_get_by_ID (Gimp *gimp, gint ID); static gint gui_display_get_ID (GimpObject *display); @@ -101,7 +102,6 @@ static void gui_display_delete (GimpObject *display); static void gui_displays_reconnect (Gimp *gimp, GimpImage *old_image, GimpImage *new_image); -static GimpDisplay * gui_get_empty_display (Gimp *gimp); static GimpProgress * gui_new_progress (Gimp *gimp, GimpObject *display); static void gui_free_progress (Gimp *gimp, @@ -145,6 +145,7 @@ gui_vtable_init (Gimp *gimp) gimp->gui.get_program_class = gui_get_program_class; gimp->gui.get_display_name = gui_get_display_name; gimp->gui.get_theme_dir = gui_get_theme_dir; + gimp->gui.get_empty_display = gui_get_empty_display; gimp->gui.display_get_by_id = gui_display_get_by_ID; gimp->gui.display_get_id = gui_display_get_ID; gimp->gui.display_get_window = gui_display_get_window; @@ -260,6 +261,25 @@ gui_get_theme_dir (Gimp *gimp) return themes_get_theme_dir (gimp, GIMP_GUI_CONFIG (gimp->config)->theme); } +static GimpObject * +gui_get_empty_display (Gimp *gimp) +{ + GimpObject *display = NULL; + + if (gimp_container_num_children (gimp->displays) == 1) + { + display = gimp_container_get_child_by_index (gimp->displays, 0); + + if (GIMP_DISPLAY (display)->image) + { + /* The display was not empty */ + display = NULL; + } + } + + return display; +} + static GimpObject * gui_display_get_by_ID (Gimp *gimp, gint ID) @@ -291,12 +311,11 @@ gui_display_create (Gimp *gimp, gdouble scale) { GimpContext *context = gimp_get_user_context (gimp); - GimpDisplay *display = NULL; + GimpObject *object = gui_get_empty_display (gimp); + GimpDisplay *display = object ? GIMP_DISPLAY (object) : NULL; - if (gui_get_empty_display (gimp) != NULL) + if (display) { - display = gui_get_empty_display (gimp); - gimp_display_fill (display, image, unit, scale); } else @@ -341,25 +360,6 @@ gui_displays_reconnect (Gimp *gimp, gimp_displays_reconnect (gimp, old_image, new_image); } -static GimpDisplay * -gui_get_empty_display (Gimp *gimp) -{ - GimpDisplay *display = NULL; - - if (gimp_container_num_children (gimp->displays) == 1) - { - display = (GimpDisplay *) gimp_container_get_child_by_index (gimp->displays, 0); - - if (display->image != NULL) - { - /* The display was not empty */ - display = NULL; - } - } - - return display; -} - static GimpProgress * gui_new_progress (Gimp *gimp, GimpObject *display)