diff --git a/gresource.xml b/gresource.xml
index 0a81b82..162aec7 100644
--- a/gresource.xml
+++ b/gresource.xml
@@ -4,6 +4,7 @@
ubl-settings-repomanager.glade
ubl-settings-repomanager-add.glade
ubl-settings-repomanager-configuration.glade
+ ubl-settings-repomanager-repo-block.glade
ubl-settings-repomanager.css
diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt
index 62d60b4..a5251e3 100644
--- a/source/CMakeLists.txt
+++ b/source/CMakeLists.txt
@@ -38,6 +38,7 @@ set(DEPENDFILES
../ubl-settings-repomanager.glade
../ubl-settings-repomanager-add.glade
../ubl-settings-repomanager-configuration.glade
+ ../ubl-settings-repomanager-repo-block.glade
../gresource.xml
../ubl-settings-repomanager-banner.png
../ubl-settings-repomanager.css
diff --git a/source/ubl-settings-repomanager.c b/source/ubl-settings-repomanager.c
index e7deeb9..6df40a8 100644
--- a/source/ubl-settings-repomanager.c
+++ b/source/ubl-settings-repomanager.c
@@ -2,7 +2,170 @@
config main_config;
+void on_repo_signed(){
+
+}
+
+void on_repo_removed(GtkWidget *self,storage_config_window *window){
+ GList *list = gtk_container_get_children(GTK_CONTAINER(gtk_widget_get_parent(self)));
+ char *repo = (char*)gtk_entry_get_text(GTK_ENTRY(g_list_nth_data(list,0)));
+ GtkTreeIter iter;
+ char *storage;
+ gtk_combo_box_get_active_iter(GTK_COMBO_BOX(window->StoragePathCombo),&iter);
+ gtk_tree_model_get(GTK_TREE_MODEL(window->StorageList),&iter,0,&storage,-1);
+ dictionary *storg = yon_dictionary_get_data(yon_dictionary_get(&window->storages,storage),dictionary*);
+ window->storages->data = yon_dictionary_rip(yon_dictionary_get(&storg,repo));
+ yon_storage_config_update(window);
+}
+
+void yon_storage_config_update(storage_config_window *window){
+ GList *children = gtk_container_get_children(GTK_CONTAINER(window->ReposBox));
+ for (int i=0;iStoragePathCombo),&iter)){
+ gtk_tree_model_get(GTK_TREE_MODEL(window->StorageList),&iter,0,&name,-1);
+ dictionary *current = yon_dictionary_get(&window->storages,name);
+ if (current&¤t->data){
+ dictionary *cur_repo = yon_dictionary_get_data(current,dictionary*);
+ dictionary *dic=NULL;
+ for_dictionaries(dic,cur_repo){
+ GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_repo_block);
+ GtkWidget *box = yon_gtk_builder_get_widget(builder,"MainBox");
+ gtk_box_pack_start(GTK_BOX(window->ReposBox),box,0,0,0);
+ g_signal_connect(gtk_builder_get_object(builder,"SignatureButton"),"clicked",G_CALLBACK(on_repo_signed),window);
+ g_signal_connect(gtk_builder_get_object(builder,"RepoRemoveButton"),"clicked",G_CALLBACK(on_repo_removed),window);
+ gtk_entry_set_text(GTK_ENTRY(gtk_builder_get_object(builder,"RepoNameEntry")),dic->key);
+ }
+ }
+ }
+}
+
//storage-configure window section
+void on_storage_open(GtkWidget *self, storage_config_window *window){
+ GtkWidget *dialog = gtk_file_chooser_dialog_new(TITLE_LABEL,GTK_WINDOW(window->MainWindow),GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,CLOSE_LABEL,GTK_RESPONSE_CANCEL,OPEN_LABEL,GTK_RESPONSE_ACCEPT,NULL);
+ int responce = gtk_dialog_run(GTK_DIALOG(dialog));
+ if (responce == GTK_RESPONSE_ACCEPT){
+ char *path = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
+ if (!yon_char_is_empty(path)){
+ GtkTreeIter iter;
+ gtk_list_store_append(window->StorageList,&iter);
+ gtk_list_store_set(window->StorageList,&iter,0,path,-1);
+ yon_dictionary_add_or_create_if_exists_with_data(window->storages,path,NULL);
+ gtk_combo_box_set_active_iter(GTK_COMBO_BOX(window->StoragePathCombo),&iter);
+ gtk_entry_set_text(GTK_ENTRY(window->AddEntry),"");
+ }
+ }
+ gtk_widget_destroy(dialog);
+}
+
+void on_storage_create(GtkWidget *self, storage_config_window *window){
+ GtkWidget *dialog = gtk_file_chooser_dialog_new(TITLE_LABEL,GTK_WINDOW(window->MainWindow),GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,CLOSE_LABEL,GTK_RESPONSE_CANCEL,OPEN_LABEL,GTK_RESPONSE_ACCEPT,NULL);
+ int responce = gtk_dialog_run(GTK_DIALOG(dialog));
+ if (responce == GTK_RESPONSE_ACCEPT){
+ char *path = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
+ if (!yon_char_is_empty(path)){
+ GtkTreeIter iter;
+ gtk_list_store_append(window->StorageList,&iter);
+ gtk_list_store_set(window->StorageList,&iter,0,path,-1);
+ yon_dictionary_add_or_create_if_exists_with_data(window->storages,path,NULL);
+ gtk_combo_box_set_active_iter(GTK_COMBO_BOX(window->StoragePathCombo),&iter);
+ gtk_entry_set_text(GTK_ENTRY(window->AddEntry),"");
+ }
+ }
+ gtk_widget_destroy(dialog);
+}
+void on_storage_disable(GtkWidget *self, storage_config_window *window){
+ dialog_confirmation_data *data = malloc(sizeof(dialog_confirmation_data));
+ data->action_text=DISABLE_CONFIRMATION_LABEL;
+ data->function=NULL;
+ data->data=NULL;
+ if (yon_confirmation_dialog_call(self,data)){
+ GtkTreeIter iter;
+ char *storage;
+ gtk_combo_box_get_active_iter(GTK_COMBO_BOX(window->StoragePathCombo),&iter);
+ gtk_tree_model_get(GTK_TREE_MODEL(window->StorageList),&iter,0,&storage,-1);
+ dictionary *storages = yon_dictionary_get(&window->storages,storage);
+ if (storages){
+ gtk_list_store_remove(window->StorageList,&iter);
+ window->storages = yon_dictionary_rip(storages);
+ }
+ }
+ yon_storage_config_update(window);
+}
+void on_storage_remove(GtkWidget *self, storage_config_window *window){
+ dialog_confirmation_data *data = malloc(sizeof(dialog_confirmation_data));
+ data->action_text=REMOVE_CONFIRMATION_LABEL;
+ data->function=NULL;
+ data->data=NULL;
+ if (yon_confirmation_dialog_call(self,data)){
+ GtkTreeIter iter;
+ char *storage;
+ gtk_combo_box_get_active_iter(GTK_COMBO_BOX(window->StoragePathCombo),&iter);
+ gtk_tree_model_get(GTK_TREE_MODEL(window->StorageList),&iter,0,&storage,-1);
+ dictionary *storages = yon_dictionary_get(&window->storages,storage);
+ if (storages){
+ gtk_list_store_remove(window->StorageList,&iter);
+ window->storages = yon_dictionary_rip(storages);
+ }
+ }
+ yon_storage_config_update(window);
+}
+
+void on_repo_add(GtkWidget *self, storage_config_window *window){
+ char *new_repo = (char*)gtk_entry_get_text(GTK_ENTRY(window->AddEntry));
+ if (yon_char_is_empty(new_repo)){
+ yon_ubl_status_highlight_incorrect(window->AddEntry);
+ yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_NAME_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE);
+ return;
+ }
+ GtkTreeIter iter;
+ char *name;
+ if (gtk_combo_box_get_active_iter(GTK_COMBO_BOX(window->StoragePathCombo),&iter)){
+ gtk_tree_model_get(GTK_TREE_MODEL(window->StorageList),&iter,0,&name,-1);
+ dictionary *current = yon_dictionary_get(&window->storages,name);
+ yon_dictionary_add_or_create_if_exists_with_data(current->data,new_repo,NULL);
+ yon_storage_config_update(window);
+ }
+
+}
+
+void on_storage_accept(GtkWidget *self,dictionary *dict){
+ main_window *widgets = yon_dictionary_get_data(dict->first,main_window*);
+ storage_config_window *window = yon_dictionary_get_data(dict->first->next,storage_config_window*);
+ dictionary *present = NULL;
+ GtkTreeIter iter;
+ int valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(widgets->RepoList),&iter);
+ for (;valid;valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(widgets->RepoList),&iter)){
+ char *name;
+ gtk_tree_model_get(GTK_TREE_MODEL(widgets->RepoList),&iter,3,&name,-1);
+ if (yon_dictionary_get(&window->storages,name)){
+ dictionary *cur = yon_gtk_tree_store_get_children(GTK_TREE_STORE(widgets->RepoList),&iter,2);
+ yon_dictionary_add_or_create_if_exists_with_data(present,name,cur);
+ } else {
+ gtk_tree_store_remove(widgets->RepoList,&iter);
+ }
+ }
+ dictionary *dic=NULL;
+ GtkTreeIter parent;
+ for_dictionaries(dic,window->storages){
+ if (!yon_dictionary_get(&present,dic->key)){
+ gtk_tree_store_append(widgets->RepoList,&parent,NULL);
+ gtk_tree_store_set(widgets->RepoList,&parent,3,dic->key,-1);
+ char *name = yon_char_new(dic->key);
+ int pos = yon_char_find_last(name,'/');
+ if (pos>-1) free(yon_char_divide(name,pos));
+ gtk_tree_store_set(widgets->RepoList,&parent,2,name,3,dic->key,-1);
+ yon_gtk_tree_store_fill_children(widgets->RepoList,&parent,dic->data,2);
+ }
+
+ }
+
+ on_subwindow_close(self);
+}
+
storage_config_window *yon_storage_config_window_new(){
storage_config_window *window = malloc(sizeof(storage_config_window));
GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_storage_config);
@@ -11,7 +174,7 @@ storage_config_window *yon_storage_config_window_new(){
window->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton");
window->AcceptButton = yon_gtk_builder_get_widget(builder,"AcceptButton");
window->StatusBox = yon_gtk_builder_get_widget(builder,"StatusBox");
- window->StoragePathEntry = yon_gtk_builder_get_widget(builder,"StoragePathEntry");
+ window->StoragePathCombo = yon_gtk_builder_get_widget(builder,"StoragePathCombo");
window->OpenExistingButton = yon_gtk_builder_get_widget(builder,"OpenExistingButton");
window->CreateNewButton = yon_gtk_builder_get_widget(builder,"CreateNewButton");
window->DisableButton = yon_gtk_builder_get_widget(builder,"DisableButton");
@@ -19,8 +182,14 @@ storage_config_window *yon_storage_config_window_new(){
window->ReposBox = yon_gtk_builder_get_widget(builder,"ReposBox");
window->AddEntry = yon_gtk_builder_get_widget(builder,"AddEntry");
window->AddRepoButton = yon_gtk_builder_get_widget(builder,"AddRepoButton");
+ window->StorageList = GTK_LIST_STORE(gtk_builder_get_object(builder,"liststore1"));
g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL);
- g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_subwindow_close),NULL);
+ g_signal_connect(G_OBJECT(window->OpenExistingButton),"clicked",G_CALLBACK(on_storage_open),window);
+ g_signal_connect(G_OBJECT(window->CreateNewButton),"clicked",G_CALLBACK(on_storage_create),window);
+ g_signal_connect(G_OBJECT(window->DisableButton),"clicked",G_CALLBACK(on_storage_disable),window);
+ g_signal_connect(G_OBJECT(window->DeleteButton),"clicked",G_CALLBACK(on_storage_remove),window);
+ g_signal_connect(G_OBJECT(window->AddRepoButton),"clicked",G_CALLBACK(on_repo_add),window);
+ window->storages=NULL;
return window;
}
@@ -29,6 +198,18 @@ void on_storage_configure_clicked(GtkWidget *self, main_window *widgets){
storage_config_window *window = yon_storage_config_window_new();
yon_gtk_window_setup(GTK_WINDOW(window->MainWindow),GTK_WINDOW(widgets->Window),TITLE_LABEL,"com.ublinux.ubl-settings-repomanager","storage-configuration-window");
gtk_window_set_transient_for(GTK_WINDOW(window->MainWindow),GTK_WINDOW(widgets->Window));
+ GtkTreeIter iter;
+ int valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(widgets->RepoList),&iter);
+ for (;valid;valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(widgets->RepoList),&iter)){
+ char *name;
+ gtk_tree_model_get(GTK_TREE_MODEL(widgets->RepoList),&iter,2,&name,-1);
+ dictionary *cur = yon_gtk_tree_store_get_children(GTK_TREE_STORE(widgets->RepoList),&iter,2);
+ yon_dictionary_add_or_create_if_exists_with_data(window->storages,name,cur);
+ }
+ dictionary *dict = NULL;
+ yon_dictionary_add_or_create_if_exists_with_data(dict,"widgets",widgets);
+ yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window);
+ g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_storage_accept),dict);
gtk_widget_show(window->MainWindow);
}
diff --git a/source/ubl-settings-repomanager.h b/source/ubl-settings-repomanager.h
index 1b0ac73..c9a43d7 100644
--- a/source/ubl-settings-repomanager.h
+++ b/source/ubl-settings-repomanager.h
@@ -24,6 +24,7 @@
#define glade_path "/com/ublinux/ui/ubl-settings-repomanager.glade"
#define glade_path_repo_add "/com/ublinux/ui/ubl-settings-repomanager-add.glade"
#define glade_path_storage_config "/com/ublinux/ui/ubl-settings-repomanager-configuration.glade"
+#define glade_path_repo_block "/com/ublinux/ui/ubl-settings-repomanager-repo-block.glade"
#define banner_path "/com/ublinux/images/ubl-settings-repomanager-banner.png"
#define CssPath "/com/ublinux/css/ubl-settings-repomanager.css"
#define config_path yon_char_unite(yon_ubl_user_get_home_directory(),"/.config/",LocaleName,"/",LocaleName,".conf",NULL)
@@ -103,7 +104,7 @@ typedef struct {
GtkWidget *CancelButton;
GtkWidget *AcceptButton;
GtkWidget *StatusBox;
- GtkWidget *StoragePathEntry;
+ GtkWidget *StoragePathCombo;
GtkWidget *OpenExistingButton;
GtkWidget *CreateNewButton;
GtkWidget *DisableButton;
@@ -111,6 +112,10 @@ typedef struct {
GtkWidget *ReposBox;
GtkWidget *AddEntry;
GtkWidget *AddRepoButton;
+ GtkListStore *StorageList;
+ dictionary *storages;
} storage_config_window;
-main_window *setup_window();
\ No newline at end of file
+main_window *setup_window();
+
+void yon_storage_config_update(storage_config_window *window);
\ No newline at end of file
diff --git a/source/ubl-strings.h b/source/ubl-strings.h
index 86c5b73..61ef52f 100644
--- a/source/ubl-strings.h
+++ b/source/ubl-strings.h
@@ -63,4 +63,10 @@
#define PACKAGE_LABEL _("package")
#define REPOSITORY_LABEL _("repository")
#define ALREADY_EXIST _("This package already exists in that repository")
-#define REPO_ALREADY_EXISTS_LABEL _("This repository has already been added")
\ No newline at end of file
+#define REPO_ALREADY_EXISTS_LABEL _("This repository has already been added")
+
+#define CLOSE_LABEL _("Close")
+
+#define DISABLE_CONFIRMATION_LABEL _("Are you sure want to disable?")
+
+#define REMOVE_CONFIRMATION_LABEL _("Are you sure want to remove?")
\ No newline at end of file
diff --git a/ubl-settings-repomanager-configuration.glade b/ubl-settings-repomanager-configuration.glade
index a970bdd..0307cc1 100644
--- a/ubl-settings-repomanager-configuration.glade
+++ b/ubl-settings-repomanager-configuration.glade
@@ -28,6 +28,12 @@
False
com.ublinux.libublsettingsui-gtk3.increase-symbolic
+
diff --git a/ubl-settings-repomanager-filechooser.glade b/ubl-settings-repomanager-filechooser.glade
index 375dece..51e6354 100644
--- a/ubl-settings-repomanager-filechooser.glade
+++ b/ubl-settings-repomanager-filechooser.glade
@@ -25,7 +25,7 @@
False
end
-
+
Cancel
True
True
@@ -39,7 +39,7 @@
-
+
Choose
True
True
diff --git a/ubl-settings-repomanager-repo-block.glade b/ubl-settings-repomanager-repo-block.glade
new file mode 100644
index 0000000..9d02791
--- /dev/null
+++ b/ubl-settings-repomanager-repo-block.glade
@@ -0,0 +1,88 @@
+
+
+
+
+
+
+ True
+ False
+ com.ublinux.libublsettingsui-gtk3.key-symbolic
+
+
+ True
+ False
+ com.ublinux.libublsettingsui-gtk3.trash-symbolic
+
+
+ True
+ False
+ 5
+
+
+ True
+ False
+
+
+ False
+ True
+ 0
+
+
+
+
+ True
+ False
+ Signature:
+ 0
+
+
+ False
+ True
+ 1
+
+
+
+
+ True
+ False
+
+
+ True
+ True
+ 2
+
+
+
+
+ True
+ True
+ True
+ image1
+
+
+
+ False
+ True
+ 3
+
+
+
+
+ True
+ True
+ True
+ image2
+
+
+
+ False
+ True
+ 4
+
+
+
+
diff --git a/ubl-settings-repomanager.glade b/ubl-settings-repomanager.glade
index 42a9d95..6ba3b54 100644
--- a/ubl-settings-repomanager.glade
+++ b/ubl-settings-repomanager.glade
@@ -8,9 +8,36 @@
False
True
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
True
False
@@ -184,9 +211,13 @@
True
True
- RepoList
+ RepoStore
False
treeviewcolumn1
+ 2
+
+
+
column
@@ -195,13 +226,20 @@
4
+ 0
+
+
+
+
+
+ 4
1
- 0
+ 2
@@ -255,19 +293,22 @@
RepoFileList
False
0
+
+
+
column
- 1
+ 0
- 0
+ 1
@@ -291,21 +332,24 @@
True
True
- RepoPackagesTre
+ RepoPackagesStore
False
+
+
+
column
- 1
+ 0
- 0
+ 1