diff --git a/gresource.xml b/gresource.xml index 15ccfb7..a374f64 100644 --- a/gresource.xml +++ b/gresource.xml @@ -7,6 +7,7 @@ ubl-settings-manager-theme-gnome-section.glade ubl-settings-manager-theme-main.glade ubl-settings-manager-settings-sections.glade + ubl-settings-manager-section-element.glade ubl-settings-manager.css diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index ffb5543..bc716e9 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -35,6 +35,7 @@ set(DEPENDFILES ../ubl-settings-manager-theme-gnome-section.glade ../ubl-settings-manager-theme-main.glade ../ubl-settings-manager-settings-sections.glade + ../ubl-settings-manager-section-element.glade ../gresource.xml ../manager-banner.png ../ubl-settings-manager.css @@ -74,6 +75,7 @@ set(SOURCE_FILES ubl-settings-manager-theme.c ubl-settings-manager-theme-gnome.c ubl-settings-manager-app-sections.c + ubl-settings-manager-settings-sections.c ubl-settings-manager.h ubl-strings.h ) diff --git a/source/ubl-settings-manager-settings-sections.c b/source/ubl-settings-manager-settings-sections.c new file mode 100644 index 0000000..359e70d --- /dev/null +++ b/source/ubl-settings-manager-settings-sections.c @@ -0,0 +1,120 @@ +#include "ubl-settings-manager.h" + +typedef struct { + GtkWidget *Window; + GtkWidget *StatusBox; + GtkWidget *SectionsBox; + GtkWidget *NameEntry; + GtkWidget *CategoriesEntry; + GtkWidget *ClearButton; + GtkWidget *AddButton; + GtkWidget *CancelButton; + GtkWidget *SaveButton; + // section_struct *sections; +} settings_section_window; + +typedef struct { + GtkWidget *SectionBox; + GtkWidget *NameEntry; + GtkWidget *CategoriesEntry; + GtkWidget *RemoveButton; + // GtkWidget *AcceptButton; +} section_struct; + +void on_section_remove(GtkWidget *,section_struct *section); +void on_section_add(GtkWidget *,settings_section_window *window); +void on_section_clear(GtkWidget *,settings_section_window *window); +void on_sections_save(GtkWidget *,settings_section_window *window); +section_struct *yon_section_new(); +settings_section_window *yon_section_window_new(); + + +void on_section_remove(GtkWidget *,section_struct *section){ + gtk_widget_destroy(section->SectionBox); +} + +section_struct *yon_section_new(){ + section_struct *section = malloc(sizeof(section_struct)); + GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_section_element); + section->SectionBox = yon_gtk_builder_get_widget(builder,"SectionBox"); + section->NameEntry = yon_gtk_builder_get_widget(builder,"NameEntry"); + section->CategoriesEntry = yon_gtk_builder_get_widget(builder,"CategoriesEntry"); + section->RemoveButton = yon_gtk_builder_get_widget(builder,"RemoveButton"); + // section->AcceptButton = yon_gtk_builder_get_widget(builder,"AcceptButton"); + + g_object_set_data(G_OBJECT(section->SectionBox),"section",section); + + g_signal_connect(G_OBJECT(section->RemoveButton),"clicked",G_CALLBACK(on_section_remove),section); + return section; +} + +void on_section_add(GtkWidget *,settings_section_window *window){ + const char *cat_name = gtk_entry_get_text(GTK_ENTRY(window->NameEntry)); + const char *cat_categories = gtk_entry_get_text(GTK_ENTRY(window->CategoriesEntry)); + if (yon_char_is_empty(cat_name)){ + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),_EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect(window->NameEntry); + return; + } + section_struct *section = yon_section_new(); + gtk_box_pack_start(GTK_BOX(window->SectionsBox),section->SectionBox,0,0,0); + + gtk_entry_set_text(GTK_ENTRY(section->NameEntry),cat_name); + gtk_entry_set_text(GTK_ENTRY(section->CategoriesEntry),cat_categories); + + gtk_entry_set_text(GTK_ENTRY(window->NameEntry),""); + gtk_entry_set_text(GTK_ENTRY(window->CategoriesEntry),""); +} + +void on_section_clear(GtkWidget *,settings_section_window *window){ + gtk_entry_set_text(GTK_ENTRY(window->NameEntry),""); + gtk_entry_set_text(GTK_ENTRY(window->CategoriesEntry),""); +} + +void on_sections_save(GtkWidget *,settings_section_window *window){ + main_window *widgets = g_object_get_data(G_OBJECT(window->Window),"widgets"); + gsize size; + config_str parameters = yon_window_config_get_section(sections_section,&size); + for (gsize i=0;iSectionsBox)); + GList *iter; + for (iter=list;iter;iter=iter->next){ + section_struct *section = g_object_get_data(G_OBJECT(iter->data),"section"); + char *name = (char*)gtk_entry_get_text(GTK_ENTRY(section->NameEntry)); + char *categories = (char*)gtk_entry_get_text(GTK_ENTRY(section->CategoriesEntry)); + yon_window_config_add_instant_parameter(name,sections_section,categories,YON_TYPE_STRING); + } + on_subwindow_close(window->Window); + yon_interface_update(widgets); + +} + +settings_section_window *yon_section_window_new(){ + settings_section_window *window = malloc(sizeof(settings_section_window)); + + GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_settings_section); + window->Window = yon_gtk_builder_get_widget(builder,"Window"); + window->StatusBox = yon_gtk_builder_get_widget(builder,"StatusBox"); + window->SectionsBox = yon_gtk_builder_get_widget(builder,"SectionsBox"); + window->NameEntry = yon_gtk_builder_get_widget(builder,"NameEntry"); + window->CategoriesEntry = yon_gtk_builder_get_widget(builder,"CategoriesEntry"); + window->ClearButton = yon_gtk_builder_get_widget(builder,"ClearButton"); + window->AddButton = yon_gtk_builder_get_widget(builder,"AddButton"); + window->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton"); + window->SaveButton = yon_gtk_builder_get_widget(builder,"SaveButton"); + + g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); + g_signal_connect(G_OBJECT(window->SaveButton),"clicked",G_CALLBACK(on_sections_save),window); + g_signal_connect(G_OBJECT(window->AddButton),"clicked",G_CALLBACK(on_section_add),window); + g_signal_connect(G_OBJECT(window->ClearButton),"clicked",G_CALLBACK(on_section_clear),window); + return window; +} + +void yon_section_window_open(GtkWidget *, settings_window *settings){ + main_window *widgets = g_object_get_data(G_OBJECT(settings->Window),"widgets"); + settings_section_window *window = yon_section_window_new(); + g_object_set_data(G_OBJECT(window->Window),"widgets",widgets); + yon_gtk_window_setup(GTK_WINDOW(window->Window),GTK_WINDOW(settings->Window),TITLE_LABEL,icon_path,"sections_window"); +} \ No newline at end of file diff --git a/source/ubl-settings-manager-settings.c b/source/ubl-settings-manager-settings.c index 07c10e0..21d9acb 100644 --- a/source/ubl-settings-manager-settings.c +++ b/source/ubl-settings-manager-settings.c @@ -16,14 +16,15 @@ gboolean on_settings_size_changed(GtkRange* , GtkScrollType* , gdouble value, se void on_settings_accept(GtkWidget *, settings_window *window){ main_window *widgets = g_object_get_data(G_OBJECT(window->Window),"widgets"); - yon_window_config_add_instant_parameter(icon_size_parameter,"Settings",&window->icon_size,YON_TYPE_INT); + yon_window_config_add_instant_parameter(icon_size_parameter,settings_section,&window->icon_size,YON_TYPE_INT); + main_config.apps_icon_size = window->icon_size; char *cur_theme = (char*)gtk_combo_box_get_active_id(GTK_COMBO_BOX(window->ThemeCombo)); if (cur_theme) - yon_window_config_add_instant_parameter(theme_parameter,"Settings",cur_theme,YON_TYPE_STRING); + yon_window_config_add_instant_parameter(theme_parameter,settings_section,cur_theme,YON_TYPE_STRING); int double_click = gtk_switch_get_active(GTK_SWITCH(window->DoubleClickSwitch)); - yon_window_config_add_instant_parameter(double_click_parameter,"Settings",&double_click,YON_TYPE_INT); + yon_window_config_add_instant_parameter(double_click_parameter,settings_section,&double_click,YON_TYPE_INT); yon_interface_update(widgets); on_subwindow_close(window->Window); } @@ -53,19 +54,20 @@ settings_window *yon_settings_window_new(){ gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(window->ThemeCombo),themes[i],themes[i]); } char *theme_id = NULL; - if (yon_window_config_get_parameter("Settings",theme_parameter,&theme_id,YON_TYPE_STRING)){ + if (yon_window_config_get_parameter(settings_section,theme_parameter,&theme_id,YON_TYPE_STRING)){ gtk_combo_box_set_active_id(GTK_COMBO_BOX(window->ThemeCombo),theme_id); } else { gtk_combo_box_set_active_id(GTK_COMBO_BOX(window->ThemeCombo),GNOME_THEME_LABEL); } window->icon_size; - if (!yon_window_config_get_parameter("Settings",icon_size_parameter,&window->icon_size,YON_TYPE_INT)){ + if (!yon_window_config_get_parameter(settings_section,icon_size_parameter,&window->icon_size,YON_TYPE_INT)){ window->icon_size=32; } gtk_range_set_value(GTK_RANGE(window->SizeSlider),window->icon_size); + on_settings_size_changed(NULL,NULL,window->icon_size,window); int double_click_activate; - if (!yon_window_config_get_parameter("Settings",double_click_parameter,&double_click_activate,YON_TYPE_BOOLEAN)){ + if (!yon_window_config_get_parameter(settings_section,double_click_parameter,&double_click_activate,YON_TYPE_BOOLEAN)){ double_click_activate=0; } gtk_switch_set_active(GTK_SWITCH(window->DoubleClickSwitch),double_click_activate); @@ -75,6 +77,7 @@ settings_window *yon_settings_window_new(){ void on_settings_open(GtkWidget *, main_window *widgets){ settings_window *window = yon_settings_window_new(); + g_signal_connect(G_OBJECT(window->SectionsConfigurationButton),"clicked",G_CALLBACK(yon_section_window_open),window); yon_gtk_window_setup(GTK_WINDOW(window->Window),GTK_WINDOW(widgets->Window),TITLE_LABEL,icon_path,"settings_window"); gtk_widget_show(window->Window); g_object_set_data(G_OBJECT(window->Window),"widgets",widgets); diff --git a/source/ubl-settings-manager-theme.c b/source/ubl-settings-manager-theme.c index 4eee16f..b4365a6 100644 --- a/source/ubl-settings-manager-theme.c +++ b/source/ubl-settings-manager-theme.c @@ -2,7 +2,7 @@ theme_struct *yon_theme_update(main_window *widgets){ char *theme_id; - if (!yon_window_config_get_parameter("Settings","theme",&theme_id,YON_TYPE_STRING)){ + if (!yon_window_config_get_parameter(settings_section,theme_parameter,&theme_id,YON_TYPE_STRING)){ theme_id = yon_char_new(GNOME_THEME_LABEL); } diff --git a/source/ubl-settings-manager.c b/source/ubl-settings-manager.c index 2cee476..9c75884 100644 --- a/source/ubl-settings-manager.c +++ b/source/ubl-settings-manager.c @@ -337,13 +337,13 @@ void on_reveal_banner(GtkWidget *, main_window *widgets){ gtk_revealer_set_reveal_child(GTK_REVEALER(widgets->BannerRevealer),0); gtk_menu_button_set_direction(GTK_MENU_BUTTON(widgets->BannerArrow),GTK_ARROW_RIGHT); int banner = 1; - yon_window_config_add_instant_parameter(hide_banner_parameter,"Settings",&banner,YON_TYPE_BOOLEAN); + yon_window_config_add_instant_parameter(hide_banner_parameter,settings_section,&banner,YON_TYPE_BOOLEAN); } else { gtk_revealer_set_transition_type(GTK_REVEALER(widgets->BannerRevealer),GTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT); gtk_revealer_set_reveal_child(GTK_REVEALER(widgets->BannerRevealer),1); gtk_menu_button_set_direction(GTK_MENU_BUTTON(widgets->BannerArrow),GTK_ARROW_LEFT); int banner = 0; - yon_window_config_add_instant_parameter(hide_banner_parameter,"Settings",&banner,YON_TYPE_BOOLEAN); + yon_window_config_add_instant_parameter(hide_banner_parameter,settings_section,&banner,YON_TYPE_BOOLEAN); } } @@ -432,18 +432,19 @@ void config_init(){ main_config.double_click=0; main_config.apps_icon_size=24; main_config.labelDensity=0; - main_config.themes = g_hash_table_new(g_str_hash,g_str_equal); - yon_theme_init(); }; void yon_config_update(){ - if (!yon_window_config_get_parameter("Setings",double_click_parameter,&main_config.double_click,YON_TYPE_INT)){ + if (!yon_window_config_get_parameter(settings_section,double_click_parameter,&main_config.double_click,YON_TYPE_INT)){ main_config.double_click=0; } - if (!yon_window_config_get_parameter("Setings",icon_size_parameter,&main_config.apps_icon_size,YON_TYPE_INT)){ + if (!yon_window_config_get_parameter(settings_section,icon_size_parameter,&main_config.apps_icon_size,YON_TYPE_INT)){ main_config.apps_icon_size=24; } + + main_config.themes = g_hash_table_new(g_str_hash,g_str_equal); + yon_theme_init(); } int yon_char_parsed_compare(const void *a, const void *b){ @@ -528,14 +529,14 @@ void yon_interface_update(main_window *widgets){ } gsize size; - config_str section_settings = yon_window_config_get_section("Sections",&size); + config_str section_settings = yon_window_config_get_section(sections_section,&size); if (size){ for (gsize i=0;iname = yon_char_new(section_settings[i]); char *categories = NULL; - yon_window_config_get_parameter("Sections",cur_section->name,&categories,YON_TYPE_STRING); + yon_window_config_get_parameter(sections_section,cur_section->name,&categories,YON_TYPE_STRING); cur_section->categories = yon_char_parse(categories,&cur_section->categories_size,";"); yon_dictionary_add_or_create_if_exists_with_data(main_config.sections,cur_section->name,cur_section); } @@ -604,14 +605,15 @@ main_window *yon_main_window_setup(){ char *path = yon_char_unite(yon_ubl_user_get_home_directory(),"/.config/",LocaleName,"/",LocaleName,".conf",NULL); yon_window_config_load(path); free(path); + config_init(); + yon_config_update(); { int banner_hidden = 0; - yon_window_config_get_parameter("Settings",hide_banner_parameter, &banner_hidden,YON_TYPE_BOOLEAN); + yon_window_config_get_parameter(settings_section,hide_banner_parameter, &banner_hidden,YON_TYPE_BOOLEAN); gtk_revealer_set_transition_type(GTK_REVEALER(widgets->BannerRevealer),!banner_hidden?GTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT:GTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT); gtk_revealer_set_reveal_child(GTK_REVEALER(widgets->BannerRevealer),!banner_hidden); gtk_menu_button_set_direction(GTK_MENU_BUTTON(widgets->BannerArrow),!banner_hidden?GTK_ARROW_LEFT:GTK_ARROW_RIGHT); } - gtk_widget_show(widgets->Window); yon_interface_update(widgets); return widgets; @@ -641,7 +643,6 @@ int main(int argc, char *argv[]){ } } gtk_init(&argc, &argv); - config_init(); main_window *widgets = yon_main_window_setup(); GtkCssProvider *css=gtk_css_provider_new(); diff --git a/source/ubl-settings-manager.h b/source/ubl-settings-manager.h index 783c4e5..a721735 100644 --- a/source/ubl-settings-manager.h +++ b/source/ubl-settings-manager.h @@ -38,6 +38,8 @@ #define glade_path_gnome_section "/com/ublinux/ui/ubl-settings-manager-theme-gnome-section.glade" #define glade_path_main_theme "/com/ublinux/ui/ubl-settings-manager-theme-main.glade" #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 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" @@ -53,6 +55,9 @@ #define launch_command(target) yon_char_unite("xdg-open ",target,NULL) #define launch_args_command(main_socket,load_socket,save_socket) yon_char_unite("--socket-id=",main_socket," --socket-ext-id=",save_socket," --socket-trd-id=",load_socket,NULL) +#define settings_section "Settings" +#define sections_section "Sections" + #define double_click_parameter "double_click" #define icon_size_parameter "icon_size" #define theme_parameter "theme" @@ -222,5 +227,6 @@ int yon_char_parsed_compare(const void *a, const void *b); void yon_interface_update(main_window *widgets); void on_settings_open(GtkWidget *, main_window *widgets); +void yon_section_window_open(GtkWidget *, settings_window *settings); #endif \ No newline at end of file diff --git a/ubl-settings-manager-section-element.glade b/ubl-settings-manager-section-element.glade new file mode 100644 index 0000000..6493942 --- /dev/null +++ b/ubl-settings-manager-section-element.glade @@ -0,0 +1,61 @@ + + + + + + True + False + 5 + + + True + False + 15 + True + False + name + + + True + True + 0 + + + + + True + False + 25 + False + + + True + True + 1 + + + + + True + True + True + center + image2 + + + + False + True + 2 + + + + + True + False + 16 + com.ublinux.libublsettingsui-gtk3.trash-symbolic + + diff --git a/ubl-settings-manager-settings-sections.glade b/ubl-settings-manager-settings-sections.glade index 2fa7881..406f7ce 100644 --- a/ubl-settings-manager-settings-sections.glade +++ b/ubl-settings-manager-settings-sections.glade @@ -3,245 +3,198 @@ - + + True + False + 16 + com.ublinux.libublsettingsui-gtk3.funnel-symbolic + + + True + False + 16 + com.ublinux.libublsettingsui-gtk3.accept-symbolic + + + True + False + com.ublinux.libublsettingsui-gtk3.cancel-uncolored-symbolic + + + True False - 800 - 600 + com.ublinux.libublsettingsui-gtk3.accept-symbolic + + + 450 + 350 + True + False + True + com.ublinux.ubl-settings-manager True False vertical + 5 - + True - True - 5 - 5 + False + vertical + + + + + + False + True + 0 + + + + + True + False 5 5 - 5 5 - in + vertical + 5 - + True - False + True + in - + True False - vertical - + True False - 5 - 5 5 5 5 5 vertical + 5 - - False - True - 0 - + + + + + True + True + 0 + + + + + True + False + 0.019999999552965164 + in + + + True + False + 5 + 5 + 5 + 5 - + True False - 5 - 5 - 5 - 5 - 0.019999999552965164 - in + 5 - + True - False - 3 - 3 - 5 - 5 - - - True - False - - - True - True - True - center - 3 - 3 - image2 - - - False - True - 0 - - - - - True - True - True - False - Section name - name - - - True - True - 1 - - - - - True - False - - - True - False - center - - - True - True - True - 5 - 5 - image4 - - - False - True - end - 2 - - - - - True - False - 2 - - - True - True - 5 - 10 - 5 - 10 - False - Identifier - - - True - True - 0 - - - - - True - True - 2 - - - - - True - True - 1 - - - - - True - True - 2 - - - - + True + 15 + True + False + Section name + name + + True + True + 0 + - - + + + True + True + 25 + False + Identifier + + + True + True + 1 + + + + + True + True + True + center + image2 + + + + False + True + 2 + + + + + True + True + True + image4 + + + + False + True + end + 3 + - - False - True - 1 - - - - - - True - True - 0 - - - - - True - False - - - Save and apply - True - True - True - 5 - 5 - 5 - image7 - - - False - True - end - 0 - - - - - Close - True - True - True - 15 - 15 - 5 - image6 + + + False True - end 1 - False + True True 1 @@ -249,11 +202,11 @@ - + True False - + True False UBLinux Settings Manager @@ -271,29 +224,32 @@ 5 + + + Cancel + True + True + True + image6 + + + 1 + + + + + Apply + True + True + True + image7 + + + end + 2 + + - - True - False - 16 - user-trash-symbolic - - - True - False - 16 - object-select-symbolic - - - True - False - process-stop-symbolic - - - True - False - emblem-ok-symbolic - diff --git a/ubl-settings-manager-theme-gnome-section.glade b/ubl-settings-manager-theme-gnome-section.glade index 600e2c4..b7ecb20 100644 --- a/ubl-settings-manager-theme-gnome-section.glade +++ b/ubl-settings-manager-theme-gnome-section.glade @@ -6,6 +6,8 @@ True True + True + True True diff --git a/ubl-settings-manager-theme-gnome.glade b/ubl-settings-manager-theme-gnome.glade index 249c798..f2d2ac0 100644 --- a/ubl-settings-manager-theme-gnome.glade +++ b/ubl-settings-manager-theme-gnome.glade @@ -28,11 +28,15 @@ True True - in True False + 5 + 5 + 5 + 5 + none True