106
102
int sp_main_gui (int, char const**) { return 0; }
107
103
int sp_main_console (int, char const**) { return 0; }
110
sp_svgview_main_delete (GtkWidget */*widget*/, GdkEvent */*event*/, struct SPSlideShow */*ss*/)
105
static int sp_svgview_main_delete (GtkWidget */*widget*/,
107
struct SPSlideShow */*ss*/)
112
109
gtk_main_quit ();
117
sp_svgview_main_key_press (GtkWidget */*widget*/, GdkEventKey *event, struct SPSlideShow *ss)
113
static int sp_svgview_main_key_press (GtkWidget */*widget*/,
115
struct SPSlideShow *ss)
119
117
switch (event->keyval) {
122
sp_svgview_goto_first(ss);
126
sp_svgview_goto_last(ss);
129
if (ss->fullscreen) {
130
gtk_window_unfullscreen (GTK_WINDOW(ss->window));
131
ss->fullscreen = false;
133
gtk_window_fullscreen (GTK_WINDOW(ss->window));
134
ss->fullscreen = true;
138
sp_svgview_control_show (ss);
140
case GDK_KEY_KP_Page_Down:
141
case GDK_KEY_Page_Down:
144
sp_svgview_show_next (ss);
146
case GDK_KEY_KP_Page_Up:
147
case GDK_KEY_Page_Up:
149
case GDK_KEY_BackSpace:
150
sp_svgview_show_prev (ss);
120
sp_svgview_goto_first(ss);
124
sp_svgview_goto_last(ss);
127
if (ss->fullscreen) {
128
gtk_window_unfullscreen (GTK_WINDOW(ss->window));
129
ss->fullscreen = false;
131
gtk_window_fullscreen (GTK_WINDOW(ss->window));
132
ss->fullscreen = true;
136
sp_svgview_control_show (ss);
138
case GDK_KEY_KP_Page_Down:
139
case GDK_KEY_Page_Down:
142
sp_svgview_show_next (ss);
144
case GDK_KEY_KP_Page_Up:
145
case GDK_KEY_Page_Up:
147
case GDK_KEY_BackSpace:
148
sp_svgview_show_prev (ss);
160
158
gtk_window_set_title(GTK_WINDOW(ss->window), ss->doc->getName());
165
main (int argc, const char **argv)
162
int main (int argc, const char **argv)
171
168
// Prevents errors like "Unable to wrap GdkPixbuf..." (in nr-filter-image.cpp for example)
232
233
// starting at where the commandline options stopped parsing because
233
234
// we want all the files to be in the list
234
235
for (i = num_parsed_options + 1 ; i < argc; i++) {
236
if (stat (argv[i], &st)
237
|| !S_ISREG (st.st_mode)
238
|| (st.st_size < 64)) {
239
fprintf(stderr, "could not open file %s\n", argv[i]);
243
if (is_jar(argv[i])) {
244
Inkjar::JarFileReader jar_file_reader(argv[i]);
246
GByteArray *gba = jar_file_reader.get_next_file();
249
gchar *last_filename = jar_file_reader.get_last_filename();
250
if (last_filename == NULL)
252
if ((c_ptr = std::strrchr(last_filename, '/')) != NULL) {
253
if (*(++c_ptr) == '\0') {
254
g_free(last_filename);
258
} else if (gba->len > 0) {
259
//::write(1, gba->data, gba->len);
261
if (ss.length >= ss.size) {
264
ss.slides = g_renew (char *, ss.slides, ss.size);
267
ss.doc = SPDocument::createNewDocFromMem ((const gchar *)gba->data,
270
gchar *last_filename = jar_file_reader.get_last_filename();
272
ss.slides[ss.length++] = strdup (last_filename);
273
(ss.doc)->setUri (last_filename);
275
g_byte_array_free(gba, TRUE);
276
g_free(last_filename);
281
#endif /* WITH_INKJAR */
283
if (ss.length >= ss.size) {
286
ss.slides = g_renew (char *, ss.slides, ss.size);
290
ss.slides[ss.length++] = strdup (argv[i]);
237
if (stat (argv[i], &st)
238
|| !S_ISREG (st.st_mode)
239
|| (st.st_size < 64)) {
240
fprintf(stderr, "could not open file %s\n", argv[i]);
244
if (is_jar(argv[i])) {
245
Inkjar::JarFileReader jar_file_reader(argv[i]);
247
GByteArray *gba = jar_file_reader.get_next_file();
250
gchar *last_filename = jar_file_reader.get_last_filename();
251
if (last_filename == NULL)
253
if ((c_ptr = std::strrchr(last_filename, '/')) != NULL) {
254
if (*(++c_ptr) == '\0') {
255
g_free(last_filename);
259
} else if (gba->len > 0) {
260
//::write(1, gba->data, gba->len);
262
if (ss.length >= ss.size) {
265
ss.slides = g_renew (char *, ss.slides, ss.size);
268
ss.doc = SPDocument::createNewDocFromMem ((const gchar *)gba->data,
271
gchar *last_filename = jar_file_reader.get_last_filename();
273
ss.slides[ss.length++] = strdup (last_filename);
274
(ss.doc)->setUri (last_filename);
276
g_byte_array_free(gba, TRUE);
277
g_free(last_filename);
283
#endif /* WITH_INKJAR */
285
if (ss.length >= ss.size) {
288
ss.slides = g_renew (char *, ss.slides, ss.size);
291
ss.slides[ss.length++] = strdup (argv[i]);
294
ss.doc = SPDocument::createNewDoc (ss.slides[ss.current], TRUE, false);
293
ss.doc = SPDocument::createNewDoc (ss.slides[ss.current], TRUE, false);
304
306
return 1; /* none of the slides loadable */
306
309
w = gtk_window_new (GTK_WINDOW_TOPLEVEL);
307
310
gtk_window_set_title( GTK_WINDOW(w), ss.doc->getName() );
308
311
gtk_window_set_default_size (GTK_WINDOW (w),
309
MIN ((int)(ss.doc)->getWidth().value("px"), (int)gdk_screen_width() - 64),
310
MIN ((int)(ss.doc)->getHeight().value("px"), (int)gdk_screen_height() - 64));
312
MIN ((int)(ss.doc)->getWidth().value("px"), (int)gdk_screen_width() - 64),
313
MIN ((int)(ss.doc)->getHeight().value("px"), (int)gdk_screen_height() - 64));
313
316
g_signal_connect (G_OBJECT (w), "delete_event", (GCallback) sp_svgview_main_delete, &ss);
337
341
static GtkWidget* sp_svgview_control_show(struct SPSlideShow *ss)
340
ctrlwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
344
ctrlwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
341
345
gtk_window_set_resizable(GTK_WINDOW(ctrlwin), FALSE);
342
346
gtk_window_set_transient_for(GTK_WINDOW(ctrlwin), GTK_WINDOW(ss->window));
343
347
g_signal_connect(G_OBJECT (ctrlwin), "key_press_event", (GCallback) sp_svgview_main_key_press, ss);
344
348
g_signal_connect(G_OBJECT (ctrlwin), "delete_event", (GCallback) sp_svgview_ctrlwin_delete, NULL);
346
350
#if GTK_CHECK_VERSION(3,0,0)
347
GtkWidget *t = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
351
GtkWidget *t = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
349
GtkWidget *t = gtk_hbutton_box_new();
353
GtkWidget *t = gtk_hbutton_box_new();
352
gtk_container_add(GTK_CONTAINER(ctrlwin), t);
356
gtk_container_add(GTK_CONTAINER(ctrlwin), t);
354
358
#if GTK_CHECK_VERSION(3,10,0)
355
359
GtkWidget *b = gtk_button_new_from_icon_name(INKSCAPE_ICON("go-first"), GTK_ICON_SIZE_BUTTON);
357
GtkWidget *b = gtk_button_new();
361
GtkWidget *b = gtk_button_new();
358
362
GtkWidget *img = gtk_image_new_from_icon_name(INKSCAPE_ICON("go-first"), GTK_ICON_SIZE_BUTTON);
359
363
gtk_button_set_image(GTK_BUTTON(b), img);
361
gtk_container_add(GTK_CONTAINER(t), b);
365
gtk_container_add(GTK_CONTAINER(t), b);
363
g_signal_connect(G_OBJECT(b), "clicked", (GCallback) sp_svgview_goto_first_cb, ss);
367
g_signal_connect(G_OBJECT(b), "clicked", (GCallback) sp_svgview_goto_first_cb, ss);
364
368
#if GTK_CHECK_VERSION(3,10,0)
365
369
b = gtk_button_new_from_icon_name(INKSCAPE_ICON("go-previous"), GTK_ICON_SIZE_BUTTON);
367
b = gtk_button_new();
371
b = gtk_button_new();
368
372
img = gtk_image_new_from_icon_name(INKSCAPE_ICON("go-previous"), GTK_ICON_SIZE_BUTTON);
369
373
gtk_button_set_image(GTK_BUTTON(b), img);
371
gtk_container_add(GTK_CONTAINER(t), b);
375
gtk_container_add(GTK_CONTAINER(t), b);
373
g_signal_connect(G_OBJECT(b), "clicked", (GCallback) sp_svgview_show_prev_cb, ss);
377
g_signal_connect(G_OBJECT(b), "clicked", (GCallback) sp_svgview_show_prev_cb, ss);
374
378
#if GTK_CHECK_VERSION(3,10,0)
375
379
b = gtk_button_new_from_icon_name(INKSCAPE_ICON("go-next"), GTK_ICON_SIZE_BUTTON);
377
b = gtk_button_new();
381
b = gtk_button_new();
378
382
img = gtk_image_new_from_icon_name(INKSCAPE_ICON("go-next"), GTK_ICON_SIZE_BUTTON);
379
383
gtk_button_set_image(GTK_BUTTON(b), img);
381
gtk_container_add(GTK_CONTAINER(t), b);
385
gtk_container_add(GTK_CONTAINER(t), b);
383
g_signal_connect(G_OBJECT(b), "clicked", (GCallback) sp_svgview_show_next_cb, ss);
387
g_signal_connect(G_OBJECT(b), "clicked", (GCallback) sp_svgview_show_next_cb, ss);
384
388
#if GTK_CHECK_VERSION(3,10,0)
385
389
b = gtk_button_new_from_icon_name(INKSCAPE_ICON("go-last"), GTK_ICON_SIZE_BUTTON);
387
b = gtk_button_new();
391
b = gtk_button_new();
388
392
img = gtk_image_new_from_icon_name(INKSCAPE_ICON("go-last"), GTK_ICON_SIZE_BUTTON);
389
393
gtk_button_set_image(GTK_BUTTON(b), img);
391
gtk_container_add(GTK_CONTAINER(t), b);
392
g_signal_connect(G_OBJECT(b), "clicked", (GCallback) sp_svgview_goto_last_cb, ss);
393
gtk_widget_show_all(ctrlwin);
395
gtk_container_add(GTK_CONTAINER(t), b);
396
g_signal_connect(G_OBJECT(b), "clicked", (GCallback) sp_svgview_goto_last_cb, ss);
397
gtk_widget_show_all(ctrlwin);
395
gtk_window_present(GTK_WINDOW(ctrlwin));
399
gtk_window_present(GTK_WINDOW(ctrlwin));
402
sp_svgview_show_next_cb (GtkWidget */*widget*/, void *data)
405
static int sp_svgview_show_next_cb (GtkWidget */*widget*/, void *data)
404
407
sp_svgview_show_next(static_cast<struct SPSlideShow *>(data));
409
sp_svgview_show_prev_cb (GtkWidget */*widget*/, void *data)
411
static int sp_svgview_show_prev_cb (GtkWidget */*widget*/, void *data)
411
413
sp_svgview_show_prev(static_cast<struct SPSlideShow *>(data));
416
sp_svgview_goto_first_cb (GtkWidget */*widget*/, void *data)
417
static int sp_svgview_goto_first_cb (GtkWidget */*widget*/, void *data)
418
419
sp_svgview_goto_first(static_cast<struct SPSlideShow *>(data));
423
sp_svgview_goto_last_cb (GtkWidget */*widget*/, void *data)
423
static int sp_svgview_goto_last_cb (GtkWidget */*widget*/, void *data)
425
425
sp_svgview_goto_last(static_cast<struct SPSlideShow *>(data));
430
sp_svgview_waiting_cursor(struct SPSlideShow *ss)
429
static void sp_svgview_waiting_cursor(struct SPSlideShow *ss)
432
431
GdkCursor *waiting = gdk_cursor_new(GDK_WATCH);
433
432
gdk_window_set_cursor(gtk_widget_get_window(GTK_WIDGET(ss->window)), waiting);