Ejemplo n.º 1
0
TWidget *pz_browser_get_actions (const char *path)
{
    struct stat st;
    browser_action *cur = action_head;
    TWidget *ret = ttk_new_menu_widget (empty_menu, ttk_menufont, ttk_screen->w - ttk_screen->wx,
					ttk_screen->h - ttk_screen->wy);
    // add default handlers XXX
    empty_menu[1].data = empty_menu[2].data = empty_menu[3].data = empty_menu[4].data = strdup((char *)path);
    empty_menu[1].free_data = 1;
    if (stat (path, &st) >= 0) {
	if (st.st_mode & S_IFDIR) {
	    ttk_menu_append (ret, empty_menu + 1);
	} else if (!S_ISBLK(st.st_mode) && !S_ISCHR(st.st_mode)) {
	    if (st.st_mode & S_IXUSR) {
	    	ttk_menu_append (ret, empty_menu + 2);
	    }
	    ttk_menu_append (ret, empty_menu + 3);
	    if (is_ascii_file(path)) {
		ttk_menu_append (ret, empty_menu + 4);
	    }
	}
    }
    while (cur) {
	if (cur->pred && (*(cur->pred))(path)) {
	    cur->action->data = strdup((char *)path);
	    cur->action->free_data = 1;
	    ttk_menu_append (ret, cur->action);
	}
	cur = cur->next;
    }
    return ret;
}
Ejemplo n.º 2
0
static TWidget *populate_playlists()
{
	mpd_InfoEntity entity;
	TWidget *ret;
	
	if (mpdc_tickle() < 0)
		return NULL;

	ret = ttk_new_menu_widget(NULL, ttk_menufont,
			ttk_screen->w - ttk_screen->wx,
			ttk_screen->h - ttk_screen->wy);

	mpd_sendLsInfoCommand(mpdz, "");

	while ((mpd_getNextInfoEntity_st(&entity, mpdz))) {
		mpd_PlaylistFile *playlist;
		ttk_menu_item *item;
		if (entity.type != MPD_INFO_ENTITY_TYPE_PLAYLISTFILE) {
			continue;
		}
		playlist = entity.info.playlistFile;
		item = (ttk_menu_item *)calloc(1, sizeof(ttk_menu_item));
		item->name = (char *)strdup(playlist->path);
		item->free_name = 1;
		item->makesub = open_playlist;

		ttk_menu_append(ret, item);
	}
	ttk_menu_set_i18nable(ret, 0);

	mpd_finishCommand(mpdz);
	return ret;
}
Ejemplo n.º 3
0
struct menulist *new_ml()
{
	struct menulist *ret =
		(struct menulist *) malloc(sizeof(struct menulist));
		
	GrGetScreenInfo(&ret->screen_info);

	ret->gc = pz_get_gc(1);
	GrSetGCUseBackground(ret->gc, GR_FALSE);
	GrSetGCForeground(ret->gc, BLACK);
	GrSetGCBackground(ret->gc, BLACK);

	ret->wid = pz_new_window(0, HEADER_TOPLINE + 1, ret->screen_info.cols,
			ret->screen_info.rows - (HEADER_TOPLINE + 1),
			itunes_do_draw, itunes_do_keystroke);

	GrSelectEvents(ret->wid, GR_EVENT_MASK_EXPOSURE|GR_EVENT_MASK_KEY_DOWN|GR_EVENT_MASK_KEY_UP|GR_EVENT_MASK_TIMER);

	GrGetGCTextSize(ret->gc, "M", -1, GR_TFASCII, &ret->gr_width,
			&ret->gr_height, &ret->gr_base);

	ret->gr_height += 4;

	GrMapWindow(ret->wid);
	ret->itunes_menu = ttk_new_menu_widget (0, ttk_menufont, ret->wid->w, ret->wid->h);
	ttk_window_set_title (ret->wid, "Music");
	ret->init = 0;
	ret->prevml = NULL;

	return ret;
}
Ejemplo n.º 4
0
static void check_init() 
{
    if (!inited) {
	root_menu = ttk_new_menu_widget (0, ttk_menufont, ttk_screen->w - ttk_screen->wx,
					 ttk_screen->h - ttk_screen->wy);
	ttk_menu_set_closeable (root_menu, 0);
	inited = 1;
    }
}
Ejemplo n.º 5
0
static TWindow *remove_tracks (ttk_menu_item *item) {
    TWindow *ret = ttk_new_window();
    ret->data = 0x12345678;
    ttk_window_set_title (ret, _("Really Delete These Tracks?"));
    remove_tracks_menu[0].flags = 0; remove_tracks_menu[1].flags = TTK_MENU_ICON_EXE;
    remove_tracks_menu[0].data = remove_tracks_menu[1].data = item->data;
    ttk_add_widget (ret, ttk_new_menu_widget (remove_tracks_menu, ttk_textfont, item->menuwidth, item->menuheight));
    ttk_set_popup (ret);
    return ret;
}
Ejemplo n.º 6
0
static TWindow *browser_delete (ttk_menu_item *item) 
{
    TWindow *ret = ttk_new_window();
    ret->data = 0x12345678;
    ttk_window_set_title (ret, _("Really Delete?"));
    delete_menu[0].flags = 0; delete_menu[1].flags = TTK_MENU_ICON_EXE;
    delete_menu[0].data = delete_menu[1].data = item->data;
    ttk_add_widget (ret, ttk_new_menu_widget (delete_menu, ttk_textfont, item->menuwidth, item->menuheight));
    ttk_set_popup (ret);
    return ret;
}
Ejemplo n.º 7
0
static TWindow *browser_execute(ttk_menu_item *item)
{
	TWindow *ret = ttk_new_window();
	ret->data = 0x12345678;
	ttk_window_set_title(ret, _("Execute"));
	execute_menu[0].data = execute_menu[1].data =
		execute_menu[2].data = item->data;
	ttk_add_widget(ret, ttk_new_menu_widget(execute_menu, ttk_menufont,
				item->menuwidth, item->menuheight));
	ttk_set_popup(ret);
	return ret;
}
Ejemplo n.º 8
0
PzWindow *transfer_alt_menu(track_list *tlist, ipod_t src_ipod, queue_fcn qfunc, ttk_menu_item *qitem) {
	TWindow *ret;

	ret = pz_new_window(_("Transfer"), PZ_WINDOW_NORMAL);
    ret->data = 0x12345678;
    
	/* Show data up top: number of tracks, total size */	
	int num_tracks = 0, size=0;
	track_item *titem = tlist->head;
	
	while (titem) {
	   num_tracks++;
	   ipod_track_t track = ipod_track_get_by_track_id(src_ipod, titem->track_id);
	   size += ipod_track_get_attribute(track, IPOD_TRACK_SIZE);
       ipod_track_free(track);
	   titem = titem->next;
	}

	
	/* Add the status widget */
	PzWidget *stats_wid = pz_new_widget(transfer_alt_stat_draw, NULL);
	stat_data *stats = (stat_data *)malloc(sizeof(stat_data));
	stats->num_files = num_tracks;
	stats->total_bytes = size;
	stats_wid->data = stats;
	stats_wid->w = ret->w;
	ttk_add_widget(ret, stats_wid);
	
	
    /* Draw the Menu */	
    int menu_height = (ttk_text_height(ttk_menufont) + 4) * (qfunc? 3 : 2);
    TWidget *menu = ttk_new_menu_widget (transfer_menu_default, ttk_menufont, ttk_screen->w - ttk_screen->wx,
					menu_height);
	menu->y = ttk_screen->h - ttk_screen->wy - menu_height;
	transfer_menu_default[1].data = transfer_menu_default[3].data = tlist;
    if (remote_ipod)
		ttk_menu_append (menu, transfer_menu_default + 1);
	if (qfunc) {
		enqueue_data *eqdata = (enqueue_data *)malloc(sizeof(enqueue_data));		
		eqdata->qfunc = qfunc;
		eqdata->item = qitem;
		transfer_menu_default[2].data = eqdata;
		transfer_menu_default[2].free_data = 1;
		ttk_menu_append(menu, transfer_menu_default + 2);
	}
    ttk_menu_append (menu, transfer_menu_default + 3);
	ttk_add_widget(ret, menu);

	return pz_finish_window(ret);
}
Ejemplo n.º 9
0
TWindow * new_podwrite_menu_window()
{
	TWindow * w=ttk_new_window(_("PodWrite"));
	podwrite_menu = ttk_new_menu_widget(0, ttk_menufont, ttk_screen->w, ttk_screen->h-ttk_screen->wy);
	if (!podwrite_menu) return 0;
	ttk_menu_append(podwrite_menu, podwrite_new_menu_item(N_("Return to PodWrite"), podwrite_mh_return, 0));
	ttk_menu_append(podwrite_menu, podwrite_new_menu_item(N_("Move Cursor"), podwrite_mh_cursor, 0));
	ttk_menu_append(podwrite_menu, podwrite_new_menu_item(N_("Scroll"), podwrite_mh_scroll, 0));
	ttk_menu_append(podwrite_menu, podwrite_new_menu_item(N_("Clear All Text"), podwrite_mh_clear, 0));
	ttk_menu_append(podwrite_menu, podwrite_new_menu_item(N_("Save..."), podwrite_mh_save, 0));
	//ttk_menu_append(podwrite_menu, podwrite_new_menu_item(N_("Change Input Method"), podwrite_mh_input, TTK_MENU_ICON_SUB));
	ttk_menu_append(podwrite_menu, podwrite_new_menu_item(N_("Quit PodWrite"), podwrite_mh_quit, 0));
	ttk_add_widget(w,podwrite_menu);
	//w = pz_new_menu_window(podwrite_menu);
//	if (w) w->title = _("PodWrite");
	return w;
}
Ejemplo n.º 10
0
TWindow *new_font_window (ttk_menu_item *item)
{
    TWindow *ret = ttk_new_window();
    TWidget *this = ttk_new_menu_widget (0, ttk_menufont, ret->w, ret->h);
    ttk_fontinfo *cur = ttk_fonts;
    
    while (cur) {
	ttk_menu_item *item = calloc (1, sizeof(ttk_menu_item));

	item->name = cur->name;
	item->makesub = select_font;
	item->flags = 0;
	item->data = cur;
	ttk_menu_append (this, item);
	
	cur = cur->next;
    }

    ttk_add_widget (ret, this);
    ttk_window_title (ret, _("Select Font"));
    return ret;
}