From 7c6244f5ba47f4f8436eb6deeef6a1146f465a58 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Mon, 14 Oct 2024 18:05:01 +0600 Subject: [PATCH] Saving windows WIP --- gresource.xml | 1 + source/CMakeLists.txt | 1 + source/ubl-settings-update.c | 100 +++++++- source/ubl-settings-update.h | 10 + ubl-settings-update-mirror-add.glade | 225 +++++++++++++----- ubl-settings-update-mirror-path-add.glade | 72 ++++++ ubl-settings-update-repo-add.glade | 30 +-- ubl-settings-update-web-publication-add.glade | 53 ++--- ubl-settings-update.css | 6 + ubl-settings-update.glade | 70 +++++- 10 files changed, 444 insertions(+), 124 deletions(-) create mode 100644 ubl-settings-update-mirror-path-add.glade diff --git a/gresource.xml b/gresource.xml index ad5e3f1..f736816 100644 --- a/gresource.xml +++ b/gresource.xml @@ -5,6 +5,7 @@ ubl-settings-update-repo-add.glade ubl-settings-update-web-publication-add.glade ubl-settings-update-mirror-add.glade + ubl-settings-update-mirror-path-add.glade ubl-settings-update-mirror-configure.glade diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 537cbbf..4fa7a4d 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -35,6 +35,7 @@ set(DEPENDFILES ../ubl-settings-update-repo-add.glade ../ubl-settings-update-web-publication-add.glade ../ubl-settings-update-mirror-add.glade + ../ubl-settings-update-mirror-path-add.glade ../ubl-settings-update-mirror-configure.glade ../gresource.xml ../ubl-settings-update-banner.png diff --git a/source/ubl-settings-update.c b/source/ubl-settings-update.c index 8542fed..f957b59 100644 --- a/source/ubl-settings-update.c +++ b/source/ubl-settings-update.c @@ -160,6 +160,43 @@ void yon_interface_update(main_window *widgets){ } } + config_str web_publish = yon_config_get_all_by_key(REPOPUBLIC_WEB_search,&size); + for (int i=0;iWebPublicationList,&iter); + char *cur = yon_char_new(web_publish[i]); + char *key = yon_char_divide_search(cur,"=",-1); + free(yon_char_divide_search(key,"[",-1)); + key[strlen(key)-1]='\0'; + char *path = yon_char_divide_search(key,":",-1); + int repos_size; + config_str repos = yon_char_parse(key,&repos_size,","); + + gtk_list_store_set(widgets->WebPublicationList,&iter,1,path,2,yon_char_parsed_to_string(repos,repos_size,"\n"),-1); + int cur_size; + config_str parsed = yon_char_parse(cur,&cur_size,":"); + if (cur_size){ + if (!strcmp(parsed[0],"enable")||!strcmp(parsed[0],"yes")){ + gtk_list_store_set(widgets->WebPublicationList,&iter,0,1,-1); + } else if (!strcmp(parsed[0],"disable")||!strcmp(parsed[0],"no")||!strcmp(parsed[0],"none")) { + gtk_list_store_set(widgets->WebPublicationList,&iter,0,0,-1); + } + if (cur_size>1&&!strcmp(parsed[1],"listing")){ + + } + if (cur_size>2&&!yon_char_is_empty(parsed[2])){ + gtk_list_store_set(widgets->WebPublicationList,&iter,4,parsed[2],-1); + } + if (cur_size>3&&!yon_char_is_empty(parsed[3])){ + gtk_list_store_set(widgets->WebPublicationList,&iter,5,parsed[3],-1); + } + if (cur_size>4&&!yon_char_is_empty(parsed[4])){ + gtk_list_store_set(widgets->WebPublicationList,&iter,6,parsed[4],-1); + } + if (cur_size>5&&!yon_char_is_empty(parsed[5])){ + gtk_list_store_set(widgets->WebPublicationList,&iter,7,parsed[5],-1); + } + } + } } // standard functions @@ -318,14 +355,15 @@ void on_mirror_configure(GtkWidget *,main_window *widgets){ void on_repo_accept_clicked(GtkWidget *, dictionary *dict){ // main_window *widgets = yon_dictionary_get_data(dict->first,main_window*); repo_add_window *window = yon_dictionary_get_data(dict->first->next,repo_add_window*); - // int enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->EnabledCheck)); + + int enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->EnabledCheck)); const char *repo_name = gtk_entry_get_text(GTK_ENTRY(window->RepoNameEntry)); if (yon_char_is_empty(repo_name)){ yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); yon_ubl_status_highlight_incorrect(window->RepoNameEntry); return; } - // int source_mode = gtk_combo_box_get_active(GTK_COMBO_BOX(window->RepoSourceCombo)); + char *source_mode = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(window->RepoSourceCombo)); const char *source_path = gtk_entry_get_text(GTK_ENTRY(window->RepoSourceEntry)); if (yon_char_is_empty(source_path)){ yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); @@ -333,28 +371,70 @@ void on_repo_accept_clicked(GtkWidget *, dictionary *dict){ return; } - // int sign_level_package = gtk_combo_box_get_active(GTK_COMBO_BOX(window->RepoSignCheckCombo)); - // int sign_level_condiition = gtk_combo_box_get_active(GTK_COMBO_BOX(window->RepoSignConditionCombo)); + char *sign_level_package = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(window->RepoSignCheckCombo)); + char *sign_level_condiition = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(window->RepoSignConditionCombo)); // int usage_level_default = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->UsageDefaultCheck)); // int usage_level_enable_update = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->UsageEnableUpdateCheck)); // int usage_level_enable_search = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->UsageEnableSearchCheck)); // int usage_level_enable_install = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->UsageEnableInsallCheck)); // int usage_level_sysupgrade = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->UsageSysupgradeCheck)); + + char *final = yon_char_unite(source_mode,source_path,";",sign_level_package,",",sign_level_condiition,";",enabled?"":"disable",NULL); + + yon_config_register(REPOSITORY(repo_name),REOSITORY_command(repo_name),final); + gtk_widget_destroy(window->Window); free(window); } -void on_web_publish_accept(GtkWidget *, dictionary *){ +void on_web_publish_accept(GtkWidget *, dictionary *dict){ // main_window *widgets = yon_dictionary_get_data(dict->first,main_window*); - // repo_add_window *window = yon_dictionary_get_data(dict->first->next,repo_add_window*); + web_publication_add_window *window = yon_dictionary_get_data(dict->first->next,web_publication_add_window*); + int enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->EnablePublishCheck)); + // char *path = (char*)gtk_entry_get_text(GTK_ENTRY(window->PathEntry)); + int port_enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->PortCheck)); + char *port = (char*)gtk_entry_get_text(GTK_ENTRY(window->PortEntry)); + int enable_browser = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->EnableWebFileBrowserCheck)); + + int username_check = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->UsernameCheck)); + char *username = (char*)gtk_entry_get_text(GTK_ENTRY(window->UsernameEntry)); + char *user_password = (char*)gtk_entry_get_text(GTK_ENTRY(window->UserPasswordEntry)); + + char *name = ""; + char *final = yon_char_unite(enabled?"enable":"disable",":",enable_browser?"listing":"",":",port_enabled?port:"",":",username_check?username:"",username_check?user_password:"",NULL); + yon_config_register(REPOPUBLIC_WEB_full(name),REPOPUBLIC_WEB_command(name),final); } void on_mirror_accept(GtkWidget *,dictionary *){ // main_window *widgets = yon_dictionary_get_data(dict->first,main_window*); - // repo_add_window *window = yon_dictionary_get_data(dict->first->next,repo_add_window*); + // mirror_add_window *window = yon_dictionary_get_data(dict->first->next,mirror_add_window*); + // char *name = (char*)gtk_entry_get_text(GTK_ENTRY(window->NameEntry)); + // char *path = (char*)gtk_entry_get_text(GTK_ENTRY(window->TypeEntry)); +} + +void on_mirror_path_removed(GtkWidget *, GtkWidget *target){ + if (GTK_IS_WIDGET(target)){ + gtk_widget_destroy(target); + } +} + +void on_mirror_path_add(GtkWidget *, mirror_add_window *window){ + const char *target = gtk_entry_get_text(GTK_ENTRY(window->TypeEntry)); + if (yon_char_is_empty(target)){ + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect(window->TypeEntry); + return; + } + char *type = (char*)gtk_combo_box_get_active_id(GTK_COMBO_BOX(window->TypeCombo)); + char *full_name = yon_char_unite(type,"@",target,NULL); + gtk_entry_set_text(GTK_ENTRY(window->TypeEntry),""); + GtkBuilder *builder = gtk_builder_new_from_resource(glade_mirror_path_add_path); + gtk_box_pack_start(GTK_BOX(window->PathBox),yon_gtk_builder_get_widget(builder,"PathRemovalBox"),0,0,5); + gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(builder,"PathLabel")),full_name); + g_signal_connect(gtk_builder_get_object(builder,"PathRemoveButton"),"clicked",G_CALLBACK(on_mirror_path_removed),gtk_builder_get_object(builder,"PathRemovalBox")); } @@ -454,10 +534,16 @@ mirror_add_window *yon_mirror_add_window_new(){ window->TypeCombo = yon_gtk_builder_get_widget(builder,"TypeCombo"); window->TypeEntry = yon_gtk_builder_get_widget(builder,"TypeEntry"); window->TypeButton = yon_gtk_builder_get_widget(builder,"TypeButton"); + window->AddButton = yon_gtk_builder_get_widget(builder,"AddButton"); window->AcceptButton = yon_gtk_builder_get_widget(builder,"AcceptButton"); window->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton"); window->HeadLabel = yon_gtk_builder_get_widget(builder,"HeadLabel"); + window->PathBox = yon_gtk_builder_get_widget(builder,"PathBox"); + window->PathRemovalBox = yon_gtk_builder_get_widget(builder,"PathRemovalBox"); + window->PathRemoveButton = yon_gtk_builder_get_widget(builder,"PathRemoveButton"); + window->PathLabel = yon_gtk_builder_get_widget(builder,"PathLabel"); + g_signal_connect(G_OBJECT(window->AddButton),"clicked",G_CALLBACK(on_mirror_path_add),window); g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); gtk_widget_show(window->Window); diff --git a/source/ubl-settings-update.h b/source/ubl-settings-update.h index a7000c6..2332c52 100644 --- a/source/ubl-settings-update.h +++ b/source/ubl-settings-update.h @@ -26,6 +26,7 @@ #define glade_web_publish_add_path "/com/ublinux/ui/ubl-settings-update-web-publication-add.glade" #define glade_mirror_configure_path "/com/ublinux/ui/ubl-settings-update-mirror-configure.glade" #define glade_mirror_add_path "/com/ublinux/ui/ubl-settings-update-mirror-add.glade" +#define glade_mirror_path_add_path "/com/ublinux/ui/ubl-settings-update-mirror-path-add.glade" #define banner_path "/com/ublinux/images/ubl-settings-update-banner.png" #define CssPath "/com/ublinux/css/ubl-settings-update.css" #define config_path yon_char_unite(yon_ubl_user_get_home_directory(),"/.config/",LocaleName,"/",LocaleName,".conf",NULL) @@ -44,12 +45,14 @@ #define REPOSITORY(target) yon_char_unite("REPOSITORY[",target,"]",NULL) #define REPOSITORY_parameter "REPOSITORY" +#define REOSITORY_command(target) yon_char_unite("ubconfig --source global get [update] REPOSITORY[",target,"]",NULL) #define REPOSITORY_search "REPOSITORY[" #define REPOPUBLIC_NET "REPOPUBLIC_NET" #define REPOPUBLIC_WEB "REPOPUBLIC_WEB" #define REPOPUBLIC_WEB_search "REPOPUBLIC_WEB[" #define REPOPUBLIC_WEB_full(target) yon_char_unite("REPOPUBLIC_WEB[",target,"]",NULL) +#define REPOPUBLIC_WEB_command(target) yon_char_unite("ubconfig --source global get [update] REPOPUBLIC_WEB[",target,"]",NULL) #define REPOPUBLIC_CACHE "REPOPUBLIC_CACHE" #define REPOPUBLIC_CACHE_search "REPOPUBLIC_CACHE[" #define REPOPUBLIC_CACHE_full(target) yon_char_unite("REPOPUBLIC_CACHE[",target,"]",NULL) @@ -158,12 +161,17 @@ typedef struct { GtkWidget *Window; GtkWidget *HeadLabel; GtkWidget *StatusBox; + GtkWidget *AddButton; GtkWidget *AcceptButton; GtkWidget *CancelButton; GtkWidget *NameEntry; GtkWidget *TypeCombo; GtkWidget *TypeEntry; GtkWidget *TypeButton; + GtkWidget *PathBox; + GtkWidget *PathRemovalBox; + GtkWidget *PathRemoveButton; + GtkWidget *PathLabel; } mirror_add_window; typedef struct { @@ -237,4 +245,6 @@ void on_selection_changed(GtkWidget *self, main_window *widgets); void yon_interface_update(main_window *widgets); +void on_mirror_path_add(GtkWidget *, mirror_add_window *window); +void on_mirror_path_removed(GtkWidget *, GtkWidget *target); #endif \ No newline at end of file diff --git a/ubl-settings-update-mirror-add.glade b/ubl-settings-update-mirror-add.glade index 6345b00..b26541a 100644 --- a/ubl-settings-update-mirror-add.glade +++ b/ubl-settings-update-mirror-add.glade @@ -47,47 +47,36 @@ True False + vertical 5 - - True - False - Repository name: - - - False - True - 0 - - - - - True - True - - - True - True - 1 - - - - - False - True - 0 - - - - - True - False - 5 - - + True False - Repository type: + 5 + + + True + False + Repository name: + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + False @@ -101,14 +90,10 @@ False 5 - + True False - - WEB link - Proxy server - Mirrors file - + Repository type: False @@ -117,9 +102,70 @@ - + True - True + False + 5 + + + True + False + 0 + + WEB link + Proxy server + Mirrors file + + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + + + + True + True + True + image1 + + + + False + True + 2 + + + + + True + True + True + image3 + + + + False + True + 3 + + True @@ -127,25 +173,9 @@ 1 - - - True - True - True - image1 - - - - False - True - 2 - - - True + False True 1 @@ -154,14 +184,69 @@ False True + 0 + + + + + True + True + + + True + False + + + True + False + 5 + + + True + False + vertical + + + + + + False + True + 0 + + + + + True + False + vertical + 2 + + + + + + True + True + 1 + + + + + + + + + True + True 1 - False + True True - 1 + 3 @@ -214,5 +299,17 @@ + + + + + + + + + True + False + com.ublinux.ubinstall.increase-symbolic + diff --git a/ubl-settings-update-mirror-path-add.glade b/ubl-settings-update-mirror-path-add.glade new file mode 100644 index 0000000..e0bed96 --- /dev/null +++ b/ubl-settings-update-mirror-path-add.glade @@ -0,0 +1,72 @@ + + + + + + + True + False + 5 + + + True + False + 5 + + + + + + False + True + 0 + + + + + True + False + 5 + + + True + False + True + image2 + + + + False + True + 1 + + + + + True + False + label + + + False + True + 2 + + + + + False + True + 2 + + + + + True + False + com.ublinux.libublsettingsui-gtk3.decrease-symbolic + + diff --git a/ubl-settings-update-repo-add.glade b/ubl-settings-update-repo-add.glade index e5f558e..89576d9 100644 --- a/ubl-settings-update-repo-add.glade +++ b/ubl-settings-update-repo-add.glade @@ -189,11 +189,11 @@ False 0 - Never (Signature verification will not be performed) - Optional - Required - TrustedOnly - TrustAll + Never (Signature verification will not be performed) + Optional + Required + TrustedOnly + TrustAll @@ -208,16 +208,16 @@ False 0 - PackageNever - DatabaseNever - PackageOptional - DatabaseOptional - PackageRequired - DatabaseRequired - Package TrustedOnly - Database TrustedOnly - Package TrustAll - Database TrustAll + PackageNever + DatabaseNever + PackageOptional + DatabaseOptional + PackageRequired + DatabaseRequired + Package TrustedOnly + Database TrustedOnly + Package TrustAll + Database TrustAll diff --git a/ubl-settings-update-web-publication-add.glade b/ubl-settings-update-web-publication-add.glade index 1a4130e..742d47b 100644 --- a/ubl-settings-update-web-publication-add.glade +++ b/ubl-settings-update-web-publication-add.glade @@ -258,6 +258,20 @@ False vertical 5 + + + Set + True + True + False + True + + + False + True + 0 + + True @@ -275,22 +289,6 @@ 0 - - - True - True - False - True - - - - - - False - True - 1 - - True @@ -306,7 +304,7 @@ False True - 0 + 1 @@ -326,25 +324,6 @@ 0 - - - True - True - False - True - - - - - - - False - True - 1 - - True @@ -377,7 +356,7 @@ False True - 1 + 2 diff --git a/ubl-settings-update.css b/ubl-settings-update.css index 3873397..5526ff1 100644 --- a/ubl-settings-update.css +++ b/ubl-settings-update.css @@ -9,6 +9,12 @@ .nobackground { background:transparent; } +.nobg_active:active { +background:@theme_selected_bg_color; +} +.nobg_active { +background:transparent; +} .nobackground:active { background:transparent; } diff --git a/ubl-settings-update.glade b/ubl-settings-update.glade index 9e8e317..42b38fe 100644 --- a/ubl-settings-update.glade +++ b/ubl-settings-update.glade @@ -58,7 +58,26 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - + + + + + + + + + + + + + + + + + + + + 100 @@ -1064,47 +1083,96 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. True True WebPublicationList + both Enabled + + + + 0 + + Storage + + + + 1 + + Chosen repositories + + + + 2 + + Reviewer + + + + 3 + + Port + + + + 4 + + Name + + + + 5 + + Password/Hash type + + + + 6 + + Password/Password hash + + + + 7 + +