From 4ba6229ebe0a5c5892051b7df631a0d22a4cd484 Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Thu, 28 Feb 2002 15:11:56 +0000 Subject: [PATCH] take an optional pixbuf as eye-candy. 2002-02-28 Sven Neumann * app/gui/resolution-calibrate-dialog.[ch]: take an optional pixbuf as eye-candy. * app/gui/preferences-dialog.c * app/gui/user-install-dialog.c: changed accordingly. --- ChangeLog | 8 +++++ app/dialogs/preferences-dialog.c | 2 +- app/dialogs/resolution-calibrate-dialog.c | 36 +++++++++++++++++------ app/dialogs/resolution-calibrate-dialog.h | 3 +- app/dialogs/user-install-dialog.c | 12 ++++++++ app/gui/preferences-dialog.c | 2 +- app/gui/resolution-calibrate-dialog.c | 36 +++++++++++++++++------ app/gui/resolution-calibrate-dialog.h | 3 +- app/gui/user-install-dialog.c | 12 ++++++++ 9 files changed, 92 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index ba3e51a061..943a1a1233 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2002-02-28 Sven Neumann + + * app/gui/resolution-calibrate-dialog.[ch]: take an optional pixbuf + as eye-candy. + + * app/gui/preferences-dialog.c + * app/gui/user-install-dialog.c: changed accordingly. + 2002-02-28 Michael Natterer Sven Naumann diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c index 3170de6bdd..8fcd20aa69 100644 --- a/app/dialogs/preferences-dialog.c +++ b/app/dialogs/preferences-dialog.c @@ -1364,7 +1364,7 @@ static void prefs_resolution_calibrate_callback (GtkWidget *widget, gpointer data) { - resolution_calibrate_dialog (GTK_WIDGET (data), NULL, NULL, NULL); + resolution_calibrate_dialog (GTK_WIDGET (data), NULL, NULL, NULL, NULL); } /* create a new notebook page */ diff --git a/app/dialogs/resolution-calibrate-dialog.c b/app/dialogs/resolution-calibrate-dialog.c index 480034928c..9ddb916286 100644 --- a/app/dialogs/resolution-calibrate-dialog.c +++ b/app/dialogs/resolution-calibrate-dialog.c @@ -29,7 +29,8 @@ #include "libgimp/gimpintl.h" -#define SET_STYLE(widget, style) if (style) gtk_widget_modify_style (widget, style) +#define SET_STYLE(widget, style) \ + if (style) gtk_widget_modify_style (widget, style) static GtkWidget *calibrate_entry = NULL; @@ -55,13 +56,16 @@ resolution_calibrate_ok (GtkWidget *button, calibrate_xres = (gdouble)ruler_width * calibrate_xres / x; calibrate_yres = (gdouble)ruler_height * calibrate_yres / y; - chain_button = g_object_get_data (G_OBJECT (resolution_entry), "chain_button"); + chain_button = g_object_get_data (G_OBJECT (resolution_entry), + "chain_button"); if (chain_button && ABS (x -y) > GIMP_MIN_RESOLUTION) gimp_chain_button_set_active (GIMP_CHAIN_BUTTON (chain_button), 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); + 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)); } @@ -69,6 +73,7 @@ resolution_calibrate_ok (GtkWidget *button, /** * resolution_calibrate_dialog: * @resolution_entry: a #GimpSizeEntry to connect the dialog to + * @pixbuf: an optional #GdkPixbuf for the upper left corner * @dialog_style: a #GtkStyle for the main dialog (used by the * user_installation_dialog) * @ruler_style: a #GtkStyle for the rulers and the entry area @@ -84,6 +89,7 @@ resolution_calibrate_ok (GtkWidget *button, **/ void resolution_calibrate_dialog (GtkWidget *resolution_entry, + GdkPixbuf *pixbuf, GtkRcStyle *dialog_style, GtkRcStyle *ruler_style, GCallback expose_callback) @@ -99,6 +105,7 @@ resolution_calibrate_dialog (GtkWidget *resolution_entry, GList *list; g_return_if_fail (GIMP_IS_SIZE_ENTRY (resolution_entry)); + g_return_if_fail (pixbuf == NULL || GDK_IS_PIXBUF (pixbuf)); /* this dialog can only exist once */ if (calibrate_entry) @@ -135,14 +142,22 @@ resolution_calibrate_dialog (GtkWidget *resolution_entry, ruler_width = gdk_screen_width (); ruler_height = gdk_screen_height (); - ruler_width = ruler_width - 300 - (ruler_width % 100); + 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_set_border_width (GTK_CONTAINER (table), 8); gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), table); gtk_widget_show (table); + if (pixbuf) + { + GtkWidget *image = gtk_image_new_from_pixbuf (pixbuf); + gtk_table_attach (GTK_TABLE (table), image, 0, 1, 0, 1, + GTK_SHRINK, GTK_SHRINK, 4, 4); + gtk_widget_show (image); + } + ruler = gtk_hruler_new (); SET_STYLE (ruler, ruler_style); gtk_widget_set_size_request (ruler, ruler_width, 32); @@ -217,7 +232,8 @@ resolution_calibrate_dialog (GtkWidget *resolution_entry, gtk_table_attach_defaults (GTK_TABLE (table), vbox, 1, 2, 1, 2); gtk_widget_show (vbox); - label = gtk_label_new (_("Measure the rulers and enter their lengths below.")); + label = + gtk_label_new (_("Measure the rulers and enter their lengths below.")); SET_STYLE (label, ruler_style); gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); @@ -228,8 +244,10 @@ resolution_calibrate_dialog (GtkWidget *resolution_entry, 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_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", diff --git a/app/dialogs/resolution-calibrate-dialog.h b/app/dialogs/resolution-calibrate-dialog.h index 8256dda3bf..20d1d1184d 100644 --- a/app/dialogs/resolution-calibrate-dialog.h +++ b/app/dialogs/resolution-calibrate-dialog.h @@ -21,7 +21,8 @@ void resolution_calibrate_dialog (GtkWidget *resolution_entry, - GtkRcStyle *dialog_style, + GdkPixbuf *pixbuf, + GtkRcStyle *dialog_style, GtkRcStyle *ruler_style, GCallback expose_callback); diff --git a/app/dialogs/user-install-dialog.c b/app/dialogs/user-install-dialog.c index 1febc086bd..52107508ae 100644 --- a/app/dialogs/user-install-dialog.c +++ b/app/dialogs/user-install-dialog.c @@ -1160,10 +1160,22 @@ static void user_install_resolution_calibrate (GtkWidget *button, gpointer data) { + GdkPixbuf *pixbuf; + gchar *filename; + + filename = g_build_filename (gimp_data_directory (), + "themes", "Default", "images", "preferences", + "monitor.png", NULL); + pixbuf = gdk_pixbuf_new_from_file (filename, NULL); + g_free (filename); + resolution_calibrate_dialog (resolution_entry, + pixbuf, title_style, page_style, G_CALLBACK (user_install_corner_expose)); + if (pixbuf) + g_object_unref (pixbuf); } static void diff --git a/app/gui/preferences-dialog.c b/app/gui/preferences-dialog.c index 3170de6bdd..8fcd20aa69 100644 --- a/app/gui/preferences-dialog.c +++ b/app/gui/preferences-dialog.c @@ -1364,7 +1364,7 @@ static void prefs_resolution_calibrate_callback (GtkWidget *widget, gpointer data) { - resolution_calibrate_dialog (GTK_WIDGET (data), NULL, NULL, NULL); + resolution_calibrate_dialog (GTK_WIDGET (data), NULL, NULL, NULL, NULL); } /* create a new notebook page */ diff --git a/app/gui/resolution-calibrate-dialog.c b/app/gui/resolution-calibrate-dialog.c index 480034928c..9ddb916286 100644 --- a/app/gui/resolution-calibrate-dialog.c +++ b/app/gui/resolution-calibrate-dialog.c @@ -29,7 +29,8 @@ #include "libgimp/gimpintl.h" -#define SET_STYLE(widget, style) if (style) gtk_widget_modify_style (widget, style) +#define SET_STYLE(widget, style) \ + if (style) gtk_widget_modify_style (widget, style) static GtkWidget *calibrate_entry = NULL; @@ -55,13 +56,16 @@ resolution_calibrate_ok (GtkWidget *button, calibrate_xres = (gdouble)ruler_width * calibrate_xres / x; calibrate_yres = (gdouble)ruler_height * calibrate_yres / y; - chain_button = g_object_get_data (G_OBJECT (resolution_entry), "chain_button"); + chain_button = g_object_get_data (G_OBJECT (resolution_entry), + "chain_button"); if (chain_button && ABS (x -y) > GIMP_MIN_RESOLUTION) gimp_chain_button_set_active (GIMP_CHAIN_BUTTON (chain_button), 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); + 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)); } @@ -69,6 +73,7 @@ resolution_calibrate_ok (GtkWidget *button, /** * resolution_calibrate_dialog: * @resolution_entry: a #GimpSizeEntry to connect the dialog to + * @pixbuf: an optional #GdkPixbuf for the upper left corner * @dialog_style: a #GtkStyle for the main dialog (used by the * user_installation_dialog) * @ruler_style: a #GtkStyle for the rulers and the entry area @@ -84,6 +89,7 @@ resolution_calibrate_ok (GtkWidget *button, **/ void resolution_calibrate_dialog (GtkWidget *resolution_entry, + GdkPixbuf *pixbuf, GtkRcStyle *dialog_style, GtkRcStyle *ruler_style, GCallback expose_callback) @@ -99,6 +105,7 @@ resolution_calibrate_dialog (GtkWidget *resolution_entry, GList *list; g_return_if_fail (GIMP_IS_SIZE_ENTRY (resolution_entry)); + g_return_if_fail (pixbuf == NULL || GDK_IS_PIXBUF (pixbuf)); /* this dialog can only exist once */ if (calibrate_entry) @@ -135,14 +142,22 @@ resolution_calibrate_dialog (GtkWidget *resolution_entry, ruler_width = gdk_screen_width (); ruler_height = gdk_screen_height (); - ruler_width = ruler_width - 300 - (ruler_width % 100); + 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_set_border_width (GTK_CONTAINER (table), 8); gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), table); gtk_widget_show (table); + if (pixbuf) + { + GtkWidget *image = gtk_image_new_from_pixbuf (pixbuf); + gtk_table_attach (GTK_TABLE (table), image, 0, 1, 0, 1, + GTK_SHRINK, GTK_SHRINK, 4, 4); + gtk_widget_show (image); + } + ruler = gtk_hruler_new (); SET_STYLE (ruler, ruler_style); gtk_widget_set_size_request (ruler, ruler_width, 32); @@ -217,7 +232,8 @@ resolution_calibrate_dialog (GtkWidget *resolution_entry, gtk_table_attach_defaults (GTK_TABLE (table), vbox, 1, 2, 1, 2); gtk_widget_show (vbox); - label = gtk_label_new (_("Measure the rulers and enter their lengths below.")); + label = + gtk_label_new (_("Measure the rulers and enter their lengths below.")); SET_STYLE (label, ruler_style); gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); @@ -228,8 +244,10 @@ resolution_calibrate_dialog (GtkWidget *resolution_entry, 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_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", diff --git a/app/gui/resolution-calibrate-dialog.h b/app/gui/resolution-calibrate-dialog.h index 8256dda3bf..20d1d1184d 100644 --- a/app/gui/resolution-calibrate-dialog.h +++ b/app/gui/resolution-calibrate-dialog.h @@ -21,7 +21,8 @@ void resolution_calibrate_dialog (GtkWidget *resolution_entry, - GtkRcStyle *dialog_style, + GdkPixbuf *pixbuf, + GtkRcStyle *dialog_style, GtkRcStyle *ruler_style, GCallback expose_callback); diff --git a/app/gui/user-install-dialog.c b/app/gui/user-install-dialog.c index 1febc086bd..52107508ae 100644 --- a/app/gui/user-install-dialog.c +++ b/app/gui/user-install-dialog.c @@ -1160,10 +1160,22 @@ static void user_install_resolution_calibrate (GtkWidget *button, gpointer data) { + GdkPixbuf *pixbuf; + gchar *filename; + + filename = g_build_filename (gimp_data_directory (), + "themes", "Default", "images", "preferences", + "monitor.png", NULL); + pixbuf = gdk_pixbuf_new_from_file (filename, NULL); + g_free (filename); + resolution_calibrate_dialog (resolution_entry, + pixbuf, title_style, page_style, G_CALLBACK (user_install_corner_expose)); + if (pixbuf) + g_object_unref (pixbuf); } static void