Commit f4342ab8 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

new files. Code for the resolution calibration dialog that used to live in

2000-09-25  Sven Neumann  <sven@gimp.org>

	* app/resolution_calibrate.[ch]: new files. Code for the resolution
	calibration dialog that used to live in user_install.c

	* app/Makefile.in
	* app/menus.c
	* app/preferences_dialog.[ch]
	* app/user_install.[ch]: added a Calibrate button to the Preferences
parent ecddfcb9
2000-09-25 Sven Neumann <sven@gimp.org>
* app/resolution_calibrate.[ch]: new files. Code for the resolution
calibration dialog that used to live in user_install.c
* app/Makefile.in
* app/menus.c
* app/preferences_dialog.[ch]
* app/user_install.[ch]: added a Calibrate button to the Preferences
2000-09-23 Kevin Turner <acapnotic@users.sourceforge.net>
 
* plug-ins/pygimp/gimpmodule.c (newpfobject): use correct type for
......
......@@ -366,6 +366,8 @@ gimp_SOURCES = \
rect_selectP.h \
regex.h \
regex.c \
resolution_calibrate.c \
resolution_calibrate.h \
resize.c \
resize.h \
rotate_tool.c \
......
This diff is collapsed.
......@@ -19,6 +19,8 @@
#ifndef __PREFERENCES_DIALOG_H__
#define __PREFERENCES_DIALOG_H__
void file_pref_cmd_callback (GtkWidget *, gpointer);
void prefs_cmd_callback (GtkWidget *widget, gpointer data);
#endif /* __PREFERENCES_DIALOG_H__ */
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
* Copyright (C) 2000 Michael Natterer and Sven Neumann
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -31,9 +32,9 @@
#include "gdisplay_ops.h"
#include "gimprc.h"
#include "gimpui.h"
#include "resolution_calibrate.h"
#include "unitrc.h"
#include "user_install.h"
#include "libgimp/gimpenv.h"
#include "libgimp/gimplimits.h"
#include "libgimp/gimpmath.h"
......@@ -1138,200 +1139,13 @@ user_install_tuning_done (void)
{
}
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;
static void
user_install_resolution_calibrate_ok (GtkWidget *button,
gpointer data)
{
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;
if (ABS (x -y) > GIMP_MIN_RESOLUTION)
gimp_chain_button_set_active (GIMP_COORDINATES_CHAINBUTTON (resolution_entry), FALSE);
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);
gtk_widget_destroy (GTK_WIDGET (data));
}
static void
user_install_resolution_calibrate (GtkWidget *button,
gpointer data)
{
GtkWidget *dialog;
GtkWidget *table;
GtkWidget *ebox;
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *darea;
GtkWidget *ruler;
GList *list;
gtk_widget_hide (user_install_dialog);
dialog = gimp_dialog_new (_("Calibrate Monitor Resolution"),
"calibrate_resolution",
NULL, NULL,
GTK_WIN_POS_CENTER,
FALSE, FALSE, FALSE,
_("OK"), user_install_resolution_calibrate_ok,
NULL, NULL, NULL, TRUE, FALSE,
_("Cancel"), gtk_widget_destroy,
NULL, 1, NULL, FALSE, TRUE,
NULL);
gtk_signal_connect (GTK_OBJECT (dialog), "destroy",
GTK_SIGNAL_FUNC (gtk_main_quit),
NULL);
TITLE_STYLE (dialog);
gimp_dialog_set_icon (GTK_WINDOW (dialog));
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area), 8);
/* hide the separator between the dialog's vbox and the action area */
/* gtk_widget_destroy (GTK_WIDGET (g_list_nth_data (gtk_container_children (GTK_CONTAINER (GTK_BIN (dialog)->child)), 0)));*/
ruler_width = gdk_screen_width ();
ruler_height = gdk_screen_height ();
ruler_width = ruler_width - 300 - (ruler_width % 100);
ruler_height = ruler_height - 300 - (ruler_height % 100);
table = gtk_table_new (4, 4, FALSE);
gtk_container_set_border_width (GTK_CONTAINER (table), 16);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), table);
gtk_widget_show (table);
ruler = gtk_hruler_new ();
PAGE_STYLE (ruler);
gtk_widget_set_usize (ruler, ruler_width, 32);
gtk_ruler_set_range (GTK_RULER (ruler), 0, ruler_width, 0, ruler_width);
gtk_table_attach (GTK_TABLE (table), ruler, 1, 3, 0, 1,
GTK_SHRINK, GTK_SHRINK, 0, 0);
gtk_widget_show (ruler);
ruler = gtk_vruler_new ();
PAGE_STYLE (ruler);
gtk_widget_set_usize (ruler, 32, ruler_height);
gtk_ruler_set_range (GTK_RULER (ruler), 0, ruler_height, 0, ruler_height);
gtk_table_attach (GTK_TABLE (table), ruler, 0, 1, 1, 3,
GTK_SHRINK, GTK_SHRINK, 0, 0);
gtk_widget_show (ruler);
ebox = gtk_event_box_new ();
PAGE_STYLE (ebox);
gtk_table_attach (GTK_TABLE (table), ebox, 1, 2, 1, 2,
GTK_SHRINK, GTK_SHRINK, 0, 0);
gtk_widget_show (ebox);
table = gtk_table_new (3, 3, FALSE);
gtk_container_add (GTK_CONTAINER (ebox), table);
gtk_widget_show (table);
darea = gtk_drawing_area_new ();
TITLE_STYLE (darea);
gtk_drawing_area_size (GTK_DRAWING_AREA (darea), 16, 16);
gtk_signal_connect_after (GTK_OBJECT (darea), "expose_event",
GTK_SIGNAL_FUNC (user_install_corner_expose),
(gpointer) GTK_CORNER_TOP_LEFT);
gtk_table_attach (GTK_TABLE (table), darea, 0, 1, 0, 1,
GTK_SHRINK, GTK_SHRINK, 0, 0);
gtk_widget_show (darea);
darea = gtk_drawing_area_new ();
TITLE_STYLE (darea);
gtk_drawing_area_size (GTK_DRAWING_AREA (darea), 16, 16);
gtk_signal_connect_after (GTK_OBJECT (darea), "expose_event",
GTK_SIGNAL_FUNC (user_install_corner_expose),
(gpointer) GTK_CORNER_BOTTOM_LEFT);
gtk_table_attach (GTK_TABLE (table), darea, 0, 1, 2, 3,
GTK_SHRINK, GTK_SHRINK, 0, 0);
gtk_widget_show (darea);
darea = gtk_drawing_area_new ();
TITLE_STYLE (darea);
gtk_drawing_area_size (GTK_DRAWING_AREA (darea), 16, 16);
gtk_signal_connect_after (GTK_OBJECT (darea), "expose_event",
GTK_SIGNAL_FUNC (user_install_corner_expose),
(gpointer) GTK_CORNER_TOP_RIGHT);
gtk_table_attach (GTK_TABLE (table), darea, 2, 3, 0, 1,
GTK_SHRINK, GTK_SHRINK, 0, 0);
gtk_widget_show (darea);
darea = gtk_drawing_area_new ();
TITLE_STYLE (darea);
gtk_drawing_area_size (GTK_DRAWING_AREA (darea), 16, 16);
gtk_signal_connect_after (GTK_OBJECT (darea), "expose_event",
GTK_SIGNAL_FUNC (user_install_corner_expose),
(gpointer) GTK_CORNER_BOTTOM_RIGHT);
gtk_table_attach (GTK_TABLE (table), darea, 2, 3, 2, 3,
GTK_SHRINK, GTK_SHRINK, 0, 0);
gtk_widget_show (darea);
vbox = gtk_vbox_new (FALSE, 16);
gtk_table_attach_defaults (GTK_TABLE (table), vbox, 1, 2, 1, 2);
gtk_widget_show (vbox);
add_label (GTK_BOX (vbox),
_("Measure the rulers and enter their lengths below."));
hbox = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
calibrate_xres = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (resolution_entry), 0);
calibrate_yres = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (resolution_entry), 1);
calibrate_entry =
gimp_coordinates_new (GIMP_UNIT_INCH, "%p",
FALSE, FALSE, 75,
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);
gtk_widget_hide (GTK_WIDGET (GIMP_COORDINATES_CHAINBUTTON (calibrate_entry)));
for (list = GTK_TABLE (calibrate_entry)->children;
list;
list = g_list_next (list))
{
GtkTableChild *child = (GtkTableChild *) list->data;
if (child && GTK_IS_LABEL (child->widget))
PAGE_STYLE (GTK_WIDGET (child->widget));
}
gtk_box_pack_end (GTK_BOX (hbox), calibrate_entry, FALSE, FALSE, 0);
gtk_widget_show (calibrate_entry);
gtk_widget_show (dialog);
gtk_main ();
gtk_widget_show (user_install_dialog);
resolution_calibrate_dialog (resolution_entry,
title_style, page_style,
GTK_SIGNAL_FUNC (user_install_corner_expose));
}
static void
......@@ -1400,6 +1214,7 @@ user_install_resolution (void)
chain = GIMP_COORDINATES_CHAINBUTTON (resolution_entry);
PAGE_STYLE (GTK_WIDGET (chain->line1));
PAGE_STYLE (GTK_WIDGET (chain->line2));
gtk_object_set_data (GTK_OBJECT (resolution_entry), "chain_button", chain);
for (list = GTK_TABLE (resolution_entry)->children;
list;
......@@ -1474,8 +1289,7 @@ user_install_resolution_done (void)
}
if (strcmp (swap_path, new_swap_path))
{
g_free (swap_path);
swap_path = new_swap_path;
g_free (swap_path); swap_path = new_swap_path;
update = g_list_append (update, "swap-path");
}
if (using_xserver_resolution != new_using_xserver_resolution ||
......
......@@ -15,8 +15,10 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __INSTALL_H__
#define __INSTALL_H__
#ifndef __USER_INSTALL_H__
#define __USER_INSTALL_H__
/* Install callback function */
typedef void (* UserInstallCallback) (void);
......@@ -24,4 +26,5 @@ typedef void (* UserInstallCallback) (void);
/* Function declarations */
void user_install_verify (UserInstallCallback user_install_callback);
#endif /* INSTALL_H */
#endif /* __USER_INSTALL_H__ */
......@@ -34,6 +34,7 @@
#include "menus.h"
#include "paths_dialog.h"
#include "paint_funcs.h"
#include "preferences_dialog.h"
#include "procedural_db.h"
#include "scale.h"
#include "tools.h"
......@@ -106,7 +107,7 @@ static GimpItemFactoryEntry toolbox_entries[] =
{ { "/File/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { N_("/File/Preferences..."), NULL, file_pref_cmd_callback, 0 },
{ { N_("/File/Preferences..."), NULL, prefs_cmd_callback, 0 },
"file/dialogs/preferences/preferences.html", NULL },
/* <Toolbox>/File/Dialogs */
......
This diff is collapsed.
......@@ -19,6 +19,8 @@
#ifndef __PREFERENCES_DIALOG_H__
#define __PREFERENCES_DIALOG_H__
void file_pref_cmd_callback (GtkWidget *, gpointer);
void prefs_cmd_callback (GtkWidget *widget, gpointer data);
#endif /* __PREFERENCES_DIALOG_H__ */
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
* Copyright (C) 2000 Michael Natterer and Sven Neumann
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -31,9 +32,9 @@
#include "gdisplay_ops.h"
#include "gimprc.h"
#include "gimpui.h"
#include "resolution_calibrate.h"
#include "unitrc.h"
#include "user_install.h"
#include "libgimp/gimpenv.h"
#include "libgimp/gimplimits.h"
#include "libgimp/gimpmath.h"
......@@ -1138,200 +1139,13 @@ user_install_tuning_done (void)
{
}
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;
static void
user_install_resolution_calibrate_ok (GtkWidget *button,
gpointer data)
{
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;
if (ABS (x -y) > GIMP_MIN_RESOLUTION)
gimp_chain_button_set_active (GIMP_COORDINATES_CHAINBUTTON (resolution_entry), FALSE);
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);
gtk_widget_destroy (GTK_WIDGET (data));
}
static void
user_install_resolution_calibrate (GtkWidget *button,
gpointer data)
{
GtkWidget *dialog;
GtkWidget *table;
GtkWidget *ebox;
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *darea;
GtkWidget *ruler;
GList *list;
gtk_widget_hide (user_install_dialog);
dialog = gimp_dialog_new (_("Calibrate Monitor Resolution"),
"calibrate_resolution",
NULL, NULL,
GTK_WIN_POS_CENTER,
FALSE, FALSE, FALSE,
_("OK"), user_install_resolution_calibrate_ok,
NULL, NULL, NULL, TRUE, FALSE,
_("Cancel"), gtk_widget_destroy,
NULL, 1, NULL, FALSE, TRUE,
NULL);
gtk_signal_connect (GTK_OBJECT (dialog), "destroy",
GTK_SIGNAL_FUNC (gtk_main_quit),
NULL);
TITLE_STYLE (dialog);
gimp_dialog_set_icon (GTK_WINDOW (dialog));
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area), 8);
/* hide the separator between the dialog's vbox and the action area */
/* gtk_widget_destroy (GTK_WIDGET (g_list_nth_data (gtk_container_children (GTK_CONTAINER (GTK_BIN (dialog)->child)), 0)));*/
ruler_width = gdk_screen_width ();
ruler_height = gdk_screen_height ();
ruler_width = ruler_width - 300 - (ruler_width % 100);
ruler_height = ruler_height - 300 - (ruler_height % 100);
table = gtk_table_new (4, 4, FALSE);
gtk_container_set_border_width (GTK_CONTAINER (table), 16);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), table);
gtk_widget_show (table);
ruler = gtk_hruler_new ();
PAGE_STYLE (ruler);
gtk_widget_set_usize (ruler, ruler_width, 32);
gtk_ruler_set_range (GTK_RULER (ruler), 0, ruler_width, 0, ruler_width);
gtk_table_attach (GTK_TABLE (table), ruler, 1, 3, 0, 1,
GTK_SHRINK, GTK_SHRINK, 0, 0);
gtk_widget_show (ruler);
ruler = gtk_vruler_new ();
PAGE_STYLE (ruler);
gtk_widget_set_usize (ruler, 32, ruler_height);
gtk_ruler_set_range (GTK_RULER (ruler), 0, ruler_height, 0, ruler_height);
gtk_table_attach (GTK_TABLE (table), ruler, 0, 1, 1, 3,
GTK_SHRINK, GTK_SHRINK, 0, 0);
gtk_widget_show (ruler);
ebox = gtk_event_box_new ();
PAGE_STYLE (ebox);
gtk_table_attach (GTK_TABLE (table), ebox, 1, 2, 1, 2,
GTK_SHRINK, GTK_SHRINK, 0, 0);
gtk_widget_show (ebox);
table = gtk_table_new (3, 3, FALSE);
gtk_container_add (GTK_CONTAINER (ebox), table);
gtk_widget_show (table);
darea = gtk_drawing_area_new ();
TITLE_STYLE (darea);
gtk_drawing_area_size (GTK_DRAWING_AREA (darea), 16, 16);
gtk_signal_connect_after (GTK_OBJECT (darea), "expose_event",
GTK_SIGNAL_FUNC (user_install_corner_expose),
(gpointer) GTK_CORNER_TOP_LEFT);
gtk_table_attach (GTK_TABLE (table), darea, 0, 1, 0, 1,
GTK_SHRINK, GTK_SHRINK, 0, 0);
gtk_widget_show (darea);
darea = gtk_drawing_area_new ();
TITLE_STYLE (darea);
gtk_drawing_area_size (GTK_DRAWING_AREA (darea), 16, 16);
gtk_signal_connect_after (GTK_OBJECT (darea), "expose_event",
GTK_SIGNAL_FUNC (user_install_corner_expose),
(gpointer) GTK_CORNER_BOTTOM_LEFT);
gtk_table_attach (GTK_TABLE (table), darea, 0, 1, 2, 3,
GTK_SHRINK, GTK_SHRINK, 0, 0);
gtk_widget_show (darea);
darea = gtk_drawing_area_new ();
TITLE_STYLE (darea);
gtk_drawing_area_size (GTK_DRAWING_AREA (darea), 16, 16);
gtk_signal_connect_after (GTK_OBJECT (darea), "expose_event",
GTK_SIGNAL_FUNC (user_install_corner_expose),
(gpointer) GTK_CORNER_TOP_RIGHT);
gtk_table_attach (GTK_TABLE (table), darea, 2, 3, 0, 1,
GTK_SHRINK, GTK_SHRINK, 0, 0);
gtk_widget_show (darea);
darea = gtk_drawing_area_new ();
TITLE_STYLE (darea);
gtk_drawing_area_size (GTK_DRAWING_AREA (darea), 16, 16);
gtk_signal_connect_after (GTK_OBJECT (darea), "expose_event",
GTK_SIGNAL_FUNC (user_install_corner_expose),
(gpointer) GTK_CORNER_BOTTOM_RIGHT);
gtk_table_attach (GTK_TABLE (table), darea, 2, 3, 2, 3,
GTK_SHRINK, GTK_SHRINK, 0, 0);
gtk_widget_show (darea);
vbox = gtk_vbox_new (FALSE, 16);
gtk_table_attach_defaults (GTK_TABLE (table), vbox, 1, 2, 1, 2);
gtk_widget_show (vbox);
add_label (GTK_BOX (vbox),
_("Measure the rulers and enter their lengths below."));
hbox = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
calibrate_xres = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (resolution_entry), 0);
calibrate_yres = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (resolution_entry), 1);
calibrate_entry =
gimp_coordinates_new (GIMP_UNIT_INCH, "%p",
FALSE, FALSE, 75,
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);
gtk_widget_hide (GTK_WIDGET (GIMP_COORDINATES_CHAINBUTTON (calibrate_entry)));
for (list = GTK_TABLE (calibrate_entry)->children;
list;
list = g_list_next (list))
{
GtkTableChild *child = (GtkTableChild *) list->data;
if (child && GTK_IS_LABEL (child->widget))
PAGE_STYLE (GTK_WIDGET (child->widget));
}
gtk_box_pack_end (GTK_BOX (hbox), calibrate_entry, FALSE, FALSE, 0);
gtk_widget_show (calibrate_entry);
gtk_widget_show (dialog);
gtk_main ();
gtk_widget_show (user_install_dialog);
resolution_calibrate_dialog (resolution_entry,
title_style, page_style,
GTK_SIGNAL_FUNC (user_install_corner_expose));
}
static void
......@@ -1400,6 +1214,7 @@ user_install_resolution (void)
chain = GIMP_COORDINATES_CHAINBUTTON (resolution_entry);
PAGE_STYLE (GTK_WIDGET (chain->line1));
PAGE_STYLE (GTK_WIDGET (chain->line2));
gtk_object_set_data (GTK_OBJECT (resolution_entry), "chain_button", chain);
for (list = GTK_TABLE (resolution_entry)->children;
list;
......@@ -1474,8 +1289,7 @@ user_install_resolution_done (void)
}
if (strcmp (swap_path, new_swap_path))
{
g_free (swap_path);
swap_path = new_swap_path;
g_free (swap_path); swap_path = new_swap_path;
update = g_list_append (update, "swap-path");
}
if (using_xserver_resolution != new_using_xserver_resolution ||
......
......@@ -15,8 +15,10 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __INSTALL_H__
#define __INSTALL_H__
#ifndef __USER_INSTALL_H__
#define __USER_INSTALL_H__
/* Install callback function */
typedef void (* UserInstallCallback) (void);
......@@ -24,4 +26,5 @@ typedef void (* UserInstallCallback) (void);
/* Function declarations */
void user_install_verify (UserInstallCallback user_install_callback);
#endif /* INSTALL_H */
#endif /* __USER_INSTALL_H__ */
......@@ -34,6 +34,7 @@
#include "menus.h"
#include "paths_dialog.h"
#include "paint_funcs.h"
#include "preferences_dialog.h"
#include "procedural_db.h"
#include "scale.h"
#include "tools.h"
......@@ -106,7 +107,7 @@ static GimpItemFactoryEntry toolbox_entries[] =
{ { "/File/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { N_("/File/Preferences..."), NULL, file_pref_cmd_callback, 0 },
{ { N_("/File/Preferences..."), NULL, prefs_cmd_callback, 0 },
"file/dialogs/preferences/preferences.html", NULL },