From 694a58fda7065ddb8ac8f0783e3b8717c58c8d29 Mon Sep 17 00:00:00 2001 From: daleclack Date: Thu, 23 Sep 2021 14:09:32 +0800 Subject: [PATCH] Update gtk108 --- Gtkmm3/gtk108_settings/src/main.cc | 14 +++++++++++++- c/args.c | 6 ++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Gtkmm3/gtk108_settings/src/main.cc b/Gtkmm3/gtk108_settings/src/main.cc index f69aa65..d5fb89b 100644 --- a/Gtkmm3/gtk108_settings/src/main.cc +++ b/Gtkmm3/gtk108_settings/src/main.cc @@ -1,8 +1,20 @@ #include "MyWin.hh" +#define bin_str 6 int main(int argc,char **argv){ + //Get binary dir + const char * src = *argv; + int len = strlen(src); //argv[0] + char * tmp = (char*)malloc(len); +#ifdef _WIN32 + strncpy(tmp,src,len-bin_str-4); + tmp[len-bin_str-4]='\0'; +#else + strncpy(tmp,src,len-bin_str); + tmp[len-bin_str]='\0'; +#endif //Initalize env - Glib::setenv("GSETTINGS_SCHEMA_DIR",".",false); + Glib::setenv("GSETTINGS_SCHEMA_DIR",tmp,false); //Create a application and run auto app=Gtk::Application::create(argc,argv,"org.gtk.daleclack"); diff --git a/c/args.c b/c/args.c index 816d9ad..ca8953e 100644 --- a/c/args.c +++ b/c/args.c @@ -6,7 +6,13 @@ int main(int argc,char **argv){ const char * src = *argv; int len = strlen(src); //argv[0] char * tmp = malloc(len); +#ifdef _WIN32 + strncpy(tmp,src,len-8); + tmp[len-8]='\0'; +#else strncpy(tmp,src,len-4); + tmp[len-4]='\0'; +#endif printf("%s\n",tmp); free(tmp); return 0;