gint display_import_romversion_dbox(void) { const gchar *filename; char *dstname; int err; // get filename filename = create_fsel(inst_paths.base_dir, NULL, "*.rom;*.89u;*.9xu;*.v2u;*.tib", FALSE); if (!filename) return 0; if(ti68k_is_a_rom_file(filename)) { err = ti68k_convert_rom_to_image(filename, inst_paths.img_dir, &dstname); handle_error(); g_free(dstname); } else if(ti68k_is_a_tib_file(filename)) { // fake rom err = ti68k_convert_tib_to_image(filename, inst_paths.img_dir, &dstname); handle_error(); g_free(dstname); } return 0; }
int display_recv_files_dbox(const char *src, const char *dst) { const gchar *fn; gchar *src_folder; gchar *dst_folder; gchar *file_basename; gchar *ext; // get file components src_folder = g_path_get_dirname(src); dst_folder = inst_paths.home_dir; file_basename = g_path_get_basename(dst); // set mask switch(tihw.calc_type) { case TI92: ext = (char *)"*.92?"; break; default: ext = (char *)"*.89?;*.92?;*.9x?;*.9X?;*.v2?;*.V2?"; break; } fn = create_fsel(dst_folder, file_basename, ext, TRUE); if (fn) tiemu_file_move_with_check(src, fn); else tiemu_file_delete(src); g_free(src_folder); g_free(file_basename); return 0; }
gint display_recv_files_dbox(const char *filename) { const gchar *fn; gchar *src_folder; gchar *dst_folder; gchar *basename; gchar *ext; // get file components src_folder = g_path_get_dirname(filename); dst_folder = inst_paths.home_dir; basename = g_path_get_basename(filename); // set mask switch(tihw.calc_type) { case TI92: ext = "*.92?"; break; default: ext = "*.89?;*.92?;*.9x?;*.9X?;*.v2?;*.V2?"; break; } fn = create_fsel(dst_folder, basename, ext, TRUE); if(fn) rename(filename, fn); g_free(src_folder); g_free(basename); return 0; }
// Send TIGroup TILP_EXPORT void on_tilp_button8_clicked(GtkButton* button, gpointer user_data) { const char *filename; int ret; int mode = TIG_ALL; ret = backup_box(_("Restore"), _("Data to restore:"), &mode); if(ret != BUTTON1) return; #if 1 filename = create_fsel(local.cwdir, NULL, "*.tig", FALSE); if(filename) tilp_calc_send_tigroup(filename, mode); #else if(local.selection2 == NULL) return; if(g_list_length(local.selection) > 1) return; { FileEntry *f = (FileEntry *) local.selection->data; if(!tifiles_file_is_tigroup(f->name)) return; tilp_calc_send_tigroup(f->name, mode); } #endif return; }
GLADE_CB void on_save_clicked (GtkToolButton *toolbutton, gpointer user_data) { gchar *fn = NULL, *ext = NULL; gchar *filename = NULL; if(GFMFile.filename != NULL) filename = g_strdup(GFMFile.filename); if(GFMFile.type & TIFILE_TIGROUP) { ext = g_strdup("*.tig"); } else if(GFMFile.type & TIFILE_GROUP) { if(ticalcs_dirlist_ve_count(GFMFile.trees.vars) > 1) { // Group file ext = g_strconcat("*.", tifiles_vartype2fext(GFMFile.model, 0x00), NULL); ext[4] = 'g'; } else if(ticalcs_dirlist_ve_count(GFMFile.trees.vars) == 1) { // Single file GNode *parent, *child; VarEntry *ve; parent = g_node_nth_child(GFMFile.trees.vars, 0); child = g_node_nth_child(parent, 0); ve = (VarEntry *) (child->data); filename = g_strconcat(ticonv_varname_to_filename(GFMFile.model, ve->name, ve->type), ".", tifiles_vartype2fext(GFMFile.model, ve->type), NULL); ext = g_strconcat("*.", tifiles_vartype2fext(GFMFile.model, ve->type), NULL); } else { g_free(filename); return; } } fn = (char *)create_fsel(inst_paths.home_dir, filename, ext, TRUE); if(fn == NULL) return; g_free(filename); g_free(ext); file_save(fn); g_free(GFMFile.filename); GFMFile.filename = g_strdup(fn); enable_save(FALSE); }
gint display_import_romversion_dbox(void) { const gchar *filename; // get filename filename = create_fsel(inst_paths.base_dir, NULL, (char *)"*.rom;*.89u;*.9xu;*.v2u;*.tib", FALSE); if (!filename) return 0; return import_romversion(filename);; }
gint display_load_state_dbox(void) { const gchar *filename; // get filename filename = create_fsel(inst_paths.img_dir, NULL, (char *)"*.sav", FALSE); if (!filename) return 0; fs_load_state(filename); return 0; }
GLADE_CB void on_open_clicked (GtkToolButton *toolbutton, gpointer user_data) { gchar *fn; if(user_data == NULL) { if(GFMFile.contents.group || GFMFile.contents.tigroup) { int result = msgbox_two(MSGBOX_YESNO, _("Do you want to save previous file?")); if(result == MSGBOX_YES) on_save_clicked(toolbutton,user_data); } fn = (char *)create_fsel(inst_paths.home_dir, "", "*.73?;*.82?;*.83?;*.8X?;*.85?;*.86?;*.89?;*.92?;*.9x?;*.V2?;*.tig", FALSE); if(fn == NULL) return; } else { // command line fn = (char *)user_data; } if(tifiles_file_is_tigroup(fn)) GFMFile.type = TIFILE_TIGROUP; else if(tifiles_file_is_regular(fn)) GFMFile.type = TIFILE_GROUP; else return; file_load(fn); g_free(GFMFile.filename); GFMFile.filename = g_strdup(fn); enable_save(FALSE); enable_tree(TRUE); ctree_refresh(); labels_refresh(); g_free(inst_paths.home_dir); inst_paths.home_dir = g_path_get_dirname(GFMFile.filename); }
gint display_load_state_dbox() { const gchar *filename; int err; // get filename filename = create_fsel(inst_paths.home_dir, NULL, "*.sav", FALSE); if (!filename) return 0; g_free(params.sav_file); params.sav_file = g_strdup(filename); err = ti68k_state_load(params.sav_file); handle_error(); return 0; }
GLADE_CB void on_ungroup_clicked (GtkButton *button, gpointer user_data) { char *fn; fn = (char *)create_fsel(inst_paths.home_dir, "", "*.73g;*.82g;*.83g;*.8Xg;*.85g;*.86g;*.89g;*.92g;*.9Xg;*.V2g;*.tig", FALSE); if(fn == NULL) return; if(tifiles_file_is_tigroup(fn)) gfm_tifiles_ungroup(fn, TIFILE_TIGROUP); else if(tifiles_file_is_regular(fn)) gfm_tifiles_ungroup(fn, TIFILE_GROUP); else return; }
gint display_skin_dbox(void) { const gchar *filename; filename = (char *)create_fsel(inst_paths.skin_dir, NULL, (char *)"*.skn", FALSE); if (!filename) { return 0; } // Load new skin g_free(options.skin_file); options.skin_file = g_strdup(filename); hid_change_skin(options.skin_file); return 0; }
gint display_debug_dbox(void) { const gchar *filename; const gchar *ext; static gchar *folder = NULL; // set mask switch(tihw.calc_type) { case TI92: ext = "*.92?"; break; default: ext = "*.89?;*.92?;*.9x?;*.v2?"; break; } // get filename if(folder == NULL) folder = g_strdup(inst_paths.base_dir); filename = (char *)create_fsel(folder, NULL, (char *)ext, FALSE); if (!filename) { return 0; } // keep folder g_free(folder); folder = g_path_get_dirname(filename); // check extension if(!tifiles_file_is_ti(filename) || !tifiles_calc_is_ti9x(tifiles_file_get_model(filename))) { msg_box1(_("Error"), _("This file is not a valid TI file.")); return -1; } fs_send_file_and_debug_info(filename); return 0; }
gint display_import_romversion_dbox(void) { const gchar *filename; char *dstname; int err; // get filename filename = create_fsel(inst_paths.base_dir, NULL, "*.rom;*.89u;*.9xu;*.v2u;*.tib", FALSE); if (!filename) return 0; if(ti68k_is_a_rom_file(filename)) { err = ti68k_convert_rom_to_image(filename, inst_paths.img_dir, &dstname); handle_error(); g_free(dstname); } else if(ti68k_is_a_tib_file(filename)) { IMG_INFO infos = { 0 }; int err = ti68k_get_tib_infos(filename, &infos, 0); int hw_type = HW2; if(infos.calc_type == TI92p || infos.calc_type == TI89) { int ret = msg_box3(_("HW type"), _("The FLASH upgrade can be imported as HW1 or HW2. Please choose..."), "HW1", "HW2", "Default"); if(ret == BUTTON1) hw_type = HW1; else if(ret == BUTTON2) hw_type = HW2; } // fake rom err = ti68k_convert_tib_to_image(filename, inst_paths.img_dir, &dstname, hw_type); handle_error(); g_free(dstname); } return 0; }
TILP_EXPORT void on_sc_load1_activate(GtkMenuItem * menuitem, gpointer user_data) { const gchar *filename; GdkPixbuf *pixbuf; GError *error = NULL; filename = create_fsel(local.cwdir, NULL, "*.jpg;*.png;*.xpm;*.bmp", FALSE); if (!filename) return; pixbuf = gdk_pixbuf_new_from_file(filename, &error); if (!pixbuf) { tilp_warning("Failed to load pixbuf file: %s: %s\n", filename, error->message); g_error_free(error); } gtk_image_set_from_pixbuf(GTK_IMAGE(scrn_img), pixbuf); g_object_unref(pixbuf); }
// Recv TIGroup TILP_EXPORT void on_tilp_button7_clicked(GtkButton* button, gpointer user_data) { char* src_filename; const char *dst_filename; const char *dst_filename2; int ret; int mode = TIG_ALL; ret = backup_box(_("Backup"), _("Data to backup:"), &mode); if(ret != BUTTON1) return; if (tilp_calc_recv_tigroup(mode) != 0) return; src_filename = g_strconcat(g_get_tmp_dir(), G_DIR_SEPARATOR_S, TMPFILE_TIGROUP, NULL); dst_filename = create_fsel(local.cwdir, "backup", "*.tig", TRUE); if(!dst_filename) { g_free(src_filename); return; } if (!strcmp(tifiles_fext_get(dst_filename), "")) dst_filename2 = g_strconcat(dst_filename, ".tig", NULL); else dst_filename2 = g_strdup(dst_filename); //g_free((void *)dst_filename); if (dst_filename2) { tilp_file_move_with_check(src_filename, dst_filename2); } g_free(src_filename); g_free((void *)dst_filename2); tilp_dirlist_local(); clist_refresh(); labels_refresh(); }
gint display_save_state_dbox(void) { const gchar *filename; int err; gchar *file_basename; gchar *dot; gchar *pattern; // get filename file_basename = g_path_get_basename(params.rom_file); dot = strrchr(file_basename, '.'); if(dot != NULL) *dot = '\0'; pattern = g_strconcat(file_basename, ".sav", NULL); g_free(file_basename); filename = create_fsel(inst_paths.img_dir, pattern, (char *)"*.sav", TRUE); g_free(pattern); if (!filename) return 0; g_free(params.sav_file); params.sav_file = g_strdup(filename); err = ti68k_state_save(params.sav_file); handle_error(); if(!rcfile_exist()) { rcfile_write(); #ifdef __WIN32__ msg_box1(_("Information"), _("You do not seem to have saved your settings. Configuration file saved (in tiemu.ini).")); #else msg_box1(_("Information"), _("You do not seem to have saved your settings. Configuration file saved (in ~/.tiemu).")); #endif } return 0; }
gint display_set_tib_dbox(void) { const gchar *filename; gchar *path, *name; int err; // get filename filename = create_fsel(inst_paths.base_dir, NULL, "*.89u;*.9xu;*.v2u;*.tib", FALSE); if (!filename) return 0; if(!ti68k_is_a_tib_file(filename)) { msg_box("Error", "Don't seem to be an upgrade."); return -1; } path = g_path_get_dirname(filename); name = g_path_get_basename(filename); // set tib file g_free(params.tib_file); params.tib_file = g_strconcat(path, G_DIR_SEPARATOR_S, name, NULL); g_free(path); g_free(name); err = ti68k_load_upgrade(params.tib_file); handle_error(); if(err) { msg_box("Error", "Can not load the upgrade."); return -1; } //msg_box(_("Information"), _("Your configuration has been saved.")); //rcfile_write(); // simply reset, don't restart ti68k_reset(); return 0; }
gint display_set_tib_dbox(void) { const gchar *filename; gchar *path, *name; int err; // get filename filename = create_fsel(inst_paths.base_dir, NULL, (char *)"*.89u;*.9xu;*.v2u;*.tib", FALSE); if (!filename) return 0; if(!ti68k_is_a_tib_file(filename)) { msg_box1(_("Error"), _("Does not seem to be an upgrade.")); return -1; } path = g_path_get_dirname(filename); name = g_path_get_basename(filename); // set tib file g_free(params.tib_file); params.tib_file = g_strconcat(path, G_DIR_SEPARATOR_S, name, NULL); g_free(path); g_free(name); err = ti68k_load_upgrade(params.tib_file); handle_error(); if(err) { msg_box1(_("Error"), _("Cannot load the upgrade.")); return -1; } // update ROM calls list dbgromcall_refresh_window(); // simply reset, don't restart ti68k_reset(); return 0; }
static int save_group(void) { char* src_filename; const char *dst_filename; const char *dst_filename2; char *ext; src_filename = g_strconcat(g_get_tmp_dir(), G_DIR_SEPARATOR_S, TMPFILE_GROUP, ".", tifiles_fext_of_group(options.calc_model), NULL); ext = g_strconcat("*.", tifiles_fext_of_group(options.calc_model), NULL); dst_filename = create_fsel(local.cwdir, "group", ext, TRUE); g_free(ext); if (!dst_filename) { g_free(src_filename); return -1; } if (!strcmp(tifiles_fext_get(dst_filename), "")) dst_filename2 = g_strconcat(dst_filename, ".", tifiles_fext_of_group(options.calc_model), NULL); else dst_filename2 = g_strdup(dst_filename); //g_free((void *)dst_filename); if (dst_filename2) { tilp_file_move_with_check(src_filename, dst_filename2); } g_free(src_filename); g_free((void *)dst_filename2); tilp_dirlist_local(); clist_refresh(); labels_refresh(); return 0; }
// Backup TILP_EXPORT void on_tilp_button3b_clicked(GtkButton* button, gpointer user_data) { char* src_filename; const char *dst_filename; const char *dst_filename2; char *ext; if (tilp_calc_recv_backup() != 0) return; src_filename = g_strconcat(g_get_tmp_dir(), G_DIR_SEPARATOR_S, TMPFILE_BACKUP, NULL); ext = g_strconcat("*.", tifiles_fext_of_backup(options.calc_model), NULL); dst_filename = create_fsel(local.cwdir, "backup", ext, TRUE); g_free(ext); if (!dst_filename) { g_free(src_filename); return; } if (!strcmp(tifiles_fext_get(dst_filename), "")) dst_filename2 = g_strconcat(dst_filename, ".", tifiles_fext_of_backup(options.calc_model), NULL); else dst_filename2 = g_strdup(dst_filename); //g_free((void *)dst_filename); if (dst_filename2) { tilp_file_move_with_check(src_filename, dst_filename2); } g_free(src_filename); g_free((void *)dst_filename2); tilp_dirlist_local(); clist_refresh(); labels_refresh(); }
// Restore TILP_EXPORT void on_tilp_button4_clicked(GtkButton* button, gpointer user_data) { const char *filename; char *ext; int mode = TIG_ALL | TIG_BACKUP; ext = g_strconcat("*.", tifiles_fext_of_backup(options.calc_model), ";*.tig", NULL); filename = create_fsel(local.cwdir, NULL, ext, FALSE); g_free(ext); if(filename) { if(tifiles_file_is_tigroup(filename)) { int ret = backup_box(_("Restore"), _("Data to restore:"), &mode); if(ret != BUTTON1) return; tilp_calc_send_tigroup(filename, mode | TIG_BACKUP); } else if(tifiles_file_is_backup(filename)) tilp_calc_send_backup(filename); } }
TILP_EXPORT void on_rom_dump1_activate(GtkMenuItem* menuitem, gpointer user_data) { char* src_filename; const char *dst_filename; const char *dst_filename2; char filename[128]; if (tilp_calc_rom_dump()) return; src_filename = g_strconcat(g_get_tmp_dir(), G_DIR_SEPARATOR_S, TMPFILE_ROMDUMP, NULL); sprintf(filename, "dump%s", tifiles_model_to_string(options.calc_model)); dst_filename = create_fsel(local.cwdir, filename, "*.rom", TRUE); if (!dst_filename) { g_free(src_filename); return; } if (!strcmp(tifiles_fext_get(dst_filename), "")) dst_filename2 = g_strconcat(dst_filename, ".", "rom", NULL); else dst_filename2 = g_strdup(dst_filename); //g_free((void *)dst_filename); if (dst_filename2) { tilp_file_move_with_check(src_filename, dst_filename2); } g_free(src_filename); g_free((void *)dst_filename2); tilp_dirlist_local(); clist_refresh(); labels_refresh(); }
GLADE_CB void on_button9_clicked (GtkButton *button, gpointer user_data) { const gchar *filename; FILE *f; gchar *txt; GtkTextIter start, end; filename = create_fsel(inst_paths.home_dir, "log_link.txt", "*.txt", TRUE); if (!filename) return; f = fopen(filename, "wt"); if(f == NULL) return; gtk_text_buffer_get_bounds(txtbuf, &start, &end); txt = gtk_text_buffer_get_text(txtbuf, &start, &end, TRUE); printf("<%s>\n", txt); fwrite(txt, strlen(txt), 1, f); fclose(f); }
TILP_EXPORT void on_sc_save1_activate(GtkMenuItem * menuitem, gpointer user_data) { GdkPixbuf *pixbuf; gboolean result = FALSE; GError *error = NULL; const gchar *type; const gchar *filename = NULL; if(screen_success == FALSE) return; switch (options.screen_format) { case XPM: type = "xpm"; filename = create_fsel(local.cwdir, "screenshot.xpm", "*.xpm", TRUE); if (!filename) return; pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(scrn_img)); result = gdk_pixbuf_save(pixbuf, filename, type, &error, NULL); break; case BMP: type = "bmp"; filename = create_fsel(local.cwdir, "screenshot.bmp", "*.bmp", TRUE); if (!filename) return; pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(scrn_img)); result = gdk_pixbuf_save(pixbuf, filename, type, &error, NULL); break; case JPG: type = "jpeg"; filename = create_fsel(local.cwdir, "screenshot.jpg", "*.jpg", TRUE); if (!filename) return; pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(scrn_img)); result = gdk_pixbuf_save(pixbuf, filename, type, &error, "quality", "100", NULL); break; case PNG: type = "png"; filename = create_fsel(local.cwdir, "screenshot.png", "*.png", TRUE); if (!filename) return; pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(scrn_img)); result = gdk_pixbuf_save(pixbuf, filename, type, &error, NULL); break; case PDF: type = "pdf"; filename = create_fsel(local.cwdir, "screenshot.pdf", "*.pdf", TRUE); if (!filename) return; result = screen_write_pdf(filename, &error); break; case EPS: type = "eps"; filename = create_fsel(local.cwdir, "screenshot.eps", "*.eps", TRUE); if (!filename) return; result = screen_write_eps(filename, &error); break; default: type = ""; break; } if (result == FALSE) { tilp_warning("Failed to save pixbuf file: %s: %s\n", filename, error->message); g_error_free(error); } filename = NULL; }