[gimp] app: Keep canvas position on all display shell widgets
- From: Martin Nordholts <martinn src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: Keep canvas position on all display shell widgets
- Date: Sun, 28 Feb 2010 14:23:54 +0000 (UTC)
commit 78ddb19347ea1d4314a1be722ddbf3427319dc58
Author: Martin Nordholts <martinn src gnome org>
Date: Sun Feb 28 15:22:17 2010 +0100
app: Keep canvas position on all display shell widgets
Don't use gimp_image_window_keep_canvas_pos() only for docks, use it
for all widgets in the display shell: the rulers, the menu bar, the
statusbar and the scrollbars. It is not really necessary for the two
latter ones because they are below and/or to the right of the canvas,
but we include them for completeness. Plus, they might get moved
around some day...
app/display/gimpdisplayshell-appearance.c | 4 +
app/display/gimpimagewindow.c | 99 ++++++++++++++---------------
app/display/gimpimagewindow.h | 1 +
3 files changed, 54 insertions(+), 50 deletions(-)
---
diff --git a/app/display/gimpdisplayshell-appearance.c b/app/display/gimpdisplayshell-appearance.c
index 269d3d9..e92b152 100644
--- a/app/display/gimpdisplayshell-appearance.c
+++ b/app/display/gimpdisplayshell-appearance.c
@@ -124,6 +124,7 @@ gimp_display_shell_set_show_menubar (GimpDisplayShell *shell,
if (window && gimp_image_window_get_active_shell (window) == shell)
{
+ gimp_image_window_keep_canvas_pos (gimp_display_shell_get_window (shell));
gimp_image_window_set_show_menubar (window, show);
}
@@ -150,6 +151,7 @@ gimp_display_shell_set_show_statusbar (GimpDisplayShell *shell,
g_object_set (options, "show-statusbar", show, NULL);
+ gimp_image_window_keep_canvas_pos (gimp_display_shell_get_window (shell));
gimp_statusbar_set_visible (GIMP_STATUSBAR (shell->statusbar), show);
appearance_set_action_active (shell, "view-show-statusbar", show);
@@ -175,6 +177,7 @@ gimp_display_shell_set_show_rulers (GimpDisplayShell *shell,
g_object_set (options, "show-rulers", show, NULL);
+ gimp_image_window_keep_canvas_pos (gimp_display_shell_get_window (shell));
gtk_widget_set_visible (shell->origin, show);
gtk_widget_set_visible (shell->hrule, show);
gtk_widget_set_visible (shell->vrule, show);
@@ -202,6 +205,7 @@ gimp_display_shell_set_show_scrollbars (GimpDisplayShell *shell,
g_object_set (options, "show-scrollbars", show, NULL);
+ gimp_image_window_keep_canvas_pos (gimp_display_shell_get_window (shell));
gtk_widget_set_visible (shell->nav_ebox, show);
gtk_widget_set_visible (shell->hsb, show);
gtk_widget_set_visible (shell->vsb, show);
diff --git a/app/display/gimpimagewindow.c b/app/display/gimpimagewindow.c
index 0076346..3afe6a9 100644
--- a/app/display/gimpimagewindow.c
+++ b/app/display/gimpimagewindow.c
@@ -140,7 +140,6 @@ static void gimp_image_window_show_tooltip (GimpUIManager *man
static void gimp_image_window_hide_tooltip (GimpUIManager *manager,
GimpImageWindow *window);
-static void gimp_image_window_keep_canvas_pos (GimpImageWindow *window);
static gboolean gimp_image_window_resume_shell (GimpDisplayShell *shell);
static void gimp_image_window_shell_size_allocate (GimpDisplayShell *shell,
GtkAllocation *allocation,
@@ -1035,6 +1034,55 @@ gimp_image_window_shrink_wrap (GimpImageWindow *window,
gimp_display_shell_scroll_center_image (active_shell, TRUE, TRUE);
}
+/**
+ * gimp_image_window_keep_canvas_pos:
+ * @window:
+ *
+ * Stores the coordinate of the current shell image origin in
+ * GtkWindow coordinates and on the first size-allocate sets the
+ * offsets in the shell so the image origin remains the same in
+ * GtkWindow coordinates.
+ *
+ * Exampe use case: The user hides docks attached to the side of image
+ * windows. You want the image to remain fixed on the screen though,
+ * so you use this function to keep the image fixed after the docks
+ * have been hidden.
+ **/
+void
+gimp_image_window_keep_canvas_pos (GimpImageWindow *window)
+{
+ GimpDisplayShell *shell = gimp_image_window_get_active_shell (window);
+ gint image_origin_shell_x = -1;
+ gint image_origin_shell_y = -1;
+ gint image_origin_window_x = -1;
+ gint image_origin_window_y = -1;
+ PosCorrectionData *data = NULL;
+
+ /* Freeze the active tool until the UI has stabilized. If it draws
+ * while we hide widgets there will be flicker
+ */
+ gimp_display_shell_pause (shell);
+ g_idle_add ((GSourceFunc) gimp_image_window_resume_shell, shell);
+
+ gimp_display_shell_transform_xy (shell,
+ 0.0, 0.0,
+ &image_origin_shell_x, &image_origin_shell_y,
+ FALSE /*use_offsets*/);
+ gtk_widget_translate_coordinates (GTK_WIDGET (shell->canvas),
+ GTK_WIDGET (window),
+ image_origin_shell_x, image_origin_shell_y,
+ &image_origin_window_x, &image_origin_window_y);
+
+ data = g_new0 (PosCorrectionData, 1);
+ data->window = window;
+ data->x = image_origin_window_x;
+ data->y = image_origin_window_y;
+ g_signal_connect_data (shell, "size-allocate",
+ G_CALLBACK (gimp_image_window_shell_size_allocate),
+ data, (GClosureNotify) g_free,
+ G_CONNECT_AFTER);
+}
+
/* private functions */
@@ -1089,55 +1137,6 @@ gimp_image_window_hide_tooltip (GimpUIManager *manager,
gimp_statusbar_pop (statusbar, "menu-tooltip");
}
-/**
- * gimp_image_window_keep_canvas_pos:
- * @window:
- *
- * Stores the coordinate of the current shell image origin in
- * GtkWindow coordinates and on the first size-allocate sets the
- * offsets in the shell so the image origin remains the same in
- * GtkWindow coordinates.
- *
- * Exampe use case: The user hides docks attached to the side of image
- * windows. You want the image to remain fixed on the screen though,
- * so you use this function to keep the image fixed after the docks
- * have been hidden.
- **/
-static void
-gimp_image_window_keep_canvas_pos (GimpImageWindow *window)
-{
- GimpDisplayShell *shell = gimp_image_window_get_active_shell (window);
- gint image_origin_shell_x = -1;
- gint image_origin_shell_y = -1;
- gint image_origin_window_x = -1;
- gint image_origin_window_y = -1;
- PosCorrectionData *data = NULL;
-
- /* Freeze the active tool until the UI has stabilized. If it draws
- * while we hide widgets there will be flicker
- */
- gimp_display_shell_pause (shell);
- g_idle_add ((GSourceFunc) gimp_image_window_resume_shell, shell);
-
- gimp_display_shell_transform_xy (shell,
- 0.0, 0.0,
- &image_origin_shell_x, &image_origin_shell_y,
- FALSE /*use_offsets*/);
- gtk_widget_translate_coordinates (GTK_WIDGET (shell->canvas),
- GTK_WIDGET (window),
- image_origin_shell_x, image_origin_shell_y,
- &image_origin_window_x, &image_origin_window_y);
-
- data = g_new0 (PosCorrectionData, 1);
- data->window = window;
- data->x = image_origin_window_x;
- data->y = image_origin_window_y;
- g_signal_connect_data (shell, "size-allocate",
- G_CALLBACK (gimp_image_window_shell_size_allocate),
- data, (GClosureNotify) g_free,
- G_CONNECT_AFTER);
-}
-
static gboolean
gimp_image_window_resume_shell (GimpDisplayShell *shell)
{
diff --git a/app/display/gimpimagewindow.h b/app/display/gimpimagewindow.h
index 275e2ae..cab3894 100644
--- a/app/display/gimpimagewindow.h
+++ b/app/display/gimpimagewindow.h
@@ -85,5 +85,6 @@ gboolean gimp_image_window_is_iconified (GimpImageWindow *windo
void gimp_image_window_shrink_wrap (GimpImageWindow *window,
gboolean grow_only);
+void gimp_image_window_keep_canvas_pos (GimpImageWindow *window);
#endif /* __GIMP_IMAGE_WINDOW_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]