2
GNOME Commander - A GNOME based file manager
3
Copyright (C) 2001-2006 Marcus Bjurman
5
This program is free software; you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation; either version 2 of the License, or
8
(at your option) any later version.
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
15
You should have received a copy of the GNU General Public License
16
along with this program; if not, write to the Free Software
17
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
Author: Assaf Gordon <agordon88@gmail.com>
31
#include <libgviewer/libgviewer.h>
33
static gchar* filename = NULL;
34
static gboolean best_fit = TRUE;
35
static double scale_factor = 1.0 ;
39
fprintf(stderr,"This program tests the image-render widget in 'libgviewer'.\n\n" ) ;
41
fprintf(stderr,"Usage: test-imagerenderer [-s scale] filename\n\n" ) ;
43
fprintf(stderr,"\t-s scale: use fixed scaling factor (0.1 to 3.0)\n\t\t(Default is using best-fit-to-window)\n");
44
fprintf(stderr,"\tfilename: The file to display.\n");
48
void parse_command_line(int argc, char* argv[])
51
extern int optind, opterr, optopt ;
57
while ( (c=getopt(argc,argv,"s:")) != -1 ) {
62
scale_factor = atof(optarg);
63
if (scale_factor<0.1 || scale_factor>3.0) {
64
warnx("Invalid scale factor \"%f\".\n", scale_factor);
75
if ( optind == argc ) {
76
warnx("Need file name to work with...\n");
79
filename = g_strdup(argv[optind++]);
83
int main(int argc, char* argv[])
89
gtk_init(&argc,&argv);
91
parse_command_line(argc,argv);
93
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
94
gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
95
gtk_widget_set_size_request(window,600,400);
97
scrollbox = scroll_box_new() ;
99
imgr = image_render_new() ;
101
image_render_set_v_adjustment(IMAGE_RENDER(imgr),
102
scroll_box_get_v_adjustment(SCROLL_BOX(scrollbox))) ;
104
image_render_set_h_adjustment(IMAGE_RENDER(imgr),
105
scroll_box_get_h_adjustment(SCROLL_BOX(scrollbox))) ;
107
image_render_load_file(IMAGE_RENDER(imgr), filename ) ;
109
image_render_set_best_fit(IMAGE_RENDER(imgr),best_fit);
112
image_render_set_scale_factor(IMAGE_RENDER(imgr), scale_factor);
114
scroll_box_set_client(SCROLL_BOX(scrollbox),imgr) ;
116
gtk_container_add(GTK_CONTAINER(window), scrollbox) ;
118
gtk_widget_show(imgr);
119
gtk_widget_show(scrollbox);
120
gtk_widget_show(window);