From 2feebae63c682e5e133e2b93f592d0c0be159584 Mon Sep 17 00:00:00 2001 From: Scott Duensing Date: Sun, 4 Jun 2023 19:24:32 -0500 Subject: [PATCH] Can configure custom JoeyLib for application builds. Not implemented in the build code yet. --- include/project.h | 4 + src/project.c | 158 ++++++++++++++++++++++++++++++++++++- src/results.c | 3 + ui/ProjectProperties.glade | 123 ++++++++++++++++++++++++----- 4 files changed, 267 insertions(+), 21 deletions(-) diff --git a/include/project.h b/include/project.h index 053aec6..c0a053f 100644 --- a/include/project.h +++ b/include/project.h @@ -41,6 +41,7 @@ typedef struct ProjectDataS { StringHashT **recipes; char *projectType; char *projectName; + char *projectJoeyLib; char *configName; char *buildHost; int buildHTTPPort; @@ -50,6 +51,9 @@ typedef struct ProjectDataS { TargetT **targets; void *buildResults; // Managed by results.c GtkWidget *tempWidget; // Used to pass data around dialogs. + GtkWidget *tempWidget2; // Used to pass data around dialogs. + GtkWidget *tempWidget3; // Used to pass data around dialogs. + GtkWidget *tempWidget4; // Used to pass data around dialogs. int tempInteger; // Used during recipe building. } ProjectDataT; diff --git a/src/project.c b/src/project.c index 645bb98..a85790e 100644 --- a/src/project.c +++ b/src/project.c @@ -96,10 +96,13 @@ EVENT void btnEditRawClicked(GtkButton *widget, gpointer userData); EVENT void btnEditRecipeClicked(GtkButton *widget, gpointer userData); EVENT void btnNewRecipeClicked(GtkButton *widget, gpointer userData); static void clearRecipeData(ProjectDataT *self); +EVENT void comboProjectTypeChanged(GtkComboBox *object, gpointer userData); static void cookFinished(CompilerContextT **context); static void decompressBuild(ArchiveT *archive); static void dialogCookOptions(char *filename, ProjectDataT *self); +EVENT void fileCustomSet(GtkWidget *object, gpointer userData); static int findRecipeData(ProjectDataT *self, char *key); +static gboolean isCustomJoeyLibProject(char *filename); static void loadConfig(ProjectDataT *self); static void loadProject(ProjectDataT *self); EVENT void menuProjectFileNew(GtkWidget *object, gpointer userData); @@ -224,6 +227,26 @@ static void clearRecipeData(ProjectDataT *self) { } +EVENT void comboProjectTypeChanged(GtkComboBox *object, gpointer userData) { + ProjectDataT *self = (ProjectDataT *)userData; + char *temp = NULL; + + temp = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(object)); + if (strcmp(temp, "JoeyLib") == 0) { + // JoeyLib project - Disable JoeyLib settings. + gtk_widget_set_sensitive(self->tempWidget, FALSE); + gtk_widget_set_sensitive(self->tempWidget2, FALSE); + gtk_widget_set_sensitive(self->tempWidget3, FALSE); + } else { + // Application project - Enable JoeyLib settings. + gtk_widget_set_sensitive(self->tempWidget, TRUE); + gtk_widget_set_sensitive(self->tempWidget2, TRUE); + gtk_widget_set_sensitive(self->tempWidget3, TRUE); + } + DEL(temp); +} + + static void cookFinished(CompilerContextT **context) { CompilerContextT *ctx = *context; ProjectDataT *self = (ProjectDataT *)ctx->userData; @@ -344,6 +367,31 @@ static void dialogCookOptions(char *filename, ProjectDataT *self) { } +EVENT void fileCustomSet(GtkWidget *object, gpointer userData) { + ProjectDataT *self = (ProjectDataT *)userData; + char *temp = NULL; + gboolean isJoeyLib = FALSE; + + temp = (char *)gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(object)); + isJoeyLib = isCustomJoeyLibProject(temp); + DEL(temp); + + if (isJoeyLib == FALSE) { + utilMessageDialog(self->tempWidget4, + "Not a Custom JoeyLib Project", + "The selected project is not a custom JoeyLib library project."); + // Deselect custom JoeyLib. + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(self->tempWidget), TRUE); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(self->tempWidget2), FALSE); + gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(self->tempWidget3), ""); + } else { + // Select custom JoeyLib. + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(self->tempWidget), FALSE); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(self->tempWidget2), TRUE); + } +} + + static int findRecipeData(ProjectDataT *self, char *key) { int i; int result = -1; @@ -359,6 +407,40 @@ static int findRecipeData(ProjectDataT *self, char *key) { } +static gboolean isCustomJoeyLibProject(char *filename) { + FILE *in = NULL; + char *line = NULL; + size_t len = 0; + char *c = NULL; + gboolean isJoeyLib = FALSE; + + // Is this project a custom JoeyLib project? + in = fopen(filename, "rt"); + if (in != NULL) { + utilEnsureBufferSize((unsigned char **)&line, (int *)&len, 1024); // Not technically needed, but fixes a pointer warning from memmaker. + while (utilGetLine(&line, &len, in) != -1) { + if (strlen(line) > 0) line[strlen(line) - 1] = 0; + c = utilGetToken(line, " ", "\"", "\""); + utilDequote(c); + + // Is this a 'project' line? + if (strcasecmp(c, "project") == 0) { + c = utilGetToken(NULL, " ", "\"", "\""); + utilDequote(c); + if (strcmp(c, "JoeyLib") == 0) { + isJoeyLib = TRUE; + } + break; + } + } + fclose(in); + DEL(line); + } + + return isJoeyLib; +} + + static void loadConfig(ProjectDataT *self) { FILE *in = NULL; char *line = NULL; @@ -506,6 +588,7 @@ static void loadProject(ProjectDataT *self) { addToRecipeData(self, raw, __utilFilenameBuffer); } DEL(raw); + continue; } // Is this a 'project' line? @@ -518,6 +601,16 @@ static void loadProject(ProjectDataT *self) { utilDequote(c); DEL(self->projectName); self->projectName = strdup(c); + continue; + } + + // Is this a 'joeylib' line? + if (strcasecmp(c, "joeylib") == 0) { + c = utilGetToken(NULL, " ", "\"", "\""); + utilDequote(c); + DEL(self->projectJoeyLib); + self->projectJoeyLib = strdup(c); + continue; } } @@ -576,8 +669,10 @@ EVENT void menuProjectFileNew(GtkWidget *object, gpointer userData) { // Clear project properties. DEL(self->projectName); DEL(self->projectType); - self->projectType = strdup("Application"); - self->projectName = strdup("None"); + DEL(self->projectJoeyLib); + self->projectType = strdup("Application"); + self->projectName = strdup("None"); + self->projectJoeyLib = strdup("Latest"); // Nuke filename & mark clean. DEL(self->windowData.filename); @@ -625,6 +720,7 @@ EVENT void menuProjectFileSave(GtkWidget *object, gpointer userData) { fprintf(out, "------------------------------------------------------------------------------\n"); // Write out project properties. fprintf(out, "project \"%s\" \"%s\"\n", self->projectType, self->projectName); + fprintf(out, "joeylib \"%s\"\n", self->projectJoeyLib); // Write out file list. gtk_tree_model_get_iter_first(model, &iter); do { @@ -782,6 +878,9 @@ EVENT void menuProjectProjectProperties(GtkWidget *object, gpointer userData) { GtkWidget *dialogProperties; GtkWidget *comboType; GtkWidget *txtName; + GtkWidget *radioLatest; + GtkWidget *radioCustom; + GtkWidget *fileCustom; (void)object; @@ -790,34 +889,60 @@ EVENT void menuProjectProjectProperties(GtkWidget *object, gpointer userData) { "dialogProjectProperties", "comboProjectType", "txtProjectName", + "radioLatest", + "radioCustom", + "fileCustom", NULL }; GtkWidget **widgets[] = { &dialogProperties, &comboType, - &txtName + &txtName, + &radioLatest, + &radioCustom, + &fileCustom }; GtkEntryBuffer *buffer; int result; utilGetWidgetsFromMemory("/com/kangaroopunch/joeydev/ProjectProperties.glade", widgetNames, widgets, self); + // Save for callbacks. + self->tempWidget = radioLatest; + self->tempWidget2 = radioCustom; + self->tempWidget3 = fileCustom; + self->tempWidget4 = dialogProperties; + + // What kind of project is this? if (strcmp(self->projectType, "JoeyLib") == 0) { gtk_combo_box_set_active(GTK_COMBO_BOX(comboType), 1); } else { gtk_combo_box_set_active(GTK_COMBO_BOX(comboType), 0); + // Which JoeyLib are we using? + if (strcmp(self->projectJoeyLib, "Latest") == 0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radioLatest), TRUE); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radioCustom), FALSE); + gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(fileCustom), ""); + } else { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radioLatest), FALSE); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radioCustom), TRUE); + gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(fileCustom), self->projectJoeyLib); + } } + comboProjectTypeChanged(GTK_COMBO_BOX(comboType), self); buffer = gtk_entry_get_buffer(GTK_ENTRY(txtName)); gtk_entry_buffer_set_text(GTK_ENTRY_BUFFER(buffer), self->projectName, strlen(self->projectName)); result = gtk_dialog_run(GTK_DIALOG(dialogProperties)); if (result == GTK_RESPONSE_OK) { + // Did the project name change? if (strcmp(self->projectName, gtk_entry_buffer_get_text(GTK_ENTRY_BUFFER(buffer))) != 0) { DEL(self->projectName); self->projectName = strdup(gtk_entry_buffer_get_text(GTK_ENTRY_BUFFER(buffer))); utilSetDirty((WindowDataT *)self, TRUE); } + // Did the project type change? temp = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(comboType)); if (strcmp(self->projectType, temp) != 0) { DEL(self->projectType); @@ -825,6 +950,29 @@ EVENT void menuProjectProjectProperties(GtkWidget *object, gpointer userData) { utilSetDirty((WindowDataT *)self, TRUE); } DEL(temp); + // Is it an application project? + if (strcmp(self->projectType, "JoeyLib") != 0) { + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radioLatest))) { + temp = strdup("Latest"); + } else { + temp = (char *)gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(fileCustom)); + if (!isCustomJoeyLibProject(temp)) { + DEL(temp); + temp = strdup("Latest"); + utilMessageDialog(dialogProperties, + "Not a Custom JoeyLib Project", + "The selected project is not a custom JoeyLib library project.\n" + "Using the latest build instead."); + } + } + // Did the desired JoeyLib change? + if (strcmp(self->projectJoeyLib, temp) != 0) { + DEL(self->projectJoeyLib); + self->projectJoeyLib = strdup(temp); + utilSetDirty((WindowDataT *)self, TRUE); + } + DEL(temp); + } } gtk_widget_destroy(dialogProperties); @@ -1059,6 +1207,8 @@ EVENT void menuProjectBuildBuild(GtkWidget *object, gpointer userData) { gboolean archPrinted; FILE *out; + //***TODO*** This needs to support building with custom JoeyLib libraries. + messageShow(); ssh = sshConnect(self->buildHost, self->buildSSHPort, self->buildUser, self->buildPassword); @@ -1088,6 +1238,8 @@ EVENT void menuProjectBuildBuild(GtkWidget *object, gpointer userData) { fprintf(out, "%s\n", self->projectType); // Write it's title. fprintf(out, "%s\n", self->projectName); + // Write the JoeyLib to use. + fprintf(out, "%s\n", self->projectJoeyLib); ///***TODO*** Paths to a custom JoeyLib mean nothing to JoeyBuild. // Write desired build targets. for (i=0; itargets); i++) { archPrinted = FALSE; diff --git a/src/results.c b/src/results.c index 99f5674..d5428bf 100644 --- a/src/results.c +++ b/src/results.c @@ -65,6 +65,8 @@ EVENT void messageClicked(GtkButton *widget, gpointer userData) { size_t column; gboolean isWarning; + (void)isWarning; + // Extract info from button name. tok = strdup(name); temp = strtok(tok, ":"); @@ -191,6 +193,7 @@ static void resultParseRaw(gboolean release, char **lineArray, ResultsDataT *sel temp = strtok(NULL, ":"); column = atol(temp) - 1; DEL(tok); + //***TODO*** Keep a list per-file so we can add markers to the editor. } // --- The above is basically GCC only. And lame. diff --git a/ui/ProjectProperties.glade b/ui/ProjectProperties.glade index 96d5205..7038bf6 100644 --- a/ui/ProjectProperties.glade +++ b/ui/ProjectProperties.glade @@ -5,10 +5,15 @@ 15 + + + *.joe + + False Project Properties - 300 + 400 200 dialog @@ -62,7 +67,7 @@ center vertical - + True False @@ -73,25 +78,13 @@ True False end - Project Type: + Project Name: 0 0 - - - True - False - end - Project Name: - - - 0 - 1 - - True @@ -102,7 +95,7 @@ 1 - 1 + 0 @@ -115,15 +108,109 @@ Application JoeyLib + - + False + Application 1 - 0 + 1 + + + + + True + False + end + Project Type: + + + 0 + 1 + + + + + True + False + end + start + JoeyLib: + + + 0 + 2 + + + + + True + False + vertical + + + Latest Official Build + True + True + False + True + True + + + False + True + 0 + + + + + True + False + + + Custom: + True + True + False + True + True + radioLatest + + + False + True + 0 + + + + + True + False + filefilterProjects + + + + + False + True + 1 + + + + + False + True + 1 + + + + + 1 + 2