From 066af6b9d456b7d636e51e5619af6dab85d07a53 Mon Sep 17 00:00:00 2001 From: Igor Belitskiy Date: Tue, 14 Mar 2023 15:27:00 +0600 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=20plug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/CMakeLists.txt | 2 + source/ubl-settings-bootloader.cc | 24 ++++++++-- source/ubl-settings-bootloader.h | 6 ++- source/ubl-util-standard.c | 76 +++++++++++++++++++++++++++++++ source/ubl-util-standard.h | 20 ++++++++ ubl-settings-bootloader.desktop | 3 +- 6 files changed, 126 insertions(+), 5 deletions(-) create mode 100644 source/ubl-util-standard.c create mode 100644 source/ubl-util-standard.h diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 8f211c8..f194fa9 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -15,6 +15,8 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissin -fstack-clash-protection -fcf-protection -g") set(SOURCE_FILES + ubl-util-standard.h + ubl-util-standard.c main.cc ubl-settings-bootloader.cc ubl-settings-bootloader.h) diff --git a/source/ubl-settings-bootloader.cc b/source/ubl-settings-bootloader.cc index cde08ff..271baed 100644 --- a/source/ubl-settings-bootloader.cc +++ b/source/ubl-settings-bootloader.cc @@ -6,14 +6,29 @@ string path_app= "/usr/bin/"; string path_glade= "/usr/share/ubl-settings-bootloader/ui/ubl-settings-bootloader.glade"; string path_css = "/usr/share/ubl-settings-bootloader/css/style.css"; string app_name = "ubl-settings-bootloader"; +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; @@ -44,8 +59,9 @@ void MainWindow::settings(){ map_cmd_error[""] = ""; this->get_builder(); this->localization(); - this->event(); + ubl_make_plugs(boxSave,boxButton, socket_ext_id_I, socket_trd_id_I); this->add_CSS(); + this->event(); } void MainWindow::get_monitor_size(){ @@ -120,6 +136,8 @@ void MainWindow::get_builder(){ builder->get_widget("btnSettings", btnSettings); builder->get_widget("btnDownload", btnDownload); builder->get_widget("btnSave", btnSave); + builder->get_widget("boxButton", boxButton); + builder->get_widget("boxSave", boxSave); } void MainWindow::localization(){ @@ -128,7 +146,7 @@ void MainWindow::localization(){ unsigned int year = 1900+ ltm->tm_year; string str_authors = string(gettext("Copyright © UBSoft LLC, 2022 - ")) + to_string(year); aboutWindows->set_copyright(str_authors); - aboutWindows->set_comments(gettext("Date and Time")); + aboutWindows->set_comments(gettext("ubl-settings-bootloader")); aboutWindows->set_website(gettext("https://wiki.ublinux.com")); aboutWindows->set_version(gettext(version_application.c_str())); aboutWindows->set_website_label(gettext("Project Home Page")); diff --git a/source/ubl-settings-bootloader.h b/source/ubl-settings-bootloader.h index fa8e678..4c7bc8a 100644 --- a/source/ubl-settings-bootloader.h +++ b/source/ubl-settings-bootloader.h @@ -9,13 +9,15 @@ #include #include #include - +#include "ubl-util-standard.c" using namespace std; 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 { @@ -89,6 +91,8 @@ class MainWindow : public Gtk::ApplicationWindow { Gtk::Button *btnDownload; Gtk::Button *btnSave; Gtk::Button *btnSettings; + Gtk::Widget *boxButton; + Gtk::Widget *boxSave; private: int width; diff --git a/source/ubl-util-standard.c b/source/ubl-util-standard.c new file mode 100644 index 0000000..f922043 --- /dev/null +++ b/source/ubl-util-standard.c @@ -0,0 +1,76 @@ +#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)); + gtk_style_context_add_class(gtk_widget_get_style_context(plug),"bkimButtonPlug"); + gtk_style_context_add_class(gtk_widget_get_style_context(plug),"noborder"); + gtk_style_context_add_class(gtk_widget_get_style_context(plug),"primary-toolbar"); + } + 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)); + gtk_style_context_add_class(gtk_widget_get_style_context(plug),"bkimButtonPlug"); + gtk_style_context_add_class(gtk_widget_get_style_context(plug),"noborder"); + gtk_style_context_add_class(gtk_widget_get_style_context(plug),"primary-toolbar"); + + } +} +#endif \ No newline at end of file diff --git a/source/ubl-util-standard.h b/source/ubl-util-standard.h new file mode 100644 index 0000000..3209625 --- /dev/null +++ b/source/ubl-util-standard.h @@ -0,0 +1,20 @@ +#ifndef __cplusplus +#include +#include + +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 +#include +#include +#include + + +static void ubl_make_plugs(Gtk::Widget *LeftWidget, Gtk::Widget *RightWidget, int left_plug_id, int right_plug_id); +#endif \ No newline at end of file diff --git a/ubl-settings-bootloader.desktop b/ubl-settings-bootloader.desktop index 89ff86d..4499946 100644 --- a/ubl-settings-bootloader.desktop +++ b/ubl-settings-bootloader.desktop @@ -11,4 +11,5 @@ Exec=ubl-settings-bootloader Icon=ubl-settings-bootloader Terminal=false X-XfcePluggable=true -Categories=XFCE;GTK;Settings;DesktopSettings;X-XFCE-SettingsDialog;X-XFCE-SystemSettings;X-UBL-SettingsManager;X-UBL-SystemSettings; \ No newline at end of file +X-UBLPluggable=true +Categories=XFCE;GTK;Settings;DesktopSettings;X-UBL-SettingsManager;X-UBL-SystemSettings; \ No newline at end of file