Добавлен функционал выбора файлов и открытия их через mime

pull/1/head
Igor Belitskiy 3 years ago
parent 538e43e6b5
commit ff979ab71d

@ -1,5 +1,5 @@
# ublexec # ublexec
# ВЫполнить # Выполнить
# Build # Build
In order to build ublexec you will need: In order to build ublexec you will need:

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 64 KiB

@ -106,7 +106,10 @@ void MainWindow::get_builder(){
builder->get_widget("lblOffice", lblOffice); builder->get_widget("lblOffice", lblOffice);
builder->get_widget("lblOther", lblOther); builder->get_widget("lblOther", lblOther);
builder->get_widget("lblDevelopment", lblDevelopment); builder->get_widget("lblDevelopment", lblDevelopment);
builder->get_widget("lblSystem", lblSystem); builder->get_widget("lblSystem", lblSystem);
/*
builder->get_widget("iconGraphics", iconGraphics); builder->get_widget("iconGraphics", iconGraphics);
builder->get_widget("iconTools", iconTools); builder->get_widget("iconTools", iconTools);
builder->get_widget("iconInternet", iconInternet); builder->get_widget("iconInternet", iconInternet);
@ -117,17 +120,8 @@ void MainWindow::get_builder(){
builder->get_widget("iconOther", iconOther); builder->get_widget("iconOther", iconOther);
builder->get_widget("iconDevelopment", iconDevelopment); builder->get_widget("iconDevelopment", iconDevelopment);
builder->get_widget("iconSystem", iconSystem); builder->get_widget("iconSystem", iconSystem);
*/
builder->get_widget("liststoreGraphics", liststoreGraphics); builder->get_widget("treeViewGraphics", treeViewGraphics);
builder->get_widget("liststoreTools", liststoreTools);
builder->get_widget("liststoreInternet", liststoreInternet);
builder->get_widget("liststoreMultimedia", liststoreMultimedia);
builder->get_widget("liststoreSettings", liststoreSettings);
builder->get_widget("liststoreEducation", liststoreEducation);
builder->get_widget("liststoreOffice", liststoreOffice);
builder->get_widget("liststoreOther", liststoreOther);
builder->get_widget("liststoreDevelopment", liststoreDevelopment);
builder->get_widget("liststoreSystem", liststoreSystem);
} }
@ -137,8 +131,10 @@ void MainWindow::add_CSS(){
Glib::RefPtr<Gtk::StyleContext> styleContext = Gtk::StyleContext::create(); Glib::RefPtr<Gtk::StyleContext> styleContext = Gtk::StyleContext::create();
Glib::RefPtr<Gdk::Screen> screen = Gdk::Screen::get_default();//get default screen Glib::RefPtr<Gdk::Screen> screen = Gdk::Screen::get_default();//get default screen
styleContext->add_provider_for_screen(screen, cssProvider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);//add provider for screen in all application styleContext->add_provider_for_screen(screen, cssProvider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);//add provider for screen in all application
Glib::RefPtr<Gtk::StyleContext> context = boxColor->get_style_context(); Glib::RefPtr<Gtk::StyleContext> context_box = boxColor->get_style_context();
context->add_class("cssboxColor1"); Glib::RefPtr<Gtk::StyleContext> context_lbl_head = lblInfoHead->get_style_context();
context_box->add_class("cssboxColor1");
context_lbl_head->add_class("textHead");
} }
void MainWindow::localization(){ void MainWindow::localization(){
@ -146,7 +142,7 @@ void MainWindow::localization(){
btnStart->set_label(gettext("Run")); btnStart->set_label(gettext("Run"));
wndChooseFileWallpaper->set_title(gettext("Please select File")); wndChooseFileWallpaper->set_title(gettext("Please select File"));
dialogStartMenu->set_title(gettext("Warning!")); dialogStartMenu->set_title(gettext("Warning!"));
lblInfoHead->set_text(gettext("Running applications as a user with a specified priority")); lblInfoHead->set_text(gettext("Running applications as a user with a\n specified priority"));
lblinfoCmd->set_text(gettext("Command Line")); lblinfoCmd->set_text(gettext("Command Line"));
lblInfoTime->set_text(gettext("Team:")); lblInfoTime->set_text(gettext("Team:"));
labInfoExecutTerm->set_text(gettext("Run in the terminal emulator")); labInfoExecutTerm->set_text(gettext("Run in the terminal emulator"));
@ -154,7 +150,7 @@ void MainWindow::localization(){
lblInfoUserOther->set_text(gettext("Run as another user")); lblInfoUserOther->set_text(gettext("Run as another user"));
lblInfoUserName->set_text(gettext("User Name:")); lblInfoUserName->set_text(gettext("User Name:"));
lblInfoNooPriority->set_text(gettext("Priority:")); lblInfoNooPriority->set_text(gettext("Priority:"));
lblInfoExec->set_text(gettext("Run with a different priority")); lblInfoExec->set_text(gettext("Change startup priority"));
lblInfoPriority->set_text(gettext("Priority:")); lblInfoPriority->set_text(gettext("Priority:"));
lblMessageError->set_text(gettext("Select an executable file or program")); lblMessageError->set_text(gettext("Select an executable file or program"));
lblInfoEnterProg->set_text(gettext("Selecting Programs")); lblInfoEnterProg->set_text(gettext("Selecting Programs"));
@ -203,7 +199,12 @@ void MainWindow::settings(){
this->pars_dir_bin(); this->pars_dir_bin();
this->pars_users(); this->pars_users();
this->activ_or_block_execute_epriority(); this->activ_or_block_execute_epriority();
this->activ_or_block_other_user(); cmbUser->set_active(0);
cmbUser->set_sensitive(false);
lblInfoUserName->set_sensitive(false);
rbPkexec->set_sensitive(false);
rbSu->set_sensitive(false);
rbSudo->set_sensitive(false);
} }
void MainWindow::close_start_menu(){ void MainWindow::close_start_menu(){
@ -232,10 +233,10 @@ void MainWindow::close_filemaneg(){
wndChooseFileWallpaper->hide(); wndChooseFileWallpaper->hide();
} }
void MainWindow::get_path_filemaneg(){ void MainWindow::get_path_filemaneg(){
path_file_name = wndChooseFileWallpaper->get_filename(); path_file = wndChooseFileWallpaper->get_filename();
if (path_file_name.length()==0){} if (path_file.length()==0){}
else{ else{
txtCmd->set_text(path_file_name); txtCmd->set_text(path_file);
this->close_filemaneg(); this->close_filemaneg();
} }
} }
@ -243,11 +244,11 @@ void MainWindow::open_list_app(){
//liststoreDevelopment = iconDevelopment->get_model(); //liststoreDevelopment = iconDevelopment->get_model();
string path = "";
for ( const auto &str_app : list_app){ for ( const auto &str_app : list_app){
for ( const auto &str_categor : str_app.Categories){ for ( const auto &str_categor : str_app.Categories){
path = "/usr/share/applications/" + str_app.Icon + ".svg";
if (str_categor=="Graphics"){ if (str_categor=="Graphics"){
} }
else if (str_categor=="Tools"){ else if (str_categor=="Tools"){
@ -300,28 +301,14 @@ void MainWindow::start_cmd(){
//========================================= //=========================================
if (chbAnotherUser->get_active()){ if (chbAnotherUser->get_active()){
if (rbPkexec->get_active()){ if (rbPkexec->get_active()){
if (geteuid()!=0){ if ((chbAnotherUser->get_active()) && (cmbUser->get_active_text().length()==0)) {
if ((chbAnotherUser->get_active()) && (cmbUser->get_active_text().length()==0)) { str_variants_root = "pkexec env PATH=$PATH DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY ";
str_variants_root = "pcexec env PATH=$PATH DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY "; }
} else if (chbAnotherUser->get_active()){
else if (chbAnotherUser->get_active()){ str_variants_root = "pkexec --user " + cmbUser->get_active_text() + " env PATH=$PATH DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY ";
str_variants_root = "pcexec --user " + cmbUser->get_active_text() + " env PATH=$PATH DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY ";
}
else{
str_variants_root = "pcexec env PATH=$PATH DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY ";
}
} }
else{ else{
if ((chbAnotherUser->get_active()) && (cmbUser->get_active_text().length()==0)) { str_variants_root = "pkexec env PATH=$PATH DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY ";
str_variants_root = "pkexec env PATH=$PATH DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY ";
}
else if (chbAnotherUser->get_active()){
str_variants_root = "pkexec --user " + cmbUser->get_active_text() + " env PATH=$PATH DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY ";
}
else{
str_variants_root = "pkexec env PATH=$PATH DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY ";
}
} }
} }
else if (rbSu->get_active()){ else if (rbSu->get_active()){
@ -356,6 +343,7 @@ void MainWindow::start_cmd(){
if (cbxExecuteEpriority->get_active()){ if (cbxExecuteEpriority->get_active()){
str_nice_cmd = "nice -n " + to_string(spinPriority->get_value_as_int()) + " "; str_nice_cmd = "nice -n " + to_string(spinPriority->get_value_as_int()) + " ";
} }
//========================================= //=========================================
string user_cmd = txtCmd->get_text(); string user_cmd = txtCmd->get_text();
@ -371,12 +359,18 @@ void MainWindow::start_cmd(){
str_cmd_terminal=""; str_cmd_terminal="";
} }
string cmd = ""; string cmd = "";
cmd = "nohup " + str_cmd_terminal + str_variants_root + str_nice_cmd + user_cmd + " &"; if (path_file!=""){
cmd = "" + str_cmd_terminal + str_variants_root + str_nice_cmd + " xdg-open '" + user_cmd + "' &";
}
else{
cmd = "" + str_cmd_terminal + str_variants_root + str_nice_cmd + user_cmd + " &";
}
txtCmd->set_text(cmd); txtCmd->set_text(cmd);
system(cmd.c_str()); system(cmd.c_str());
path_file_name=""; path_file_name="";
} path_file="";
}
void MainWindow::changed_user(){ void MainWindow::changed_user(){
Glib::ustring entry_user = cmbUser->get_active_text(); Glib::ustring entry_user = cmbUser->get_active_text();
if (geteuid()==0 || entry_user == "root"){ if (geteuid()==0 || entry_user == "root"){
@ -400,6 +394,7 @@ void MainWindow::changed_user(){
//void MainWindow::execute_another_User(){} //void MainWindow::execute_another_User(){}
void MainWindow::activ_or_block_other_user(){ void MainWindow::activ_or_block_other_user(){
bool flag = chbAnotherUser->get_active(); bool flag = chbAnotherUser->get_active();
cmbUser->set_active(0);
cmbUser->set_sensitive(flag); cmbUser->set_sensitive(flag);
lblInfoUserName->set_sensitive(flag); lblInfoUserName->set_sensitive(flag);
//lblInfoUserOther->set_sensitive(flag); //lblInfoUserOther->set_sensitive(flag);
@ -489,6 +484,7 @@ void MainWindow::pars_apps(){
char *Exec=g_key_file_get_string(gfile,"Desktop Entry", "Exec",NULL); char *Exec=g_key_file_get_string(gfile,"Desktop Entry", "Exec",NULL);
char *Categories=g_key_file_get_locale_string(gfile,"Desktop Entry", "Categories",setlocale(LC_ALL,""),NULL); char *Categories=g_key_file_get_locale_string(gfile,"Desktop Entry", "Categories",setlocale(LC_ALL,""),NULL);
char *Icon=g_key_file_get_string(gfile,"Desktop Entry", "Icon",NULL); char *Icon=g_key_file_get_string(gfile,"Desktop Entry", "Icon",NULL);
char *Mime=g_key_file_get_string(gfile,"Desktop Entry", "MimeType",NULL);
if (Type==NULL) continue; if (Type==NULL) continue;
if (Name==NULL) continue; if (Name==NULL) continue;
if (Exec==NULL) continue; if (Exec==NULL) continue;
@ -499,6 +495,13 @@ void MainWindow::pars_apps(){
App.Type = Type; App.Type = Type;
App.Exec = Exec; App.Exec = Exec;
App.Icon = Name; App.Icon = Name;
if (Mime!=NULL){
App.MimeType = Mime;
cout << App.MimeType << endl;
}
else{
App.MimeType = "";
}
App.Name_desktop = file_name; App.Name_desktop = file_name;
App.Categories = split(str_Categories, ';'); App.Categories = split(str_Categories, ';');
for ( const auto &text : App.Categories){ for ( const auto &text : App.Categories){

@ -87,6 +87,19 @@ public:
void pars_apps(); void pars_apps();
vector<std::string> split(const std::string &s, char delim); vector<std::string> split(const std::string &s, char delim);
public:
class ModelColumns : public Gtk::TreeModel::ColumnRecord
{
public:
ModelColumns()
{ add(m_col_id); add(m_col_name); }
Gtk::TreeModelColumn<int> m_col_id;
Gtk::TreeModelColumn<Glib::ustring> m_col_name;
};
ModelColumns m_Columns;
public: public:
Glib::RefPtr<Gtk::Builder> builder; Glib::RefPtr<Gtk::Builder> builder;
Gtk::Button *btnFilemaneg; Gtk::Button *btnFilemaneg;
@ -140,33 +153,18 @@ public:
Gtk::Label *lblDevelopment; Gtk::Label *lblDevelopment;
Gtk::Label *lblSystem; Gtk::Label *lblSystem;
Gtk::IconView *iconGraphics;
Gtk::IconView *iconTools;
Gtk::IconView *iconInternet;
Gtk::IconView *iconMultimedia;
Gtk::IconView *iconSettings;
Gtk::IconView *iconEducation;
Gtk::IconView *iconOffice;
Gtk::IconView *iconOther;
Gtk::IconView *iconDevelopment;
Gtk::IconView *iconSystem;
Gtk::ListStore *liststoreGraphics;
Gtk::ListStore *liststoreTools; Gtk::TreeView *treeViewGraphics=0;
Gtk::ListStore *liststoreInternet; Glib::RefPtr<Gtk::TreeStore> tree_store;
Gtk::ListStore *liststoreMultimedia; Glib::RefPtr<Gtk::ListStore> m_refTreeModel;
Gtk::ListStore *liststoreSettings;
Gtk::ListStore *liststoreEducation;
Gtk::ListStore *liststoreOffice;
Gtk::ListStore *liststoreOther;
Gtk::ListStore *liststoreDevelopment;
Gtk::ListStore *liststoreSystem;
public: public:
string execute_cmd = ""; string execute_cmd = "";
string path_file = "";
bool flag_pkexec = false; bool flag_pkexec = false;
bool flag_su = false; bool flag_su = false;
bool flag_sudo = false; bool flag_sudo = false;
@ -195,3 +193,5 @@ private:
Gtk::Widget *plugBox; Gtk::Widget *plugBox;
Gtk::Widget *parent; Gtk::Widget *parent;
}; };

@ -1,3 +1,6 @@
.cssboxColor1{ .cssboxColor1{
background: url("/usr/share/ublexec/images/bg_top.png") no-repeat; background: url("/usr/share/ublexec/images/bg_top.png") no-repeat;
} }
.textHead{
text-shadow: 1px 1px #ffffff;
}

File diff suppressed because it is too large Load Diff

@ -45,8 +45,8 @@ msgstr "Выход"
msgid "Selecting Programs" msgid "Selecting Programs"
msgstr "Выбор программ" msgstr "Выбор программ"
msgid "Running applications as a user with a specified priority" msgid "Running applications as a user with a\n specified priority"
msgstr "Запуск приложений от имени пользователя с указанным приоритетом" msgstr "Запуск приложений от имени пользователя с\n указанным приоритетом"
msgid "Team:" msgid "Team:"
msgstr "Команда:" msgstr "Команда:"
@ -75,8 +75,8 @@ msgstr "Имя поьзователя:"
msgid "User" msgid "User"
msgstr "Пользователь" msgstr "Пользователь"
msgid "Run with a different priority" msgid "Change startup priority"
msgstr "Выполнить c другим приоритетом" msgstr "Изменить приоритет запуска"
msgid "Priority:" msgid "Priority:"
msgstr "Приоритет:" msgstr "Приоритет:"

Loading…
Cancel
Save