You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ublexec/source/main.cc

87 lines
1.9 KiB

#include <cstddef>
#include <cstdlib>
#include <iostream>
#include <memory>
#include <gtkmm.h>
#include <ostream>
#include <string>
#include <ctime>
#include <vector>
#include <map>
#include <fstream>
#include <filesystem>
#include <libintl.h>
#include <locale.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <stdio.h>
#include <gtkmm/plug.h>
#include <gtkmm/stock.h>
#include <gtkmm/window.h>
#include <string>
#include <gtkmm.h>
#include <gtkmm/plug.h>
#include <string>
#include <iostream>
#include <filesystem>
#include <iostream>
#include <sys/types.h>
#include <pwd.h>
#include <set>
#include "ublexec.h"
int main(int argc, char** argv)
{
string str_cmd_argv = "";
for (int i=1; i<argc; i++){
str_cmd_argv+= to_string(*argv[i]) + " ";
}
if (geteuid()!=0){
string cmd = "pkexec " + app_name + " " + str_cmd_argv ;
system(cmd.c_str());
return 0;
}
auto app = Gtk::Application::create(argc, argv, "org.gtkmm.example.plug");
auto builder = Gtk::Builder::create_from_file(path_glade);
bindtextdomain("ublexec", "/usr/share/locale/");
bind_textdomain_codeset("ublexec", "UTF-8");
textdomain("ublexec");
if (argc!=1){
Glib::init();
setlocale(LC_ALL, "");
Glib::OptionContext context;
CmdArgParser parser{
"Socket ID",
"Command line argument for socket ID communication.",
"No help available, sorry"
};
context.set_main_group(parser);
context.parse(argc, argv);
::Window socketID = parser.GetSocketID();
// Handle plug:
SettingsPlug plug{socketID, builder};
plug.show();
app->run(plug);
return 0;
}
else {
MainWindow* wnd = nullptr;
builder->get_widget_derived("window", wnd);
auto r = app->run(*wnd);
delete wnd;
return r;
}
}