Mercurial > geeqie
annotate src/layout_image.c @ 1811:f405ec9b696b default tip
Some small logic mistakes
Use boolean operators for booleans and bitwise otherwise only.
| author | mow |
|---|---|
| date | Mon, 10 May 2010 11:33:13 +0000 |
| parents | 956aab097ea7 |
| children |
| rev | line source |
|---|---|
| 9 | 1 /* |
| 196 | 2 * Geeqie |
|
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
3 * (C) 2006 John Ellis |
| 1802 | 4 * Copyright (C) 2008 - 2010 The Geeqie Team |
| 9 | 5 * |
| 6 * Author: John Ellis | |
| 7 * | |
| 8 * This software is released under the GNU General Public License (GNU GPL). | |
| 9 * Please read the included file COPYING for more information. | |
| 10 * This software comes with no warranty of any kind, use at your own risk! | |
| 11 */ | |
| 12 | |
| 281 | 13 #include "main.h" |
| 9 | 14 #include "layout_image.h" |
| 15 | |
| 16 #include "collect.h" | |
| 1431 | 17 #include "color-man.h" |
| 9 | 18 #include "dnd.h" |
| 19 #include "editors.h" | |
| 586 | 20 #include "filedata.h" |
| 9 | 21 #include "fullscreen.h" |
| 22 #include "image.h" | |
| 23 #include "image-overlay.h" | |
| 24 #include "img-view.h" | |
| 25 #include "layout.h" | |
| 26 #include "layout_util.h" | |
| 27 #include "menu.h" | |
|
1022
9962b24b6b43
Move miscellaneous functions to their own files (new misc.[ch]).
zas_
parents:
995
diff
changeset
|
28 #include "misc.h" |
| 9 | 29 #include "pixbuf_util.h" |
|
1375
df58e511d90e
Display pixel coordinates and rgb - patch by Ruben Stein
nadvornik
parents:
1373
diff
changeset
|
30 #include "pixbuf-renderer.h" |
| 9 | 31 #include "slideshow.h" |
| 32 #include "ui_fileops.h" | |
| 33 #include "ui_menu.h" | |
|
904
1698baa37871
Move uri_*() functions to separate files: uri_utils.[ch]
zas_
parents:
888
diff
changeset
|
34 #include "uri_utils.h" |
|
1022
9962b24b6b43
Move miscellaneous functions to their own files (new misc.[ch]).
zas_
parents:
995
diff
changeset
|
35 #include "utilops.h" |
| 1761 | 36 #include "view_file.h" |
| 9 | 37 |
| 38 #include <gdk/gdkkeysyms.h> /* for keyboard values */ | |
| 39 | |
| 40 | |
| 41 static GtkWidget *layout_image_pop_menu(LayoutWindow *lw); | |
| 42 static void layout_image_set_buttons(LayoutWindow *lw); | |
| 43 | |
| 44 /* | |
| 45 *---------------------------------------------------------------------------- | |
| 46 * full screen overlay | |
| 47 *---------------------------------------------------------------------------- | |
| 48 */ | |
| 49 | |
|
122
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
50 void layout_image_overlay_toggle(LayoutWindow *lw) |
| 9 | 51 { |
|
481
67a612985686
Merge view_overlay_toggle() and layout_image_overlay_toggle() into new image_osd_toggle().
zas_
parents:
479
diff
changeset
|
52 if (!lw) return; |
|
67a612985686
Merge view_overlay_toggle() and layout_image_overlay_toggle() into new image_osd_toggle().
zas_
parents:
479
diff
changeset
|
53 image_osd_toggle(lw->image); |
| 9 | 54 } |
| 55 | |
| 56 /* | |
| 57 *---------------------------------------------------------------------------- | |
| 58 * full screen | |
| 59 *---------------------------------------------------------------------------- | |
| 60 */ | |
| 160 | 61 |
| 9 | 62 static void layout_image_full_screen_stop_func(FullScreenData *fs, gpointer data) |
| 63 { | |
| 64 LayoutWindow *lw = data; | |
| 65 | |
| 66 /* restore image window */ | |
| 67 lw->image = fs->normal_imd; | |
| 68 | |
| 69 lw->full_screen = NULL; | |
| 70 } | |
| 71 | |
| 72 void layout_image_full_screen_start(LayoutWindow *lw) | |
| 73 { | |
| 74 if (!layout_valid(&lw)) return; | |
| 75 | |
| 76 if (lw->full_screen) return; | |
| 77 | |
| 78 lw->full_screen = fullscreen_start(lw->window, lw->image, | |
| 79 layout_image_full_screen_stop_func, lw); | |
| 80 | |
| 81 /* set to new image window */ | |
| 82 lw->image = lw->full_screen->imd; | |
| 83 | |
| 84 layout_image_set_buttons(lw); | |
| 85 | |
| 86 g_signal_connect(G_OBJECT(lw->full_screen->window), "key_press_event", | |
| 160 | 87 G_CALLBACK(layout_key_press_cb), lw); |
| 9 | 88 |
| 160 | 89 layout_actions_add_window(lw, lw->full_screen->window); |
| 9 | 90 #if 0 |
| 91 gtk_widget_set_sensitive(lw->window, FALSE); | |
| 92 if (lw->tools) gtk_widget_set_sensitive(lw->tools, FALSE); | |
| 93 #endif | |
| 94 | |
| 1336 | 95 image_osd_copy_status(lw->full_screen->normal_imd, lw->image); |
| 9 | 96 } |
| 97 | |
| 98 void layout_image_full_screen_stop(LayoutWindow *lw) | |
| 99 { | |
| 100 if (!layout_valid(&lw)) return; | |
| 101 if (!lw->full_screen) return; | |
| 102 | |
| 1336 | 103 image_osd_copy_status(lw->image, lw->full_screen->normal_imd); |
| 621 | 104 |
| 9 | 105 fullscreen_stop(lw->full_screen); |
| 106 | |
| 107 #if 0 | |
| 108 gtk_widget_set_sensitive(lw->window, TRUE); | |
| 109 if (lw->tools) gtk_widget_set_sensitive(lw->tools, TRUE); | |
| 110 #endif | |
| 111 } | |
| 112 | |
| 113 void layout_image_full_screen_toggle(LayoutWindow *lw) | |
| 114 { | |
| 115 if (!layout_valid(&lw)) return; | |
| 116 if (lw->full_screen) | |
| 117 { | |
| 118 layout_image_full_screen_stop(lw); | |
| 119 } | |
| 120 else | |
| 121 { | |
| 122 layout_image_full_screen_start(lw); | |
| 123 } | |
| 124 } | |
| 125 | |
|
1433
b4ad1d201279
Use gboolean where applicable, minor cleanup and indentations fixes.
zas_
parents:
1432
diff
changeset
|
126 gboolean layout_image_full_screen_active(LayoutWindow *lw) |
| 9 | 127 { |
| 128 if (!layout_valid(&lw)) return FALSE; | |
| 129 | |
| 130 return (lw->full_screen != NULL); | |
| 131 } | |
| 132 | |
| 133 /* | |
| 134 *---------------------------------------------------------------------------- | |
| 135 * slideshow | |
| 136 *---------------------------------------------------------------------------- | |
| 137 */ | |
| 138 | |
| 139 static void layout_image_slideshow_next(LayoutWindow *lw) | |
| 140 { | |
| 141 if (lw->slideshow) slideshow_next(lw->slideshow); | |
| 142 } | |
| 143 | |
| 144 static void layout_image_slideshow_prev(LayoutWindow *lw) | |
| 145 { | |
| 146 if (lw->slideshow) slideshow_prev(lw->slideshow); | |
| 147 } | |
| 148 | |
| 149 static void layout_image_slideshow_stop_func(SlideShowData *ss, gpointer data) | |
| 150 { | |
| 151 LayoutWindow *lw = data; | |
| 152 | |
| 153 lw->slideshow = NULL; | |
| 154 layout_status_update_info(lw, NULL); | |
| 155 } | |
| 156 | |
| 157 void layout_image_slideshow_start(LayoutWindow *lw) | |
| 158 { | |
| 159 CollectionData *cd; | |
| 160 CollectInfo *info; | |
| 161 | |
| 162 if (!layout_valid(&lw)) return; | |
| 163 if (lw->slideshow) return; | |
| 164 | |
| 165 cd = image_get_collection(lw->image, &info); | |
| 166 | |
| 167 if (cd && info) | |
| 168 { | |
|
1627
1a134b4dc88c
use layout_set_fd() for changing images from a slideshow
nadvornik
parents:
1626
diff
changeset
|
169 lw->slideshow = slideshow_start_from_collection(lw, NULL, cd, |
| 9 | 170 layout_image_slideshow_stop_func, lw, info); |
| 171 } | |
| 172 else | |
| 173 { | |
|
1627
1a134b4dc88c
use layout_set_fd() for changing images from a slideshow
nadvornik
parents:
1626
diff
changeset
|
174 lw->slideshow = slideshow_start(lw, |
| 783 | 175 layout_list_get_index(lw, layout_image_get_fd(lw)), |
| 9 | 176 layout_image_slideshow_stop_func, lw); |
| 177 } | |
| 178 | |
| 179 layout_status_update_info(lw, NULL); | |
| 180 } | |
| 181 | |
| 182 /* note that slideshow will take ownership of the list, do not free it */ | |
| 183 void layout_image_slideshow_start_from_list(LayoutWindow *lw, GList *list) | |
| 184 { | |
| 185 if (!layout_valid(&lw)) return; | |
| 186 | |
| 187 if (lw->slideshow || !list) | |
| 188 { | |
| 138 | 189 filelist_free(list); |
| 9 | 190 return; |
| 191 } | |
| 192 | |
|
1627
1a134b4dc88c
use layout_set_fd() for changing images from a slideshow
nadvornik
parents:
1626
diff
changeset
|
193 lw->slideshow = slideshow_start_from_filelist(lw, NULL, list, |
| 9 | 194 layout_image_slideshow_stop_func, lw); |
| 195 | |
| 196 layout_status_update_info(lw, NULL); | |
| 197 } | |
| 198 | |
| 199 void layout_image_slideshow_stop(LayoutWindow *lw) | |
| 200 { | |
| 201 if (!layout_valid(&lw)) return; | |
| 202 | |
| 203 if (!lw->slideshow) return; | |
| 204 | |
| 205 slideshow_free(lw->slideshow); | |
| 206 /* the stop_func sets lw->slideshow to NULL for us */ | |
| 207 } | |
| 208 | |
| 209 void layout_image_slideshow_toggle(LayoutWindow *lw) | |
| 210 { | |
| 211 if (!layout_valid(&lw)) return; | |
| 212 | |
| 213 if (lw->slideshow) | |
| 214 { | |
| 215 layout_image_slideshow_stop(lw); | |
| 216 } | |
| 217 else | |
| 218 { | |
| 219 layout_image_slideshow_start(lw); | |
| 220 } | |
| 221 } | |
| 222 | |
|
1433
b4ad1d201279
Use gboolean where applicable, minor cleanup and indentations fixes.
zas_
parents:
1432
diff
changeset
|
223 gboolean layout_image_slideshow_active(LayoutWindow *lw) |
| 9 | 224 { |
| 225 if (!layout_valid(&lw)) return FALSE; | |
| 226 | |
| 227 return (lw->slideshow != NULL); | |
| 228 } | |
| 229 | |
|
1433
b4ad1d201279
Use gboolean where applicable, minor cleanup and indentations fixes.
zas_
parents:
1432
diff
changeset
|
230 gboolean layout_image_slideshow_pause_toggle(LayoutWindow *lw) |
| 9 | 231 { |
|
1433
b4ad1d201279
Use gboolean where applicable, minor cleanup and indentations fixes.
zas_
parents:
1432
diff
changeset
|
232 gboolean ret; |
| 9 | 233 |
| 234 if (!layout_valid(&lw)) return FALSE; | |
| 235 | |
| 236 ret = slideshow_pause_toggle(lw->slideshow); | |
| 237 | |
| 238 layout_status_update_info(lw, NULL); | |
| 239 | |
| 240 return ret; | |
| 241 } | |
| 242 | |
|
1433
b4ad1d201279
Use gboolean where applicable, minor cleanup and indentations fixes.
zas_
parents:
1432
diff
changeset
|
243 gboolean layout_image_slideshow_paused(LayoutWindow *lw) |
| 9 | 244 { |
| 245 if (!layout_valid(&lw)) return FALSE; | |
| 246 | |
| 247 return (slideshow_paused(lw->slideshow)); | |
| 248 } | |
| 249 | |
|
1433
b4ad1d201279
Use gboolean where applicable, minor cleanup and indentations fixes.
zas_
parents:
1432
diff
changeset
|
250 static gboolean layout_image_slideshow_continue_check(LayoutWindow *lw) |
| 9 | 251 { |
| 252 if (!lw->slideshow) return FALSE; | |
| 253 | |
| 254 if (!slideshow_should_continue(lw->slideshow)) | |
| 255 { | |
| 256 layout_image_slideshow_stop(lw); | |
| 257 return FALSE; | |
| 258 } | |
| 259 | |
| 260 return TRUE; | |
| 261 } | |
| 262 | |
| 263 /* | |
| 264 *---------------------------------------------------------------------------- | |
| 265 * pop-up menus | |
| 266 *---------------------------------------------------------------------------- | |
| 267 */ | |
| 268 | |
| 269 static void li_pop_menu_zoom_in_cb(GtkWidget *widget, gpointer data) | |
| 270 { | |
| 271 LayoutWindow *lw = data; | |
| 272 | |
| 1047 | 273 layout_image_zoom_adjust(lw, get_zoom_increment(), FALSE); |
| 9 | 274 } |
| 275 | |
| 276 static void li_pop_menu_zoom_out_cb(GtkWidget *widget, gpointer data) | |
| 277 { | |
| 278 LayoutWindow *lw = data; | |
| 1047 | 279 layout_image_zoom_adjust(lw, -get_zoom_increment(), FALSE); |
| 9 | 280 } |
| 281 | |
| 282 static void li_pop_menu_zoom_1_1_cb(GtkWidget *widget, gpointer data) | |
| 283 { | |
| 284 LayoutWindow *lw = data; | |
| 285 | |
| 1047 | 286 layout_image_zoom_set(lw, 1.0, FALSE); |
| 9 | 287 } |
| 288 | |
| 289 static void li_pop_menu_zoom_fit_cb(GtkWidget *widget, gpointer data) | |
| 290 { | |
| 291 LayoutWindow *lw = data; | |
| 292 | |
| 1047 | 293 layout_image_zoom_set(lw, 0.0, FALSE); |
| 9 | 294 } |
| 295 | |
| 296 static void li_pop_menu_edit_cb(GtkWidget *widget, gpointer data) | |
| 297 { | |
| 298 LayoutWindow *lw; | |
| 1272 | 299 const gchar *key = data; |
| 9 | 300 |
| 301 lw = submenu_item_get_data(widget); | |
| 302 | |
| 1272 | 303 if (!editor_window_flag_set(key)) |
|
60
9c0c402b0ef3
Mon Jun 13 17:31:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
304 { |
|
9c0c402b0ef3
Mon Jun 13 17:31:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
305 layout_image_full_screen_stop(lw); |
|
9c0c402b0ef3
Mon Jun 13 17:31:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
306 } |
| 1272 | 307 file_util_start_editor_from_file(key, layout_image_get_fd(lw), lw->window); |
| 9 | 308 } |
| 309 | |
| 310 static void li_pop_menu_wallpaper_cb(GtkWidget *widget, gpointer data) | |
| 311 { | |
| 312 LayoutWindow *lw = data; | |
| 313 | |
| 314 layout_image_to_root(lw); | |
| 315 } | |
| 316 | |
| 317 static void li_pop_menu_alter_cb(GtkWidget *widget, gpointer data) | |
| 318 { | |
| 319 LayoutWindow *lw = data; | |
| 320 AlterType type; | |
| 321 | |
| 322 lw = submenu_item_get_data(widget); | |
| 323 type = (AlterType)GPOINTER_TO_INT(data); | |
| 324 | |
| 1566 | 325 image_alter_orientation(lw->image, type); |
| 9 | 326 } |
| 327 | |
| 328 static void li_pop_menu_new_cb(GtkWidget *widget, gpointer data) | |
| 329 { | |
| 330 LayoutWindow *lw = data; | |
| 331 | |
| 138 | 332 view_window_new(layout_image_get_fd(lw)); |
| 9 | 333 } |
| 334 | |
| 335 static GtkWidget *li_pop_menu_click_parent(GtkWidget *widget, LayoutWindow *lw) | |
| 336 { | |
| 337 GtkWidget *menu; | |
| 338 GtkWidget *parent; | |
| 339 | |
| 340 menu = gtk_widget_get_toplevel(widget); | |
| 341 if (!menu) return NULL; | |
| 342 | |
| 343 parent = g_object_get_data(G_OBJECT(menu), "click_parent"); | |
| 344 | |
| 345 if (!parent && lw->full_screen) | |
| 346 { | |
| 347 parent = lw->full_screen->imd->widget; | |
| 348 } | |
| 349 | |
| 350 return parent; | |
| 351 } | |
| 352 | |
| 353 static void li_pop_menu_copy_cb(GtkWidget *widget, gpointer data) | |
| 354 { | |
| 355 LayoutWindow *lw = data; | |
| 356 | |
| 138 | 357 file_util_copy(layout_image_get_fd(lw), NULL, NULL, |
| 9 | 358 li_pop_menu_click_parent(widget, lw)); |
| 359 } | |
| 360 | |
| 497 | 361 static void li_pop_menu_copy_path_cb(GtkWidget *widget, gpointer data) |
| 362 { | |
| 363 LayoutWindow *lw = data; | |
| 364 | |
| 365 file_util_copy_path_to_clipboard(layout_image_get_fd(lw)); | |
| 366 } | |
| 367 | |
| 9 | 368 static void li_pop_menu_move_cb(GtkWidget *widget, gpointer data) |
| 369 { | |
| 370 LayoutWindow *lw = data; | |
| 371 | |
| 138 | 372 file_util_move(layout_image_get_fd(lw), NULL, NULL, |
| 9 | 373 li_pop_menu_click_parent(widget, lw)); |
| 374 } | |
| 375 | |
| 376 static void li_pop_menu_rename_cb(GtkWidget *widget, gpointer data) | |
| 377 { | |
| 378 LayoutWindow *lw = data; | |
| 379 | |
| 138 | 380 file_util_rename(layout_image_get_fd(lw), NULL, |
| 9 | 381 li_pop_menu_click_parent(widget, lw)); |
| 382 } | |
| 383 | |
| 384 static void li_pop_menu_delete_cb(GtkWidget *widget, gpointer data) | |
| 385 { | |
| 386 LayoutWindow *lw = data; | |
| 387 | |
| 138 | 388 file_util_delete(layout_image_get_fd(lw), NULL, |
| 9 | 389 li_pop_menu_click_parent(widget, lw)); |
| 390 } | |
| 391 | |
| 392 static void li_pop_menu_slide_start_cb(GtkWidget *widget, gpointer data) | |
| 393 { | |
| 394 LayoutWindow *lw = data; | |
| 395 | |
| 396 layout_image_slideshow_start(lw); | |
| 397 } | |
| 398 | |
| 399 static void li_pop_menu_slide_stop_cb(GtkWidget *widget, gpointer data) | |
| 400 { | |
| 401 LayoutWindow *lw = data; | |
| 402 | |
| 403 layout_image_slideshow_stop(lw); | |
| 404 } | |
| 405 | |
| 406 static void li_pop_menu_slide_pause_cb(GtkWidget *widget, gpointer data) | |
| 407 { | |
| 408 LayoutWindow *lw = data; | |
| 409 | |
| 410 layout_image_slideshow_pause_toggle(lw); | |
| 411 } | |
| 412 | |
| 413 static void li_pop_menu_full_screen_cb(GtkWidget *widget, gpointer data) | |
| 414 { | |
| 415 LayoutWindow *lw = data; | |
| 416 | |
| 417 layout_image_full_screen_toggle(lw); | |
| 418 } | |
| 419 | |
| 420 static void li_pop_menu_hide_cb(GtkWidget *widget, gpointer data) | |
| 421 { | |
| 422 LayoutWindow *lw = data; | |
| 423 | |
| 424 layout_tools_hide_toggle(lw); | |
| 425 } | |
| 426 | |
|
368
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
339
diff
changeset
|
427 static void li_set_layout_path_cb(GtkWidget *widget, gpointer data) |
|
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
339
diff
changeset
|
428 { |
|
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
339
diff
changeset
|
429 LayoutWindow *lw = data; |
| 783 | 430 FileData *fd; |
|
368
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
339
diff
changeset
|
431 |
|
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
339
diff
changeset
|
432 if (!layout_valid(&lw)) return; |
| 442 | 433 |
| 783 | 434 fd = layout_image_get_fd(lw); |
| 435 if (fd) layout_set_fd(lw, fd); | |
|
368
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
339
diff
changeset
|
436 } |
|
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
339
diff
changeset
|
437 |
|
1433
b4ad1d201279
Use gboolean where applicable, minor cleanup and indentations fixes.
zas_
parents:
1432
diff
changeset
|
438 static gboolean li_check_if_current_path(LayoutWindow *lw, const gchar *path) |
|
368
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
339
diff
changeset
|
439 { |
|
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
339
diff
changeset
|
440 gchar *dirname; |
|
1433
b4ad1d201279
Use gboolean where applicable, minor cleanup and indentations fixes.
zas_
parents:
1432
diff
changeset
|
441 gboolean ret; |
|
368
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
339
diff
changeset
|
442 |
| 783 | 443 if (!path || !layout_valid(&lw) || !lw->dir_fd) return FALSE; |
|
368
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
339
diff
changeset
|
444 |
|
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
339
diff
changeset
|
445 dirname = g_path_get_dirname(path); |
| 783 | 446 ret = (strcmp(lw->dir_fd->path, dirname) == 0); |
|
368
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
339
diff
changeset
|
447 g_free(dirname); |
|
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
339
diff
changeset
|
448 return ret; |
|
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
339
diff
changeset
|
449 } |
|
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
339
diff
changeset
|
450 |
|
1397
a0bd58a6535f
In various Edit context menus, only display editors that match the file types in the selection.
zas_
parents:
1383
diff
changeset
|
451 static void layout_image_popup_menu_destroy_cb(GtkWidget *widget, gpointer data) |
|
a0bd58a6535f
In various Edit context menus, only display editors that match the file types in the selection.
zas_
parents:
1383
diff
changeset
|
452 { |
| 1698 | 453 GList *editmenu_fd_list = data; |
|
1397
a0bd58a6535f
In various Edit context menus, only display editors that match the file types in the selection.
zas_
parents:
1383
diff
changeset
|
454 |
| 1698 | 455 filelist_free(editmenu_fd_list); |
| 456 } | |
|
1397
a0bd58a6535f
In various Edit context menus, only display editors that match the file types in the selection.
zas_
parents:
1383
diff
changeset
|
457 |
|
a0bd58a6535f
In various Edit context menus, only display editors that match the file types in the selection.
zas_
parents:
1383
diff
changeset
|
458 static GList *layout_image_get_fd_list(LayoutWindow *lw) |
|
a0bd58a6535f
In various Edit context menus, only display editors that match the file types in the selection.
zas_
parents:
1383
diff
changeset
|
459 { |
|
a0bd58a6535f
In various Edit context menus, only display editors that match the file types in the selection.
zas_
parents:
1383
diff
changeset
|
460 GList *list = NULL; |
|
a0bd58a6535f
In various Edit context menus, only display editors that match the file types in the selection.
zas_
parents:
1383
diff
changeset
|
461 FileData *fd = layout_image_get_fd(lw); |
|
a0bd58a6535f
In various Edit context menus, only display editors that match the file types in the selection.
zas_
parents:
1383
diff
changeset
|
462 |
|
a0bd58a6535f
In various Edit context menus, only display editors that match the file types in the selection.
zas_
parents:
1383
diff
changeset
|
463 if (fd) |
| 1761 | 464 { |
| 465 if (lw->vf) | |
| 466 /* optionally include sidecars if the filelist entry is not expanded */ | |
| 467 list = vf_selection_get_one(lw->vf, fd); | |
| 468 else | |
| 469 list = g_list_append(NULL, file_data_ref(fd)); | |
| 470 } | |
|
1397
a0bd58a6535f
In various Edit context menus, only display editors that match the file types in the selection.
zas_
parents:
1383
diff
changeset
|
471 |
|
a0bd58a6535f
In various Edit context menus, only display editors that match the file types in the selection.
zas_
parents:
1383
diff
changeset
|
472 return list; |
|
a0bd58a6535f
In various Edit context menus, only display editors that match the file types in the selection.
zas_
parents:
1383
diff
changeset
|
473 } |
|
a0bd58a6535f
In various Edit context menus, only display editors that match the file types in the selection.
zas_
parents:
1383
diff
changeset
|
474 |
| 9 | 475 static GtkWidget *layout_image_pop_menu(LayoutWindow *lw) |
| 476 { | |
| 477 GtkWidget *menu; | |
| 478 GtkWidget *item; | |
| 479 GtkWidget *submenu; | |
| 480 const gchar *path; | |
|
1433
b4ad1d201279
Use gboolean where applicable, minor cleanup and indentations fixes.
zas_
parents:
1432
diff
changeset
|
481 gboolean fullscreen; |
| 1698 | 482 GList *editmenu_fd_list; |
| 9 | 483 |
| 484 path = layout_image_get_path(lw); | |
| 485 fullscreen = layout_image_full_screen_active(lw); | |
| 486 | |
| 487 menu = popup_menu_short_lived(); | |
| 488 | |
| 489 menu_item_add_stock(menu, _("Zoom _in"), GTK_STOCK_ZOOM_IN, G_CALLBACK(li_pop_menu_zoom_in_cb), lw); | |
| 490 menu_item_add_stock(menu, _("Zoom _out"), GTK_STOCK_ZOOM_OUT, G_CALLBACK(li_pop_menu_zoom_out_cb), lw); | |
| 491 menu_item_add_stock(menu, _("Zoom _1:1"), GTK_STOCK_ZOOM_100, G_CALLBACK(li_pop_menu_zoom_1_1_cb), lw); | |
| 492 menu_item_add_stock(menu, _("Fit image to _window"), GTK_STOCK_ZOOM_FIT, G_CALLBACK(li_pop_menu_zoom_fit_cb), lw); | |
| 493 menu_item_add_divider(menu); | |
| 494 | |
| 1698 | 495 editmenu_fd_list = layout_image_get_fd_list(lw); |
| 496 g_signal_connect(G_OBJECT(menu), "destroy", | |
| 497 G_CALLBACK(layout_image_popup_menu_destroy_cb), editmenu_fd_list); | |
| 498 submenu = submenu_add_edit(menu, &item, G_CALLBACK(li_pop_menu_edit_cb), lw, editmenu_fd_list); | |
| 9 | 499 if (!path) gtk_widget_set_sensitive(item, FALSE); |
| 500 menu_item_add_divider(submenu); | |
| 501 menu_item_add(submenu, _("Set as _wallpaper"), G_CALLBACK(li_pop_menu_wallpaper_cb), lw); | |
| 502 | |
| 503 item = submenu_add_alter(menu, G_CALLBACK(li_pop_menu_alter_cb), lw); | |
| 504 | |
| 505 item = menu_item_add_stock(menu, _("View in _new window"), GTK_STOCK_NEW, G_CALLBACK(li_pop_menu_new_cb), lw); | |
| 506 if (!path || fullscreen) gtk_widget_set_sensitive(item, FALSE); | |
| 442 | 507 |
|
368
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
339
diff
changeset
|
508 item = menu_item_add(menu, _("_Go to directory view"), G_CALLBACK(li_set_layout_path_cb), lw); |
|
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
339
diff
changeset
|
509 if (!path || li_check_if_current_path(lw, path)) gtk_widget_set_sensitive(item, FALSE); |
| 9 | 510 |
| 511 menu_item_add_divider(menu); | |
| 512 | |
| 513 item = menu_item_add_stock(menu, _("_Copy..."), GTK_STOCK_COPY, G_CALLBACK(li_pop_menu_copy_cb), lw); | |
| 514 if (!path) gtk_widget_set_sensitive(item, FALSE); | |
| 515 item = menu_item_add(menu, _("_Move..."), G_CALLBACK(li_pop_menu_move_cb), lw); | |
| 516 if (!path) gtk_widget_set_sensitive(item, FALSE); | |
| 517 item = menu_item_add(menu, _("_Rename..."), G_CALLBACK(li_pop_menu_rename_cb), lw); | |
| 518 if (!path) gtk_widget_set_sensitive(item, FALSE); | |
| 519 item = menu_item_add_stock(menu, _("_Delete..."), GTK_STOCK_DELETE, G_CALLBACK(li_pop_menu_delete_cb), lw); | |
| 520 if (!path) gtk_widget_set_sensitive(item, FALSE); | |
| 497 | 521 |
| 1513 | 522 item = menu_item_add(menu, _("_Copy path"), G_CALLBACK(li_pop_menu_copy_path_cb), lw); |
| 523 if (!path) gtk_widget_set_sensitive(item, FALSE); | |
| 9 | 524 |
| 525 menu_item_add_divider(menu); | |
| 526 | |
| 527 if (layout_image_slideshow_active(lw)) | |
| 528 { | |
| 529 menu_item_add(menu, _("_Stop slideshow"), G_CALLBACK(li_pop_menu_slide_stop_cb), lw); | |
| 530 if (layout_image_slideshow_paused(lw)) | |
| 531 { | |
| 532 item = menu_item_add(menu, _("Continue slides_how"), | |
| 533 G_CALLBACK(li_pop_menu_slide_pause_cb), lw); | |
| 534 } | |
| 535 else | |
| 536 { | |
| 537 item = menu_item_add(menu, _("Pause slides_how"), | |
| 538 G_CALLBACK(li_pop_menu_slide_pause_cb), lw); | |
| 539 } | |
| 540 } | |
| 541 else | |
| 442 | 542 { |
| 9 | 543 menu_item_add(menu, _("_Start slideshow"), G_CALLBACK(li_pop_menu_slide_start_cb), lw); |
| 544 item = menu_item_add(menu, _("Pause slides_how"), G_CALLBACK(li_pop_menu_slide_pause_cb), lw); | |
| 545 gtk_widget_set_sensitive(item, FALSE); | |
| 546 } | |
| 547 | |
| 548 if (!fullscreen) | |
| 549 { | |
| 550 menu_item_add(menu, _("_Full screen"), G_CALLBACK(li_pop_menu_full_screen_cb), lw); | |
| 551 } | |
| 552 else | |
| 553 { | |
| 554 menu_item_add(menu, _("Exit _full screen"), G_CALLBACK(li_pop_menu_full_screen_cb), lw); | |
| 555 } | |
| 556 | |
| 557 menu_item_add_divider(menu); | |
| 558 | |
| 1309 | 559 item = menu_item_add_check(menu, _("Hide file _list"), lw->options.tools_hidden, |
| 9 | 560 G_CALLBACK(li_pop_menu_hide_cb), lw); |
| 561 if (fullscreen) gtk_widget_set_sensitive(item, FALSE); | |
| 562 | |
| 563 return menu; | |
| 564 } | |
| 565 | |
| 566 static void layout_image_menu_pos_cb(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer data) | |
| 567 { | |
| 568 LayoutWindow *lw = data; | |
| 569 | |
|
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
570 gdk_window_get_origin(lw->image->pr->window, x, y); |
| 9 | 571 popup_menu_position_clamp(menu, x, y, 0); |
| 572 } | |
| 573 | |
| 574 void layout_image_menu_popup(LayoutWindow *lw) | |
| 575 { | |
| 576 GtkWidget *menu; | |
| 577 | |
| 578 menu = layout_image_pop_menu(lw); | |
| 579 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, layout_image_menu_pos_cb, lw, 0, GDK_CURRENT_TIME); | |
| 580 } | |
| 581 | |
| 582 /* | |
| 583 *---------------------------------------------------------------------------- | |
| 584 * dnd | |
| 585 *---------------------------------------------------------------------------- | |
| 586 */ | |
| 587 | |
| 588 static void layout_image_dnd_receive(GtkWidget *widget, GdkDragContext *context, | |
| 589 gint x, gint y, | |
| 590 GtkSelectionData *selection_data, guint info, | |
| 591 guint time, gpointer data) | |
| 592 { | |
| 593 LayoutWindow *lw = data; | |
| 127 | 594 gint i; |
| 442 | 595 |
| 596 | |
| 520 | 597 for (i = 0; i < MAX_SPLIT_IMAGES; i++) |
| 127 | 598 { |
| 599 if (lw->split_images[i] && lw->split_images[i]->pr == widget) | |
| 600 break; | |
| 601 } | |
| 602 if (i < MAX_SPLIT_IMAGES) | |
| 603 { | |
|
506
fc9c8a3e1a8b
Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents:
497
diff
changeset
|
604 DEBUG_1("dnd image activate %d", i); |
| 1659 | 605 layout_image_activate(lw, i, FALSE); |
| 127 | 606 } |
| 607 | |
| 9 | 608 |
| 609 if (info == TARGET_URI_LIST || info == TARGET_APP_COLLECTION_MEMBER) | |
| 610 { | |
| 611 CollectionData *source; | |
| 612 GList *list; | |
| 613 GList *info_list; | |
| 614 | |
| 615 if (info == TARGET_URI_LIST) | |
| 616 { | |
| 138 | 617 list = uri_filelist_from_text((gchar *)selection_data->data, TRUE); |
| 9 | 618 source = NULL; |
| 619 info_list = NULL; | |
| 620 } | |
| 621 else | |
| 622 { | |
| 623 source = collection_from_dnd_data((gchar *)selection_data->data, &list, &info_list); | |
| 624 } | |
| 625 | |
| 626 if (list) | |
| 627 { | |
| 138 | 628 FileData *fd = list->data; |
| 9 | 629 |
| 138 | 630 if (isfile(fd->path)) |
| 9 | 631 { |
| 632 gchar *base; | |
| 633 gint row; | |
| 783 | 634 FileData *dir_fd; |
| 9 | 635 |
| 138 | 636 base = remove_level_from_path(fd->path); |
| 783 | 637 dir_fd = file_data_new_simple(base); |
| 638 if (dir_fd != lw->dir_fd) | |
| 9 | 639 { |
| 783 | 640 layout_set_fd(lw, dir_fd); |
| 9 | 641 } |
| 783 | 642 file_data_unref(dir_fd); |
| 9 | 643 g_free(base); |
| 644 | |
| 783 | 645 row = layout_list_get_index(lw, fd); |
| 9 | 646 if (source && info_list) |
| 647 { | |
| 648 layout_image_set_collection(lw, source, info_list->data); | |
| 649 } | |
| 650 else if (row == -1) | |
| 651 { | |
| 138 | 652 layout_image_set_fd(lw, fd); |
| 9 | 653 } |
| 654 else | |
| 655 { | |
| 656 layout_image_set_index(lw, row); | |
| 657 } | |
| 658 } | |
| 138 | 659 else if (isdir(fd->path)) |
| 9 | 660 { |
| 783 | 661 layout_set_fd(lw, fd); |
| 138 | 662 layout_image_set_fd(lw, NULL); |
| 9 | 663 } |
| 664 } | |
| 665 | |
| 138 | 666 filelist_free(list); |
| 9 | 667 g_list_free(info_list); |
| 668 } | |
| 669 } | |
| 670 | |
| 671 static void layout_image_dnd_get(GtkWidget *widget, GdkDragContext *context, | |
| 672 GtkSelectionData *selection_data, guint info, | |
| 673 guint time, gpointer data) | |
| 674 { | |
| 675 LayoutWindow *lw = data; | |
| 138 | 676 FileData *fd; |
| 127 | 677 gint i; |
| 442 | 678 |
| 679 | |
| 520 | 680 for (i = 0; i < MAX_SPLIT_IMAGES; i++) |
| 127 | 681 { |
| 682 if (lw->split_images[i] && lw->split_images[i]->pr == widget) | |
| 683 break; | |
| 684 } | |
| 685 if (i < MAX_SPLIT_IMAGES) | |
| 686 { | |
|
506
fc9c8a3e1a8b
Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents:
497
diff
changeset
|
687 DEBUG_1("dnd get from %d", i); |
| 138 | 688 fd = image_get_fd(lw->split_images[i]); |
| 127 | 689 } |
| 690 else | |
| 138 | 691 fd = layout_image_get_fd(lw); |
| 9 | 692 |
| 138 | 693 if (fd) |
| 9 | 694 { |
| 695 gchar *text = NULL; | |
| 696 gint len; | |
|
1433
b4ad1d201279
Use gboolean where applicable, minor cleanup and indentations fixes.
zas_
parents:
1432
diff
changeset
|
697 gboolean plain_text; |
| 9 | 698 GList *list; |
| 699 | |
| 700 switch (info) | |
| 701 { | |
| 702 case TARGET_URI_LIST: | |
| 703 plain_text = FALSE; | |
| 704 break; | |
| 705 case TARGET_TEXT_PLAIN: | |
| 706 default: | |
| 707 plain_text = TRUE; | |
| 708 break; | |
| 709 } | |
| 138 | 710 list = g_list_append(NULL, fd); |
| 711 text = uri_text_from_filelist(list, &len, plain_text); | |
| 9 | 712 g_list_free(list); |
| 713 if (text) | |
| 714 { | |
|
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
715 gtk_selection_data_set(selection_data, selection_data->target, |
|
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
716 8, (guchar *)text, len); |
| 9 | 717 g_free(text); |
| 718 } | |
| 719 } | |
| 720 else | |
| 721 { | |
|
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
722 gtk_selection_data_set(selection_data, selection_data->target, |
|
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
723 8, NULL, 0); |
| 9 | 724 } |
| 725 } | |
| 726 | |
| 727 static void layout_image_dnd_end(GtkWidget *widget, GdkDragContext *context, gpointer data) | |
| 728 { | |
| 729 LayoutWindow *lw = data; | |
| 730 if (context->action == GDK_ACTION_MOVE) | |
| 731 { | |
| 783 | 732 FileData *fd; |
| 9 | 733 gint row; |
| 734 | |
| 783 | 735 fd = layout_image_get_fd(lw); |
| 736 row = layout_list_get_index(lw, fd); | |
| 9 | 737 if (row < 0) return; |
| 738 | |
| 783 | 739 if (!isfile(fd->path)) |
| 9 | 740 { |
| 736 | 741 if ((guint) row < layout_list_count(lw, NULL) - 1) |
| 9 | 742 { |
| 743 layout_image_next(lw); | |
| 744 } | |
| 745 else | |
| 746 { | |
| 747 layout_image_prev(lw); | |
| 748 } | |
| 749 } | |
| 750 layout_refresh(lw); | |
| 751 } | |
| 752 } | |
| 753 | |
| 127 | 754 static void layout_image_dnd_init(LayoutWindow *lw, gint i) |
| 9 | 755 { |
| 127 | 756 ImageWindow *imd = lw->split_images[i]; |
| 757 | |
| 758 gtk_drag_source_set(imd->pr, GDK_BUTTON2_MASK, | |
| 9 | 759 dnd_file_drag_types, dnd_file_drag_types_count, |
| 760 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK); | |
| 127 | 761 g_signal_connect(G_OBJECT(imd->pr), "drag_data_get", |
| 9 | 762 G_CALLBACK(layout_image_dnd_get), lw); |
| 127 | 763 g_signal_connect(G_OBJECT(imd->pr), "drag_end", |
| 9 | 764 G_CALLBACK(layout_image_dnd_end), lw); |
| 765 | |
| 127 | 766 gtk_drag_dest_set(imd->pr, |
| 9 | 767 GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP, |
| 768 dnd_file_drop_types, dnd_file_drop_types_count, | |
| 442 | 769 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK); |
| 127 | 770 g_signal_connect(G_OBJECT(imd->pr), "drag_data_received", |
| 9 | 771 G_CALLBACK(layout_image_dnd_receive), lw); |
| 772 } | |
| 773 | |
| 774 | |
| 775 /* | |
| 776 *---------------------------------------------------------------------------- | |
| 777 * misc | |
| 778 *---------------------------------------------------------------------------- | |
| 779 */ | |
| 780 | |
| 781 void layout_image_to_root(LayoutWindow *lw) | |
| 782 { | |
| 783 image_to_root_window(lw->image, (image_zoom_get(lw->image) == 0)); | |
| 784 } | |
| 785 | |
| 786 /* | |
| 787 *---------------------------------------------------------------------------- | |
| 788 * manipulation + accessors | |
| 789 *---------------------------------------------------------------------------- | |
| 790 */ | |
| 791 | |
| 1047 | 792 void layout_image_scroll(LayoutWindow *lw, gint x, gint y, gboolean connect_scroll) |
| 9 | 793 { |
|
530
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
794 gdouble dx, dy; |
|
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
795 gint width, height, i; |
| 9 | 796 if (!layout_valid(&lw)) return; |
| 797 | |
| 798 image_scroll(lw->image, x, y); | |
|
530
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
799 |
| 1047 | 800 if (!connect_scroll) return; |
|
879
0f85435ac335
Optimize a bit when connected zoom and scrolling are unset,
zas_
parents:
869
diff
changeset
|
801 |
|
530
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
802 image_get_image_size(lw->image, &width, &height); |
|
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
803 dx = (gdouble) x / width; |
|
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
804 dy = (gdouble) y / height; |
|
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
805 |
|
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
806 for (i = 0; i < MAX_SPLIT_IMAGES; i++) |
|
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
807 { |
|
879
0f85435ac335
Optimize a bit when connected zoom and scrolling are unset,
zas_
parents:
869
diff
changeset
|
808 if (lw->split_images[i] && lw->split_images[i] != lw->image) |
|
530
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
809 { |
|
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
810 gdouble sx, sy; |
|
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
811 image_get_scroll_center(lw->split_images[i], &sx, &sy); |
|
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
812 sx += dx; |
|
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
813 sy += dy; |
|
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
814 image_set_scroll_center(lw->split_images[i], sx, sy); |
|
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
815 } |
|
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
816 } |
|
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
817 |
| 9 | 818 } |
| 819 | |
| 1047 | 820 void layout_image_zoom_adjust(LayoutWindow *lw, gdouble increment, gboolean connect_zoom) |
| 9 | 821 { |
| 130 | 822 gint i; |
| 9 | 823 if (!layout_valid(&lw)) return; |
| 824 | |
| 825 image_zoom_adjust(lw->image, increment); | |
| 130 | 826 |
| 1047 | 827 if (!connect_zoom) return; |
|
879
0f85435ac335
Optimize a bit when connected zoom and scrolling are unset,
zas_
parents:
869
diff
changeset
|
828 |
| 520 | 829 for (i = 0; i < MAX_SPLIT_IMAGES; i++) |
| 130 | 830 { |
|
879
0f85435ac335
Optimize a bit when connected zoom and scrolling are unset,
zas_
parents:
869
diff
changeset
|
831 if (lw->split_images[i] && lw->split_images[i] != lw->image) |
| 130 | 832 image_zoom_adjust(lw->split_images[i], increment); ; |
| 833 } | |
| 9 | 834 } |
| 835 | |
| 1047 | 836 void layout_image_zoom_adjust_at_point(LayoutWindow *lw, gdouble increment, gint x, gint y, gboolean connect_zoom) |
|
530
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
837 { |
|
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
838 gint i; |
|
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
839 if (!layout_valid(&lw)) return; |
|
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
840 |
|
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
841 image_zoom_adjust_at_point(lw->image, increment, x, y); |
|
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
842 |
| 1047 | 843 if (!connect_zoom) return; |
|
879
0f85435ac335
Optimize a bit when connected zoom and scrolling are unset,
zas_
parents:
869
diff
changeset
|
844 |
|
530
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
845 for (i = 0; i < MAX_SPLIT_IMAGES; i++) |
|
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
846 { |
|
879
0f85435ac335
Optimize a bit when connected zoom and scrolling are unset,
zas_
parents:
869
diff
changeset
|
847 if (lw->split_images[i] && lw->split_images[i] != lw->image) |
|
530
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
848 image_zoom_adjust_at_point(lw->split_images[i], increment, x, y); |
|
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
849 } |
|
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
850 } |
|
1d67ef911fa8
fixed connected zoom and scroll that didn't work in some cases
nadvornik
parents:
529
diff
changeset
|
851 |
| 1047 | 852 void layout_image_zoom_set(LayoutWindow *lw, gdouble zoom, gboolean connect_zoom) |
| 9 | 853 { |
| 130 | 854 gint i; |
| 9 | 855 if (!layout_valid(&lw)) return; |
| 856 | |
| 857 image_zoom_set(lw->image, zoom); | |
| 130 | 858 |
| 1047 | 859 if (!connect_zoom) return; |
|
879
0f85435ac335
Optimize a bit when connected zoom and scrolling are unset,
zas_
parents:
869
diff
changeset
|
860 |
|
0f85435ac335
Optimize a bit when connected zoom and scrolling are unset,
zas_
parents:
869
diff
changeset
|
861 for (i = 0; i < MAX_SPLIT_IMAGES; i++) |
| 130 | 862 { |
|
879
0f85435ac335
Optimize a bit when connected zoom and scrolling are unset,
zas_
parents:
869
diff
changeset
|
863 if (lw->split_images[i] && lw->split_images[i] != lw->image) |
| 130 | 864 image_zoom_set(lw->split_images[i], zoom); |
| 865 } | |
| 9 | 866 } |
| 867 | |
| 1269 | 868 void layout_image_zoom_set_fill_geometry(LayoutWindow *lw, gboolean vertical, gboolean connect_zoom) |
| 9 | 869 { |
| 1047 | 870 gint i; |
| 9 | 871 if (!layout_valid(&lw)) return; |
| 872 | |
| 873 image_zoom_set_fill_geometry(lw->image, vertical); | |
| 1047 | 874 |
| 875 if (!connect_zoom) return; | |
| 876 | |
| 877 for (i = 0; i < MAX_SPLIT_IMAGES; i++) | |
| 878 { | |
| 879 if (lw->split_images[i] && lw->split_images[i] != lw->image) | |
| 880 image_zoom_set_fill_geometry(lw->split_images[i], vertical); | |
| 881 } | |
| 9 | 882 } |
| 883 | |
| 1566 | 884 void layout_image_alter_orientation(LayoutWindow *lw, AlterType type) |
| 885 { | |
| 886 if (!layout_valid(&lw)) return; | |
| 887 | |
| 888 image_alter_orientation(lw->image, type); | |
| 889 } | |
| 890 | |
| 891 void layout_image_set_desaturate(LayoutWindow *lw, gboolean desaturate) | |
| 9 | 892 { |
| 893 if (!layout_valid(&lw)) return; | |
| 894 | |
| 1566 | 895 image_set_desaturate(lw->image, desaturate); |
| 9 | 896 } |
| 897 | |
| 1566 | 898 gboolean layout_image_get_desaturate(LayoutWindow *lw) |
| 899 { | |
| 900 if (!layout_valid(&lw)) return FALSE; | |
| 901 | |
| 902 return image_get_desaturate(lw->image); | |
| 903 } | |
| 904 | |
| 905 | |
| 906 | |
| 9 | 907 const gchar *layout_image_get_path(LayoutWindow *lw) |
| 908 { | |
| 909 if (!layout_valid(&lw)) return NULL; | |
| 910 | |
| 911 return image_get_path(lw->image); | |
| 912 } | |
| 913 | |
| 914 const gchar *layout_image_get_name(LayoutWindow *lw) | |
| 915 { | |
| 916 if (!layout_valid(&lw)) return NULL; | |
| 917 | |
| 918 return image_get_name(lw->image); | |
| 919 } | |
| 920 | |
| 138 | 921 FileData *layout_image_get_fd(LayoutWindow *lw) |
| 922 { | |
| 923 if (!layout_valid(&lw)) return NULL; | |
| 924 | |
| 925 return image_get_fd(lw->image); | |
| 926 } | |
| 927 | |
| 9 | 928 CollectionData *layout_image_get_collection(LayoutWindow *lw, CollectInfo **info) |
| 929 { | |
| 930 if (!layout_valid(&lw)) return NULL; | |
| 931 | |
| 932 return image_get_collection(lw->image, info); | |
| 933 } | |
| 934 | |
| 935 gint layout_image_get_index(LayoutWindow *lw) | |
| 936 { | |
| 783 | 937 return layout_list_get_index(lw, image_get_fd(lw->image)); |
| 9 | 938 } |
| 939 | |
| 940 /* | |
| 941 *---------------------------------------------------------------------------- | |
| 942 * image changers | |
| 943 *---------------------------------------------------------------------------- | |
| 944 */ | |
| 945 | |
| 138 | 946 void layout_image_set_fd(LayoutWindow *lw, FileData *fd) |
| 9 | 947 { |
| 948 if (!layout_valid(&lw)) return; | |
| 949 | |
|
885
ad420f2eb789
Use a specific enum for image.zoom_mode values (ZoomMode) and
zas_
parents:
879
diff
changeset
|
950 image_change_fd(lw->image, fd, image_zoom_get_default(lw->image)); |
| 9 | 951 |
| 138 | 952 layout_list_sync_fd(lw, fd); |
| 9 | 953 layout_image_slideshow_continue_check(lw); |
| 954 layout_bars_new_image(lw); | |
| 955 } | |
| 956 | |
| 138 | 957 void layout_image_set_with_ahead(LayoutWindow *lw, FileData *fd, FileData *read_ahead_fd) |
| 9 | 958 { |
| 959 if (!layout_valid(&lw)) return; | |
| 960 | |
| 144 | 961 /* |
| 962 This should be handled at the caller: in vflist_select_image | |
| 963 if (path) | |
| 9 | 964 { |
| 965 const gchar *old_path; | |
| 966 | |
| 967 old_path = layout_image_get_path(lw); | |
| 968 if (old_path && strcmp(path, old_path) == 0) return; | |
| 969 } | |
| 127 | 970 */ |
| 138 | 971 layout_image_set_fd(lw, fd); |
| 334 | 972 if (options->image.enable_read_ahead) image_prebuffer_set(lw->image, read_ahead_fd); |
| 9 | 973 } |
| 974 | |
| 975 void layout_image_set_index(LayoutWindow *lw, gint index) | |
| 976 { | |
| 138 | 977 FileData *fd; |
| 978 FileData *read_ahead_fd; | |
| 9 | 979 gint old; |
| 980 | |
| 981 if (!layout_valid(&lw)) return; | |
| 982 | |
| 783 | 983 old = layout_list_get_index(lw, layout_image_get_fd(lw)); |
| 138 | 984 fd = layout_list_get_fd(lw, index); |
| 9 | 985 |
| 986 if (old > index) | |
| 987 { | |
| 138 | 988 read_ahead_fd = layout_list_get_fd(lw, index - 1); |
| 9 | 989 } |
| 990 else | |
| 991 { | |
| 138 | 992 read_ahead_fd = layout_list_get_fd(lw, index + 1); |
| 9 | 993 } |
| 994 | |
| 995 | 995 if (layout_selection_count(lw, 0) > 1) |
| 220 | 996 { |
| 995 | 997 GList *x = layout_selection_list_by_index(lw); |
| 998 GList *y; | |
| 999 GList *last; | |
| 220 | 1000 |
| 995 | 1001 for (last = y = x; y; y = y->next) |
| 1002 last = y; | |
|
529
8815fea478ee
fix warning cast from pointer to integer of different size (when an integer is
bruclik
parents:
520
diff
changeset
|
1003 for (y = x; y && (GPOINTER_TO_INT(y->data)) != index; y = y->next) |
| 220 | 1004 ; |
| 1005 | |
| 1006 if (y) | |
| 1007 { | |
| 1008 gint newindex; | |
| 1009 | |
|
529
8815fea478ee
fix warning cast from pointer to integer of different size (when an integer is
bruclik
parents:
520
diff
changeset
|
1010 if ((index > old && (index != GPOINTER_TO_INT(last->data) || old != GPOINTER_TO_INT(x->data))) |
| 995 | 1011 || (old == GPOINTER_TO_INT(last->data) && index == GPOINTER_TO_INT(x->data))) |
| 442 | 1012 { |
| 220 | 1013 if (y->next) |
|
529
8815fea478ee
fix warning cast from pointer to integer of different size (when an integer is
bruclik
parents:
520
diff
changeset
|
1014 newindex = GPOINTER_TO_INT(y->next->data); |
| 220 | 1015 else |
|
529
8815fea478ee
fix warning cast from pointer to integer of different size (when an integer is
bruclik
parents:
520
diff
changeset
|
1016 newindex = GPOINTER_TO_INT(x->data); |
| 220 | 1017 } |
| 1018 else | |
| 1019 { | |
| 1020 if (y->prev) | |
|
529
8815fea478ee
fix warning cast from pointer to integer of different size (when an integer is
bruclik
parents:
520
diff
changeset
|
1021 newindex = GPOINTER_TO_INT(y->prev->data); |
| 220 | 1022 else |
|
529
8815fea478ee
fix warning cast from pointer to integer of different size (when an integer is
bruclik
parents:
520
diff
changeset
|
1023 newindex = GPOINTER_TO_INT(last->data); |
| 995 | 1024 } |
| 220 | 1025 |
| 1026 read_ahead_fd = layout_list_get_fd(lw, newindex); | |
| 1027 } | |
| 442 | 1028 |
| 220 | 1029 while (x) |
| 1030 x = g_list_remove(x, x->data); | |
| 1031 } | |
| 1032 | |
| 138 | 1033 layout_image_set_with_ahead(lw, fd, read_ahead_fd); |
| 9 | 1034 } |
| 1035 | |
|
1433
b4ad1d201279
Use gboolean where applicable, minor cleanup and indentations fixes.
zas_
parents:
1432
diff
changeset
|
1036 static void layout_image_set_collection_real(LayoutWindow *lw, CollectionData *cd, CollectInfo *info, gboolean forward) |
| 9 | 1037 { |
| 1038 if (!layout_valid(&lw)) return; | |
| 1039 | |
|
885
ad420f2eb789
Use a specific enum for image.zoom_mode values (ZoomMode) and
zas_
parents:
879
diff
changeset
|
1040 image_change_from_collection(lw->image, cd, info, image_zoom_get_default(lw->image)); |
| 334 | 1041 if (options->image.enable_read_ahead) |
| 9 | 1042 { |
| 1043 CollectInfo *r_info; | |
| 1044 if (forward) | |
| 1045 { | |
| 1046 r_info = collection_next_by_info(cd, info); | |
| 1047 if (!r_info) r_info = collection_prev_by_info(cd, info); | |
| 1048 } | |
| 1049 else | |
| 1050 { | |
| 1051 r_info = collection_prev_by_info(cd, info); | |
| 1052 if (!r_info) r_info = collection_next_by_info(cd, info); | |
| 1053 } | |
| 138 | 1054 if (r_info) image_prebuffer_set(lw->image, r_info->fd); |
| 9 | 1055 } |
| 1056 | |
| 1057 layout_image_slideshow_continue_check(lw); | |
| 1058 layout_bars_new_image(lw); | |
| 1059 } | |
| 1060 | |
| 1061 void layout_image_set_collection(LayoutWindow *lw, CollectionData *cd, CollectInfo *info) | |
| 1062 { | |
| 1063 layout_image_set_collection_real(lw, cd, info, TRUE); | |
| 138 | 1064 layout_list_sync_fd(lw, layout_image_get_fd(lw)); |
| 9 | 1065 } |
| 1066 | |
| 1067 void layout_image_refresh(LayoutWindow *lw) | |
| 1068 { | |
| 1069 if (!layout_valid(&lw)) return; | |
| 1070 | |
| 1071 image_reload(lw->image); | |
| 1072 } | |
| 1073 | |
|
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1074 void layout_image_color_profile_set(LayoutWindow *lw, |
| 1548 | 1075 gint input_type, |
| 1431 | 1076 gboolean use_image) |
|
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1077 { |
|
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1078 if (!layout_valid(&lw)) return; |
|
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1079 |
| 1548 | 1080 image_color_profile_set(lw->image, input_type, use_image); |
|
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1081 } |
|
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1082 |
| 1431 | 1083 gboolean layout_image_color_profile_get(LayoutWindow *lw, |
| 1548 | 1084 gint *input_type, |
| 1431 | 1085 gboolean *use_image) |
|
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1086 { |
|
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1087 if (!layout_valid(&lw)) return FALSE; |
|
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1088 |
| 1548 | 1089 return image_color_profile_get(lw->image, input_type, use_image); |
|
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1090 } |
|
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1091 |
| 1431 | 1092 void layout_image_color_profile_set_use(LayoutWindow *lw, gboolean enable) |
|
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1093 { |
|
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1094 if (!layout_valid(&lw)) return; |
|
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1095 |
|
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1096 image_color_profile_set_use(lw->image, enable); |
|
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1097 } |
|
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1098 |
| 1431 | 1099 gboolean layout_image_color_profile_get_use(LayoutWindow *lw) |
|
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1100 { |
|
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1101 if (!layout_valid(&lw)) return FALSE; |
|
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1102 |
|
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1103 return image_color_profile_get_use(lw->image); |
|
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1104 } |
|
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1105 |
| 1549 | 1106 gboolean layout_image_color_profile_get_status(LayoutWindow *lw, gchar **image_profile, gchar **screen_profile) |
|
426
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
369
diff
changeset
|
1107 { |
| 1549 | 1108 if (!layout_valid(&lw)) return FALSE; |
|
426
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
369
diff
changeset
|
1109 |
| 1549 | 1110 return image_color_profile_get_status(lw->image, image_profile, screen_profile); |
|
426
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
369
diff
changeset
|
1111 } |
|
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
369
diff
changeset
|
1112 |
| 9 | 1113 /* |
| 1114 *---------------------------------------------------------------------------- | |
| 1115 * list walkers | |
| 1116 *---------------------------------------------------------------------------- | |
| 1117 */ | |
| 1118 | |
| 1119 void layout_image_next(LayoutWindow *lw) | |
| 1120 { | |
| 1121 gint current; | |
| 1122 CollectionData *cd; | |
| 1123 CollectInfo *info; | |
| 1124 | |
| 1125 if (!layout_valid(&lw)) return; | |
| 1126 | |
| 1127 if (layout_image_slideshow_active(lw)) | |
| 1128 { | |
| 1129 layout_image_slideshow_next(lw); | |
| 1130 return; | |
| 1131 } | |
| 1132 | |
| 220 | 1133 if (layout_selection_count(lw, 0) > 1) |
| 1134 { | |
| 1135 GList *x = layout_selection_list_by_index(lw); | |
| 783 | 1136 gint old = layout_list_get_index(lw, layout_image_get_fd(lw)); |
| 220 | 1137 GList *y; |
| 1138 | |
|
529
8815fea478ee
fix warning cast from pointer to integer of different size (when an integer is
bruclik
parents:
520
diff
changeset
|
1139 for (y = x; y && (GPOINTER_TO_INT(y->data)) != old; y = y->next) |
| 220 | 1140 ; |
| 1141 if (y) | |
| 1142 { | |
| 442 | 1143 if (y->next) |
|
529
8815fea478ee
fix warning cast from pointer to integer of different size (when an integer is
bruclik
parents:
520
diff
changeset
|
1144 layout_image_set_index(lw, GPOINTER_TO_INT(y->next->data)); |
| 442 | 1145 else |
|
529
8815fea478ee
fix warning cast from pointer to integer of different size (when an integer is
bruclik
parents:
520
diff
changeset
|
1146 layout_image_set_index(lw, GPOINTER_TO_INT(x->data)); |
| 220 | 1147 } |
| 1148 while (x) | |
| 1149 x = g_list_remove(x, x->data); | |
| 1150 if (y) /* not dereferenced */ | |
| 1151 return; | |
| 1152 } | |
| 1153 | |
| 9 | 1154 cd = image_get_collection(lw->image, &info); |
| 1155 | |
| 1156 if (cd && info) | |
| 1157 { | |
| 1158 info = collection_next_by_info(cd, info); | |
|
122
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1159 if (info) |
|
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1160 { |
|
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1161 layout_image_set_collection_real(lw, cd, info, TRUE); |
|
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1162 } |
|
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1163 else |
|
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1164 { |
|
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1165 image_osd_icon(lw->image, IMAGE_OSD_LAST, -1); |
|
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1166 } |
| 9 | 1167 return; |
| 1168 } | |
| 1169 | |
| 1170 current = layout_image_get_index(lw); | |
| 1171 | |
| 1172 if (current >= 0) | |
| 1173 { | |
| 736 | 1174 if ((guint) current < layout_list_count(lw, NULL) - 1) |
| 9 | 1175 { |
| 1176 layout_image_set_index(lw, current + 1); | |
| 1177 } | |
|
122
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1178 else |
|
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1179 { |
|
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1180 image_osd_icon(lw->image, IMAGE_OSD_LAST, -1); |
|
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1181 } |
| 9 | 1182 } |
| 1183 else | |
| 1184 { | |
| 1185 layout_image_set_index(lw, 0); | |
| 1186 } | |
| 1187 } | |
| 1188 | |
| 1189 void layout_image_prev(LayoutWindow *lw) | |
| 1190 { | |
| 1191 gint current; | |
| 1192 CollectionData *cd; | |
| 1193 CollectInfo *info; | |
| 1194 | |
| 1195 if (!layout_valid(&lw)) return; | |
| 1196 | |
| 1197 if (layout_image_slideshow_active(lw)) | |
| 1198 { | |
| 1199 layout_image_slideshow_prev(lw); | |
| 1200 return; | |
| 1201 } | |
| 1202 | |
| 220 | 1203 if (layout_selection_count(lw, 0) > 1) |
| 1204 { | |
| 1205 GList *x = layout_selection_list_by_index(lw); | |
| 783 | 1206 gint old = layout_list_get_index(lw, layout_image_get_fd(lw)); |
| 220 | 1207 GList *y; |
| 1208 GList *last; | |
| 1209 | |
| 1210 for (last = y = x; y; y = y->next) | |
| 1211 last = y; | |
|
529
8815fea478ee
fix warning cast from pointer to integer of different size (when an integer is
bruclik
parents:
520
diff
changeset
|
1212 for (y = x; y && (GPOINTER_TO_INT(y->data)) != old; y = y->next) |
| 220 | 1213 ; |
| 1214 if (y) | |
| 1215 { | |
| 442 | 1216 if (y->prev) |
|
529
8815fea478ee
fix warning cast from pointer to integer of different size (when an integer is
bruclik
parents:
520
diff
changeset
|
1217 layout_image_set_index(lw, GPOINTER_TO_INT(y->prev->data)); |
| 220 | 1218 else |
|
529
8815fea478ee
fix warning cast from pointer to integer of different size (when an integer is
bruclik
parents:
520
diff
changeset
|
1219 layout_image_set_index(lw, GPOINTER_TO_INT(last->data)); |
| 220 | 1220 } |
| 1221 while (x) | |
| 1222 x = g_list_remove(x, x->data); | |
| 1223 if (y) /* not dereferenced */ | |
| 1224 return; | |
| 1225 } | |
| 1226 | |
| 9 | 1227 cd = image_get_collection(lw->image, &info); |
| 1228 | |
| 1229 if (cd && info) | |
| 1230 { | |
| 1231 info = collection_prev_by_info(cd, info); | |
|
122
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1232 if (info) |
|
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1233 { |
|
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1234 layout_image_set_collection_real(lw, cd, info, FALSE); |
|
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1235 } |
|
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1236 else |
|
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1237 { |
|
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1238 image_osd_icon(lw->image, IMAGE_OSD_FIRST, -1); |
|
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1239 } |
| 9 | 1240 return; |
| 1241 } | |
| 1242 | |
| 1243 current = layout_image_get_index(lw); | |
| 1244 | |
| 1245 if (current >= 0) | |
| 1246 { | |
| 1247 if (current > 0) | |
| 1248 { | |
| 1249 layout_image_set_index(lw, current - 1); | |
| 1250 } | |
|
122
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1251 else |
|
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1252 { |
|
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1253 image_osd_icon(lw->image, IMAGE_OSD_FIRST, -1); |
|
e2a8b7f2165b
Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
117
diff
changeset
|
1254 } |
| 9 | 1255 } |
| 1256 else | |
| 1257 { | |
| 1258 layout_image_set_index(lw, layout_list_count(lw, NULL) - 1); | |
| 1259 } | |
| 1260 } | |
| 1261 | |
| 1262 void layout_image_first(LayoutWindow *lw) | |
| 1263 { | |
| 1264 gint current; | |
| 1265 CollectionData *cd; | |
| 1266 CollectInfo *info; | |
| 1267 | |
| 1268 if (!layout_valid(&lw)) return; | |
| 1269 | |
| 1270 cd = image_get_collection(lw->image, &info); | |
| 1271 | |
| 1272 if (cd && info) | |
| 1273 { | |
| 1274 CollectInfo *new; | |
| 1275 new = collection_get_first(cd); | |
| 1276 if (new != info) layout_image_set_collection_real(lw, cd, new, TRUE); | |
| 1277 return; | |
| 1278 } | |
| 1279 | |
| 1280 current = layout_image_get_index(lw); | |
| 1281 if (current != 0 && layout_list_count(lw, NULL) > 0) | |
| 1282 { | |
| 1283 layout_image_set_index(lw, 0); | |
| 1284 } | |
| 1285 } | |
| 1286 | |
| 1287 void layout_image_last(LayoutWindow *lw) | |
| 1288 { | |
| 1289 gint current; | |
| 1290 gint count; | |
| 1291 CollectionData *cd; | |
| 1292 CollectInfo *info; | |
| 1293 | |
| 1294 if (!layout_valid(&lw)) return; | |
| 1295 | |
| 1296 cd = image_get_collection(lw->image, &info); | |
| 1297 | |
| 1298 if (cd && info) | |
| 1299 { | |
| 1300 CollectInfo *new; | |
| 1301 new = collection_get_last(cd); | |
| 1302 if (new != info) layout_image_set_collection_real(lw, cd, new, FALSE); | |
| 1303 return; | |
| 1304 } | |
| 1305 | |
| 1306 current = layout_image_get_index(lw); | |
| 1307 count = layout_list_count(lw, NULL); | |
| 1308 if (current != count - 1 && count > 0) | |
| 1309 { | |
| 1310 layout_image_set_index(lw, count - 1); | |
| 1311 } | |
| 1312 } | |
| 1313 | |
| 1314 /* | |
| 1315 *---------------------------------------------------------------------------- | |
| 1316 * mouse callbacks | |
| 1317 *---------------------------------------------------------------------------- | |
| 1318 */ | |
| 1319 | |
| 127 | 1320 static gint image_idx(LayoutWindow *lw, ImageWindow *imd) |
| 1321 { | |
| 1322 gint i; | |
| 442 | 1323 |
| 520 | 1324 for (i = 0; i < MAX_SPLIT_IMAGES; i++) |
| 127 | 1325 { |
| 1326 if (lw->split_images[i] == imd) | |
| 1327 break; | |
| 1328 } | |
| 1329 if (i < MAX_SPLIT_IMAGES) | |
| 1330 { | |
| 1331 return i; | |
| 1332 } | |
| 1333 return -1; | |
| 1334 } | |
| 1335 | |
| 1481 | 1336 static void layout_image_focus_in_cb(ImageWindow *imd, gpointer data) |
| 1337 { | |
| 1338 LayoutWindow *lw = data; | |
| 1339 | |
| 1340 gint i = image_idx(lw, imd); | |
| 1341 | |
| 1342 if (i != -1) | |
| 1343 { | |
| 1344 DEBUG_1("image activate focus_in %d", i); | |
| 1659 | 1345 layout_image_activate(lw, i, FALSE); |
| 1481 | 1346 } |
| 1347 } | |
| 1348 | |
| 127 | 1349 |
|
868
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1350 static void layout_image_button_cb(ImageWindow *imd, GdkEventButton *event, gpointer data) |
| 9 | 1351 { |
| 1352 LayoutWindow *lw = data; | |
| 1353 GtkWidget *menu; | |
| 1354 | |
|
868
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1355 switch (event->button) |
| 9 | 1356 { |
|
448
a73cc0fa14d0
Use explicit names for mouse buttons instead of numbers.
zas_
parents:
446
diff
changeset
|
1357 case MOUSE_BUTTON_LEFT: |
|
1286
eba0b4ae413b
do not switch to the next image on mouse click in split mode
nadvornik
parents:
1284
diff
changeset
|
1358 if (lw->split_mode == SPLIT_NONE) |
|
eba0b4ae413b
do not switch to the next image on mouse click in split mode
nadvornik
parents:
1284
diff
changeset
|
1359 layout_image_next(lw); |
| 9 | 1360 break; |
|
448
a73cc0fa14d0
Use explicit names for mouse buttons instead of numbers.
zas_
parents:
446
diff
changeset
|
1361 case MOUSE_BUTTON_MIDDLE: |
|
1286
eba0b4ae413b
do not switch to the next image on mouse click in split mode
nadvornik
parents:
1284
diff
changeset
|
1362 if (lw->split_mode == SPLIT_NONE) |
|
eba0b4ae413b
do not switch to the next image on mouse click in split mode
nadvornik
parents:
1284
diff
changeset
|
1363 layout_image_prev(lw); |
| 9 | 1364 break; |
|
448
a73cc0fa14d0
Use explicit names for mouse buttons instead of numbers.
zas_
parents:
446
diff
changeset
|
1365 case MOUSE_BUTTON_RIGHT: |
| 9 | 1366 menu = layout_image_pop_menu(lw); |
| 1367 if (imd == lw->image) | |
| 1368 { | |
| 1369 g_object_set_data(G_OBJECT(menu), "click_parent", imd->widget); | |
| 1370 } | |
|
868
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1371 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 3, event->time); |
| 9 | 1372 break; |
| 1373 default: | |
| 1374 break; | |
| 1375 } | |
| 1376 } | |
| 1377 | |
|
868
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1378 static void layout_image_scroll_cb(ImageWindow *imd, GdkEventScroll *event, gpointer data) |
| 9 | 1379 { |
| 1380 LayoutWindow *lw = data; | |
| 1381 | |
| 127 | 1382 gint i = image_idx(lw, imd); |
| 442 | 1383 |
| 127 | 1384 if (i != -1) |
| 1385 { | |
|
506
fc9c8a3e1a8b
Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents:
497
diff
changeset
|
1386 DEBUG_1("image activate scroll %d", i); |
| 1659 | 1387 layout_image_activate(lw, i, FALSE); |
| 127 | 1388 } |
| 1389 | |
| 1390 | |
|
868
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1391 if (event->state & GDK_CONTROL_MASK) |
| 9 | 1392 { |
|
868
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1393 switch (event->direction) |
| 9 | 1394 { |
| 1395 case GDK_SCROLL_UP: | |
| 1047 | 1396 layout_image_zoom_adjust_at_point(lw, get_zoom_increment(), event->x, event->y, event->state & GDK_SHIFT_MASK); |
| 9 | 1397 break; |
| 1398 case GDK_SCROLL_DOWN: | |
| 1047 | 1399 layout_image_zoom_adjust_at_point(lw, -get_zoom_increment(), event->x, event->y, event->state & GDK_SHIFT_MASK); |
| 9 | 1400 break; |
| 1401 default: | |
| 1402 break; | |
| 1403 } | |
| 1404 } | |
| 1047 | 1405 else if (options->mousewheel_scrolls) |
| 9 | 1406 { |
|
868
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1407 switch (event->direction) |
| 9 | 1408 { |
| 1409 case GDK_SCROLL_UP: | |
| 1410 image_scroll(imd, 0, -MOUSEWHEEL_SCROLL_SIZE); | |
| 1411 break; | |
| 1412 case GDK_SCROLL_DOWN: | |
| 1413 image_scroll(imd, 0, MOUSEWHEEL_SCROLL_SIZE); | |
| 1414 break; | |
| 1415 case GDK_SCROLL_LEFT: | |
| 1416 image_scroll(imd, -MOUSEWHEEL_SCROLL_SIZE, 0); | |
| 1417 break; | |
| 1418 case GDK_SCROLL_RIGHT: | |
| 1419 image_scroll(imd, MOUSEWHEEL_SCROLL_SIZE, 0); | |
| 1420 break; | |
| 1421 default: | |
| 1422 break; | |
| 1423 } | |
| 1424 } | |
| 1425 else | |
| 1426 { | |
|
868
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1427 switch (event->direction) |
| 9 | 1428 { |
| 1429 case GDK_SCROLL_UP: | |
| 1430 layout_image_prev(lw); | |
| 1431 break; | |
| 1432 case GDK_SCROLL_DOWN: | |
| 1433 layout_image_next(lw); | |
| 1434 break; | |
| 1435 default: | |
| 1436 break; | |
| 1437 } | |
| 1438 } | |
| 1439 } | |
| 1440 | |
|
868
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1441 static void layout_image_drag_cb(ImageWindow *imd, GdkEventButton *event, gdouble dx, gdouble dy, gpointer data) |
| 127 | 1442 { |
| 1443 gint i; | |
| 1444 LayoutWindow *lw = data; | |
| 1445 | |
| 1047 | 1446 if (!(event->state & GDK_SHIFT_MASK)) return; |
|
869
371a1c3d4504
layout_image_drag_cb(): optimize when connected scrolling is unset.
zas_
parents:
868
diff
changeset
|
1447 |
|
868
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1448 for (i = 0; i < MAX_SPLIT_IMAGES; i++) |
| 127 | 1449 { |
|
869
371a1c3d4504
layout_image_drag_cb(): optimize when connected scrolling is unset.
zas_
parents:
868
diff
changeset
|
1450 if (lw->split_images[i] && lw->split_images[i] != imd) |
|
868
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1451 { |
|
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1452 gdouble sx, sy; |
|
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1453 |
|
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1454 if (event->state & GDK_CONTROL_MASK) |
| 129 | 1455 { |
|
868
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1456 image_get_scroll_center(imd, &sx, &sy); |
| 129 | 1457 } |
|
868
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1458 else |
|
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1459 { |
|
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1460 image_get_scroll_center(lw->split_images[i], &sx, &sy); |
|
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1461 sx += dx; |
|
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1462 sy += dy; |
|
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1463 } |
|
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1464 image_set_scroll_center(lw->split_images[i], sx, sy); |
|
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1465 } |
| 127 | 1466 } |
| 1467 } | |
| 1468 | |
|
868
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1469 static void layout_image_button_inactive_cb(ImageWindow *imd, GdkEventButton *event, gpointer data) |
| 127 | 1470 { |
| 1471 LayoutWindow *lw = data; | |
|
128
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1472 GtkWidget *menu; |
| 127 | 1473 gint i = image_idx(lw, imd); |
| 442 | 1474 |
| 127 | 1475 if (i != -1) |
| 1476 { | |
| 1659 | 1477 layout_image_activate(lw, i, FALSE); |
| 127 | 1478 } |
|
128
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1479 |
|
868
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1480 switch (event->button) |
|
128
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1481 { |
|
448
a73cc0fa14d0
Use explicit names for mouse buttons instead of numbers.
zas_
parents:
446
diff
changeset
|
1482 case MOUSE_BUTTON_RIGHT: |
|
128
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1483 menu = layout_image_pop_menu(lw); |
|
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1484 if (imd == lw->image) |
|
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1485 { |
|
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1486 g_object_set_data(G_OBJECT(menu), "click_parent", imd->widget); |
|
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1487 } |
|
868
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1488 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 3, event->time); |
|
128
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1489 break; |
|
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1490 default: |
|
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1491 break; |
|
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1492 } |
|
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1493 |
| 127 | 1494 } |
| 1495 | |
|
868
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1496 static void layout_image_drag_inactive_cb(ImageWindow *imd, GdkEventButton *event, gdouble dx, gdouble dy, gpointer data) |
|
128
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1497 { |
|
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1498 LayoutWindow *lw = data; |
|
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1499 gint i = image_idx(lw, imd); |
| 442 | 1500 |
|
128
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1501 if (i != -1) |
|
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1502 { |
| 1659 | 1503 layout_image_activate(lw, i, FALSE); |
|
128
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1504 } |
|
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1505 |
| 129 | 1506 /* continue as with active image */ |
|
868
db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
zas_
parents:
837
diff
changeset
|
1507 layout_image_drag_cb(imd, event, dx, dy, data); |
|
128
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1508 } |
|
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1509 |
|
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1510 |
| 9 | 1511 static void layout_image_set_buttons(LayoutWindow *lw) |
| 1512 { | |
| 1513 image_set_button_func(lw->image, layout_image_button_cb, lw); | |
| 1514 image_set_scroll_func(lw->image, layout_image_scroll_cb, lw); | |
| 1515 } | |
| 1516 | |
| 127 | 1517 static void layout_image_set_buttons_inactive(LayoutWindow *lw, gint i) |
| 1518 { | |
| 1519 image_set_button_func(lw->split_images[i], layout_image_button_inactive_cb, lw); | |
| 1520 image_set_scroll_func(lw->split_images[i], layout_image_scroll_cb, lw); | |
| 1521 } | |
| 1522 | |
|
1377
dab37628f5d8
layout_status_update_pixel_cb(): cleanup and optimization, drop pango markup in i18n string, use a small function to calculate numbers length, only allocate text when needed.
zas_
parents:
1375
diff
changeset
|
1523 /* Returns the length of an integer */ |
|
dab37628f5d8
layout_status_update_pixel_cb(): cleanup and optimization, drop pango markup in i18n string, use a small function to calculate numbers length, only allocate text when needed.
zas_
parents:
1375
diff
changeset
|
1524 static gint num_length(gint num) |
|
dab37628f5d8
layout_status_update_pixel_cb(): cleanup and optimization, drop pango markup in i18n string, use a small function to calculate numbers length, only allocate text when needed.
zas_
parents:
1375
diff
changeset
|
1525 { |
|
1433
b4ad1d201279
Use gboolean where applicable, minor cleanup and indentations fixes.
zas_
parents:
1432
diff
changeset
|
1526 gint len = 0; |
|
b4ad1d201279
Use gboolean where applicable, minor cleanup and indentations fixes.
zas_
parents:
1432
diff
changeset
|
1527 if (num < 0) num = -num; |
|
b4ad1d201279
Use gboolean where applicable, minor cleanup and indentations fixes.
zas_
parents:
1432
diff
changeset
|
1528 while (num) |
|
b4ad1d201279
Use gboolean where applicable, minor cleanup and indentations fixes.
zas_
parents:
1432
diff
changeset
|
1529 { |
|
b4ad1d201279
Use gboolean where applicable, minor cleanup and indentations fixes.
zas_
parents:
1432
diff
changeset
|
1530 num /= 10; |
|
b4ad1d201279
Use gboolean where applicable, minor cleanup and indentations fixes.
zas_
parents:
1432
diff
changeset
|
1531 len++; |
|
b4ad1d201279
Use gboolean where applicable, minor cleanup and indentations fixes.
zas_
parents:
1432
diff
changeset
|
1532 } |
|
b4ad1d201279
Use gboolean where applicable, minor cleanup and indentations fixes.
zas_
parents:
1432
diff
changeset
|
1533 return len; |
|
1377
dab37628f5d8
layout_status_update_pixel_cb(): cleanup and optimization, drop pango markup in i18n string, use a small function to calculate numbers length, only allocate text when needed.
zas_
parents:
1375
diff
changeset
|
1534 } |
|
1375
df58e511d90e
Display pixel coordinates and rgb - patch by Ruben Stein
nadvornik
parents:
1373
diff
changeset
|
1535 |
|
df58e511d90e
Display pixel coordinates and rgb - patch by Ruben Stein
nadvornik
parents:
1373
diff
changeset
|
1536 void layout_status_update_pixel_cb(PixbufRenderer *pr, gpointer data) |
|
df58e511d90e
Display pixel coordinates and rgb - patch by Ruben Stein
nadvornik
parents:
1373
diff
changeset
|
1537 { |
|
df58e511d90e
Display pixel coordinates and rgb - patch by Ruben Stein
nadvornik
parents:
1373
diff
changeset
|
1538 LayoutWindow *lw = data; |
|
1377
dab37628f5d8
layout_status_update_pixel_cb(): cleanup and optimization, drop pango markup in i18n string, use a small function to calculate numbers length, only allocate text when needed.
zas_
parents:
1375
diff
changeset
|
1539 gint x_pixel, y_pixel; |
|
1584
0cd2268f500b
improved pixel info, changed the menu entry from "Hide" to "Show",
nadvornik
parents:
1566
diff
changeset
|
1540 gint width, height; |
|
0cd2268f500b
improved pixel info, changed the menu entry from "Hide" to "Show",
nadvornik
parents:
1566
diff
changeset
|
1541 gchar *text; |
|
0cd2268f500b
improved pixel info, changed the menu entry from "Hide" to "Show",
nadvornik
parents:
1566
diff
changeset
|
1542 PangoAttrList *attrs; |
|
1375
df58e511d90e
Display pixel coordinates and rgb - patch by Ruben Stein
nadvornik
parents:
1373
diff
changeset
|
1543 |
|
1377
dab37628f5d8
layout_status_update_pixel_cb(): cleanup and optimization, drop pango markup in i18n string, use a small function to calculate numbers length, only allocate text when needed.
zas_
parents:
1375
diff
changeset
|
1544 if (!data || !layout_valid(&lw) || !lw->image |
|
1584
0cd2268f500b
improved pixel info, changed the menu entry from "Hide" to "Show",
nadvornik
parents:
1566
diff
changeset
|
1545 || !lw->options.show_info_pixel || lw->image->unknown) return; |
|
0cd2268f500b
improved pixel info, changed the menu entry from "Hide" to "Show",
nadvornik
parents:
1566
diff
changeset
|
1546 |
|
0cd2268f500b
improved pixel info, changed the menu entry from "Hide" to "Show",
nadvornik
parents:
1566
diff
changeset
|
1547 pixbuf_renderer_get_image_size(pr, &width, &height); |
|
0cd2268f500b
improved pixel info, changed the menu entry from "Hide" to "Show",
nadvornik
parents:
1566
diff
changeset
|
1548 if (width < 1 || height < 1) return; |
|
0cd2268f500b
improved pixel info, changed the menu entry from "Hide" to "Show",
nadvornik
parents:
1566
diff
changeset
|
1549 |
|
1377
dab37628f5d8
layout_status_update_pixel_cb(): cleanup and optimization, drop pango markup in i18n string, use a small function to calculate numbers length, only allocate text when needed.
zas_
parents:
1375
diff
changeset
|
1550 pixbuf_renderer_get_mouse_position(pr, &x_pixel, &y_pixel); |
|
dab37628f5d8
layout_status_update_pixel_cb(): cleanup and optimization, drop pango markup in i18n string, use a small function to calculate numbers length, only allocate text when needed.
zas_
parents:
1375
diff
changeset
|
1551 |
|
1492
c350242b1a5d
Fixed bug where pixel/color information at x=0 coordinates werent shown:
zas_
parents:
1481
diff
changeset
|
1552 if(x_pixel >= 0 && y_pixel >= 0) |
|
1377
dab37628f5d8
layout_status_update_pixel_cb(): cleanup and optimization, drop pango markup in i18n string, use a small function to calculate numbers length, only allocate text when needed.
zas_
parents:
1375
diff
changeset
|
1553 { |
|
dab37628f5d8
layout_status_update_pixel_cb(): cleanup and optimization, drop pango markup in i18n string, use a small function to calculate numbers length, only allocate text when needed.
zas_
parents:
1375
diff
changeset
|
1554 gint r_mouse, g_mouse, b_mouse; |
|
1375
df58e511d90e
Display pixel coordinates and rgb - patch by Ruben Stein
nadvornik
parents:
1373
diff
changeset
|
1555 |
|
1377
dab37628f5d8
layout_status_update_pixel_cb(): cleanup and optimization, drop pango markup in i18n string, use a small function to calculate numbers length, only allocate text when needed.
zas_
parents:
1375
diff
changeset
|
1556 pixbuf_renderer_get_pixel_colors(pr, x_pixel, y_pixel, |
|
dab37628f5d8
layout_status_update_pixel_cb(): cleanup and optimization, drop pango markup in i18n string, use a small function to calculate numbers length, only allocate text when needed.
zas_
parents:
1375
diff
changeset
|
1557 &r_mouse, &g_mouse, &b_mouse); |
|
dab37628f5d8
layout_status_update_pixel_cb(): cleanup and optimization, drop pango markup in i18n string, use a small function to calculate numbers length, only allocate text when needed.
zas_
parents:
1375
diff
changeset
|
1558 |
|
1584
0cd2268f500b
improved pixel info, changed the menu entry from "Hide" to "Show",
nadvornik
parents:
1566
diff
changeset
|
1559 text = g_strdup_printf(_("[%*d,%*d]: RGB(%3d,%3d,%3d)"), |
|
1377
dab37628f5d8
layout_status_update_pixel_cb(): cleanup and optimization, drop pango markup in i18n string, use a small function to calculate numbers length, only allocate text when needed.
zas_
parents:
1375
diff
changeset
|
1560 num_length(width - 1), x_pixel, |
|
dab37628f5d8
layout_status_update_pixel_cb(): cleanup and optimization, drop pango markup in i18n string, use a small function to calculate numbers length, only allocate text when needed.
zas_
parents:
1375
diff
changeset
|
1561 num_length(height - 1), y_pixel, |
|
dab37628f5d8
layout_status_update_pixel_cb(): cleanup and optimization, drop pango markup in i18n string, use a small function to calculate numbers length, only allocate text when needed.
zas_
parents:
1375
diff
changeset
|
1562 r_mouse, g_mouse, b_mouse); |
|
dab37628f5d8
layout_status_update_pixel_cb(): cleanup and optimization, drop pango markup in i18n string, use a small function to calculate numbers length, only allocate text when needed.
zas_
parents:
1375
diff
changeset
|
1563 |
|
1375
df58e511d90e
Display pixel coordinates and rgb - patch by Ruben Stein
nadvornik
parents:
1373
diff
changeset
|
1564 } |
|
1377
dab37628f5d8
layout_status_update_pixel_cb(): cleanup and optimization, drop pango markup in i18n string, use a small function to calculate numbers length, only allocate text when needed.
zas_
parents:
1375
diff
changeset
|
1565 else |
|
dab37628f5d8
layout_status_update_pixel_cb(): cleanup and optimization, drop pango markup in i18n string, use a small function to calculate numbers length, only allocate text when needed.
zas_
parents:
1375
diff
changeset
|
1566 { |
|
1584
0cd2268f500b
improved pixel info, changed the menu entry from "Hide" to "Show",
nadvornik
parents:
1566
diff
changeset
|
1567 text = g_strdup_printf(_("[%*s,%*s]: RGB(---,---,---)"), |
|
0cd2268f500b
improved pixel info, changed the menu entry from "Hide" to "Show",
nadvornik
parents:
1566
diff
changeset
|
1568 num_length(width - 1), " ", |
|
0cd2268f500b
improved pixel info, changed the menu entry from "Hide" to "Show",
nadvornik
parents:
1566
diff
changeset
|
1569 num_length(height - 1), " "); |
|
1377
dab37628f5d8
layout_status_update_pixel_cb(): cleanup and optimization, drop pango markup in i18n string, use a small function to calculate numbers length, only allocate text when needed.
zas_
parents:
1375
diff
changeset
|
1570 } |
|
1584
0cd2268f500b
improved pixel info, changed the menu entry from "Hide" to "Show",
nadvornik
parents:
1566
diff
changeset
|
1571 |
|
0cd2268f500b
improved pixel info, changed the menu entry from "Hide" to "Show",
nadvornik
parents:
1566
diff
changeset
|
1572 attrs = pango_attr_list_new(); |
|
0cd2268f500b
improved pixel info, changed the menu entry from "Hide" to "Show",
nadvornik
parents:
1566
diff
changeset
|
1573 pango_attr_list_insert(attrs, pango_attr_family_new("Monospace")); |
|
0cd2268f500b
improved pixel info, changed the menu entry from "Hide" to "Show",
nadvornik
parents:
1566
diff
changeset
|
1574 gtk_label_set_text(GTK_LABEL(lw->info_pixel), text); |
|
0cd2268f500b
improved pixel info, changed the menu entry from "Hide" to "Show",
nadvornik
parents:
1566
diff
changeset
|
1575 gtk_label_set_attributes(GTK_LABEL(lw->info_pixel), attrs); |
|
0cd2268f500b
improved pixel info, changed the menu entry from "Hide" to "Show",
nadvornik
parents:
1566
diff
changeset
|
1576 pango_attr_list_unref(attrs); |
|
0cd2268f500b
improved pixel info, changed the menu entry from "Hide" to "Show",
nadvornik
parents:
1566
diff
changeset
|
1577 g_free(text); |
|
1375
df58e511d90e
Display pixel coordinates and rgb - patch by Ruben Stein
nadvornik
parents:
1373
diff
changeset
|
1578 } |
|
df58e511d90e
Display pixel coordinates and rgb - patch by Ruben Stein
nadvornik
parents:
1373
diff
changeset
|
1579 |
|
df58e511d90e
Display pixel coordinates and rgb - patch by Ruben Stein
nadvornik
parents:
1373
diff
changeset
|
1580 |
| 9 | 1581 /* |
| 1582 *---------------------------------------------------------------------------- | |
| 1583 * setup | |
| 1584 *---------------------------------------------------------------------------- | |
| 1585 */ | |
| 1586 | |
| 1587 static void layout_image_update_cb(ImageWindow *imd, gpointer data) | |
| 1588 { | |
| 1589 LayoutWindow *lw = data; | |
| 1590 layout_status_update_image(lw); | |
| 1591 } | |
| 1592 | |
| 127 | 1593 GtkWidget *layout_image_new(LayoutWindow *lw, gint i) |
| 9 | 1594 { |
|
837
f8c22438376c
use GtkSizeGroup to control initial size of split images
nadvornik
parents:
836
diff
changeset
|
1595 if (!lw->split_image_sizegroup) lw->split_image_sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_BOTH); |
|
f8c22438376c
use GtkSizeGroup to control initial size of split images
nadvornik
parents:
836
diff
changeset
|
1596 |
| 442 | 1597 if (!lw->split_images[i]) |
| 9 | 1598 { |
| 127 | 1599 lw->split_images[i] = image_new(TRUE); |
| 1600 | |
| 1043 | 1601 #if GTK_CHECK_VERSION(2,12,0) |
| 1602 g_object_ref(lw->split_images[i]->widget); | |
| 1603 #else | |
| 127 | 1604 gtk_widget_ref(lw->split_images[i]->widget); |
| 1043 | 1605 #endif |
|
1375
df58e511d90e
Display pixel coordinates and rgb - patch by Ruben Stein
nadvornik
parents:
1373
diff
changeset
|
1606 |
|
df58e511d90e
Display pixel coordinates and rgb - patch by Ruben Stein
nadvornik
parents:
1373
diff
changeset
|
1607 g_signal_connect(G_OBJECT(lw->split_images[i]->pr), "update-pixel", |
|
df58e511d90e
Display pixel coordinates and rgb - patch by Ruben Stein
nadvornik
parents:
1373
diff
changeset
|
1608 G_CALLBACK(layout_status_update_pixel_cb), lw); |
|
df58e511d90e
Display pixel coordinates and rgb - patch by Ruben Stein
nadvornik
parents:
1373
diff
changeset
|
1609 |
|
1626
1d7941c147be
Add an option to Image preferences to restrict custom border to fullscreen mode only. Bug 2798062.
zas_
parents:
1584
diff
changeset
|
1610 image_background_set_color_from_options(lw->split_images[i], FALSE); |
| 9 | 1611 |
| 888 | 1612 image_auto_refresh_enable(lw->split_images[i], TRUE); |
|
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
86
diff
changeset
|
1613 |
| 127 | 1614 layout_image_dnd_init(lw, i); |
| 207 | 1615 image_color_profile_set(lw->split_images[i], |
| 327 | 1616 options->color_profile.input_type, |
| 1617 options->color_profile.use_image); | |
| 1618 image_color_profile_set_use(lw->split_images[i], options->color_profile.enabled); | |
|
837
f8c22438376c
use GtkSizeGroup to control initial size of split images
nadvornik
parents:
836
diff
changeset
|
1619 |
|
f8c22438376c
use GtkSizeGroup to control initial size of split images
nadvornik
parents:
836
diff
changeset
|
1620 gtk_size_group_add_widget(lw->split_image_sizegroup, lw->split_images[i]->widget); |
| 1383 | 1621 gtk_widget_set_size_request(lw->split_images[i]->widget, IMAGE_MIN_WIDTH, -1); |
| 1622 | |
| 1481 | 1623 image_set_focus_in_func(lw->split_images[i], layout_image_focus_in_cb, lw); |
| 1624 | |
| 9 | 1625 } |
| 1626 | |
| 127 | 1627 return lw->split_images[i]->widget; |
| 1628 } | |
| 1629 | |
| 1630 void layout_image_deactivate(LayoutWindow *lw, gint i) | |
| 1631 { | |
| 1632 if (!lw->split_images[i]) return; | |
| 1633 image_set_update_func(lw->split_images[i], NULL, NULL); | |
| 1634 layout_image_set_buttons_inactive(lw, i); | |
| 129 | 1635 image_set_drag_func(lw->split_images[i], layout_image_drag_inactive_cb, lw); |
| 127 | 1636 |
| 1637 image_attach_window(lw->split_images[i], NULL, NULL, NULL, FALSE); | |
| 1638 image_select(lw->split_images[i], FALSE); | |
| 1639 } | |
| 1640 | |
| 1659 | 1641 /* force should be set after change of lw->split_mode */ |
| 1642 void layout_image_activate(LayoutWindow *lw, gint i, gboolean force) | |
| 127 | 1643 { |
| 138 | 1644 FileData *fd; |
| 442 | 1645 |
| 127 | 1646 if (!lw->split_images[i]) return; |
| 1659 | 1647 if (!force && lw->active_split_image == i) return; |
| 127 | 1648 |
| 1649 /* deactivate currently active */ | |
| 1650 if (lw->active_split_image != i) | |
| 1651 layout_image_deactivate(lw, lw->active_split_image); | |
| 1652 | |
| 1653 lw->image = lw->split_images[i]; | |
| 1654 lw->active_split_image = i; | |
| 442 | 1655 |
| 127 | 1656 image_set_update_func(lw->image, layout_image_update_cb, lw); |
| 1657 layout_image_set_buttons(lw); | |
|
128
98e2632b5d3d
improved connected scroll and active image switching
nadvornik
parents:
127
diff
changeset
|
1658 image_set_drag_func(lw->image, layout_image_drag_cb, lw); |
| 127 | 1659 |
|
288
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
281
diff
changeset
|
1660 image_attach_window(lw->image, lw->window, NULL, GQ_APPNAME, FALSE); |
| 127 | 1661 |
| 152 | 1662 /* do not hilight selected image in SPLIT_NONE */ |
| 1663 /* maybe the image should be selected always and hilight should be controled by | |
| 1664 another image option */ | |
| 1665 if (lw->split_mode != SPLIT_NONE) | |
| 1666 image_select(lw->split_images[i], TRUE); | |
| 1667 else | |
| 1668 image_select(lw->split_images[i], FALSE); | |
| 127 | 1669 |
| 138 | 1670 fd = image_get_fd(lw->image); |
| 127 | 1671 |
| 442 | 1672 if (fd) |
| 127 | 1673 { |
| 1674 // layout_list_sync_path(lw, path); | |
| 783 | 1675 layout_set_fd(lw, fd); |
| 127 | 1676 } |
| 1677 } | |
| 1678 | |
| 1679 | |
|
1168
0c7534002b0a
layout_image_setup_split_*(): move common code to a new function layout_image_setup_split_common().
zas_
parents:
1055
diff
changeset
|
1680 static void layout_image_setup_split_common(LayoutWindow *lw, gint n) |
| 127 | 1681 { |
| 1636 | 1682 gboolean frame = (n > 1) || (!lw->options.tools_float && !lw->options.tools_hidden); |
| 127 | 1683 gint i; |
| 1684 | |
| 1169 | 1685 for (i = 0; i < n; i++) |
|
1168
0c7534002b0a
layout_image_setup_split_*(): move common code to a new function layout_image_setup_split_common().
zas_
parents:
1055
diff
changeset
|
1686 if (!lw->split_images[i]) |
|
153
0e54267762f6
fixed copying zoom an scroll values from the original image on splitting
nadvornik
parents:
152
diff
changeset
|
1687 { |
|
1172
08ef8c605723
When more than one image is selected, Split Horizontal, Vertical and Quad will use selected images when initialized.
zas_
parents:
1171
diff
changeset
|
1688 FileData *img_fd = NULL; |
|
08ef8c605723
When more than one image is selected, Split Horizontal, Vertical and Quad will use selected images when initialized.
zas_
parents:
1171
diff
changeset
|
1689 double zoom = 0.0; |
|
08ef8c605723
When more than one image is selected, Split Horizontal, Vertical and Quad will use selected images when initialized.
zas_
parents:
1171
diff
changeset
|
1690 |
|
1168
0c7534002b0a
layout_image_setup_split_*(): move common code to a new function layout_image_setup_split_common().
zas_
parents:
1055
diff
changeset
|
1691 layout_image_new(lw, i); |
|
1170
159f225985c5
Use common code for layout_image_setup_split_none() too.
zas_
parents:
1169
diff
changeset
|
1692 image_set_frame(lw->split_images[i], frame); |
| 1636 | 1693 image_set_selectable(lw->split_images[i], (n > 1)); |
|
1173
52ce0263cb7c
Use the last selected images for the splitted views. Ie. when 5 images are selected, the last one is displayed, split quad while open images 5,4,3,2. It seems better to me.
zas_
parents:
1172
diff
changeset
|
1694 |
| 1373 | 1695 if (lw->image) |
| 1696 { | |
| 1697 image_osd_copy_status(lw->image, lw->split_images[i]); | |
| 1698 } | |
| 1699 | |
|
1172
08ef8c605723
When more than one image is selected, Split Horizontal, Vertical and Quad will use selected images when initialized.
zas_
parents:
1171
diff
changeset
|
1700 if (layout_selection_count(lw, 0) > 1) |
|
08ef8c605723
When more than one image is selected, Split Horizontal, Vertical and Quad will use selected images when initialized.
zas_
parents:
1171
diff
changeset
|
1701 { |
|
1173
52ce0263cb7c
Use the last selected images for the splitted views. Ie. when 5 images are selected, the last one is displayed, split quad while open images 5,4,3,2. It seems better to me.
zas_
parents:
1172
diff
changeset
|
1702 GList *work = g_list_last(layout_selection_list(lw)); |
|
1172
08ef8c605723
When more than one image is selected, Split Horizontal, Vertical and Quad will use selected images when initialized.
zas_
parents:
1171
diff
changeset
|
1703 gint j = 0; |
|
1173
52ce0263cb7c
Use the last selected images for the splitted views. Ie. when 5 images are selected, the last one is displayed, split quad while open images 5,4,3,2. It seems better to me.
zas_
parents:
1172
diff
changeset
|
1704 |
|
52ce0263cb7c
Use the last selected images for the splitted views. Ie. when 5 images are selected, the last one is displayed, split quad while open images 5,4,3,2. It seems better to me.
zas_
parents:
1172
diff
changeset
|
1705 if (work) work = work->prev; |
|
1172
08ef8c605723
When more than one image is selected, Split Horizontal, Vertical and Quad will use selected images when initialized.
zas_
parents:
1171
diff
changeset
|
1706 |
|
08ef8c605723
When more than one image is selected, Split Horizontal, Vertical and Quad will use selected images when initialized.
zas_
parents:
1171
diff
changeset
|
1707 while (work && j < i) |
|
08ef8c605723
When more than one image is selected, Split Horizontal, Vertical and Quad will use selected images when initialized.
zas_
parents:
1171
diff
changeset
|
1708 { |
|
08ef8c605723
When more than one image is selected, Split Horizontal, Vertical and Quad will use selected images when initialized.
zas_
parents:
1171
diff
changeset
|
1709 FileData *fd = work->data; |
|
1173
52ce0263cb7c
Use the last selected images for the splitted views. Ie. when 5 images are selected, the last one is displayed, split quad while open images 5,4,3,2. It seems better to me.
zas_
parents:
1172
diff
changeset
|
1710 work = work->prev; |
|
1172
08ef8c605723
When more than one image is selected, Split Horizontal, Vertical and Quad will use selected images when initialized.
zas_
parents:
1171
diff
changeset
|
1711 |
|
08ef8c605723
When more than one image is selected, Split Horizontal, Vertical and Quad will use selected images when initialized.
zas_
parents:
1171
diff
changeset
|
1712 j++; |
|
08ef8c605723
When more than one image is selected, Split Horizontal, Vertical and Quad will use selected images when initialized.
zas_
parents:
1171
diff
changeset
|
1713 if (!fd || !*fd->path) continue; |
|
08ef8c605723
When more than one image is selected, Split Horizontal, Vertical and Quad will use selected images when initialized.
zas_
parents:
1171
diff
changeset
|
1714 img_fd = fd; |
|
08ef8c605723
When more than one image is selected, Split Horizontal, Vertical and Quad will use selected images when initialized.
zas_
parents:
1171
diff
changeset
|
1715 } |
|
08ef8c605723
When more than one image is selected, Split Horizontal, Vertical and Quad will use selected images when initialized.
zas_
parents:
1171
diff
changeset
|
1716 } |
|
08ef8c605723
When more than one image is selected, Split Horizontal, Vertical and Quad will use selected images when initialized.
zas_
parents:
1171
diff
changeset
|
1717 |
|
08ef8c605723
When more than one image is selected, Split Horizontal, Vertical and Quad will use selected images when initialized.
zas_
parents:
1171
diff
changeset
|
1718 if (!img_fd && lw->image) |
|
08ef8c605723
When more than one image is selected, Split Horizontal, Vertical and Quad will use selected images when initialized.
zas_
parents:
1171
diff
changeset
|
1719 { |
|
08ef8c605723
When more than one image is selected, Split Horizontal, Vertical and Quad will use selected images when initialized.
zas_
parents:
1171
diff
changeset
|
1720 img_fd = image_get_fd(lw->image); |
|
08ef8c605723
When more than one image is selected, Split Horizontal, Vertical and Quad will use selected images when initialized.
zas_
parents:
1171
diff
changeset
|
1721 zoom = image_zoom_get(lw->image); |
|
08ef8c605723
When more than one image is selected, Split Horizontal, Vertical and Quad will use selected images when initialized.
zas_
parents:
1171
diff
changeset
|
1722 } |
|
08ef8c605723
When more than one image is selected, Split Horizontal, Vertical and Quad will use selected images when initialized.
zas_
parents:
1171
diff
changeset
|
1723 |
|
08ef8c605723
When more than one image is selected, Split Horizontal, Vertical and Quad will use selected images when initialized.
zas_
parents:
1171
diff
changeset
|
1724 if (img_fd) |
|
1168
0c7534002b0a
layout_image_setup_split_*(): move common code to a new function layout_image_setup_split_common().
zas_
parents:
1055
diff
changeset
|
1725 { |
|
0c7534002b0a
layout_image_setup_split_*(): move common code to a new function layout_image_setup_split_common().
zas_
parents:
1055
diff
changeset
|
1726 gdouble sx, sy; |
|
1172
08ef8c605723
When more than one image is selected, Split Horizontal, Vertical and Quad will use selected images when initialized.
zas_
parents:
1171
diff
changeset
|
1727 image_change_fd(lw->split_images[i], img_fd, zoom); |
|
1168
0c7534002b0a
layout_image_setup_split_*(): move common code to a new function layout_image_setup_split_common().
zas_
parents:
1055
diff
changeset
|
1728 image_get_scroll_center(lw->image, &sx, &sy); |
|
0c7534002b0a
layout_image_setup_split_*(): move common code to a new function layout_image_setup_split_common().
zas_
parents:
1055
diff
changeset
|
1729 image_set_scroll_center(lw->split_images[i], sx, sy); |
|
0c7534002b0a
layout_image_setup_split_*(): move common code to a new function layout_image_setup_split_common().
zas_
parents:
1055
diff
changeset
|
1730 } |
|
0c7534002b0a
layout_image_setup_split_*(): move common code to a new function layout_image_setup_split_common().
zas_
parents:
1055
diff
changeset
|
1731 layout_image_deactivate(lw, i); |
|
153
0e54267762f6
fixed copying zoom an scroll values from the original image on splitting
nadvornik
parents:
152
diff
changeset
|
1732 } |
|
1168
0c7534002b0a
layout_image_setup_split_*(): move common code to a new function layout_image_setup_split_common().
zas_
parents:
1055
diff
changeset
|
1733 else |
|
0c7534002b0a
layout_image_setup_split_*(): move common code to a new function layout_image_setup_split_common().
zas_
parents:
1055
diff
changeset
|
1734 { |
|
1170
159f225985c5
Use common code for layout_image_setup_split_none() too.
zas_
parents:
1169
diff
changeset
|
1735 image_set_frame(lw->split_images[i], frame); |
| 1636 | 1736 image_set_selectable(lw->split_images[i], (n > 1)); |
|
1168
0c7534002b0a
layout_image_setup_split_*(): move common code to a new function layout_image_setup_split_common().
zas_
parents:
1055
diff
changeset
|
1737 } |
| 127 | 1738 |
|
1168
0c7534002b0a
layout_image_setup_split_*(): move common code to a new function layout_image_setup_split_common().
zas_
parents:
1055
diff
changeset
|
1739 for (i = n; i < MAX_SPLIT_IMAGES; i++) |
| 127 | 1740 { |
| 1741 if (lw->split_images[i]) | |
| 1742 { | |
| 1043 | 1743 #if GTK_CHECK_VERSION(2,12,0) |
| 1744 g_object_unref(lw->split_images[i]->widget); | |
| 1745 #else | |
| 127 | 1746 gtk_widget_unref(lw->split_images[i]->widget); |
| 1043 | 1747 #endif |
| 127 | 1748 lw->split_images[i] = NULL; |
| 1749 } | |
| 1750 } | |
|
1168
0c7534002b0a
layout_image_setup_split_*(): move common code to a new function layout_image_setup_split_common().
zas_
parents:
1055
diff
changeset
|
1751 |
|
0c7534002b0a
layout_image_setup_split_*(): move common code to a new function layout_image_setup_split_common().
zas_
parents:
1055
diff
changeset
|
1752 if (!lw->image || lw->active_split_image < 0 || lw->active_split_image >= n) |
| 127 | 1753 { |
| 1659 | 1754 layout_image_activate(lw, 0, TRUE); |
| 127 | 1755 } |
| 1273 | 1756 else |
| 1757 { | |
| 1758 /* this will draw the frame around selected image (image_select) | |
| 1759 on switch from single to split images */ | |
| 1659 | 1760 layout_image_activate(lw, lw->active_split_image, TRUE); |
| 1273 | 1761 } |
|
1168
0c7534002b0a
layout_image_setup_split_*(): move common code to a new function layout_image_setup_split_common().
zas_
parents:
1055
diff
changeset
|
1762 } |
|
0c7534002b0a
layout_image_setup_split_*(): move common code to a new function layout_image_setup_split_common().
zas_
parents:
1055
diff
changeset
|
1763 |
|
1170
159f225985c5
Use common code for layout_image_setup_split_none() too.
zas_
parents:
1169
diff
changeset
|
1764 GtkWidget *layout_image_setup_split_none(LayoutWindow *lw) |
|
159f225985c5
Use common code for layout_image_setup_split_none() too.
zas_
parents:
1169
diff
changeset
|
1765 { |
|
159f225985c5
Use common code for layout_image_setup_split_none() too.
zas_
parents:
1169
diff
changeset
|
1766 lw->split_mode = SPLIT_NONE; |
|
159f225985c5
Use common code for layout_image_setup_split_none() too.
zas_
parents:
1169
diff
changeset
|
1767 |
|
159f225985c5
Use common code for layout_image_setup_split_none() too.
zas_
parents:
1169
diff
changeset
|
1768 layout_image_setup_split_common(lw, 1); |
|
159f225985c5
Use common code for layout_image_setup_split_none() too.
zas_
parents:
1169
diff
changeset
|
1769 |
|
159f225985c5
Use common code for layout_image_setup_split_none() too.
zas_
parents:
1169
diff
changeset
|
1770 lw->split_image_widget = lw->split_images[0]->widget; |
|
159f225985c5
Use common code for layout_image_setup_split_none() too.
zas_
parents:
1169
diff
changeset
|
1771 |
|
159f225985c5
Use common code for layout_image_setup_split_none() too.
zas_
parents:
1169
diff
changeset
|
1772 return lw->split_image_widget; |
|
159f225985c5
Use common code for layout_image_setup_split_none() too.
zas_
parents:
1169
diff
changeset
|
1773 } |
|
159f225985c5
Use common code for layout_image_setup_split_none() too.
zas_
parents:
1169
diff
changeset
|
1774 |
|
159f225985c5
Use common code for layout_image_setup_split_none() too.
zas_
parents:
1169
diff
changeset
|
1775 |
|
1168
0c7534002b0a
layout_image_setup_split_*(): move common code to a new function layout_image_setup_split_common().
zas_
parents:
1055
diff
changeset
|
1776 GtkWidget *layout_image_setup_split_hv(LayoutWindow *lw, gboolean horizontal) |
|
0c7534002b0a
layout_image_setup_split_*(): move common code to a new function layout_image_setup_split_common().
zas_
parents:
1055
diff
changeset
|
1777 { |
|
0c7534002b0a
layout_image_setup_split_*(): move common code to a new function layout_image_setup_split_common().
zas_
parents:
1055
diff
changeset
|
1778 GtkWidget *paned; |
|
0c7534002b0a
layout_image_setup_split_*(): move common code to a new function layout_image_setup_split_common().
zas_
parents:
1055
diff
changeset
|
1779 |
|
0c7534002b0a
layout_image_setup_split_*(): move common code to a new function layout_image_setup_split_common().
zas_
parents:
1055
diff
changeset
|
1780 lw->split_mode = horizontal ? SPLIT_HOR : SPLIT_VERT; |
|
0c7534002b0a
layout_image_setup_split_*(): move common code to a new function layout_image_setup_split_common().
zas_
parents:
1055
diff
changeset
|
1781 |
|
0c7534002b0a
layout_image_setup_split_*(): move common code to a new function layout_image_setup_split_common().
zas_
parents:
1055
diff
changeset
|
1782 layout_image_setup_split_common(lw, 2); |
|
0c7534002b0a
layout_image_setup_split_*(): move common code to a new function layout_image_setup_split_common().
zas_
parents:
1055
diff
changeset
|
1783 |
|
156
dd6dc0a55d3d
better integration of split image functions into menu
nadvornik
parents:
153
diff
changeset
|
1784 /* horizontal split means vpaned and vice versa */ |
| 127 | 1785 if (horizontal) |
|
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1786 paned = gtk_vpaned_new(); |
|
156
dd6dc0a55d3d
better integration of split image functions into menu
nadvornik
parents:
153
diff
changeset
|
1787 else |
|
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1788 paned = gtk_hpaned_new(); |
| 127 | 1789 |
|
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1790 gtk_paned_pack1(GTK_PANED(paned), lw->split_images[0]->widget, TRUE, TRUE); |
|
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1791 gtk_paned_pack2(GTK_PANED(paned), lw->split_images[1]->widget, TRUE, TRUE); |
| 442 | 1792 |
|
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1793 gtk_widget_show(lw->split_images[0]->widget); |
|
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1794 gtk_widget_show(lw->split_images[1]->widget); |
| 442 | 1795 |
| 127 | 1796 lw->split_image_widget = paned; |
| 442 | 1797 |
| 127 | 1798 return lw->split_image_widget; |
| 1799 | |
| 1800 } | |
| 1801 | |
| 1802 GtkWidget *layout_image_setup_split_quad(LayoutWindow *lw) | |
| 1803 { | |
| 1804 GtkWidget *hpaned; | |
| 1805 GtkWidget *vpaned1; | |
| 1806 GtkWidget *vpaned2; | |
| 1807 gint i; | |
| 442 | 1808 |
| 152 | 1809 lw->split_mode = SPLIT_QUAD; |
| 1810 | |
|
1168
0c7534002b0a
layout_image_setup_split_*(): move common code to a new function layout_image_setup_split_common().
zas_
parents:
1055
diff
changeset
|
1811 layout_image_setup_split_common(lw, 4); |
| 127 | 1812 |
|
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1813 hpaned = gtk_hpaned_new(); |
|
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1814 vpaned1 = gtk_vpaned_new(); |
|
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1815 vpaned2 = gtk_vpaned_new(); |
| 127 | 1816 |
|
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1817 gtk_paned_pack1(GTK_PANED(vpaned1), lw->split_images[0]->widget, TRUE, TRUE); |
|
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1818 gtk_paned_pack2(GTK_PANED(vpaned1), lw->split_images[2]->widget, TRUE, TRUE); |
| 127 | 1819 |
|
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1820 gtk_paned_pack1(GTK_PANED(vpaned2), lw->split_images[1]->widget, TRUE, TRUE); |
|
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1821 gtk_paned_pack2(GTK_PANED(vpaned2), lw->split_images[3]->widget, TRUE, TRUE); |
| 127 | 1822 |
|
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1823 gtk_paned_pack1(GTK_PANED(hpaned), vpaned1, TRUE, TRUE); |
|
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1824 gtk_paned_pack2(GTK_PANED(hpaned), vpaned2, TRUE, TRUE); |
| 127 | 1825 |
| 520 | 1826 for (i = 0; i < 4; i++) |
|
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1827 gtk_widget_show(lw->split_images[i]->widget); |
|
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1828 |
|
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1829 gtk_widget_show(vpaned1); |
|
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1830 gtk_widget_show(vpaned2); |
| 442 | 1831 |
| 127 | 1832 lw->split_image_widget = hpaned; |
| 442 | 1833 |
| 127 | 1834 return lw->split_image_widget; |
| 1835 | |
| 1836 } | |
| 1837 | |
| 1838 GtkWidget *layout_image_setup_split(LayoutWindow *lw, ImageSplitMode mode) | |
| 1839 { | |
| 1840 switch (mode) | |
| 1841 { | |
| 442 | 1842 case SPLIT_HOR: |
| 127 | 1843 return layout_image_setup_split_hv(lw, TRUE); |
| 1844 case SPLIT_VERT: | |
| 1845 return layout_image_setup_split_hv(lw, FALSE); | |
| 1846 case SPLIT_QUAD: | |
| 1847 return layout_image_setup_split_quad(lw); | |
| 1848 case SPLIT_NONE: | |
| 1849 default: | |
| 1850 return layout_image_setup_split_none(lw); | |
| 1851 } | |
| 1852 } | |
| 1853 | |
| 1854 | |
| 9 | 1855 /* |
| 1856 *----------------------------------------------------------------------------- | |
| 1857 * maintenance (for rename, move, remove) | |
| 1858 *----------------------------------------------------------------------------- | |
| 1859 */ | |
| 1860 | |
| 796 | 1861 static void layout_image_maint_renamed(LayoutWindow *lw, FileData *fd) |
| 9 | 1862 { |
| 1171 | 1863 if (fd == layout_image_get_fd(lw)) |
| 9 | 1864 { |
| 138 | 1865 image_set_fd(lw->image, fd); |
| 9 | 1866 } |
| 1867 } | |
| 1868 | |
| 796 | 1869 static void layout_image_maint_removed(LayoutWindow *lw, FileData *fd) |
| 9 | 1870 { |
| 1171 | 1871 if (fd == layout_image_get_fd(lw)) |
| 9 | 1872 { |
| 1873 CollectionData *cd; | |
| 1874 CollectInfo *info; | |
| 1875 | |
| 1876 cd = image_get_collection(lw->image, &info); | |
| 1877 if (cd && info) | |
| 1878 { | |
| 1879 CollectInfo *new; | |
| 1880 | |
| 1881 new = collection_next_by_info(cd, info); | |
| 1882 if (!new) new = collection_prev_by_info(cd, info); | |
| 1883 | |
| 1884 if (new) | |
| 1885 { | |
| 1886 layout_image_set_collection(lw, cd, new); | |
| 1887 return; | |
| 1888 } | |
| 1701 | 1889 layout_image_set_fd(lw, NULL); |
| 9 | 1890 } |
| 1701 | 1891 |
| 1892 /* the image will be set to the next image from the list soon, | |
| 1893 setting it to NULL here is not necessary*/ | |
| 9 | 1894 } |
| 1895 } | |
| 1896 | |
| 796 | 1897 |
| 1898 void layout_image_notify_cb(FileData *fd, NotifyType type, gpointer data) | |
| 9 | 1899 { |
| 796 | 1900 LayoutWindow *lw = data; |
| 1901 | |
| 1432 | 1902 if (!(type & NOTIFY_CHANGE) || !fd->change) return; |
| 1498 | 1903 |
| 1904 DEBUG_1("Notify layout_image: %s %04x", fd->path, type); | |
| 796 | 1905 |
|
1347
79937bc55f3a
Add missing space between switch and first parenthesis.
zas_
parents:
1336
diff
changeset
|
1906 switch (fd->change->type) |
| 796 | 1907 { |
| 1908 case FILEDATA_CHANGE_MOVE: | |
| 1909 case FILEDATA_CHANGE_RENAME: | |
| 1910 layout_image_maint_renamed(lw, fd); | |
| 1911 break; | |
| 1912 case FILEDATA_CHANGE_DELETE: | |
| 1913 layout_image_maint_removed(lw, fd); | |
| 1914 break; | |
| 1915 case FILEDATA_CHANGE_COPY: | |
| 1916 case FILEDATA_CHANGE_UNSPECIFIED: | |
| 1211 | 1917 case FILEDATA_CHANGE_WRITE_METADATA: |
| 796 | 1918 break; |
| 1919 } | |
| 1920 | |
| 9 | 1921 } |
|
1055
1646720364cf
Adding a vim modeline to all files - patch by Klaus Ethgen
nadvornik
parents:
1047
diff
changeset
|
1922 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ |
