gimp r25032 - in branches/weskaggs: . app/display
- From: weskaggs svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r25032 - in branches/weskaggs: . app/display
- Date: Tue, 4 Mar 2008 19:03:28 +0000 (GMT)
Author: weskaggs
Date: Tue Mar 4 19:03:28 2008
New Revision: 25032
URL: http://svn.gnome.org/viewvc/gimp?rev=25032&view=rev
Log:
Bill Skaggs <weskaggs primate ucdavis edu>
* app/display/gimpdisplayshell.[ch]
(gimp_display_shell_set_initial_scale): Factor out code
from gimp_display_shell_new.
* app/display/gimpdisplay.c (gimp_display_reconnect):
Scale things properly when opening an image in a
no-image-open display.
Modified:
branches/weskaggs/ChangeLog
branches/weskaggs/app/display/gimpdisplay.c
branches/weskaggs/app/display/gimpdisplayshell.c
branches/weskaggs/app/display/gimpdisplayshell.h
Modified: branches/weskaggs/app/display/gimpdisplay.c
==============================================================================
--- branches/weskaggs/app/display/gimpdisplay.c (original)
+++ branches/weskaggs/app/display/gimpdisplay.c Tue Mar 4 19:03:28 2008
@@ -53,6 +53,7 @@
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-appearance.h"
#include "gimpdisplayshell-handlers.h"
+#include "gimpdisplayshell-scale.h"
#include "gimpdisplayshell-transform.h"
#include "gimp-intl.h"
@@ -443,7 +444,7 @@
/* create the shell for the image */
display->shell = gimp_display_shell_new (display, unit, scale,
- menu_factory, popup_manager);
+ menu_factory, popup_manager);
shell = GIMP_DISPLAY_SHELL (display->shell);
gimp_display_shell_set_show_layer (shell, FALSE);
@@ -659,7 +660,16 @@
gimp_display_connect (display, image);
if (image->gimp->scratch_image == old_image)
- gimp_display_shell_configure (GIMP_DISPLAY_SHELL (display->shell));
+ {
+ GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (display->shell);
+ gint n_width;
+ gint n_height;
+
+ gimp_display_shell_set_initial_scale (shell, &n_width, &n_height);
+ gtk_widget_set_size_request (shell->canvas, n_width, n_height);
+ gimp_display_shell_configure (shell);
+ gimp_display_shell_scale_resize (shell, TRUE, TRUE);
+ }
g_object_unref (old_image);
Modified: branches/weskaggs/app/display/gimpdisplayshell.c
==============================================================================
--- branches/weskaggs/app/display/gimpdisplayshell.c (original)
+++ branches/weskaggs/app/display/gimpdisplayshell.c Tue Mar 4 19:03:28 2008
@@ -645,12 +645,9 @@
GtkWidget *lower_hbox;
GtkWidget *inner_table;
GtkWidget *image;
- GdkScreen *screen;
GtkAction *action;
gint image_width, image_height;
gint n_width, n_height;
- gint s_width, s_height;
- gdouble new_scale;
g_return_val_if_fail (GIMP_IS_DISPLAY (display), NULL);
g_return_val_if_fail (GIMP_IS_MENU_FACTORY (menu_factory), NULL);
@@ -683,63 +680,7 @@
* value is the same as in gimp_display_shell_shrink_wrap. It
* probably should be a user-configurable option.
*/
- screen = gtk_widget_get_screen (GTK_WIDGET (shell));
-
- if (display_config->monitor_res_from_gdk)
- {
- gimp_get_screen_resolution (screen,
- &shell->monitor_xres, &shell->monitor_yres);
- }
- else
- {
- shell->monitor_xres = display_config->monitor_xres;
- shell->monitor_yres = display_config->monitor_yres;
- }
-
- s_width = gdk_screen_get_width (screen) * 0.75;
- s_height = gdk_screen_get_height (screen) * 0.75;
-
- n_width = SCALEX (shell, image_width);
- n_height = SCALEY (shell, image_height);
-
- if (display_config->initial_zoom_to_fit)
- {
- /* Limit to the size of the screen... */
- if (n_width > s_width || n_height > s_height)
- {
- gdouble current = gimp_zoom_model_get_factor (shell->zoom);
-
- new_scale = current * MIN (((gdouble) s_height) / n_height,
- ((gdouble) s_width) / n_width);
-
- new_scale = gimp_zoom_model_zoom_step (GIMP_ZOOM_OUT, new_scale);
-
- /* Since zooming out might skip a zoom step we zoom in again
- * and test if we are small enough.
- */
- gimp_zoom_model_zoom (shell->zoom, GIMP_ZOOM_TO,
- gimp_zoom_model_zoom_step (GIMP_ZOOM_IN,
- new_scale));
-
- if (SCALEX (shell, image_width) > s_width ||
- SCALEY (shell, image_height) > s_height)
- gimp_zoom_model_zoom (shell->zoom, GIMP_ZOOM_TO, new_scale);
-
- n_width = SCALEX (shell, image_width);
- n_height = SCALEY (shell, image_height);
- }
- }
- else
- {
- /* Set up size like above, but do not zoom to fit.
- Useful when working on large images. */
-
- if (n_width > s_width)
- n_width = s_width;
-
- if (n_height > s_height)
- n_height = s_height;
- }
+ gimp_display_shell_set_initial_scale (shell, &n_width, &n_height);
shell->menubar_manager = gimp_menu_factory_manager_new (menu_factory,
"<Image>",
@@ -1117,6 +1058,84 @@
}
void
+gimp_display_shell_set_initial_scale (GimpDisplayShell *shell,
+ gint *n_width_ptr,
+ gint *n_height_ptr)
+{
+ GimpDisplay *display = shell->display;
+ Gimp *gimp = display->image->gimp;
+ GimpDisplayConfig *display_config = GIMP_DISPLAY_CONFIG (gimp->config);
+ GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (shell));
+ gint image_width = gimp_image_get_width (display->image);
+ gint image_height = gimp_image_get_height (display->image);
+ gdouble new_scale;
+ gint s_width;
+ gint s_height;
+ gint n_width;
+ gint n_height;
+
+
+ if (display_config->monitor_res_from_gdk)
+ {
+ gimp_get_screen_resolution (screen,
+ &shell->monitor_xres, &shell->monitor_yres);
+ }
+ else
+ {
+ shell->monitor_xres = display_config->monitor_xres;
+ shell->monitor_yres = display_config->monitor_yres;
+ }
+
+ s_width = gdk_screen_get_width (screen) * 0.75;
+ s_height = gdk_screen_get_height (screen) * 0.75;
+
+ n_width = SCALEX (shell, image_width);
+ n_height = SCALEY (shell, image_height);
+
+ if (display_config->initial_zoom_to_fit)
+ {
+ /* Limit to the size of the screen... */
+ if (n_width > s_width || n_height > s_height)
+ {
+ gdouble current = gimp_zoom_model_get_factor (shell->zoom);
+
+ new_scale = current * MIN (((gdouble) s_height) / n_height,
+ ((gdouble) s_width) / n_width);
+
+ new_scale = gimp_zoom_model_zoom_step (GIMP_ZOOM_OUT, new_scale);
+
+ /* Since zooming out might skip a zoom step we zoom in again
+ * and test if we are small enough.
+ */
+ gimp_zoom_model_zoom (shell->zoom, GIMP_ZOOM_TO,
+ gimp_zoom_model_zoom_step (GIMP_ZOOM_IN,
+ new_scale));
+
+ if (SCALEX (shell, image_width) > s_width ||
+ SCALEY (shell, image_height) > s_height)
+ gimp_zoom_model_zoom (shell->zoom, GIMP_ZOOM_TO, new_scale);
+
+ n_width = SCALEX (shell, image_width);
+ n_height = SCALEY (shell, image_height);
+ }
+ }
+ else
+ {
+ /* Set up size like above, but do not zoom to fit.
+ Useful when working on large images. */
+
+ if (n_width > s_width)
+ n_width = s_width;
+
+ if (n_height > s_height)
+ n_height = s_height;
+ }
+
+ *n_width_ptr = n_width;
+ *n_height_ptr = n_height;
+}
+
+void
gimp_display_shell_configure (GimpDisplayShell *shell)
{
Gimp *gimp;
Modified: branches/weskaggs/app/display/gimpdisplayshell.h
==============================================================================
--- branches/weskaggs/app/display/gimpdisplayshell.h (original)
+++ branches/weskaggs/app/display/gimpdisplayshell.h Tue Mar 4 19:03:28 2008
@@ -259,6 +259,8 @@
GimpDrawable *mask,
GimpChannelType color);
void gimp_display_shell_configure (GimpDisplayShell *shell);
-
+void gimp_display_shell_set_initial_scale (GimpDisplayShell *shell,
+ gint *n_width_ptr,
+ gint *n_height_ptr);
#endif /* __GIMP_DISPLAY_SHELL_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]