Exemple #1
0
void rdiswindow_open (GtkMenuItem * menuItem, struct _rdiswindow * rdiswindow)
{
    GtkWidget * dialog;

    dialog = gtk_file_chooser_dialog_new(LANG_OPENRDISFILE,
                                         GTK_WINDOW(rdiswindow->window),
                                         GTK_FILE_CHOOSER_ACTION_OPEN,
                                         GTK_STOCK_CANCEL,
                                         GTK_RESPONSE_CANCEL,
                                         GTK_STOCK_OPEN,
                                         GTK_RESPONSE_ACCEPT,
                                         NULL);

    if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
    {
        char * filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
        char tmp[256];

        json_error_t json_error;
        json_t * json = json_load_file(filename, 0, &json_error);
        if (json == NULL) {
            snprintf(tmp, 256, "json error: %s", json_error.text);
            gui_console(rdiswindow->gui, tmp);
        }
        else {
            struct _rdis * rdis = rdis_deserialize(json);
            if (rdis == NULL) {
                snprintf(tmp, 256, "rdis deserialize error # %d\n", serialize_error);
                gui_console(rdiswindow->gui, tmp);
            }
            else {
                gui_close_windows(rdiswindow->gui);
                gui_set_rdis(rdiswindow->gui, rdis);
                snprintf(tmp, 256, "opened file %s", filename);
                gui_console(rdiswindow->gui, tmp);
            }
            json_decref(json);
        }
        g_free(filename);
    }

    gtk_widget_destroy(dialog);
}
Exemple #2
0
void rdiswindow_load (GtkMenuItem * menuItem, struct _rdiswindow * rdiswindow)
{
    GtkWidget * dialog;

    dialog = gtk_file_chooser_dialog_new(LANG_LOADEXECFILE,
                                         GTK_WINDOW(rdiswindow->window),
                                         GTK_FILE_CHOOSER_ACTION_OPEN,
                                         GTK_STOCK_CANCEL,
                                         GTK_RESPONSE_CANCEL,
                                         GTK_STOCK_OPEN,
                                         GTK_RESPONSE_ACCEPT,
                                         NULL);

    if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
    {
        char * filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
        char tmp[256];

        _loader * loader = loader_create(filename);

        if (loader == NULL)
            snprintf(tmp, 256, "failed to load executable %s", filename);
        else {
            struct _rdis * rdis;
            rdis = rdis_create_with_console(loader,
                                 (void (*) (void *, const char *)) gui_console,
                                            rdiswindow->gui);
            gui_close_windows(rdiswindow->gui);
            gui_set_rdis(rdiswindow->gui, rdis);
            snprintf(tmp, 256, "loaded executable %s", filename);
        }

        gui_console(rdiswindow->gui, tmp);

        g_free(filename);
    }

    gtk_widget_destroy(dialog);
}
Exemple #3
0
void rdis_clear_gui (struct _rdis * rdis)
{
    if (rdis->gui != NULL)
        gui_close_windows(rdis->gui);
}