Added Options window; Added configuration file option

pull/79/head
parent 7ea298513c
commit 80827ec0ad

@ -9,6 +9,7 @@
<file>ubl-settings-manager-theme-main-section.glade</file>
<file>ubl-settings-manager-settings-sections.glade</file>
<file>ubl-settings-manager-section-element.glade</file>
<file>ubl-settings-manager-config.glade</file>
</gresource>
<gresource prefix="/com/ublinux/css">
<file>ubl-settings-manager.css</file>

@ -17,129 +17,150 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: source/ubl-strings.h:3
#: source/ubl-strings.h:1
msgid "Settings manager for the system"
msgstr ""
#: source/ubl-strings.h:4
msgid "About Settings manager for the system"
#: source/ubl-strings.h:2
msgid "About UBLinux Settings Manager"
msgstr ""
#: source/ubl-strings.h:6
#: source/ubl-strings.h:4
msgid ""
"https://wiki.ublinux.ru/software/programs_and_utilities/all/ubl-settings-"
"manager"
msgstr ""
#: source/ubl-strings.h:8
#: source/ubl-strings.h:6
msgid "Settings manager for UBLinux"
msgstr ""
#: source/ubl-strings.h:9
#: source/ubl-strings.h:7
msgid "Back to settings"
msgstr ""
#: source/ubl-strings.h:10
#: source/ubl-strings.h:8
msgid "Config loading failed!\n"
msgstr ""
#: source/ubl-strings.h:11
#: source/ubl-strings.h:9
msgid "Double click selection"
msgstr ""
#: source/ubl-strings.h:12
#: source/ubl-strings.h:10
msgid "Sections management"
msgstr ""
#: source/ubl-strings.h:13
#: source/ubl-strings.h:11
msgid "Understood"
msgstr ""
#: source/ubl-strings.h:14
#: source/ubl-strings.h:12
msgid "Settings"
msgstr ""
#: source/ubl-strings.h:15
#: source/ubl-strings.h:13
msgid "Apply"
msgstr ""
#: source/ubl-strings.h:16
#: source/ubl-strings.h:14
msgid "Close"
msgstr ""
#: source/ubl-strings.h:17
#: source/ubl-strings.h:15
msgid "Cancel"
msgstr ""
#: source/ubl-strings.h:18
#: source/ubl-strings.h:16
msgid "About..."
msgstr ""
#: source/ubl-strings.h:19
#: source/ubl-strings.h:17
msgid "Documentation"
msgstr ""
#: source/ubl-strings.h:20
#: source/ubl-strings.h:18
msgid "Window theme"
msgstr ""
#: source/ubl-strings.h:21
#: source/ubl-strings.h:19
msgid "Icon size"
msgstr ""
#: source/ubl-strings.h:22
#: source/ubl-strings.h:20
msgid "All settings"
msgstr ""
#: source/ubl-strings.h:23
#: source/ubl-strings.h:21
msgid "Failed to load theme"
msgstr ""
#: source/ubl-strings.h:24
#: source/ubl-strings.h:22
msgid "Main theme"
msgstr ""
#: source/ubl-strings.h:25
#: source/ubl-strings.h:23
msgid "GNOME theme"
msgstr ""
#: source/ubl-strings.h:26
#: source/ubl-strings.h:24
msgid "Default"
msgstr ""
#: source/ubl-strings.h:27
#: source/ubl-strings.h:25
msgid "Section name"
msgstr ""
#: source/ubl-strings.h:28
#: source/ubl-strings.h:26
msgid "Identifier"
msgstr ""
#: source/ubl-strings.h:29
#: source/ubl-strings.h:27
msgid "Add section"
msgstr ""
#: source/ubl-strings.h:30
#: source/ubl-strings.h:28
msgid "Clear fields"
msgstr ""
#: source/ubl-strings.h:31
#: source/ubl-strings.h:29
msgid "Remove section"
msgstr ""
#: source/ubl-strings.h:32
#: source/ubl-strings.h:30 source/ubl-settings-manager-settings-sections.c:108
#: source/ubl-settings-manager.c:138
msgid "Personal"
msgstr ""
#: source/ubl-strings.h:33
#: source/ubl-strings.h:31 source/ubl-settings-manager-settings-sections.c:113
#: source/ubl-settings-manager.c:144
msgid "Hardware"
msgstr ""
#: source/ubl-strings.h:34
#: source/ubl-strings.h:32 source/ubl-settings-manager-settings-sections.c:118
#: source/ubl-settings-manager.c:150
msgid "System"
msgstr ""
#: source/ubl-strings.h:35
#: source/ubl-strings.h:33 source/ubl-settings-manager-settings-sections.c:123
#: source/ubl-settings-manager.c:156
msgid "Misc"
msgstr ""
#: source/ubl-strings.h:34
msgid ""
"Select the configuration file that the applications will use to save the "
"settings. The selected file will be sent to the applications as an argument."
msgstr ""
#: source/ubl-strings.h:35
msgid "Configuration file:"
msgstr ""
#: source/ubl-strings.h:36
msgid "Attention! Configuration mode was enabled"
msgstr ""
#: source/ubl-strings.h:36
msgid "Configuration will be saved in configuration file"
msgstr ""

@ -17,15 +17,15 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: source/ubl-strings.h:3
#: source/ubl-strings.h:1
msgid "Settings manager for the system"
msgstr "Диспетчер настроек"
#: source/ubl-strings.h:4
msgid "About Settings manager for the system"
#: source/ubl-strings.h:2
msgid "About UBLinux Settings Manager"
msgstr "О приложении Диспетчер настроек"
#: source/ubl-strings.h:6
#: source/ubl-strings.h:4
msgid ""
"https://wiki.ublinux.ru/software/programs_and_utilities/all/ubl-settings-"
"manager"
@ -33,114 +33,136 @@ msgstr ""
"https://wiki.ublinux.ru/software/programs_and_utilities/all/ubl-settings-"
"manager"
#: source/ubl-strings.h:8
#: source/ubl-strings.h:6
msgid "Settings manager for UBLinux"
msgstr "Диспетчер настроек UBLinux"
#: source/ubl-strings.h:9
#: source/ubl-strings.h:7
msgid "Back to settings"
msgstr "Назад к настройкам"
#: source/ubl-strings.h:10
#: source/ubl-strings.h:8
msgid "Config loading failed!\n"
msgstr "Ошибка загрузки конфигурации!\n"
#: source/ubl-strings.h:11
#: source/ubl-strings.h:9
msgid "Double click selection"
msgstr "Открывать приложения двойным нажатием"
#: source/ubl-strings.h:12
#: source/ubl-strings.h:10
msgid "Sections management"
msgstr "Настройка разделов"
#: source/ubl-strings.h:13
#: source/ubl-strings.h:11
msgid "Understood"
msgstr "Понятно"
#: source/ubl-strings.h:14
#: source/ubl-strings.h:12
msgid "Settings"
msgstr "Настройки"
#: source/ubl-strings.h:15
#: source/ubl-strings.h:13
msgid "Apply"
msgstr "Применить"
#: source/ubl-strings.h:16
#: source/ubl-strings.h:14
msgid "Close"
msgstr "Закрыть"
#: source/ubl-strings.h:17
#: source/ubl-strings.h:15
msgid "Cancel"
msgstr "Отменить"
#: source/ubl-strings.h:18
#: source/ubl-strings.h:16
msgid "About..."
msgstr "О программе..."
#: source/ubl-strings.h:19
#: source/ubl-strings.h:17
msgid "Documentation"
msgstr "Справка"
#: source/ubl-strings.h:20
#: source/ubl-strings.h:18
msgid "Window theme"
msgstr "Выбор темы"
#: source/ubl-strings.h:21
#: source/ubl-strings.h:19
msgid "Icon size"
msgstr "Размер иконок"
#: source/ubl-strings.h:22
#: source/ubl-strings.h:20
msgid "All settings"
msgstr "Все настройки"
#: source/ubl-strings.h:23
#: source/ubl-strings.h:21
msgid "Failed to load theme"
msgstr "Ошибка загрузки темы"
#: source/ubl-strings.h:24
#: source/ubl-strings.h:22
msgid "Main theme"
msgstr "Основная тема"
#: source/ubl-strings.h:25
#: source/ubl-strings.h:23
msgid "GNOME theme"
msgstr "GNOME тема"
#: source/ubl-strings.h:26
#: source/ubl-strings.h:24
msgid "Default"
msgstr "По умолчанию"
#: source/ubl-strings.h:27
#: source/ubl-strings.h:25
msgid "Section name"
msgstr "Название раздела"
#: source/ubl-strings.h:28
#: source/ubl-strings.h:26
msgid "Identifier"
msgstr "Идентификатор"
#: source/ubl-strings.h:29
#: source/ubl-strings.h:27
msgid "Add section"
msgstr "Добавить раздел"
#: source/ubl-strings.h:30
#: source/ubl-strings.h:28
msgid "Clear fields"
msgstr "Очистить поля"
#: source/ubl-strings.h:31
#: source/ubl-strings.h:29
msgid "Remove section"
msgstr "Удалить раздел"
#: source/ubl-strings.h:32
#: source/ubl-strings.h:30 source/ubl-settings-manager-settings-sections.c:108
#: source/ubl-settings-manager.c:138
msgid "Personal"
msgstr "Личные"
#: source/ubl-strings.h:33
#: source/ubl-strings.h:31 source/ubl-settings-manager-settings-sections.c:113
#: source/ubl-settings-manager.c:144
msgid "Hardware"
msgstr "Оборудование"
#: source/ubl-strings.h:34
#: source/ubl-strings.h:32 source/ubl-settings-manager-settings-sections.c:118
#: source/ubl-settings-manager.c:150
msgid "System"
msgstr "Система"
#: source/ubl-strings.h:35
#: source/ubl-strings.h:33 source/ubl-settings-manager-settings-sections.c:123
#: source/ubl-settings-manager.c:156
msgid "Misc"
msgstr "Прочее"
#: source/ubl-strings.h:34
msgid ""
"Select the configuration file that the applications will use to save the "
"settings. The selected file will be sent to the applications as an argument."
msgstr "Выберите файл конфигурации, который приложения будут использовать для сохранения настроек. Выбранный файл будет отправлен приложениям в качестве аргумента."
#: source/ubl-strings.h:35
msgid "Configuration file:"
msgstr "Файл конфигурации:"
#: source/ubl-strings.h:36
msgid "Attention! Configuration mode was enabled"
msgstr "Внимание! Включен режим конфигурации!"
#: source/ubl-strings.h:36
msgid "Configuration will be saved in configuration file"
msgstr "Конфигурация будет сохранена в файл конфигурации"

@ -39,6 +39,7 @@ set(DEPENDFILES
../ubl-settings-manager-settings-sections.glade
../ubl-settings-manager-theme-main-section.glade
../ubl-settings-manager-section-element.glade
../ubl-settings-manager-config.glade
../gresource.xml
../manager-banner.png
../ubl-settings-manager.css
@ -83,6 +84,7 @@ set(SOURCE_FILES
ubl-settings-manager-theme-main.c
ubl-settings-manager-app-sections.c
ubl-settings-manager-settings-sections.c
ubl-settings-manager-config-chooser.c
ubl-settings-manager-misc.c
ubl-settings-manager.h
ubl-strings.h

@ -0,0 +1,95 @@
#include "ubl-settings-manager.h"
struct config_chooser {
GtkWidget *RootBox;
GtkWidget *PathEntry;
GtkWidget *PathButton;
GtkWidget *ClearButton;
};
void on_config_destroy(GtkWidget *, struct config_chooser *parameter);
void on_config_destroy(GtkWidget *, struct config_chooser *parameter){
free(parameter);
}
void on_config_chooser_opened(GtkWidget *, struct config_chooser *parameter);
void on_config_chooser_opened(GtkWidget *, struct config_chooser *parameter){
filechooser_window *window = yon_file_chooser_window_new(GTK_FILE_CHOOSER_ACTION_SAVE);
yon_gtk_window_setup(GTK_WINDOW(window->Window),NULL,CHOOSE_FILE_LABEL,icon_path,"file_chooser");
GtkFileFilter *ini_filter = gtk_file_filter_new();
GtkFileFilter *yaml_filter = gtk_file_filter_new();
GtkFileFilter *json_filter = gtk_file_filter_new();
gtk_file_filter_add_pattern(ini_filter,"*.ini");
gtk_file_filter_set_name(ini_filter,"*.ini");
gtk_file_filter_add_pattern(yaml_filter,"*.yaml");
gtk_file_filter_set_name(yaml_filter,"*.yaml");
gtk_file_filter_add_pattern(json_filter,"*.json");
gtk_file_filter_set_name(json_filter,"*.json");
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(window->MainFileChooser),ini_filter);
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(window->MainFileChooser),yaml_filter);
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(window->MainFileChooser),json_filter);
if (yon_file_chooser_start(window) != GTK_RESPONSE_CANCEL){
char *full_name = NULL;
gtk_entry_set_text(GTK_ENTRY(parameter->PathEntry),window->last_success_selection);
GtkFileFilter *cur_filter = gtk_file_chooser_get_filter(GTK_FILE_CHOOSER(window->MainFileChooser));
if ((cur_filter == ini_filter&&!strstr(window->last_success_selection,".ini"))){
full_name = yon_char_append(window->last_success_selection,".ini");
} else if ((cur_filter == yaml_filter&&!strstr(window->last_success_selection,".yaml"))){
full_name = yon_char_append(window->last_success_selection,".yaml");
} else if ((cur_filter == json_filter&&!strstr(window->last_success_selection,".json"))){
full_name = yon_char_append(window->last_success_selection,".json");
} else {
full_name = yon_char_new(window->last_success_selection);
}
if (access(full_name,F_OK)){
yon_launch(ubconfig_file_create(full_name));
}
}
}
void on_config_chooser_clear(GtkWidget *,struct config_chooser *parameter);
void on_config_chooser_clear(GtkWidget *,struct config_chooser *parameter){
yon_window_config_erase_instant_parameter("file",yon_configuration_window_section);
gtk_entry_set_text(GTK_ENTRY(parameter->PathEntry),"");
}
GtkWidget *yon_config_chooser_new( char *){
struct config_chooser *parameter = malloc(sizeof(struct config_chooser));
GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_config);
parameter->RootBox = yon_gtk_builder_get_widget(builder,"RootBox");
parameter->PathEntry = yon_gtk_builder_get_widget(builder,"PathEntry");
parameter->PathButton = yon_gtk_builder_get_widget(builder,"PathButton");
parameter->ClearButton = yon_gtk_builder_get_widget(builder,"ClearButton");
g_object_set_data(G_OBJECT(parameter->RootBox),"data_struct",parameter);
g_signal_connect(G_OBJECT(parameter->PathButton),"clicked",G_CALLBACK(on_config_chooser_opened),parameter);
g_signal_connect(G_OBJECT(parameter->ClearButton),"clicked",G_CALLBACK(on_config_chooser_clear),parameter);
g_signal_connect(G_OBJECT(parameter->RootBox),"destroy",G_CALLBACK(on_config_destroy),parameter);
return parameter->RootBox;
}
void yon_config_chooser_update(GtkWidget *root){
struct config_chooser *parameter = g_object_get_data(G_OBJECT(root),"data_struct");
char *target;
if (!yon_window_config_get_parameter(yon_configuration_window_section,"file",&target,YON_TYPE_STRING)){
target = NULL;
}
if (target){
gtk_entry_set_text(GTK_ENTRY(parameter->PathEntry),target);
}
}
void yon_config_chooser_save(GtkWidget *root){
struct config_chooser *parameter = g_object_get_data(G_OBJECT(root),"data_struct");
char *path = (char*)gtk_entry_get_text(GTK_ENTRY(parameter->PathEntry));
if (!yon_char_is_empty(path)){
yon_window_config_add_instant_parameter("file",yon_configuration_window_section,path,YON_TYPE_STRING);
yon_ubl_status_box_spawn_infinite(GTK_CONTAINER(main_config.widgets->StatusBox),"config_mode",CONFIG_MODE_LABEL(path),BACKGROUND_IMAGE_INFO_TYPE);
} else {
yon_window_config_erase_instant_parameter("file",yon_configuration_window_section);
yon_ubl_status_box_despawn_infinite(GTK_CONTAINER(main_config.widgets->StatusBox));
}
}

@ -39,6 +39,13 @@ void on_gnome_activate(GtkWidget *,GtkListBoxRow *self, gnome_theme_struct *them
command_args = yon_char_unite("--socket-id=",main_socket_id,NULL);
}
char *file_param = NULL;
if (yon_window_config_get_parameter(yon_configuration_window_section,"file",&file_param,YON_TYPE_STRING)){
char *file_arg = yon_char_unite("--file ",file_param,NULL);
char *temp = yon_char_append_element(command_args,file_arg," ");
if (!yon_char_is_empty(command_args)) free(command_args);
command_args = temp;
}
yon_launch_app_with_arguments(command,command_args);
}

@ -164,6 +164,10 @@ void yon_interface_update(main_window *widgets){
widgets->current_theme->list_update_func(widgets->current_theme);
}
void on_main_exit(GtkWidget *, GdkEvent *, main_window *){
yon_window_config_erase_instant_parameter("file",yon_configuration_window_section);
gtk_main_quit();
}
main_window *yon_main_window_setup(){
main_window *widgets = malloc(sizeof(main_window));
@ -191,14 +195,25 @@ main_window *yon_main_window_setup(){
yon_gtk_window_setup(GTK_WINDOW(widgets->Window),NULL,TITLE_LABEL,icon_path,NULL);
yon_apps_init();
g_signal_connect(G_OBJECT(widgets->Window),"delete-event",G_CALLBACK(on_main_exit),widgets);
g_signal_connect(G_OBJECT(widgets->MainMenuItemSettings),"activate",G_CALLBACK(on_settings_open),widgets);
g_signal_connect(G_OBJECT(widgets->BannerButton),"clicked",G_CALLBACK(on_reveal_banner),widgets);
g_signal_connect(G_OBJECT(widgets->MainMenuItemDocumentation),"activate",G_CALLBACK(on_open_documentation_confirmation),WIKI_LINK);
g_signal_connect(G_OBJECT(widgets->MainMenuItemAbout),"activate",G_CALLBACK(on_about),version_application);
yon_window_config_setup(GTK_WINDOW(widgets->Window));
char *path = yon_char_unite(yon_ubl_user_get_home_directory(),"/.config/",LocaleName,"/",LocaleName,".conf",NULL);
yon_window_config_load(path);
yon_ubl_settings_window_init(GTK_MENU(gtk_widget_get_parent(widgets->MainMenuItemAbout)));
struct yon_configuration_window_custom_parameter *parameter = malloc(sizeof(struct yon_configuration_window_custom_parameter));
parameter->custom_parameter_create_func = yon_config_chooser_new;
parameter->custom_parameter_save_value_func = yon_config_chooser_save;
parameter->custom_parameter_update_func = yon_config_chooser_update;
yon_configuration_window_add_custom_parameter("file",parameter);
free(path);
config_init();
yon_config_update();

@ -39,6 +39,7 @@
#define glade_path_settings "/com/ublinux/ui/ubl-settings-manager-settings.glade"
#define glade_path_settings_section "/com/ublinux/ui/ubl-settings-manager-settings-sections.glade"
#define glade_path_section_element "/com/ublinux/ui/ubl-settings-manager-section-element.glade"
#define glade_path_config "/com/ublinux/ui/ubl-settings-manager-config.glade"
#define CssPath "/com/ublinux/css/ubl-settings-manager.css"
#define GlobalConfigPath "/etc/xdg/ubl-settings-manager/ubl-settings-manager.conf"
#define UserConfigPath "/.config/ubl-settings-manager/ubl-settings-manager.conf"
@ -251,5 +252,8 @@ void on_main_activate(GtkFlowBox* , GtkFlowBoxChild* child, main_theme_struct *t
void yon_main_section_setup(main_theme_struct *theme, app_section *section);
void yon_main_theme_resize(main_theme_struct *theme);
int yon_main_update(main_theme_struct *theme);
GtkWidget *yon_config_chooser_new( char*);
void yon_config_chooser_update(GtkWidget *root);
void yon_config_chooser_save(GtkWidget *root);
void on_main_exit(GtkWidget *, GdkEvent *, main_window *widgets);
#endif

@ -31,3 +31,6 @@
#define HARDWARE_SECTION_LABEL _("Hardware")
#define SYSTEM_SECTION_LABEL _("System")
#define MISC_SECTION_LABEL _("Misc")
#define CONFIG_FILE_DESCRIPTION_LABEL _("Select the configuration file that the applications will use to save the settings. The selected file will be sent to the applications as an argument.")
#define CONFIG_FILE_LABEL _("Configuration file:")
#define CONFIG_MODE_LABEL(path) yon_char_unite(_("Attention! Configuration mode was enabled"),"\n",_("Configuration will be saved in configuration file")," ",path,NULL)

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.40.0 -->
<interface domain="ubl-settings-manager">
<requires lib="gtk+" version="3.24"/>
<!-- interface-css-provider-path ubl-settings-manager.css -->
<object class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">com.ublinux.libublsettingsui-gtk3.zoom-symbolic</property>
</object>
<object class="GtkFrame" id="RootBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label-xalign">0</property>
<property name="shadow-type">in</property>
<child>
<object class="GtkAlignment">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="top-padding">5</property>
<property name="bottom-padding">5</property>
<property name="left-padding">5</property>
<property name="right-padding">5</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">15</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Select the configuration file that the applications will use to save the settings. The selected file will be sent to the applications as an argument.</property>
<property name="wrap">True</property>
<property name="xalign">0</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="spacing">5</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Configuration file:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="PathEntry">
<property name="visible">True</property>
<property name="can-focus">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="ClearButton">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">image2</property>
<style>
<class name="thin"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkButton" id="PathButton">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">image1</property>
<style>
<class name="thin"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child type="label_item">
<placeholder/>
</child>
</object>
<object class="GtkImage" id="image2">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">com.ublinux.libublsettingsui-gtk3.trash-symbolic</property>
</object>
</interface>
Loading…
Cancel
Save