debug : simple working area access

This commit is contained in:
Jean Sirmai 2024-05-23 15:59:14 +02:00
parent 310340a17e
commit 4cc6bda354
Signed by: jean
GPG Key ID: FB3115C340E057E3
4 changed files with 43 additions and 8 deletions

View File

@ -133,6 +133,7 @@ void ui_model_loading(GObject *source_object,
GAsyncResult *result,
GemGraphClientWindow *self);
void ui_debug_model_loading (GemGraphClientWindow *self, const char *file);
//
// General events
//

View File

@ -71,7 +71,10 @@ static void gem_graph_client_application_activate(GApplication *app)
"application", app,
NULL);
// Launch with sidebar off
ui_toggle_sidebar();
ui_set_stack(HOME_MODE);
ui_debug_model_loading(window, "data/models/dimers random walk.xml");
gtk_window_present(window);
}

View File

@ -23,6 +23,7 @@
*/
#include <stdio.h>
#include <libgen.h>
#include "../../include/base.h"
#include "../../include/graphics.h"
@ -325,7 +326,7 @@ void ui_model_loading(GObject *source_object,
size_t length = 0;
GError *error = NULL;
char *basename = g_file_get_basename(file);
char *basenamestr = g_file_get_basename(file);
// Gives you the contents of the file as a byte array, or
// set the error argument
@ -343,14 +344,14 @@ void ui_model_loading(GObject *source_object,
error->message);
ui_send_internal_notification("Unable to open file !");
g_free(error);
g_free(basename);
g_free(basenamestr);
g_free(content);
return;
}
if (model_init(content, length, basename) == false) {
if (model_init(content, length, basenamestr) == false) {
ui_send_internal_notification("Error while loading the model");
g_free(basename);
g_free(basenamestr);
g_free(content);
return;
}
@ -363,10 +364,43 @@ void ui_model_loading(GObject *source_object,
ui_enable_action("togglesidebar");
ui_set_stack(RUN_MODE);
g_free(basename);
g_free(basenamestr);
g_free(content);
}
void ui_debug_model_loading (GemGraphClientWindow *self, const char *file)
{
char *content = NULL;
size_t length = 0;
char *basenamestr = basename(file);
content = read_file (file);
length = strlen (content);
/* // In case of error, print a warning to the standard error output */
/* if (error != NULL) { */
/* g_printerr("Unable to open “%s”: %s\n", */
/* g_file_peek_path(file), */
/* error->message); */
/* ui_send_internal_notification("Unable to open file !"); */
/* return; */
/* } */
if (model_init(content, length, basenamestr) == false) {
ui_send_internal_notification("Error while loading the model");
return;
}
ui_enable_action("closefile");
ui_enable_action("savefile");
ui_enable_action("runmode");
ui_enable_action("editmode");
ui_enable_action("presentmode");
ui_enable_action("togglesidebar");
ui_set_stack(RUN_MODE);
ui_toggle_sidebar();
}
/* -------------------------------------------------------------------------- */
/*

View File

@ -123,9 +123,6 @@ static void gem_graph_client_window_init(GemGraphClientWindow *self)
{
gtk_widget_init_template(GTK_WIDGET(self));
window = self;
// Launch with sidebar off
ui_toggle_sidebar();
}
/* -------------------------------------------------------------------------- */