Если пользователь стёр команду, галки должны отключены.

pull/3/head
Igor Belitskiy 3 years ago
parent bb2cc550be
commit bd4deb1b73

@ -17,7 +17,9 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(SOURCE_FILES
main.cc
ublexec.cc
ublexec.h)
ublexec.h
ubl-util-standard.h
ubl-util-standard.c)
set(LIBRARIES
${GTK_LIBRARIES}

@ -0,0 +1,69 @@
#include "ubl-util-standard.h"
#ifndef __cplusplus
#ifndef UBL_GET_STANDARD_UI
#define UBL_GET_STANDARD_UI
inline returnstruct *ubl_make_plugs(GtkWidget *LeftWidget, GtkWidget *RightWidget, int left_plug_id, int right_plug_id){
returnstruct *ret=(returnstruct*)malloc(sizeof(returnstruct*));
if (left_plug_id>0&&LeftWidget){
GtkWidget *plug=gtk_plug_new(left_plug_id);
GtkWidget *toplug=LeftWidget;
if (gtk_widget_get_parent(GTK_WIDGET(toplug))){
g_object_ref(G_OBJECT(toplug));
GtkWidget *parent=gtk_widget_get_parent(toplug);
gtk_container_remove(GTK_CONTAINER(parent),toplug);
gtk_container_add(GTK_CONTAINER(plug),GTK_WIDGET(toplug));
} else
gtk_container_add(GTK_CONTAINER(plug),GTK_WIDGET(toplug));
gtk_widget_show(GTK_WIDGET(plug));
ret->plugLeft=plug;
}
if (right_plug_id>0&&RightWidget){
GtkWidget *plug=gtk_plug_new(right_plug_id);
GtkWidget *toplug=RightWidget;
if (gtk_widget_get_parent(GTK_WIDGET(toplug))){
g_object_ref(G_OBJECT(toplug));
GtkWidget *parent=gtk_widget_get_parent(toplug);
gtk_container_remove(GTK_CONTAINER(parent),toplug);
gtk_container_add(GTK_CONTAINER(plug),GTK_WIDGET(toplug));
} else
gtk_container_add(GTK_CONTAINER(plug),GTK_WIDGET(toplug));
gtk_widget_show(GTK_WIDGET(plug));
ret->plugRight=plug;
}
return ret;
}
#endif
#else
inline void ubl_make_plugs(Gtk::Widget *LeftWidget, Gtk::Widget *RightWidget, int left_plug_id, int right_plug_id){
if (left_plug_id>0&&LeftWidget){
GtkWidget *plug=gtk_plug_new(left_plug_id);
GtkWidget *toplug=GTK_WIDGET(LeftWidget->gobj());
if (gtk_widget_get_parent(GTK_WIDGET(toplug))){
g_object_ref(G_OBJECT(toplug));
GtkWidget *parent=gtk_widget_get_parent(toplug);
gtk_container_remove(GTK_CONTAINER(parent),toplug);
gtk_container_add(GTK_CONTAINER(plug),GTK_WIDGET(toplug));
} else
gtk_container_add(GTK_CONTAINER(plug),GTK_WIDGET(toplug));
gtk_widget_show(GTK_WIDGET(plug));
}
if (right_plug_id>0&&RightWidget){
GtkWidget *plug=gtk_plug_new(right_plug_id);
GtkWidget *toplug=GTK_WIDGET(RightWidget->gobj());
if (gtk_widget_get_parent(GTK_WIDGET(toplug))){
g_object_ref(G_OBJECT(toplug));
GtkWidget *parent=gtk_widget_get_parent(toplug);
gtk_container_remove(GTK_CONTAINER(parent),toplug);
gtk_container_add(GTK_CONTAINER(plug),GTK_WIDGET(toplug));
} else
gtk_container_add(GTK_CONTAINER(plug),GTK_WIDGET(toplug));
gtk_widget_show(GTK_WIDGET(plug));
}
}
#endif

@ -0,0 +1,20 @@
#ifndef __cplusplus
#include <gtk/gtk.h>
#include <gtk/gtkx.h>
typedef struct {
GtkWidget *plugLeft;
GtkWidget *plugRight;
} returnstruct;
static returnstruct *ubl_make_plugs(GtkWidget *LeftWidget, GtkWidget *RightWidget, int left_plug_id, int right_plug_id);
#else
#include <gtkmm.h>
#include <gtkmm/stock.h>
#include <gtkmm/window.h>
#include <gtkmm/plug.h>
static void ubl_make_plugs(Gtk::Widget *LeftWidget, Gtk::Widget *RightWidget, int left_plug_id, int right_plug_id);
#endif

@ -4,14 +4,28 @@ string path_app= "/usr/bin/";
string path_glade= "/usr/share/ublexec/ui/ublexec.glade";
string path_css = "/usr/share/ublexec/css/style.css";
string app_name = "ublexec";
int socket_ext_id_I=0;
int socket_trd_id_I=0;
CmdArgParser::CmdArgParser(const std::string& p_name, const std::string& p_description, const std::string& p_help)
: Glib::OptionGroup{p_name, p_description, p_help} {
Glib::OptionEntry socketIDArg;
socketIDArg.set_long_name("socket-id");
socketIDArg.set_short_name('s');
socketIDArg.set_flags(Glib::OptionEntry::FLAG_IN_MAIN);
socketIDArg.set_description("Settings manager socket");
Glib::OptionEntry socketExtId;
socketExtId.set_long_name("socket-ext-id");
socketExtId.set_flags(Glib::OptionEntry::FLAG_IN_MAIN);
socketExtId.set_description("Settings manager secondary socket");
Glib::OptionEntry socketTrdId;
socketTrdId.set_long_name("socket-trd-id");
socketTrdId.set_flags(Glib::OptionEntry::FLAG_IN_MAIN);
socketTrdId.set_description("Settings manager secondary socket");
add_entry(socketIDArg, m_socketID);
add_entry(socketExtId, socket_ext_id_I);
add_entry(socketTrdId, socket_trd_id_I);
}
::Window CmdArgParser::GetSocketID() const{
return m_socketID;
@ -204,18 +218,20 @@ void MainWindow::event(){
bool MainWindow::focus_in_txt_cmd(GdkEventFocus* event){
if (user_cmd.length() != 0){
//txtCmd->set_text(user_cmd);
//user_cmd_old = user_cmd;
}
else if (name_app.length() != 0){
//txtCmd->set_text(name_app);
//name_app_old = name_app;
}
else if (path_file.length() != 0){
//txtCmd->set_text(path_file);
//path_file_old = path_file;
}
else{
user_cmd = txtCmd->get_text();
//txtCmd->set_text(user_cmd);
}
chbTerminal->set_active(false);
chbAnotherUser->set_active(false);
cbxExecuteEpriority->set_active(false);
cmd_old = txtCmd->get_text();
return true;
}
@ -349,15 +365,11 @@ void MainWindow::settings(){
rbSu->set_sensitive(false);
rbSudo->set_sensitive(false);
btnBoxAboutDialog->set_visible(false);
/*
Gtk::Widget *boxButton;
Gtk::Widget *boxAbout;
builder->get_widget("plugBox",plugBox);
builder->get_widget("window",window);
builder->get_widget("boxButton",boxButton);
builder->get_widget("boxAbout",boxAbout);
ubl_make_plugs(boxAbout,boxButton, socket_ext_id_I, socket_trd_id_I);
*/
ubl_make_plugs(boxAbout,boxAbout, 0, socket_trd_id_I);
}
void MainWindow::close_entry_app(){
this->icon_clear();
@ -396,7 +408,9 @@ void MainWindow::get_path_filemaneg(){
else{
txtCmd->set_text(path_file);
this->close_filemaneg();
}
this->denamic_cmd();
}
void MainWindow::tempalte_row(string Name, string Exec, string path , Glib::RefPtr<Gtk::ListStore> &dtk_list){
@ -466,7 +480,7 @@ void MainWindow::open_list_app(){
}
string MainWindow::start_cmd(string user_cmd=""){
string MainWindow::start_cmd(string user_cmd){
string str_cmd_terminal="";
string str_variants_root = "";
string str_nice_cmd = "";
@ -523,11 +537,12 @@ string MainWindow::start_cmd(string user_cmd=""){
else{
str_cmd_terminal = "";
}
string cmd = "";
if (path_file != ""){
if (path_file.length()>0){
cmd = "nohup " + str_nice_cmd + str_cmd_terminal + str_variants_root + " xdg-open '" + path_file + "' ";
}
else if (name_app!=""){
else if (name_app.length()>0){
cmd = "nohup " + str_nice_cmd + str_cmd_terminal + str_variants_root + name_app;
}
else if (user_cmd.length()>0){
@ -542,13 +557,10 @@ string MainWindow::start_cmd(string user_cmd=""){
}
void MainWindow::call_app(string &cmd){
path_file = "";
name_app = "";
if (cmd.length() != 0){
std::thread t([&](string cmd){system(cmd.c_str());}, cmd);
t.detach();
}
}
void MainWindow::denamic_cmd(){
if (chbTerminal->get_active()==true || chbAnotherUser->get_active()==true || cbxExecuteEpriority->get_active()==true){
@ -570,8 +582,13 @@ void MainWindow::denamic_cmd(){
if (user_cmd.length() != 0){
txtCmd->set_text(this->start_cmd(user_cmd));
}
else if (path_file.length() != 0){
txtCmd->set_text(this->start_cmd(user_cmd));
}
else if (name_app.length() != 0){
txtCmd->set_text(this->start_cmd(user_cmd));
}
}
}
bool MainWindow::focus_out_txt_cmd(GdkEventFocus* event){
@ -584,6 +601,7 @@ bool MainWindow::focus_out_txt_cmd(GdkEventFocus* event){
}
void MainWindow::entry_app(){
this->denamic_cmd();
if (name_app.length()==0 && path_file.length()==0){
}

@ -15,6 +15,7 @@
#include <ostream>
#include <thread>
#include <algorithm>
#include "ubl-util-standard.c"
using namespace std;
@ -22,6 +23,8 @@ extern string path_app;
extern string app_name;
extern string path_glade;
extern string path_css;
extern int socket_ext_id_I;
extern int socket_trd_id_I;
void me_thread(string cmd);
class CmdArgParser : public Glib::OptionGroup
{

Loading…
Cancel
Save