void feh_menu_cb(feh_menu * m, feh_menu_item * i, int action, void *data) { char *path; Imlib_Image im; winwidget winwid; switch (action) { case CB_BG_TILED: path = feh_absolute_path(FEH_FILE(m->fehwin->file->data)->filename); feh_wm_set_bg(path, m->fehwin->im, 0, 0, 0, (int) data, 1); free(path); break; case CB_BG_SCALED: path = feh_absolute_path(FEH_FILE(m->fehwin->file->data)->filename); feh_wm_set_bg(path, m->fehwin->im, 0, 1, 0, (int) data, 1); free(path); break; case CB_BG_CENTERED: path = feh_absolute_path(FEH_FILE(m->fehwin->file->data)->filename); feh_wm_set_bg(path, m->fehwin->im, 1, 0, 0, (int) data, 1); free(path); break; case CB_BG_FILLED: path = feh_absolute_path(FEH_FILE(m->fehwin->file->data)->filename); feh_wm_set_bg(path, m->fehwin->im, 0, 0, 1, (int) data, 1); free(path); break; case CB_BG_TILED_NOFILE: feh_wm_set_bg(NULL, m->fehwin->im, 0, 0, 0, (int) data, 1); break; case CB_BG_SCALED_NOFILE: feh_wm_set_bg(NULL, m->fehwin->im, 0, 1, 0, (int) data, 1); break; case CB_BG_CENTERED_NOFILE: feh_wm_set_bg(NULL, m->fehwin->im, 1, 0, 0, (int) data, 1); break; case CB_BG_FILLED_NOFILE: feh_wm_set_bg(NULL, m->fehwin->im, 0, 0, 1, (int) data, 1); break; case CB_ABOUT: if (feh_load_image_char(&im, PREFIX "/share/feh/images/about.png") != 0) { winwid = winwidget_create_from_image(im, "About " PACKAGE, WIN_TYPE_ABOUT); winwid->file = gib_list_add_front(NULL, feh_file_new(PREFIX "/share/feh/images/about.png")); winwidget_show(winwid); } break; case CB_CLOSE: winwidget_destroy(m->fehwin); break; case CB_EXIT: winwidget_destroy_all(); break; case CB_RESET: if (m->fehwin->has_rotated) { m->fehwin->im_w = gib_imlib_image_get_width(m->fehwin->im); m->fehwin->im_h = gib_imlib_image_get_height(m->fehwin->im); winwidget_resize(m->fehwin, m->fehwin->im_w, m->fehwin->im_h); } winwidget_reset_image(m->fehwin); winwidget_render_image(m->fehwin, 1, 1); break; case CB_RELOAD: feh_reload_image(m->fehwin, 0, 0); break; case CB_REMOVE: feh_filelist_image_remove(m->fehwin, 0); break; case CB_DELETE: feh_filelist_image_remove(m->fehwin, 1); break; case CB_REMOVE_THUMB: feh_thumbnail_mark_removed(FEH_FILE(m->fehwin->file->data), 0); feh_filelist_image_remove(m->fehwin, 0); break; case CB_DELETE_THUMB: feh_thumbnail_mark_removed(FEH_FILE(m->fehwin->file->data), 1); feh_filelist_image_remove(m->fehwin, 1); break; case CB_SORT_FILENAME: filelist = gib_list_sort(filelist, feh_cmp_filename); if (opt.jump_on_resort) { slideshow_change_image(m->fehwin, SLIDE_FIRST); } break; case CB_SORT_IMAGENAME: filelist = gib_list_sort(filelist, feh_cmp_name); if (opt.jump_on_resort) { slideshow_change_image(m->fehwin, SLIDE_FIRST); } break; case CB_SORT_FILESIZE: filelist = gib_list_sort(filelist, feh_cmp_size); if (opt.jump_on_resort) { slideshow_change_image(m->fehwin, SLIDE_FIRST); } break; case CB_SORT_RANDOMIZE: filelist = gib_list_randomize(filelist); if (opt.jump_on_resort) { slideshow_change_image(m->fehwin, SLIDE_FIRST); } break; case CB_FIT: winwidget_size_to_image(m->fehwin); break; case CB_EDIT_ROTATE: feh_edit_inplace_orient(m->fehwin, (int) data); break; case CB_SAVE_IMAGE: slideshow_save_image(m->fehwin); break; case CB_SAVE_FILELIST: feh_save_filelist(); break; case CB_OPT_DRAW_FILENAME: MENU_ITEM_TOGGLE(i); if (MENU_ITEM_IS_ON(i)) opt.draw_filename = TRUE; else opt.draw_filename = FALSE; winwidget_rerender_all(0, 1); break; case CB_OPT_DRAW_ACTIONS: MENU_ITEM_TOGGLE(i); if (MENU_ITEM_IS_ON(i)) opt.draw_actions = TRUE; else opt.draw_actions = FALSE; winwidget_rerender_all(0, 1); break; case CB_OPT_KEEP_HTTP: MENU_ITEM_TOGGLE(i); if (MENU_ITEM_IS_ON(i)) opt.keep_http = TRUE; else opt.keep_http = FALSE; break; case CB_OPT_FREEZE_WINDOW: MENU_ITEM_TOGGLE(i); if (MENU_ITEM_IS_ON(i)) { opt.geom_flags = (WidthValue | HeightValue); opt.geom_w = m->fehwin->w; opt.geom_h = m->fehwin->h; } else { opt.geom_flags = 0; } break; case CB_OPT_FULLSCREEN: feh_menu_cb_opt_fullscreen(m, i); break; case CB_OPT_AUTO_ZOOM: MENU_ITEM_TOGGLE(i); if (MENU_ITEM_IS_ON(i)) opt.zoom_mode = ZOOM_MODE_FILL; else opt.zoom_mode = 0; winwidget_rerender_all(1, 1); break; } return; }
void feh_menu_cb(feh_menu * m, feh_menu_item * i, int action, unsigned short data) { char *path; switch (action) { case CB_BG_TILED: path = FEH_FILE(m->fehwin->file->data)->filename; feh_wm_set_bg(path, m->fehwin->im, 0, 0, 0, data, 0); break; case CB_BG_SCALED: path = FEH_FILE(m->fehwin->file->data)->filename; feh_wm_set_bg(path, m->fehwin->im, 0, 1, 0, data, 0); break; case CB_BG_CENTERED: path = FEH_FILE(m->fehwin->file->data)->filename; feh_wm_set_bg(path, m->fehwin->im, 1, 0, 0, data, 0); break; case CB_BG_FILLED: path = FEH_FILE(m->fehwin->file->data)->filename; feh_wm_set_bg(path, m->fehwin->im, 0, 0, 1, data, 0); break; case CB_BG_TILED_NOFILE: feh_wm_set_bg(NULL, m->fehwin->im, 0, 0, 0, data, 0); break; case CB_BG_SCALED_NOFILE: feh_wm_set_bg(NULL, m->fehwin->im, 0, 1, 0, data, 0); break; case CB_BG_CENTERED_NOFILE: feh_wm_set_bg(NULL, m->fehwin->im, 1, 0, 0, data, 0); break; case CB_BG_FILLED_NOFILE: feh_wm_set_bg(NULL, m->fehwin->im, 0, 0, 1, data, 0); break; case CB_CLOSE: winwidget_destroy(m->fehwin); break; case CB_EXIT: winwidget_destroy_all(); break; case CB_RESET: if (m->fehwin->has_rotated) { m->fehwin->im_w = gib_imlib_image_get_width(m->fehwin->im); m->fehwin->im_h = gib_imlib_image_get_height(m->fehwin->im); winwidget_resize(m->fehwin, m->fehwin->im_w, m->fehwin->im_h); } winwidget_reset_image(m->fehwin); winwidget_render_image(m->fehwin, 1, 0); break; case CB_RELOAD: feh_reload_image(m->fehwin, 0, 1); break; case CB_REMOVE: feh_filelist_image_remove(m->fehwin, 0); break; case CB_DELETE: feh_filelist_image_remove(m->fehwin, 1); break; case CB_REMOVE_THUMB: feh_thumbnail_mark_removed(FEH_FILE(m->fehwin->file->data), 0); feh_filelist_image_remove(m->fehwin, 0); break; case CB_DELETE_THUMB: feh_thumbnail_mark_removed(FEH_FILE(m->fehwin->file->data), 1); feh_filelist_image_remove(m->fehwin, 1); break; case CB_SORT_FILENAME: filelist = gib_list_sort(filelist, feh_cmp_filename); if (opt.jump_on_resort) { slideshow_change_image(m->fehwin, SLIDE_FIRST, 1); } break; case CB_SORT_IMAGENAME: filelist = gib_list_sort(filelist, feh_cmp_name); if (opt.jump_on_resort) { slideshow_change_image(m->fehwin, SLIDE_FIRST, 1); } break; case CB_SORT_FILESIZE: filelist = gib_list_sort(filelist, feh_cmp_size); if (opt.jump_on_resort) { slideshow_change_image(m->fehwin, SLIDE_FIRST, 1); } break; case CB_SORT_RANDOMIZE: filelist = gib_list_randomize(filelist); if (opt.jump_on_resort) { slideshow_change_image(m->fehwin, SLIDE_FIRST, 1); } break; case CB_FIT: winwidget_size_to_image(m->fehwin); break; case CB_EDIT_ROTATE: feh_edit_inplace(m->fehwin, data); break; case CB_SAVE_IMAGE: slideshow_save_image(m->fehwin); break; case CB_SAVE_FILELIST: feh_save_filelist(); break; case CB_OPT_DRAW_FILENAME: MENU_ITEM_TOGGLE(i); if (MENU_ITEM_IS_ON(i)) opt.draw_filename = TRUE; else opt.draw_filename = FALSE; winwidget_rerender_all(0); break; case CB_OPT_DRAW_ACTIONS: MENU_ITEM_TOGGLE(i); if (MENU_ITEM_IS_ON(i)) opt.draw_actions = TRUE; else opt.draw_actions = FALSE; winwidget_rerender_all(0); break; case CB_OPT_KEEP_HTTP: MENU_ITEM_TOGGLE(i); if (MENU_ITEM_IS_ON(i)) opt.keep_http = TRUE; else opt.keep_http = FALSE; break; case CB_OPT_FREEZE_WINDOW: MENU_ITEM_TOGGLE(i); if (MENU_ITEM_IS_ON(i)) { opt.geom_flags = (WidthValue | HeightValue); opt.geom_w = m->fehwin->w; opt.geom_h = m->fehwin->h; } else { opt.geom_flags = 0; } break; case CB_OPT_FULLSCREEN: feh_menu_cb_opt_fullscreen(m, i); break; case CB_OPT_AUTO_ZOOM: MENU_ITEM_TOGGLE(i); if (MENU_ITEM_IS_ON(i)) opt.zoom_mode = ZOOM_MODE_MAX; else opt.zoom_mode = 0; winwidget_rerender_all(1); break; case CB_OPT_KEEP_ZOOM_VP: MENU_ITEM_TOGGLE(i); if (MENU_ITEM_IS_ON(i)) opt.keep_zoom_vp = 1; else opt.keep_zoom_vp = 0; break; } return; }