static int mystify_down(TWidget *wid, int button) { switch(button){ case TTK_BUTTON_MENU: ttk_hide_window(wid->win); break; case TTK_BUTTON_NEXT: if(nb_polygons < MAX_POLYGONS) ++nb_polygons; wid->dirty++; break; case TTK_BUTTON_PREVIOUS: if(nb_polygons > MIN_POLYGONS) --nb_polygons; wid->dirty++; break; case TTK_BUTTON_ACTION: aa = !aa; break; case TTK_BUTTON_HOLD: paused = 1; break; case TTK_BUTTON_PLAY: default: return TTK_EV_UNUSED; break; } return TTK_EV_CLICK; }
static TWindow *browser_do_delete (ttk_menu_item *item) { #define PATHSIZ 512 struct stat st; const char *filename = item->data; if (stat (filename, &st) < 0) { pz_perror (filename); return TTK_MENU_UPONE; } if (S_ISDIR (st.st_mode)) { /* we change the current directory here in order to find the * absolute path of the specified directory with getcwd. this * removes the need to check for references to the parent * directory or follow along a path until we find the end * result. in addition, opening the current directory and using * its file descriptor to return to it is faster than storing * its path */ if (filename[0]) { int fd; char full_path[PATHSIZ]; if ((fd = open(".", O_RDONLY)) == -1) return TTK_MENU_UPONE; chdir(filename); getcwd(full_path, PATHSIZ); fchdir(fd); close(fd); if (full_path[0] && full_path[1] && strchr(full_path + 2, '/')) rm_rf (filename); // not "" or "/" or a root dir else pz_error (_("Dangerous rm -rf aborted.\n")); } } else { unlink (filename); } /* hide the top two windows */ if (ttk_hide_window (ttk_windows->w) != -1 && ttk_hide_window (ttk_windows->w) != -1) { /* -ttk_windows->w->widgets->v- is the top window's menu */ ttk_menu_remove_by_ptr(ttk_windows->w->widgets->v, ttk_menu_get_selected_item(ttk_windows->w->widgets->v)); } else { pz_error("Unable to close windows"); } return TTK_MENU_DONOTHING; /* we are now back at the directory */ }