Пример #1
0
u32 menu(u16 *original_screen)
{
  u32 clock_speed_number = clock_speed - 1;
  u8 print_buffer[81];
  u32 _current_option = 0;
  gui_action_type gui_action;
  menu_enum _current_menu = MAIN_MENU;
  u32 i;
  u32 repeat = 1;
  u32 return_value = 0;
  u32 first_load = 0;
  u8 savestate_ext[16];
  u8 current_savestate_filename[512];
  u8 line_buffer[80];
  u8 cheat_format_str[10][41];

  menu_type *current_menu;
  menu_option_type *current_option;
  menu_option_type *display_option;
  u32 current_option_num;

  auto void choose_menu();
  auto void clear_help();

  u8 *gamepad_help[] =
  {
    "Up button on GBA d-pad.",
    "Down button on GBA d-pad.",
    "Left button on GBA d-pad.",
    "Right button on GBA d-pad.",
    "A button on GBA.",
    "B button on GBA.",
    "Left shoulder button on GBA.",
    "Right shoulder button on GBA.",
    "Start button on GBA.",
    "Select button on GBA.",
    "Brings up frameskip adjust bar and menu access.",
    "Jumps directly to the menu.",
    "Toggles fastforward on/off (don't expect it to do much or anything)",
    "Loads the game state from the current slot.",
    "Saves the game state to the current slot.",
    "Rapidly press/release the A button on GBA.",
    "Rapidly press/release the B button on GBA.",
    "Rapidly press/release the Left shoulder button on GBA.",
    "Rapidly press/release the Right shoulder button on GBA.",
    "Does nothing."
  };

  void menu_exit()
  {
    if(!first_load)
     repeat = 0;
  }

  void menu_quit()
  {
    clock_speed = clock_speed_number + 1;
    save_config_file();
    quit();
  }
Пример #2
0
int set_module_option(wchar_t* option_name, wchar_t const* option_value)
{
	char tmp_option_value[MAX_STRING_SIZE * 2] = {0};
	int error_code =0x0;
	size_t size = 0x0;
	errno_t errno;

	error_code = load_config_file(__config_file_path);
	if(error_code == APP_FAULT){	__last_error_code = get_last_error();	goto GOTO;}

	error_code = check_segd_option(option_name);
	if(error_code == APP_FAULT){	__last_error_code = get_last_error();	goto GOTO;}

	errno = wcstombs_s(&size, tmp_option_value, sizeof(tmp_option_value), option_value, sizeof(tmp_option_value));
	if(errno != 0){	__last_error_code = IDS_STRING5015; 	goto GOTO;}

	tmp_option_value[size] = 0x0;
	error_code = modify_segd_option(option_name, tmp_option_value);
	if(error_code == APP_FAULT){	__last_error_code = get_last_error();	goto GOTO;}

	error_code = save_config_file(__config_file_path);
	if(error_code == APP_FAULT){	__last_error_code = get_last_error();}

GOTO:
	return error_code;
}
void SlideshowController::ensure_folder_structure()
{
  // Check for profile folder and create one if it does not exist
  if (!QDir(slideshow_data_model_->profile_folder_path()).exists())
    {
      QDir().mkdir(slideshow_data_model_->profile_folder_path());
    }
  if (!QDir(slideshow_data_model_->main_image_folder_path()).exists())
    {
      QDir().mkdir(slideshow_data_model_->main_image_folder_path());
    }
  // Check for config file and create one if it does not exist
  if (!QFile::exists(slideshow_data_model_->config_file_path()))
    {
       QFile config_file(slideshow_data_model_->config_file_path());
       if (config_file.open(QIODevice::ReadWrite))
         {
           QTextStream text_stream(&config_file);
           save_config_file(slideshow_data_model_->config_file_path());
         }
    }
   /* Qt automatically closes files in
    * this context.
    */
}
Пример #4
0
int
Snes9xConfig::load_config_file (void)
{
    struct stat file_info;
    char        *pathname;
    xmlDoc      *xml_doc = NULL;
    xmlNodePtr  xml_root = NULL;

    load_defaults ();

    pathname = get_config_dir ();

    if (stat (pathname, &file_info))
    {
        if (mkdir (pathname, 0755))
        {
            fprintf (stderr,
                     _("Couldn't create config directory: %s\n"),
                     pathname);
            return -1;
        }
    }
    else
    {
        chmod (pathname, 0755);
    }

    free (pathname);

    pathname = get_config_file_name ();

    if (stat (pathname, &file_info))
    {
        save_config_file ();
    }

    xml_doc = xmlReadFile (pathname, NULL, 0);

    if (!xml_doc)
    {
        fprintf (stderr, _("Couldn't open config file: %s\n"), pathname);
        return -2;
    }

    free (pathname);

    xml_root = xmlDocGetRootElement (xml_doc);

    parse_snes9x (xml_root);

    xmlFreeDoc (xml_doc);

    return 0;
}
Пример #5
0
void on_file_new(void)
{
	gchar *comline;
	gchar *option;

	save_config_file();
	option = pub->fi->charset_flag ?
		g_strdup_printf("%s%s", " --codeset=", pub->fi->charset) : "";
	comline = g_strdup_printf("%s%s", PACKAGE, option);
	if (pub->fi->charset_flag)
		g_free(option);
	g_spawn_command_line_async(comline, NULL);
	g_free(comline);
}
Пример #6
0
void on_file_open(void)
#ifdef ENABLE_CSDI
{ // too slow...
	FileInfo *fi;
	gchar *comline;
	gchar *option = NULL;

	fi = get_fileinfo_from_selector(pub->fi, OPEN);
	if (fi) {
		save_config_file();
		option = g_strdup_printf("--codeset=%s ", fi->charset);
		comline = g_strdup_printf("%s %s%s", PACKAGE,
			fi->charset ? option : "",
			fi->filename);
		g_spawn_command_line_async(comline, NULL);
		g_free(option);
		g_free(comline);
		g_free(fi);
	}
}
Пример #7
0
u32 menu(u16 *original_screen)
{
  u32 clock_speed_number = (clock_speed / 33) - 1;
  u8 print_buffer[81];
  u32 _current_option = 0;
  gui_action_type gui_action;
  menu_enum _current_menu = MAIN_MENU;
  u32 i;
  u32 repeat = 1;
  u32 return_value = 0;
  u32 first_load = 0;
  u8 savestate_ext[16];
  u8 current_savestate_filename[512];
  u8 line_buffer[80];
  u8 cheat_format_str[10][41];

  menu_type *current_menu;
  menu_option_type *current_option;
  menu_option_type *display_option;
  u32 current_option_num;

  auto void choose_menu();
  auto void clear_help();

  u8 *gamepad_help[] =
  {
    "Up button on GBA d-pad.",
    "Down button on GBA d-pad.",
    "Left button on GBA d-pad.",
    "Right button on GBA d-pad.",
    "A button on GBA.",
    "B button on GBA.",
    "Left shoulder button on GBA.",
    "Right shoulder button on GBA.",
    "Start button on GBA.",
    "Select button on GBA.",
    "Brings up the options menu.",
    "Toggles fastforward on/off.",
    "Loads the game state from the current slot.",
    "Saves the game state to the current slot.",
    "Rapidly press/release the A button on GBA.",
    "Rapidly press/release the B button on GBA.",
    "Rapidly press/release the L shoulder on GBA.",
    "Rapidly press/release the R shoulder on GBA.",
    "Increases the volume.",
    "Decreases the volume.",
    "Displays virtual/drawn frames per second.",
    "Does nothing."
  };

  void menu_exit()
  {
    if(!first_load)
     repeat = 0;
  }

  void menu_quit()
  {
    clock_speed = (clock_speed_number + 1) * 33;
    save_config_file();
    quit();
  }
Пример #8
0
int main (int argc, char **argv)
{

    char sql[256];
    gboolean verbose = FALSE;
    gboolean use_mysql = FALSE;
    int ret;

    if (argc == 1)
        usage(1);

    int c;
    while ((c = getopt_long(argc, argv, short_opts, long_opts, NULL)) != EOF) {
        switch (c) {
        case 'h':
            usage(0);
            break;
        case 'v':
            verbose = TRUE;
            break;
        case 'm':
            use_mysql = TRUE;
            break;
        case 's':
            config.mysql_host = strdup(optarg);
            break;
        case 't':
            config.mysql_socket = strdup(optarg);
            break;
        case 'r':
            config.mysql_root_passwd = strdup(optarg);
            break;
        case 'd':
            config.seafile_dir = strdup(optarg);
            break;
        case 'p':
            config.port = strdup(optarg);
            break;
        case 'P':
            config.httpserver_port = strdup(optarg);
            break;
        default:
            usage(1);
        }
    }

    if (use_mysql && !config.mysql_root_passwd) {
        fprintf (stderr, "You choose to use mysql database. "
                 "Mysql Root Password must be specified.\n");
        exit(1);
    }

    if (!config.seafile_dir) {
        fprintf (stderr, "You must specify seafile data dir\n");
        usage(1);
    }

    /* Create database for mysql */
    if (use_mysql) {
        SeafDB *db_root = seaf_db_new_mysql (config.mysql_host, "root",
                                             config.mysql_root_passwd,
                                             NULL, config.mysql_socket);
        if (!db_root) {
        fprintf (stderr, "Out of memory!\n");
        return 1;
        }

        /* Create database for Seafile server. */
        snprintf (sql, sizeof(sql), "CREATE DATABASE IF NOT EXISTS `%s`",
              config.mysql_db_name);
        ret = seaf_db_query (db_root, sql);
        if (ret < 0) {
            fprintf (stderr, "Failed to create database %s.\n", config.mysql_db_name);
        return 1;
        }
        
        if (verbose)
            printf ("Successfully created database:     %s\n",
                    config.mysql_db_name);
        
        /* Create database for Seahub. */
        snprintf (sql, sizeof(sql), "CREATE DATABASE IF NOT EXISTS `%s` character set utf8",
                  config.mysql_seahub_db_name);
        ret = seaf_db_query (db_root, sql);
        if (ret < 0) {
            fprintf (stderr, "Failed to create database %s.\n",
                     config.mysql_seahub_db_name);
            return 1;
        }

        if (verbose)
            printf ("Successfully created database:     %s\n",
                    config.mysql_seahub_db_name);
    }
        
    /* Generate config file. */
    GKeyFile *key_file = g_key_file_new ();

    g_key_file_set_string (key_file, "database", "type",
                           use_mysql ? "mysql" : "sqlite");
    if (use_mysql) {
        g_key_file_set_string (key_file, "database", "host", config.mysql_host);
        g_key_file_set_string (key_file, "database", "user", "root");
        g_key_file_set_string (key_file, "database", "password", config.mysql_root_passwd);
        g_key_file_set_string (key_file, "database", "db_name", config.mysql_db_name);
        if (config.mysql_socket)
            g_key_file_set_string (key_file, "database", "unix_socket", config.mysql_socket);
    }

    g_key_file_set_string (key_file, "network", "port", config.port);
    if (config.httpserver_port) {
        g_key_file_set_string (key_file, "httpserver", "port", config.httpserver_port);
    } else {
        /* httpserver port defaults to 8082 */
        g_key_file_set_string (key_file, "httpserver", "port", "8082");
    }

    struct stat st;
    if (lstat (config.seafile_dir, &st) < 0) {
        if (mkdir (config.seafile_dir, 0777) < 0) {
            fprintf (stderr, "Directory %s cannot be created.\n", config.seafile_dir);
            return 1;
        }
    }

    char *seafile_conf = g_build_filename (config.seafile_dir, "seafile.conf", NULL);

    if (verbose)
        printf ("Generating config files:           %s\n", seafile_conf);

    if (save_config_file (key_file, seafile_conf) < 0)
        return 1;

    printf ("Done.\n");

    return 0;
}
Пример #9
0
void save_config (GtkButton *button, gpointer user_data)
{
	GtkTreeIter f_iter, h_iter;
	GValue f_value = {0};
	GValue h_value = {0};
	gchar *f_src, *f_dst, *h_val;
	gboolean delete_cond = FALSE, valid = TRUE; 
	gint i, j;
	GtkWidget *dialog;
	Widgets *widgets = (Widgets*)user_data;

	if(gtk_tree_model_get_iter_first (widgets->store, &f_iter) && gtk_tree_model_get_iter_first (widgets->store_hidden, &h_iter))
	{
		gtk_tree_model_get_iter_first (widgets->store_hidden, &h_iter);
		do
		{
			gtk_tree_model_get_value (widgets->store_hidden, &h_iter, 0, &h_value);
			gtk_tree_model_get_iter_first (widgets->store, &f_iter);
			do
			{
				gtk_tree_model_get_value (widgets->store, &f_iter, 0, &f_value);
				if(strcmp(g_value_get_string (&f_value), g_value_get_string (&h_value)) == 0)
				{
					if(!gtk_tree_store_remove (widgets->store_hidden, &h_iter))
					{
						valid = FALSE;
					}
					delete_cond = TRUE;
					g_value_unset(&f_value);
					break;
				}
				g_value_unset(&f_value);
				
				gtk_tree_model_get_value (widgets->store, &f_iter, 1, &f_value);
				if(strcmp(g_value_get_string (&f_value), g_value_get_string (&h_value)) == 0)
				{
					if(!gtk_tree_store_remove (widgets->store_hidden, &h_iter))
					{
						valid = FALSE;
					}
					delete_cond = TRUE;
					g_value_unset(&f_value);
					break;
				}
				g_value_unset(&f_value);
			}
			while (gtk_tree_model_iter_next (widgets->store, &f_iter));
			g_value_unset(&h_value);
			if(delete_cond)
			{
				delete_cond = FALSE;
			}
			else
			{
				if(!gtk_tree_model_iter_next (widgets->store_hidden, &h_iter))
				{
					valid = FALSE;
				}
			}
		}
		while (valid);
	}
	
	if(gtk_tree_model_get_iter_first (widgets->store, &f_iter))
	{
		j=0;
		do
		{
			gtk_tree_model_get_value (widgets->store, &f_iter, 0, &f_value);
			f_src = g_value_get_string (&f_value);
			for(i=0; i<size_lang; i++)
			{
				if(strcmp(f_src, dicts[i].name) == 0)
				{
					favorite[j].src_code = i;
					break;
				}
			}
			g_value_unset(&f_value);
			gtk_tree_model_get_value (widgets->store, &f_iter, 1, &f_value);
			f_dst = g_value_get_string (&f_value);
			for(i=0; i<size_lang; i++)
			{
				if(strcmp(f_dst, dicts[i].name) == 0)
				{
					favorite[j].dst_code = i;
					break;
				}
			}
			g_value_unset(&f_value);
			//g_print ("\n%s -> %s", *f_src, *f_dst);
			j++;
		}
		while(gtk_tree_model_iter_next (widgets->store, &f_iter));
	}

	for(i=0; i<sizeof(favorite)/sizeof(favorite[0]); i++)
	{
		if(favorite[i].src_code == -1)
		{
			break;
		}
		g_print("\n%d %d", favorite[i].src_code, favorite[i].dst_code);
	}

	if(gtk_tree_model_get_iter_first (widgets->store_hidden, &h_iter))
	{
		j=0;
		do
		{
			gtk_tree_model_get_value (widgets->store_hidden, &h_iter, 0, &h_value);
			h_val = g_value_get_string (&h_value);
			for(i=0; i<size_lang; i++)
			{
				if(strcmp(h_val, dicts[i].name) == 0)
				{
					h_dict[j].code = i;
					break;
				}
			}
			g_value_unset(&h_value);
			j++;
		}
		while(gtk_tree_model_iter_next (widgets->store_hidden, &h_iter));
	}

	for(i=0; i<sizeof(h_dict)/sizeof(h_dict[0]); i++)
	{
		if(h_dict[i].code == -1)
		{
			break;
		}
		g_print("\n%d", h_dict[i].code);
	}

	strcpy (shortcut[0].name, gtk_entry_get_text (widgets->entry_sn));
	strcpy (shortcut[1].name, gtk_entry_get_text (widgets->entry_wn));
	strcpy (shortcut[2].name, gtk_entry_get_text (widgets->entry_sf));
	strcpy (shortcut[3].name, gtk_entry_get_text (widgets->entry_sb));
	strcpy (shortcut[4].name, gtk_entry_get_text (widgets->log_file_entry));
	strcpy (shortcut[5].name, gtk_entry_get_text (widgets->save_freq_entry));
	

	save_config_file (conf_file, &shortcut, &favorite, &h_dict);
	exit_window (NULL, user_data);
	exit_code = 1;
}
Пример #10
0
static void dnd_drag_data_recieved_handler(GtkWidget *widget,
	GdkDragContext *context, gint x, gint y,
	GtkSelectionData *selection_data, guint info, guint time)
{
	static gboolean flag_called_once = FALSE;
	gchar **files;
	gchar *filename;
	gchar *comline;
	gint i = 0, j = 0;
	gchar *filename_sh;
	gchar **strs;
#ifdef ENABLE_CSDI
	j = 1;
#endif
DV(g_print("DND start!\n"));
	
#if GTK_CHECK_VERSION(2, 10, 0)
	if (g_strcasecmp(gdk_atom_name(context->targets->data),
	    "GTK_TEXT_BUFFER_CONTENTS") != 0) {
#else
	if (info != TARGET_SELF) {
#endif
		if (flag_called_once) {
			flag_called_once = FALSE;
			g_signal_stop_emission_by_name(widget, "drag_data_received");
DV(g_print("second drop signal killed.\n"));
			return;
		} else
			flag_called_once = TRUE;
	}
	
DV({	
	g_print("info                      = %d\n", info);
	g_print("time                      = %d\n", time);
	g_print("context->protocol         = %d\n", context->protocol);
	g_print("context->is_source        = %d\n", context->is_source);
	g_print("context->targets          = %d\n", g_list_length(context->targets));
	g_print("context->target           = %s\n", gdk_atom_name(context->targets->data));
/*	g_print("context->target           = %s\n", gdk_atom_name(context->targets->next->data));
	g_print("context->target           = %s\n", gdk_atom_name(context->targets->next->next->data));
	g_print("context->actions          = %d\n", context->actions);
	g_print("context->suggested_action = %d\n", context->suggested_action);
	g_print("context->action           = %d\n", context->action);
	g_print("selection_data->selection = %s\n", gdk_atom_name(selection_data->selection));
	g_print("selection_data->target    = %s\n", gdk_atom_name(selection_data->target));
*/	g_print("selection_data->type      = %s\n", gdk_atom_name(selection_data->type));
	g_print("selection_data->format    = %d\n", selection_data->format);
	g_print("selection_data->length    = %d\n", selection_data->length);
	g_print("%s\n", selection_data->data);
});	
	
	if (selection_data->data && info == TARGET_URI_LIST) {
		files = g_strsplit((gchar *)selection_data->data, "\n" , -1);
		while (files[i]) {
			if (strlen(files[i]) == 0)
				break;
			filename = g_strstrip(parse_file_uri(files[i]));
			if (i + j == 0)
				dnd_open_first_file(filename);
			else {
				if (i + j == 1)
					save_config_file();
				if (strstr(filename, " ")) {
					strs = g_strsplit(filename, " ", -1);
					filename_sh = g_strjoinv("\\ ", strs);
					g_strfreev(strs);
				} else
					filename_sh = g_strdup(filename);
				comline = g_strdup_printf("%s %s", PACKAGE, filename_sh);
DV(g_print(">%s\n", comline));
				g_free(filename_sh);
				g_spawn_command_line_async(comline, NULL);
				g_free(comline);
			}
			g_free(filename);
			i++;
		}
		g_strfreev(files);
	}
	else {
		clear_current_keyval();
		undo_set_sequency(FALSE);
#if GTK_CHECK_VERSION(2, 10, 0)
		if (info == TARGET_UTF8_STRING) {
#else
		if (info == TARGET_SELF) {
#endif
			undo_set_sequency_reserve();
			context->action = GDK_ACTION_MOVE;
		} else if (info == TARGET_PLAIN 
			&& g_utf8_validate((gchar *)selection_data->data, -1, NULL)) {
			selection_data->type =
				gdk_atom_intern("UTF8_STRING", FALSE);
		}
	}
	
	return;
}

static gboolean dnd_drag_motion_handler(GtkWidget *widget,
	GdkDragContext *context, gint x, gint y, guint time)
{
	GList *targets;
	gchar *name;
	gboolean flag = FALSE;
	
	targets = context->targets;
	while (targets) {
		name = gdk_atom_name(targets->data);
DV(g_print("%s\n", name));
		if (g_ascii_strcasecmp(name, "text/uri-list") == 0)
			flag = TRUE;
		g_free(name);
		targets = targets->next;
	}
/*	if (flag)
		context->action = GDK_ACTION_DEFAULT;
	else
		context->action = GDK_ACTION_COPY;
//	g_signal_stop_emission_by_name(widget, "drag_motion");
*/	
/*	if (!flag) {
		gint bx, by;
		GtkTextIter iter;
		
		gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(widget),
			GTK_TEXT_WINDOW_WIDGET,
			x, y, &bx, &by);
		gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(widget), &iter, bx, by);
		if (!dnd_mark) {
			dnd_mark = gtk_text_buffer_create_mark(GTK_TEXT_VIEW(widget)->buffer,
			    NULL, &iter, TRUE);
			gtk_text_mark_set_visible(dnd_mark, TRUE);
		} else
			gtk_text_mark_set_visible(dnd_mark, FALSE);
			gtk_text_buffer_move_mark(GTK_TEXT_VIEW(widget)->buffer,
			    dnd_mark, &iter);
			gtk_text_mark_set_visible(dnd_mark, TRUE);
	}
*/	
	return flag;
}