📄 layout_image.c
字号:
* misc *---------------------------------------------------------------------------- */void layout_image_to_root(LayoutWindow *lw){ image_to_root_window(lw->image, (image_zoom_get(lw->image) == 0));}/* *---------------------------------------------------------------------------- * manipulation + accessors *---------------------------------------------------------------------------- */void layout_image_scroll(LayoutWindow *lw, gint x, gint y){ if (!layout_valid(&lw)) return; image_scroll(lw->image, x, y);}void layout_image_zoom_adjust(LayoutWindow *lw, gdouble increment){ if (!layout_valid(&lw)) return; image_zoom_adjust(lw->image, increment);}void layout_image_zoom_set(LayoutWindow *lw, gdouble zoom){ if (!layout_valid(&lw)) return; image_zoom_set(lw->image, zoom);}void layout_image_zoom_set_fill_geometry(LayoutWindow *lw, gint vertical){ if (!layout_valid(&lw)) return; image_zoom_set_fill_geometry(lw->image, vertical);}void layout_image_alter(LayoutWindow *lw, AlterType type){ if (!layout_valid(&lw)) return; image_alter(lw->image, type);}const gchar *layout_image_get_path(LayoutWindow *lw){ if (!layout_valid(&lw)) return NULL; return image_get_path(lw->image);}const gchar *layout_image_get_name(LayoutWindow *lw){ if (!layout_valid(&lw)) return NULL; return image_get_name(lw->image);}CollectionData *layout_image_get_collection(LayoutWindow *lw, CollectInfo **info){ if (!layout_valid(&lw)) return NULL; return image_get_collection(lw->image, info);}gint layout_image_get_index(LayoutWindow *lw){ return layout_list_get_index(lw, image_get_path(lw->image));}/* *---------------------------------------------------------------------------- * image changers *---------------------------------------------------------------------------- */void layout_image_set_path(LayoutWindow *lw, const gchar *path){ if (!layout_valid(&lw)) return; image_change_path(lw->image, path, image_zoom_get_default(lw->image, zoom_mode)); layout_list_sync_path(lw, path); layout_image_slideshow_continue_check(lw); layout_bars_new_image(lw);}void layout_image_set_with_ahead(LayoutWindow *lw, const gchar *path, const gchar *read_ahead_path){ if (!layout_valid(&lw)) return; if (path) { const gchar *old_path; old_path = layout_image_get_path(lw); if (old_path && strcmp(path, old_path) == 0) return; } layout_image_set_path(lw, path); if (enable_read_ahead) image_prebuffer_set(lw->image, read_ahead_path);}void layout_image_set_index(LayoutWindow *lw, gint index){ const gchar *path; const gchar *read_ahead_path; gint old; if (!layout_valid(&lw)) return; old = layout_list_get_index(lw, layout_image_get_path(lw)); path = layout_list_get_path(lw, index); if (old > index) { read_ahead_path = layout_list_get_path(lw, index - 1); } else { read_ahead_path = layout_list_get_path(lw, index + 1); } layout_image_set_with_ahead(lw, path, read_ahead_path);}static void layout_image_set_collection_real(LayoutWindow *lw, CollectionData *cd, CollectInfo *info, gint forward){ if (!layout_valid(&lw)) return; image_change_from_collection(lw->image, cd, info, image_zoom_get_default(lw->image, zoom_mode)); if (enable_read_ahead) { CollectInfo *r_info; if (forward) { r_info = collection_next_by_info(cd, info); if (!r_info) r_info = collection_prev_by_info(cd, info); } else { r_info = collection_prev_by_info(cd, info); if (!r_info) r_info = collection_next_by_info(cd, info); } if (r_info) image_prebuffer_set(lw->image, r_info->path); } layout_image_slideshow_continue_check(lw); layout_bars_new_image(lw);}void layout_image_set_collection(LayoutWindow *lw, CollectionData *cd, CollectInfo *info){ layout_image_set_collection_real(lw, cd, info, TRUE); layout_list_sync_path(lw, layout_image_get_path(lw));}void layout_image_refresh(LayoutWindow *lw){ if (!layout_valid(&lw)) return; image_reload(lw->image);}/* *---------------------------------------------------------------------------- * list walkers *---------------------------------------------------------------------------- */void layout_image_next(LayoutWindow *lw){ gint current; CollectionData *cd; CollectInfo *info; if (!layout_valid(&lw)) return; if (layout_image_slideshow_active(lw)) { layout_image_slideshow_next(lw); return; } cd = image_get_collection(lw->image, &info); if (cd && info) { info = collection_next_by_info(cd, info); if (info) layout_image_set_collection_real(lw, cd, info, TRUE); return; } current = layout_image_get_index(lw); if (current >= 0) { if (current < layout_list_count(lw, NULL) - 1) { layout_image_set_index(lw, current + 1); } } else { layout_image_set_index(lw, 0); }}void layout_image_prev(LayoutWindow *lw){ gint current; CollectionData *cd; CollectInfo *info; if (!layout_valid(&lw)) return; if (layout_image_slideshow_active(lw)) { layout_image_slideshow_prev(lw); return; } cd = image_get_collection(lw->image, &info); if (cd && info) { info = collection_prev_by_info(cd, info); if (info) layout_image_set_collection_real(lw, cd, info, FALSE); return; } current = layout_image_get_index(lw); if (current >= 0) { if (current > 0) { layout_image_set_index(lw, current - 1); } } else { layout_image_set_index(lw, layout_list_count(lw, NULL) - 1); }}void layout_image_first(LayoutWindow *lw){ gint current; CollectionData *cd; CollectInfo *info; if (!layout_valid(&lw)) return; cd = image_get_collection(lw->image, &info); if (cd && info) { CollectInfo *new; new = collection_get_first(cd); if (new != info) layout_image_set_collection_real(lw, cd, new, TRUE); return; } current = layout_image_get_index(lw); if (current != 0 && layout_list_count(lw, NULL) > 0) { layout_image_set_index(lw, 0); }}void layout_image_last(LayoutWindow *lw){ gint current; gint count; CollectionData *cd; CollectInfo *info; if (!layout_valid(&lw)) return; cd = image_get_collection(lw->image, &info); if (cd && info) { CollectInfo *new; new = collection_get_last(cd); if (new != info) layout_image_set_collection_real(lw, cd, new, FALSE); return; } current = layout_image_get_index(lw); count = layout_list_count(lw, NULL); if (current != count - 1 && count > 0) { layout_image_set_index(lw, count - 1); }}/* *---------------------------------------------------------------------------- * mouse callbacks *---------------------------------------------------------------------------- */static void layout_image_button_cb(ImageWindow *imd, gint button, guint32 time, gdouble x, gdouble y, guint state, gpointer data){ LayoutWindow *lw = data; GtkWidget *menu; switch (button) { case 1: layout_image_next(lw); break; case 2: layout_image_prev(lw); break; case 3: menu = layout_image_pop_menu(lw); if (imd == lw->image) { g_object_set_data(G_OBJECT(menu), "click_parent", imd->widget); } gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 3, time); break; default: break; }}static void layout_image_scroll_cb(ImageWindow *imd, GdkScrollDirection direction, guint32 time, gdouble x, gdouble y, guint state, gpointer data){ LayoutWindow *lw = data; if (state & GDK_CONTROL_MASK) { switch (direction) { case GDK_SCROLL_UP: image_zoom_adjust_at_point(imd, get_zoom_increment(), x, y); break; case GDK_SCROLL_DOWN: image_zoom_adjust_at_point(imd, -get_zoom_increment(), x, y); break; default: break; } } else if ( (state & GDK_SHIFT_MASK) != (mousewheel_scrolls)) { switch (direction) { case GDK_SCROLL_UP: image_scroll(imd, 0, -MOUSEWHEEL_SCROLL_SIZE); break; case GDK_SCROLL_DOWN: image_scroll(imd, 0, MOUSEWHEEL_SCROLL_SIZE); break; case GDK_SCROLL_LEFT: image_scroll(imd, -MOUSEWHEEL_SCROLL_SIZE, 0); break; case GDK_SCROLL_RIGHT: image_scroll(imd, MOUSEWHEEL_SCROLL_SIZE, 0); break; default: break; } } else { switch (direction) { case GDK_SCROLL_UP: layout_image_prev(lw); break; case GDK_SCROLL_DOWN: layout_image_next(lw); break; default: break; } }}static void layout_image_set_buttons(LayoutWindow *lw){ image_set_button_func(lw->image, layout_image_button_cb, lw); image_set_scroll_func(lw->image, layout_image_scroll_cb, lw);}/* *---------------------------------------------------------------------------- * setup *---------------------------------------------------------------------------- */static void layout_image_update_cb(ImageWindow *imd, gpointer data){ LayoutWindow *lw = data; layout_status_update_image(lw);}GtkWidget *layout_image_new(LayoutWindow *lw, const gchar *path){ if (!lw->image) { lw->image = image_new( (!lw->tools_float && !lw->tools_hidden) ); if (black_window_background) image_background_set_black(lw->image, TRUE); image_set_update_func(lw->image, layout_image_update_cb, lw); layout_image_set_buttons(lw); layout_image_dnd_init(lw); image_attach_window(lw->image, lw->window, NULL, "GQview", FALSE); image_auto_refresh(lw->image, 0); } return lw->image->widget;}/* *----------------------------------------------------------------------------- * maintenance (for rename, move, remove) *----------------------------------------------------------------------------- */void layout_image_maint_renamed(LayoutWindow *lw, const gchar *source, const gchar *dest){ const gchar *img_path; img_path = layout_image_get_path(lw); if (img_path && strcmp(img_path, source) == 0) { image_set_path(lw->image, dest); layout_bars_maint_renamed(lw); }}void layout_image_maint_removed(LayoutWindow *lw, const gchar *path){ const gchar *img_path; img_path = layout_image_get_path(lw); if (img_path && strcmp(img_path, path) == 0) { CollectionData *cd; CollectInfo *info; cd = image_get_collection(lw->image, &info); if (cd && info) { CollectInfo *new; new = collection_next_by_info(cd, info); if (!new) new = collection_prev_by_info(cd, info); if (new) { layout_image_set_collection(lw, cd, new); return; } } layout_image_set_path(lw, NULL); }}void layout_image_maint_moved(LayoutWindow *lw, const gchar *source, const gchar *dest){ layout_image_maint_renamed(lw, source, dest);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -