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);
196 *----------------------------------------------------------------------------
197 * full screen functions
198 *----------------------------------------------------------------------------
201 static gint full_screen_delete_cb(GtkWidget *widget, GdkEventAny *event, gpointer data)
207 static gint full_screen_destroy_cb(GtkWidget *widget, GdkEventAny *event, gpointer data)
209 image_area_free(full_screen_image);
210 full_screen_image = NULL;
215 void full_screen_start()
221 if (full_screen_window) return;
223 w = gdk_screen_width();
224 h = gdk_screen_height();
226 window = gtk_window_new(GTK_WINDOW_POPUP);
227 gtk_container_border_width(GTK_CONTAINER(window), 0);
228 gtk_signal_connect(GTK_OBJECT(window), "delete_event", (GtkSignalFunc)full_screen_delete_cb, NULL);
229 gtk_signal_connect(GTK_OBJECT(window), "destroy_event", (GtkSignalFunc)full_screen_destroy_cb, NULL);
231 gtk_window_set_title(GTK_WINDOW(window), _("GQview full screen"));
232 gtk_widget_set_usize(window, w, h);
234 full_screen_image = image_area_new(NULL);
236 gtk_viewport_set_shadow_type (GTK_VIEWPORT(full_screen_image->viewport), GTK_SHADOW_NONE);
237 gtk_container_add(GTK_CONTAINER(window), full_screen_image->eventbox);
239 /* set background to black */
240 if (BLACK_BACKGROUND)
243 style = gtk_style_copy(gtk_widget_get_style(full_screen_image->eventbox));
244 gtk_style_ref(style);
245 style->bg[GTK_STATE_NORMAL] = style->black;
246 gtk_widget_set_style(full_screen_image->viewport, style);
247 gtk_style_unref(style);
250 gtk_widget_show_all(full_screen_image->eventbox);
252 gtk_signal_connect(GTK_OBJECT(window), "key_press_event", GTK_SIGNAL_FUNC(full_screen_key_press_cb), full_screen_image);
254 image_area_set_image(full_screen_image, image_get_path(), image_area_get_zoom(normal_image));
257 if (!GTK_WIDGET_REALIZED(window)) gtk_widget_realize(window);
258 gdk_window_set_override_redirect(window->window, TRUE);
260 gtk_widget_show(window);
261 gdk_keyboard_grab(window->window, TRUE, GDK_CURRENT_TIME);
263 /* hide normal window */
264 gtk_widget_hide(mainwindow);
265 image_area_set_image(normal_image, NULL, image_area_get_zoom(normal_image));
267 full_screen_window = window;
269 image_area_set_button(full_screen_image, 1, button1_cb, NULL);
270 image_area_set_button(full_screen_image, 2, button2_cb, NULL);
271 image_area_set_button(full_screen_image, 3, button3_cb, NULL);
273 main_image = full_screen_image;
276 void full_screen_stop()
278 if (!full_screen_window) return;
280 gdk_keyboard_ungrab (GDK_CURRENT_TIME);
282 image_area_set_image(normal_image, image_get_path(), image_area_get_zoom(full_screen_image));
283 main_image = normal_image;
285 gtk_widget_destroy(full_screen_window);
286 full_screen_window = NULL;
288 image_area_free(full_screen_image);
289 full_screen_image = NULL;
291 gtk_widget_show(mainwindow);
294 void full_screen_toggle()
296 if (full_screen_window)
307 *----------------------------------------------------------------------------
308 * main image manipulation
309 *----------------------------------------------------------------------------
312 void image_scroll(gint x, gint y)
314 image_area_scroll(main_image, x, y);
317 void image_adjust_zoom(gint increment)
319 image_area_adjust_zoom(main_image, increment);
322 void image_set_zoom(gint zoom)
324 image_area_set_zoom(main_image, zoom);
327 void image_set_path(gchar *path)
329 image_area_set_path(main_image, path);
332 gchar *image_get_path()
334 return image_area_get_path(main_image);
337 gchar *image_get_name()
339 return image_area_get_name(main_image);
342 void image_change_to(gchar *path)
344 image_area_set_image(main_image, path, get_default_zoom(main_image));
347 void image_set_labels(GtkWidget *info, GtkWidget *zoom)
349 image_area_set_labels(normal_image, info, zoom);
352 GtkWidget *image_create()
354 normal_image = image_area_new(mainwindow);
356 main_image = normal_image;
358 image_area_set_button(main_image, 1, button1_cb, NULL);
359 image_area_set_button(main_image, 2, button2_cb, NULL);
360 image_area_set_button(main_image, 3, button3_cb, NULL);
362 return main_image->eventbox;
367 image_area_to_root(main_image, (image_area_get_zoom(main_image) == 0));