TWindow * mystify_new_window() { TWindow *win; TWidget *wid; win = ttk_new_window(); win->title="Mystify"; wid = ttk_new_widget(0,0); wid->w = ttk_screen->w; wid->h = ttk_screen->h - ttk_screen->wy; wid->draw = mystify_draw; wid->down = mystify_down; wid->button = mystify_button; wid->scroll = mystify_scroll; wid->timer = mystify_timer; wid->focusable = 1; mystify_init(); ttk_widget_set_timer(wid, sleep_time); ttk_add_widget(win, wid); ttk_window_hide_header(win); ttk_show_window(win); }
void pz_modules_init(char *path) { #ifdef IPOD #define MODULEDIR "/opt/Base:/opt/Emulators:/opt/Media:/opt/Tools:/opt/Zillae" #else #define MODULEDIR "modules" #endif /* Used for the progress bar */ TWindow * sliderwin; TWidget * slider; int sliderVal=0; int verbosity = pz_get_int_setting( pz_global_config, VERBOSITY ); #define MAXSLIDERVAL (100) #define SETUPSECTIONS (6) PzModule *last, *cur; int i; int modCount=0; if (module_head) { pz_error (_("modules_init called more than once")); return; } /* set up the screen to show a pretty progress bar */ sliderwin = ttk_new_window(); ttk_window_hide_header(sliderwin); sliderwin->x = sliderwin->y = 0; slider = ttk_new_slider_widget(2, ttk_screen->h/3, ttk_screen->w - 8, 0, MAXSLIDERVAL, &sliderVal, 0); slider->x = (sliderwin->w - slider->w)/2; ttk_add_widget(sliderwin, slider); sliderVal = (MAXSLIDERVAL/SETUPSECTIONS) * 1; updateprogress(sliderwin, slider, sliderVal, _("Scanning For Modules"), NULL); if (!path) path = MODULEDIR; path = strtok(strdupa(path), ":"); while (path) { find_modules (path); path = strtok(NULL, ":"); } sliderVal = (MAXSLIDERVAL/SETUPSECTIONS) * 2; updateprogress(sliderwin, slider, sliderVal, _("Reading Modules"), NULL); for (i = 0; i < __pz_builtin_number_of_init_functions; i++) { int found = 0; const char *name = __pz_builtin_names[i]; cur = module_head; while (cur) { char *p = strrchr (cur->podpath, '/'); if (!p) p = cur->podpath; else p++; if (!strncmp (p, name, strlen (name)) && !isalpha (p[strlen (name)])) { found = 1; break; } cur = cur->next; } if (!found) { if (module_head) { cur = module_head; while (cur->next) cur = cur->next; cur->next = calloc (1, sizeof(PzModule)); cur = cur->next; } else { cur = module_head = calloc (1, sizeof(PzModule)); } cur->podpath = 0; cur->name = strdup (__pz_builtin_names[i]); cur->init = __pz_builtin_init_functions[i]; cur->to_load = -1; cur->ordered = 0; cur->next = 0; } } if (!module_head) { pz_message_title (_("Warning"), _("No modules. podzilla will probably be very boring.")); return; } /* Used to initialize the window + progressbar used in loading the modules*/ cur = module_head; while (cur) { modCount++; cur = cur->next; } sliderVal = (MAXSLIDERVAL/SETUPSECTIONS) * 3; updateprogress(sliderwin, slider, sliderVal, _("Mounting Modules"), NULL); // Mount 'em cur = module_head; last = 0; while (cur) { if (cur->podpath && cur->extracted) { cur->mountpt = strdup (cur->podpath); last = cur; cur = cur->next; } else if (cur->podpath && mount_pod (cur) == -1) { if (last) last->next = cur->next; else module_head = cur->next; free (cur->podpath); free (cur); cur = last? last->next : module_head; } else { last = cur; cur = cur->next; } } sliderVal = (MAXSLIDERVAL/SETUPSECTIONS) * 4; updateprogress(sliderwin, slider, sliderVal, _("Scanning Module Info"), NULL); // Load the module.inf's cur = module_head; while (cur) { load_modinf (cur); cur = cur->next; } sliderVal = (MAXSLIDERVAL/SETUPSECTIONS) * 5; updateprogress(sliderwin, slider, sliderVal, _("Module Dependencies"), NULL); // Figure out the dependencies cur = module_head; last = 0; while (cur) { if (fix_dependencies (cur, 1, SOFTDEP) == -1 || fix_dependencies(cur, 1, HARDDEP) == -1) { if (last) last->next = cur->next; else module_head = cur->next; free_module (cur); cur = last? last->next : module_head; } else { last = cur; cur = cur->next; } } // Check which ones are linked in cur = module_head; last = 0; while (cur) { for (i = 0; i < __pz_builtin_number_of_init_functions; i++) { if (!strcmp (__pz_builtin_names[i], cur->name)) { cur->init = __pz_builtin_init_functions[i]; cur->to_load = -1; cur->ordered = 0; } } cur = cur->next; } // XXX. For now, we use a slow method for deps, and it'll crash // for circular deps. davidc__ is working on a // better solution. cur = module_head; while (cur) { add_deps (cur); cur = cur->next; } sliderVal = (MAXSLIDERVAL/SETUPSECTIONS) * 6; updateprogress(sliderwin, slider, sliderVal, _("Loading Modules"), NULL); struct dep *c = load_order; while (c) { if (c->mod->to_load > 0) { do_load (c->mod); } if( verbosity < VERBOSITY_ERRORS && c->mod->longname ) { updateprogress(sliderwin, slider, sliderVal, _("Loading Modules"), c->mod->longname ); } c = c->next; } c = load_order; sliderVal = 0; updateprogress(sliderwin, slider, sliderVal, _("Initializing Modules"), NULL); /* trigger the sliders to switch to init mode, restting the slider */ sliderVal = 0; /* initialize the modules */ while (c) { sliderVal += MAXSLIDERVAL / modCount; current_module = c->mod; updateprogress(sliderwin, slider, sliderVal, _("Initializing Modules"), (verbosity < 2)? c->mod->longname : NULL ); do_init (c->mod); c = c->next; } sliderVal = MAXSLIDERVAL; updateprogress(sliderwin, slider, sliderVal, _("Finishing Up..."), NULL); // Any modules with unrecoverable errors on loading set mod->to_free. // Oblige them. cur = module_head; last = 0; while (cur) { if (cur->to_free) { if (last) last->next = cur->next; else module_head = cur->next; free_module (cur); cur = last? last->next : module_head; } else { last = cur; cur = cur->next; } } ttk_free_window (sliderwin); }
int event_truchet( PzEvent *ev ) { switch (ev->type) { case PZ_EVENT_SCROLL: if( ev->arg > 0 ) { } else { } break; case PZ_EVENT_BUTTON_DOWN: switch( ev->arg ) { case( PZ_BUTTON_HOLD ): tglob.fullscreen = 1; ttk_window_hide_header( tglob.window ); tglob.w = tglob.window->w; tglob.h = tglob.window->h; ev->wid->dirty = 1; default: break; } break; case PZ_EVENT_BUTTON_UP: switch( ev->arg ) { case( PZ_BUTTON_MENU ): pz_set_priority(PZ_PRIORITY_IDLE); pz_close_window (ev->wid->win); break; case( PZ_BUTTON_HOLD ): tglob.fullscreen = 0; ttk_window_show_header( tglob.window ); tglob.w = tglob.window->w; tglob.h = tglob.window->h; ev->wid->dirty = 1; break; case( PZ_BUTTON_PLAY ): break; case( PZ_BUTTON_ACTION ): if( !tglob.fullscreen ) tglob.clicks++; ev->wid->dirty = 1; break; default: break; } break; case PZ_EVENT_DESTROY: cleanup_truchet(); break; case PZ_EVENT_TIMER: twiddle_buffer(); ev->wid->dirty = 1; tglob.timer++; break; default: break; } return 0; }