master #40

Merged
asmeron merged 9 commits from Igor1/ublexec:master into develop 3 years ago

@ -13,48 +13,25 @@ int main(int argc, char** argv) {
if (argc > 1){
str_argv = argv[1];
}
if (str_argv.find("--socket-id") != std::string::npos) {
auto app = Gtk::Application::create(argc, argv, "org.gtkmm.example.plug");
auto builder = Gtk::Builder::create_from_file(path_glade);
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();
SettingsPlug plug{socketID, builder};
plug.show();
app->run(plug);
return 0;
}
else {
if (argc == 3) {
name_app_cmd = argv[2];
string str_flag = argv[1];
if (str_flag == "-x") {
flag_prog_file = 1;
}
else if (str_flag == "-e") {
flag_prog_file = 2;
}
if (argc == 3) {
name_app_cmd = argv[2];
string str_flag = argv[1];
if (str_flag == "-x") {
flag_prog_file = 1;
}
else if (str_flag == "-e") {
flag_prog_file = 2;
}
pars_flag(1,argc, argv);
int local_argc = 1;
auto app = Gtk::Application::create(local_argc, argv, "org.gtkmm.example.plug");
auto builder = Gtk::Builder::create_from_file(path_glade);
MainWindow* wnd = nullptr;
builder->get_widget_derived("window", wnd);
auto r = app->run(*wnd);
delete wnd;
return r;
}
pars_flag(1,argc, argv);
int local_argc = 1;
auto app = Gtk::Application::create(local_argc, argv, "org.gtkmm.example.plug");
auto builder = Gtk::Builder::create_from_file(path_glade);
MainWindow* wnd = nullptr;
builder->get_widget_derived("window", wnd);
auto r = app->run(*wnd);
delete wnd;
return r;
}
void pars_flag(int index_start, int argc, char* argv[]) {

@ -9,9 +9,11 @@ int socket_ext_id_I = 0;
int socket_trd_id_I = 0;
MainWindow* obj_main;
void wrapper_synopsis_show() {
void wrapper_help_show(GtkWidget *self, char* link, gpointer user_data) {
if (self && user_data) {}
obj_main->global_lick_doc = link;
obj_main->aboutWindows->hide();
obj_main->synopsis_show();
obj_main->temp_help_show();
}
CmdArgParser::CmdArgParser(const std::string& p_name, const std::string& p_description, const std::string& p_help)
@ -106,7 +108,7 @@ void MainWindow::get_builder() {
builder->get_widget("iconSystem", iconSystem);
builder->get_widget("lblSystem", lblSystem);
builder->get_widget("lblHeaderName", lblHeaderName);
builder->get_widget("btnSynopsis", btnSynopsis);
builder->get_widget("btnhelp", btnhelp);
builder->get_widget("btnAbout", btnAbout);
builder->get_widget("aboutWindows", aboutWindows);
builder->get_widget("btnSettings", btnSettings);
@ -175,7 +177,7 @@ void MainWindow::localization() {
string str_authors = string(copyright) + to_string(year);
aboutWindows->set_copyright(str_authors);
aboutWindows->set_website(website);
btnSynopsis->set_label(str_help);
btnhelp->set_label(str_help);
btnAbout->set_label(str_about_1);
aboutWindows->set_comments(define_name_app);
aboutWindows->set_website_label(home_page );
@ -187,7 +189,7 @@ void MainWindow::localization() {
btnStart->set_label(str_run);
wndChooseFileWallpaper->set_title(str_please_select_file);
dialogStartMenu->set_title(str_selecting_programs);
lblInfoHead->set_text(str_run_applications_as_another);
lblInfoHead->set_text(define_name_app);
lblinfoCmd->set_text(str_localization_cmd_line);
lblInfoTime->set_text(str_localization_team);
labInfoExecutTerm->set_text(str_run_terminal);
@ -220,14 +222,16 @@ void MainWindow::localization() {
lblwebHeaderName->set_label(name_app_1);
lblHeadeWndWeb->set_label(define_name_app);
lblwebHeaderName->set_label(define_name_app);
btnFilemaneg->set_tooltip_text(str_tooltip_filemanager);
btnListApp->set_tooltip_text(str_tooltip_list_app);
}
void MainWindow::event() {
g_signal_connect(G_OBJECT(aboutWindows->gobj()), "activate-link", G_CALLBACK(wrapper_synopsis_show), this);
g_signal_connect(G_OBJECT(aboutWindows->gobj()), "activate-link", G_CALLBACK(wrapper_help_show), this);
btnCancelHelp->signal_clicked().connect([&]() {wndShowWeb->hide();});
chkAlwaysOpenHelp->signal_toggled().connect([&]() {flag_open_browser = true;});
btnReadHelp->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::open_browser));
btnSynopsis->signal_activate().connect(sigc::mem_fun(*this, &MainWindow::synopsis_show));
btnhelp->signal_activate().connect(sigc::mem_fun(*this, &MainWindow::open_help));
btnFilemaneg->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::open_filemaneg));
btnListApp->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::open_list_app));
btnStart->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::entry_app));
@ -252,7 +256,6 @@ void MainWindow::event() {
iconOther->signal_selection_changed().connect(sigc::mem_fun(*this,&MainWindow::select_Other));
iconDevelopment->signal_selection_changed().connect(sigc::mem_fun(*this,&MainWindow::select_Development));
iconSystem->signal_selection_changed().connect(sigc::mem_fun(*this,&MainWindow::select_System));
btnSynopsis->signal_activate().connect(sigc::mem_fun(*this, &MainWindow::synopsis_show));
btnAbout->signal_activate().connect([&]() {aboutWindows->show();});
cmbUser->signal_changed().connect([&]() {changed_user();this->denamic_cmd();});
rbSudo->signal_toggled().connect(sigc::mem_fun(*this, &MainWindow::sudo_nice));
@ -353,7 +356,7 @@ bool MainWindow::focus_in_txt_cmd(GdkEventFocus* event) {
return true;
}
void MainWindow::synopsis_show() {
void MainWindow::temp_help_show() {
if (flag_open_browser == true) {
this->open_browser();
}
@ -363,26 +366,31 @@ void MainWindow::synopsis_show() {
}
void MainWindow::open_help() {
global_lick_doc = const_link_doc;
temp_help_show();
}
void MainWindow::open_browser() {
#ifdef WEBKIT_FOUND
webkit_web_view_load_uri(one, link_doc);
webkit_web_view_load_uri(one, _(global_lick_doc.c_str()));
wndWeb->show_all();
#else
this->template_open_browser();
this->template_open_browser(global_lick_doc);
#endif
wndShowWeb->hide();
}
void MainWindow::template_open_browser() {
string cmd = cmd_xdg + string(_(link_doc)) + " &";
void MainWindow::template_open_browser(string link_doc) {
string cmd = cmd_xdg + string(_(link_doc.c_str())) + " &";
string buf = "";
if (geteuid() == 0) {
string response_user = getlogin();
int size_s = std::snprintf(nullptr, 0, cmd_execute, response_user.c_str(), cmd.c_str()) + 1;
auto size = static_cast<size_t>(size_s);
std::unique_ptr<char[]> buf(new char[ size ]);
std::snprintf( buf.get(), size, cmd_execute, response_user.c_str(), cmd.c_str() );
cmd = std::string( buf.get(), buf.get() + size - 1 );
std::snprintf(buf.get(), size, cmd_execute, response_user.c_str(), cmd.c_str());
cmd = string(buf.get(), buf.get() + size - 1);
}
index_error = system(cmd.c_str());
}

@ -24,6 +24,8 @@
#include <webkit2/webkit2.h>
#endif
#define str_tooltip_filemanager _("Program view")
#define str_tooltip_list_app _("File view")
#define copyright _("Copyright © UBSoft LLC, 2022 - ")
#define define_name_app _("Run as...")
#define name_app_1 _("ublexec")
@ -45,7 +47,7 @@
#define always_redirect _("Always redirect")
#define nothing_save _("Nothing to save!")
#define read_documentation_web _("Would you like to read documentation in the Web?")
#define redirected_documentation _("You will be redirected to documentation site, where user help pages are ""translated and supported by community.")
#define redirected_documentation _("You will be redirected to documentation website where documentation is\ntranslated and supported by community.")
#define str_help_h _("GTK \"Run applications as another user with the specified priority\" for ""UBLinux\n""\n""Usage: ublexec [OPTIONS...]\n""Options:\n"" -h, --help\t Show this help\n"" -V, --version\t Show package version\n"" -x APP_NAME Running the program\n"" -e FILE_NAME Running the file\n")
#define str_version _("ublexec version: ")
#define nice_19 _("19 (Low)")
@ -79,7 +81,7 @@
#define str_localization_team _("Team:")
#define str_run _("Run")
#define link_doc "https://wiki.ublinux.com/ru/Программное_обеспечениерограммы_и_утилиты/Все/ublexec"
#define const_link_doc "https://wiki.ublinux.com/ru/Программное_обеспечениерограммы_и_утилиты/Все/ublexec"
#define cmd_xdg "xdg-open "
#define cmd_execute "su -l %s -c \" DISPLAY=$DISPLAY %s \""
#define path_app "/usr/bin/"
@ -158,11 +160,13 @@ public:
void icon_clear();
void set_icon_array();
void delete_cmd(const int &x,const int &y);
void synopsis_show();
void help_show();
void denamic_cmd();
void temp_help_show();
void open_help();
void is_user_wheel();
void sudo_nice();
void template_open_browser();
void template_open_browser(string link_doc);
void open_browser();
vector <size_t> find_all(string &text, string &word);
bool focus_out_txt_cmd(GdkEventFocus* event);
@ -258,7 +262,7 @@ public:
Gtk::IconView *iconSystem;
Gtk::IconView *iconEntry;
Gtk::MenuItem *btnAbout;
Gtk::MenuItem *btnSynopsis;
Gtk::MenuItem *btnhelp;
Gtk::AboutDialog *aboutWindows;
Gtk::MenuButton *btnSettings;
Gtk::ButtonBox *btnBoxAboutDialog;
@ -309,6 +313,7 @@ public:
bool flag_sudo = false;
bool flag_open_browser = false;
string path_file_name;
string global_lick_doc;
struct struct_App {
string Name_desktop;
string Name;
@ -335,6 +340,6 @@ private:
Gtk::Widget *parent;
};
void help();
void wrapper_synopsis_show();
void wrapper_help_show(GtkWidget *self, char* link, gpointer user_data);

@ -10,6 +10,4 @@ Type=Application
Exec=ublexec
Icon=com.ublinux.ublexec
Terminal=false
X-XfcePluggable=true
X-UBLPluggable=true
Categories=XFCE;GTK;Utility;X-GNOME-Utilities;System;

@ -113,8 +113,7 @@
<property name="margin-end">5</property>
<property name="margin-top">6</property>
<property name="margin-bottom">6</property>
<property name="label" translatable="yes">Run applications as another user
with the specified priority</property>
<property name="label" translatable="yes">Run as...</property>
<attributes>
<attribute name="weight" value="bold"/>
<attribute name="size" value="15360"/>
@ -1037,7 +1036,7 @@ with the specified priority</property>
<property name="rect-anchor-dy">4</property>
<property name="menu-type-hint">dropdown-menu</property>
<child>
<object class="GtkMenuItem" id="btnSynopsis">
<object class="GtkMenuItem" id="btnhelp">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Help</property>

@ -17,6 +17,12 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
msgid "File view"
msgstr ""
msgid "Program view"
msgstr ""
#: source/ublexec.h:32 source/ublexec.cc:181 source/ublexec.cc:182
#: source/ublexec.cc:180 source/ublexec.cc:163
msgid " Run as..."
@ -318,8 +324,7 @@ msgid "Would you like to read documentation in the Web?"
msgstr ""
#: source/ublexec.h:48 source/ublexec.cc:214 source/ublexec.cc:212
msgid ""
"You will be redirected to documentation site, where user help pages are "
"You will be redirected to documentation website where documentation is\n"
"translated and supported by community."
msgstr ""

@ -17,10 +17,16 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
msgid "File view"
msgstr "Обзор файлов"
msgid "Program view"
msgstr "Обзор программ"
#: source/ublexec.h:32 source/ublexec.cc:181 source/ublexec.cc:182
#: source/ublexec.cc:180 source/ublexec.cc:163
msgid " Run as..."
msgstr "О программе ublexec"
msgstr "О программе Выполнить как..."
#: source/ublexec.h:53 source/ublexec.cc:274 source/ublexec.cc:282
#: source/ublexec.cc:313 source/ublexec.cc:272 source/ublexec.cc:280
@ -333,10 +339,10 @@ msgstr "Вы хотите прочитать справку в Сети?"
#: source/ublexec.h:48 source/ublexec.cc:214 source/ublexec.cc:212
msgid ""
"You will be redirected to documentation site, where user help pages are "
"You will be redirected to documentation website where documentation is\n"
"translated and supported by community."
msgstr ""
"Вы будете перенаправлены на сайт с документацией где страницы помощи "
"Вы будете перенаправлены на сайт с документацией где страницы помощи\n"
"переводятся и поддерживаются сообществом."
#: source/ublexec.h:30 source/ublexec.cc:175 source/ublexec.cc:174

Loading…
Cancel
Save