master #68

Merged
asmeron merged 4 commits from YanTheKaller/libublsettingsui-gtk3:master into master 2 weeks ago

@ -2,6 +2,7 @@
<gresources>
<gresource prefix="/com/ublinux/ui">
<file>libublsettingsui-gtk3.glade</file>
<file>libublsettingsui-gtk3-window.glade</file>
<file>libublsettingsui-gtk3-about.glade</file>
<file>libublsettingsui-gtk3-documentation.glade</file>
<file>libublsettingsui-gtk3-saving.glade</file>

@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.40.0 -->
<interface>
<requires lib="gtk+" version="3.24"/>
<object class="GtkWindow" id="Window">
<property name="width-request">450</property>
<property name="height-request">350</property>
<property name="can-focus">False</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>
<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" id="MainBox">
<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>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
<child type="titlebar">
<object class="GtkHeaderBar">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="spacing">5</property>
<property name="show-close-button">True</property>
<child type="title">
<object class="GtkLabel" id="TitleLabel">
<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>
</interface>

@ -38,6 +38,7 @@ add_custom_target(GLADE libublsettingsui-gtk3.glade)
set(DEPENDFILES
../libublsettingsui-gtk3.glade
../libublsettingsui-gtk3-window.glade
../libublsettingsui-gtk3-about.glade
../libublsettingsui-gtk3-documentation.glade
../libublsettingsui-gtk3-saving.glade
@ -83,6 +84,7 @@ add_library(${PROJECT_NAME} SHARED
libublsettingsui-gtk3-save.c
libublsettingsui-gtk3-config-window.c
libublsettingsui-gtk3-filechooser.c
libublsettingsui-gtk3-config-chooser.c
libublsettingsui-gtk3-service.c
libublsettingsui-gtk3-app-chooser.c
libublsettingsui-gtk3-standard-callbacks.c

@ -0,0 +1,65 @@
#include "libublsettingsui-gtk3.h"
typedef struct {
filechooser_window *file_chooser_window;
GtkFileFilter *ini_filter;
GtkFileFilter *yaml_filter;
GtkFileFilter *json_filter;
} config_file_chooser_window;
void on_config_file_chooser_destroy(GtkWidget*, config_file_chooser_window *window){
printf("fewrgege\n");
}
void on_config_file_chooser_accept(GtkWidget *, config_file_chooser_window *window){
switch (gtk_file_chooser_get_action(GTK_FILE_CHOOSER(window->file_chooser_window->MainFileChooser))){
case GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER:
case GTK_FILE_CHOOSER_ACTION_SAVE:
if (yon_char_is_empty(window->file_chooser_window->last_success_selection)){
yon_ubl_status_box_spawn(GTK_CONTAINER(window->file_chooser_window->StatusBox),yon_char_get_localised_from_lib(NOTHING_CHOSEN_LABEL),5,BACKGROUND_IMAGE_FAIL_TYPE);
return;
}
window->file_chooser_window->responce=GTK_RESPONSE_APPLY;
break;
case GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER:
case GTK_FILE_CHOOSER_ACTION_OPEN:
window->file_chooser_window->responce = GTK_RESPONSE_ACCEPT;
break;
}
char *path = NULL;
const char *filter_name = gtk_file_filter_get_name(gtk_file_chooser_get_filter(GTK_FILE_CHOOSER(window->file_chooser_window->MainFileChooser)));
if (window->file_chooser_window->last_success_selection){
int ext_pos = yon_char_find_last(window->file_chooser_window->last_success_selection,'.');
if (ext_pos==-1||strcmp(window->file_chooser_window->last_success_selection+ext_pos,filter_name)){
path = yon_char_unite(window->file_chooser_window->last_success_selection,filter_name,NULL);
free(window->file_chooser_window->last_success_selection);
window->file_chooser_window->last_success_selection = path;
}
}
gtk_widget_destroy(window->file_chooser_window->Window);
gtk_main_quit();
}
filechooser_window *yon_config_file_chooser_window_new(GtkFileChooserAction action){
config_file_chooser_window *window = malloc(sizeof(config_file_chooser_window));
window->file_chooser_window = yon_file_chooser_window_new(action);
window->ini_filter = gtk_file_filter_new();
gtk_file_filter_add_pattern(window->ini_filter,"*.ini");
gtk_file_filter_set_name(window->ini_filter,".ini");
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(window->file_chooser_window->MainFileChooser),window->ini_filter);
window->yaml_filter = gtk_file_filter_new();
gtk_file_filter_add_pattern(window->yaml_filter,"*.yaml");
gtk_file_filter_set_name(window->yaml_filter,".yaml");
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(window->file_chooser_window->MainFileChooser),window->yaml_filter);
window->json_filter = gtk_file_filter_new();
gtk_file_filter_add_pattern(window->json_filter,"*.json");
gtk_file_filter_set_name(window->json_filter,".json");
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(window->file_chooser_window->MainFileChooser),window->json_filter);
yon_file_chooser_remove_accept_function(window->file_chooser_window);
g_signal_connect(G_OBJECT(window->file_chooser_window->SaveButton),"clicked",G_CALLBACK(on_config_file_chooser_accept),window);
return window->file_chooser_window;
}

@ -114,7 +114,7 @@ char *yon_settings_configuration_get(char *id){
// init section
void __yon_on_ubl_settings_window_open();
void yon_on_settings_window_accept(GtkWidget*,GdkEvent *,ubl_settings_window *window);
gboolean yon_on_settings_window_accept(GtkWidget*,GdkEvent *,ubl_settings_window *window);
void yon_ubl_settings_window_init(GtkMenu *menu){
if (!yon_window_config_check_init()) return;
@ -167,12 +167,13 @@ void __yon_on_ubl_settings_window_open(){
gtk_widget_show(window->window);
}
void yon_on_settings_window_accept(GtkWidget*,GdkEvent *,ubl_settings_window *window){
gboolean yon_on_settings_window_accept(GtkWidget*,GdkEvent *,ubl_settings_window *window){
dictionary *current;
for_dictionaries(current,__yon_configuration_custom_parameters){
struct yon_configuration_custom_parameter *parameter = ((struct yon_configuration_custom_parameter*)current->data);
parameter->custom_callbacks->custom_parameter_save_value_func(parameter->custom_parameter_root);
}
return 0;
}
void yon_configuration_window_add_custom_parameter(const char *id, struct yon_configuration_window_custom_parameter *custom_parameter_data){

@ -87,7 +87,7 @@ void yon_file_chooser_set_root(filechooser_window *window, char *root_path){
g_signal_connect(G_OBJECT(window->MainFileChooser),"current-folder-changed",G_CALLBACK(on_file_chooser_check_root),window);
}
void yon_file_chooser_remove_root(filechooser_window *window, char *root_path){
void yon_file_chooser_remove_root(filechooser_window *window){
if (!yon_char_is_empty(window->root)) free(window->root);
window->root=NULL;
g_signal_handlers_disconnect_by_func(G_OBJECT(window->MainFileChooser),G_CALLBACK(on_file_chooser_check_root),window);
@ -152,3 +152,8 @@ GtkResponseType yon_file_chooser_start(filechooser_window *window){
return window->responce;
}
void yon_file_chooser_remove_accept_function(filechooser_window *window){
g_signal_handlers_disconnect_by_func(G_OBJECT(window->SaveButton),G_CALLBACK(on_file_chooser_accept),window);
}

@ -510,7 +510,7 @@ void on_root_access(GtkWidget *, GtkWidget *window){
if (getuid()){
char *argline = template_app_information.app_tech_name;
for (int i=1;i<arg_size;i++){
if (!strcmp(arg_target[i],"socket-id")||!strcmp(arg_target[i],"socket-ext-id")||!strcmp(arg_target[i],"socket-trd-id")){ i++;
if (yon_char_check_begins_with(arg_target[i],"--socket-id")||yon_char_check_begins_with(arg_target[i],"--socket-ext-id")||yon_char_check_begins_with(arg_target[i],"--socket-trd-id")){ i++;
continue;
}
char *temp = yon_char_unite(argline," ", arg_target[i],NULL);
@ -714,3 +714,15 @@ void yon_entry_set_entry_type(GtkEntry *target,GtkBox *status){
default: break;
}
}
yon_window *yon_window_new(){
yon_window *window = new(yon_window);
memset(window,0,sizeof(yon_window));
GtkBuilder *builder = gtk_builder_new_from_resource(ui_glade_path_window);
window->Window = yon_gtk_builder_get_widget(builder,"Window");
window->StatusBox = yon_gtk_builder_get_widget(builder,"StatusBox");
window->MainBox = yon_gtk_builder_get_widget(builder,"MainBox");
return window;
}

@ -24,6 +24,9 @@
/**Путь до файла основного окна утилит ubl-settings-**/
#define ui_glade_path "/com/ublinux/ui/libublsettingsui-gtk3.glade"
#define ui_glade_path_window "/com/ublinux/ui/libublsettingsui-gtk3-window.glade"
/**Путь до файла подтверждения открытия документации утилит ubl-settings-**/
#define ui_glade_path_documentation "/com/ublinux/ui/libublsettingsui-gtk3-documentation.glade"
@ -245,11 +248,36 @@ typedef struct {
char *root;
} filechooser_window;
/// @brief Create a file chooser window for specific action
/// @param action File chooser's action, a mode for window to work at
/// @return A newly allocated file chooser window;
filechooser_window *yon_file_chooser_window_new(GtkFileChooserAction action);
/// @brief Start file chooser window as dialog window
/// @param window File chooser window to start
/// @return GtkResponceType of pressed button
GtkResponseType yon_file_chooser_start(filechooser_window *window);
/// @brief Sets a a new label for "Accept" button
/// @param label
void yon_file_chooser_set_button_label(char *label);
/// @brief Set a root for file chooser. File chooser cannot escape root folder
/// @param window
/// @param root_path
void yon_file_chooser_set_root(filechooser_window *window, char *root_path);
void yon_file_chooser_remove_root(filechooser_window *window, char *root_path);
/// @brief Remove root from file chooser.
/// @param window
/// @param root_path
void yon_file_chooser_remove_root(filechooser_window *window);
/// @brief Create file chooser window, configured to select supported configuration files.
/// @return A newly allocated file chooser window;
filechooser_window *yon_config_file_chooser_window_new(GtkFileChooserAction action);
void yon_file_chooser_remove_accept_function(filechooser_window *window);
dialog_confirmation_data *yon_confirmation_dialog_data_new();
@ -534,6 +562,16 @@ void yon_password_hash_list_set(yon_password_window *window, config_str hashes,
yon_password_window *yon_password_open(GtkEntry *target);
typedef struct {
GtkWidget *Window;
GtkWidget *StatusBox;
GtkWidget *MainBox;
} yon_window;
/// @brief Create empty window
/// @return A newly allocated empty window;
yon_window *yon_window_new();
#define VERSION_LABEL yon_char_unite(_("Version:")," ",!yon_char_is_empty(template_app_information.app_version)?template_app_information.app_version:"","\n",NULL)
#define HELP_LABEL(rest) yon_char_unite(template_app_information.app_tech_name,_(" version:")," ", !yon_char_is_empty(template_app_information.app_version)?template_app_information.app_version:"","\n",\
template_app_information.app_title,"\n",_("Usage:"), " ",template_app_information.app_tech_name," ",_("[OPTIONS]"),"\n",\

Loading…
Cancel
Save