diff --git a/gresource.xml b/gresource.xml
index 2434328..1dd3f75 100644
--- a/gresource.xml
+++ b/gresource.xml
@@ -7,6 +7,7 @@
ubl-settings-repomanager-repo-block.glade
ubl-settings-repomanager-filechooser.glade
ubl-settings-repomanager-key.glade
+ ubl-settings-repomanager-sign.glade
ubl-settings-repomanager.css
diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt
index 9ee5702..65f3e99 100644
--- a/source/CMakeLists.txt
+++ b/source/CMakeLists.txt
@@ -40,6 +40,7 @@ set(DEPENDFILES
../ubl-settings-repomanager-configuration.glade
../ubl-settings-repomanager-filechooser.glade
../ubl-settings-repomanager-key.glade
+ ../ubl-settings-repomanager-sign.glade
../ubl-settings-repomanager-repo-block.glade
../gresource.xml
../ubl-settings-repomanager-banner.png
diff --git a/source/ubl-settings-repomanager.c b/source/ubl-settings-repomanager.c
index a18167b..82d4776 100644
--- a/source/ubl-settings-repomanager.c
+++ b/source/ubl-settings-repomanager.c
@@ -139,20 +139,28 @@ void on_storage_open(GtkWidget *self, storage_config_window *window){
if (responce == GTK_RESPONSE_ACCEPT){
char *path = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
if (!yon_char_is_empty(path)){
- GtkTreeIter iter, itar;
- gtk_tree_store_append(window->storages_copy,&iter,NULL);
- char *name = yon_char_new(path);
- free(yon_char_divide(name,yon_char_find_last(name,'/')));
- gtk_tree_store_set(window->storages_copy,&iter,2,name,3,path,-1);
- gtk_entry_set_text(GTK_ENTRY(window->AddEntry),"");
- char *iterpath = gtk_tree_model_get_string_from_iter(GTK_TREE_MODEL(window->storages_copy),&iter);
- gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(window->StoragePathCombo),iterpath,path);
- char *repos=NULL;
- int repos_size=0;
- g_signal_handlers_block_by_func(G_OBJECT(window->StoragePathCombo),on_storage_changed,window);
- yon_gtk_combo_box_text_find(window->StoragePathCombo,path);
- g_signal_handlers_unblock_by_func(G_OBJECT(window->StoragePathCombo),on_storage_changed,window);
- yon_window_config_add_instant_parameter(path,"storage_info","",YON_TYPE_STRING);
+ int size;
+ config_str files = yon_file_list_dirs(path,&size);
+ if (!files){
+ yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_FOLDER_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE);
+ gtk_widget_destroy(dialog);
+ return;
+ } else {
+ yon_char_parsed_free(files,size);
+ GtkTreeIter iter, itar;
+ gtk_tree_store_append(window->storages_copy,&iter,NULL);
+ char *name = yon_char_new(path);
+ free(yon_char_divide(name,yon_char_find_last(name,'/')));
+ gtk_tree_store_set(window->storages_copy,&iter,2,name,3,path,-1);
+ gtk_entry_set_text(GTK_ENTRY(window->AddEntry),"");
+ char *iterpath = gtk_tree_model_get_string_from_iter(GTK_TREE_MODEL(window->storages_copy),&iter);
+ gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(window->StoragePathCombo),iterpath,path);
+ char *repos=NULL;
+ int repos_size=0;
+ g_signal_handlers_block_by_func(G_OBJECT(window->StoragePathCombo),on_storage_changed,window);
+ yon_gtk_combo_box_text_find(window->StoragePathCombo,path);
+ g_signal_handlers_unblock_by_func(G_OBJECT(window->StoragePathCombo),on_storage_changed,window);
+ yon_window_config_add_instant_parameter(path,"storage_info","",YON_TYPE_STRING);
config_str repos_list = yon_file_list_dirs(path,&repos_size);
for (int i=0;istorages_copy,&iter,NULL);
- char *name = yon_char_new(path);
- free(yon_char_divide(name,yon_char_find_last(name,'/')));
- gtk_tree_store_set(window->storages_copy,&iter,2,name,3,path,-1);
- char *iterpath = gtk_tree_model_get_string_from_iter(GTK_TREE_MODEL(window->storages_copy),&iter);
- gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(window->StoragePathCombo),iterpath,path);
- g_signal_handlers_block_by_func(G_OBJECT(window->StoragePathCombo),on_storage_changed,window);
- yon_gtk_combo_box_text_find(window->StoragePathCombo,path);
- g_signal_handlers_unblock_by_func(G_OBJECT(window->StoragePathCombo),on_storage_changed,window);
- gtk_entry_set_text(GTK_ENTRY(window->AddEntry),"");
- yon_window_config_add_instant_parameter(path,"storage_info","",YON_TYPE_STRING);
+ int size;
+ config_str files = yon_file_list_dirs(path,&size);
+ if (files){
+ yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),FILES_EXIST_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE);
+ gtk_widget_destroy(dialog);
+ return;
+ } else {
+ yon_char_parsed_free(files,size);
+ GtkTreeIter iter;
+ gtk_tree_store_append(window->storages_copy,&iter,NULL);
+ char *name = yon_char_new(path);
+ free(yon_char_divide(name,yon_char_find_last(name,'/')));
+ gtk_tree_store_set(window->storages_copy,&iter,2,name,3,path,-1);
+ char *iterpath = gtk_tree_model_get_string_from_iter(GTK_TREE_MODEL(window->storages_copy),&iter);
+ gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(window->StoragePathCombo),iterpath,path);
+ g_signal_handlers_block_by_func(G_OBJECT(window->StoragePathCombo),on_storage_changed,window);
+ yon_gtk_combo_box_text_find(window->StoragePathCombo,path);
+ g_signal_handlers_unblock_by_func(G_OBJECT(window->StoragePathCombo),on_storage_changed,window);
+ gtk_entry_set_text(GTK_ENTRY(window->AddEntry),"");
+ yon_window_config_add_instant_parameter(path,"storage_info","",YON_TYPE_STRING);
+ }
}
}
yon_storage_config_update(window);
@@ -1634,6 +1653,77 @@ void on_update_clicked(GtkWidget *self, main_window *widgets){
yon_config_load_update(widgets);
}
+void on_sign_window_accept(GtkWidget *self, dictionary *dict){
+ main_window *widgets = yon_dictionary_get_data(dict->first,main_window*);
+ sign_window *window = yon_dictionary_get_data(dict->first->next,sign_window*);
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->ReposTree)),&model,&iter)){
+ char *arch;
+ char *repo;
+ char *storage;
+ char *signature = (char*)gtk_combo_box_get_active_id(GTK_COMBO_BOX(window->SignCombo));
+ gtk_tree_model_get(GTK_TREE_MODEL(widgets->RepoList),&iter,3,&arch,-1);
+ repo = yon_char_divide(arch,yon_char_find_last(arch,'/'));
+ storage = yon_char_divide(repo,yon_char_find_last(repo,'/'));
+ storage = yon_char_append(storage,"/");
+ GList *list = gtk_tree_selection_get_selected_rows(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->RepoFileTree)),NULL);
+ char *targets = "";
+ for (int i=0;iRepoFileList),&iter,(GtkTreePath*)g_list_nth_data(list,i));
+ gtk_tree_model_get(GTK_TREE_MODEL(widgets->RepoFileList),&iter,1,&pack,-1);
+ char *temp = yon_char_unite(targets, " ", pack,NULL);
+ if (!yon_char_is_empty(targets)) free(targets);
+ targets=temp;
+ }
+ if (!system(yon_debug_output("%s\n",yon_sign_package(storage,repo,arch,targets,signature)))){
+ yon_ubl_status_box_render(SIGN_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);
+ }
+ on_subwindow_close(window->Window);
+ }
+}
+
+sign_window *yon_sign_window_new(){
+ sign_window *window = malloc(sizeof(sign_window));
+ GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_sign);
+
+ window->Window = yon_gtk_builder_get_widget(builder,"MainWindow");
+ window->StatusBox = yon_gtk_builder_get_widget(builder,"StatusBox");
+ window->HeadLabel = yon_gtk_builder_get_widget(builder,"HeadLabel");
+ window->SignCombo = yon_gtk_builder_get_widget(builder,"SignCombo");
+ window->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton");
+ window->SignButton = yon_gtk_builder_get_widget(builder,"SignButton");
+
+ g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL);
+
+ return window;
+}
+
+void on_packages_sign(GtkWidget *self, main_window *widgets){
+ sign_window *window = yon_sign_window_new();
+ yon_gtk_window_setup(GTK_WINDOW(window->Window),GTK_WINDOW(widgets->Window),SIGNATURE_TITLE_LABEL,icon_path,"sign-window");
+ yon_combo_box_text_set_signs(GTK_COMBO_BOX_TEXT(window->SignCombo));
+ 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->SignButton),"clicked",G_CALLBACK(on_sign_window_accept),dict);
+ gtk_widget_show(window->Window);
+}
+
+int yon_tree_is_selected(void *widget){
+ main_window *widgets = (main_window*)widget;
+ GtkTreeModel *model;
+ GtkTreeIter iter, itar;
+ if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->RepoFileTree)),&model,&iter)){
+ gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->ReposTree)),NULL,&itar);
+ if (gtk_tree_store_iter_depth(widgets->RepoList,&itar)==2){
+ return 1;
+ }
+ }
+ return 0;
+}
+
main_window *yon_main_window_complete(main_window *widgets){
widgets = yon_remalloc(widgets,sizeof(main_window));
GtkBuilder *builder = gtk_builder_new_from_resource(glade_path);
@@ -1673,6 +1763,8 @@ main_window *yon_main_window_complete(main_window *widgets){
}
main_config.tree_store = widgets->RepoList;
+ rmb_menu_window *rmb = yon_rmb_menu_setup(widgets->RepoFileTree, yon_tree_is_selected,widgets,SIGN_LABEL,lib_key_icon_name,G_CALLBACK(on_packages_sign),widgets,NULL);
+
g_signal_connect(G_OBJECT(widgets->DBConfigurationButton),"clicked",G_CALLBACK(on_storage_configure_clicked),widgets);
g_signal_connect(G_OBJECT(widgets->AddButton),"clicked",G_CALLBACK(on_add_clicked),widgets);
g_signal_connect(G_OBJECT(widgets->MoveButton),"clicked",G_CALLBACK(on_move_clicked),widgets);
diff --git a/source/ubl-settings-repomanager.h b/source/ubl-settings-repomanager.h
index 8d6abe4..988028f 100644
--- a/source/ubl-settings-repomanager.h
+++ b/source/ubl-settings-repomanager.h
@@ -27,6 +27,7 @@
#define glade_path_repo_block "/com/ublinux/ui/ubl-settings-repomanager-repo-block.glade"
#define glade_path_filechooser "/com/ublinux/ui/ubl-settings-repomanager-filechooser.glade"
#define glade_path_key "/com/ublinux/ui/ubl-settings-repomanager-key.glade"
+#define glade_path_sign "/com/ublinux/ui/ubl-settings-repomanager-sign.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)
@@ -40,6 +41,7 @@
#define LocalePath "/usr/share/locale"
#define LocaleName "ubl-settings-repomanager"
+#define lib_key_icon_name "com.ublinux.libublsettingsui-gtk3.key-symbolic"
#define key_icon_name "com.ublinux.ubl-settings-repomanager.document-sign-symbolic"
#define key_error_icon_name "com.ublinux.ubl-settings-repomanager.document-sign-error-symbolic"
@@ -74,7 +76,7 @@ typedef char* string;
#define yon_repo_get_signature(path, repo) yon_char_unite("repo-manager verify --quiet -d ",path," -r ",repo," . 2>&1 | cut -d: -f2 |sed -E 's/ *//g'",NULL)
#define yon_repo_get_signature_status(path,repo,arch, package) yon_char_unite("repo-manager verify --quiet -d ",path," -r ",repo," ",package,NULL)
#define yon_repo_get_signature_status_arch(path,repo,arch) yon_char_unite("repo-manager verify --quiet -d ",path," -r ",repo," .",NULL)
-#define yon_repo_get_signature_status_packages(path,repo,arch) yon_char_unite("repo-manager verify -d ",path," -r ",repo,NULL)
+#define yon_repo_get_signature_status_packages(path,repo,arch) yon_char_unite("repo-manager verify --quiet -d ",path," -r ",repo,NULL)
#define yon_get_package_name_from_filename(path) yon_char_unite("[[ '",path,"' =~ (.*/)*(.*)-[^-]+-[^-]+-[^-]+\\.pkg\\.tar\\.[^.-]+ ]] && echo ${BASH_REMATCH[2]}",NULL)
@@ -243,6 +245,15 @@ typedef struct {
unsigned long expire_time;
} key_creation_window;
+typedef struct {
+ GtkWidget *Window;
+ GtkWidget *StatusBox;
+ GtkWidget *HeadLabel;
+ GtkWidget *CancelButton;
+ GtkWidget *SignButton;
+ GtkWidget *SignCombo;
+} sign_window;
+
main_window *setup_window();
void yon_storage_config_update(storage_config_window *window);
diff --git a/source/ubl-strings.h b/source/ubl-strings.h
index 051355c..739457e 100644
--- a/source/ubl-strings.h
+++ b/source/ubl-strings.h
@@ -156,4 +156,12 @@
#define SIGNATURE_INFO_LABEL _("Signature")
-#define SIGN_STATUS_LABEL _("Signature status")
\ No newline at end of file
+#define SIGN_STATUS_LABEL _("Signature status")
+
+#define SIGNATURE_TITLE_LABEL _("Sign packages")
+
+#define SIGN_SUCCESS_LABEL _("Packages successfully signed")
+
+#define EMPTY_FOLDER_LABEL _("Folder must contain repositories")
+
+#define FILES_EXIST_LABEL _("Folder must not be empty")
\ No newline at end of file
diff --git a/ubl-settings-repomanager-sign.glade b/ubl-settings-repomanager-sign.glade
new file mode 100644
index 0000000..584e3fa
--- /dev/null
+++ b/ubl-settings-repomanager-sign.glade
@@ -0,0 +1,132 @@
+
+
+
+
+
+
+
diff --git a/ubl-settings-repomanager.pot b/ubl-settings-repomanager.pot
index 3cbac15..4ce191e 100644
--- a/ubl-settings-repomanager.pot
+++ b/ubl-settings-repomanager.pot
@@ -320,7 +320,7 @@ msgid "Packages were moved successfully"
msgstr ""
#: source/ubl-strings.h:92
-msgid "Storages changes saved"
+msgid "Changes saved"
msgstr ""
#: source/ubl-strings.h:93
@@ -508,3 +508,19 @@ msgstr ""
#: source/ubl-strings.h:159
msgid "Signature status"
msgstr ""
+
+#: source/ubl-strings.h:161
+msgid "Sign packages"
+msgstr ""
+
+#: source/ubl-strings.h:163
+msgid "Packages successfully signed"
+msgstr ""
+
+#: source/ubl-strings.h:165
+msgid "Folder must contain repositories"
+msgstr ""
+
+#: source/ubl-strings.h:167
+msgid "Folder must not be empty"
+msgstr ""
diff --git a/ubl-settings-repomanager_ru.po b/ubl-settings-repomanager_ru.po
index 29edbde..f7624f4 100644
--- a/ubl-settings-repomanager_ru.po
+++ b/ubl-settings-repomanager_ru.po
@@ -520,3 +520,19 @@ msgstr "Подпись"
#: source/ubl-strings.h:159
msgid "Signature status"
msgstr "Статус подписи"
+
+#: source/ubl-strings.h:161
+msgid "Sign packages"
+msgstr "Подписать пакеты"
+
+#: source/ubl-strings.h:163
+msgid "Packages successfully signed"
+msgstr "Пакеты успешно подписаны"
+
+#: source/ubl-strings.h:165
+msgid "Folder must contain repositories"
+msgstr "Директория должна содержать репозитории"
+
+#: source/ubl-strings.h:167
+msgid "Folder must not be empty"
+msgstr "Директория должна быть пустой"