Добавлен webkit

pull/35/head
Igor Belitskiy 3 years ago
parent 404c1b4944
commit eae2a16ecf

@ -8,13 +8,28 @@ include_directories(${GTK_INCLUDE_DIRS})
link_directories(${GTK_LIBRARY_DIRS})
add_definitions(${GTK_CFLAGS_OTHER})
find_library(WEBKIT_LIBRARIES_FOUND webkit2gtk-4.0 webkit2gtk-web-extension-4.0)
option(WEBKIT_FOUND "No" OFF)
find_library(WEBKIT_LIBRARIES_FOUND webkit2gtk-4.0 webkit2gtk-web-extension-4.0)
if(WEBKIT_LIBRARIES_FOUND)
option(WEBKIT_FOUND "Yes" ON)
PKG_CHECK_MODULES(WEBKIT REQUIRED webkit2gtk-4.0 webkit2gtk-web-extension-4.0)
include_directories(${WEBKIT_INCLUDE_DIRS})
link_directories(${WEBKIT_LIBRARY_DIRS})
add_definitions(${WEBKIT_CFLAGS_OTHER})
endif()
configure_file(ublexec.h.in ublexec-cm.h)
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always -std=c++2a -g")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always \
-O2 -pipe -fno-plt -fexceptions \
-Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security \
-fstack-clash-protection -fcf-protection")
-fstack-clash-protection -fcf-protection -g")
set(SOURCE_FILES
ublexec-cm.h
main.cc
ublexec.cc
ublexec.h
@ -26,5 +41,10 @@ set(LIBRARIES
pthread)
add_executable(ublexec ${SOURCE_FILES})
target_link_libraries(ublexec ${LIBRARIES})
target_link_libraries(ublexec PUBLIC ${WEBKIT_LIBRARIES} ${LIBRARIES})
target_include_directories(ublexec PUBLIC
"${PROJECT_BINARY_DIR}"
${WEBKIT_INCLUDE_DIRS}
)
install(TARGETS ublexec DESTINATION bin)

@ -0,0 +1,7 @@
#ifndef MY_CMD_H
#define MY_CMD_H
#define link_doc "https://wiki.ublinux.com/ru/Программное_обеспечениерограммы_и_утилиты/Все/ublexec"
#define cmd_xdg "xdg-open "
#define cmd_execute "su -l %s -c \" DISPLAY=$DISPLAY %s \""
#endif

@ -7,7 +7,7 @@ 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";
string version_application = "2.24";
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;
@ -111,6 +111,19 @@ void MainWindow::get_builder() {
builder->get_widget("btnBoxAboutDialog", btnBoxAboutDialog);
builder->get_widget("boxAbout", boxAbout);
builder->get_widget("cmbTerminal", cmbTerminal);
builder->get_widget("lblwebHeaderName", lblwebHeaderName);
builder->get_widget("lblhelpText", lblhelpText);
builder->get_widget("lblhelpHeader", lblhelpHeader);
builder->get_widget("chkAlwaysOpenHelp", chkAlwaysOpenHelp);
builder->get_widget("btnReadHelp", btnReadHelp);
builder->get_widget("btnCancelHelp", btnCancelHelp);
builder->get_widget("wndShowWeb", wndShowWeb);
builder->get_widget("lblHeadeWndWeb", lblHeadeWndWeb);
#ifdef WEBKIT_FOUND
builder->get_widget("wndWeb", wndWeb);
#endif
}
void MainWindow::set_icon_array() {
@ -195,9 +208,21 @@ void MainWindow::localization() {
btnListApp->set_tooltip_text(gettext("Application Overview"));
btnFilemaneg->set_tooltip_text(gettext("File Overview"));
btnMessageErrorOk->set_label(gettext("Close"));
lblhelpHeader->set_text(_("Would you like to read documentation in the Web?"));
lblhelpText->set_text(_("You will be redirected to documentation site, where user help pages are "
"translated and supported by community."));
btnReadHelp->set_label(_("Read online"));
btnCancelHelp->set_label(_("Cancel"));
chkAlwaysOpenHelp->set_label(_("Always redirect"));
lblwebHeaderName->set_label(_("ubl-settings-bootloader"));
lblHeadeWndWeb->set_label(_("Run as..."));
}
void MainWindow::event() {
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));
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));
@ -323,12 +348,32 @@ bool MainWindow::focus_in_txt_cmd(GdkEventFocus* event) {
}
void MainWindow::synopsis_show() {
string cmd = "xdg-open " + string(gettext("https://wiki.ublinux.com/ru/Программное_обеспечениерограммы_и_утилиты/Все/")) + app_name + " &";
if (flag_open_browser == true) {
this->open_browser();
}
else {
wndShowWeb->show_all();
}
}
void MainWindow::open_browser() {
#ifdef WEBKIT_FOUND
webkit_web_view_load_uri(one, link_doc);
wndWeb->show_all();
#else
string cmd = cmd_xdg + string(gettext(link_doc)) + " &";
string buf = "";
if (geteuid() == 0) {
string response_user = getlogin();
cmd = "su -l " + response_user + " -c \" DISPLAY=$DISPLAY " + cmd + " \"";
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 );
}
index_error = system(cmd.c_str());
#endif
}
void MainWindow::icon_clear() {
@ -456,7 +501,11 @@ void MainWindow::settings() {
btnBoxAboutDialog->set_visible(false);
cmbTerminal->set_sensitive(false);
ubl_make_plugs(boxAbout, boxAbout, socket_ext_id_I, 0);
#ifdef WEBKIT_FOUND
one = WEBKIT_WEB_VIEW( webkit_web_view_new() );
three = Glib::wrap(GTK_WIDGET(one));
wndWeb->add(*three);
#endif
}
void MainWindow::close_entry_app() {
@ -975,6 +1024,9 @@ SettingsPlug::SettingsPlug(::Window p_socketID, Glib::RefPtr<Gtk::Builder> build
show_all_children();
}
MainWindow::~MainWindow() {
}
void help() {
string help = "GTK \"Run applications as another user with the specified priority\" for UBLinux\n\n"
"Usage: ublexec [OPTIONS...]\n"

@ -17,6 +17,11 @@
#include <algorithm>
#include <fstream>
#include "ubl-util-standard.c"
#include "ublexec-cm.h"
#include "my_cmd.h"
#ifdef WEBKIT_FOUND
#include <webkit2/webkit2.h>
#endif
using namespace std;
@ -46,6 +51,7 @@ class MainWindow : public Gtk::ApplicationWindow {
public:
MainWindow(BaseObjectType* obj, Glib::RefPtr<Gtk::Builder> const& builder);
MainWindow(Glib::RefPtr<Gtk::Builder> const& builder);
~MainWindow();
void template_apps_obj(Gtk::IconView *icon, Glib::RefPtr<Gtk::ListStore> &gtk_list_app);
void get_builder();
void add_CSS();
@ -93,6 +99,7 @@ public:
void denamic_cmd();
void is_user_wheel();
void sudo_nice();
void open_browser();
vector <size_t> find_all(string &text, string &word);
bool focus_out_txt_cmd(GdkEventFocus* event);
bool focus_in_txt_cmd(GdkEventFocus* event);
@ -205,6 +212,20 @@ public:
Gtk::Image *imgHeadBackground;
Gtk::Overlay *overHead;
Gtk::Widget *boxAbout;
Gtk::Label *lblHeadeWndWeb;
Gtk::Label *lblwebHeaderName;
Gtk::Label *lblhelpText;
Gtk::Label *lblhelpHeader;
Gtk::CheckButton *chkAlwaysOpenHelp;
Gtk::Button *btnReadHelp;
Gtk::Button *btnCancelHelp;
Gtk::Window *wndShowWeb;
#ifdef WEBKIT_FOUND
Gtk::Window *wndWeb;
Gtk::Widget *three;
WebKitWebView *one;
#endif
public:
string termunal_cmd[3] = {"konsole -e ", "xfce4-terminal -x ", "xterm -e "};
string cmd_old = "";
@ -220,6 +241,7 @@ public:
bool flag_pkexec = false;
bool flag_su = false;
bool flag_sudo = false;
bool flag_open_browser = false;
string path_file_name;
struct struct_App {
string Name_desktop;

@ -0,0 +1 @@
#cmakedefine WEBKIT_FOUND

@ -2060,4 +2060,237 @@ with the specified priority</property>
</object>
</child>
</object>
<object class="GtkApplicationWindow" id="wndShowWeb">
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="valign">start</property>
<property name="resizable">False</property>
<property name="default-width">450</property>
<property name="default-height">250</property>
<property name="icon-name">dialog-question-symbolic</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="valign">start</property>
<property name="xpad">20</property>
<property name="ypad">20</property>
<property name="icon-name">dialog-question-symbolic</property>
<property name="icon_size">6</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="lblhelpHeader">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="margin-top">10</property>
<property name="margin-bottom">5</property>
<property name="label" context="Would you like to read documentation in the Net?" comments="Would you like to read documentation in the Net?">Would you like to read documentation in the Web?</property>
<property name="wrap">True</property>
<property name="xalign">0</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
<style>
<class name="fgnb"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="lblhelpText">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="valign">start</property>
<property name="margin-right">10</property>
<property name="margin-end">10</property>
<property name="label" context="You will be redirected to documentation web site, where documentation are translated and supported by community." comments="You will be redirected to documentation web site, where documentation are translated and supported by community.">You will be redirected to documentation website where documentation is translated and supported by community.</property>
<property name="wrap">True</property>
<property name="xalign">0</property>
<style>
<class name="fgnb"/>
</style>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="chkAlwaysOpenHelp">
<property name="label" translatable="yes">Always redirect to online documentation</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="halign">end</property>
<property name="margin-bottom">10</property>
<property name="draw-indicator">True</property>
<style>
<class name="label"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<style>
<class name="fgnb"/>
</style>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<style>
<class name="fgnb"/>
</style>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</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>
<property name="spacing">30</property>
<property name="homogeneous">True</property>
<child>
<object class="GtkButton" id="btnCancelHelp">
<property name="label">Cancel</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<style>
<class name="button"/>
</style>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="btnReadHelp">
<property name="label">Read Online</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<style>
<class name="button"/>
</style>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
<child type="titlebar">
<object class="GtkHeaderBar" id="SettingsBar">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child type="title">
<object class="GtkLabel" id="lblwebHeaderName">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">ublexec</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
</child>
<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">dialog-question-symbolic</property>
</object>
</child>
</object>
</child>
</object>
<object class="GtkWindow" id="wndWeb">
<property name="width-request">800</property>
<property name="height-request">600</property>
<property name="can-focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="icon-name">com.ublinux.ubl-settings-datetime</property>
<child>
<placeholder/>
</child>
<child type="titlebar">
<object class="GtkHeaderBar">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="show-close-button">True</property>
<child type="title">
<object class="GtkLabel" id="lblHeadeWndWeb">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">ublexec</property>
</object>
</child>
<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.ubl-settings-datetime</property>
<property name="icon_size">5</property>
</object>
</child>
</object>
</child>
</object>
</interface>

@ -17,6 +17,23 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
msgid "Would you like to read documentation in the Web?"
msgstr ""
msgid ""
"You will be redirected to documentation site, where user help pages are "
"translated and supported by community."
msgstr ""
msgid "Cancel"
msgstr ""
msgid "Read online"
msgstr ""
msgid "Always redirect"
msgstr ""
msgid ""
msgstr ""

@ -17,6 +17,25 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
msgid "Would you like to read documentation in the Web?"
msgstr "Вы хотите прочитать справку в Сети?"
msgid ""
"You will be redirected to documentation site, where user help pages are "
"translated and supported by community."
msgstr ""
"Вы будете перенаправлены на сайт с документацией где страницы помощи "
"переводятся и поддерживаются сообществом."
msgid "Cancel"
msgstr "Отменить"
msgid "Always redirect"
msgstr "Всегда перенаправлять"
msgid "Read online"
msgstr "Прочитать онлайн"
#: source/ublexec.cc:163
msgid " Run as..."
msgstr "О программе ublexec"
@ -48,9 +67,6 @@ msgstr "О программе"
msgid "Application Overview"
msgstr "Обзор приложений"
msgid "Cancel"
msgstr "Отмена"
#: source/ublexec.cc:177 source/ublexec.cc:173
msgid "Change startup priority"
msgstr "Изменить приоритет запуска"

Loading…
Cancel
Save