TILP_EXPORT void on_manual1_activate(GtkMenuItem* menuitem, gpointer user_data) { gchar *path = g_strconcat(inst_paths.help_dir, _("Manual_en.html"), NULL); if(go_to_bookmark(path) < 0) msg_box1(_("Error"), _("Failed to run browser.")); g_free(path); }
int tiemu_file_delete(const char *f) { if(g_unlink(f) < 0) { msg_box1(_("Information"), _("Unable to remove the file !")); return -1; } return 0; }
GLADE_CB void on_transient1_activate (GtkMenuItem *menu_item, gpointer user_data) { // This make dbg wnd's as children of the main window. // Thus, the taskbar is not filled-up with a lot of windows. options3.transient = GTK_CHECK_MENU_ITEM(menu_item)->active; msg_box1(_("Warning"), _("You will have to save configuration and restart TiEmu for changes to take effect!")); }
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; }
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; }
int tiemu_file_move(const char *src, const char *dst) { if(tiemu_file_copy(src, dst) < 0) //if(g_rename(src, dst) < 0) { msg_box1(_("Information"), _("Unable to move file.\n\n")); return -1; } tiemu_file_delete(src); return 0; }
int tiemu_file_mkdir(const char *pathname) { #ifdef __WIN32__ if(g_mkdir(pathname, S_IRWXU) < 0) #else if(g_mkdir(pathname, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) < 0) #endif { msg_box1(_("Information"), _("Unable to create the directory.\n\n")); return -1; } 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; }
GLADE_CB void qs_filechooserbutton1_current_folder_changed (GtkFileChooser *filechooser, gpointer user_data) { gchar *fname = gtk_file_chooser_get_filename (filechooser); if(!fname) return; if(!tifiles_file_is_ti(fname) || !tifiles_calc_is_ti9x(tifiles_file_get_model(fname)) || !tifiles_file_test(fname, TIFILE_REGULAR, CALC_NONE)) { g_free(tmp_file); tmp_file = NULL; msg_box1(_("Error"), _("This file is not a valid TI file.")); return; } g_free(tmp_file); tmp_file = g_strdup(fname); // dup or copy??? }
static int hwkey_to_tikey(guint16 hardware_keycode, int action) { int i; for(i = 0; i < KEYMAP_MAX; i++) { int ti_key, modifier; if(kbd_keymap[i].pc_key == hardware_keycode) { ti_key = kbd_keymap[i].ti_key; modifier = kbd_keymap[i].modifier; if(options.kbd_dbg) { gchar *str; str = g_strdup_printf("%s:%s,%s\n", keymap_value_to_string(pckeys, hardware_keycode), keymap_value_to_string(tikeys, ti_key), keymap_value_to_string(tikeys, modifier)); msg_box1(_("Information"), str); g_free(str); } if(modifier != -1) { ti68k_kbd_set_key(modifier, action); kp_recording_key(modifier, action); } ti68k_kbd_set_key(ti_key, action); kp_recording_key(ti_key, action); return !0; } } return 0; }
/* Try and move a file. If file already exists, ask for an action (skip, overwrite or rename) Return 0 if skipped. */ int tiemu_file_move_with_check(const char *src, const char *dst) { char *dst2; if (tiemu_file_check(dst, &dst2)) { if (tiemu_file_move(src, dst2)) { msg_box1(_("Error"), _("Unable to move the temporary file.\n")); g_free(dst2); return 0; } } else { g_free(dst2); return 0; } g_free(dst2); return !0; }
int fs_send_files(gchar **filenames) { gchar **ptr; int i, l; // check extension and send for(ptr = filenames, l = 0; *ptr; ptr++, l++); for(ptr = filenames, i = 0; *ptr; ptr++, i++) { if(!tifiles_file_is_ti(*ptr) || (!tifiles_calc_is_ti9x(tifiles_file_get_model(*ptr)) && !tifiles_file_is_tigroup(*ptr))) { msg_box1(_("Error"), _("This file is not a valid TI file.")); g_strfreev(filenames); return -1; } fs_send_file(*ptr); } return 0; }
GLADE_CB void on_dockmode1_activate (GtkMenuItem *menu_item, gpointer user_data) { msg_box1(_("Warning"), _("TiEmu is about to restart...")); #ifndef NO_GDB // In GDB mode, we have to restart the engine here, otherwise // gtk_debugger_close will call gdbcall_continue to do so and never // return. engine_start(); #endif gtk_debugger_close(); // Stop the engine before calling gtk_main_quit. // Otherwise, it will keep running even when it is supposed to have // been stopped by the debugger. engine_stop(); if(options3.dbg_dock) gtk_widget_destroy(dbgw.dock); options3.dbg_dock = GTK_CHECK_MENU_ITEM(menu_item)->active; gtk_main_quit(); }
int import_romversion(const char *filename) { char *dstname; int err; 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)) { #ifdef _MSC_VER IMG_INFO infos = {0}; #else IMG_INFO infos = {}; #endif int hw_type = HW2; err = ti68k_get_tib_infos(filename, &infos, 0); handle_error(); if (!err) { 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; } else if(infos.calc_type == TI89t) { int ret = msg_box3(_("HW type"), _("The FLASH upgrade can be imported as HW3 or HW4. Please choose..."), "HW3", "HW4", "Default"); hw_type = HW3; // default is HW3 for the Titanium, there's no Titanium HW2 if(ret == BUTTON1) hw_type = HW3; else if(ret == BUTTON2) hw_type = HW4; } } // fake rom err = ti68k_convert_tib_to_image(filename, inst_paths.img_dir, &dstname, hw_type); handle_error(); g_free(dstname); } else { msg_box1(_("Error"), _("This is not a valid file")); return -1; } return 0; }
int go_to_bookmark(const char *link) { #ifdef __WIN32__ HINSTANCE hInst; // Windows do the whole work for us, let's go... hInst = ShellExecute(NULL, "open", link, NULL, NULL, SW_SHOWNORMAL); if((int)hInst <= 32) { //msg_box("Error", "Unable to run ShellExecute extension."); return -1; } #else // Kevin's list: // These ones should be first, as they will honor the user's choice rather // than guessing an arbitrary one: // * /usr/bin/xdg-open (runs the default browser of the desktop environment // currently in use, this is the best solution) // * /usr/bin/gnome-open (GNOME 2.6+ default browser, user-configurable) // Distro-specific browser wrapper scripts: // * /usr/bin/sensible-browser (Debian's browser script) // * /usr/bin/htmlview (old RHL/Fedora default browser script, current // versions will honor the GNOME browser preference) // Fallback to a hardcoded list of browsers: // * /usr/bin/firefox (Mozilla Firefox) // * /usr/bin/seamonkey (Seamonkey) // * /usr/bin/konqueror (Konqueror) // * /usr/bin/mozilla (old Mozilla Suite) // gboolean result; static const char *apps[] = { "/usr/bin/xdg-open", "/usr/bin/gnome-open", "/usr/bin/sensible-browser", "/usr/bin/htmlview", "/usr/bin/firefox", "/usr/bin/seamonkey", "/usr/bin/konqueror", "/usr/bin/mozilla", }; gint i, n; n = sizeof(apps) / sizeof(apps[0]); for(i = 0; i < n; i++) { gchar **argv = g_malloc0(3 * sizeof(gchar *)); argv[0] = g_strdup(apps[i]); argv[1] = g_strdup(link); argv[2] = NULL; result = g_spawn_async(NULL, argv, NULL, 0, NULL, NULL, NULL, NULL); g_strfreev(argv); if(result != FALSE) break; } if (i == n) { msg_box1("Error", "Spawn error: do you have Firefox installed ?"); return -1; } #endif else { const gchar *message = _("A web browser has been launched: this may take a while before it appears. If it is already launched, the page may be opened in the existing frame."); GTimer *timer; msg_box("Information", message, !0); for(timer = g_timer_new(); g_timer_elapsed(timer, NULL) < 3.0;); g_timer_destroy(timer); msg_box("", "", 0); } return 0; }