void onButtonClicked(GtkWidget* widget, gpointer* data) { if (GTK_IS_BUILDER(data)) { GtkBuilder* builder = GTK_BUILDER(data); GtkWidget* window = GTK_WIDGET(gtk_builder_get_object(builder, "mainWindow")); if (exit_confirm(GTK_WIDGET(window))) { onDestoryed(widget, data); } } }
static t_win_menu_op scene_imgkey_menucb(dword key, p_win_menuitem item, dword * count, dword max_height, dword * topindex, dword * index) { dword key1, key2; SceCtrlData ctl; int i; switch (key) { case (PSP_CTRL_SELECT | PSP_CTRL_START): return exit_confirm(); case PSP_CTRL_CIRCLE: disp_duptocache(); disp_waitv(); prompt_press_any_key(); disp_flip(); ctrl_waitrelease(); do { xrCtrlReadBufferPositive(&ctl, 1); key1 = (ctl.Buttons & ~PSP_CTRL_SELECT) & ~PSP_CTRL_START; } while (key1 == 0); key2 = key1; while ((key2 & key1) == key1) { key1 = key2; xrCtrlReadBufferPositive(&ctl, 1); key2 = (ctl.Buttons & ~PSP_CTRL_SELECT) & ~PSP_CTRL_START; } if (config.imgkey[*index] == key1 || config.imgkey2[*index] == key1) return win_menu_op_force_redraw; for (i = 0; i < NELEMS(config.imgkey); i++) { if (i == *index) continue; if (config.imgkey[i] == key1) { config.imgkey[i] = config.imgkey2[*index]; if (config.imgkey[i] == 0) { config.imgkey[i] = config.imgkey2[i]; config.imgkey2[i] = 0; } break; } if (config.imgkey2[i] == key1) { config.imgkey2[i] = config.imgkey2[*index]; break; } } config.imgkey2[*index] = config.imgkey[*index]; config.imgkey[*index] = key1; do { xrCtrlReadBufferPositive(&ctl, 1); } while (ctl.Buttons != 0); return win_menu_op_force_redraw; case PSP_CTRL_TRIANGLE: config.imgkey[*index] = config.imgkey2[*index]; config.imgkey2[*index] = 0; return win_menu_op_redraw; case PSP_CTRL_SQUARE: return win_menu_op_cancel; default:; } return win_menu_defcb(key, item, count, max_height, topindex, index); }
static int image_handle_input(dword * selidx, dword key) { slideshow_move = false; #ifdef ENABLE_ANALOG if (config.img_enable_analog) { int x, y, orgtop = curtop, orgleft = curleft; if (ctrl_analog(&x, &y)) { slideshow_move = true; x = x / 31 * (int) config.imgmvspd / 2; y = y / 31 * (int) config.imgmvspd / 2; curtop += y; if (curtop + imgh > height_rotated) curtop = (int) height_rotated - imgh; if (curtop < 0) curtop = 0; curleft += x; if (curleft + PSP_SCREEN_WIDTH > width_rotated) curleft = (int) width_rotated - PSP_SCREEN_WIDTH; if (curleft < 0) curleft = 0; thumb = (config.thumb == conf_thumb_scroll); img_needrp = (thumb || orgtop != curtop || orgleft != curleft); } } #endif if (key == 0) goto next; if (!slideshow || (key != CTRL_FORWARD && key != 0)) secticks = 0; if (key == (PSP_CTRL_SELECT | PSP_CTRL_START)) { return exit_confirm(); } else if (key == PSP_CTRL_SELECT) { bool lastbicubic = config.bicubic; img_needrp = true; if (scene_options(selidx)) { imgreading = false; reset_image_ptr(); return *selidx; } if (lastbicubic != config.bicubic) img_needrc = true; if (config.imginfobar) imgh = PSP_SCREEN_HEIGHT - DISP_FONTSIZE; else imgh = PSP_SCREEN_HEIGHT; } else if (key == PSP_CTRL_START) { scene_mp3bar(); img_needrp = true; } else if (key == config.imgkey[1] || key == config.imgkey2[1] || key == CTRL_FORWARD) { bool should_exit = false; if (config.imgpaging == conf_imgpaging_updown || config.imgpaging == conf_imgpaging_leftright) xrKernelDelayThread(200000); if (!image_paging(true, config.imgpaging)) goto next; next_image(selidx, &should_exit); if (should_exit) { return *selidx; } } else if (key == config.imgkey[0] || key == config.imgkey2[0] || key == CTRL_BACK) { if (config.imgpaging == conf_imgpaging_updown || config.imgpaging == conf_imgpaging_leftright) xrKernelDelayThread(200000); if (!image_paging(false, config.imgpaging)) goto next; prev_image(selidx); } else if (key == config.imgkey[2] || key == config.imgkey2[2]) { ctrl_waitrelease(); if (config.fit == conf_fit_custom) config.fit = conf_fit_none; else config.fit++; img_needrc = img_needrp = true; } else if (key == config.imgkey[10] || key == config.imgkey2[10]) { config.bicubic = !config.bicubic; img_needrc = img_needrp = true; } else if (key == config.imgkey[11] || key == config.imgkey2[11]) { if (!slideshow) { slideshow = true; lasttime = time(NULL); ctrl_waitrelease(); } else { slideshow = false; win_msg(_("幻灯片播放已经停止!"), COLOR_WHITE, COLOR_WHITE, config.msgbcolor); ctrl_waitrelease(); } } else if (key == config.imgkey[7] || key == config.imgkey2[7]) { SceCtrlData ctl; int t = 0; config.imginfobar = !config.imginfobar; if (config.imginfobar) imgh = PSP_SCREEN_HEIGHT - DISP_FONTSIZE; else imgh = PSP_SCREEN_HEIGHT; if (height_rotated > imgh && curtop > height_rotated - imgh) curtop = height_rotated - imgh; img_needrc = (config.fit == conf_fit_height); img_needrp = true; do { xrCtrlReadBufferPositive(&ctl, 1); xrKernelDelayThread(10000); t += 10000; } while (ctl.Buttons != 0 && t <= 500000); } else if (key == config.imgkey[9] || key == config.imgkey2[9] || key == CTRL_PLAYPAUSE) { if (slideshow) { slideshow = false; win_msg(_("幻灯片播放已经停止!"), COLOR_WHITE, COLOR_WHITE, config.msgbcolor); ctrl_waitrelease(); } else { imgreading = false; reset_image_ptr(); return *selidx; } } else if (key == config.imgkey[8] || key == config.imgkey2[8]) { if (!slideshow && !showinfo) { img_needrp = true; showinfo = true; } } else if (key == config.imgkey[5] || key == config.imgkey2[5]) { if (config.rotate == conf_rotate_0) config.rotate = conf_rotate_270; else config.rotate--; ctrl_waitreleasekey(key); img_needrc = img_needrp = true; } else if (key == config.imgkey[6] || key == config.imgkey2[6]) { if (config.rotate == conf_rotate_270) config.rotate = conf_rotate_0; else config.rotate++; ctrl_waitreleasekey(key); img_needrc = img_needrp = true; } else if (key == config.imgkey[3] || key == config.imgkey2[3]) { if (config.scale > 200) config.scale -= 50; else if (config.scale > 10) config.scale -= 5; else goto next; config.fit = conf_fit_custom; img_needrc = img_needrp = true; ctrl_waitreleasekey(key); } else if (key == config.imgkey[4] || key == config.imgkey2[4]) { if (config.scale < 200) config.scale += 5; else if (config.scale < 1000) config.scale += 50; else goto next; config.fit = conf_fit_custom; img_needrc = img_needrp = true; ctrl_waitreleasekey(key); } else if (key & (config.imgkey[12] | config.imgkey[13] | config. imgkey[14] | config.imgkey[15] | config.imgkey2[12] | config. imgkey2[13] | config.imgkey2[14] | config.imgkey2[15]) && !(key & ~(config.imgkey[12] | config.imgkey[13] | config. imgkey[14] | config.imgkey[15] | config. imgkey2[12] | config.imgkey2[13] | config. imgkey2[14] | config.imgkey2[15] ))) { slideshow_move = true; image_move(key); } else img_needrf = img_needrc = false; next: return -1; }
gboolean onWindowDeleteEvent (GtkWidget *widget, GdkEvent *event, gpointer user_data) { g_return_val_if_fail(GTK_IS_BUILDER(user_data), FALSE); GtkBuilder* builder = GTK_BUILDER(user_data); GtkWidget* window = GTK_WIDGET(gtk_builder_get_object(builder, "mainWindow")); return !exit_confirm(GTK_WIDGET(window)); }