From fd5935ef9d8f52445f80f7797ff215ffff20f306 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Tue, 15 Oct 2024 18:27:08 +0600 Subject: [PATCH] repo adding window applying WIP --- source/ubl-settings-update.c | 95 +++++-- source/ubl-settings-update.h | 11 +- ubl-settings-update-mirror-add.glade | 308 ++++++++++++---------- ubl-settings-update-mirror-path-add.glade | 84 +++--- ubl-settings-update-repo-add.glade | 231 ++++++++++++---- ubl-settings-update.glade | 4 +- 6 files changed, 479 insertions(+), 254 deletions(-) diff --git a/source/ubl-settings-update.c b/source/ubl-settings-update.c index f957b59..e54952a 100644 --- a/source/ubl-settings-update.c +++ b/source/ubl-settings-update.c @@ -40,6 +40,11 @@ void yon_load_proceed(YON_CONFIG_TYPE type){ } void yon_interface_update(main_window *widgets){ + gtk_list_store_clear(widgets->ReposList); + gtk_list_store_clear(widgets->MirrorList); + gtk_list_store_clear(widgets->UpdateRepoList); + gtk_list_store_clear(widgets->PublicationList); + gtk_list_store_clear(widgets->WebPublicationList); int size; char *repo_config = config(REPOSITORY_parameter); if (!yon_char_is_empty(repo_config)){ @@ -353,7 +358,7 @@ 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*); + 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)); @@ -363,9 +368,19 @@ void on_repo_accept_clicked(GtkWidget *, dictionary *dict){ yon_ubl_status_highlight_incorrect(window->RepoNameEntry); return; } - 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)){ + char *sources = ""; + GList *list = gtk_container_get_children(GTK_CONTAINER(window->SourceBox)); + for (guint i=0;iStatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); yon_ubl_status_highlight_incorrect(window->RepoSourceEntry); return; @@ -380,17 +395,17 @@ void on_repo_accept_clicked(GtkWidget *, dictionary *dict){ // 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); + char *final = yon_char_unite(sources,";",sign_level_package,",",sign_level_condiition,";",enabled?"":"disable",NULL); yon_config_register(REPOSITORY(repo_name),REOSITORY_command(repo_name),final); - + yon_interface_update(widgets); gtk_widget_destroy(window->Window); free(window); } void on_web_publish_accept(GtkWidget *, dictionary *dict){ - // main_window *widgets = yon_dictionary_get_data(dict->first,main_window*); + main_window *widgets = yon_dictionary_get_data(dict->first,main_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)); @@ -406,13 +421,26 @@ void on_web_publish_accept(GtkWidget *, dictionary *dict){ 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); + yon_interface_update(widgets); } -void on_mirror_accept(GtkWidget *,dictionary *){ - // main_window *widgets = yon_dictionary_get_data(dict->first,main_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_accept(GtkWidget *,dictionary *dict){ + main_window *widgets = yon_dictionary_get_data(dict->first,main_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 *paths = ""; + GList *list = gtk_container_get_children(GTK_CONTAINER(window->PathBox)); + for (guint i=0;iTypeEntry)); if (yon_char_is_empty(target)){ @@ -432,12 +475,30 @@ void on_mirror_path_add(GtkWidget *, mirror_add_window *window){ 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); + gtk_box_pack_start(GTK_BOX(window->PathBox),yon_gtk_builder_get_widget(builder,"PathRemovalBox"),0,0,2); + gtk_entry_set_text(GTK_ENTRY(gtk_builder_get_object(builder,"PathEntry")),full_name); + g_signal_connect(gtk_builder_get_object(builder,"PathEditButton"),"clicked",G_CALLBACK(on_mirror_path_edit),gtk_builder_get_object(builder,"PathRemovalBox")); g_signal_connect(gtk_builder_get_object(builder,"PathRemoveButton"),"clicked",G_CALLBACK(on_mirror_path_removed),gtk_builder_get_object(builder,"PathRemovalBox")); } +void on_repo_source_add(GtkWidget *, repo_add_window *window){ + const char *target = gtk_entry_get_text(GTK_ENTRY(window->RepoSourceEntry)); + 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->RepoSourceEntry); + return; + } + char *type = (char*)gtk_combo_box_get_active_id(GTK_COMBO_BOX(window->RepoSourceCombo)); + char *full_name = yon_char_append(type,target); + gtk_entry_set_text(GTK_ENTRY(window->RepoSourceEntry),""); + GtkBuilder *builder = gtk_builder_new_from_resource(glade_mirror_path_add_path); + gtk_box_pack_start(GTK_BOX(window->SourceBox),yon_gtk_builder_get_widget(builder,"PathRemovalBox"),0,0,2); + gtk_entry_set_text(GTK_ENTRY(gtk_builder_get_object(builder,"PathEntry")),full_name); + g_signal_connect(gtk_builder_get_object(builder,"PathEditButton"),"clicked",G_CALLBACK(on_mirror_path_edit),gtk_builder_get_object(builder,"PathRemovalBox")); + g_signal_connect(gtk_builder_get_object(builder,"PathRemoveButton"),"clicked",G_CALLBACK(on_mirror_path_removed),gtk_builder_get_object(builder,"PathRemovalBox")); +} + repo_add_window *yon_repo_add_window_new(){ GtkBuilder *builder = gtk_builder_new_from_resource(glade_repo_add_path); repo_add_window *window = malloc(sizeof(repo_add_window)); @@ -458,7 +519,10 @@ repo_add_window *yon_repo_add_window_new(){ 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->SourceBox = yon_gtk_builder_get_widget(builder,"SourceBox"); + window->RepoSourceAddButton = yon_gtk_builder_get_widget(builder,"RepoSourceAddButton"); + g_signal_connect(G_OBJECT(window->RepoSourceAddButton),"clicked",G_CALLBACK(on_repo_source_add),window); g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); gtk_widget_show(window->Window); @@ -539,9 +603,6 @@ mirror_add_window *yon_mirror_add_window_new(){ 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); diff --git a/source/ubl-settings-update.h b/source/ubl-settings-update.h index 2332c52..3425ebb 100644 --- a/source/ubl-settings-update.h +++ b/source/ubl-settings-update.h @@ -31,6 +31,9 @@ #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) +#define accept_icon_name "com.ublinux.libublsettingsui-gtk3.accept-symbolic" +#define edit_icon_name "document-edit-symbolic" + #define LocalePath "/usr/share/locale" #define LocaleName "ubl-settings-update" #define icon_path "com.ublinux.ubl-settings-update" @@ -56,6 +59,7 @@ #define REPOPUBLIC_CACHE "REPOPUBLIC_CACHE" #define REPOPUBLIC_CACHE_search "REPOPUBLIC_CACHE[" #define REPOPUBLIC_CACHE_full(target) yon_char_unite("REPOPUBLIC_CACHE[",target,"]",NULL) +#define REPOPUBLIC_CACHE_full_command(target) yon_char_unite("ubconfig --source global get [update] REPOPUBLIC_CACHE[",target,"]",NULL) #define AUTOUPDATE "AUTOUPDATE" #define AUTOUPDATE_mode "AUTOUPDATE[mode]" #define AUTOUPDATE_interval "AUTOUPDATE[interval]" @@ -131,6 +135,8 @@ typedef struct { GtkWidget *RepoSourceButton; GtkWidget *RepoSourceEntry; GtkWidget *RepoSourceCombo; + GtkWidget *SourceBox; + GtkWidget *RepoSourceAddButton; GtkWidget *RepoNameEntry; GtkWidget *EnabledCheck; GtkWidget *AcceptButton; @@ -169,9 +175,6 @@ typedef struct { GtkWidget *TypeEntry; GtkWidget *TypeButton; GtkWidget *PathBox; - GtkWidget *PathRemovalBox; - GtkWidget *PathRemoveButton; - GtkWidget *PathLabel; } mirror_add_window; typedef struct { @@ -247,4 +250,6 @@ 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); +void on_mirror_path_edit(GtkWidget*,GtkWidget *target); +void on_repo_source_add(GtkWidget *, repo_add_window *window); #endif \ No newline at end of file diff --git a/ubl-settings-update-mirror-add.glade b/ubl-settings-update-mirror-add.glade index b26541a..bdc2cf4 100644 --- a/ubl-settings-update-mirror-add.glade +++ b/ubl-settings-update-mirror-add.glade @@ -8,6 +8,11 @@ False com.ublinux.libublsettingsui-gtk3.zoom-symbolic + + True + False + com.ublinux.ubinstall.increase-symbolic + 500 False @@ -85,161 +90,199 @@ - - True - False - 5 - - - True - False - Repository type: - - - False - True - 0 - - - - - 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 - True - 1 - - - - - False - True - 1 - + - - - False - True - 0 - - - - - True - True - + True False + 0 + in - + True False - 5 + 5 + 5 + 5 - + True False vertical + 5 - + + True + False + 5 + + + True + False + Repository type: + + + False + True + 0 + + + + + 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 + True + 1 + + + + + False + True + 0 + - - - False - True - 0 - - - - - True - False - vertical - 2 - + + True + True + + + True + False + + + True + False + 5 + + + True + False + vertical + + + + + + False + True + 0 + + + + + True + False + vertical + + + + + + True + True + 1 + + + + + + + + + True + True + 1 + - - True - True - 1 - + + + True + False + + + + True + True + 2 + True True - 1 + 0 @@ -306,10 +349,5 @@ - - 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 index e0bed96..13c785d 100644 --- a/ubl-settings-update-mirror-path-add.glade +++ b/ubl-settings-update-mirror-path-add.glade @@ -3,70 +3,72 @@ + + True + False + document-edit-symbolic + + + True + False + com.ublinux.libublsettingsui-gtk3.decrease-symbolic + True False 5 - + True False - 5 - - - + True + image2 + False True + end 0 - + + True + True + False + False + False + + + + False + True + 1 + + + + True False - 5 - - - True - False - True - image2 - - - - False - True - 1 - - - - - True - False - label - - - False - True - 2 - - + True + image1 + False True + end 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 89576d9..87b576f 100644 --- a/ubl-settings-update-repo-add.glade +++ b/ubl-settings-update-repo-add.glade @@ -95,68 +95,174 @@ - + True False - 3 - 5 - - - True - False - Source: - - - False - True - 0 - - + 0 + in - + True False - 0 - - file:// - ftp:// - http:// - https:// - Configuration - - - - False - True - 1 - - - - - True - True + 5 + 5 + 5 + 5 + + + True + False + vertical + 5 + + + True + False + 3 + 5 + + + True + False + Source: + + + False + True + 0 + + + + + True + False + 0 + + file:// + ftp:// + http:// + https:// + Configuration + + + + False + True + 1 + + + + + True + True + + + True + True + 2 + + + + + True + True + True + image1 + + + + False + True + 3 + + + + + True + True + True + image2 + + + + False + True + 4 + + + + + False + True + 0 + + + + + True + True + 100 + + + True + False + + + True + False + 5 + + + True + False + vertical + + + + + + False + True + 0 + + + + + True + False + vertical + 5 + + + + + + True + True + 1 + + + + + + + + + False + True + 1 + + + + - - True - True - 2 - - - - True - True - True - image1 - - - - False - True - 3 - + + @@ -230,7 +336,7 @@ False True - 3 + 4 @@ -337,7 +443,7 @@ True True - 4 + 5 @@ -397,4 +503,15 @@ + + + + + + + + True + False + com.ublinux.libublsettingsui-gtk3.increase-symbolic + diff --git a/ubl-settings-update.glade b/ubl-settings-update.glade index 42b38fe..c6f70a6 100644 --- a/ubl-settings-update.glade +++ b/ubl-settings-update.glade @@ -726,7 +726,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Signature level - + + 125 + 3