2006-12-09 21:33:38 +00:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2000-09-25 01:31:48 +00:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-17 22:28:01 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2000-09-25 01:31:48 +00:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-17 22:28:01 +00:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2000-09-25 01:31:48 +00:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2018-07-11 23:27:07 +02:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2000-09-25 01:31:48 +00:00
|
|
|
*/
|
2000-12-16 21:37:03 +00:00
|
|
|
|
2000-09-25 01:31:48 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
2013-11-01 22:28:18 +01:00
|
|
|
#include <gegl.h>
|
2000-12-16 21:37:03 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2001-01-23 23:56:18 +00:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
2001-05-21 20:30:16 +00:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2001-01-24 22:36:18 +00:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
2001-01-23 23:56:18 +00:00
|
|
|
|
2001-05-22 21:12:43 +00:00
|
|
|
#include "resolution-calibrate-dialog.h"
|
2000-09-25 01:31:48 +00:00
|
|
|
|
2003-03-25 16:38:19 +00:00
|
|
|
#include "gimp-intl.h"
|
2000-09-25 01:31:48 +00:00
|
|
|
|
2001-01-23 23:56:18 +00:00
|
|
|
|
2000-09-25 01:31:48 +00:00
|
|
|
static GtkWidget *calibrate_entry = NULL;
|
|
|
|
static gdouble calibrate_xres = 1.0;
|
|
|
|
static gdouble calibrate_yres = 1.0;
|
|
|
|
static gint ruler_width = 1;
|
|
|
|
static gint ruler_height = 1;
|
|
|
|
|
2001-05-22 21:12:43 +00:00
|
|
|
|
2000-09-25 01:31:48 +00:00
|
|
|
/**
|
|
|
|
* resolution_calibrate_dialog:
|
2001-05-22 21:12:43 +00:00
|
|
|
* @resolution_entry: a #GimpSizeEntry to connect the dialog to
|
2018-05-09 01:44:42 +02:00
|
|
|
* @icon_name: an optional icon-name for the upper left corner
|
2001-05-22 21:12:43 +00:00
|
|
|
*
|
|
|
|
* Displays a dialog that allows the user to interactively determine
|
|
|
|
* her monitor resolution. This dialog runs it's own GTK main loop and
|
2004-02-28 12:37:49 +00:00
|
|
|
* is connected to a #GimpSizeEntry handling the resolution to be set.
|
2001-05-22 21:12:43 +00:00
|
|
|
**/
|
2000-09-25 01:31:48 +00:00
|
|
|
void
|
2018-05-09 01:44:42 +02:00
|
|
|
resolution_calibrate_dialog (GtkWidget *resolution_entry,
|
|
|
|
const gchar *icon_name)
|
2000-09-25 01:31:48 +00:00
|
|
|
{
|
2005-02-14 13:51:02 +00:00
|
|
|
GtkWidget *dialog;
|
2018-05-03 00:44:54 +02:00
|
|
|
GtkWidget *grid;
|
2005-02-14 13:51:02 +00:00
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *ruler;
|
|
|
|
GtkWidget *label;
|
2018-05-04 13:20:46 +02:00
|
|
|
GdkRectangle workarea;
|
2000-09-25 01:31:48 +00:00
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_SIZE_ENTRY (resolution_entry));
|
2010-04-19 19:21:07 +02:00
|
|
|
g_return_if_fail (gtk_widget_get_realized (resolution_entry));
|
2003-09-09 11:35:27 +00:00
|
|
|
|
2000-09-25 01:31:48 +00:00
|
|
|
/* this dialog can only exist once */
|
|
|
|
if (calibrate_entry)
|
2003-09-09 11:35:27 +00:00
|
|
|
return;
|
|
|
|
|
2000-09-25 01:31:48 +00:00
|
|
|
dialog = gimp_dialog_new (_("Calibrate Monitor Resolution"),
|
2006-04-23 02:15:16 +00:00
|
|
|
"gimp-resolution-calibration",
|
2004-02-28 21:33:03 +00:00
|
|
|
gtk_widget_get_toplevel (resolution_entry),
|
2004-02-28 12:37:49 +00:00
|
|
|
GTK_DIALOG_DESTROY_WITH_PARENT,
|
2006-04-12 12:49:29 +00:00
|
|
|
NULL, NULL,
|
2000-09-25 01:31:48 +00:00
|
|
|
|
2017-02-12 16:06:34 +01:00
|
|
|
_("_Cancel"), GTK_RESPONSE_CANCEL,
|
|
|
|
_("_OK"), GTK_RESPONSE_OK,
|
2001-11-23 23:04:49 +00:00
|
|
|
|
2006-04-12 12:49:29 +00:00
|
|
|
NULL);
|
2000-09-25 01:31:48 +00:00
|
|
|
|
2018-05-10 17:04:37 +02:00
|
|
|
gimp_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
|
2005-02-08 20:40:33 +00:00
|
|
|
GTK_RESPONSE_OK,
|
|
|
|
GTK_RESPONSE_CANCEL,
|
|
|
|
-1);
|
|
|
|
|
2018-05-04 13:20:46 +02:00
|
|
|
gdk_monitor_get_workarea (gimp_widget_get_monitor (dialog), &workarea);
|
2003-09-09 11:35:27 +00:00
|
|
|
|
2018-05-04 13:20:46 +02:00
|
|
|
ruler_width = workarea.width - 300 - (workarea.width % 100);
|
|
|
|
ruler_height = workarea.height - 300 - (workarea.height % 100);
|
2000-09-25 01:31:48 +00:00
|
|
|
|
2018-05-03 00:44:54 +02:00
|
|
|
grid = gtk_grid_new ();
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (grid), 12);
|
2010-10-30 14:56:00 +02:00
|
|
|
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
|
2018-05-03 00:44:54 +02:00
|
|
|
grid, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (grid);
|
2003-09-09 11:35:27 +00:00
|
|
|
|
2018-05-09 01:44:42 +02:00
|
|
|
if (icon_name)
|
2002-02-28 15:11:56 +00:00
|
|
|
{
|
2018-05-09 01:44:42 +02:00
|
|
|
GtkWidget *image = gtk_image_new_from_icon_name (icon_name,
|
|
|
|
GTK_ICON_SIZE_DIALOG);
|
2004-02-28 21:33:03 +00:00
|
|
|
|
2018-05-03 00:44:54 +02:00
|
|
|
gtk_grid_attach (GTK_GRID (grid), image, 0, 0, 1, 1);
|
2002-02-28 15:11:56 +00:00
|
|
|
gtk_widget_show (image);
|
|
|
|
}
|
|
|
|
|
2008-08-29 10:25:29 +00:00
|
|
|
ruler = gimp_ruler_new (GTK_ORIENTATION_HORIZONTAL);
|
2001-12-29 13:26:29 +00:00
|
|
|
gtk_widget_set_size_request (ruler, ruler_width, 32);
|
2008-05-28 10:18:43 +00:00
|
|
|
gimp_ruler_set_range (GIMP_RULER (ruler), 0, ruler_width, ruler_width);
|
2018-05-03 00:44:54 +02:00
|
|
|
gtk_grid_attach (GTK_GRID (grid), ruler, 1, 0, 2, 1);
|
2000-09-25 01:31:48 +00:00
|
|
|
gtk_widget_show (ruler);
|
|
|
|
|
2008-08-29 10:25:29 +00:00
|
|
|
ruler = gimp_ruler_new (GTK_ORIENTATION_VERTICAL);
|
2001-12-29 13:26:29 +00:00
|
|
|
gtk_widget_set_size_request (ruler, 32, ruler_height);
|
2008-05-28 10:18:43 +00:00
|
|
|
gimp_ruler_set_range (GIMP_RULER (ruler), 0, ruler_height, ruler_height);
|
2018-05-03 00:44:54 +02:00
|
|
|
gtk_grid_attach (GTK_GRID (grid), ruler, 0, 1, 1, 2);
|
2000-09-25 01:31:48 +00:00
|
|
|
gtk_widget_show (ruler);
|
|
|
|
|
2011-09-30 11:29:11 +02:00
|
|
|
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
|
2018-05-03 00:44:54 +02:00
|
|
|
gtk_grid_attach (GTK_GRID (grid), vbox, 1, 1, 1, 1);
|
2000-09-25 01:31:48 +00:00
|
|
|
gtk_widget_show (vbox);
|
2003-09-09 11:35:27 +00:00
|
|
|
|
|
|
|
label =
|
2004-06-09 23:51:06 +00:00
|
|
|
gtk_label_new (_("Measure the rulers and enter their lengths:"));
|
2000-09-25 01:31:48 +00:00
|
|
|
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
|
2016-09-08 19:11:20 +02:00
|
|
|
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
|
2004-06-21 13:18:50 +00:00
|
|
|
gimp_label_set_attributes (GTK_LABEL (label),
|
|
|
|
PANGO_ATTR_SCALE, PANGO_SCALE_LARGE,
|
|
|
|
PANGO_ATTR_WEIGHT, PANGO_WEIGHT_BOLD,
|
|
|
|
-1);
|
2000-09-25 01:31:48 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
2011-09-30 11:29:11 +02:00
|
|
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
2000-09-25 01:31:48 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
2003-09-09 11:35:27 +00:00
|
|
|
calibrate_xres =
|
2002-02-28 15:11:56 +00:00
|
|
|
gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (resolution_entry), 0);
|
2003-09-09 11:35:27 +00:00
|
|
|
calibrate_yres =
|
2002-02-28 15:11:56 +00:00
|
|
|
gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (resolution_entry), 1);
|
2000-09-25 01:31:48 +00:00
|
|
|
|
|
|
|
calibrate_entry =
|
Issue #434: remove broken plural support for GimpUnit.
Rather than trying to implement full i18n plural support, we just remove
this failed attempt from the past. The fact is that to get proper
support, we'd basically need to reimplement a Gettext-like plural
definition syntax within our API, then ask people to write down this
plural definition for their language, then to write every plural form…
all this for custom units which only them will ever see!
Moreover code investigation shows that the singular form was simply
never used, and the plural form was always used (whatever the actual
unit value displayed).
As for the "identifier", this was a text which was never shown anywhere
(except in the unit editor) and for all built-in units, as well as
default unitrc units, it was equivalent to the English plural value.
So we now just have a unique name which is the "long label" to be used
everywhere in the GUI, and abbreviation will be basically the "short
label". That's it. No useless (or worse, not actually usable because it
was not generic internationalization) values anymore!
2024-08-05 16:02:47 +02:00
|
|
|
gimp_coordinates_new (gimp_unit_inch (), "%n",
|
2006-04-12 12:49:29 +00:00
|
|
|
FALSE, FALSE, 10,
|
|
|
|
GIMP_SIZE_ENTRY_UPDATE_SIZE,
|
|
|
|
FALSE,
|
|
|
|
FALSE,
|
|
|
|
_("_Horizontal:"),
|
|
|
|
ruler_width,
|
|
|
|
calibrate_xres,
|
|
|
|
1, GIMP_MAX_IMAGE_SIZE,
|
|
|
|
0, 0,
|
|
|
|
_("_Vertical:"),
|
|
|
|
ruler_height,
|
|
|
|
calibrate_yres,
|
|
|
|
1, GIMP_MAX_IMAGE_SIZE,
|
|
|
|
0, 0);
|
2000-09-25 01:31:48 +00:00
|
|
|
gtk_widget_hide (GTK_WIDGET (GIMP_COORDINATES_CHAINBUTTON (calibrate_entry)));
|
2003-01-05 22:07:10 +00:00
|
|
|
g_signal_connect (dialog, "destroy",
|
2001-08-01 09:33:12 +00:00
|
|
|
G_CALLBACK (gtk_widget_destroyed),
|
|
|
|
&calibrate_entry);
|
2000-09-25 01:31:48 +00:00
|
|
|
|
|
|
|
gtk_box_pack_end (GTK_BOX (hbox), calibrate_entry, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (calibrate_entry);
|
2001-05-22 21:12:43 +00:00
|
|
|
|
2000-09-25 01:31:48 +00:00
|
|
|
gtk_widget_show (dialog);
|
|
|
|
|
2003-11-11 18:11:56 +00:00
|
|
|
switch (gimp_dialog_run (GIMP_DIALOG (dialog)))
|
2003-11-06 15:27:05 +00:00
|
|
|
{
|
|
|
|
case GTK_RESPONSE_OK:
|
|
|
|
{
|
|
|
|
GtkWidget *chain_button;
|
|
|
|
gdouble x, y;
|
|
|
|
|
|
|
|
x = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (calibrate_entry), 0);
|
|
|
|
y = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (calibrate_entry), 1);
|
|
|
|
|
|
|
|
calibrate_xres = (gdouble) ruler_width * calibrate_xres / x;
|
|
|
|
calibrate_yres = (gdouble) ruler_height * calibrate_yres / y;
|
|
|
|
|
|
|
|
chain_button = GIMP_COORDINATES_CHAINBUTTON (resolution_entry);
|
|
|
|
|
2004-02-28 21:33:03 +00:00
|
|
|
if (ABS (x - y) > GIMP_MIN_RESOLUTION)
|
|
|
|
gimp_chain_button_set_active (GIMP_CHAIN_BUTTON (chain_button),
|
|
|
|
FALSE);
|
2003-11-06 15:27:05 +00:00
|
|
|
|
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (resolution_entry),
|
|
|
|
0, calibrate_xres);
|
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (resolution_entry),
|
|
|
|
1, calibrate_yres);
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_widget_destroy (dialog);
|
2000-09-25 01:31:48 +00:00
|
|
|
}
|