From 0d129d54814fe8ae5ac7704143a9ae5026c03b4f Mon Sep 17 00:00:00 2001 From: osxmidi Date: Wed, 9 Aug 2023 15:34:39 +1000 Subject: [PATCH] Add files via upload --- convert/linvstconvertgtk.cpp | 101 +++++++++++++++++++++++++++++++++-- 1 file changed, 96 insertions(+), 5 deletions(-) diff --git a/convert/linvstconvertgtk.cpp b/convert/linvstconvertgtk.cpp index f8140d48..aecbb0c6 100644 --- a/convert/linvstconvertgtk.cpp +++ b/convert/linvstconvertgtk.cpp @@ -15,6 +15,7 @@ int filecopy = 0; int intimer = 0; + int dofullup = 0; int vst2filehit = 0; size_t find_last(std::string searchstr, std::string searcharg) @@ -85,13 +86,30 @@ if(vst2filehit == 1) { + if(dofullup == 1) + { std::string sourcename = linvst; std::ifstream source(sourcename.c_str(), std::ios::binary); std::ofstream dest(convertname.c_str(), std::ios::binary); dest << source.rdbuf(); source.close(); dest.close(); - } + } + else + { + test = std::ifstream(convertname).good(); + + if(!test) + { + std::string sourcename = linvst; + std::ifstream source(sourcename.c_str(), std::ios::binary); + std::ofstream dest(convertname.c_str(), std::ios::binary); + dest << source.rdbuf(); + source.close(); + dest.close(); + } + } + } } if(fs) @@ -139,7 +157,18 @@ filehit = 1; gboolean dolabelupdate(gpointer data) { - gtk_button_set_label(GTK_BUTTON (data), "Start"); + gtk_button_set_label(GTK_BUTTON (data), "Update Newly Added Plugins"); + + intimer = 0; + + return FALSE; + +} + +gboolean dolabelupdate2(gpointer data) +{ + + gtk_button_set_label(GTK_BUTTON (data), "Update All Plugins (Upgrade All Plugins)"); intimer = 0; @@ -201,15 +230,72 @@ void buttoncallback(GtkFileChooser *button, gpointer data) } +void buttoncallback2(GtkFileChooser *button, gpointer data) +{ + std::string name; + + if((filehit == 1) && (folderhit == 1) && (intimer == 0)) + { + + name = filepath; + + if(name.find("linvst.so") == std::string::npos) + { + gtk_button_set_label(GTK_BUTTON (button), "Not Found"); + + filecopy = 0; + filehit = 0; + folderhit = 0; + + intimer = 1; + + g_timeout_add_seconds(3, dolabelupdate2, (GtkWidget *)data); + + return; + } + + dofullup = 1; + + if(doconvert(filepath, folderpath) == 1) + { + gtk_button_set_label(GTK_BUTTON (button), "Not Found"); + + filecopy = 0; + filehit = 0; + folderhit = 0; + dofullup = 0; + + intimer = 1; + + g_timeout_add_seconds(3, dolabelupdate2, (GtkWidget *)data); + + return; + } + + filecopy = 0; + filehit = 1; + folderhit = 0; + dofullup = 0; + + gtk_button_set_label(GTK_BUTTON (button), "Done"); + + intimer = 1; + + g_timeout_add_seconds(3, dolabelupdate2, (GtkWidget *)data); + +} +} + + int main (int argc, char *argv[]) { - GtkWidget *window, *folderselect, *fileselect, *spacertext, *spacertext2, *spacertext3, *vbox, *button; + GtkWidget *window, *folderselect, *fileselect, *spacertext, *spacertext2, *spacertext3, *vbox, *button, *button2; GtkFileFilter *extfilter; gtk_init (&argc, &argv); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_default_size (GTK_WINDOW (window), 300, 300); + gtk_window_set_default_size (GTK_WINDOW (window), 600, 300); gtk_window_set_title (GTK_WINDOW (window), "LinVst"); gtk_container_set_border_width (GTK_CONTAINER (window), 8); @@ -221,7 +307,10 @@ int main (int argc, char *argv[]) fileselect = gtk_file_chooser_button_new ("Choose linvst.so", GTK_FILE_CHOOSER_ACTION_OPEN); button = gtk_button_new (); - gtk_button_set_label(GTK_BUTTON (button), "Start"); + gtk_button_set_label(GTK_BUTTON (button), "Update Newly Added Plugins"); + + button2 = gtk_button_new (); + gtk_button_set_label(GTK_BUTTON (button2), "Update All Plugins (Upgrade All Plugins)"); vbox = gtk_vbox_new (FALSE, 8); gtk_box_pack_start(GTK_BOX (vbox), spacertext, FALSE, FALSE, 0); @@ -230,11 +319,13 @@ int main (int argc, char *argv[]) gtk_box_pack_start(GTK_BOX (vbox), folderselect, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX (vbox), spacertext3, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX (vbox), button, FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX (vbox), button2, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (quitcallback), NULL); g_signal_connect (G_OBJECT (folderselect), "selection_changed", G_CALLBACK (foldercallback), NULL); g_signal_connect (G_OBJECT (fileselect), "selection_changed", G_CALLBACK (filecallback), NULL); g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (buttoncallback), button); + g_signal_connect (G_OBJECT (button2), "clicked", G_CALLBACK (buttoncallback2), button2); gtk_file_chooser_set_show_hidden(GTK_FILE_CHOOSER(folderselect), TRUE); gtk_file_chooser_set_show_hidden(GTK_FILE_CHOOSER(fileselect), TRUE);