示例#1
0
static void meh_screen_mapping_next_screen(App* app, Screen* screen) {
	g_assert(app != NULL);
	g_assert(screen != NULL);


	MappingData* data = meh_screen_mapping_get_data(screen);
	g_assert(data != NULL);

	/* build the mapping object */
	Mapping* mapping = meh_model_mapping_new(data->device_configuring->text, data->up, data->down, data->left, data->right,
												data->start, data->select, data->a, data->b, data->l, data->r);

	/* delete an eventual mapping with the same id */
	meh_db_delete_mapping(app->db, data->device_configuring->text);

	/* save the created mapping */
	meh_db_save_mapping(app->db, mapping);

	/* re-assign the mapping */
	meh_input_manager_assign_mapping(app->db, app->input_manager);

	/* create the child screen */
	Screen* platform_screen = meh_screen_platform_list_new(app);
	Screen* fade_screen = meh_screen_fade_new(app, screen, platform_screen);
	meh_app_set_current_screen(app, fade_screen, TRUE);
	/* NOTE we don't free the memory of the starting screen, the fade screen
	 * will do it. */
}
示例#2
0
static void meh_screen_starting_go_to_next_screen(App* app, Screen* screen) {
	g_assert(app != NULL);
	g_assert(screen != NULL);

	/* create and switch to the platform list screen
	 * if we don't need to configure a mapping */
	if (meh_input_manager_has_something_plugged(app->input_manager) && !app->flags.configure_mapping) {
		Screen* platform_list_screen = meh_screen_platform_list_new(app);
		Screen* fade_screen = meh_screen_fade_new(app, screen, platform_list_screen);
		meh_app_set_current_screen(app, fade_screen, TRUE);
	} else {
		Screen* mapping_screen = meh_screen_mapping_new(app);
		Screen* fade_screen = meh_screen_fade_new(app, screen, mapping_screen);
		meh_app_set_current_screen(app, fade_screen, TRUE);
	}
	/* NOTE we don't free the memory of the starting screen, the fade screen
	 * will do it. */
}
示例#3
0
static void meh_main_popup_close(App* app, Screen* screen) {
	g_assert(app != NULL);
	g_assert(screen != NULL);

	MainPopupData* data = meh_main_popup_get_data(screen);

	meh_app_set_current_screen(app, data->src_screen, TRUE);
	meh_screen_destroy(screen);
}
示例#4
0
/*
 * meh_screen_popup_update udpates the content of the popup screen.
 */
int meh_screen_popup_update(struct App* app, Screen* screen) {
    /* Animate the fading rect. */
    meh_screen_update_transitions(screen);

    PopupData* data = meh_screen_popup_get_data(screen);

    /* update the src screen */
    meh_message_send(app, data->src_screen, MEH_MSG_UPDATE, NULL);

    /* quit the screen at the end of the exit animation. */
    if (data->quitting && data->background_widget->y.ended) {
        meh_app_set_current_screen(app, data->src_screen, TRUE);
        meh_screen_destroy(screen);
    }

    return 0;
}
示例#5
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;
}
示例#6
0
void meh_exec_popup_favorite_toggle(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);

	/* updates the value of the executable */

	gboolean new_value = data->executable->favorite == 1 ? FALSE : TRUE;

	if (meh_db_set_executable_favorite(app->db, data->executable, new_value)) {
		data->executable->favorite = new_value;
	}

	/* re-position the executable in the executables list if necessary */
	if (g_queue_get_length(exec_list_data->executables) > 1) {
		int prev_selected = exec_list_data->selected_executable;

		unsigned int i = 0;

		/* retrieves the one which will move in the list */
		Executable* to_move = g_queue_pop_nth(exec_list_data->executables, exec_list_data->selected_executable);

		/* find the good position for the moved executable */

		for (i = 0; i < g_queue_get_length(exec_list_data->executables); i++) {
			gboolean exit = FALSE;
			Executable* ex = g_queue_peek_nth(exec_list_data->executables, i);
			/* if favorite, ensure to stay in the favorite zone */
			if (new_value == TRUE) {
				if (ex->favorite == FALSE)  {
					exit = TRUE;
				}
			}

			gchar* first = g_utf8_strup(ex->display_name, g_utf8_strlen(ex->display_name, -1));
			gchar* second = g_utf8_strup(data->executable->display_name, g_utf8_strlen(ex->display_name, -1));

			if (g_utf8_collate(first, second) > 0) {
				if (new_value == TRUE && ex->favorite == TRUE) {
					exit = TRUE;
				}
				else if (new_value == FALSE && ex->favorite == FALSE) {
					exit = TRUE;
				}
			}

			g_free(first);
			g_free(second);

			if (exit) {
				break;
			}
		}

		GList* after = g_queue_peek_nth_link(exec_list_data->executables, i);

		/* re-add it to the good position */

		g_queue_insert_before(exec_list_data->executables, after, to_move);

		/* notify the screen of the new selected executable */

		exec_list_data->selected_executable = i;

		/* redraw the executables list texts */

		meh_complete_selec_refresh_executables_widgets(app, data->src_screen);

		/* move and redraw the selection */

		meh_exec_list_after_cursor_move(app, data->src_screen, prev_selected);
	}

	meh_app_set_current_screen(app, data->src_screen, TRUE);
}