Commit 9ac6ecef authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

app/dialogs/Makefile.am new files for the Print Size dialog that is still

2004-11-13  Sven Neumann  <sven@gimp.org>

	* app/dialogs/Makefile.am
	* app/dialogs/print-size-dialog.[ch]: new files for the Print Size
	dialog that is still missing. Still work in progress...

	* app/actions/image-actions.c
	* app/actions/image-commands.[ch]
	* app/widgets/gimphelp-ids.h
	* menus/image-menu.xml.in: integrate the new dialog.
parent ff654be7
2004-11-13 Sven Neumann <sven@gimp.org>
* app/dialogs/Makefile.am
* app/dialogs/print-size-dialog.[ch]: new files for the Print Size
dialog that is still missing. Still work in progress...
* app/actions/image-actions.c
* app/actions/image-commands.[ch]
* app/widgets/gimphelp-ids.h
* menus/image-menu.xml.in: integrate the new dialog.
2004-11-13 Sven Neumann <sven@gimp.org>
 
* tools/pdbgen/pdb/selection.pdb: deprecate gimp_selection_clear()
......
......@@ -81,6 +81,11 @@ static GimpActionEntry image_actions[] =
G_CALLBACK (image_resize_to_layers_cmd_callback),
GIMP_HELP_IMAGE_RESIZE_TO_LAYERS },
{ "image-print-size", GTK_STOCK_PRINT,
N_("_Print Size..."), NULL, NULL,
G_CALLBACK (image_print_size_cmd_callback),
GIMP_HELP_IMAGE_PRINT_SIZE },
{ "image-scale", GIMP_STOCK_SCALE,
N_("_Scale Image..."), NULL, NULL,
G_CALLBACK (image_scale_cmd_callback),
......@@ -242,6 +247,7 @@ image_actions_update (GimpActionGroup *group,
SET_SENSITIVE ("image-resize", gimage);
SET_SENSITIVE ("image-resize-to-layers", gimage);
SET_SENSITIVE ("image-print-size", gimage);
SET_SENSITIVE ("image-scale", gimage);
SET_SENSITIVE ("image-crop", gimage && sel);
SET_SENSITIVE ("image-duplicate", gimage);
......
......@@ -53,6 +53,7 @@
#include "dialogs/image-merge-layers-dialog.h"
#include "dialogs/image-new-dialog.h"
#include "dialogs/image-scale-dialog.h"
#include "dialogs/print-size-dialog.h"
#include "dialogs/resize-dialog.h"
#include "actions.h"
......@@ -79,6 +80,12 @@ static void image_resize_callback (GtkWidget *dialog,
gint offset_x,
gint offset_y,
gpointer data);
static void image_print_size_callback (GtkWidget *dialog,
GimpImage *image,
gdouble xresolution,
gdouble yresolution,
GimpUnit resolution_unit,
gpointer data);
static void image_scale_callback (ImageScaleDialog *dialog);
static void image_merge_layers_response (GtkWidget *widget,
......@@ -221,6 +228,32 @@ image_resize_to_layers_cmd_callback (GtkAction *action,
gimp_image_flush (gdisp->gimage);
}
void
image_print_size_cmd_callback (GtkAction *action,
gpointer data)
{
GtkWidget *dialog;
GimpDisplay *gdisp;
GtkWidget *widget;
return_if_no_display (gdisp, data);
return_if_no_widget (widget, data);
dialog = print_size_dialog_new (gdisp->gimage,
_("Set Image Print Resolution"),
"gimp-image-print-size",
widget,
gimp_standard_help_func,
GIMP_HELP_IMAGE_PRINT_SIZE,
image_print_size_callback,
NULL);
g_signal_connect_object (gdisp, "disconnect",
G_CALLBACK (gtk_widget_destroy),
dialog, G_CONNECT_SWAPPED);
gtk_widget_show (dialog);
}
void
image_scale_cmd_callback (GtkAction *action,
gpointer data)
......@@ -432,6 +465,28 @@ image_resize_callback (GtkWidget *dialog,
}
}
static void
image_print_size_callback (GtkWidget *dialog,
GimpImage *image,
gdouble xresolution,
gdouble yresolution,
GimpUnit resolution_unit,
gpointer data)
{
gtk_widget_destroy (dialog);
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_IMAGE_SCALE,
_("Change Print Size"));
gimp_image_set_resolution (image, xresolution, yresolution);
gimp_image_set_unit (image, resolution_unit);
gimp_image_undo_group_end (image);
gimp_image_flush (image);
}
static void
image_scale_callback (ImageScaleDialog *dialog)
{
......
......@@ -33,6 +33,8 @@ void image_resize_cmd_callback (GtkAction *action,
gpointer data);
void image_resize_to_layers_cmd_callback (GtkAction *action,
gpointer data);
void image_print_size_cmd_callback (GtkAction *action,
gpointer data);
void image_scale_cmd_callback (GtkAction *action,
gpointer data);
void image_flip_cmd_callback (GtkAction *action,
......
......@@ -46,6 +46,8 @@ libappdialogs_a_SOURCES = \
palette-import-dialog.h \
preferences-dialog.c \
preferences-dialog.h \
print-size-dialog.c \
print-size-dialog.h \
quit-dialog.c \
quit-dialog.h \
resize-dialog.c \
......
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (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
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
#include "dialogs-types.h"
#include "core/gimpimage.h"
#include "core/gimpitem.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpsizebox.h"
#include "widgets/gimpviewabledialog.h"
#include "print-size-dialog.h"
#include "gimp-intl.h"
#define RESPONSE_RESET 1
typedef struct _PrintSizeDialog PrintSizeDialog;
struct _PrintSizeDialog
{
GimpImage *image;
GtkWidget *box;
GimpResolutionCallback callback;
gpointer user_data;
};
static void print_size_dialog_response (GtkWidget *dialog,
gint response_id,
PrintSizeDialog *private);
static void print_size_dialog_reset (PrintSizeDialog *private);
GtkWidget *
print_size_dialog_new (GimpImage *image,
const gchar *title,
const gchar *role,
GtkWidget *parent,
GimpHelpFunc help_func,
const gchar *help_id,
GimpResolutionCallback callback,
gpointer user_data)
{
GtkWidget *dialog;
GtkWidget *vbox;
GtkWidget *frame;
PrintSizeDialog *private;
gint width, height;
gdouble xres, yres;
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
g_return_val_if_fail (callback != NULL, NULL);
width = gimp_image_get_width (image);
height = gimp_image_get_height (image);
dialog = gimp_viewable_dialog_new (GIMP_VIEWABLE (image),
title, role, GTK_STOCK_PRINT, title,
parent,
help_func, help_id,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GIMP_STOCK_RESET, RESPONSE_RESET,
GTK_STOCK_OK, GTK_RESPONSE_OK,
NULL);
gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
private = g_new0 (PrintSizeDialog, 1);
g_signal_connect_swapped (dialog, "destroy",
G_CALLBACK (g_free),
private);
private->image = image;
private->callback = callback;
private->user_data = user_data;
gimp_image_get_resolution (image, &xres, &yres);
private->box = g_object_new (GIMP_TYPE_SIZE_BOX,
"width", width,
"height", height,
"unit", gimp_image_get_unit (image),
"xresolution", xres,
"yresolution", yres,
"resolution-unit", gimp_image_get_unit (image),
"keep-aspect", TRUE,
"edit-resolution", TRUE,
NULL);
g_signal_connect (dialog, "response",
G_CALLBACK (print_size_dialog_response),
private);
vbox = gtk_vbox_new (FALSE, 12);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), vbox);
gtk_widget_show (vbox);
frame = gimp_frame_new (_("Print Size"));
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
gtk_container_add (GTK_CONTAINER (frame), private->box);
gtk_widget_show (private->box);
return dialog;
}
static void
print_size_dialog_response (GtkWidget *dialog,
gint response_id,
PrintSizeDialog *private)
{
GimpUnit resolution_unit;
gdouble xres, yres;
switch (response_id)
{
case RESPONSE_RESET:
print_size_dialog_reset (private);
break;
case GTK_RESPONSE_OK:
g_object_get (private->box,
"xresolution", &xres,
"yresolution", &yres,
"resolution-unit", &resolution_unit,
NULL);
private->callback (dialog,
private->image,
xres, yres, resolution_unit,
private->user_data);
break;
default:
gtk_widget_destroy (dialog);
break;
}
}
static void
print_size_dialog_reset (PrintSizeDialog *private)
{
gdouble xres, yres;
gimp_image_get_resolution (private->image, &xres, &yres);
g_object_set (private->box,
"keep-aspect", FALSE,
"xresolution", xres,
"yresolution", yres,
"resolution-unit", gimp_image_get_unit (private->image),
"keep-aspect", TRUE,
NULL);
}
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (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
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __PRINT_SIZE_DIALOG_H__
#define __PRINT_SIZE_DIALOG_H__
typedef void (* GimpResolutionCallback) (GtkWidget *dialog,
GimpImage *image,
gdouble xresolution,
gdouble yresolution,
GimpUnit resolution_unit,
gpointer user_data);
GtkWidget * print_size_dialog_new (GimpImage *image,
const gchar *title,
const gchar *role,
GtkWidget *parent,
GimpHelpFunc help_func,
const gchar *help_id,
GimpResolutionCallback callback,
gpointer user_data);
#endif /* __PRINT_SIZE_DIALOG_H__ */
......@@ -111,6 +111,7 @@
#define GIMP_HELP_IMAGE_ROTATE_270 "gimp-image-rotate-270"
#define GIMP_HELP_IMAGE_RESIZE "gimp-image-resize"
#define GIMP_HELP_IMAGE_RESIZE_TO_LAYERS "gimp-image-resize-to-layers"
#define GIMP_HELP_IMAGE_PRINT_SIZE "gimp-image-print-size"
#define GIMP_HELP_IMAGE_SCALE "gimp-image-scale"
#define GIMP_HELP_IMAGE_SCALE_WARNING "gimp-image-scale-warning"
#define GIMP_HELP_IMAGE_CROP "gimp-image-crop"
......
......@@ -283,6 +283,7 @@
<placeholder name="Resize">
<menuitem action="image-resize" />
<menuitem action="image-resize-to-layers" />
<menuitem action="image-print-size" />
</placeholder>
<placeholder name="Scale">
<menuitem action="image-scale" />
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment