11 #include <gdk/gdkkeysyms.h> /* for keyboard values */
13 #define BLACK_BACKGROUND 1
16 *-----------------------------------------------------------------------------
17 * full screen keyboard
18 *-----------------------------------------------------------------------------
21 static gint full_screen_key_press_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
23 ImageWindow *imd = data;
24 gint stop_signal = FALSE;
28 switch (event->keyval)
47 image_area_adjust_zoom(imd, 1);
50 image_area_adjust_zoom(imd, -1);
53 image_area_set_zoom(imd, 0);
56 image_area_set_zoom(imd, 1);
78 file_util_delete(image_area_get_path(imd), NULL);
97 if (event->state & GDK_CONTROL_MASK)
100 switch (event->keyval)
128 file_util_copy(image_area_get_path(imd), NULL, current_path);
132 file_util_move(image_area_get_path(imd), NULL, current_path);
136 file_util_rename(image_area_get_path(imd), NULL);
140 file_util_delete(image_area_get_path(imd), NULL);
146 start_editor_from_file(n, image_area_get_path(imd));
150 if (event->state & GDK_SHIFT_MASK)
158 keyboard_scroll_calc(&x, &y, event);
159 image_area_scroll(imd, x, y);
166 *----------------------------------------------------------------------------
167 * mouse button callbacks
168 *----------------------------------------------------------------------------
171 static void button1_cb(ImageWindow *imd, GdkEventButton *bevent, gpointer data)
176 static void button2_cb(ImageWindow *imd, GdkEventButton *bevent, gpointer data)
181 static void button3_cb(ImageWindow *imd, GdkEventButton *bevent, gpointer data)
183 if (main_image == normal_image)
185 gtk_menu_popup (GTK_MENU(menu_image_popup), NULL, NULL, NULL, NULL,
186 bevent->button, bevent->time);
190 gtk_menu_popup (GTK_MENU(menu_window_full), NULL, NULL, NULL, NULL,
191 bevent->button, bevent->time);
195 static void button4_cb(ImageWindow *imd, GdkEventButton *bevent, gpointer data)
197 if (mousewheel_scrolls)
198 image_area_scroll(imd, 0, -MOUSEWHEEL_SCROLL_SIZE);
203 static void button5_cb(ImageWindow *imd, GdkEventButton *bevent, gpointer data)
205 if (mousewheel_scrolls)
206 image_area_scroll(imd, 0, MOUSEWHEEL_SCROLL_SIZE);
212 *----------------------------------------------------------------------------
213 * full screen functions
214 *----------------------------------------------------------------------------
217 static gint full_screen_delete_cb(GtkWidget *widget, GdkEventAny *event, gpointer data)
223 static gint full_screen_destroy_cb(GtkWidget *widget, GdkEventAny *event, gpointer data)
225 image_area_free(full_screen_image);
226 full_screen_image = NULL;
231 void full_screen_start()
237 if (full_screen_window) return;
239 w = gdk_screen_width();
240 h = gdk_screen_height();
242 window = gtk_window_new(GTK_WINDOW_POPUP);
243 gtk_container_border_width(GTK_CONTAINER(window), 0);
244 gtk_signal_connect(GTK_OBJECT(window), "delete_event", (GtkSignalFunc)full_screen_delete_cb, NULL);
245 gtk_signal_connect(GTK_OBJECT(window), "destroy_event", (GtkSignalFunc)full_screen_destroy_cb, NULL);
247 gtk_window_set_title(GTK_WINDOW(window), _("GQview full screen"));
248 gtk_widget_set_usize(window, w, h);
250 full_screen_image = image_area_new(NULL);
252 gtk_viewport_set_shadow_type (GTK_VIEWPORT(full_screen_image->viewport), GTK_SHADOW_NONE);
253 gtk_container_add(GTK_CONTAINER(window), full_screen_image->eventbox);
255 /* set background to black */
256 if (BLACK_BACKGROUND)
259 style = gtk_style_copy(gtk_widget_get_style(full_screen_image->eventbox));
260 gtk_style_ref(style);
261 style->bg[GTK_STATE_NORMAL] = style->black;
262 gtk_widget_set_style(full_screen_image->viewport, style);
263 gtk_style_unref(style);
266 gtk_widget_show_all(full_screen_image->eventbox);
268 gtk_signal_connect(GTK_OBJECT(window), "key_press_event", GTK_SIGNAL_FUNC(full_screen_key_press_cb), full_screen_image);
270 image_area_set_image(full_screen_image, image_get_path(), image_area_get_zoom(normal_image));
272 gtk_widget_show(window);
273 gdk_keyboard_grab(window->window, TRUE, GDK_CURRENT_TIME);
275 /* hide normal window
276 * FIXME: properly restore this window on show
278 gtk_widget_hide(mainwindow);
279 image_area_set_image(normal_image, NULL, image_area_get_zoom(normal_image));
281 full_screen_window = window;
283 image_area_set_button(full_screen_image, 1, button1_cb, NULL);
284 image_area_set_button(full_screen_image, 2, button2_cb, NULL);
285 image_area_set_button(full_screen_image, 3, button3_cb, NULL);
287 image_area_set_button(full_screen_image, 4, button4_cb, NULL);
288 image_area_set_button(full_screen_image, 5, button5_cb, NULL);
290 main_image = full_screen_image;
293 void full_screen_stop()
295 if (!full_screen_window) return;
297 gdk_keyboard_ungrab (GDK_CURRENT_TIME);
299 image_area_set_image(normal_image, image_get_path(), image_area_get_zoom(full_screen_image));
300 main_image = normal_image;
302 gtk_widget_destroy(full_screen_window);
303 full_screen_window = NULL;
305 image_area_free(full_screen_image);
306 full_screen_image = NULL;
308 gtk_widget_show(mainwindow);
312 void full_screen_toggle()
314 if (full_screen_window)
325 *----------------------------------------------------------------------------
326 * main image manipulation
327 *----------------------------------------------------------------------------
330 void image_scroll(gint x, gint y)
332 image_area_scroll(main_image, x, y);
335 void image_adjust_zoom(gint increment)
337 image_area_adjust_zoom(main_image, increment);
340 void image_set_zoom(gint zoom)
342 image_area_set_zoom(main_image, zoom);
345 void image_set_path(gchar *path)
347 image_area_set_path(main_image, path);
350 gchar *image_get_path()
352 return image_area_get_path(main_image);
355 gchar *image_get_name()
357 return image_area_get_name(main_image);
360 void image_change_to(gchar *path)
362 image_area_set_image(main_image, path, get_default_zoom(main_image));
365 void image_set_labels(GtkWidget *info, GtkWidget *zoom)
367 image_area_set_labels(normal_image, info, zoom);
370 GtkWidget *image_create()
372 normal_image = image_area_new(mainwindow);
374 main_image = normal_image;
376 image_area_set_button(main_image, 1, button1_cb, NULL);
377 image_area_set_button(main_image, 2, button2_cb, NULL);
378 image_area_set_button(main_image, 3, button3_cb, NULL);
380 image_area_set_button(main_image, 4, button4_cb, NULL);
381 image_area_set_button(main_image, 5, button5_cb, NULL);
383 return main_image->eventbox;
388 image_area_to_root(main_image, (image_area_get_zoom(main_image) == 0));