2
This file is part of Gnome Photo Printer.
4
Gnome Photo Printer is free software; you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation; either version 2 of the License, or
7
(at your option) any later version.
9
Gnome Photo Printer is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public License
15
along with Gnome Photo Printer; if not, write to the Free Software
16
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
#include <libgnome/gnome-i18n.h>
23
#include <glade/glade.h>
24
#include <gdk-pixbuf/gdk-pixbuf.h>
25
#include <libgnomevfs/gnome-vfs.h>
26
#include <libgnomeprint/gnome-print.h>
27
#include <libgnomeprint/gnome-print-job.h>
28
#include <libgnomeprintui/gnome-print-dialog.h>
29
#include "gpp_print.h"
30
#include "gpp_functions.h"
31
#include "gpp_widget.h"
32
#include "gpp_callbacks.h"
37
return: true on success
40
gpp_get_settings_from_libgnomeprint ()
42
gdouble width, height;
45
if (gnome_print_job_get_page_size (gpp_job, &width, &height) != TRUE)
47
g_printf ("Error, couldn't get page size!\n");
51
gpp_definition->paper_size_x = width;
52
gpp_definition->paper_size_y = height;
55
/* This truely needs to be fixed!!! Its a bug inside libgnomeprint!!!
56
* if (gnome_print_config_get_boolean
57
* (gpp_config, "PrintToFile", &to_file) != TRUE)
59
* g_printf ("Error, couldn't get output definition!\n");
64
* gpp_definition->to_file = to_file;
68
/* Needs to be fixed when libgnomeprintui gets fixed!
69
* if (gnome_print_config_get
70
* (gpp_config, "Settings.Transport.Backend.FileName") == NULL)
72
* g_printf ("Error, couldn't get Name of Output File!\n");
77
* gpp_definition->output_file_name =
78
* g_strdup (gnome_print_config_get
80
* "Settings.Transport.Backend.FileName"));
84
/* Doing it this way right now! */
85
gpp_definition->output_file_name =
86
g_strdup (gnome_print_config_get
88
"Settings.Transport.Backend.FileName"));
95
return: is TRUE on success
98
gpp_show_settings_from_libgnomeprint ()
105
g_printf ("Print to file: %d\n", gpp_definition->to_file);
106
g_printf ("File Name: %s\n", gpp_definition->output_file_name);
107
g_printf ("Width: %f\n", gpp_definition->paper_size_x);
108
g_printf ("Height: %f\n", gpp_definition->paper_size_y);
109
g_printf ("Layout Type: %d\n", gpp_definition->layout);
110
g_printf ("Layout X: %f\n", gpp_definition->layout_x);
111
g_printf ("Layout Y: %f\n", gpp_definition->layout_y);
112
g_printf ("Rotate: %d\n", gpp_calculate_rotate_pictures ());
113
g_printf ("Number of Files: %d\n", gpp_definition->number_of_files);
115
tree = GTK_TREE_MODEL (gpp_definition->file_names);
117
/* Get the first iter in the list */
118
valid = gtk_tree_model_get_iter_first (tree, &iter);
123
/* Walk through the list, reading each row */
126
gtk_tree_model_get (tree, &iter, FILE_COLUMN, &file_name, -1);
128
/* Do something with the data */
129
g_print ("File Names %s\n", file_name);
132
valid = gtk_tree_model_iter_next (tree, &iter);
139
Calculate the pictures sizes (in metric)
144
gpp_calculate_size_metric_to_dpi (gdouble size)
147
value = (size / 2.54) * PRINTER_DPI;
152
Put as many pictures on one page as possibly!
153
With or without rotating the pictures?
154
Also updates the gpp_definition->layout information.
155
return: true or false
159
gpp_calculate_rotate_pictures ()
161
gdouble help, ax, ay, bx, by;
164
ax = gpp_definition->paper_size_x;
165
ay = gpp_definition->paper_size_y;
167
bx = gpp_definition->layout_x;
168
by = gpp_definition->layout_y;
170
cx = gpp_calculate_fit_to_page (ax, bx);
171
cy = gpp_calculate_fit_to_page (ay, by);
173
dx = gpp_calculate_fit_to_page (ax, by);
174
dy = gpp_calculate_fit_to_page (ay, bx);
176
if ((cx * cy) <= (dx * dy))
178
help = gpp_definition->layout_x;
179
gpp_definition->layout_x = gpp_definition->layout_y;
180
gpp_definition->layout_y = help;
188
gpp_calculate_fit_to_page (gdouble page, gdouble pic)
194
Returns the number of pages
195
return: number of pages
198
gpp_calculate_number_of_sites ()
202
sites = gpp_definition->number_of_files /
203
gpp_calculate_pics_on_page ();
204
if ((gpp_definition->number_of_files %
205
gpp_calculate_pics_on_page ()) > 0)
212
Calculates the number of pictures that fit on one page.
213
return: number of pictures
216
gpp_calculate_pics_on_page ()
218
gdouble ax, ay, bx, by;
221
ax = gpp_definition->paper_size_x;
222
ay = gpp_definition->paper_size_y;
224
bx = gpp_definition->layout_x;
225
by = gpp_definition->layout_y;
227
cx = gpp_calculate_fit_to_page (ax, bx);
228
cy = gpp_calculate_fit_to_page (ay, by);
235
Calculates the space between each picture
236
return: space between pictures
239
gpp_calculate_space_between_pics (gdouble page, gdouble pic)
244
(gpp_calculate_fit_to_page (page, pic) * pic)) /
245
(gpp_calculate_fit_to_page (page, pic) + 1);
251
Rotates one picture at 90 degree
256
gpp_gdk_rotate_pixbuf_90 (GdkPixbuf * pixbuf)
258
GdkPixbuf *pixbuf_new;
259
GdkColorspace colorspace;
262
gint x, y, rowstride, height, width, bits_per_sample;
264
raw_image = gdk_pixbuf_get_pixels (pixbuf);
265
has_alpha = gdk_pixbuf_get_has_alpha (pixbuf);
266
rowstride = gdk_pixbuf_get_rowstride (pixbuf);
267
height = gdk_pixbuf_get_height (pixbuf);
268
width = gdk_pixbuf_get_width (pixbuf);
269
bits_per_sample = gdk_pixbuf_get_bits_per_sample (pixbuf);
270
colorspace = gdk_pixbuf_get_colorspace (pixbuf);
273
gdk_pixbuf_new (colorspace, has_alpha, bits_per_sample,
276
for (x = 0; x < width; x++)
278
for (y = 0; y < height; y++)
280
gdk_pixbuf_copy_area (pixbuf, x, y, 1, 1, pixbuf_new,
285
gdk_pixbuf_unref (pixbuf);
291
Checks if a file_name is an Image
293
output: TRUE or FALSE
296
gpp_check_for_image (gchar * file_name)
298
GnomeVFSResult result;
299
GnomeVFSFileInfo *file_info;
301
file_info = gnome_vfs_file_info_new ();
302
result = gnome_vfs_get_file_info (file_name, file_info,
303
GNOME_VFS_FILE_INFO_GET_MIME_TYPE);
305
if (file_info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_TYPE)
306
if (file_info->type == GNOME_VFS_FILE_TYPE_REGULAR)
309
GNOME_VFS_FILE_INFO_FIELDS_MIME_TYPE)
310
if (g_strrstr (file_info->mime_type, "image/")