Merge pull request 'master' (#30) from Igor1/ublexec:master into develop

Reviewed-on: #30
pull/31/head
Dmitry Razumov 3 years ago
commit 883d8f10be

@ -24,7 +24,7 @@ all: init build
init:
@echo "Initialize ..."; \
sed -r "s/(version_application = ).*/\1\"$$(grep 'VERSION' ${FILE_VERSION} | cut -d" " -f2)\";/" -i source/ublexec.h; \
sed -r "s/(version_application = ).*/\1\"$$(grep 'VERSION' ${FILE_VERSION} | cut -d" " -f2)\";/" -i source/ublexec.cc; \
echo "-- Build path: ${CMAKE_BUILD_DIR}"
depend:

@ -1,18 +1,21 @@
#include "ublexec.h"
void pars_flag(int index_start, int argc, char* argv[]);
int main(int argc, char** argv) {
string str_argv= "";
string str_cmd_argv = "";
for (int i=1; i<argc; i++){
str_cmd_argv += to_string(*argv[i]) + " ";
}
auto app = Gtk::Application::create(argc, argv, "org.gtkmm.example.plug");
auto builder = Gtk::Builder::create_from_file(path_glade);
setlocale(LC_ALL, "");
bindtextdomain("ublexec", "/usr/share/locale/");
bind_textdomain_codeset("ublexec", "UTF-8");
textdomain("ublexec");
if (argc != 1){
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;
@ -31,6 +34,20 @@ int main(int argc, char** argv) {
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;
}
}
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);
@ -39,3 +56,19 @@ int main(int argc, char** argv) {
}
}
void pars_flag(int index_start, int argc, char* argv[]) {
string str_argv = "";
for (int i = index_start; i<argc; i++){
str_argv = argv[i];
if (str_argv == "--help" || str_argv == "-h"){
help();
exit(1);
}
else if (str_argv == "--version" || str_argv == "-v"){
string version = string(gettext("ublexec version: ")) + version_application + "\n";
cout << version.c_str();
exit(1);
}
}
}

@ -5,6 +5,9 @@ const string path_app = "/usr/bin/";
const string path_glade = "/usr/share/ublexec/ui/ublexec.glade";
const string path_css = "/usr/share/ublexec/css/ublexec.css";
const string app_name = "ublexec";
int flag_prog_file = 0;
string name_app_cmd = "";
string version_application = "2.23";
const string path_img_head_background = "/usr/share/ublexec/images/logo-background.png";
int socket_ext_id_I = 0;
int socket_trd_id_I = 0;
@ -67,8 +70,6 @@ void MainWindow::get_builder() {
builder->get_widget("messageError", messageError);
builder->get_widget("lblMessageError", lblMessageError);
builder->get_widget("btnMessageErrorOk", btnMessageErrorOk);
builder->get_widget("btnMessageErrorOk", btnMessageErrorOk);
builder->get_widget("btnMessageErrorOk", btnMessageErrorOk);
builder->get_widget("dialogStartMenu", dialogStartMenu);
builder->get_widget("btnStartMenuOK", btnStartMenuOK);
builder->get_widget("btnStartMenuExit", btnStartMenuExit);
@ -177,7 +178,7 @@ void MainWindow::localization() {
lblInfoExec->set_text(gettext("Change startup priority"));
lblInfoPriority->set_text(gettext("Priority:"));
lblMessageError->set_text(gettext("Select an executable file or program"));
messageError->set_title(gettext("Warning!"));
messageError->set_title(gettext("Attention"));
lblGraphics->set_text(gettext("Graphics"));
lblTools->set_text(gettext("Tools"));
lblInternet->set_text(gettext("Internet"));
@ -191,6 +192,7 @@ void MainWindow::localization() {
btnListApp->set_tooltip_text(gettext("Application Overview"));
btnFilemaneg->set_tooltip_text(gettext("File Overview"));
btnStartMenuExit->set_label(gettext("Cancel"));
btnMessageErrorOk->set_label(gettext("Close"));
}
void MainWindow::event() {
@ -413,6 +415,13 @@ void MainWindow::unselect_icon(Gtk::IconView *icon_entry) {
}
void MainWindow::settings() {
if (flag_prog_file == 1){
user_cmd = name_app_cmd;
}
if (flag_prog_file == 2){
path_file = name_app_cmd;
}
this->pars_apps();
this->get_builder();
this->event();
@ -628,7 +637,7 @@ string MainWindow::start_cmd(string user_cmd) {
str_nice_cmd = "nice -n " + to_string(spinPriority->get_value_as_int()) + " ";
}
if (user_cmd.length() == 0 && name_app.length() == 0 && path_file.length() == 0) {
messageError->set_title(gettext("Warning!"));
messageError->set_title(gettext("Attention"));
messageError->show();
return "";
}
@ -697,7 +706,7 @@ void MainWindow::denamic_cmd() {
name_app = "";
user_cmd = "";
txtCmd->set_text(user_cmd);
messageError->set_title(gettext("Warning!"));
messageError->set_title(gettext("Attention"));
messageError->show();
}
else{
@ -963,7 +972,16 @@ SettingsPlug::SettingsPlug(::Window p_socketID, Glib::RefPtr<Gtk::Builder> build
show_all_children();
}
void help() {
string help = "GTK \"Run applications as another user with the specified priority\" for UBLinux\n\n"
"Usage: ublexec [OPTIONS...]\n"
"Options:\n"
" -h, --help Show this help\n"
" -V, --version Show package version\n"
" -x APP_NAME Running the program\n"
" -e FILE_NAME Running the file\n";
cout << gettext(help.c_str());
}

@ -24,9 +24,12 @@ extern const string path_app;
extern const string app_name;
extern const string path_glade;
extern const string path_css;
extern string name_app_cmd;
extern const string path_img_head_background;
extern int socket_ext_id_I;
extern int socket_trd_id_I;
extern int flag_prog_file;
extern string version_application;
void me_thread(string cmd);
class CmdArgParser : public Glib::OptionGroup
{
@ -144,7 +147,7 @@ public:
Gtk::Label *lblTimeEpriorityLow;
Gtk::Label *lblTime4EpriorityHigh;
Gtk::Label *lblUserName;
Gtk::MessageDialog *messageError;
Gtk::Window *messageError;
Gtk::Button *btnMessageErrorOk;
Gtk::Label *lblMessageError;
Gtk::Button *btnStartMenuOK;
@ -204,7 +207,6 @@ public:
Gtk::Widget *boxAbout;
public:
string termunal_cmd[3] = {"konsole -e ", "xfce4-terminal -x ", "xterm -e "};
string version_application = "2.23";
string cmd_old = "";
string user_exec_app = "";
string user_cmd = "";
@ -244,5 +246,6 @@ private:
Gtk::Widget *plugBox;
Gtk::Widget *parent;
};
void help();

@ -1658,7 +1658,7 @@ with the specified priority</property>
<property name="margin-right">5</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">6</property>
<property name="margin-top">13</property>
<property name="label" translatable="yes" context="Time" comments="Time">Priority:</property>
<property name="wrap">True</property>
<property name="xalign">0</property>
@ -1697,7 +1697,7 @@ with the specified priority</property>
<property name="margin-right">5</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">6</property>
<property name="margin-top">15</property>
<property name="numeric">True</property>
</object>
<packing>
@ -1921,67 +1921,107 @@ with the specified priority</property>
</object>
</child>
</object>
<object class="GtkMessageDialog" id="messageError">
<object class="GtkWindow" id="messageError">
<property name="can-focus">False</property>
<property name="title" translatable="yes">Warning!</property>
<property name="icon-name">com.ublinux.ublexec</property>
<property name="type-hint">dialog</property>
<child internal-child="vbox">
<property name="valign">start</property>
<property name="resizable">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="homogeneous">True</property>
<property name="layout-style">end</property>
<child>
<placeholder/>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">center</property>
<property name="valign">start</property>
<property name="margin-left">20</property>
<property name="margin-right">20</property>
<property name="margin-start">20</property>
<property name="margin-end">20</property>
<property name="margin-top">20</property>
<property name="margin-bottom">20</property>
<property name="icon-name">dialog-warning-symbolic</property>
<property name="icon_size">6</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="btnMessageErrorOk">
<property name="label" translatable="yes">OK</property>
<object class="GtkLabel" id="lblMessageError">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="margin-left">5</property>
<property name="margin-right">5</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">6</property>
<property name="margin-bottom">6</property>
<property name="can-focus">False</property>
<property name="halign">center</property>
<property name="valign">start</property>
<property name="margin-left">10</property>
<property name="margin-right">25</property>
<property name="margin-start">10</property>
<property name="margin-end">25</property>
<property name="margin-top">34</property>
<property name="margin-bottom">20</property>
<property name="label">Select an executable file or program</property>
<property name="wrap">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="lblMessageError">
<object class="GtkButton" id="btnMessageErrorOk">
<property name="label" translatable="yes">Close</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-left">10</property>
<property name="margin-right">10</property>
<property name="margin-bottom">15</property>
<property name="label" translatable="yes">Select an executable file or program</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="margin-left">5</property>
<property name="margin-right">5</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
</object>
<packing>
<property name="expand">True</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
<child type="titlebar">
<object class="GtkHeaderBar">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="title" translatable="yes">Warning!</property>
<property name="show-close-button">True</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">32</property>
<property name="icon-name">com.ublinux.ublexec</property>
<property name="icon_size">5</property>
</object>
</child>
</object>
</child>
</object>
<object class="GtkFileChooserDialog" id="wndChooseFileWallpaper">
<property name="can-focus">False</property>

@ -187,7 +187,7 @@ msgid "User Name:"
msgstr ""
#: source/ublexec.cc:180 source/ublexec.cc:631 source/ublexec.cc:700
msgid "Warning!"
msgid "Attention"
msgstr ""
#: source/ublexec.cc:157 source/ublexec.cc:154
@ -214,3 +214,15 @@ msgstr ""
msgid "ОК"
msgstr ""
#: source/main.cc:60
msgid "ublexec version: "
msgstr ""
#: source/main.cc:970
msgid "ublexec version: "
msgstr ""
#: source/main.cc:197
msgid "Close"
msgstr ""

@ -189,8 +189,8 @@ msgid "User Name:"
msgstr "Имя пользователя:"
#: source/ublexec.cc:180 source/ublexec.cc:631 source/ublexec.cc:700
msgid "Warning!"
msgstr "Внимание!"
msgid "Attention"
msgstr "Внимание"
#: source/ublexec.cc:157 source/ublexec.cc:154
msgid "https://wiki.ublinux.com"
@ -218,3 +218,28 @@ msgstr "pkexec"
msgid "ОК"
msgstr "ОК"
#: source/main.cc:60 source/main.cc:60
msgid "ublexec version: "
msgstr "ublexec версия: "
msgid ""
"GTK \"Run applications as another user with the specified priority\" for UBLinux\n\n"
"Usage: ublexec [OPTIONS...]\n"
"Options:\n"
" -h, --help Show this help\n"
" -V, --version Show package version\n"
" -x APP_NAME Running the program\n"
" -e FILE_NAME Running the file\n"
msgstr ""
"GTK-утилита \"Запускать приложения от имени другого пользователя с указанным приоритетом\" для UBLinux\n\n"
"Использование: ublexec [Параметры приложения...]\n"
"Параметры приложения:\n"
" -h, --help\t Показать параметры справки\n"
" -V, --version\t Показать версию пакета\n"
" -x APP_NAME Запуск программы\n"
" -e FILE_NAME Запуск файла\n"
#: source/main.cc:197
msgid "Close"
msgstr "Закрыть"

Loading…
Cancel
Save