Ejemplo n.º 1
0
void meh_exec_popup_start_random_executable(App* app, Screen* screen) {
	g_assert(app != NULL);
	g_assert(screen != NULL);

	SimplePopupData* data = meh_simple_popup_get_data(screen);
	ExecutableListData* exec_list_data = meh_exec_list_get_data(data->src_screen);

	/* get a random executable */
	int platform_id = exec_list_data->platform->id;
	Executable* executable = meh_db_get_platform_random_executable(app->db, platform_id);

	if (executable) {
		Platform* platform = meh_db_get_platform(app->db, platform_id);
		if (platform) {
			/* keep some infos */
			PlatformListData* platform_list_data = meh_screen_platform_list_get_data(data->src_screen->parent_screen);

			int cursor_platform = platform_list_data->selected_platform;
			int cursor_exec = exec_list_data->selected_executable;

			meh_app_start_executable(app, platform, executable);

			/* destroy screens view */
			meh_screen_destroy(data->src_screen->parent_screen);
			data->src_screen->parent_screen = NULL;
			platform_list_data = NULL;
			meh_screen_destroy(data->src_screen);
			app->current_screen = NULL;
			exec_list_data = NULL;

			/* recreate the executable list view */
			data->src_screen = meh_exec_list_new(app, platform->id);
			exec_list_data = meh_exec_list_get_data(data->src_screen);

			/* restore the cursor position */
			exec_list_data->selected_executable = cursor_exec;
			meh_exec_list_after_cursor_move(app, data->src_screen, 0);

			/* recreate the parent screen which is the platform list */
			Screen* platform_screen = meh_screen_platform_list_new(app);
			data->src_screen->parent_screen = platform_screen;

			/* restore the cursor position */
			platform_list_data = meh_screen_platform_list_get_data(platform_screen);
			platform_list_data->selected_platform = cursor_platform;
			meh_screen_platform_change_platform(app, platform_screen);

			meh_model_platform_destroy(platform);
		}
		meh_model_executable_destroy(executable);
	}
}
Ejemplo n.º 2
0
/*
 * meh_screen_popup_random_executable starts a random executable of this platform.
 */
static void meh_screen_popup_random_executable(App* app, Screen* screen) {
	g_assert(app != NULL);

	PopupData* data = meh_screen_popup_get_data(screen);

	int platform_id = data->platform->id;

	Executable* executable = meh_db_get_platform_random_executable(app->db, platform_id);
	if (executable) {
		meh_app_start_executable(app, data->platform, executable);
		meh_model_executable_destroy(executable);
	}
}
Ejemplo n.º 3
0
/*
 * meh_main_popup_random_executable starts a random executable.
 */
void meh_main_popup_random_executable(App* app, Screen* screen) {
	g_assert(app != NULL);

	int platform_id = 0;
	Executable* executable = meh_db_get_random_executable(app->db, &platform_id);
	if (executable) {
		Platform* platform = meh_db_get_platform(app->db, platform_id);
		if (platform) {
			meh_app_start_executable(app, platform, executable);
			meh_model_platform_destroy(platform);
		}
		meh_model_executable_destroy(executable);
	}
}
Ejemplo n.º 4
0
/*
 * meh_screen_launch_update udpates the content of the launch screen.
 */
int meh_screen_launch_update(struct App* app, Screen* screen) {
	/* Animate the fading rect. */
	meh_screen_update_transitions(screen);

	LaunchData* data = meh_screen_launch_get_data(screen);
	g_assert(data != NULL);

	/* update the src screen */
	meh_message_send(app, data->src_screen, MEH_MSG_UPDATE, NULL);
		
	if (data->fade_widget->a.ended == TRUE) {
		/* it's time to start the executable and to switch back to the src screen */
		meh_app_start_executable(app, data->platform, data->executable);
		meh_app_set_current_screen(app, data->src_screen, TRUE);
		meh_screen_destroy(screen); /* destroy the launch screen */
	}

	return 0;
}