Use gimp_display_shell_get_window() instead of gtk_widget_get_toplevel()

The new function does the right thing, unlike get_toplevel() which
returns the shell itself if it is not in a window. Check the return
value of get_window() for being non-NULL.
This commit is contained in:
Michael Natterer 2009-09-29 20:32:26 +02:00
parent 97987aff6e
commit 253b8e2cbe
21 changed files with 255 additions and 211 deletions

View file

@ -610,28 +610,30 @@ action_message (GimpDisplay *display,
const gchar *format,
...)
{
GtkWidget *toplevel;
GtkWidget *statusbar;
const gchar *stock_id = NULL;
va_list args;
GimpImageWindow *window;
toplevel = gtk_widget_get_toplevel (display->shell);
statusbar = GIMP_IMAGE_WINDOW (toplevel)->statusbar;
window = gimp_display_shell_get_window (GIMP_DISPLAY_SHELL (display->shell));
if (GIMP_IS_TOOL_OPTIONS (object))
if (window)
{
GimpToolInfo *tool_info = GIMP_TOOL_OPTIONS (object)->tool_info;
const gchar *stock_id = NULL;
va_list args;
stock_id = gimp_viewable_get_stock_id (GIMP_VIEWABLE (tool_info));
}
else if (GIMP_IS_VIEWABLE (object))
{
stock_id = gimp_viewable_get_stock_id (GIMP_VIEWABLE (object));
}
if (GIMP_IS_TOOL_OPTIONS (object))
{
GimpToolInfo *tool_info = GIMP_TOOL_OPTIONS (object)->tool_info;
va_start (args, format);
gimp_statusbar_push_temp_valist (GIMP_STATUSBAR (statusbar),
GIMP_MESSAGE_INFO, stock_id,
format, args);
va_end (args);
stock_id = gimp_viewable_get_stock_id (GIMP_VIEWABLE (tool_info));
}
else if (GIMP_IS_VIEWABLE (object))
{
stock_id = gimp_viewable_get_stock_id (GIMP_VIEWABLE (object));
}
va_start (args, format);
gimp_statusbar_push_temp_valist (GIMP_STATUSBAR (window->statusbar),
GIMP_MESSAGE_INFO, stock_id,
format, args);
va_end (args);
}
}

View file

@ -187,17 +187,17 @@ void
debug_dump_keyboard_shortcuts_cmd_callback (GtkAction *action,
gpointer data)
{
GimpDisplay *display = NULL;
GtkWidget *window = NULL;
GtkUIManager *manager = NULL;
GtkAccelGroup *accel_group = NULL;
GList *group_it = NULL;
GList *strings = NULL;
GimpDisplay *display;
GimpImageWindow *window;
GtkUIManager *manager;
GtkAccelGroup *accel_group;
GList *group_it;
GList *strings = NULL;
return_if_no_display (display, data);
window = gtk_widget_get_toplevel (display->shell);
window = gimp_display_shell_get_window (GIMP_DISPLAY_SHELL (display->shell));
manager = GTK_UI_MANAGER (GIMP_IMAGE_WINDOW (window)->menubar_manager);
manager = GTK_UI_MANAGER (window->menubar_manager);
accel_group = gtk_ui_manager_get_accel_group (manager);

View file

@ -550,12 +550,14 @@ view_actions_update (GimpActionGroup *group,
if (display)
{
GtkWidget *window = gtk_widget_get_toplevel (display->shell);
GimpImageWindow *window;
image = display->image;
shell = GIMP_DISPLAY_SHELL (display->shell);
image = display->image;
shell = GIMP_DISPLAY_SHELL (display->shell);
window = gimp_display_shell_get_window (shell);
fullscreen = gimp_image_window_get_fullscreen (GIMP_IMAGE_WINDOW (window));
if (window)
fullscreen = gimp_image_window_get_fullscreen (window);
options = (image ?
(fullscreen ? shell->fullscreen_options : shell->options) :
@ -679,7 +681,8 @@ view_actions_update (GimpActionGroup *group,
window = gtk_widget_get_toplevel (GTK_WIDGET (shell));
/* see view_actions_setup() */
window_actions_update (group, window);
if (GTK_IS_WINDOW (window))
window_actions_update (group, window);
}
#undef SET_ACTIVE

View file

@ -260,12 +260,13 @@ view_dot_for_dot_cmd_callback (GtkAction *action,
if (active != shell->dot_for_dot)
{
GtkWidget *window = gtk_widget_get_toplevel (GTK_WIDGET (shell));
GimpImageWindow *window = gimp_display_shell_get_window (shell);
gimp_display_shell_scale_set_dot_for_dot (shell, active);
SET_ACTIVE (GIMP_IMAGE_WINDOW (window)->menubar_manager,
"view-dot-for-dot", shell->dot_for_dot);
if (window)
SET_ACTIVE (window->menubar_manager,
"view-dot-for-dot", shell->dot_for_dot);
if (IS_ACTIVE_DISPLAY (display))
SET_ACTIVE (shell->popup_manager, "view-dot-for-dot",
@ -576,17 +577,19 @@ view_padding_color_cmd_callback (GtkAction *action,
gpointer data)
{
GimpDisplay *display;
GtkWidget *window;
GimpImageWindow *window;
GimpDisplayShell *shell;
GimpDisplayOptions *options;
gboolean fullscreen;
return_if_no_display (display, data);
window = gtk_widget_get_toplevel (display->shell);
shell = GIMP_DISPLAY_SHELL (display->shell);
window = gimp_display_shell_get_window (shell);
shell = GIMP_DISPLAY_SHELL (display->shell);
fullscreen = gimp_image_window_get_fullscreen (GIMP_IMAGE_WINDOW (window));
if (window)
fullscreen = gimp_image_window_get_fullscreen (window);
else
fullscreen = FALSE;
if (fullscreen)
options = shell->fullscreen_options;
@ -678,16 +681,22 @@ void
view_fullscreen_cmd_callback (GtkAction *action,
gpointer data)
{
GimpDisplay *display;
GtkWidget *window;
gboolean active;
GimpDisplay *display;
GimpDisplayShell *shell;
GimpImageWindow *window;
return_if_no_display (display, data);
window = gtk_widget_get_toplevel (display->shell);
shell = GIMP_DISPLAY_SHELL (display->shell);
window = gimp_display_shell_get_window (shell);
active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
if (window)
{
gboolean active;
gimp_image_window_set_fullscreen (GIMP_IMAGE_WINDOW (window), active);
active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
gimp_image_window_set_fullscreen (window, active);
}
}
void
@ -736,13 +745,16 @@ view_padding_color_dialog_update (GimpColorDialog *dialog,
GimpColorDialogState state,
GimpDisplayShell *shell)
{
GtkWidget *window;
GimpImageWindow *window;
GimpDisplayOptions *options;
gboolean fullscreen;
window = gtk_widget_get_toplevel (GTK_WIDGET (shell));
window = gimp_display_shell_get_window (shell);
fullscreen = gimp_image_window_get_fullscreen (GIMP_IMAGE_WINDOW (window));
if (window)
fullscreen = gimp_image_window_get_fullscreen (window);
else
fullscreen = FALSE;
if (fullscreen)
options = shell->fullscreen_options;

View file

@ -70,9 +70,11 @@ void
windows_show_display_cmd_callback (GtkAction *action,
gpointer data)
{
GimpDisplay *display = g_object_get_data (G_OBJECT (action), "display");
GimpDisplay *display = g_object_get_data (G_OBJECT (action), "display");
GtkWidget *toplevel = gtk_widget_get_toplevel (display->shell);
gtk_window_present (GTK_WINDOW (gtk_widget_get_toplevel (display->shell)));
if (GTK_IS_WINDOW (toplevel))
gtk_window_present (GTK_WINDOW (toplevel));
}
void

View file

@ -246,14 +246,18 @@ gimp_displays_get_num_visible (Gimp *gimp)
if (GTK_WIDGET_DRAWABLE (display->shell))
{
GtkWidget *toplevel = gtk_widget_get_toplevel (display->shell);
GdkWindow *window = gtk_widget_get_window (toplevel);
GdkWindowState state = gdk_window_get_state (window);
GtkWidget *toplevel = gtk_widget_get_toplevel (display->shell);
if ((state & (GDK_WINDOW_STATE_WITHDRAWN |
GDK_WINDOW_STATE_ICONIFIED)) == 0)
if (GTK_IS_WINDOW (toplevel))
{
visible++;
GdkWindow *window = gtk_widget_get_window (toplevel);
GdkWindowState state = gdk_window_get_state (window);
if ((state & (GDK_WINDOW_STATE_WITHDRAWN |
GDK_WINDOW_STATE_ICONIFIED)) == 0)
{
visible++;
}
}
}
}

View file

@ -163,10 +163,10 @@ gimp_display_saved_handler (GimpImage *image,
const gchar *uri,
GimpDisplay *display)
{
GtkWidget *toplevel = gtk_widget_get_toplevel (display->shell);
GimpImageWindow *window = GIMP_IMAGE_WINDOW (toplevel);
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (display->shell);
GimpImageWindow *window = gimp_display_shell_get_window (shell);
if (gimp_image_window_get_active_shell (window)->display == display)
if (window && gimp_image_window_get_active_shell (window) == shell)
{
gchar *filename = file_utils_uri_display_name (uri);
@ -183,10 +183,10 @@ gimp_display_exported_handler (GimpImage *image,
const gchar *uri,
GimpDisplay *display)
{
GtkWidget *toplevel = gtk_widget_get_toplevel (display->shell);
GimpImageWindow *window = GIMP_IMAGE_WINDOW (toplevel);
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (display->shell);
GimpImageWindow *window = gimp_display_shell_get_window (shell);
if (gimp_image_window_get_active_shell (window)->display == display)
if (window && gimp_image_window_get_active_shell (window) == shell)
{
gchar *filename = file_utils_uri_display_name (uri);

View file

@ -437,11 +437,8 @@ gimp_display_delete (GimpDisplay *display)
if (display->shell)
{
GtkWidget *shell = display->shell;
GtkWidget *toplevel = gtk_widget_get_toplevel (shell);
#if 0
GimpImageWindow *window = GIMP_IMAGE_WINDOW (toplevel);
#endif
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (display->shell);
GimpImageWindow *window = gimp_display_shell_get_window (shell);
/* set display->shell to NULL *before* destroying the shell.
* all callbacks in gimpdisplayshell-callbacks.c will check
@ -451,14 +448,14 @@ gimp_display_delete (GimpDisplay *display)
/* FIXME image window: enable this code for multiple shells */
#if 0
if (gimp_image_window_get_n_displays (window) > 1)
if (window && gimp_image_window_get_n_displays (window) > 1)
{
gimp_image_window_remove_display (window, display);
}
else
else if (window)
#endif
{
gtk_widget_destroy (toplevel);
gtk_widget_destroy (GTK_WIDGET (window));
}
}

View file

@ -65,17 +65,16 @@ void
gimp_display_shell_appearance_update (GimpDisplayShell *shell)
{
GimpDisplayOptions *options;
GtkWidget *toplevel;
GimpImageWindow *window;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
options = appearance_get_options (shell);
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (shell));
window = GIMP_IMAGE_WINDOW (toplevel);
options = appearance_get_options (shell);
window = gimp_display_shell_get_window (shell);
appearance_set_action_active (shell, "view-fullscreen",
gimp_image_window_get_fullscreen (window));
if (window)
appearance_set_action_active (shell, "view-fullscreen",
gimp_image_window_get_fullscreen (window));
gimp_display_shell_set_show_menubar (shell,
options->show_menubar);
@ -106,18 +105,16 @@ gimp_display_shell_set_show_menubar (GimpDisplayShell *shell,
gboolean show)
{
GimpDisplayOptions *options;
GtkWidget *toplevel;
GimpImageWindow *window;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
options = appearance_get_options (shell);
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (shell));
window = GIMP_IMAGE_WINDOW (toplevel);
options = appearance_get_options (shell);
window = gimp_display_shell_get_window (shell);
g_object_set (options, "show-menubar", show, NULL);
if (gimp_image_window_get_active_shell (window) == shell &&
if (window && gimp_image_window_get_active_shell (window) == shell &&
window->menubar)
{
if (show)
@ -142,18 +139,16 @@ gimp_display_shell_set_show_statusbar (GimpDisplayShell *shell,
gboolean show)
{
GimpDisplayOptions *options;
GtkWidget *toplevel;
GimpImageWindow *window;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
options = appearance_get_options (shell);
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (shell));
window = GIMP_IMAGE_WINDOW (toplevel);
options = appearance_get_options (shell);
window = gimp_display_shell_get_window (shell);
g_object_set (options, "show-statusbar", show, NULL);
if (gimp_image_window_get_active_shell (window) == shell)
if (window && gimp_image_window_get_active_shell (window) == shell)
{
gimp_statusbar_set_visible (GIMP_STATUSBAR (window->statusbar), show);
}
@ -592,10 +587,9 @@ appearance_get_options (const GimpDisplayShell *shell)
{
if (shell->display->image)
{
GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (shell));
GimpImageWindow *window = GIMP_IMAGE_WINDOW (toplevel);
GimpImageWindow *window = gimp_display_shell_get_window (shell);
if (gimp_image_window_get_fullscreen (window))
if (window && gimp_image_window_get_fullscreen (window))
return shell->fullscreen_options;
else
return shell->options;
@ -609,11 +603,10 @@ appearance_set_action_active (GimpDisplayShell *shell,
const gchar *action,
gboolean active)
{
GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (shell));
GimpImageWindow *window = GIMP_IMAGE_WINDOW (toplevel);
GimpImageWindow *window = gimp_display_shell_get_window (shell);
GimpContext *context;
if (gimp_image_window_get_active_shell (window) == shell)
if (window && gimp_image_window_get_active_shell (window) == shell)
{
GimpActionGroup *action_group;
@ -643,11 +636,10 @@ appearance_set_action_color (GimpDisplayShell *shell,
const gchar *action,
const GimpRGB *color)
{
GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (shell));
GimpImageWindow *window = GIMP_IMAGE_WINDOW (toplevel);
GimpImageWindow *window = gimp_display_shell_get_window (shell);
GimpContext *context;
if (gimp_image_window_get_active_shell (window) == shell)
if (window && gimp_image_window_get_active_shell (window) == shell)
{
GimpActionGroup *action_group;

View file

@ -1833,12 +1833,13 @@ gimp_display_shell_quick_mask_button_press (GtkWidget *widget,
if ((bevent->type == GDK_BUTTON_PRESS) && (bevent->button == 3))
{
GtkWidget *window = gtk_widget_get_toplevel (GTK_WIDGET (shell));
GimpImageWindow *window = gimp_display_shell_get_window (shell);
gimp_ui_manager_ui_popup (GIMP_IMAGE_WINDOW (window)->menubar_manager,
"/quick-mask-popup",
GTK_WIDGET (shell),
NULL, NULL, NULL, NULL);
if (window)
gimp_ui_manager_ui_popup (window->menubar_manager,
"/quick-mask-popup",
GTK_WIDGET (shell),
NULL, NULL, NULL, NULL);
return TRUE;
}

View file

@ -111,13 +111,16 @@ gimp_display_shell_close (GimpDisplayShell *shell,
}
else
{
GtkWidget *window = gtk_widget_get_toplevel (GTK_WIDGET (shell));
GimpImageWindow *window = gimp_display_shell_get_window (shell);
/* Activate the action instead of simply calling gimp_exit(), so
* the quit action's sensitivity is taken into account.
*/
gimp_ui_manager_activate_action (GIMP_IMAGE_WINDOW (window)->menubar_manager,
"file", "file-quit");
if (window)
{
/* Activate the action instead of simply calling gimp_exit(), so
* the quit action's sensitivity is taken into account.
*/
gimp_ui_manager_activate_action (window->menubar_manager,
"file", "file-quit");
}
}
}
@ -214,7 +217,7 @@ gimp_display_shell_close_name_changed (GimpImage *image,
{
GtkWidget *window = gtk_widget_get_toplevel (GTK_WIDGET (box));
if (window)
if (GTK_IS_WINDOW (window))
{
gchar *title = g_strdup_printf (_("Close %s"),
gimp_image_get_display_name (image));
@ -299,12 +302,15 @@ gimp_display_shell_close_response (GtkWidget *widget,
case RESPONSE_SAVE:
{
GtkWidget *window = gtk_widget_get_toplevel (GTK_WIDGET (shell));
GimpImageWindow *window = gimp_display_shell_get_window (shell);
/* FIXME image window: set this display active */
if (window)
{
/* FIXME image window: set this display active */
gimp_ui_manager_activate_action (GIMP_IMAGE_WINDOW (window)->menubar_manager,
"file", "file-save-and-close");
gimp_ui_manager_activate_action (window->menubar_manager,
"file", "file-save-and-close");
}
}
break;

View file

@ -125,8 +125,7 @@ gimp_display_shell_update_cursor (GimpDisplayShell *shell,
gdouble image_x,
gdouble image_y)
{
GtkWidget *toplevel;
GtkWidget *statusbar;
GimpImageWindow *window;
GimpDialogFactory *factory;
GimpSessionInfo *session_info;
GimpImage *image;
@ -162,11 +161,13 @@ gimp_display_shell_update_cursor (GimpDisplayShell *shell,
/* use the passed image_coords for the statusbar because they are
* possibly snapped...
*/
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (shell));
statusbar = GIMP_IMAGE_WINDOW (toplevel)->statusbar;
window = gimp_display_shell_get_window (shell);
gimp_statusbar_update_cursor (GIMP_STATUSBAR (statusbar),
precision, image_x, image_y);
if (window && gimp_image_window_get_active_shell (window))
{
gimp_statusbar_update_cursor (GIMP_STATUSBAR (window->statusbar),
precision, image_x, image_y);
}
factory = gimp_dialog_factory_from_name ("dock");
session_info = gimp_dialog_factory_find_session_info (factory,
@ -197,17 +198,18 @@ gimp_display_shell_update_cursor (GimpDisplayShell *shell,
void
gimp_display_shell_clear_cursor (GimpDisplayShell *shell)
{
GtkWidget *toplevel;
GtkWidget *statusbar;
GimpImageWindow *window;
GimpDialogFactory *factory;
GimpSessionInfo *session_info;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (shell));
statusbar = GIMP_IMAGE_WINDOW (toplevel)->statusbar;
window = gimp_display_shell_get_window (shell);
gimp_statusbar_clear_cursor (GIMP_STATUSBAR (statusbar));
if (window && gimp_image_window_get_active_shell (window) == shell)
{
gimp_statusbar_clear_cursor (GIMP_STATUSBAR (window->statusbar));
}
factory = gimp_dialog_factory_from_name ("dock");
session_info = gimp_dialog_factory_find_session_info (factory,

View file

@ -184,7 +184,8 @@ gimp_display_shell_dnd_flush (GimpDisplayShell *shell,
{
GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (shell));
gtk_window_present (GTK_WINDOW (toplevel));
if (GTK_IS_WINDOW (toplevel))
gtk_window_present (GTK_WINDOW (toplevel));
gimp_image_flush (image);

View file

@ -500,10 +500,9 @@ gimp_display_shell_size_changed_detailed_handler (GimpImage *image,
{
if (shell->display->config->resize_windows_on_resize)
{
GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (shell));
GimpImageWindow *window = GIMP_IMAGE_WINDOW (toplevel);
GimpImageWindow *window = gimp_display_shell_get_window (shell);
if (gimp_image_window_get_active_shell (window) == shell)
if (window && gimp_image_window_get_active_shell (window) == shell)
{
/* If the window is resized just center the image in it when it
* has change size
@ -678,16 +677,19 @@ gimp_display_shell_padding_notify_handler (GObject *config,
GimpDisplayShell *shell)
{
GimpDisplayConfig *display_config;
GtkWidget *window;
GimpImageWindow *window;
gboolean fullscreen;
GimpCanvasPaddingMode padding_mode;
GimpRGB padding_color;
display_config = shell->display->config;
window = gtk_widget_get_toplevel (GTK_WIDGET (shell));
window = gimp_display_shell_get_window (shell);
fullscreen = gimp_image_window_get_fullscreen (GIMP_IMAGE_WINDOW (window));
if (window)
fullscreen = gimp_image_window_get_fullscreen (window);
else
fullscreen = FALSE;
/* if the user did not set the padding mode for this display explicitely */
if (! shell->fullscreen_options->padding_mode_set)

View file

@ -41,11 +41,10 @@
static GimpProgress *
gimp_display_shell_progress_get_real_progress (GimpProgress *progress)
{
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (progress);
GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (shell));
GimpImageWindow *window = GIMP_IMAGE_WINDOW (toplevel);
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (progress);
GimpImageWindow *window = gimp_display_shell_get_window (shell);
if (gimp_image_window_get_active_shell (window) == shell)
if (window && gimp_image_window_get_active_shell (window) == shell)
return GIMP_PROGRESS (window->statusbar);
else
return NULL;
@ -129,7 +128,10 @@ gimp_display_shell_progress_get_window (GimpProgress *progress)
{
GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (progress));
return (guint32) gimp_window_get_native (GTK_WINDOW (toplevel));
if (GTK_IS_WINDOW (toplevel))
return (guint32) gimp_window_get_native (GTK_WINDOW (toplevel));
return 0;
}
static gboolean

View file

@ -367,11 +367,7 @@ gimp_display_shell_scale (GimpDisplayShell *shell,
{
if (shell->display->config->resize_windows_on_zoom)
{
GtkWidget *toplevel;
GimpImageWindow *window;
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (shell));
window = GIMP_IMAGE_WINDOW (toplevel);
GimpImageWindow *window = gimp_display_shell_get_window (shell);
/* If the window is resized on zoom, simply do the zoom and
* get things rolling
@ -379,7 +375,7 @@ gimp_display_shell_scale (GimpDisplayShell *shell,
gimp_zoom_model_zoom (shell->zoom, GIMP_ZOOM_TO, real_new_scale);
gimp_display_shell_scaled (shell);
if (gimp_image_window_get_active_shell (window) == shell)
if (window && gimp_image_window_get_active_shell (window) == shell)
{
gimp_image_window_shrink_wrap (window, FALSE);
}
@ -668,10 +664,9 @@ gimp_display_shell_scale_resize (GimpDisplayShell *shell,
if (resize_window)
{
GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (shell));
GimpImageWindow *window = GIMP_IMAGE_WINDOW (toplevel);
GimpImageWindow *window = gimp_display_shell_get_window (shell);
if (gimp_image_window_get_active_shell (window) == shell)
if (window && gimp_image_window_get_active_shell (window) == shell)
{
gimp_image_window_shrink_wrap (window, grow_only);
}

View file

@ -1236,9 +1236,12 @@ gimp_display_shell_fill_idle (GimpDisplayShell *shell)
shell->fill_idle_id = 0;
gimp_display_shell_scale_shrink_wrap (shell, TRUE);
if (GTK_IS_WINDOW (toplevel))
{
gimp_display_shell_scale_shrink_wrap (shell, TRUE);
gtk_window_present (GTK_WINDOW (toplevel));
gtk_window_present (GTK_WINDOW (toplevel));
}
return FALSE;
}
@ -1610,11 +1613,10 @@ gimp_display_shell_flush (GimpDisplayShell *shell,
}
else
{
GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (shell));
GimpImageWindow *window = GIMP_IMAGE_WINDOW (toplevel);
GimpImageWindow *window = gimp_display_shell_get_window (shell);
GimpContext *context;
if (gimp_image_window_get_active_shell (window) == shell)
if (window && gimp_image_window_get_active_shell (window) == shell)
{
gimp_ui_manager_update (window->menubar_manager, shell->display);
}

View file

@ -359,10 +359,11 @@ gui_display_create (Gimp *gimp,
/* FIXME image window: do this elsewhere */
{
GtkWidget *toplevel = gtk_widget_get_toplevel (display->shell);
GimpImageWindow *window;
gimp_ui_manager_update (GIMP_IMAGE_WINDOW (toplevel)->menubar_manager,
display);
window = gimp_display_shell_get_window (GIMP_DISPLAY_SHELL (display->shell));
gimp_ui_manager_update (window->menubar_manager, display);
}
return GIMP_OBJECT (display);

View file

@ -532,7 +532,6 @@ gui_restore_after_callback (Gimp *gimp,
/* move keyboard focus to the display */
gtk_window_present (GTK_WINDOW (gtk_widget_get_toplevel (display->shell)));
}
/* indicate that the application has finished loading */
@ -702,11 +701,12 @@ gui_menu_show_tooltip (GimpUIManager *manager,
if (display)
{
GtkWidget *toplevel = gtk_widget_get_toplevel (display->shell);
GtkWidget *statusbar = GIMP_IMAGE_WINDOW (toplevel)->statusbar;
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (display->shell);
GimpImageWindow *window = gimp_display_shell_get_window (shell);
gimp_statusbar_push (GIMP_STATUSBAR (statusbar), "menu-tooltip",
NULL, "%s", tooltip);
if (window)
gimp_statusbar_push (GIMP_STATUSBAR (window->statusbar), "menu-tooltip",
NULL, "%s", tooltip);
}
}
@ -719,10 +719,11 @@ gui_menu_hide_tooltip (GimpUIManager *manager,
if (display)
{
GtkWidget *toplevel = gtk_widget_get_toplevel (display->shell);
GtkWidget *statusbar = GIMP_IMAGE_WINDOW (toplevel)->statusbar;
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (display->shell);
GimpImageWindow *window = gimp_display_shell_get_window (shell);
gimp_statusbar_pop (GIMP_STATUSBAR (statusbar), "menu-tooltip");
if (window)
gimp_statusbar_pop (GIMP_STATUSBAR (window->statusbar), "menu-tooltip");
}
}

View file

@ -333,10 +333,10 @@ gimp_measure_tool_button_press (GimpTool *tool,
/* create the info window if necessary */
if (! measure->dialog)
{
GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (shell));
GimpImageWindow *window = gimp_display_shell_get_window (shell);
if (options->use_info_window ||
! GTK_WIDGET_VISIBLE (GIMP_IMAGE_WINDOW (toplevel)->statusbar))
! GTK_WIDGET_VISIBLE (window->statusbar))
{
measure->dialog = gimp_measure_tool_dialog_new (measure);
g_object_add_weak_pointer (G_OBJECT (measure->dialog),

View file

@ -895,27 +895,31 @@ gimp_tool_push_status (GimpTool *tool,
const gchar *format,
...)
{
GtkWidget *toplevel;
GtkWidget *statusbar;
const gchar *stock_id;
va_list args;
GimpDisplayShell *shell;
GimpImageWindow *window;
g_return_if_fail (GIMP_IS_TOOL (tool));
g_return_if_fail (GIMP_IS_DISPLAY (display));
g_return_if_fail (format != NULL);
toplevel = gtk_widget_get_toplevel (display->shell);
statusbar = GIMP_IMAGE_WINDOW (toplevel)->statusbar;
shell = GIMP_DISPLAY_SHELL (display->shell);
window = gimp_display_shell_get_window (shell);
stock_id = gimp_viewable_get_stock_id (GIMP_VIEWABLE (tool->tool_info));
if (window)
{
const gchar *stock_id;
va_list args;
va_start (args, format);
stock_id = gimp_viewable_get_stock_id (GIMP_VIEWABLE (tool->tool_info));
gimp_statusbar_push_valist (GIMP_STATUSBAR (statusbar),
G_OBJECT_TYPE_NAME (tool), stock_id,
format, args);
va_start (args, format);
va_end (args);
gimp_statusbar_push_valist (GIMP_STATUSBAR (window->statusbar),
G_OBJECT_TYPE_NAME (tool), stock_id,
format, args);
va_end (args);
}
tool->status_displays = g_list_remove (tool->status_displays, display);
tool->status_displays = g_list_prepend (tool->status_displays, display);
@ -931,22 +935,26 @@ gimp_tool_push_status_coords (GimpTool *tool,
gdouble y,
const gchar *help)
{
GtkWidget *toplevel;
GtkWidget *statusbar;
const gchar *stock_id;
GimpDisplayShell *shell;
GimpImageWindow *window;
g_return_if_fail (GIMP_IS_TOOL (tool));
g_return_if_fail (GIMP_IS_DISPLAY (display));
toplevel = gtk_widget_get_toplevel (display->shell);
statusbar = GIMP_IMAGE_WINDOW (toplevel)->statusbar;
shell = GIMP_DISPLAY_SHELL (display->shell);
window = gimp_display_shell_get_window (shell);
stock_id = gimp_viewable_get_stock_id (GIMP_VIEWABLE (tool->tool_info));
if (window)
{
const gchar *stock_id;
gimp_statusbar_push_coords (GIMP_STATUSBAR (statusbar),
G_OBJECT_TYPE_NAME (tool), stock_id,
precision, title, x, separator, y,
help);
stock_id = gimp_viewable_get_stock_id (GIMP_VIEWABLE (tool->tool_info));
gimp_statusbar_push_coords (GIMP_STATUSBAR (window->statusbar),
G_OBJECT_TYPE_NAME (tool), stock_id,
precision, title, x, separator, y,
help);
}
tool->status_displays = g_list_remove (tool->status_displays, display);
tool->status_displays = g_list_prepend (tool->status_displays, display);
@ -960,21 +968,25 @@ gimp_tool_push_status_length (GimpTool *tool,
gdouble value,
const gchar *help)
{
GtkWidget *toplevel;
GtkWidget *statusbar;
const gchar *stock_id;
GimpDisplayShell *shell;
GimpImageWindow *window;
g_return_if_fail (GIMP_IS_TOOL (tool));
g_return_if_fail (GIMP_IS_DISPLAY (display));
toplevel = gtk_widget_get_toplevel (display->shell);
statusbar = GIMP_IMAGE_WINDOW (toplevel)->statusbar;
shell = GIMP_DISPLAY_SHELL (display->shell);
window = gimp_display_shell_get_window (shell);
stock_id = gimp_viewable_get_stock_id (GIMP_VIEWABLE (tool->tool_info));
if (window)
{
const gchar *stock_id;
gimp_statusbar_push_length (GIMP_STATUSBAR (statusbar),
G_OBJECT_TYPE_NAME (tool), stock_id,
title, axis, value, help);
stock_id = gimp_viewable_get_stock_id (GIMP_VIEWABLE (tool->tool_info));
gimp_statusbar_push_length (GIMP_STATUSBAR (window->statusbar),
G_OBJECT_TYPE_NAME (tool), stock_id,
title, axis, value, help);
}
tool->status_displays = g_list_remove (tool->status_displays, display);
tool->status_displays = g_list_prepend (tool->status_displays, display);
@ -986,27 +998,31 @@ gimp_tool_replace_status (GimpTool *tool,
const gchar *format,
...)
{
GtkWidget *toplevel;
GtkWidget *statusbar;
const gchar *stock_id;
va_list args;
GimpDisplayShell *shell;
GimpImageWindow *window;
g_return_if_fail (GIMP_IS_TOOL (tool));
g_return_if_fail (GIMP_IS_DISPLAY (display));
g_return_if_fail (format != NULL);
toplevel = gtk_widget_get_toplevel (display->shell);
statusbar = GIMP_IMAGE_WINDOW (toplevel)->statusbar;
shell = GIMP_DISPLAY_SHELL (display->shell);
window = gimp_display_shell_get_window (shell);
stock_id = gimp_viewable_get_stock_id (GIMP_VIEWABLE (tool->tool_info));
if (window)
{
const gchar *stock_id;
va_list args;
va_start (args, format);
stock_id = gimp_viewable_get_stock_id (GIMP_VIEWABLE (tool->tool_info));
gimp_statusbar_replace_valist (GIMP_STATUSBAR (statusbar),
G_OBJECT_TYPE_NAME (tool), stock_id,
format, args);
va_start (args, format);
va_end (args);
gimp_statusbar_replace_valist (GIMP_STATUSBAR (window->statusbar),
G_OBJECT_TYPE_NAME (tool), stock_id,
format, args);
va_end (args);
}
tool->status_displays = g_list_remove (tool->status_displays, display);
tool->status_displays = g_list_prepend (tool->status_displays, display);
@ -1016,17 +1032,20 @@ void
gimp_tool_pop_status (GimpTool *tool,
GimpDisplay *display)
{
GtkWidget *toplevel;
GtkWidget *statusbar;
GimpDisplayShell *shell;
GimpImageWindow *window;
g_return_if_fail (GIMP_IS_TOOL (tool));
g_return_if_fail (GIMP_IS_DISPLAY (display));
toplevel = gtk_widget_get_toplevel (display->shell);
statusbar = GIMP_IMAGE_WINDOW (toplevel)->statusbar;
shell = GIMP_DISPLAY_SHELL (display->shell);
window = gimp_display_shell_get_window (shell);
gimp_statusbar_pop (GIMP_STATUSBAR (statusbar),
G_OBJECT_TYPE_NAME (tool));
if (window)
{
gimp_statusbar_pop (GIMP_STATUSBAR (window->statusbar),
G_OBJECT_TYPE_NAME (tool));
}
tool->status_displays = g_list_remove (tool->status_displays, display);
}