Merge pull request 'master' (#13) from YanTheKaller/libublsettingsui-gtk3:master into master

Reviewed-on: #13
pull/21/head v1.11
Dmitry Razumov 2 years ago
commit 6f215e7b43

@ -5,6 +5,7 @@
<file>libublsettingsui-gtk3-about.glade</file> <file>libublsettingsui-gtk3-about.glade</file>
<file>libublsettingsui-gtk3-documentation.glade</file> <file>libublsettingsui-gtk3-documentation.glade</file>
<file>libublsettingsui-gtk3-saving.glade</file> <file>libublsettingsui-gtk3-saving.glade</file>
<file>libublsettingsui-gtk3-debugger.glade</file>
</gresource> </gresource>
<gresource prefix="/com/ublinux/css"> <gresource prefix="/com/ublinux/css">
<file>libublsettingsui-gtk3.css</file> <file>libublsettingsui-gtk3.css</file>

@ -0,0 +1,141 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.38.2 -->
<interface domain="libublsettingsui-gtk3">
<requires lib="gtk+" version="3.24"/>
<requires lib="vte-2.91" version="0.68"/>
<!-- interface-css-provider-path libublsettingsui-gtk3.css -->
<object class="GtkCheckButton" id="ToggleAllCheck">
<property name="label" translatable="yes">Save</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="draw-indicator">True</property>
</object>
<object class="GtkWindow" id="Window">
<property name="width-request">800</property>
<property name="can-focus">False</property>
<property name="modal">True</property>
<property name="default-height">450</property>
<property name="icon-name">com.ublinux.libublsettingsui-gtk3</property>
<property name="type-hint">dialog</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">5</property>
<child>
<object class="GtkBox" id="StatusBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<placeholder/>
</child>
</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="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-bottom">5</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="shadow-type">in</property>
<child>
<object class="GtkViewport">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="VteTerminal" id="DebuggerTerminal">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="hscroll-policy">natural</property>
<property name="vscroll-policy">natural</property>
<property name="encoding">UTF-8</property>
<property name="scrollback-lines">0</property>
<property name="scroll-on-keystroke">True</property>
<property name="scroll-on-output">False</property>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
</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="HeaderTopic">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">TEMPLATE Manager</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
</child>
<child>
<object class="GtkImage" id="HeaderImage">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">32</property>
<property name="icon-name">com.ublinux.libublsettingsui-gtk3</property>
</object>
</child>
<style>
<class name="toolbar"/>
</style>
</object>
</child>
</object>
<object class="GtkListStore" id="liststore1">
<columns>
<!-- column-name Active -->
<column type="gboolean"/>
<!-- column-name Parameter -->
<column type="gchararray"/>
<!-- column-name OldValue -->
<column type="gchararray"/>
<!-- column-name NewValue -->
<column type="gchararray"/>
<!-- column-name Color -->
<column type="gchararray"/>
<!-- column-name Show -->
<column type="gboolean"/>
<!-- column-name Section -->
<column type="gchararray"/>
<!-- column-name CompareString -->
<column type="gchararray"/>
</columns>
</object>
<object class="GtkTreeModelFilter" id="listfilter1">
<property name="child-model">liststore1</property>
</object>
</interface>

@ -9,6 +9,11 @@ include_directories(${GTK_INCLUDE_DIRS})
link_directories(${GTK_LIBRARY_DIRS}) link_directories(${GTK_LIBRARY_DIRS})
add_definitions(${GTK_CFLAGS_OTHER}) add_definitions(${GTK_CFLAGS_OTHER})
pkg_check_modules(VTE291 REQUIRED vte-2.91)
include_directories(${VTE291_INCLUDE_DIRS})
link_directories(${VTE291_LIBRARY_DIRS})
add_definitions(${VTE291_CFLAGS_OTHER})
find_library(WEBKIT_LIBRARIES_FOUND webkit2gtk-4.0 webkit2gtk-web-extension-4.0) find_library(WEBKIT_LIBRARIES_FOUND webkit2gtk-4.0 webkit2gtk-web-extension-4.0)
option(WEBKIT_FOUND "No" OFF) option(WEBKIT_FOUND "No" OFF)
@ -31,6 +36,7 @@ set(DEPENDFILES
../libublsettingsui-gtk3-about.glade ../libublsettingsui-gtk3-about.glade
../libublsettingsui-gtk3-documentation.glade ../libublsettingsui-gtk3-documentation.glade
../libublsettingsui-gtk3-saving.glade ../libublsettingsui-gtk3-saving.glade
../libublsettingsui-gtk3-debugger.glade
../gresource.xml ../gresource.xml
../libublsettingsui-gtk3-banner.png ../libublsettingsui-gtk3-banner.png
../libublsettingsui-gtk3.css ../libublsettingsui-gtk3.css
@ -73,11 +79,12 @@ add_library(${PROJECT_NAME} SHARED
set(LIBRARIES set(LIBRARIES
${GTK_LIBRARIES} ${GTK_LIBRARIES}
${WEBKIT_LIBRARIES} ${WEBKIT_LIBRARIES}
${VTE291_LIBRARIES}
ublsettings ublsettings
ublsettings-gtk3 ublsettings-gtk3
pthread) pthread)
add_definitions(-DVTE_DISABLE) add_definitions(-DVTE_INCLUDE)
message(${CMAKE_INSTALL_LIBDIR}) message(${CMAKE_INSTALL_LIBDIR})
target_include_directories(${PROJECT_NAME} PUBLIC ${PROJECT_BINARY_DIR}) target_include_directories(${PROJECT_NAME} PUBLIC ${PROJECT_BINARY_DIR})

@ -148,6 +148,23 @@ void on_save_window_parameter_switched(GtkCellRendererToggle *self, gchar *path,
} }
template_debug_window *template_debugger_window_new(){
template_debug_window *window = malloc(sizeof(template_debug_window));
GtkBuilder *builder = gtk_builder_new_from_resource(ui_glade_path_debug);
window->Window=yon_gtk_builder_get_widget(builder,"Window");
window->HeaderTopic=yon_gtk_builder_get_widget(builder,"HeaderTopic");
window->HeaderImage=yon_gtk_builder_get_widget(builder,"HeaderImage");
window->StatusBox=yon_gtk_builder_get_widget(builder,"StatusBox");
window->Vte=yon_gtk_builder_get_widget(builder,"DebuggerTerminal");
gtk_window_set_title(GTK_WINDOW(window->Window),template_app_information.app_title);
gtk_label_set_text(GTK_LABEL(window->HeaderTopic),template_app_information.app_title);
gtk_window_set_icon_name(GTK_WINDOW(window->Window),yon_char_append("com.ublinux.",template_app_information.app_tech_name));
gtk_image_set_from_pixbuf(GTK_IMAGE(window->HeaderImage),gtk_icon_theme_load_icon_for_scale(gtk_icon_theme_get_default(),yon_char_append("com.ublinux.",template_app_information.app_tech_name),32,1,GTK_ICON_LOOKUP_FORCE_SIZE,NULL));
yon_window_config_custom_window_setup(GTK_WINDOW(window->Window),"DebugWindow");
return window;
}
void on_save_parameters(GtkWidget *self, template_saving_window *window){ void on_save_parameters(GtkWidget *self, template_saving_window *window){
char *append_command = yon_char_unite("ubconfig --target ",template_config->load_mode==1?"global":"system"," set ",NULL); char *append_command = yon_char_unite("ubconfig --target ",template_config->load_mode==1?"global":"system"," set ",NULL);
char *remove_command = yon_char_unite("ubconfig --target ",template_config->load_mode==1?"global":"system"," remove ",NULL); char *remove_command = yon_char_unite("ubconfig --target ",template_config->load_mode==1?"global":"system"," remove ",NULL);
@ -169,26 +186,36 @@ void on_save_parameters(GtkWidget *self, template_saving_window *window){
} }
} else { // non-empty new value - add } else { // non-empty new value - add
if (yon_dictionary_get(&final_append,section)){ if (yon_dictionary_get(&final_append,section)){
final_append->data=yon_char_unite((char*)final_append->data," ",yon_char_unite(parameter,"=\"",new_value,"\"",NULL),NULL); final_append->data=yon_char_unite((char*)final_append->data," ",yon_char_unite(parameter,"=\'",new_value,"\'",NULL),NULL);
} else { } else {
yon_dictionary_add_or_create_if_exists_with_data(final_append,section, yon_char_unite(parameter,"=",new_value[0]!='\"'?"\"":"",new_value,new_value[strlen(new_value)-1]!='\"'?"\"":"",NULL)); yon_dictionary_add_or_create_if_exists_with_data(final_append,section, yon_char_unite(parameter,"=",new_value[0]!='\''?"\'":"",new_value,new_value[strlen(new_value)-1]!='\''?"\'":"",NULL));
} }
} }
} }
} }
} }
if (debug_output==1){
template_debug_window *debug_window = template_debugger_window_new();
gtk_widget_show(debug_window->Window);
dictionary *dict = NULL; dictionary *dict = NULL;
char *final_command_line = "";
if (final_remove){ if (final_remove){
for_dictionaries(dict,final_remove){ for_dictionaries(dict,final_remove){
char *final_command = yon_char_unite(remove_command," ",dict->key," ",(char*)dict->data,NULL); char *final_command = yon_char_unite(remove_command," ",dict->key," ",(char*)dict->data,NULL);
system(final_command); char *temp = yon_char_unite(final_command_line,!yon_char_is_empty(final_command_line)?";echo \'":"echo \'",final_command,"\';",final_command,NULL);
if (!yon_char_is_empty(final_command_line))
free(final_command_line);
final_command_line=temp;
free(final_command); free(final_command);
} }
} }
if (final_append){ if (final_append){
for_dictionaries(dict,final_append){ for_dictionaries(dict,final_append){
char *final_command = yon_char_unite(append_command," ",dict->key," ",(char*)dict->data,NULL); char *final_command = yon_char_unite(append_command," ",dict->key," ",(char*)dict->data,NULL);
system(final_command); char *temp = yon_char_unite(final_command_line,!yon_char_is_empty(final_command_line)?";echo \'":"echo \'",final_command,"\';",final_command,NULL);
if (!yon_char_is_empty(final_command_line))
free(final_command_line);
final_command_line=temp;
free(final_command); free(final_command);
} }
} }
@ -199,6 +226,34 @@ void on_save_parameters(GtkWidget *self, template_saving_window *window){
yon_config_save_registered("global"); yon_config_save_registered("global");
} }
} }
if (!yon_char_is_empty(final_command_line)){
yon_terminal_integrated_start(debug_window->Vte,final_command_line,NULL,NULL);
}
} else {
dictionary *dict = NULL;
if (final_remove){
for_dictionaries(dict,final_remove){
char *final_command = yon_char_unite(remove_command," ",dict->key," ",(char*)dict->data,NULL);
system(final_command);
free(final_command);
}
}
if (final_append){
for_dictionaries(dict,final_append){
char *final_command = yon_char_unite(append_command," ",dict->key," ",(char*)dict->data,NULL);
system(final_command);
free(final_command);
}
}
if (window->type==YON_CONFIG_BOTH) {
if (template_config->load_mode==1){
yon_config_save_registered("system");
} else if (template_config->load_mode==0){
yon_config_save_registered("global");
}
}
}
textdomain(template_ui_LocaleName); textdomain(template_ui_LocaleName);
if (window->type == YON_CONFIG_GLOBAL) if (window->type == YON_CONFIG_GLOBAL)
yon_ubl_status_box_render(GLOBAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); yon_ubl_status_box_render(GLOBAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);
@ -626,11 +681,12 @@ int yon_ubl_setup_arguments(int argc, char *argv[],config_str *unfound_arguments
{"socket-ext-id", 1,0, 'e'}, {"socket-ext-id", 1,0, 'e'},
{"socket-trd-id", 1,0, 't'}, {"socket-trd-id", 1,0, 't'},
{"clear-config", 0,0, 'c'}, {"clear-config", 0,0, 'c'},
{"debug", 0,0, 'd'},
{ NULL, 0, NULL, 0 } { NULL, 0, NULL, 0 }
}; };
config_str unregistered_arguments=NULL; config_str unregistered_arguments=NULL;
for (int i=1;i<argc;i++){ for (int i=1;i<argc;i++){
int argument=getopt_long(argc,argv,"hVvs:e:t:c",long_options,&option_index); int argument=getopt_long(argc,argv,"hVvs:e:t:cd",long_options,&option_index);
switch(argument){ switch(argument){
case 'h': case 'h':
show_help=1; show_help=1;
@ -654,6 +710,8 @@ int yon_ubl_setup_arguments(int argc, char *argv[],config_str *unfound_arguments
break; break;
case 'c': if (system(remove_config_dir_command)){}; case 'c': if (system(remove_config_dir_command)){};
break; break;
case 'd': debug_output = 1;
break;
case 1: case 1:
template_config->lock_help=1; template_config->lock_help=1;
break; break;

@ -1,7 +1,10 @@
#ifndef UBL_UTILS_UI
#define UBL_UTILS_UI
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <gtk/gtkx.h> #include <gtk/gtkx.h>
#include <libublsettings.h> #include <libublsettings.h>
#include <libublsettings-gtk3.h> #include <libublsettings-gtk3.h>
#include <vte/vte.h>
#include <locale.h> #include <locale.h>
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
@ -20,6 +23,7 @@
#define ui_glade_path_documentation "/com/ublinux/ui/libublsettingsui-gtk3-documentation.glade" #define ui_glade_path_documentation "/com/ublinux/ui/libublsettingsui-gtk3-documentation.glade"
#define ui_glade_path_about "/com/ublinux/ui/libublsettingsui-gtk3-about.glade" #define ui_glade_path_about "/com/ublinux/ui/libublsettingsui-gtk3-about.glade"
#define ui_glade_path_saving "/com/ublinux/ui/libublsettingsui-gtk3-saving.glade" #define ui_glade_path_saving "/com/ublinux/ui/libublsettingsui-gtk3-saving.glade"
#define ui_glade_path_debug "/com/ublinux/ui/libublsettingsui-gtk3-debugger.glade"
#define ui_banner_path "/com/ublinux/images/libublsettingsui-gtk3-banner.png" #define ui_banner_path "/com/ublinux/images/libublsettingsui-gtk3-banner.png"
#define ui_CssPath "/com/ublinux/css/libublsettingsui-gtk3.css" #define ui_CssPath "/com/ublinux/css/libublsettingsui-gtk3.css"
#define ui_config_path yon_char_unite(yon_ubl_user_get_home_directory(),"/.config/",template_app_information.app_tech_name,"/",template_app_information.app_tech_name,".conf",NULL) #define ui_config_path yon_char_unite(yon_ubl_user_get_home_directory(),"/.config/",template_app_information.app_tech_name,"/",template_app_information.app_tech_name,".conf",NULL)
@ -197,12 +201,22 @@ typedef struct {
YON_CONFIG_TYPE type; YON_CONFIG_TYPE type;
} template_saving_window; } template_saving_window;
typedef struct {
GtkWidget *Window;
GtkWidget *HeaderTopic;
GtkWidget *HeaderImage;
GtkWidget *StatusBox;
GtkWidget *Vte;
} template_debug_window;
typedef struct { typedef struct {
void (*function)(void*,void*); void (*function)(void*,void*);
void *data; void *data;
char *action_text; char *action_text;
} dialog_confirmation_data; } dialog_confirmation_data;
static int debug_output;
int yon_confirmation_dialog_call(GtkWidget *self,dialog_confirmation_data *data); int yon_confirmation_dialog_call(GtkWidget *self,dialog_confirmation_data *data);
template_saving_window *yon_save_proceed(char *path,YON_CONFIG_TYPE type, ...); template_saving_window *yon_save_proceed(char *path,YON_CONFIG_TYPE type, ...);
@ -272,3 +286,4 @@ void on_open_documentation_confirmation(GtkWidget *self, char *link);
void on_subwindow_close(GtkWidget *self); void on_subwindow_close(GtkWidget *self);
int yon_ubl_setup_arguments(int argc, char *argv[],config_str *unfound_arguments, int *arguments_size, char *additional_options_output); int yon_ubl_setup_arguments(int argc, char *argv[],config_str *unfound_arguments, int *arguments_size, char *additional_options_output);
#endif
Loading…
Cancel
Save