Исправлено окно справки

pull/107/head
Igor Belitskiy 3 years ago
parent 485991a029
commit 294cdcf19f

@ -4,16 +4,25 @@ project(ubl-settings-datetime)
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK REQUIRED gtkmm-3.0)
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})
include_directories(${GTK_INCLUDE_DIRS})
link_directories(${GTK_LIBRARY_DIRS})
add_definitions(${GTK_CFLAGS_OTHER})
find_package(ICU REQUIRED COMPONENTS uc dt in io)
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(ubl-settings-datetime.h.in ubl-settings-datetime-cm.h)
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always -std=c++2a")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always \
-O2 -pipe -fno-plt -fexceptions \
@ -21,6 +30,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissin
-fstack-clash-protection -fcf-protection")
set(SOURCE_FILES
ubl-settings-datetime-cm.h
ubl-util-standard.h
ubl-util-standard.c
my_cmd.h
@ -33,5 +43,9 @@ set(LIBRARIES
pthread)
add_executable(ubl-settings-datetime ${SOURCE_FILES})
target_link_libraries(ubl-settings-datetime ${LIBRARIES} ${ICU_LIBRARIES} ${WEBKIT_LIBRARIES})
target_link_libraries(ubl-settings-datetime PUBLIC ${ICU_LIBRARIES} ${WEBKIT_LIBRARIES} ${LIBRARIES})
target_include_directories(ubl-settings-datetime PUBLIC
"${PROJECT_BINARY_DIR}"
${WEBKIT_INCLUDE_DIRS}
)
install(TARGETS ubl-settings-datetime DESTINATION bin)

@ -2,7 +2,8 @@
#define MY_CMD_H
#define link_doc "https://wiki.ublinux.com/ru/Программное_обеспечениерограммы_и_утилиты/Все/ubl-settings-datetime"
#define cmd_xdg "xdg-open "
#define cmd_execute "su -l %s -c \" DISPLAY=$DISPLAY %s \""
#define get_NTPSERVERS_DEFAULT "ubconfig --source default get [] NTPSERVERS_DEFAULT"
#define get_global_NTPSERVERS "ubconfig --default --source global get network NTPSERVERS"
#define get_system_ZONE "ubconfig --default --source system get clock ZONE"

@ -92,9 +92,11 @@ void MainWindow::settings() {
day = 0;
this->lacalization();
btnBoxAboutDialog->set_visible(false);
#ifdef WEBKIT_FOUND
one = WEBKIT_WEB_VIEW( webkit_web_view_new() );
three = Glib::wrap( GTK_WIDGET( one ) );
wndWeb->add( *three );
three = Glib::wrap(GTK_WIDGET(one));
wndWeb->add(*three);
#endif
if (geteuid() == 0) {
numTimeHrs->set_range(0, 23);
numTimeMin->set_range(0, 59);
@ -162,6 +164,14 @@ void MainWindow::lacalization() {
this->bubble_sort(array_hw, array_hw_local, 2);
cbHw->append(array_hw_local[0]);
cbHw->append(array_hw_local[1]);
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"));
}
void MainWindow::bubble_sort(string arr[],string arr_local[], int len_arr) {
@ -315,13 +325,26 @@ void MainWindow::get_builder() {
builder->get_widget("boxWidgetFunc", boxWidgetFunc);
builder->get_widget("overHead", overHead);
builder->get_widget("imgHeadBackground", imgHeadBackground);
#ifdef WEBKIT_FOUND
builder->get_widget("wndWeb", wndWeb);
#endif
builder->get_widget("lblHeadeWndWeb", lblHeadeWndWeb);
builder->get_widget("lblHeaderAboutTopic", lblHeaderAboutTopic);
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);
}
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));
btnHardwareTime->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::hardware_clock));
btnMessClose->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::gui_mess_close));
//cldrDate->signal_day_selected().connect(sigc::mem_fun(*this, &MainWindow::get_calendar));
@ -389,9 +412,32 @@ void MainWindow::event_zone() {
}
void MainWindow::synopsis_show() {
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();
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 );
}
obj_process_system.call(cmd, "&");
#endif
}
void MainWindow::load_local_cfg() {

@ -17,10 +17,12 @@
#include <unicode/calendar.h>
#include <map>
#include <pwd.h>
#include <webkit2/webkit2.h>
#include "ubl-util-standard.c"
#include "my_cmd.h"
#include "ubl-settings-datetime-cm.h"
#ifdef WEBKIT_FOUND
#include <webkit2/webkit2.h>
#endif
using namespace std;
@ -117,11 +119,22 @@ class MainWindow : public Gtk::ApplicationWindow {
Gtk::Image *imgSettings;
Gtk::Overlay *overHead;
Gtk::Image *imgHeadBackground;
Gtk::Window *wndWeb;
Gtk::Label *lblHeadeWndWeb;
Gtk::Widget *three;
WebKitWebView * one;
Gtk::Label *lblHeaderAboutTopic;
Gtk::Label *lblwebHeaderName;
Gtk::Label *lblhelpText;
Gtk::Label *lblhelpHeader;
Gtk::CheckButton *chkAlwaysOpenHelp;
Gtk::Button *btnReadHelp;
Gtk::Button *btnCancelHelp;
Gtk::Window *wndShowWeb;
bool flag_open_browser = false;
#ifdef WEBKIT_FOUND
Gtk::Window *wndWeb;
Gtk::Widget *three;
WebKitWebView *one;
#endif
string array_hw[2];
string array_hw_local[2];
bool flag_load = false;
@ -162,6 +175,7 @@ class MainWindow : public Gtk::ApplicationWindow {
public:
MainWindow(BaseObjectType* obj, Glib::RefPtr<Gtk::Builder> const& builder);
MainWindow(Glib::RefPtr<Gtk::Builder> const& builder);
void open_browser();
virtual ~MainWindow() = default;
void log_mess_error(string &cmd);
void set_hardware_clock(string &local, string &etc);

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

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.40.0 -->
<!-- Generated with glade 3.38.2 -->
<interface>
<requires lib="gtk+" version="3.24"/>
<object class="GtkWindow">
@ -84,54 +84,6 @@
</object>
</child>
</object>
<object class="GtkAboutDialog">
<property name="can-focus">False</property>
<property name="title" translatable="yes">О Программе</property>
<property name="resizable">False</property>
<property name="modal">True</property>
<property name="window-position">center</property>
<property name="icon-name">com.ublinux.ubl-settings-datetime</property>
<property name="type-hint">dialog</property>
<property name="urgency-hint">True</property>
<property name="accept-focus">False</property>
<property name="focus-on-map">False</property>
<property name="program-name">ubl-settings-datetime</property>
<property name="version">1.2</property>
<property name="copyright" translatable="yes">Copyright © 2023 - UBSoft Software LLC</property>
<property name="website">https://ublinux.ru/</property>
<property name="website-label" translatable="yes">Project Home Page</property>
<property name="license" translatable="yes">Это приложение распространяется без каких-либо гарантий.
Подробнее в &lt;a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.html"&gt;GNU General Public License, версии 2 или позднее&lt;/a&gt;.</property>
<property name="authors">UBGroup</property>
<property name="artists">UBGroup</property>
<property name="logo-icon-name">com.ublinux.ubl-settings-datetime</property>
<property name="wrap-license">True</property>
<property name="license-type">gpl-2-0</property>
<child internal-child="vbox">
<object class="GtkBox">
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can-focus">False</property>
<property name="layout-style">end</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
</object>
<object class="GtkAboutDialog" id="aboutWindows">
<property name="can-focus">False</property>
<property name="resizable">False</property>
@ -190,7 +142,7 @@
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-bottom">2</property>
<property name="label" translatable="yes">System quotas</property>
<property name="label" translatable="yes">ubl-settings-datetime</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
@ -1445,6 +1397,205 @@ Format: DD.MM.YYYY</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">ubl-settings-bootloader</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>

@ -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 "Read online"
msgstr ""
msgid "Always redirect"
msgstr ""
msgid ":"
msgstr ""

@ -17,6 +17,28 @@ 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 "Прочитать онлайн"
msgid "About ubl-settings-bootloader"
msgstr "О программе Загрузка системы"
msgid ":"
msgstr ":"

Loading…
Cancel
Save