[gimp] app: rename gimp_get_screen_resolution() to get_monitor_resolution()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: rename gimp_get_screen_resolution() to get_monitor_resolution()
- Date: Fri, 2 May 2014 22:00:11 +0000 (UTC)
commit 7cdede6decbeb401a4a2c695136d5c7686199e2e
Author: Michael Natterer <mitch gimp org>
Date: Fri May 2 23:56:16 2014 +0200
app: rename gimp_get_screen_resolution() to get_monitor_resolution()
Add a "monitor" parameter and return something reasonable, instead
of a useless resolution average of all the screen's monitors. Also
require a screen to be passed now.
app/dialogs/preferences-dialog.c | 8 ++++-
app/display/gimpdisplayshell-handlers.c | 7 +++--
app/display/gimpdisplayshell.c | 12 +++++---
app/gui/gui.c | 4 ++-
app/widgets/gimpwidgets-utils.c | 45 ++++++++++++++----------------
app/widgets/gimpwidgets-utils.h | 3 +-
6 files changed, 43 insertions(+), 36 deletions(-)
---
diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c
index 6060fea..d527296 100644
--- a/app/dialogs/preferences-dialog.c
+++ b/app/dialogs/preferences-dialog.c
@@ -450,7 +450,9 @@ prefs_resolution_source_callback (GtkWidget *widget,
if (from_gdk)
{
- gimp_get_screen_resolution (NULL, &xres, &yres);
+ gimp_get_monitor_resolution (gtk_widget_get_screen (widget),
+ gimp_widget_get_monitor (widget),
+ &xres, &yres);
}
else
{
@@ -2204,7 +2206,9 @@ prefs_dialog_new (Gimp *gimp,
gdouble xres, yres;
gchar *str;
- gimp_get_screen_resolution (NULL, &xres, &yres);
+ gimp_get_monitor_resolution (gdk_screen_get_default (), /* FIXME monitor */
+ 0, /* FIXME monitor */
+ &xres, &yres);
str = g_strdup_printf (_("_Detect automatically (currently %d × %d ppi)"),
ROUND (xres), ROUND (yres));
diff --git a/app/display/gimpdisplayshell-handlers.c b/app/display/gimpdisplayshell-handlers.c
index ea65df4..d208a5d 100644
--- a/app/display/gimpdisplayshell-handlers.c
+++ b/app/display/gimpdisplayshell-handlers.c
@@ -952,9 +952,10 @@ gimp_display_shell_monitor_res_notify_handler (GObject *config,
{
if (GIMP_DISPLAY_CONFIG (config)->monitor_res_from_gdk)
{
- gimp_get_screen_resolution (gtk_widget_get_screen (GTK_WIDGET (shell)),
- &shell->monitor_xres,
- &shell->monitor_yres);
+ gimp_get_monitor_resolution (gtk_widget_get_screen (GTK_WIDGET (shell)),
+ gimp_widget_get_monitor (GTK_WIDGET (shell)),
+ &shell->monitor_xres,
+ &shell->monitor_yres);
}
else
{
diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c
index c4790a3..8e97261 100644
--- a/app/display/gimpdisplayshell.c
+++ b/app/display/gimpdisplayshell.c
@@ -406,8 +406,9 @@ gimp_display_shell_constructed (GObject *object)
if (config->monitor_res_from_gdk)
{
- gimp_get_screen_resolution (screen,
- &shell->monitor_xres, &shell->monitor_yres);
+ gimp_get_monitor_resolution (screen, /* FIXME monitor */
+ 0, /* FIXME monitor */
+ &shell->monitor_xres, &shell->monitor_yres);
}
else
{
@@ -990,9 +991,10 @@ gimp_display_shell_screen_changed (GtkWidget *widget,
if (shell->display->config->monitor_res_from_gdk)
{
- gimp_get_screen_resolution (gtk_widget_get_screen (widget),
- &shell->monitor_xres,
- &shell->monitor_yres);
+ gimp_get_monitor_resolution (gtk_widget_get_screen (widget),
+ gimp_widget_get_monitor (widget),
+ &shell->monitor_xres,
+ &shell->monitor_yres);
}
else
{
diff --git a/app/gui/gui.c b/app/gui/gui.c
index a1d4a15..0ad2b70 100644
--- a/app/gui/gui.c
+++ b/app/gui/gui.c
@@ -409,7 +409,9 @@ gui_restore_callback (Gimp *gimp,
{
gdouble xres, yres;
- gimp_get_screen_resolution (NULL, &xres, &yres);
+ gimp_get_monitor_resolution (initial_screen,
+ initial_monitor,
+ &xres, &yres);
g_object_set (gimp->config,
"monitor-xresolution", xres,
diff --git a/app/widgets/gimpwidgets-utils.c b/app/widgets/gimpwidgets-utils.c
index 8d5fde5..ceb0850 100644
--- a/app/widgets/gimpwidgets-utils.c
+++ b/app/widgets/gimpwidgets-utils.c
@@ -724,36 +724,33 @@ gimp_get_all_modifiers_mask (void)
}
/**
- * gimp_get_screen_resolution:
- * @screen: a #GdkScreen or %NULL
- * @xres: returns the horizontal screen resolution (in dpi)
- * @yres: returns the vertical screen resolution (in dpi)
+ * gimp_get_monitor_resolution:
+ * @screen: a #GdkScreen
+ * @monitor: a monitor number
+ * @xres: returns the horizontal monitor resolution (in dpi)
+ * @yres: returns the vertical monitor resolution (in dpi)
*
- * Retrieves the screen resolution from GDK. If @screen is %NULL, the
- * default screen is used.
+ * Retrieves the monitor's resolution from GDK.
**/
void
-gimp_get_screen_resolution (GdkScreen *screen,
- gdouble *xres,
- gdouble *yres)
+gimp_get_monitor_resolution (GdkScreen *screen,
+ gint monitor,
+ gdouble *xres,
+ gdouble *yres)
{
- gint width, height;
- gint width_mm, height_mm;
- gdouble x = 0.0;
- gdouble y = 0.0;
+ GdkRectangle size_pixels;
+ gint width_mm, height_mm;
+ gdouble x = 0.0;
+ gdouble y = 0.0;
- g_return_if_fail (screen == NULL || GDK_IS_SCREEN (screen));
+ g_return_if_fail (GDK_IS_SCREEN (screen));
g_return_if_fail (xres != NULL);
g_return_if_fail (yres != NULL);
- if (!screen)
- screen = gdk_screen_get_default ();
+ gdk_screen_get_monitor_geometry (screen, monitor, &size_pixels);
- width = gdk_screen_get_width (screen);
- height = gdk_screen_get_height (screen);
-
- width_mm = gdk_screen_get_width_mm (screen);
- height_mm = gdk_screen_get_height_mm (screen);
+ width_mm = gdk_screen_get_monitor_width_mm (screen, monitor);
+ height_mm = gdk_screen_get_monitor_height_mm (screen, monitor);
/*
* From xdpyinfo.c:
@@ -767,14 +764,14 @@ gimp_get_screen_resolution (GdkScreen *screen,
if (width_mm > 0 && height_mm > 0)
{
- x = (width * 25.4) / (gdouble) width_mm;
- y = (height * 25.4) / (gdouble) height_mm;
+ x = (size_pixels.width * 25.4) / (gdouble) width_mm;
+ y = (size_pixels.height * 25.4) / (gdouble) height_mm;
}
if (x < GIMP_MIN_RESOLUTION || x > GIMP_MAX_RESOLUTION ||
y < GIMP_MIN_RESOLUTION || y > GIMP_MAX_RESOLUTION)
{
- g_warning ("GDK returned bogus values for the screen resolution, "
+ g_warning ("GDK returned bogus values for the monitor resolution, "
"using 96 dpi instead.");
x = 96.0;
diff --git a/app/widgets/gimpwidgets-utils.h b/app/widgets/gimpwidgets-utils.h
index 81bf514..a9c0b5f 100644
--- a/app/widgets/gimpwidgets-utils.h
+++ b/app/widgets/gimpwidgets-utils.h
@@ -66,7 +66,8 @@ GdkModifierType gimp_get_toggle_behavior_mask (void);
GdkModifierType gimp_get_constrain_behavior_mask (void);
GdkModifierType gimp_get_all_modifiers_mask (void);
-void gimp_get_screen_resolution (GdkScreen *screen,
+void gimp_get_monitor_resolution (GdkScreen *screen,
+ gint monitor,
gdouble *xres,
gdouble *yres);
void gimp_rgb_get_gdk_color (const GimpRGB *rgb,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]