From fa5b9bfc31288d500091dc5c1d88f1aaf49d9ecb Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 12 Apr 2024 17:43:00 +0600 Subject: [PATCH] Repomanager rework beginning --- gresource.xml | 4 +- source/CMakeLists.txt | 17 +- source/ubl-settings-repomanager.c | 1106 ++-------- source/ubl-settings-repomanager.h | 199 +- source/ubl-strings.h | 19 - source/ubl-utils.c | 1924 ----------------- source/ubl-utils.h | 367 ---- ubl-settings-repomanager-add.glade | 620 ++++++ ubl-settings-repomanager-configuration.glade | 337 +++ ubl-settings-repomanager-filechooser.glade | 90 + ubl-settings-repomanager-move.glade | 498 +++++ ...tings-repomanager-progressbar-window.glade | 107 +- ubl-settings-repomanager-windows.glade | 549 ----- ubl-settings-repomanager.css | 84 +- ubl-settings-repomanager.glade | 1678 ++------------ 15 files changed, 2051 insertions(+), 5548 deletions(-) delete mode 100644 source/ubl-utils.c delete mode 100644 source/ubl-utils.h create mode 100644 ubl-settings-repomanager-add.glade create mode 100644 ubl-settings-repomanager-configuration.glade create mode 100644 ubl-settings-repomanager-filechooser.glade create mode 100644 ubl-settings-repomanager-move.glade rename ubl-settings-repomanager-sign.glade => ubl-settings-repomanager-progressbar-window.glade (56%) delete mode 100644 ubl-settings-repomanager-windows.glade diff --git a/gresource.xml b/gresource.xml index 58afa6e..0a81b82 100644 --- a/gresource.xml +++ b/gresource.xml @@ -2,8 +2,8 @@ ubl-settings-repomanager.glade - ubl-settings-repomanager-windows.glade - ubl-settings-repomanager-sign.glade + ubl-settings-repomanager-add.glade + ubl-settings-repomanager-configuration.glade ubl-settings-repomanager.css diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 4eb002d..62d60b4 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -8,6 +8,11 @@ include_directories(${GTK_INCLUDE_DIRS}) link_directories(${GTK_LIBRARY_DIRS}) add_definitions(${GTK_CFLAGS_OTHER}) +pkg_check_modules(VTE291 REQUIRED vte-2.91) +include_directories(${VTE291_INCLUDE_DIRS}) +link_directories(${VTE291_LIBRARY_DIRS}) +add_definitions(${VTE291_CFLAGS_OTHER}) + find_library(WEBKIT_LIBRARIES_FOUND webkit2gtk-4.0 webkit2gtk-web-extension-4.0) option(WEBKIT_FOUND "No" OFF) @@ -31,8 +36,8 @@ add_custom_target(GLADE ubl-settings-repomanager.glade) set(DEPENDFILES ../ubl-settings-repomanager.glade - ../ubl-settings-repomanager-windows.glade - ../ubl-settings-repomanager-sign.glade + ../ubl-settings-repomanager-add.glade + ../ubl-settings-repomanager-configuration.glade ../gresource.xml ../ubl-settings-repomanager-banner.png ../ubl-settings-repomanager.css @@ -70,15 +75,17 @@ set(SOURCE_FILES ubl-settings-repomanager.c ubl-settings-repomanager.h ubl-strings.h - ubl-utils.h - ubl-utils.c ${CMAKE_CURRENT_BINARY_DIR}/ubl-cmake.h ) set(LIBRARIES ${GTK_LIBRARIES} ${WEBKIT_LIBRARIES} - pthread) + ${VTE291_LIBRARIES} + pthread + ublsettings + ublsettings-gtk3 + ublsettingsui-gtk3) add_executable(${PROJECT_NAME} ${SOURCE_FILES} ${CMAKE_CURRENT_BINARY_DIR}/${GRESOURCE_C}) diff --git a/source/ubl-settings-repomanager.c b/source/ubl-settings-repomanager.c index 0abdd92..e7deeb9 100644 --- a/source/ubl-settings-repomanager.c +++ b/source/ubl-settings-repomanager.c @@ -2,766 +2,96 @@ config main_config; -/**on_close_subwindow(GtkWidget *self) - * [EN] - * Closes window in which [self] is contained. - * [RU] - * Закрывает окно, в котором расположен виджет [self]. -*/ -void on_close_subwindow(GtkWidget *self){ - gtk_widget_destroy(gtk_widget_get_toplevel(self)); +//storage-configure window section +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); + window->MainWindow = yon_gtk_builder_get_widget(builder,"MainWindow"); + window->HeadLabel = yon_gtk_builder_get_widget(builder,"HeadLabel"); + 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->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"); + window->DeleteButton = yon_gtk_builder_get_widget(builder,"DeleteButton"); + 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"); + 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); + + return window; +} + +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)); + gtk_widget_show(window->MainWindow); +} + +//repo-add window section +repo_add_window *yon_repo_add_window_new(){ + repo_add_window *window = malloc(sizeof(repo_add_window)); + GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_repo_add); + window->MainWindow = yon_gtk_builder_get_widget(builder,"MainWindow"); + window->StatusBox = yon_gtk_builder_get_widget(builder,"StatusBox"); + window->StorageCombo = yon_gtk_builder_get_widget(builder,"StorageCombo"); + window->HeadLabel = yon_gtk_builder_get_widget(builder,"HeadLabel"); + window->RepositoryCombo = yon_gtk_builder_get_widget(builder,"RepositoryCombo"); + window->ArchitectureCombo = yon_gtk_builder_get_widget(builder,"ArchitectureCombo"); + window->MoveSourceFrame = yon_gtk_builder_get_widget(builder,"MoveSourceFrame"); + window->MoveSourceStorageEntry = yon_gtk_builder_get_widget(builder,"MoveSourceStorageEntry"); + window->MoveSourceRepoEntry = yon_gtk_builder_get_widget(builder,"MoveSourceRepoEntry"); + window->MoveSourceArchEntry = yon_gtk_builder_get_widget(builder,"MoveSourceArchEntry"); + window->MoveTargetFrame = yon_gtk_builder_get_widget(builder,"MoveTargetFrame"); + window->MoveTargetStorageEntry = yon_gtk_builder_get_widget(builder,"MoveTargetStorageEntry"); + window->MoveTargetRepoEntry = yon_gtk_builder_get_widget(builder,"MoveTargetRepoEntry"); + window->MoveTargetArchEntry = yon_gtk_builder_get_widget(builder,"MoveTargetArchEntry"); + window->PackageSignCombo = yon_gtk_builder_get_widget(builder,"PackageSignCombo"); + window->RepoSignCombo = yon_gtk_builder_get_widget(builder,"RepoSignCombo"); + window->AddPackageButton = yon_gtk_builder_get_widget(builder,"AddPackageButton"); + window->RemoveButton = yon_gtk_builder_get_widget(builder,"RemoveButton"); + window->PackagesTree = yon_gtk_builder_get_widget(builder,"PackagesTree"); + window->InfoLabel = yon_gtk_builder_get_widget(builder,"InfoLabel"); + window->AddButton = yon_gtk_builder_get_widget(builder,"AddButton"); + window->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton"); + window->PackagesList = GTK_LIST_STORE(gtk_builder_get_object(builder,"PackagesList")); + + g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); + g_signal_connect(G_OBJECT(window->AddButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); + + return window; +} + +void on_add_clicked(GtkWidget *self, main_window *widgets){ + repo_add_window *window = yon_repo_add_window_new(); + yon_gtk_window_setup(GTK_WINDOW(window->MainWindow),GTK_WINDOW(widgets->Window),TITLE_LABEL,"com.ublinux.ubl-settings-repomanager","add-repo-window"); + gtk_widget_show(window->MainWindow); +} + +void on_move_clicked(GtkWidget *self, main_window *widgets){ + repo_add_window *window = yon_repo_add_window_new(); + yon_gtk_window_setup(GTK_WINDOW(window->MainWindow),GTK_WINDOW(widgets->Window),TITLE_LABEL,"com.ublinux.ubl-settings-repomanager","add-repo-window"); + gtk_widget_show(window->MoveSourceFrame); + gtk_widget_show(window->MoveTargetFrame); + gtk_widget_hide(gtk_widget_get_parent(window->PackageSignCombo)); + gtk_widget_show(window->MainWindow); +} + +void on_remove_clicked(GtkWidget *self, main_window *widgets){ + repo_add_window *window = yon_repo_add_window_new(); + yon_gtk_window_setup(GTK_WINDOW(window->MainWindow),GTK_WINDOW(widgets->Window),TITLE_LABEL,"com.ublinux.ubl-settings-repomanager","add-repo-window"); + gtk_widget_hide(gtk_widget_get_parent(window->PackageSignCombo)); + gtk_widget_show(window->MainWindow); } -/**yon_open_browser(GtkWidget *self, char *link) - * [EN] - * Opens browser with [link] link. - * [RU] - * Открывает браузер с [link] ссылкой. -*/ -void yon_open_browser(GtkWidget *self, char *link){ - yon_ubl_browser_window_open(link,TITLE_LABEL); -} - -/**on_open_documentation_confirmation(GtkWidget *self, char *link) - * [EN] - * Opens confirmation window for [link] link. - * [RU] - * Открывает окно подтверждение перехода по ссылке [link]. -*/ -void on_open_documentation_confirmation(GtkWidget *self, char *link){ - if (main_config.always_open_documentation==0){ - GtkBuilder *builder = gtk_builder_new_from_resource(glade_path); - documentation_confirmation_window *widgets = malloc(sizeof(documentation_confirmation_window)); - widgets->Window = yon_gtk_builder_get_widget(builder,"helpConfirmationWindow"); - widgets->AcceptButton = yon_gtk_builder_get_widget(builder,"ReadHelpButton"); - widgets->CloseButton = yon_gtk_builder_get_widget(builder,"CancelHelpButton"); - widgets->HatText = yon_gtk_builder_get_widget(builder,"webHeaderNameLabel"); - widgets->HeaderText = yon_gtk_builder_get_widget(builder,"helpHeader"); - widgets->InfoText = yon_gtk_builder_get_widget(builder,"helpText"); - widgets->AlwaysOpenCheck = yon_gtk_builder_get_widget(builder,"AlwaysOpenDocumentationCheckbox"); - gtk_label_set_text(GTK_LABEL(widgets->HatText),TITLE_LABEL); - gtk_label_set_text(GTK_LABEL(widgets->HeaderText),HELP_TITLE_LABEL); - gtk_label_set_text(GTK_LABEL(widgets->InfoText),HELP_INFO_LABEL); - gtk_button_set_label(GTK_BUTTON(widgets->AcceptButton),OPEN_HELP_LABEL); - gtk_button_set_label(GTK_BUTTON(widgets->AlwaysOpenCheck),HELP_ALWAYS_OPEN_LABEL); - gtk_button_set_label(GTK_BUTTON(widgets->CloseButton),CANCEL_LABEL); - gtk_widget_show_all(widgets->Window); - g_signal_connect(G_OBJECT(widgets->CloseButton),"clicked",G_CALLBACK(on_close_subwindow),NULL); - g_signal_connect(G_OBJECT(widgets->AcceptButton),"clicked",G_CALLBACK(yon_open_browser),yon_char_new(link)); - g_signal_connect(G_OBJECT(widgets->AcceptButton),"clicked",G_CALLBACK(on_close_subwindow),NULL); - - - } else { - yon_open_browser(self,link); - } -} - -/**on_link(GtkWidget *self, char* uri, gpointer user_data) - * [EN] - * Signal for hadnling AboutDialog links. - * Connect to "activate-link" signal. - * [self] is AboutDialog window; - * [uri] is activated link; - * [user_data] is pointer for user data, hasn't used in standard handler; - * [RU] - * Функция для обработки сигнала нажатия на ссылку окна AboutDialog. - * Присоединять к сигналу "activate-link". - * [self] - окно AboutDialog; - * [uri] - ссылка, по которой совершается переход; - * [user_data] - указатель на любые другие данные, не используется в стандартном обработчике; -*/ -void on_link(GtkWidget *self, char* uri, gpointer user_data){ - gtk_widget_destroy(self); - on_open_documentation_confirmation(self,uri); -} - -/**on_about() - * [EN] - * Function for setting up and showing AboutDialog. - * Connect it to "activate" signal of Documentation MenuItem. - * [RU] - * Функиця для настройки и показа окна AboutDialog. - * Присоединять к сигналу "activate" кнопки справки типа MenuItem. -*/ -void on_about(){ - GtkBuilder *builder=gtk_builder_new_from_resource(glade_path); - GtkWidget *window=yon_gtk_builder_get_widget(builder,"AboutWindow"); - GtkWidget *title=yon_gtk_builder_get_widget(builder,"headerAboutTopic"); - GtkWidget *hideButtonBox=yon_gtk_builder_get_widget(builder,"buttonBoxHide"); - gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(window),version_application); - gtk_about_dialog_set_website_label(GTK_ABOUT_DIALOG(window),PROJECT_HOME_LABEL); - gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(window),TITLE_LABEL); - gtk_label_set_text(GTK_LABEL(title),TITLE_LABEL); - g_signal_connect(G_OBJECT(window),"activate-link",G_CALLBACK(on_link),NULL); - gtk_widget_set_visible(hideButtonBox,0); - gtk_widget_destroy(hideButtonBox); - gtk_widget_show(window); -} - -void on_load(){ - gsize size=0; - gsize sigsize=0; - config_str repos = yon_window_config_get_section("repos",&size); - config_str signatures = yon_window_config_get_section("signatures",&sigsize); - gtk_tree_store_clear(main_config.tree_store); - for (int i=0;i",-1); - if (repostatus == 1) gtk_tree_store_set(main_config.tree_store,&iter,0,folder_no_edits,3,0,-1); - else if (repostatus == -1){ - yon_launch(yon_char_unite("rm -rfd ",origin_flagged,NULL)); - yon_window_config_erase_custom_parameter(origin_flagged,"repos"); - GtkTreeIter *deleteIter = gtk_tree_iter_copy(&iter); - if (!gtk_tree_model_iter_previous(GTK_TREE_MODEL(main_config.tree_store),deleteIter)){ - gtk_tree_iter_free(deleteIter); - deleteIter = gtk_tree_iter_copy(&iter); - if (!gtk_tree_model_iter_next(GTK_TREE_MODEL(main_config.tree_store),deleteIter)){ - gtk_tree_iter_free(deleteIter); - deleteIter = gtk_tree_iter_copy(&iter); - gtk_tree_store_remove(main_config.tree_store,deleteIter); - break; - } else { - gtk_tree_store_remove(main_config.tree_store,&iter); - } - } else { - gtk_tree_store_remove(main_config.tree_store,&iter); - - } - continue; - } - gboolean valid_child=gtk_tree_model_iter_children(GTK_TREE_MODEL(main_config.tree_store),&childIter,&iter); - for (;valid_child;valid_child=gtk_tree_model_iter_next(GTK_TREE_MODEL(main_config.tree_store),&childIter)){ - char *pack_name, *pack_path; - char *pack_old_repo, *pack_new_repo; - char *pack_code_name, *pack_version, *pack_arch, *pack_depends; - int pack_status=0; - gboolean moved=0; - char *icon; - char *pack_sign; - gboolean pack_signed=0; - - gtk_tree_model_get(GTK_TREE_MODEL(main_config.tree_store),&childIter,0,&icon,1,&pack_name,2,&pack_path,3,&pack_status,4,&pack_old_repo,5,&pack_new_repo,6,&moved,9,&pack_code_name,10,&pack_version,11,&pack_arch,12,&pack_depends,13,&pack_sign,14,&pack_signed,-1); - if (!pack_path) continue; - char *pack_sign_paths; - pack_sign_paths = yon_char_new(pack_path); - yon_char_divide(pack_sign_paths,yon_char_find_last(pack_sign_paths,'/')); - packnames = yon_char_unite(packnames ? yon_char_append(packnames," "):"",pack_sign_paths,NULL); - if (pack_sign&&pack_signed==1){ - char *package_full_name = yon_char_new(pack_path); - yon_char_divide(package_full_name,yon_char_find_last(package_full_name,'/')); - yon_window_config_add_custom_parameter(package_full_name,"signatures",yon_char_new(pack_sign),YON_TYPE_STRING); - yon_char_divide_search(pack_sign,"<",-1); - pack_sign=yon_char_divide_search(pack_sign,">",-1); - if (!pack_groups||!(yon_dictionary_get(&pack_groups,pack_sign))){ - dictionary *dict = yon_dictionary_new(); - dict->key = pack_sign_paths; - yon_dictionary_add_or_create_if_exists_with_data(pack_groups,yon_char_new(pack_sign),dict); - } else { - dictionary *dict = yon_dictionary_new(); - dict->key = pack_sign_paths; - yon_dictionary_add_or_create_if_exists_with_data(pack_groups->data,yon_char_new(pack_sign),dict); - } - } - printf("%d\n",pack_status); - if (pack_status==1||!strcmp(icon,document_added)){ - add_packages = yon_char_unite(add_packages ? yon_char_append(add_packages,",") : "",pack_path,NULL); - yon_char_divide(pack_path,yon_char_find_last(pack_path,'/')); - pack_path = yon_char_unite(origin_flagged,"/pool/overlay/",pack_path,NULL); - gtk_tree_store_set(main_config.tree_store,&childIter,2,pack_path,-1); - repostatus=1; - } else if (pack_status==-1||!strcmp(icon,document_deleted)){ - remove_packages = yon_char_unite(remove_packages ? yon_char_append(remove_packages,",") : "",pack_code_name,NULL); - } - if (pack_status==1||!strcmp(icon,document_added)) gtk_tree_store_set(main_config.tree_store,&childIter,0,document_no_edits,3,0,-1); - if (pack_status == -1||!strcmp(icon,document_deleted)){ - GtkTreeIter *deleteIter = gtk_tree_iter_copy(&childIter); - if (!gtk_tree_model_iter_previous(GTK_TREE_MODEL(main_config.tree_store),deleteIter)){ - gtk_tree_iter_free(deleteIter); - deleteIter = gtk_tree_iter_copy(&childIter); - if (!gtk_tree_model_iter_next(GTK_TREE_MODEL(main_config.tree_store),deleteIter)){ - gtk_tree_iter_free(deleteIter); - deleteIter = gtk_tree_iter_copy(&childIter); - gtk_tree_store_remove(main_config.tree_store,deleteIter); - break; - } else { - gtk_tree_store_remove(main_config.tree_store,&childIter); - } - } else { - gtk_tree_store_remove(main_config.tree_store,&childIter); - } - } - } - if (origin_flagged&&name_flagged){ - if (add_packages){ - char *sign_check = repo_sign_flagged ? yon_char_new(repo_sign_flagged) : NULL; - add_command = yon_char_unite(command, " add -d \"",origin_flagged,"\" -r \"",name_flagged, sign_flagged ? yon_char_append("\" --sign-repo ",sign_flagged):"\"" ," -p ", add_packages,NULL); - } - if (remove_packages){ - char *sign_check = repo_sign_flagged ? yon_char_new(repo_sign_flagged) : NULL; - remove_command = yon_char_unite(command, " remove -d \"",origin_flagged,"\" -r \"",name_flagged, sign_flagged ? yon_char_append("\" --sign-repo ",sign_flagged):"\"" , " -p ", remove_packages,NULL); - } - if (repostatus == 1){ - yon_window_config_add_custom_parameter(yon_char_unite(origin_flagged,NULL),"repos",packnames,YON_TYPE_STRING); - } - if (!add_packages&&!signed_packages&&!remove_packages&&repostatus==1) - add_command = yon_char_unite(command, " add -d \"",origin_flagged,"\" -r \"",name_flagged,sign_flagged ? yon_char_append("\" --sign-repo ",sign_flagged):"\"" ,NULL); - if (add_signed_command){ yon_launch(add_signed_command); - yon_ubl_status_box_render(OPERATION_DONE_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);} - if (add_command) { yon_launch(add_command); - yon_ubl_status_box_render(OPERATION_DONE_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);} - if (remove_command) { yon_launch(remove_command); - yon_ubl_status_box_render(OPERATION_DONE_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);} - if (pack_groups){ - dictionary *dct; - for_dictionaries(dct,pack_groups){ - char *signed_packs=NULL; - dictionary *pck; - for_dictionaries(pck,yon_dictionary_get_data(dct,dictionary*)){ - signed_packs=yon_char_unite(signed_packs ? yon_char_append(signed_packs,","): "" ,pck->key,NULL); - } - char *sign_command = yon_char_unite(command, " add -f -d ",origin_flagged," -r ",name_flagged," --sign-pkg ", dct->key," -p $(find ",origin_flagged,"/pool/overlay -name ", signed_packs,")",NULL); - yon_launch(sign_command); - } - - } - if (repo_sign_flagged){ - char *repo_sign_command = yon_char_unite(command, " add -f -d ",origin_flagged, " -r ", name_flagged, " --sign-repo ", repo_sign_flagged ,NULL); - yon_window_config_add_custom_parameter(yon_char_unite(origin_flagged,NULL),"signatures",repo_sign_flagged_full,YON_TYPE_STRING); - yon_launch(repo_sign_command); - } - } - } - yon_ubl_status_box_render(SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); -} - -void on_search(GtkCellEditable *self, main_window *widgets){ - GtkTreeIter iter, childIter; - char *name=NULL; - int valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(main_config.tree_store),&iter); - for (;valid;valid=gtk_tree_model_iter_next(GTK_TREE_MODEL(main_config.tree_store),&iter)){ - gtk_tree_model_get(GTK_TREE_MODEL(main_config.tree_store),&iter,1,&name,-1); - if (strstr(name,gtk_entry_get_text(GTK_ENTRY(widgets->Finder)))) { - gtk_tree_selection_select_iter(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->RepoTree)),&iter); - return; - } - gtk_tree_view_expand_row(GTK_TREE_VIEW(widgets->RepoTree),gtk_tree_model_get_path(GTK_TREE_MODEL(main_config.tree_store),&iter),1); - int child_valid = gtk_tree_model_iter_children(GTK_TREE_MODEL(main_config.tree_store),&childIter,&iter); - for (;child_valid;child_valid=gtk_tree_model_iter_next(GTK_TREE_MODEL(main_config.tree_store),&childIter)){ - gtk_tree_model_get(GTK_TREE_MODEL(main_config.tree_store),&childIter,1,&name,-1); - if (strstr(name,gtk_entry_get_text(GTK_ENTRY(widgets->Finder)))) { - gtk_tree_selection_select_iter(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->RepoTree)),&childIter); - return; - } - - } - gtk_tree_view_expand_row(GTK_TREE_VIEW(widgets->RepoTree),gtk_tree_model_get_path(GTK_TREE_MODEL(main_config.tree_store),&iter),0); - } - yon_ubl_status_box_render(OPERATION_DONE_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); -} - -void on_tree_selection_changed(GtkWidget *self,main_window *widgets){ - GtkTreeModel *model = GTK_TREE_MODEL(main_config.tree_store); - GtkTreeIter iter; - if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->RepoTree)),&model,&iter)){ - char *codeName=NULL,*version=NULL,*architecture=NULL, *dependeces=NULL, *signature=NULL; - int serverType=0,trusted=0,published=0; - gtk_tree_model_get(model,&iter,9,&codeName,10,&version,11,&architecture,12,&dependeces,13,&signature,-1); - gtk_label_set_text(GTK_LABEL(widgets->CodeNameInfoLabel),codeName ? codeName : ""); - gtk_label_set_text(GTK_LABEL(widgets->VersionInfoLabel),version ? version : ""); - gtk_label_set_text(GTK_LABEL(widgets->ArchitectureInfoLabel),architecture ? architecture : ""); - gtk_label_set_text(GTK_LABEL(widgets->DependencesInfoLabel),dependeces ? dependeces : ""); - gtk_label_set_text(GTK_LABEL(widgets->SignatureInfoLabel),signature ? signature : ABSENT_LABEL); - int depth = gtk_tree_store_iter_depth(main_config.tree_store,&iter); - if (depth == 0){ - gtk_widget_set_sensitive(widgets->CreateButton,1); - gtk_widget_set_sensitive(widgets->LoadFromLocalButton,1); - gtk_widget_set_sensitive(widgets->ConfigureButton,1); - gtk_widget_set_sensitive(widgets->DeleteButton,1); - gtk_widget_set_sensitive(widgets->AddPackageButton,1); - gtk_widget_set_sensitive(widgets->RemovePackageButton,0); - gtk_widget_set_sensitive(widgets->SignButton,1); - gtk_widget_set_visible(widgets->NameBox,1); - gtk_widget_set_visible(widgets->DependenceBox,0); - gtk_widget_set_visible(widgets->VersionBox,0); - gtk_widget_set_visible(widgets->ArchitectureBox,0); - gtk_widget_set_visible(widgets->SignatureBox,1); - } else if (depth == 1){ - gtk_widget_set_sensitive(widgets->CreateButton,1); - gtk_widget_set_sensitive(widgets->LoadFromLocalButton,1); - gtk_widget_set_sensitive(widgets->ConfigureButton,0); - gtk_widget_set_sensitive(widgets->DeleteButton,0); - gtk_widget_set_sensitive(widgets->AddPackageButton,1); - gtk_widget_set_sensitive(widgets->RemovePackageButton,1); - gtk_widget_set_sensitive(widgets->SignButton,1); - gtk_widget_set_visible(widgets->NameBox,1); - gtk_widget_set_visible(widgets->DependenceBox,1); - gtk_widget_set_visible(widgets->VersionBox,1); - gtk_widget_set_visible(widgets->ArchitectureBox,1); - gtk_widget_set_visible(widgets->SignatureBox,1); - } - } else { - gtk_widget_set_sensitive(widgets->CreateButton,1); - gtk_widget_set_sensitive(widgets->LoadFromLocalButton,1); - gtk_widget_set_sensitive(widgets->ConfigureButton,0); - gtk_widget_set_sensitive(widgets->DeleteButton,0); - gtk_widget_set_sensitive(widgets->AddPackageButton,0); - gtk_widget_set_sensitive(widgets->RemovePackageButton,0); - gtk_widget_set_sensitive(widgets->SignButton,0); - gtk_widget_set_visible(widgets->NameBox,0); - gtk_widget_set_visible(widgets->DependenceBox,0); - gtk_widget_set_visible(widgets->VersionBox,0); - gtk_widget_set_visible(widgets->ArchitectureBox,0); - gtk_widget_set_visible(widgets->SignatureBox,0); - } -} - -void on_repo_add_new(GtkWidget *self, dictionary *dict){ - main_window *widgets = yon_dictionary_get_data(dict->first,main_window*); - repo_create_window *window = yon_dictionary_get_data(dict->first->next,repo_create_window*); - if (!window->path){ yon_ubl_status_box_render(CHOOSE_PATH_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); return;} - char *name=NULL; - - name = window->path; - if (!name||strcmp(name,"")!=0){ - GtkTreeIter *iter = yon_repo_append(widgets, name, YON_REPO_LINE_REPO_TYPE); - if (iter){ - struct dirent *de; - GtkTreeIter child; - char *reponame = yon_char_new(name); - yon_char_divide(reponame,yon_char_find_last(reponame,'/')); - char *searchpath = yon_char_unite(name,"/",reponame,"/x86_64/",NULL); - DIR *directory = opendir(searchpath); - if (directory){ - char *found_packages = NULL; - while ((de = readdir(directory))) - { - if (strstr(de->d_name,"pkg.tar.")&&!strstr(de->d_name,".sig")){ - char *filename = yon_char_unite(searchpath,"/",de->d_name,NULL); - FILE *file = popen(get_package_info_command(filename),"r"); - char *cur_string=g_malloc0(sizeof(char)*4096); - char *packname=NULL, *packver=NULL, *packarch=NULL, *packdepends=NULL; - while (fgets(cur_string,4096,file)){ - char *stringe = yon_char_divide_search(cur_string,"\n",-1); - char *p = yon_char_divide_search(stringe,":",-1); - if (strstr(p,"Name")) packname = yon_char_new(stringe); - else if (strstr(p,"Version")) packver = yon_char_new(stringe); - else if (strstr(p,"Architecture")) packarch = yon_char_new(stringe); - else if (strstr(p,"Depends On")) packdepends = yon_char_new(stringe); - else if (strstr(p,"Depends On")) packdepends = yon_char_new(stringe); - } - gtk_tree_store_append(main_config.tree_store,&child,iter); - gtk_tree_store_set(main_config.tree_store,&child,0,document_no_edits,1,yon_char_unite(packname,"-",packver,"-",packarch,NULL),2,filename,3,0,9,packname,10,packver,11,packarch,12,packdepends,-1); - found_packages = yon_char_unite(found_packages ? yon_char_append(found_packages," ") : "",de->d_name,NULL); - } - } - yon_window_config_add_custom_parameter(window->path,"repos",found_packages,YON_TYPE_STRING); - gtk_tree_store_set(main_config.tree_store,iter,0,folder_no_edits,2,window->path,3,0,9,reponame,-1); - } else { - gtk_tree_store_set(main_config.tree_store,iter,0,folder_added,2,window->path,3,1,9,reponame,-1); - - } - } - } -} - -char *on_choose_repo_folder(GtkWidget *self,repo_create_window *window){ - GtkWidget *chooser = gtk_file_chooser_dialog_new(ADD_REPO_LABEL,NULL,GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,CANCEL_LABEL,GTK_RESPONSE_CANCEL,OPEN_LABEL,GTK_RESPONSE_ACCEPT,NULL); - gtk_window_set_icon_name(GTK_WINDOW(chooser),icon_path); - int res = gtk_dialog_run(GTK_DIALOG(chooser)); - if (res==GTK_RESPONSE_ACCEPT){ - - char *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(chooser)); - window->path=yon_char_new(filename); - } - on_close_subwindow(chooser); -} - -void on_repo_new (GtkWidget *self, main_window *widgets){ - repo_create_window *window = new(repo_create_window); - window->path=NULL; - on_choose_repo_folder(self,window); - dictionary *dict = yon_dictionary_new_with_data("",widgets); - dict = yon_dictionary_append_with_data(dict,"",window); - on_repo_add_new(self,dict); -} - -void on_repo_add_file(GtkWidget *self, main_window *widgets){ - yon_add_file(widgets); -} - -void on_repo_remove_package(GtkWidget *self, main_window *widgets){ - yon_repo_remove_package(widgets); -} - -void on_repo_remove(GtkWidget *self, main_window *widgets){ - yon_repo_remove(widgets); -} - -void on_sign_save(GtkWidget *self, dictionary *dict){ - GtkTreeIter iter; - main_window *widgets = yon_dictionary_get_data(dict->first,main_window*); - repo_sign_window *window = yon_dictionary_get_data(dict->first->next,repo_sign_window*); - GtkTreeModel *model = GTK_TREE_MODEL(main_config.tree_store); - if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->RepoTree)),&model,&iter)){ - char *key = (char*)gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(window->KeysCombo)); - gtk_tree_store_set(main_config.tree_store,&iter,13,key,14,1,-1); - } - on_tree_selection_changed(self,widgets); - yon_ubl_status_box_render(OPERATION_DONE_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); - on_close_subwindow(self); -} - -void on_repo_sign(GtkWidget *self, main_window *widgets){ - repo_sign_window *window = g_malloc(sizeof(repo_sign_window)); - GtkBuilder *builder = gtk_builder_new_from_resource(glade_sign_path); - window->Window = yon_gtk_builder_get_widget(builder,"repoSignWindow"); - window->HeaderLabel = yon_gtk_builder_get_widget(builder,"signHeaderNameLabel"); - window->KeysCombo = yon_gtk_builder_get_widget(builder,"repoSignKeysCombo"); - - window->SaveButton = yon_gtk_builder_get_widget(builder,"repoSignSaveButton"); - window->CloseButton = yon_gtk_builder_get_widget(builder,"repoSignCancelButton"); - GtkTreeModel *model = GTK_TREE_MODEL(main_config.tree_store); - GtkTreeIter iter; - gtk_window_set_title(GTK_WINDOW(window->Window),TITLE_LABEL); - if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->RepoTree)),&model,&iter)){ - if (gtk_tree_store_iter_depth(main_config.tree_store,&iter)==1) - gtk_label_set_text(GTK_LABEL( window->HeaderLabel),yon_char_unite(DIGITAL_SIGNATURE_LABEL," - ",PACKAGE_LABEL,NULL)); - else - gtk_label_set_text(GTK_LABEL( window->HeaderLabel),yon_char_unite(DIGITAL_SIGNATURE_LABEL," - ",REPOSITORY_LABEL,NULL)); - int size=0; - config_str ret = yon_config_load(get_gpg_keys_command,&size); - for (int i=0;iKeysCombo),ret[i]); - } - dictionary *dict = yon_dictionary_new_with_data("",widgets); - dict = yon_dictionary_append_with_data(dict,"",window); - g_signal_connect(G_OBJECT(window->SaveButton),"clicked", G_CALLBACK(on_sign_save),dict); - g_signal_connect(G_OBJECT(window->CloseButton),"clicked", G_CALLBACK(on_close_subwindow),NULL); - - gtk_widget_show(window->Window); - } else { - yon_ubl_status_box_render(SIGN_CHOOSE_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); - } -} - -void on_repo_configure(GtkWidget *self, main_window *widgets){ - GtkTreeModel *model = GTK_TREE_MODEL(main_config.tree_store); - GtkTreeIter iter; - if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->RepoTree)),&model,&iter)){ - GtkBuilder *builder = gtk_builder_new_from_resource(glade_repo_path); - repo_create_window *window = new(repo_create_window); - window->Window=yon_gtk_builder_get_widget(builder,"repoEditWindow"); - window->NameEntry=yon_gtk_builder_get_widget(builder,"repoEditNameEntry"); - window->CancelButton=yon_gtk_builder_get_widget(builder,"repoEditCancelButton"); - window->SaveButton=yon_gtk_builder_get_widget(builder,"repoEditSaveButton"); - window->BranchesTree=yon_gtk_builder_get_widget(builder,"repoEditBranchTree"); - window->BranchesListStore=GTK_LIST_STORE(gtk_builder_get_object(builder,"curRepoEditList")); - gtk_widget_show(window->Window); - dictionary *dict = yon_dictionary_new_with_data("",widgets); - dict = yon_dictionary_append_with_data(dict,"",window); - g_signal_connect(G_OBJECT(window->SaveButton),"clicked",G_CALLBACK(on_repo_configure_done),dict); - g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_close_subwindow),NULL); - gtk_list_store_clear(window->BranchesListStore); - } else yon_ubl_status_box_render(NOTHING_CHOSEN_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); -} - -void on_repo_configure_done(GtkWidget *self, dictionary *dict){ - main_window *widgets = yon_dictionary_get_data(dict->first,main_window*); - repo_create_window *window = yon_dictionary_get_data(dict->first->next,repo_create_window*); - GtkTreeIter iter, parentIter; - GtkTreeModel *model = GTK_TREE_MODEL(main_config.tree_store); - if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->RepoTree)),&model,&iter)){ - if (gtk_tree_model_iter_parent(GTK_TREE_MODEL(main_config.tree_store),&parentIter,&iter)) - iter=parentIter; - char *oldname=NULL; - int status=0; - char *name = (char*)gtk_entry_get_text(GTK_ENTRY(window->NameEntry)); - gtk_tree_model_get(model,&iter,1,&oldname,3,&status,-1); - if (status==0) - gtk_tree_store_set(main_config.tree_store,&iter,1,name,4,oldname,6,1,-1); - else if (status==1) - gtk_tree_store_set(main_config.tree_store,&iter,1,name,-1); - } - yon_ubl_status_box_render(OPERATION_DONE_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); - on_close_subwindow(self); -} - -void on_repo_load_local(GtkWidget *self, main_window *widgets){ - GtkFileFilter *file_filter = gtk_file_filter_new(); - GtkWidget *chooser = gtk_file_chooser_dialog_new(LOAD_REPO_LABEL,NULL,GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,CANCEL_LABEL,GTK_RESPONSE_CANCEL,OPEN_LABEL,GTK_RESPONSE_ACCEPT,NULL); - gtk_window_set_icon_name(GTK_WINDOW(chooser),"com.ublinux.ubl-settings-repomanager"); - int res = gtk_dialog_run(GTK_DIALOG(chooser)); - if (res==GTK_RESPONSE_ACCEPT){ - - char *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(chooser)); - yon_repo_append(widgets,filename,YON_REPO_LINE_REPO_TYPE); - } - on_close_subwindow(chooser); -} - -GtkTreeIter *yon_repo_append(main_window *widgets, char *name, YON_REPO_LINE_TYPE type){ - GtkTreeIter *retIter=g_malloc0(sizeof(GtkTreeIter)); - GtkTreeIter iter,parentIter; - GtkIconTheme *theme = gtk_icon_theme_get_default(); - char *name_short = yon_char_new(name); - gboolean fls = 0; - while(1){ - yon_char_divide_search(name_short,"/",-1); - if (!strstr(name_short,"/")) break; - } - GtkTreeModel *model = GTK_TREE_MODEL(main_config.tree_store); - if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->RepoTree)),&model,&parentIter)){ - if (type==YON_REPO_LINE_REPO_TYPE){ - GtkTreeIter ater; - char *repo_path; - int valid = gtk_tree_model_get_iter_first(model,&ater); - for (;valid;valid=gtk_tree_model_iter_next(model,&ater)){ - gtk_tree_model_get(model,&ater,2,&repo_path,-1); - if (!strcmp(repo_path,name)){ - yon_ubl_status_box_render(REPO_ALREADY_EXISTS_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); - return NULL; - } - } - gtk_tree_store_append(main_config.tree_store,&iter,NULL); - gtk_tree_store_set(main_config.tree_store,&iter,0, folder_no_edits, 1, name_short,2,name,3,1,4,fls,-1); - retIter = gtk_tree_iter_copy(&iter); - } - else if (type==YON_REPO_LINE_FILE_TYPE){ - GtkTreeIter branch; - if (gtk_tree_model_iter_parent(model,&branch,&parentIter)){ - GtkTreeIter repo; - char *filename; - int valid = gtk_tree_model_iter_nth_child(model,&repo,&branch,0); - for (;valid;valid=gtk_tree_model_iter_next(model,&repo)){ - gtk_tree_model_get(model,&repo,1,&filename,-1); - if (!strcmp(yon_char_divide_search(yon_char_new(name_short),".pkg.tar",-1), filename)){ - yon_ubl_status_box_render(ALREADY_EXIST,BACKGROUND_IMAGE_FAIL_TYPE); - return NULL; - } - free(filename); - } - gtk_tree_store_append(main_config.tree_store,&iter,&branch); - gtk_tree_store_set(main_config.tree_store,&iter,0, document_no_edits, 1, name_short,2,name,3,1,4,fls,-1); - retIter = gtk_tree_iter_copy(&iter); - - } else { - GtkTreeIter repo; - char *filename; - int valid = gtk_tree_model_iter_nth_child(model,&repo,&parentIter,0); - for (;valid;valid=gtk_tree_model_iter_next(model,&repo)){ - gtk_tree_model_get(model,&repo,1,&filename,-1); - if (!strcmp(yon_char_divide_search(yon_char_new(name_short),".pkg.tar",-1), filename)){ - yon_ubl_status_box_render(ALREADY_EXIST,BACKGROUND_IMAGE_FAIL_TYPE); - return NULL; - } - free(filename); - } - gtk_tree_store_append(main_config.tree_store,&iter,&parentIter); - gtk_tree_store_set(main_config.tree_store,&iter,0, document_no_edits, 1, name_short,2,name,3,1,4,fls,-1); - retIter = gtk_tree_iter_copy(&iter); - } - yon_ubl_status_box_render(OPERATION_DONE_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); - } - gtk_tree_selection_select_iter(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->RepoTree)),&iter); - } - else if (type==YON_REPO_LINE_REPO_TYPE){ - gtk_tree_store_append(main_config.tree_store,&iter,NULL); - gtk_tree_store_set(main_config.tree_store,&iter,0, folder_no_edits, 1, name_short,2,name,3,1,4,fls,9,name_short,-1); - retIter = gtk_tree_iter_copy(&iter); - gtk_tree_selection_select_iter(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->RepoTree)),&iter); - } else { - yon_ubl_status_box_render(NOTHING_CHOSEN_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); - } - return retIter; -} - -void yon_repo_remove_package(main_window *widgets){ - GtkTreeIter iter; - GtkTreeModel *model = GTK_TREE_MODEL(main_config.tree_store); - if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->RepoTree)),&model,&iter)){ - GtkTreeIter iterparent; - if (gtk_tree_model_iter_parent(model,&iterparent,&iter)){ - int status = 0; - gtk_tree_model_get(GTK_TREE_MODEL(main_config.tree_store),&iter,3,&status,-1); - if (status != 1){ - gtk_tree_store_set(main_config.tree_store,&iter,3,-1,-1); - gtk_tree_store_set(main_config.tree_store,&iter,0,document_deleted,-1); - } else gtk_tree_store_remove(main_config.tree_store,&iter); - yon_ubl_status_box_render(OPERATION_DONE_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); - }else yon_ubl_status_box_render(CHOOSE_PACK_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); - } -} - -void yon_repo_remove(main_window *widgets){ - GtkTreeIter iter, childIter, *deletecopy; - GtkTreeModel *model = GTK_TREE_MODEL(main_config.tree_store); - if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->RepoTree)),&model,&iter)){ - if(gtk_tree_store_iter_depth(main_config.tree_store,&iter)==0){ - int repostatus=0; - gtk_tree_model_get(GTK_TREE_MODEL(main_config.tree_store),&iter,3,&repostatus,-1); - if (repostatus ==0){ - gtk_tree_store_set(main_config.tree_store,&iter,3,-1,0,folder_deleted,-1); - int valid=gtk_tree_model_iter_children(model,&childIter,&iter); - for (;valid;valid=gtk_tree_model_iter_next(model,&childIter)){ - int status=5; - gtk_tree_model_get(model,&childIter,3,&status,-1); - if (status==1){ - deletecopy = gtk_tree_iter_copy(&childIter); - gtk_tree_model_iter_previous(model,&childIter); - gtk_tree_store_remove(main_config.tree_store,deletecopy); - } else if (status == 0){ - gtk_tree_store_set(main_config.tree_store,&childIter, 0,document_deleted,3,-1,-1); - } - } - } else if (repostatus == 1) { - gtk_tree_store_remove(main_config.tree_store,&iter); - } - }else yon_ubl_status_box_render(CHOOSE_REPO_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); - } else yon_ubl_status_box_render(NOTHING_CHOSEN_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); -} - -gboolean yon_check_file_pattern(GtkFileFilterInfo *info){ - if (!strstr(info->filename,".sig")&&strstr(info->filename,".pkg.tar.")) - return 1; - else return 0; -} - -void yon_add_file(main_window *widgets){ - GtkWidget *chooser = gtk_file_chooser_dialog_new(ADD_PACKAGE_REPO_LABEL,NULL,GTK_FILE_CHOOSER_ACTION_OPEN,CANCEL_LABEL,GTK_RESPONSE_CANCEL,OPEN_LABEL,GTK_RESPONSE_ACCEPT,NULL); - GtkFileFilter *file_filter = gtk_file_filter_new(); - file_filter = gtk_file_filter_new(); - gtk_file_filter_add_custom(file_filter,GTK_FILE_FILTER_FILENAME,(GtkFileFilterFunc)yon_check_file_pattern,NULL,NULL); - gtk_file_filter_set_name(file_filter,".pkg.tar.*"); - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(chooser),file_filter); - file_filter = gtk_file_filter_new(); - gtk_file_filter_add_pattern(file_filter,"*"); - gtk_file_filter_set_name(file_filter,"All"); - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(chooser),file_filter); - gtk_window_set_icon_name(GTK_WINDOW(chooser),"com.ublinux.ubl-settings-repomanager"); - int res = gtk_dialog_run(GTK_DIALOG(chooser)); - if (res==GTK_RESPONSE_ACCEPT){ - char *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(chooser)); - FILE *file = popen(get_package_info_command(filename),"r"); - char *cur_string=g_malloc0(sizeof(char)*4096); - char *packname=NULL, *packver=NULL, *packarch=NULL, *packdepends=NULL; - while (fgets(cur_string,4096,file)){ - char *stringe = yon_char_divide_search(cur_string,"\n",-1); - char *p = yon_char_divide_search(stringe,":",-1); - if (strstr(p,"Name")) packname = yon_char_new(stringe); - else if (strstr(p,"Version")) packver = yon_char_new(stringe); - else if (strstr(p,"Architecture")) packarch = yon_char_new(stringe); - else if (strstr(p,"Depends On")) packdepends = yon_char_new(stringe); - else if (strstr(p,"Depends On")) packdepends = yon_char_new(stringe); - } - int add = 1; - GtkTreeIter *iter = yon_repo_append(widgets,filename,YON_REPO_LINE_FILE_TYPE); - if (iter){ - gtk_tree_view_expand_to_path(GTK_TREE_VIEW(widgets->RepoTree),gtk_tree_model_get_path(GTK_TREE_MODEL(main_config.tree_store),iter)); - gtk_tree_store_set(main_config.tree_store,iter,0,document_added,1,yon_char_unite(packname,"-",packver,"-",packarch,NULL),2,filename,3,add,9,packname,10,packver,11,packarch,12,packdepends,-1); - } - } - on_tree_selection_changed(NULL,widgets); - on_close_subwindow(chooser); - - -} - - /* setup functions */ void config_init(){ main_config.tree_store=NULL; main_config.always_open_documentation=0; - main_config.win_height=0; - main_config.win_width=0; - main_config.win_pos_x=0; - main_config.win_pos_y=0; main_config.socket_id=-1; main_config.save_socket_id=-1; main_config.load_socket_id=-1; @@ -772,235 +102,65 @@ void config_init(){ main_config.lock_save_local=0; } -main_window *setup_window(){ - /* Widgets getting | Получение виджетов */ - main_window *widgets = malloc(sizeof(main_window)); - GtkBuilder *builder = gtk_builder_new_from_resource(glade_path); - widgets->Window = yon_gtk_builder_get_widget(builder,"MainWindow"); - widgets->HatLabel = yon_gtk_builder_get_widget(builder,"headerTopic"); - widgets->PlugBox = yon_gtk_builder_get_widget(builder,"plugBox"); - widgets->MovePaned = yon_gtk_builder_get_widget(builder,"MovePaned"); - - widgets->HeadOverlay = yon_gtk_builder_get_widget(builder,"HeadOverlay"); - widgets->HeadImage = yon_gtk_builder_get_widget(builder,"HeadBackgroundImage"); - widgets->HeadBox = yon_gtk_builder_get_widget(builder,"HeaderBox"); - widgets->HeadTitleLabel = yon_gtk_builder_get_widget(builder,"HeaderTitleLabel"); - widgets->HeadInfoLabel = yon_gtk_builder_get_widget(builder,"HeaderInfoLabel"); - - widgets->StatusBox = yon_gtk_builder_get_widget(builder,"mainStatusBox"); - widgets->StatusIcon = yon_gtk_builder_get_widget(builder,"mainStatusIcon"); - widgets->StatusLabel = yon_gtk_builder_get_widget(builder,"mainStatusLabel"); - - widgets->SaveLabel = yon_gtk_builder_get_widget(builder,"headerSaveConfigLabel"); - widgets->SaveMenuItem = yon_gtk_builder_get_widget(builder,"SaveGlobalLocalConfigurationMenuItem"); - widgets->SaveGlobalMenuItem = yon_gtk_builder_get_widget(builder,"SaveGlobalConfigurationMenuItem"); - widgets->SaveLocalMenuItem = yon_gtk_builder_get_widget(builder,"SaveLocalConfigurationMenuItem"); - widgets->RightBox = yon_gtk_builder_get_widget(builder,"HeaderRightBox"); - - widgets->LoadLabel = yon_gtk_builder_get_widget(builder,"headerLoadConfigLabel"); - widgets->LoadGlobalMenuItem = yon_gtk_builder_get_widget(builder,"LoadGlobalConfigurationMenuItem"); - widgets->LoadLocalMenuItem = yon_gtk_builder_get_widget(builder,"LoadLocalConfigurationMenuItem"); - widgets->LeftBox = yon_gtk_builder_get_widget(builder,"HeaderLeftBox"); +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); + gtk_box_pack_start(GTK_BOX(widgets->InterfaceBox),yon_gtk_builder_get_widget(builder,"BoxMain"),1,1,0); + // Custom widgets configuration + { + widgets->UpdateButton = yon_gtk_builder_get_widget(builder,"UpdateButton"); + widgets->DBConfigurationButton = yon_gtk_builder_get_widget(builder,"DBConfigurationButton"); + widgets->AddButton = yon_gtk_builder_get_widget(builder,"AddButton"); + widgets->MoveButton = yon_gtk_builder_get_widget(builder,"MoveButton"); + widgets->RemoveButton = yon_gtk_builder_get_widget(builder,"RemoveButton"); + widgets->CloudButton = yon_gtk_builder_get_widget(builder,"CloudButton"); + + widgets->ReposTree = yon_gtk_builder_get_widget(builder,"ReposTree"); + widgets->SearchEntry = yon_gtk_builder_get_widget(builder,"SearchEntry"); + widgets->RepoFileTree = yon_gtk_builder_get_widget(builder,"RepoFileTree"); + widgets->RepoPackagesTree = yon_gtk_builder_get_widget(builder,"RepoPackagesTree"); + widgets->InformationLabel = yon_gtk_builder_get_widget(builder,"InformationLabel"); + + widgets->RepoList = GTK_TREE_STORE(gtk_builder_get_object(builder,"RepoStore")); + widgets->RepoFileList = GTK_LIST_STORE(gtk_builder_get_object(builder,"RepoFileList")); + widgets->RepoPackagesTre = GTK_LIST_STORE(gtk_builder_get_object(builder,"RepoPackagesTre")); + + 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); + g_signal_connect(G_OBJECT(widgets->RemoveButton),"clicked",G_CALLBACK(on_remove_clicked),widgets); + + gtk_window_set_title(GTK_WINDOW(widgets->Window),TITLE_LABEL); - widgets->GeneralTabLabel = yon_gtk_builder_get_widget(builder,"GeneralTabLabel"); - widgets->PublicationTabLabel = yon_gtk_builder_get_widget(builder,"PublicationTabLabel"); - widgets->CreateButton = yon_gtk_builder_get_widget(builder,"CreateButton"); - widgets->LoadFromNetButton = yon_gtk_builder_get_widget(builder,"LoadNetButton"); - widgets->ConfigureButton = yon_gtk_builder_get_widget(builder,"ConfigureButton"); - widgets->DeleteButton = yon_gtk_builder_get_widget(builder,"DeleteButton"); - widgets->LoadFromLocalButton = yon_gtk_builder_get_widget(builder,"LoadLocalButton"); - widgets->SwitchPublishButton = yon_gtk_builder_get_widget(builder,"SwitchPublishButton"); - widgets->CheckDependencesButton = yon_gtk_builder_get_widget(builder,"CheckDependencesButton"); - widgets->SignButton = yon_gtk_builder_get_widget(builder,"SignButton"); - widgets->AddPackageButton = yon_gtk_builder_get_widget(builder,"AddPackageButton"); - widgets->RemovePackageButton = yon_gtk_builder_get_widget(builder,"RemovePackageButton"); - widgets->RepoTree = yon_gtk_builder_get_widget(builder,"RepoTree"); - widgets->TrustedRepoCheck = yon_gtk_builder_get_widget(builder,"TrustedCheck"); - widgets->ServerTypeLabel = yon_gtk_builder_get_widget(builder,"ServerLabel"); - widgets->ServerTypeCombo = yon_gtk_builder_get_widget(builder,"ServerCombo"); - widgets->IpAdressLabel = yon_gtk_builder_get_widget(builder,"IpAdresslabel"); - widgets->IpAdressCombo = yon_gtk_builder_get_widget(builder,"IpAdressCombo"); - widgets->PortLabel = yon_gtk_builder_get_widget(builder,"PortLabel"); - widgets->PortSpin = yon_gtk_builder_get_widget(builder,"PortSpin"); - widgets->OutputEntry = yon_gtk_builder_get_widget(builder,"OutputEntry"); - widgets->CopyButton = yon_gtk_builder_get_widget(builder,"CopyButton"); - widgets->PublishButton = yon_gtk_builder_get_widget(builder,"PublishButton"); - widgets->CodeNameLabel = yon_gtk_builder_get_widget(builder,"CodeNameLabel"); - widgets->CodeNameInfoLabel = yon_gtk_builder_get_widget(builder,"CodeNameInfoLabel"); - widgets->BranchLabel = yon_gtk_builder_get_widget(builder,"BranchLabel"); - widgets->BranchInfoLabel = yon_gtk_builder_get_widget(builder,"BranchInfoLabel"); - widgets->VersionLabel = yon_gtk_builder_get_widget(builder,"VersionLabel"); - widgets->VersionInfoLabel = yon_gtk_builder_get_widget(builder,"VersionInfoLabel"); - widgets->ArchitectureLabel = yon_gtk_builder_get_widget(builder,"ArchitectureLabel"); - widgets->ArchitectureInfoLabel = yon_gtk_builder_get_widget(builder,"ArchitectureInfoLabel"); - widgets->ComponentsLabel = yon_gtk_builder_get_widget(builder,"ComponentsLabel"); - widgets->DependencesInfoLabel = yon_gtk_builder_get_widget(builder,"DependencesInfoLabel"); - widgets->SignatureLabel = yon_gtk_builder_get_widget(builder,"SignatureLabel"); - widgets->SignatureInfoLabel = yon_gtk_builder_get_widget(builder,"SignatureInfoLabel"); - widgets->Finder = yon_gtk_builder_get_widget(builder,"RepoFinder"); - widgets->NameBox = yon_gtk_builder_get_widget(builder,"nameBox"); - widgets->VersionBox = yon_gtk_builder_get_widget(builder,"versionBox"); - widgets->ArchitectureBox = yon_gtk_builder_get_widget(builder,"archBox"); - widgets->DependenceBox = yon_gtk_builder_get_widget(builder,"dependBox"); - widgets->SignatureBox = yon_gtk_builder_get_widget(builder,"signatureBox"); - widgets->SaveButton = yon_gtk_builder_get_widget(builder,"mainSaveButton"); - main_config.tree_store = GTK_TREE_STORE(gtk_builder_get_object(builder,"RepoStore")); - widgets->DocumentationMenuItem = yon_ubl_menu_item_documentation_new(DOCUMENTATION_LABEL); - widgets->AboutMenuItem = yon_ubl_menu_item_about_new(ABOUT_LABEL); - - gtk_window_set_title(GTK_WINDOW(widgets->Window),TITLE_LABEL); - GtkWidget *menu = yon_gtk_builder_get_widget(builder,"menu2"); - gtk_menu_shell_append(GTK_MENU_SHELL(menu),widgets->DocumentationMenuItem); - gtk_menu_shell_append(GTK_MENU_SHELL(menu),widgets->AboutMenuItem); - - if (main_config.lock_load_global == 1){ - gtk_widget_set_sensitive(widgets->LoadGlobalMenuItem,0); - } - if (main_config.lock_save_global == 1&&main_config.lock_save_local == 1){ - gtk_widget_set_sensitive(gtk_widget_get_parent(gtk_widget_get_parent(widgets->SaveLabel)),0); - }else{ - if (main_config.lock_save_global == 1){ - gtk_widget_set_sensitive(widgets->SaveGlobalMenuItem,0); - gtk_widget_set_sensitive(widgets->SaveMenuItem,0); - } - if (main_config.lock_save_local == 1){ - gtk_widget_set_sensitive(widgets->SaveLocalMenuItem,0); - gtk_widget_set_sensitive(widgets->SaveMenuItem,0); - } + /* Widget registration for config monitoring | Регистрация виджетов для мониторинга конфига */ + /* Localisation | Локализация */ + gtk_widget_show(widgets->Window); + return widgets; } - - - /* Widget registration for config monitoring | Регистрация виджетов для мониторинга конфига */ - yon_window_config_add_listener(widgets->MovePaned,"pane_position","position",YON_TYPE_INT); - - /* Signal connection | Присоединение сигналов */ - g_signal_connect(G_OBJECT(widgets->Window), "destroy", G_CALLBACK(gtk_main_quit), NULL); - g_signal_connect(G_OBJECT(widgets->DocumentationMenuItem),"activate",G_CALLBACK(on_open_documentation_confirmation),WIKI_LINK); - g_signal_connect(G_OBJECT(widgets->AboutMenuItem),"activate",G_CALLBACK(on_about),NULL); - g_signal_connect(G_OBJECT(widgets->CreateButton),"clicked",G_CALLBACK(on_repo_new),widgets); - g_signal_connect(G_OBJECT(widgets->AddPackageButton),"clicked",G_CALLBACK(on_repo_add_file),widgets); - g_signal_connect(G_OBJECT(widgets->RemovePackageButton),"clicked",G_CALLBACK(on_repo_remove_package),widgets); - g_signal_connect(G_OBJECT(widgets->DeleteButton),"clicked",G_CALLBACK(on_repo_remove),widgets); - g_signal_connect(G_OBJECT(widgets->LoadFromLocalButton),"clicked",G_CALLBACK(on_repo_load_local),widgets); - g_signal_connect(G_OBJECT(widgets->ConfigureButton),"clicked",G_CALLBACK(on_repo_configure),widgets); - g_signal_connect(G_OBJECT(widgets->SignButton),"clicked",G_CALLBACK(on_repo_sign),widgets); - g_signal_connect(G_OBJECT(widgets->SaveButton),"clicked",G_CALLBACK(on_save),widgets); - g_signal_connect(G_OBJECT(widgets->RepoTree),"cursor-changed",G_CALLBACK(on_tree_selection_changed),widgets); - g_signal_connect(G_OBJECT(widgets->Finder),"changed",G_CALLBACK(on_search),widgets); - - /* Localisation | Локализация */ - gtk_widget_show(widgets->Window); - - - return widgets; } -int main(int argc, char *argv[]){ +int main(int argc, char *argv[]){ local=setlocale(LC_ALL, ""); textdomain (LocaleName); config_init(); - int option_index=0; - int show_help=0; - int debug_mode=0; - { - struct option long_options[] = { - {"help", 0, 0, 'h'}, - {"version", 0, 0, 'V'}, - {"lock-help", 0,0, 1}, - {"lock-save", 0,0, 2}, - {"lock-save-local", 0,0, 3}, - {"lock-save-global", 0,0, 4}, - {"lock-load-global", 0,0, 5}, - {"socket-id", 1, 0, 's'}, - {"socket-ext-id", 1,0, 'e'}, - {"socket-trd-id", 1,0, 't'}, - {"debug", 0,0, 'd'}, - {"clean-config", 0,0, 'c'}, - { NULL, 0, NULL, 0 } - }; - for (int i=0;iSaveMenuItem)))); + gtk_widget_hide(gtk_menu_get_attach_widget(GTK_MENU(gtk_widget_get_parent(widgets->LoadGlobalMenuItem)))); + widgets = (template_main_window*)yon_main_window_complete((main_window*)widgets); + char *path = yon_char_unite(yon_ubl_user_get_home_directory(),"/.config/",LocaleName,"/",LocaleName,".conf",NULL); + yon_window_config_load(path); if (getuid()!=0){ - main_config.lock_load_global=1; - main_config.lock_save_global=1; - main_config.lock_save_local=1; - main_config.lock_root=1; + yon_ubl_status_box_render("",BACKGROUND_IMAGE_SUCCESS_TYPE); } - gtk_init(&argc,&argv); - - - main_window *widgets = setup_window(); - yon_ubl_header_setup_resource(widgets->HeadOverlay,widgets->HeadBox,widgets->HeadImage,banner_path); - yon_ubl_status_box_setup(widgets->StatusIcon,widgets->StatusBox,widgets->StatusLabel); - yon_ubl_status_box_render(LOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); - yon_ubl_setup_sockets(widgets->PlugBox,widgets->LeftBox,widgets->RightBox,main_config.socket_id,main_config.load_socket_id,main_config.save_socket_id); - yon_window_config_setup(GTK_WINDOW(widgets->Window)); - yon_window_config_load(config_path); - - /*Check for null config parameter | Проверка на отсутствующий в конфигурации параметр */ - GValue *val = g_malloc0(sizeof(GValue)); - g_object_get_property(G_OBJECT(widgets->MovePaned),"position",val); - int paned_size = g_value_get_int(val); - if (paned_size<100) - gtk_paned_set_position(GTK_PANED(widgets->MovePaned),400); - - on_load(); - GtkTreeIter *iter = g_malloc0(sizeof(GtkTreeIter)); - if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(main_config.tree_store),iter)) - gtk_tree_selection_select_iter(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->RepoTree)),iter); - GtkCssProvider *css=gtk_css_provider_new(); - gtk_css_provider_load_from_resource(css,CssPath); - gtk_style_context_add_provider_for_screen(gdk_screen_get_default(), - GTK_STYLE_PROVIDER(css), - -1); gtk_main(); + return 0; } \ No newline at end of file diff --git a/source/ubl-settings-repomanager.h b/source/ubl-settings-repomanager.h index 70d39a9..1b0ac73 100644 --- a/source/ubl-settings-repomanager.h +++ b/source/ubl-settings-repomanager.h @@ -1,6 +1,5 @@ #include #include -#include "ubl-utils.h" #include #include #include @@ -10,7 +9,9 @@ #include #include #include -#include "../compile/ubl-cmake.h" +#include +#include +#include #ifdef WEBKIT_FOUND #include #endif @@ -21,19 +22,17 @@ #define _(String) gettext(String) #define glade_path "/com/ublinux/ui/ubl-settings-repomanager.glade" -#define glade_repo_path "/com/ublinux/ui/ubl-settings-repomanager-windows.glade" -#define glade_sign_path "/com/ublinux/ui/ubl-settings-repomanager-sign.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 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) #define icon_path "com.ublinux.ubl-settings-repomanager" -#define folder_no_edits "com.ublinux.ubl-settings-repomanager.folder-symbolic" -#define folder_deleted "com.ublinux.ubl-settings-repomanager.folder-red-symbolic" -#define folder_added "com.ublinux.ubl-settings-repomanager.folder-green-symbolic" -#define document_no_edits "com.ublinux.ubl-settings-repomanager.document-symbolic" -#define document_deleted "com.ublinux.ubl-settings-repomanager.document-red-symbolic" -#define document_added "com.ublinux.ubl-settings-repomanager.document-green-symbolic" +#define folder_no_edits "com.ublinux.libublsettingsui-gtk3.folder-symbolic" +#define document_no_edits "com.ublinux.libublsettingsui-gtk3.key-symbolic" +#define document_deleted "com.ublinux.ubl-settings-repomanager.key-red-symbolic" +#define document_added "com.ublinux.ubl-settings-repomanager.key-green-symbolic" #define LocalePath "/usr/share/locale" #define LocaleName "ubl-settings-repomanager" @@ -49,143 +48,69 @@ string version_application; char *local; typedef struct { + template_config_fields GtkTreeStore *tree_store; - int always_open_documentation; - int win_pos_x; - int win_pos_y; - int win_width; - int win_height; - - int socket_id; - int load_socket_id; - int save_socket_id; - - int lock_help; - int lock_save_local; - int lock_save_global; - int lock_load_global; int lock_root; } config; typedef struct { - GtkWidget *Window; - GtkWidget *HatLabel; - GtkWidget *PlugBox; - - GtkWidget *MovePaned; - - GtkWidget *HeadOverlay; - GtkWidget *HeadImage; - GtkWidget *HeadBox; - GtkWidget *HeadTitleLabel; - GtkWidget *HeadInfoLabel; - - GtkWidget *StatusBox; - GtkWidget *StatusIcon; - GtkWidget *StatusLabel; - - GtkWidget *SaveLabel; - GtkWidget *SaveMenuItem; - GtkWidget *SaveGlobalMenuItem; - GtkWidget *SaveLocalMenuItem; - GtkWidget *RightBox; - - GtkWidget *LoadLabel; - GtkWidget *LoadGlobalMenuItem; - GtkWidget *LoadLocalMenuItem; - GtkWidget *LeftBox; - - GtkWidget *DocumentationMenuItem; - GtkWidget *AboutMenuItem; - - GtkWidget *GeneralTabLabel; - GtkWidget *PublicationTabLabel; - GtkWidget *CreateButton; - GtkWidget *LoadFromNetButton; - GtkWidget *ConfigureButton; - GtkWidget *DeleteButton; - GtkWidget *LoadFromLocalButton; - GtkWidget *SwitchPublishButton; - GtkWidget *CheckDependencesButton; - GtkWidget *SignButton; - GtkWidget *AddPackageButton; - GtkWidget *RemovePackageButton; - GtkWidget *RepoTree; - GtkWidget *TrustedRepoCheck; - GtkWidget *ServerTypeLabel; - GtkWidget *ServerTypeCombo; - GtkWidget *IpAdressLabel; - GtkWidget *IpAdressCombo; - GtkWidget *PortLabel; - GtkWidget *PortSpin; - GtkWidget *OutputEntry; - GtkWidget *CopyButton; - GtkWidget *PublishButton; - GtkWidget *CodeNameLabel; - GtkWidget *CodeNameInfoLabel; - GtkWidget *BranchLabel; - GtkWidget *BranchInfoLabel; - GtkWidget *VersionLabel; - GtkWidget *VersionInfoLabel; - GtkWidget *ArchitectureLabel; - GtkWidget *ArchitectureInfoLabel; - GtkWidget *ComponentsLabel; - GtkWidget *DependencesInfoLabel; - GtkWidget *SignatureLabel; - GtkWidget *SignatureInfoLabel; - GtkWidget *Finder; - GtkWidget *SaveButton; - GtkWidget *NameBox; - GtkWidget *VersionBox; - GtkWidget *ArchitectureBox; - GtkWidget *DependenceBox; - GtkWidget *SignatureBox; + template_window_fields + GtkWidget *UpdateButton; + GtkWidget *DBConfigurationButton; + GtkWidget *AddButton; + GtkWidget *MoveButton; + GtkWidget *RemoveButton; + GtkWidget *CloudButton; + GtkWidget *ReposTree; + GtkWidget *RepoFileTree; + GtkWidget *SearchEntry; + GtkWidget *RepoPackagesTree; + GtkWidget *InformationLabel; + GtkTreeStore *RepoList; + GtkListStore *RepoFileList; + GtkListStore *RepoPackagesTre; } main_window; typedef struct { - GtkWidget *Window; - GtkWidget *NameEntry; - GtkWidget *BranchesTree; + GtkWidget *MainWindow; + GtkWidget *StatusBox; + GtkWidget *HeadLabel; GtkWidget *CancelButton; - GtkWidget *SaveButton; - GtkCellRenderer *BranchCell; - GtkWidget *repoChooseFolderButton; - - GtkListStore *BranchesListStore; - GtkWidget *PathLabel; - char *path; -} repo_create_window; - -typedef struct { - GtkWidget *Window; - GtkWidget *HeaderLabel; - GtkWidget *KeysCombo; - - GtkWidget *CloseButton; - GtkWidget *SaveButton; -} repo_sign_window; + GtkWidget *AddButton; + GtkWidget *MoveSourceFrame; + GtkWidget *MoveSourceStorageEntry; + GtkWidget *MoveSourceRepoEntry; + GtkWidget *MoveSourceArchEntry; + GtkWidget *MoveTargetFrame; + GtkWidget *MoveTargetStorageEntry; + GtkWidget *MoveTargetRepoEntry; + GtkWidget *MoveTargetArchEntry; + GtkWidget *StorageCombo; + GtkWidget *RepositoryCombo; + GtkWidget *ArchitectureCombo; + GtkWidget *PackageSignCombo; + GtkWidget *RepoSignCombo; + GtkWidget *AddPackageButton; + GtkWidget *RemoveButton; + GtkWidget *PackagesTree; + GtkWidget *InfoLabel; + GtkListStore *PackagesList; +} repo_add_window; typedef struct { - GtkWidget *Window; - - GtkWidget *HatText; - GtkWidget *HeaderText; - GtkWidget *InfoText; - GtkWidget *AlwaysOpenCheck; - - GtkWidget *CloseButton; + GtkWidget *MainWindow; + GtkWidget *HeadLabel; + GtkWidget *CancelButton; GtkWidget *AcceptButton; -} documentation_confirmation_window; - -typedef enum { - YON_REPO_LINE_REPO_TYPE, - YON_REPO_LINE_FILE_TYPE, - YON_REPO_LINE_BRANCH_TYPE -} YON_REPO_LINE_TYPE; + GtkWidget *StatusBox; + GtkWidget *StoragePathEntry; + GtkWidget *OpenExistingButton; + GtkWidget *CreateNewButton; + GtkWidget *DisableButton; + GtkWidget *DeleteButton; + GtkWidget *ReposBox; + GtkWidget *AddEntry; + GtkWidget *AddRepoButton; +} storage_config_window; -main_window *setup_window(); -void yon_add_file(main_window *widgets); -GtkTreeIter *yon_repo_append(main_window *widgets, char *name, YON_REPO_LINE_TYPE type); -void yon_repo_remove_package(main_window *widgets); -void yon_repo_remove(main_window *widgets); -void on_repo_configure_done(GtkWidget *self, dictionary *dict); \ No newline at end of file +main_window *setup_window(); \ No newline at end of file diff --git a/source/ubl-strings.h b/source/ubl-strings.h index 872817d..86c5b73 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -1,25 +1,6 @@ -#define VERSION_LABEL yon_char_unite(_("Version:")," ",version_application,"\n",NULL) -#define HELP_LABEL yon_char_unite(_("ubl-settings-repomanager version:")," ", version_application,"\n",TITLE_LABEL,"\n",_("Usage:"), " ubl-settings-repomanager ",_("[OPTIONS]"),"\n",_("Options:"),"\n\t--help, -h\t\t\t",_("Show this help"),"\n\t--version, -V\t\t\t",_("Show package version"),"\n\t--lock-help\t\t\t",_("Lock this help menu"),"\n\t--lock-save\t\t\t",_("Lock configuration saving"),"\n\t--lock-save-local\t\t",_("Lock local configration saving"),"\n\t--lock-save-global\t\t",_("Lock global configration saving"),"\n\t--lock-load-global\t\t",_("Lock global configration loading"),"\n",NULL) - -#define ROOT_WARNING_LABEL _("Warning! Application was launched without root - root-dependent actions are locked") #define TITLE_LABEL _("Repository manager") #define TITLE_INFO_LABEL _("Repository management and configuring") -#define SUCCESS_LABEL _("Operation succeeded") - -#define ABOUT_LABEL _("About") -#define DOCUMENTATION_LABEL _("Documentation") - -#define SAVE_LOCAL_LABEL _("Save to local configuration") -#define SAVE_GLOBAL_LABEL _("Save to global configuration") -#define SAVE_CONFIGURATION_LABEL _("Save configuration") -#define SAVE_LABEL _("Save") - -#define LOAD_LOCAL_LABEL _("Load local configuration") -#define LOAD_GLOBAL_LABEL _("Load global configuration") -#define LOAD_LABEL _("Load") - -#define CANCEL_LABEL _("Cancel") #define HELP_TITLE_LABEL _("Would you like to read documentation in the Web?") #define HELP_INFO_LABEL _("You will be redirected to documentation website where documentation is\ntranslated and supported by community.") diff --git a/source/ubl-utils.c b/source/ubl-utils.c deleted file mode 100644 index b75f4ff..0000000 --- a/source/ubl-utils.c +++ /dev/null @@ -1,1924 +0,0 @@ -#include "ubl-utils.h" - -// dictionary functions - -/**yon_dictionary_new(): - * [EN] - * Creates and returns empty dictionary - * [RU] - * Создаёт и возвращает пустой словарь. - */ -dictionary *yon_dictionary_new() -{ - dictionary *dict = malloc(sizeof(dictionary)); - dict->data = NULL; - dict->key = NULL; - dict->next = NULL; - dict->prev = NULL; - dict->first = dict; - dict->data_type = DICTIONARY_OTHER_TYPE; - return dict; -} - -/**yon_dictionary_copy(dictionary *dict) - * [EN] - * - * [RU] - * Создаёт и возвращает копию элемента словаря [dict] -*/ -dictionary *yon_dictinoary_copy(dictionary *dict){ - dictionary *dct = yon_dictionary_new_with_data(dict->key,dict->data); - dct->data_type= dict->data_type; - return dct; -} - -/**yon_dictionary_copy_deep(dictionary *dict) - * [EN] - * - * [RU] - * Создаёт полную копию словаря [dict] и возвращает первый элемент -*/ -dictionary *yon_dictionary_copy_deep(dictionary *dict){ - dictionary *dct = NULL; - dictionary *newone=NULL; - for_dictionaries(dct,dict){ - yon_dictionary_add_or_create_if_exists_with_data(newone,dct->key,dct->data); - newone->data_type=dct->data_type; - } - return newone->first; -} - -/**int yon_dictionary_set_data(dictionary *dict, void *data) - * [EN] - * - * [RU] - * Установить элементу словаря [dict] значение [data] -*/ -int yon_dictionary_set_data(dictionary *dict, void *data){ - dict->data=data; -} - -/**int yon_dictionary_set_key(dictionary *dict, char *key) - * [EN] - * - * [RU] - * Изменяет ключ элемента словаря [dict] на [key] -*/ -int yon_dictionary_set_key(dictionary *dict, char *key){ - dict->key=key; - return 1; -} - -/** int yon_dictionary_set(dictionary *dict, char *key, void *data) - * [EN] - * - * [RU] -* Устанавливает значение ключа элемента словаря [dict] на [key] и его данные на [data] -*/ -int yon_dictionary_set(dictionary *dict, char *key, void *data){ - dict->key=key; - dict->data=data; - return 1; -} - -/**int yon_dictionary_empty(dictionary *dict) - * [EN] - * - * [RU] - * Очищает элемент словаря [dict] от данных -*/ -int yon_dictionary_empty(dictionary *dict){ - dict->data=NULL; - dict->data_type=DICTIONARY_OTHER_TYPE; - return 1; -} - -/**yon_dictionary_switch_to_last(dictionary **dict) - * [EN] - * - * [RU] - * Переключает словарь [dict] на последний элемент. -*/ -void yon_dictionary_switch_to_last(dictionary **dict) -{ - dictionary *dct=NULL, *dact=*dict; - for_dictionaries(dct,dact); -} - -/**yon_dictionary_create_conneced(dictionary *targetdict) - * [EN] - * - * [RU] - * Создаёт новый элемент словаря [targetdict] -*/ -dictionary *yon_dictionary_append(dictionary *targetdict) -{ - targetdict = yon_dictionary_get_last(targetdict); - targetdict->next = yon_dictionary_new(); - targetdict->next->prev = targetdict; - targetdict->next->first = targetdict->first; - targetdict->next->data_type = DICTIONARY_OTHER_TYPE; - return targetdict->next; -} - -/**yon_dictionary_get_last(dictionary *dict) - * [EN] - * - * [RU] - * Возвращает последний элемент словаря [dict]. - * В отличае от yon_dictionary_switch_to_last() - * словарь [dict] остаётся на прежнем элементе. -*/ -dictionary *yon_dictionary_get_last(dictionary *dict) -{ - if (dict->next){ - dictionary *dct = NULL; - for_dictionaries(dct,dict); - return dct; - } else return dict; -} - -/**yon_dictionary_switch_places(dictionary *dict, int aim) - * [EN] - * - * [RU] - * Меняет элемент словаря [dict] местами с другим элементом. - * если [aim]<0 элемент меняется местами с левым элементом; - * если [aim]>0 элемент меняется местами с правым элементом; -*/ -dictionary *yon_dictionary_swap(dictionary *dict, int aim) -{ - if (aim < 0) - { - if (dict->prev) - { - if (dict->prev->prev) - { - dictionary *next = dict->next, *prev = dict->prev, *preprev = prev->prev; - if (next) - { - preprev->next = dict; - dict->prev = preprev; - dict->next = prev; - prev->prev = dict; - prev->next = next; - next->prev = prev; - } - else - { - preprev->next = dict; - dict->prev = preprev; - dict->next = prev; - prev->prev = dict; - prev->next = NULL; - } - return prev; - } - else - { - dictionary *next = dict->next, *prev = dict->prev; - if (next) - { - yon_dictionary_make_first(dict); - dict->prev = NULL; - dict->next = prev; - prev->prev = dict; - prev->next = next; - next->prev = prev; - } - else - { - dict->prev = NULL; - dict->next = prev; - prev->prev = dict; - prev->next = NULL; - } - return prev; - } - } - } - else if (aim > 0) - { - if (dict->next) - { - if (dict->next->next) - { - dictionary *next = dict->next, *prev = dict->prev, *afnext = next->next; - if (prev) - { - prev->next = next; - next->prev = prev; - next->next = dict; - dict->prev = next; - dict->next = afnext; - afnext->prev = dict; - } - else - { - yon_dictionary_make_first(next); - next->prev = NULL; - next->next = dict; - dict->prev = next; - dict->next = afnext; - afnext->prev = dict; - } - return next; - } - else - { - dictionary *next = dict->next, *prev = dict->prev; - if (prev) - { - prev->next = next; - next->prev = prev; - next->next = dict; - dict->prev = next; - dict->next = NULL; - } - else - { - next->prev = NULL; - next->next = dict; - dict->prev = next; - dict->next = NULL; - } - } - } - } -} - -/**yon_dictionary_make_first(dictionary *dict) - * [EN] - * - * [RU] - * Устанавливает указатель первого элемента словаря [dict] - * на текущий элемент. Не использовать. -*/ -void yon_dictionary_make_first(dictionary *dict) -{ - for (dictionary *dct = dict->first; dct != NULL; dct = dct->next) - { - dct->first = dict; - } -} - -/**yon_dictionary_make_nth(dictionary *dict, int nth) - * [EN] - * - * [RU] - * Перемещает элемент словаря [dict] на позицию [nth]. -*/ -void yon_dictionary_make_nth(dictionary *dict, int nth) -{ - dictionary *dct = dict->first; - for (int i = 0; i < nth; i++) - { - if (dct == NULL) - return; - else - dct = dct->next; - } - yon_dictionary_rip(dict); - dictionary *prev = dct->prev; - prev->next = dict; - dict->prev = prev; - dict->next = dct; - dct->prev = dict; -} - -/**yon_dictionary_create_with_data(char *key, void *data) - * [EN] - * - * [RU] - * Создаёт новый словарь с ключом [key] и указателем на данные [data] -*/ -dictionary *yon_dictionary_new_with_data(char *key, void *data) -{ - dictionary *dct = yon_dictionary_new(); - dct->key = yon_char_new(key); - dct->data = data; - dct->data_type = DICTIONARY_OTHER_TYPE; - return dct; -} - -/** void *yon_dictionary_free_all(dictionary *dictionary,void *data_manipulation) - * [EN] - * Frees whole [dictionary] and activates [data_manipulation] function if not NULL with [dictionary]->data argument for each dictionary. - * [RU] - * Освобождает память для всех элементов словаря [dictionary] и активирует функцию [data_manipulation], если она была передана, с аргументом [dictionary]->data на каждый элемент словаря. -*/ -void *yon_dictionary_free_all(dictionary *dictionary_to_free,void (*data_manipulation)(void*)){ - dictionary *dict=NULL; - for_dictionaries(dict,dictionary_to_free){ - if(data_manipulation) - data_manipulation(dict->data); - if(dict->prev) - free(dict->prev); - } - free(dict); - return NULL; -} - -/**yon_dictionary_create_with_data_connected(dictionary *dict, char *key, void *data) - * [EN] - * - * [RU] - * Создаёт новый элемент словаря, присоединяемый в конец словаря [dict] - * с ключом [key] и указателем на данные [data] -*/ -dictionary *yon_dictionary_append_with_data(dictionary *dict, char *key, void *data) -{ - dictionary *dct = yon_dictionary_append(dict); - dct->key = yon_char_new(key); - dct->data = data; - dct->data_type = DICTIONARY_OTHER_TYPE; - return dct; -} - -/**yon_dictionary_connect(dictionary *old, dictionary *toconnect) - * [EN] - * - * [RU] - * Присоединяет словарь [toconnect] в конец словаря [old]. -*/ -dictionary *yon_dictionary_connect(dictionary *old, dictionary *toconnect) -{ - dictionary *dict = yon_dictionary_get_last(old); - dict->next = toconnect; - toconnect->prev = dict; - toconnect->first = dict->first; - return toconnect; -} - -/**yon_dictionary_get(dictionary **dict, char *key) - * [EN] - * - * [RU] - * Возвращает элемент словаря [dict] с ключом [key]. - * Если такого элемента не было обнаружено, возвращается NULL -*/ -dictionary *yon_dictionary_get(dictionary **dict, char *key) -{ - dictionary *dct = *dict; - for (dictionary *pointer = dct->first; pointer != NULL; pointer = pointer->next) - { - if (strcmp(pointer->key, key) == 0) - { - *dict = pointer; - return pointer; - } - } - return NULL; -} - -/**yon_dictionary_rip(dictionary *dict) - * [EN] - * - * [RU] - * Вырезает элемент из словаря и возвращает вырезанный элемент. -*/ -dictionary *yon_dictionary_rip(dictionary *dict) -{ - if (!dict->next&&!dict->prev) return NULL; - else if (!dict->next) - { - dictionary *prev = dict->prev; - if (prev) - { - prev->next = NULL; - return prev; - } - else - return dict; - } - else if (!dict->prev) - { - dictionary *next = dict->next; - if (next) - { - yon_dictionary_make_first(next); - next->prev = NULL; - return next; - } - else - return dict; - } - else - { - dictionary *next = dict->next, *prev = dict->prev; - next->prev = prev; - prev->next = next; - return next; - } -} - -/**yon_dictionary_get_nth(dictionary *dict, int place) - * [EN] - * - * [RU] - * Возвращает [place]-й элемент словаря [dict] -*/ -dictionary *yon_dictionary_get_nth(dictionary *dict, int place) -{ - if (dict){ - dict = dict->first; - int i = 0; - for (i = 0; i < place; i++) - if (dict->next) - dict = dict->next; - else - break; - if (i == place) - return dict; - else - return NULL; - } else return NULL; -} - -// char functions - -int yon_char_find_last(char *source, char find){ - int size = strlen(source); - int i=size; - for (;source[i]!=find&&i>0;i--); - return i; -} - -/**[EN] - * - * creates new char string by combining two char strings. - */ -char *yon_char_append(char *source, char *append) -{ - if (source && append) - { - int size = strlen(source) + strlen(append) + 1; - char *final = malloc(size); - memset(final, 0, size); - if (strstr(source, "%%")) - sprintf(final, source, append); - else - sprintf(final, "%s%s", source, append); - return final; - } - else - return NULL; -} - -/**[EN] - * - * creates new char string by copying another char. - */ -char *yon_char_new(char *chr) -{ - if (chr){ - char *newchar = malloc(strlen(chr) + 1); - memset(newchar, 0, strlen(chr) + 1); - memcpy(newchar, chr, strlen(chr)); - return newchar; - } else - return NULL; -} - -/**yon_char_unite(char *source, ...) - * [En] - * - * [RU] - * Объединяет строку [source] со всеми строками, написанными в [...] -*/ -char *yon_char_unite(char *source, ...){ - va_list arglist; - char *new_char=NULL; - char *unite_char=NULL; - new_char=yon_char_new(source); - va_start(arglist,source); - unite_char = va_arg(arglist,char*); - while(unite_char){ - new_char = yon_char_append(new_char,unite_char); - unite_char = va_arg(arglist,char*); - } - va_end(arglist); - return new_char; -} - -/**yon_cut(char *source, int size, int startpos) - * [EN] - * cuts source string by size length from startpos position. - */ -char *yon_cut(char *source, int size, int startpos) -{ - char *cut = NULL; - cut = malloc(size + 1); - memset(cut, 0, size + 1); - memcpy(cut, source + startpos, size); - return cut; -} - -/**yon_char_divide(char *source, int dividepos) - * [EN] - * divides source string in dividepos position, - * returning left part of divided string and - * inserting right part to source string. - */ -char *yon_char_divide(char *source, int dividepos) -{ - char *cut = malloc(dividepos + 1); - memset(cut, 0, dividepos + 1); - memcpy(cut, source, dividepos); - char *left = malloc(strlen(source) - strlen(cut)); - memset(left, 0, strlen(source) - strlen(cut)); - memcpy(left, source + dividepos + 1, (strlen(source) - dividepos)); - memset(source, 0, strlen(source)); - memcpy(source, left, strlen(left)); - return cut; -} - -/**yon_char_find_count(char *source, char *find) - * [EN] - * - * [RU] - * Считает количество символов [find] в строке [source] -*/ -int yon_char_find_count(char *source, char *find){ - char *working_string=yon_char_new(source); - int i=0; - int size=0; - int pos=0; - config_str rtn = yon_char_parse(working_string,&size,"\n"); - for (int j=0;j= 10; i++) - { - convert_check = convert_check / 10; - } - char *ch = g_malloc0(i * sizeof(char) + 1); - sprintf(ch, "%d", int_to_convert); - return ch; -} - -/**yon_char_replace(char *source, char *find, char*replace) - * [EN] - * - * [RU] - * Заменяет в строке [source] все вхождения строки [find] на [replace] -*/ -char *yon_char_replace(char *source, char *find, char*replace){ - if (!strstr(replace,find)){ - - - char *final=NULL; - char *temp=NULL; - if(!strstr(replace,find)){ - while ((final=strstr(source,find))){ - temp=malloc(strlen(source)-strlen(final)); - memset(temp,0,strlen(source)-strlen(final)+strlen(replace)); - memcpy(temp,source,strlen(source)-strlen(final)); - temp=yon_char_append(temp,replace); - source=yon_char_append(temp,final+1); - } - - } - } - return source; -} - -/**yon_char_parse(char *parameters, int *size, char *divider) - * [EN] - * Parses string [parameters], divided by [divider], - * then returns parsed string array and sets [size] to - * size of returned array -*/ -char **yon_char_parse(char *parameters, int *size, char *divider){ - char **string=NULL; - int i=1; - string=malloc(sizeof(char*)); - char *paramline=yon_char_new(parameters); - char *param; - if (!strstr(parameters,divider)) return NULL; - while ((param=yon_char_divide_search(paramline,divider,1))){ - if (strcmp(param,paramline)==0||param[0]=='\0') break; - string=realloc(string,sizeof(char*)*i); - string[i-1]=yon_char_new(param); - i++; - } - string=realloc(string,sizeof(char*)*i); - string[i-1]=yon_char_new(paramline); - i++; - *size=i-1; - return string; -} - -/**yon_char_parsed_rip(char **char_string, int *size, int item_to_delete) - * [EN] - * - * [RU] - * Удаляет элемент [item_to_delete] из массива строк [char_string], размера [size] - * Возвращает получившийся массив, в [size] загружается размер нового массива. -*/ -char **yon_char_parsed_rip(char **char_string, int *size, int item_to_delete){ - char **new_char_parsed=NULL; - new_char_parsed=malloc(sizeof(char*)*((*size)-1)); - int flag = 0; - for (int i=0;i < (*size);i++){ - if (i==item_to_delete) { - flag = 1; - } - if (flag == 0) { - new_char_parsed[i]=yon_char_new(char_string[i]); - } - else if (flag == 1 && i!=item_to_delete) { - new_char_parsed[i-1]=yon_char_new(char_string[i]); - } - } - (*size)=(*size)-1; - return new_char_parsed; -} - -/**yon_char_parsed_check_exist(char **parameters, int size, char *param) - * [EN] - * Checks if [parameters] string array of length [size] - * has [param] element; - * [RU] - * Проверяет есть ли в массиве строк [parameters], размера [size] - * элемент [param] -*/ -int yon_char_parsed_check_exist(char **parameters, int size, char *param){ - - for (int i=0;id_name); - file = fopen(path, "r"); - if (strlen(de->d_name) > 9) - { - char *extension = strstr(path, "."); - if (extension != NULL) - { - if (strcmp(extension, ".desktop") == 0) - { - apps tempapp; - GKeyFile *gfile = g_key_file_new(); - GError *err = NULL; - g_key_file_load_from_file(gfile, path, G_KEY_FILE_KEEP_TRANSLATIONS, NULL); - char *Type = g_key_file_get_string(gfile, "Desktop Entry", "Type", &err); - if (err) - { - printf("%s\n", err->message); - } - if (strcmp(Type, "Application") == 0) - tempapp.Type = 1; - else if (strcmp(Type, "pyApplication") == 0) - tempapp.Type = 2; - else - continue; - tempapp.Name = g_key_file_get_locale_string(gfile, "Desktop Entry", "Name", setlocale(LC_ALL, NULL), NULL); - if (tempapp.Name == NULL) - continue; - tempapp.Categories = g_key_file_get_string(gfile, "Desktop Entry", "Categories", NULL); - if (tempapp.Categories == NULL) - continue; - tempapp.Exec = g_key_file_get_string(gfile, "Desktop Entry", "Exec", NULL); - if (tempapp.Exec == NULL) - continue; - tempapp.Icon = g_key_file_get_string(gfile, "Desktop Entry", "Icon", NULL); - if (tempapp.Icon == NULL) - continue; - tempapp.Pluggable = g_key_file_get_boolean(gfile, "Desktop Entry", "Pluggable", NULL); - if (!tempapp.Pluggable) - tempapp.Pluggable = g_key_file_get_boolean(gfile, "Desktop Entry", "X-XfcePluggable", NULL); - if (tempapp.Pluggable) - tempapp.DualPluggable = g_key_file_get_boolean(gfile, "Desktop Entry", "X-UBLPluggable", NULL); - if (g_key_file_get_boolean(gfile, "Desktop Entry", "X-UBL-SettingsManager-Hidden", NULL) == 0) - if (size == 0) - { - applist = (apps *)malloc(size + 1 * sizeof(apps)); - applist[0].Name = yon_char_new(tempapp.Name); - applist[0].Categories = yon_char_new(tempapp.Categories); - applist[0].Exec = yon_char_new(tempapp.Exec); - applist[0].Icon = yon_char_new(tempapp.Icon); - applist[0].Type = tempapp.Type; - applist[0].Pluggable = tempapp.Pluggable; - applist[0].DualPluggable = tempapp.DualPluggable; - size++; - } - else - { - applist = (apps *)realloc(applist, (size + 1) * sizeof(apps)); - applist[size].Name = yon_char_new(tempapp.Name); - applist[size].Categories = yon_char_new(tempapp.Categories); - applist[size].Exec = yon_char_new(tempapp.Exec); - applist[size].Icon = yon_char_new(tempapp.Icon); - applist[size].Pluggable = tempapp.Pluggable; - applist[size].DualPluggable = tempapp.DualPluggable; - applist[size].Type = tempapp.Type; - size++; - } - } - } - } - } - } - *sizef = size; - return applist; -}; - -void yon_apps_sort(apps *applist, int size) -{ - apps tmp; - if (size > 2) - { - for (int i = 1; i < size; i++) - { - for (int j = 1; j < size; j++) - { - if (strcmp(applist[j].Name, applist[j - 1].Name) < 0) - { - tmp = applist[j]; - applist[j] = applist[j - 1]; - applist[j - 1] = tmp; - }; - } - }; - } -}; - -apps *yon_apps_get_by_name(apps *applist, char *name, int size) -{ - for (int i = 0; i < size; i++) - { - if (strcmp(applist[i].Name, name) == 0) - return &applist[i]; - } - return NULL; -}; - -//config functions - -/**yon_config_load_register(char *command) - * [EN] - * - * [RU] - * Выполняет команду [command]. - * Полученные данные парсятся и регистрируются в конфиг. -*/ -int yon_config_load_register(char *command){ - if (__yon__config__strings){ - __yon__config__strings = yon_dictionary_free_all(__yon__config__strings,NULL); - } - FILE *output = popen(command, "r"); - char **output_strings = NULL; - output_strings = malloc(sizeof(char)); - int i = 0; - char str[4096]; - memset(str, 0, 4096); - while (fgets(str, 4096, output)) - { - if (strcmp(str, "") != 0&& strcmp(str,"(null)\n")!=0) - { - char *key = yon_char_divide_search(str,"=",-1); - yon_dictionary_add_or_create_if_exists_with_data(__yon__config__strings,key,str); - __yon__config__strings->data_type=DICTIONARY_CHAR_TYPE; - } - } - check_config - return 0; - else return 1; -} - -/**yon_config_remove_by_key(char *key) - * [EN] - * - * [RU] - * Удаляет параметр конфига по ключу [key] -*/ -int yon_config_remove_by_key(char *key){ - check_config{ - dictionary *dict = yon_dictionary_get(&__yon__config__strings,key); - if (dict){ - yon_dictionary_rip(dict); - return 1; - }else return 0; - } - return 0; -} - -/**yon_config_remove_by_data(void *data) - * [EN] - * - * [RU] - * Производит поиск по конфигу на наличие параметра со значением [data] и удаляет найденное значение из конфига. -*/ -int yon_config_remove_by_data(void *data){ - check_config{ - dictionary *dict = NULL; - for_dictionaries(dict,__yon__config__strings){ - if (dict->data==data){ - yon_dictionary_rip(dict); - return 1; - } - } - return 0; - } - return 0; -} - -/**yon_config_remove_element(char *key, char *deleted) - * [EN] - * - * [RU] - * Удаляет элемент [deleted] из массива параметров с ключом [key] -*/ -int yon_config_remove_element(char *key, char *deleted){ - check_config{ - dictionary *dict = yon_dictionary_get(&__yon__config__strings,key); - char *data = (char*)dict->data; - char *found = strstr(data,deleted); - int size=strlen(data)-strlen(found)+1; - char *new_data = malloc(size); - memset(new_data,0,size); - if (strlen(found)!=strlen(deleted)){ - memcpy(new_data,data,size-1); - new_data = yon_char_append(new_data,found+strlen(deleted)+1); - } else { - memcpy(new_data,data,size-2); - new_data = yon_char_append(new_data,found+strlen(deleted)); - } - dict->data=(void*)(new_data); - free(data); - dict->flag1=1; - return 1; - } else return 0; -} - -/**yon_config_get_by_key(char *key) - * [EN] - * - * [RU] - * Возвращает значение параметра конфига с ключом [key] -*/ -void *yon_config_get_by_key(char *key){ - check_config{ - dictionary *dict = NULL; - for_dictionaries(dict, __yon__config__strings){ - if (strcmp(dict->key,key)==0){ - return dict->data; - } - } - } - return NULL; -} - -/**yon_config_get_key_by_data(char *data) - * [EN] - * - * [RU] - * Возвращает ключ параметра конфига со значением [data]. - * Если параметр с таким значением не найден, возвращается NULL -*/ -char *yon_config_get_key_by_data(char *data){ - check_config{ - dictionary *dict = NULL; - for_dictionaries(dict, __yon__config__strings){ - if (strcmp(((char*)dict->data),data)==0){ - return dict->key; - } - } - } - return NULL; -} - -/**yon_config_set(char *key, void *data) - * [EN] - * - * [RU] - * Производит поиск по конфигу и заменяет значение параметра с ключом [key] на новое значение [data]; -*/ -int yon_config_set(char *key, void *data){ - check_config{ - dictionary *dict = yon_dictionary_get(&__yon__config__strings,key); - dict->data=data; - return 1; - } else return 0; -} - -/**yon_config_clean() - * [EN] - * Erase all parameters from config; - * [RU] - * Удаляет все параметры из конфига; -*/ -int yon_config_clean(){ - check_config{ - __yon__config__strings = yon_dictionary_free_all(__yon__config__strings, NULL); - return 1; - } - else return 0; -} - -/**yon_config_register(char *key, void *data) - * [EN] - * - * [RU] - * Регистрирует новый параметр конфига. - * [key] - ключ параметра; - * [data] - значение параметра; -*/ -void yon_config_register(char *key, void *data){ - yon_dictionary_add_or_create_if_exists_with_data(__yon__config__strings,key,data); - __yon__config__strings->data_type=DICTIONARY_CHAR_TYPE; -} - -/**yon_config_load(char *command, int *str_len) - * [EN] - * - * [RU] - * Выполняет команду [command] и возвращает распаршеный результат выполнения команды. - * В [str_len] возвращается длина возвращаемого массива -*/ -config_str yon_config_load(char *command, int *str_len){ - FILE *output = popen(command, "r"); - char **output_strings = NULL; - output_strings = malloc(sizeof(char)); - int i = 0; - char str[4096]; - memset(str, 0, 4096); - while (fgets(str, 4096, output)) - { - if (strcmp(str, "") != 0) - { - output_strings = realloc(output_strings, sizeof(char *) * (i + 1)); - // printf("%s\n", str); - output_strings[i] = NULL; - output_strings[i] = yon_char_new(str); - memset(str, 0, 4096); - i++; - } - } - if (i>0){ - *str_len = i; - return output_strings; - } else{ - *str_len=-1; - return NULL; - } -} - -/**int yon_config_save(char *command) - * [EN] - * Saves config with [command] - * [RU] - * Выполняет команду [command], добавляя в конец все записи конфига в таком виде: - * [ПАРАМЕТР1]="[значения1]" [ПАРАМЕТР2]="[значения2]" -*/ -int yon_config_save_registered(char *command){ - check_config{ - dictionary *dict = NULL; - for_dictionaries(dict,__yon__config__strings){ - command = yon_char_unite(command, " ", yon_dictionary_get_data(dict,char*), NULL); - } - if (popen(command, "r")) return 1; - else return 0; - } else return 0; -} - -/**yon_config_get_all(int *size) - * [EN] - * - * [RU] - * Возвращает массив со всеми параметрами конфига, оканчивающаяся NULL - * [size] - указатель, в который выгружается длина массива -*/ -config_str yon_config_get_all(int *size){ - check_config{ - *size = 1; - config_str conf = NULL; - dictionary *dict = NULL; - for_dictionaries(dict,__yon__config__strings){ - conf = yon_remalloc(conf,sizeof(char*)*(*size)); - conf[(*size)-1] = yon_char_unite(dict->key,"=",(char*)dict->data,NULL); - size++; - } - conf = yon_remalloc(conf,sizeof(char*)*(*size+1)); - conf[*size] = NULL; - return conf; - } else return NULL; -} - -/**char *yon_config_get_parameter(config parameters, int size, char *param) - * [EN] - * Gets parameter [param] from parameter list [parameters] of size [size]; - * or NULL if nothing were found - * [RU] - * Возвращает параметр [param] из массива строк [parameters] размером [size] - * или NULL если такой не был найден -*/ -char *yon_config_get_parameter(config_str parameters, int size, char *param) -{ - if (param[0]==' ') - yon_char_divide_search(param," ",-1); - param=yon_char_divide_search(yon_char_new(param)," ",-1); - - char *str = NULL; - for (int j = 0; j < size; j++) - { - char *name = yon_char_divide_search(yon_char_new(parameters[j]), "=", 1); - if (name) - { - if (strcmp(name, param) == 0) - { - str = yon_char_divide_search(yon_char_new(parameters[j]), "\n", 1); - if (strcmp(str, "") != 0 && strcmp(str, "(null)") != 0) - return str; - else - return NULL; - } - } - } - return NULL; -} - - - -// terminal-using functions - -/**yon_launch_app_with_arguments(char *name, char *args) - * [EN] - * Execute [command] in separate thread; - * [RU] - * Выполнить команду [command] в отдельном потоке; -*/ -int yon_launch_app_with_arguments(char *name, char *args) -{ - char *path = yon_char_unite("/usr/bin/", name, " ", args,NULL); - pthread_t thread_id; - char *command = NULL; - command = path; - pthread_create(&thread_id, NULL, (void *)yon_launch, command); -}; - -/**yon_launch(char *command) - * [EN] - * Execute command [command] - * [RU] - * Выполнить команду [command] -*/ -void yon_launch(char *command) -{ - system(command); -} - -// Gtk functions - - -#ifdef __GTK_H__ - - -static render_data render; - -#ifdef VTE_TERMINAL - -static void child_ready(VteTerminal *terminal, GPid pid, GError *error, gpointer user_data) -{ - if (!terminal) return; - if (pid == -1) printf("Error\n\n\n"); - else vte_terminal_feed_child(VTE_TERMINAL(terminal),(char*)user_data,strlen((char*)user_data)); -} - -/** - * void yon_terminal_integrated_launch(GtkWidget *place_to_show, void *endwork_function, void* endwork_function_argument) - * [EN] - * launches terminal with specific [command], - * terminal is shown in [place_to_show] container, - * after terminal done its work [endwork_function] is called with [endwork_function_argument] argument. - * [RU] - * Запускает терминал с командой [command], - * терминал добавляется в контейнер [place_to_show] виджета, - * после завершения работы терминала вызывается функция [endwork_function] с аргументом [endwork_function_argument]. -*/ -void yon_terminal_integrated_launch(GtkWidget *place_to_show, char* command, void *endwork_function, void* endwork_function_argument){ - char **commands=new_arr(char*,2); - gchar **envp = g_get_environ(); - commands[0]=(gchar *)g_strdup(g_environ_getenv(envp, "SHELL")); - commands[1]=NULL; - char **env=new_arr(char*,2); - env[0]=""; - env[1]=NULL; - GtkWidget *terminal = vte_terminal_new(); - vte_terminal_set_size(VTE_TERMINAL(terminal),10,15); - VtePty *pty = vte_pty_new_sync(VTE_PTY_DEFAULT,NULL,NULL); - vte_terminal_set_pty(VTE_TERMINAL(terminal),pty); - gtk_container_add(GTK_CONTAINER(place_to_show),terminal); - char *install_command=yon_char_unite("tput cup 0 0 && tput ed; ",command," ; sleep 5;exit 0","\n",NULL); - printf("%s\n",install_command); - if(endwork_function) - g_signal_connect(G_OBJECT(terminal), "child-exited", G_CALLBACK(endwork_function), endwork_function_argument); - vte_terminal_spawn_async(VTE_TERMINAL(terminal), - VTE_PTY_DEFAULT, - NULL, - commands, - NULL, - 0, - NULL, NULL, - NULL, - -1, - NULL, - child_ready, - install_command); - vte_pty_spawn_async(pty, - NULL, - commands, - NULL, - 0, - NULL, NULL, - NULL, - -1, - NULL, - NULL, - NULL); - vte_terminal_set_scrollback_lines(VTE_TERMINAL(terminal), -1); - vte_terminal_set_scroll_on_output(VTE_TERMINAL(terminal), TRUE); - vte_terminal_set_scroll_on_keystroke(VTE_TERMINAL(terminal), TRUE); - gtk_widget_show_all(terminal); - } - -/**yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *endwork_function, void* endwork_function_argument) - * [EN] - * launches terminal with specific [command], - * terminal is shown in [place_to_show] container, - * after terminal done its work [endwork_function] is called with [endwork_function_argument] argument. - * [RU] - * Запускает терминал с командой [command], - * терминал добавляется в контейнер [place_to_show] виджета, - * после завершения работы терминала вызывается функция [endwork_function] с аргументом [endwork_function_argument]. -*/ -void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *endwork_function, void* endwork_function_argument){ - char **commands=new_arr(char*,2); - gchar **envp = g_get_environ(); - commands[0]=(gchar *)g_strdup(g_environ_getenv(envp, "SHELL")); - commands[1]=NULL; - char **env=new_arr(char*,2); - env[0]=""; - env[1]=NULL; - vte_terminal_set_size(VTE_TERMINAL(terminal),10,15); - VtePty *pty = vte_pty_new_sync(VTE_PTY_DEFAULT,NULL,NULL); - vte_terminal_set_pty(VTE_TERMINAL(terminal),pty); - char *install_command=yon_char_unite("tput cup 0 0 && tput ed; ",command," ; sleep 5;exit 0","\n",NULL); - if(endwork_function) - g_signal_connect(G_OBJECT(terminal), "child-exited", G_CALLBACK(endwork_function), endwork_function_argument); - vte_terminal_spawn_async(VTE_TERMINAL(terminal), - VTE_PTY_DEFAULT, - NULL, - commands, - NULL, - 0, - NULL, NULL, - NULL, - -1, - NULL, - child_ready, - install_command); - vte_pty_spawn_async(pty, - NULL, - commands, - NULL, - 0, - NULL, NULL, - NULL, - -1, - NULL, - NULL, - NULL); - vte_terminal_set_scrollback_lines(VTE_TERMINAL(terminal), 100); - vte_terminal_set_scroll_on_output(VTE_TERMINAL(terminal), TRUE); - vte_terminal_set_scroll_on_keystroke(VTE_TERMINAL(terminal), TRUE); - gtk_widget_show_all(terminal); - } -#endif - - // Window config functions - - #define check_window_config_setup if(__yon_window_config_target_window) - - typedef struct { - char *parameter_name; - enum YON_TYPE containing_type; - GtkWidget *track_widget; - char *property_name; - } __yon_listener_parameter; - - typedef struct { - char *parameter_name; - char *section; - enum YON_TYPE containing_type; - void *property; - } __yon_custom_parameter; - - struct { - int x; - int y; - int width; - int height; - int fullscreen; - dictionary *custom_listeners; - dictionary *custom_parameters; - dictionary *deleted_parameters; - } __yon_main_window_config; - - static GtkWindow *__yon_window_config_target_window = NULL; - static GKeyFile *__yon_window_config_file = NULL; - static char *__yon_window_config_path = NULL; - - void yon_window_config_save(){ - g_key_file_set_integer(__yon_window_config_file,"window","WindowPosX",__yon_main_window_config.x); - g_key_file_set_integer(__yon_window_config_file,"window","WindowPosY",__yon_main_window_config.y); - g_key_file_set_integer(__yon_window_config_file,"window","WindowWidth",__yon_main_window_config.width); - g_key_file_set_integer(__yon_window_config_file,"window","WindowHeight",__yon_main_window_config.height); - g_key_file_set_integer(__yon_window_config_file,"window","fullscreen",__yon_main_window_config.fullscreen); - dictionary *dict=NULL; - if (__yon_main_window_config.custom_listeners) - for_dictionaries(dict,__yon_main_window_config.custom_listeners){ - __yon_listener_parameter *param = yon_dictionary_get_data(dict,__yon_listener_parameter*); - GValue *val = g_malloc0(sizeof(GValue)); - g_object_get_property(G_OBJECT(param->track_widget),param->property_name,val); - switch(param->containing_type){ - case YON_TYPE_STRING: - g_key_file_set_string(__yon_window_config_file,"window",param->parameter_name, g_value_get_string(val)); - break; - case YON_TYPE_INT: - g_key_file_set_integer(__yon_window_config_file,"window",param->parameter_name, g_value_get_int(val)); - break; - case YON_TYPE_BOOLEAN: - g_key_file_set_boolean(__yon_window_config_file,"window",param->parameter_name, g_value_get_boolean(val)); - break; - case YON_TYPE_OTHER:printf("\033[0;31mCannot save %s property with %s key\033[0m\n",param->property_name,param->parameter_name);break; - } - } - if (__yon_main_window_config.custom_parameters) - for_dictionaries(dict,__yon_main_window_config.custom_parameters){ - __yon_custom_parameter *param = yon_dictionary_get_data(dict,__yon_custom_parameter*); - switch (param->containing_type){ - case YON_TYPE_STRING: - g_key_file_set_string(__yon_window_config_file,param->section,param->parameter_name, (char*)param->property); - break; - case YON_TYPE_INT: - g_key_file_set_integer(__yon_window_config_file,param->section,param->parameter_name, *(int*)param->property); - break; - case YON_TYPE_BOOLEAN: - g_key_file_set_boolean(__yon_window_config_file,param->section,param->parameter_name, *(gboolean*)param->property); - break; - default: - break; - } - } - if (__yon_main_window_config.deleted_parameters) - for_dictionaries(dict,__yon_main_window_config.deleted_parameters){ - __yon_custom_parameter *param = yon_dictionary_get_data(dict,__yon_custom_parameter*); - g_key_file_remove_key(__yon_window_config_file,param->section,param->parameter_name,NULL); - } - g_key_file_save_to_file(__yon_window_config_file,__yon_window_config_path,NULL); - } - - void yon_get_is_fullscreen(){ - gtk_window_is_maximized(__yon_window_config_target_window); - __yon_main_window_config.fullscreen = gtk_window_is_maximized(__yon_window_config_target_window); - if (!__yon_main_window_config.fullscreen) gtk_window_get_position(__yon_window_config_target_window,&__yon_main_window_config.x,&__yon_main_window_config.y); - } - - /**yon_on_configured_window_destroy(GtkWidget* self,GdkEvent* event) - * [EN] - * - * [RU] - * Сохраняет настройки основного окна. Вызывается когда основное окно уничтожается. - */ - void yon_on_configured_window_destroy(GtkWidget* self,GdkEvent* event){ - check_window_config_setup{ - yon_get_is_fullscreen(); - yon_window_config_save(); - } - gtk_main_quit(); - } - - void __yon_window_config_on_resize(){ - int max=0; - max=gtk_window_is_maximized(__yon_window_config_target_window); - if(max==0){ - gtk_window_get_size(__yon_window_config_target_window,&__yon_main_window_config.width,&__yon_main_window_config.height); - gtk_window_get_position(__yon_window_config_target_window,&__yon_main_window_config.x,&__yon_main_window_config.y); - } - } - - /**yon_window_config_setup(GtkWindow *window) - * [EN] - * - * [RU] - * Устанавливает указатель на окно для отслеживания его положения и размера - */ - void yon_window_config_setup(GtkWindow *window){ - __yon_window_config_target_window = window; - g_signal_connect(G_OBJECT(window),"delete-event",G_CALLBACK(yon_on_configured_window_destroy),NULL); - g_signal_connect(G_OBJECT(window),"check-resize"/*"configure-event"*/,G_CALLBACK(__yon_window_config_on_resize),NULL); - } - - void _yon_maximize(void *data){ - g_usleep(G_USEC_PER_SEC/10); - if(__yon_main_window_config.fullscreen ==1) gtk_window_maximize(__yon_window_config_target_window); - } - - /**yon_window_config_load(char *path) - * [EN] - * - * [RU] - * Загружает конфиг окна и инициализирует отслеживание его параметров - */ - int yon_window_config_load(char *path){ - __yon_window_config_file = g_key_file_new(); - __yon_window_config_path=yon_char_new(path); - if (!g_key_file_load_from_file(__yon_window_config_file,__yon_window_config_path,G_KEY_FILE_NONE,NULL)){ - struct stat st; - int size; - char *path = yon_char_divide(yon_char_new(__yon_window_config_path),yon_char_find_last(__yon_window_config_path,'/')); - if (stat(path, &st) == -1) { - mkdir(path, 0777); - } - FILE *fp; - fp=fopen(__yon_window_config_path,"w"); - fclose(fp); - g_key_file_load_from_file(__yon_window_config_file,__yon_window_config_path,G_KEY_FILE_NONE,NULL); - } - __yon_main_window_config.x = g_key_file_get_integer(__yon_window_config_file,"window","WindowPosX",NULL); - __yon_main_window_config.y = g_key_file_get_integer(__yon_window_config_file,"window","WindowPosY",NULL); - __yon_main_window_config.width = g_key_file_get_integer(__yon_window_config_file,"window","WindowWidth",NULL); - __yon_main_window_config.height = g_key_file_get_integer(__yon_window_config_file,"window","WindowHeight",NULL); - __yon_main_window_config.fullscreen = g_key_file_get_integer(__yon_window_config_file,"window","fullscreen",NULL); - dictionary *dict=NULL; - if (__yon_main_window_config.custom_listeners) - for_dictionaries(dict,__yon_main_window_config.custom_listeners){ - __yon_listener_parameter *param = yon_dictionary_get_data(dict,__yon_listener_parameter*); - GValue *val = g_malloc0(sizeof(GValue)); - g_object_get_property(G_OBJECT(param->track_widget),param->property_name,val); - switch(param->containing_type){ - case YON_TYPE_STRING: - g_value_set_string(val,g_key_file_get_string(__yon_window_config_file,"window",param->parameter_name, NULL)); - break; - case YON_TYPE_INT: - g_value_set_int(val,g_key_file_get_integer(__yon_window_config_file,"window",param->parameter_name, NULL)); - break; - case YON_TYPE_BOOLEAN: - gboolean res = g_key_file_get_boolean(__yon_window_config_file,"window",param->parameter_name, NULL); - g_value_set_boolean(val,res); - break; - default:printf("\033[0;31mCannot load %s property with %s key\033[0m\n",param->property_name,param->parameter_name);break; - } - g_object_set_property(G_OBJECT(param->track_widget),param->property_name,val); - } - if (__yon_main_window_config.width==0) __yon_main_window_config.width=800; - if (__yon_main_window_config.height==0) __yon_main_window_config.height=600; - gtk_window_resize(__yon_window_config_target_window,__yon_main_window_config.width,__yon_main_window_config.height); - gtk_window_move(__yon_window_config_target_window,__yon_main_window_config.x,__yon_main_window_config.y); - pthread_t tid; - pthread_create(&tid,NULL,(void *)_yon_maximize,NULL); - return 1; - } - - void yon_window_config_apply(){ - dictionary *dict=NULL; - gtk_window_move(__yon_window_config_target_window,__yon_main_window_config.x,__yon_main_window_config.y); - gtk_window_resize(__yon_window_config_target_window,__yon_main_window_config.width,__yon_main_window_config.height); - } - - config_str yon_window_config_get_section(char *section, gsize *size){ - config_str key = g_key_file_get_keys(__yon_window_config_file,section,size,NULL); - return key; - } - - /**yon_window_config_add_listener(GtkWidget *widget, char *param_name, char *widget_property, enum YON_TYPE val_type) - * [EN] - * - * [RU] - * Добавляет параметр виджета [widget] по названию [widget_property] для отслеживания и сохраняет его в конфиг под ключом [param_name]. - */ - void yon_window_config_add_listener(GtkWidget *widget, char *param_name, char *widget_property, enum YON_TYPE val_type){ - __yon_listener_parameter *param = NULL; - param = yon_remalloc(param,sizeof(__yon_listener_parameter)); - param->parameter_name = yon_char_new(param_name); - param->track_widget = widget; - param->property_name = yon_char_new(widget_property); - param->containing_type = val_type; - yon_dictionary_add_or_create_if_exists_with_data(__yon_main_window_config.custom_listeners,param->parameter_name,param); - } - - void yon_window_config_add_custom_parameter(char *param_name, char *section, void *tracked_value, enum YON_TYPE val_type){ - __yon_custom_parameter *param = NULL; - param = yon_remalloc(param,sizeof(__yon_custom_parameter)); - param->parameter_name = yon_char_new(param_name); - param->section=section; - param->property = tracked_value; - param->containing_type = val_type; - yon_dictionary_add_or_create_if_exists_with_data(__yon_main_window_config.custom_parameters,param->parameter_name,param); - } - - void yon_window_config_erase_custom_parameter(char *param_name, char *section){ - __yon_custom_parameter *param = NULL; - param = yon_remalloc(param,sizeof(__yon_custom_parameter)); - param->parameter_name=param_name; - param->section=section; - yon_dictionary_add_or_create_if_exists_with_data(__yon_main_window_config.deleted_parameters,param->parameter_name,param); - } - - int yon_window_config_get_parameter(char *section, char *config_parameter, void *return_value, enum YON_TYPE type){ - GError *err=NULL; - switch (type){ - case YON_TYPE_BOOLEAN: - *((int*)return_value) = g_key_file_get_boolean(__yon_window_config_file,section,config_parameter,&err); - if (err) return 0; else return 1; - break; - case YON_TYPE_INT: - *((int*)return_value) = g_key_file_get_integer(__yon_window_config_file,section,config_parameter,&err); - if (err) return 0; else return 1; - break; - case YON_TYPE_STRING: - *((char**)return_value) = g_key_file_get_string(__yon_window_config_file,section,config_parameter,&err); - if (err) return 0; else return 1; - break; - case YON_TYPE_STRING_LIST: - gsize size=0; - *((char***)return_value) = g_key_file_get_string_list(__yon_window_config_file,section,config_parameter,&size,&err); - *((char***)return_value)=yon_remalloc(return_value,size+1); - *((char***)return_value)[size]=NULL; - if (err) return 0; else return 1; - break; - } - } - -GtkWidget *yon_ubl_menu_item_about_new(char *buttonname){ - GtkWidget *menu_item = gtk_menu_item_new(); - gtk_style_context_add_class(gtk_widget_get_style_context(menu_item),"menuitembottom"); - GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0); - GtkWidget *label = gtk_label_new(buttonname); - GtkWidget *image = gtk_image_new_from_icon_name("dialog-information-symbolic",GTK_ICON_SIZE_BUTTON); - gtk_label_set_xalign(GTK_LABEL(label),0.0); - gtk_box_pack_start(GTK_BOX(box),image,0,0,5); - gtk_box_pack_start(GTK_BOX(box),label,0,0,5); - gtk_container_add(GTK_CONTAINER(menu_item),box); - gtk_widget_show_all(menu_item); - return menu_item; -} - -GtkWidget *yon_ubl_menu_item_documentation_new(char *buttonname){ - GtkWidget *menu_item = gtk_menu_item_new(); - gtk_style_context_add_class(gtk_widget_get_style_context(menu_item),"menuitemtop"); - GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0); - GtkWidget *label = gtk_label_new(buttonname); - GtkWidget *image = gtk_image_new_from_icon_name("dialog-question-symbolic",GTK_ICON_SIZE_BUTTON); - gtk_label_set_xalign(GTK_LABEL(label),0.0); - gtk_box_pack_start(GTK_BOX(box),image,0,0,5); - gtk_box_pack_start(GTK_BOX(box),label,0,0,5); - gtk_container_add(GTK_CONTAINER(menu_item),box); - gtk_widget_show_all(menu_item); - return menu_item; -} - - -// other Gtk functions - -/**yon_gtk_combo_box_text_fill(GtkWidget *combo, config_str parameters,int size) - * [EN] - * - * [RU] - * Добавляет в Комбобокс [combo] все строки из массива строк [parameters] размера [size] -*/ -int yon_gtk_combo_box_text_fill(GtkWidget *combo, config_str parameters,int size){ - if (combo&¶meters){ - for (int i=0;imessage); - g_error_free(err); - } - if (type == BACKGROUND_IMAGE_SUCCESS_TYPE||! type) - { - gtk_style_context_remove_class(gtk_widget_get_style_context(data.box), "boxInfoMessError"); - gtk_style_context_add_class(gtk_widget_get_style_context(data.box), "boxInfoMessOK"); - gtk_image_set_from_pixbuf(GTK_IMAGE(data.icon), gtk_icon_theme_load_icon_for_scale(ictheme, "com.ublinux.ubl-settings-video.checked", 25, 1, GTK_ICON_LOOKUP_FORCE_SIZE, &err)); - } - else if (type == BACKGROUND_IMAGE_FAIL_TYPE) - { - gtk_style_context_remove_class(gtk_widget_get_style_context(data.box), "boxInfoMessOK"); - gtk_style_context_add_class(gtk_widget_get_style_context(data.box), "boxInfoMessError"); - gtk_image_set_from_pixbuf(GTK_IMAGE(data.icon), gtk_icon_theme_load_icon_for_scale(ictheme, "com.ublinux.ubl-settings-video.warning", 25, 1, GTK_ICON_LOOKUP_FORCE_SIZE, &err)); - } - if (text) - gtk_label_set_text(GTK_LABEL(data.label), text); -} - -void yon_ubl_status_box_render(char *text, BACKGROUND_IMAGE_TYPE type){ - _yon_ubl_status_box_render(text,type); -} - -/**yon_ubl_setup_sockets(GtkWidget *main_window, GtkWidget *left_window, GtkWidget *right_window, int socket_main_id, int socket_left_id, int socket_right_id) - * [EN] - * Set up plugs for using with GtkSockets insine ubl-settings-manager. - * [main_window] is container widget, which holds main application functionality. - * [left_window] is container widget, which holds widgets, have to be shown at left part of ubl-settings-manager header. - * [right_window] is container widget, which holds widgets, have to be shown at right part of ubl-settings-manager header. - * [socket_main_id] is id of socket for [main_window]. - * [socket_left_id] is id of socket for [left_window]. - * [socket_right_id] is id of socket for [right_window]. - * [RU] - * Настраивает плаги для работы с сокетами в утилите ubl-settings-manager. - * [main_window] - контейнер основного интерфейса приложения. - * [left_window] - контейнер для виджетов которые должны отображаться в левой части шапки ubl-settings-manager. - * [right_window] - контейнер для виджетов которые должны отображаться в правой части шапки ubl-settings-manager. - * [socket_main_id] - id сокета для [main_window]. - * [socket_left_id] - id сокета для [left_window]. - * [socket_right_id] - id сокета для [right_window]. -*/ -void yon_ubl_setup_sockets(GtkWidget *main_window, GtkWidget *left_window, GtkWidget *right_window, int socket_main_id, int socket_left_id, int socket_right_id){ - if (main_window&&socket_main_id>-1){ - gtk_widget_hide(gtk_widget_get_toplevel(main_window)); - GtkWidget *plug_main=gtk_plug_new(socket_main_id); - GtkWidget *plug_left=NULL; - GtkWidget *plug_right=NULL; - GtkWidget *box=NULL; - g_signal_connect(G_OBJECT(plug_main), "destroy", G_CALLBACK(gtk_main_quit),NULL); - if (socket_left_id>-1&&left_window){ - plug_left=gtk_plug_new(socket_left_id); - g_object_ref(left_window); - gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(left_window)),left_window); - gtk_container_add(GTK_CONTAINER(plug_left),left_window); - gtk_style_context_add_class(gtk_widget_get_style_context(plug_left),"primary-toolbar"); - gtk_style_context_add_class(gtk_widget_get_style_context(left_window),"button"); - gtk_style_context_add_class(gtk_widget_get_style_context(left_window),"opacited"); - gtk_style_context_add_class(gtk_widget_get_style_context(left_window),"color"); - gtk_style_context_add_class(gtk_widget_get_style_context(plug_left),"noborder"); - gtk_widget_show(plug_left); - } - else if (left_window){ - if (box==NULL){ - box=gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5); - gtk_box_pack_start(GTK_BOX(main_window),box,0,0,5); - gtk_box_reorder_child(GTK_BOX(main_window),box,0); - gtk_widget_show(box); - } - gtk_style_context_add_class(gtk_widget_get_style_context(left_window),"inherited"); - gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(left_window)),left_window); - gtk_box_pack_end(GTK_BOX(box),left_window,0,0,5); - } - if (socket_right_id>-1&&right_window){ - plug_right=gtk_plug_new(socket_right_id); - g_object_ref(right_window); - gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(right_window)),right_window); - gtk_container_add(GTK_CONTAINER(plug_right),right_window); - gtk_style_context_add_class(gtk_widget_get_style_context(plug_right),"primary-toolbar"); - gtk_style_context_add_class(gtk_widget_get_style_context(right_window),"button"); - gtk_style_context_add_class(gtk_widget_get_style_context(right_window),"opacited"); - gtk_style_context_add_class(gtk_widget_get_style_context(right_window),"color"); - gtk_style_context_add_class(gtk_widget_get_style_context(plug_right),"noborder"); - gtk_widget_show(plug_right); - } - else if (right_window){ - if (box==NULL){ - box=gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5); - gtk_box_pack_start(GTK_BOX(main_window),box,0,0,5); - gtk_box_reorder_child(GTK_BOX(main_window),box,0); - gtk_widget_show(box); - } - gtk_style_context_add_class(gtk_widget_get_style_context(right_window),"inherited"); - gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(right_window)),right_window); - gtk_box_pack_start(GTK_BOX(box),right_window,0,0,5); - } - g_object_ref(main_window); - gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(main_window)),main_window); - gtk_container_add(GTK_CONTAINER(plug_main),main_window); - gtk_widget_show(plug_main); - } -} - -#ifdef WEBKIT_FOUND - -/**yon_ubl_browser_window_open(char *link, char *browser_window_name) - * [EN] - * Launches integrated browser window, named [browser_window_name] at header with [link]. - * [RU] - * Открывает встроенный браузер с именем [browser_window_name] и показываемой страницей по ссылке [link] -*/ -void yon_ubl_browser_window_open(char *link, char *browser_window_name){ - GtkWidget *browser=gtk_window_new(GTK_WINDOW_TOPLEVEL); - GtkWidget *web_place=gtk_box_new(GTK_ORIENTATION_VERTICAL,0); - GtkWidget *header=gtk_header_bar_new(); - GtkWidget *header_label=gtk_label_new(browser_window_name); - GtkWidget *WebView=webkit_web_view_new(); - gtk_container_add(GTK_CONTAINER(browser),web_place); - gtk_window_set_titlebar(GTK_WINDOW(browser),header); - gtk_window_set_title(GTK_WINDOW(browser),browser_window_name); - gtk_widget_set_size_request(browser,800,600); - gtk_header_bar_set_custom_title(GTK_HEADER_BAR(header),header_label); - gtk_header_bar_set_show_close_button(GTK_HEADER_BAR(header),1); - webkit_web_view_load_uri(WEBKIT_WEB_VIEW(WebView),link); - gtk_box_pack_start(GTK_BOX(web_place),WebView,1,1,0); - gtk_widget_show_all(browser); -} -#else - -/**yon_ubl_browser_window_open(char *link, char *browser_window_name) - * [EN] - * Launches browser with [link]. - * [browser_window_name] is't used. It's needed for compatibility with webkit version of that function. - * [RU] - * Открывает браузер со страницей по ссылке [link] - * [browser_window_name] не используется. Нужна для совместимости с webkit версией этой функции. -*/ -void yon_ubl_browser_window_open(char *link, char *browser_window_name){ - char *user=getenv("SUDO_USER"); - if (!user) - user=getlogin(); - char *command=yon_char_unite("sudo -u ",user," xdg-open ", link,NULL); - yon_launch_app(command); -} -#endif - -#endif \ No newline at end of file diff --git a/source/ubl-utils.h b/source/ubl-utils.h deleted file mode 100644 index 6ef2559..0000000 --- a/source/ubl-utils.h +++ /dev/null @@ -1,367 +0,0 @@ -#ifndef UBL_UTILS -#define UBL_UTILS -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../compile/ubl-cmake.h" -#ifdef WEBKIT_FOUND - #include -#endif -#define DesktopPath "/usr/share/applications/" - -#define for_dictionaries(obj, obj1) for (obj = obj1->first; obj != NULL; obj = obj->next) - -#define new(type) malloc(sizeof(type)) -#define new_arr(type,size) malloc(sizeof(type)*size) - -#define get_home_dir_command yon_char_unite("getent passwd \"",yon_ubl_root_user_get(),"\" | cut -d: -f6",NULL) - -typedef enum -{ - #ifdef __GTK_H__ - DICTIONARY_GTK_WIDGETS_TYPE, - #endif - DICTIONARY_OTHER_TYPE=0, - DICTIONARY_CHAR_TYPE, - DICTIONARY_INT_TYPE, - DICTIONARY_BOOL_TYPE, - -} DICT_TYPE; - -typedef struct dictionary -{ - char *key; - void *data; - struct dictionary *next; - struct dictionary *prev; - struct dictionary *first; - DICT_TYPE data_type; - int flag1; -} dictionary; - -typedef struct apps -{ - char *Name; - int Type; - char *Categories; - char *Exec; - char *Icon; - int Pluggable; - int DualPluggable; -} apps; - -typedef char** config_str; - -static dictionary *__yon__config__strings = NULL; -#define check_config if(__yon__config__strings&&__yon__config__strings->data_type==DICTIONARY_CHAR_TYPE) - -#define config(key) yon_config_get_by_key(key) - -#define for_config dictionary temp = NULL; for_dictionary(temp,__yon__config__strings) - -#define yon_remalloc(pointer, size) (!pointer) ? malloc(size) : realloc(pointer, size) -// dictionary functions - -/**yon_dictionary_get_data(dictionary, type) - * [EN] - * Gets data from dictionary. - * [dictionary] is dictionary, from which data should be extracted; - * [type] is type of data, [dictionary] contains. - * [RU] - * Возвращает данные из словаря. - * [dictionary] - словарь из которого достаются данные. - * [type] - тип данных, хранящихся в словаре [dictionary]. -*/ -#define yon_dictionary_get_data(dictionary, type) ((type)dictionary->data) - -/**yon_dictionary_add_or_create_if_exists_with_data(dict,key,data) - * [EN] - * - * [RU] - * Добавляет элемент словаря в конец словаря [dict] c ключом [key] и данными [data]. - * Если словарь не существует, создаёт его -*/ -#define yon_dictionary_add_or_create_if_exists_with_data(dict,key,data) {if (!dict) dict=yon_dictionary_new_with_data(key,data); \ - else dict=yon_dictionary_append_with_data(dict,key,data);} - -dictionary *yon_dictionary_new(); - -dictionary *yon_dictionary_append(dictionary *targetdict); - -dictionary *yon_dictionary_get_last(dictionary *dict); - -dictionary *yon_dictionary_swap(dictionary *dict, int aim); - -void yon_dictionary_make_first(dictionary *dict); - -void yon_dictionary_make_nth(dictionary *dict, int nth); - -dictionary *yon_dictionary_new_with_data(char *key, void *data); - -dictionary *yon_dictionary_append_with_data(dictionary *dict, char *key, void *data); - -dictionary *yon_dictionary_connect(dictionary *old, dictionary *toconnect); - -dictionary *yon_dictionary_get(dictionary **dict, char *key); - -dictionary *yon_dictionary_rip(dictionary *dict); - -dictionary *yon_dictionary_get_nth(dictionary *dict, int place); - -void *yon_dictionary_free_all(dictionary *dictionary,void (data_manipulation)(void*)); - -// char functions - -int yon_char_find_last(char *source, char find); - -char *yon_char_append(char *source, char *append); - -char *yon_char_new(char *chr); - -char *yon_char_unite(char *source, ...); - -char *yon_cut(char *source, int size, int startpos); - -char *yon_char_divide(char *source, int dividepos); - -char *yon_char_divide_search(char *source, char *dividepos, int delete_divider); - -char *yon_char_from_int(int int_to_convert); - -char *yon_char_replace(char *source, char *find, char*replace); - -char **yon_char_parse(char *parameters, int *size, char *divider); - -char **yon_char_parsed_rip(char **char_string, int *size, int item_to_delete); - -int yon_char_parsed_check_exist(char **parameters, int size, char *param); - -int yon_char_find_count(char *source, char *find); - -int yon_char_parsed_includes_char_parsed (config_str source, config_str to_check, int source_size, int check_size); - -config_str yon_char_parsed_new (int *size, ...); - -void yon_char_parsed_copy(config_str *source, config_str *to_copy); - -config_str yon_char_parsed_append(config_str parsed, int *size, char *string); - -int yon_ubl_check_root(); - -char *yon_ubl_root_user_get(); - -char *yon_ubl_user_get_home_directory(); - -// parsing functions - -config_str philos_list_user(int* size); - -apps *yon_apps_scan_and_parse_desktops(int *sizef); - -void yon_apps_sort(apps *applist, int size); - -apps *yon_apps_get_by_name(apps *applist, char *name, int size); - -config_str yon_config_load(char *command, int *str_len); - -int yon_config_save_registered(char *command); - -char *yon_config_get_parameter(config_str parameters, int size, char *param); - -int yon_config_load_register(char *command); - -int yon_config_remove_by_key(char *key); - -int yon_config_remove_by_data(void *data); - -int yon_config_remove_element(char *key, char *deleted); - -void *yon_config_get_by_key(char *key); - -char *yon_config_get_key_by_data(char *data); - -int yon_config_set(char *key, void *data); - -int yon_config_clean(); - -void yon_config_register(char *key, void *data); - -config_str yon_config_get_all(); - -// terminal-using functions - -int yon_launch_app_with_arguments(char *name, char *args); - -void yon_launch(char *command); - -// Gtk functions - -#ifdef __GTK_H__ -#ifdef VTE_TERMINAL -void yon_terminal_integrated_launch(GtkWidget *place_to_show, char* command, void *endwork_function, void* endwork_function_argument); - -void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *endwork_function, void* endwork_function_argument); - -#endif - -enum YON_TYPE{ - YON_TYPE_STRING, - YON_TYPE_STRING_LIST, - YON_TYPE_INT, - YON_TYPE_BOOLEAN, - YON_TYPE_OTHER -}; - -GtkWidget *yon_ubl_menu_item_about_new(char *buttonname); -GtkWidget *yon_ubl_menu_item_documentation_new(char *buttonname); - -/**yon_gtk_builder_get_widget(builder, widget_name) - * [EN] - * Returns GtkWidget from GtkBuilder *[builder]. - * [builder] is GtkBuilder*; - * [widget_name] is id of widget; -*/ -#define yon_gtk_builder_get_widget(builder, widget_name) GTK_WIDGET(gtk_builder_get_object(builder, widget_name)) - -typedef struct -{ - GtkWidget *Icon; - GtkWidget *Label; - GtkWidget *IconView; - GtkListStore *List; -} expander_icon_view; - -void yon_window_config_setup(GtkWindow *window); - -int yon_window_config_load(char *path); - -config_str yon_window_config_get_section(char *section, gsize *size); - -void yon_window_config_add_listener(GtkWidget *widget, char *param_name, char *widget_property, enum YON_TYPE val_type); - -void yon_window_config_add_custom_parameter(char *param_name, char *section, void *tracked_value, enum YON_TYPE val_type); - -void yon_window_config_erase_custom_parameter(char *param_name, char *section); - -int yon_window_config_get_parameter(char *section, char *config_parameter, void *return_value, enum YON_TYPE type); - -int yon_gtk_combo_box_fill(GtkWidget *combo, char **parameters,int size); - -int yon_gtk_combo_box_text_find(GtkWidget *combo_box, char *text_to_find); - -int yon_gtk_icon_view_hide_empty(dictionary *icon_view_segment); - -int yon_dictionary_gtk_pack_start_multiple_widgets(GtkBox *destination, gboolean expand, gboolean fill, int padding, ...); - -int yon_dictionary_gtk_pack_end_multiple_widgets(GtkBox *destination, gboolean expand, gboolean fill, int padding, ...); - - - -typedef enum -{ - BACKGROUND_IMAGE_SUCCESS_TYPE, - BACKGROUND_IMAGE_FAIL_TYPE -} BACKGROUND_IMAGE_TYPE; - -typedef struct { - BACKGROUND_IMAGE_TYPE type; - GtkWidget *icon; - GtkWidget *box; - GtkWidget *label; - char* text_to_render; -} render_data; - - -/**yon_ubl_status_box_setup(render,icon,box,label) - * [EN] - * Sets up [render] structure of type render_data. - * [icon] is GtkImage widget of status box for showing status icons; - * [box] is GtkBox widget of status box for showing status color; - * [label] is GtkLabel widget of status box for showing status text; - * [RU] - * Настраивает структуру [render] типа render_data. - * [icon] - виджет типа GtkIcon в котором будут отображаться статусные иконки; - * [box] - виджет типа GtkBox в котором будет отображаться цвет статуса; - * [label] - виджет типа GtkLabel в котором будет отображаться текст статусного сообщения; -*/ -int yon_ubl_status_box_setup(GtkWidget *icon, GtkWidget *box, GtkWidget *label); - -/**yon_ubl_status_box_render(render,text,type) - * [EN] - * Renders message in status box; - * [render] is render_data structure of status box; - * [text] is text to be shown in status box; - * [type] if type of message. Can be BACKGROUND_IMAGE_FAIL_TYPE or BACKGROUND_IMAGE_SUCCESS_TYPE - * [RU] - * Отображает сообщение в статусном окне. - * [render] - структура типа render_data для нужного статусного окна; - * [text] - текст, отображаемый в статусном окне; - * [type] - тип сообщения. Может быть: - * BACKGROUND_IMAGE_FAIL_TYPE (красный фон,иконка - восклицательный знак) - * или - * BACKGROUND_IMAGE_SUCCESS_TYPE (Жёлтный фон, иконка - галка) -*/ -void yon_ubl_status_box_render(char *text, BACKGROUND_IMAGE_TYPE type); - -#ifdef __cplusplus - -/**yon_ubl_header_setup(overlay, head, image, imag_path) - * [EN] - * Sets up header of app. - * [overlay] is overlay for app header; - * [head] is box of header, which connects to [overlay] - * [image] is header background image; - * [imag_path] is path of image, shown in [image] - * [RU] - * Настраивает заголовок приложения. - * [overlay] - оверлей заголовка приложения; - * [head] - шапка заголовка, присоединяемая к [overlay] - * [image] - виджет картинки для заднего фона; - * [imag_path] - путь до картинки, загружаемой в [image] -*/ -#define yon_ubl_header_setup(overlay, head, image, imag_path) _yon_ubl_header_setup(GTK_WIDGET(overlay.gobj()), GTK_WIDGET(head.gobj()), GTK_WIDGET(image.gobj()), (char *)imag_path) -#else - -/**yon_ubl_header_setup(overlay, head, image, imag_path) - * [EN] - * Sets up header of app. - * [overlay] is overlay for app header; - * [head] is box of header, which connects to [overlay] - * [image] is header background image; - * [imag_path] is path of image, shown in [image] - * [RU] - * Настраивает заголовок приложения. - * [overlay] - оверлей заголовка приложения; - * [head] - шапка заголовка, присоединяемая к [overlay] - * [image] - виджет картинки для заднего фона; - * [imag_path] - путь до картинки, загружаемой в [image] -*/ -#define yon_ubl_header_setup(overlay, head, image, imag_path) _yon_ubl_header_setup(GTK_WIDGET(overlay), GTK_WIDGET(head), GTK_WIDGET(image), (char *)imag_path) -#define yon_ubl_header_setup_resource(overlay, head, image, imag_path) _yon_ubl_header_setup_resource(GTK_WIDGET(overlay), GTK_WIDGET(head), GTK_WIDGET(image), (char *)imag_path) -#endif - -void _yon_ubl_header_setup(GtkWidget *Overlay, GtkWidget *Head, GtkWidget *Image, char *image_path); - -void _yon_ubl_header_setup_resource(GtkWidget *Overlay, GtkWidget *Head, GtkWidget *Image, char *image_path); - -void yon_ubl_setup_sockets(GtkWidget *main_window, GtkWidget *left_window, GtkWidget *right_window, int socket_main_id, int socket_left_id, int socket_right_id); -#ifdef WEBKIT_FOUND - -void yon_ubl_browser_window_open(char *link, char *browser_window_name); -#else -void yon_ubl_browser_window_open(char *link, char *browser_window_name); -#endif -#endif -#endif \ No newline at end of file diff --git a/ubl-settings-repomanager-add.glade b/ubl-settings-repomanager-add.glade new file mode 100644 index 0000000..dcab229 --- /dev/null +++ b/ubl-settings-repomanager-add.glade @@ -0,0 +1,620 @@ + + + + + + + + True + False + com.ublinux.libublsettingsui-gtk3.trash-symbolic + + + True + False + com.ublinux.libublsettingsui-gtk3.increase-symbolic + + + 800 + 600 + False + True + com.ublinux.ubl-settings-repomanager + + + True + False + vertical + + + True + False + vertical + + + + + + False + True + 0 + + + + + True + False + 5 + 5 + 5 + 5 + vertical + 5 + + + True + False + 5 + + + True + False + Storage: + + + False + True + 0 + + + + + True + False + + + True + True + 1 + + + + + True + False + Repository + + + False + True + 2 + + + + + True + False + + + True + True + 3 + + + + + True + False + Architecture: + + + False + True + 4 + + + + + True + False + + + True + True + 5 + + + + + False + True + 0 + + + + + False + 0.019999999552965164 + in + + + True + False + 5 + 5 + 5 + + + True + False + 5 + + + True + False + Storage: + + + False + True + 0 + + + + + True + False + + + True + True + 1 + + + + + True + False + Repository + + + False + True + 2 + + + + + True + False + + + True + True + 3 + + + + + True + False + Architecture: + + + False + True + 4 + + + + + True + False + + + True + True + 5 + + + + + + + + + True + False + Source + + + + + False + True + 1 + + + + + False + 0.019999999552965164 + in + + + True + False + 5 + 5 + 5 + + + True + False + 5 + + + True + False + Storage: + + + False + True + 0 + + + + + True + False + + + True + True + 1 + + + + + True + False + Repository + + + False + True + 2 + + + + + True + False + + + True + True + 3 + + + + + True + False + Architecture: + + + False + True + 4 + + + + + True + False + + + True + True + 5 + + + + + + + + + True + False + Target + + + + + False + True + 2 + + + + + True + False + 5 + + + True + False + Packages sign: + 0 + + + False + True + 0 + + + + + True + False + + + True + True + 1 + + + + + False + True + 3 + + + + + True + False + 5 + + + True + False + Repository sign: + 0 + + + False + True + 0 + + + + + True + False + + + True + True + 1 + + + + + False + True + 4 + + + + + True + False + 5 + + + True + False + 8 + vertical + 5 + + + True + True + True + image2 + + + + False + True + 0 + + + + + True + True + True + image1 + + + + False + True + 1 + + + + + False + True + 0 + + + + + True + False + 0.019999999552965164 + in + + + True + False + 5 + 5 + 5 + + + True + False + 5 + + + True + True + in + + + True + True + PackagesList + + + + + + + + True + True + 0 + + + + + True + True + in + + + True + False + + + True + False + True + 0 + 0 + + + + + + + True + True + 1 + + + + + + + + + True + False + Package (-s) to add + + + + + True + True + 1 + + + + + True + True + 5 + + + + + True + True + 1 + + + + + + + True + False + + + True + False + Repository manager + + + + + + + + True + False + 32 + com.ublinux.ubl-settings-repomanager + + + + + Cancel + True + True + True + + + 1 + + + + + Add + True + True + True + + + end + 2 + + + + + + + + + + + + diff --git a/ubl-settings-repomanager-configuration.glade b/ubl-settings-repomanager-configuration.glade new file mode 100644 index 0000000..a970bdd --- /dev/null +++ b/ubl-settings-repomanager-configuration.glade @@ -0,0 +1,337 @@ + + + + + + + True + False + com.ublinux.libublsettingsui-gtk3.zoom-symbolic + + + True + False + com.ublinux.libublsettingsui-gtk3.increase-symbolic + + + True + False + com.ublinux.libublsettingsui-gtk3.cancel-uncolored-symbolic + + + True + False + com.ublinux.libublsettingsui-gtk3.trash-symbolic + + + True + False + com.ublinux.libublsettingsui-gtk3.increase-symbolic + + + 450 + 200 + False + True + com.ublinux.ubl-settings-repomanager + + + True + False + vertical + + + True + False + vertical + + + + + + False + True + 0 + + + + + True + False + 5 + 5 + 5 + 5 + vertical + + + True + False + 5 + + + True + False + Storage: + 0 + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + + + + True + True + True + image1 + + + + False + True + 2 + + + + + True + True + True + image2 + + + + False + True + 3 + + + + + True + True + True + image3 + + + + False + True + 4 + + + + + True + True + True + image4 + + + + False + True + 5 + + + + + False + True + 0 + + + + + True + False + 0.019999999552965164 + in + + + True + False + 5 + 5 + 5 + + + True + False + vertical + 5 + + + True + True + + + True + False + none + + + True + False + vertical + 5 + + + + + + + + + + + + + + + + + + + True + True + 0 + + + + + True + False + 5 + + + True + True + + + True + True + 0 + + + + + True + True + True + image5 + + + + False + True + 1 + + + + + False + True + 1 + + + + + + + + + True + False + Repository (-ies) + + + + + True + True + 1 + + + + + True + True + 1 + + + + + + + True + False + + + True + False + Repository manager + + + + + + + + True + False + 32 + com.ublinux.ubl-settings-repomanager + + + + + Cancel + True + True + True + + + 1 + + + + + Accept + True + True + True + + + end + 2 + + + + + + diff --git a/ubl-settings-repomanager-filechooser.glade b/ubl-settings-repomanager-filechooser.glade new file mode 100644 index 0000000..375dece --- /dev/null +++ b/ubl-settings-repomanager-filechooser.glade @@ -0,0 +1,90 @@ + + + + + + True + False + com.ublinux.libublsettingsui-gtk3.accept-symbolic + + + True + False + com.ublinux.libublsettingsui-gtk3.cancel-uncolored-symbolic + + + False + dialog + + + False + vertical + 2 + + + False + end + + + Cancel + True + True + True + image2 + + + True + True + 0 + + + + + Choose + True + True + True + image1 + + + True + True + 1 + + + + + False + False + 0 + + + + + + + True + False + True + + + True + False + Repository manager + + + + + + + + True + False + 32 + com.ublinux.ubl-settings-repomanager + + + + + + diff --git a/ubl-settings-repomanager-move.glade b/ubl-settings-repomanager-move.glade new file mode 100644 index 0000000..f145770 --- /dev/null +++ b/ubl-settings-repomanager-move.glade @@ -0,0 +1,498 @@ + + + + + + + True + False + com.ublinux.libublsettingsui-gtk3.trash-symbolic + + + True + False + com.ublinux.libublsettingsui-gtk3.add-symbolic + + + 800 + 600 + False + True + com.ublinux.ubl-settings-repomanager + + + True + False + vertical + + + True + False + vertical + + + + + + False + True + 0 + + + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + vertical + 5 + + + True + False + 0 + in + + + True + False + 5 + 5 + 5 + + + True + False + 5 + + + True + False + Storage: + + + False + True + 0 + + + + + True + False + + + True + True + 1 + + + + + True + False + Repository + + + False + True + 2 + + + + + True + False + + + True + True + 3 + + + + + True + False + Architecture: + + + False + True + 4 + + + + + True + False + + + True + True + 5 + + + + + + + + + True + False + Source + + + + + False + True + 0 + + + + + True + False + 0 + in + + + True + False + 5 + 5 + 5 + + + True + False + 5 + + + True + False + Storage: + + + False + True + 0 + + + + + True + False + + + True + True + 1 + + + + + True + False + Repository + + + False + True + 2 + + + + + True + False + + + True + True + 3 + + + + + True + False + Architecture: + + + False + True + 4 + + + + + True + False + + + True + True + 5 + + + + + + + + + True + False + Target + + + + + False + True + 1 + + + + + True + False + 5 + + + True + False + Repository sign: + + + False + True + 0 + + + + + True + False + + + True + True + 1 + + + + + False + True + 2 + + + + + True + False + 5 + + + True + False + 8 + vertical + 5 + + + True + True + True + image2 + + + + False + True + 0 + + + + + True + True + True + image1 + + + + False + True + 1 + + + + + False + True + 0 + + + + + True + False + 0.019999999552965164 + in + + + True + False + 5 + 5 + 5 + + + True + False + 5 + + + True + True + in + + + True + True + + + + + + + + True + True + 0 + + + + + True + True + in + + + True + False + + + True + False + True + 0 + 0 + + + + + + + True + True + 1 + + + + + + + + + True + False + Package (-s) to add + + + + + True + True + 1 + + + + + True + True + 3 + + + + + True + True + 1 + + + + + + + True + False + + + True + False + Repository manager + + + + + + + + True + False + 32 + com.ublinux.ubl-settings-repomanager + + + + + Cancel + True + True + True + + + 1 + + + + + Add + True + True + True + + + end + 2 + + + + + + diff --git a/ubl-settings-repomanager-sign.glade b/ubl-settings-repomanager-progressbar-window.glade similarity index 56% rename from ubl-settings-repomanager-sign.glade rename to ubl-settings-repomanager-progressbar-window.glade index 491c267..13218ba 100644 --- a/ubl-settings-repomanager-sign.glade +++ b/ubl-settings-repomanager-progressbar-window.glade @@ -2,18 +2,9 @@ - - True - False - process-stop-symbolic - - - True - False - emblem-ok-symbolic - - + 450 + 200 False True com.ublinux.ubl-settings-repomanager @@ -36,69 +27,86 @@ vertical 5 - + True False + 15 + + + True + False + dialog-information-symbolic + 6 + + + False + True + 0 + + + + + True + False + Please, wait. List of repository packages is currently updating. It can take a while + True + 0 + + + False + True + 1 + + - False + True True 0 - - - True - True - 0 - - - - - True - False - end - 5 - True - - Cancel + True - True - True - image16 - + False + vertical + 15 + + + True + False + + + False + True + 0 + + - True + False True - 0 + 1 - - Save + True - True - True - image17 - + False + 0% + 0 True True - 1 + 2 - False + True True - 1 + 0 @@ -107,9 +115,8 @@ True False - True - + True False Repository manager diff --git a/ubl-settings-repomanager-windows.glade b/ubl-settings-repomanager-windows.glade deleted file mode 100644 index 98d4bbd..0000000 --- a/ubl-settings-repomanager-windows.glade +++ /dev/null @@ -1,549 +0,0 @@ - - - - - - - - - - - - - - - master - True - - - - - True - False - process-stop-symbolic - - - True - False - emblem-ok-symbolic - - - 450 - 150 - False - True - com.ublinux.ubl-settings-repomanager - - - True - False - 5 - 5 - 5 - 5 - 5 - 5 - vertical - 10 - - - True - False - vertical - 5 - - - True - False - 5 - - - True - False - Name: - 0 - - - False - True - 0 - - - - - True - True - - - True - True - 1 - - - - - False - True - 0 - - - - - True - False - vertical - 4 - - - Choose repository folder - True - True - True - start - - - False - True - 0 - - - - - True - False - True - 0 - - - False - True - 1 - - - - - False - True - 1 - - - - - True - False - 5 - - - False - Branches: - 0 - - - False - True - 0 - - - - - False - True - 2 - - - - - True - False - 5 - - - True - True - never - in - - - True - False - - - True - curRepoEditList - False - True - 0 - False - - - - - - column - - - True - < Type branch name > - - - 0 - - - - - - - - - - - - - - True - True - 0 - - - - - True - True - 3 - - - - - True - True - 0 - - - - - True - False - end - 5 - True - - - Cancel - True - True - True - image14 - - - - True - True - 0 - - - - - Save - True - True - True - image15 - - - - True - True - 1 - - - - - False - True - 1 - - - - - - - True - False - True - - - True - False - Repository manager - - - - - - - - True - False - 32 - com.ublinux.ubl-settings-repomanager - - - - - - - True - False - process-stop-symbolic - - - True - False - emblem-ok-symbolic - - - 450 - 150 - False - True - com.ublinux.ubl-settings-repomanager - - - True - False - 5 - 5 - 5 - 5 - 5 - 5 - vertical - 10 - - - True - False - vertical - 5 - - - True - False - 5 - - - True - False - Name: - 0 - - - False - True - 0 - - - - - True - True - - - True - True - 1 - - - - - False - True - 0 - - - - - True - False - 5 - - - False - Branches: - 0 - - - False - True - 0 - - - - - False - True - 1 - - - - - True - False - 5 - - - True - True - never - in - - - True - False - - - True - curRepoEditList - False - 0 - False - - - none - - - - - column - - - - 0 - - - - - - - - - - - - - - True - True - 0 - - - - - True - True - 3 - - - - - True - True - 0 - - - - - True - False - end - 5 - True - - - Cancel - True - True - True - image16 - - - - True - True - 0 - - - - - Save - True - True - True - image17 - - - - True - True - 1 - - - - - False - True - 1 - - - - - - - True - False - True - - - True - False - Repository manager - - - - - - - - True - False - 32 - com.ublinux.ubl-settings-repomanager - - - - - - diff --git a/ubl-settings-repomanager.css b/ubl-settings-repomanager.css index 2a55ea0..1ca94fe 100644 --- a/ubl-settings-repomanager.css +++ b/ubl-settings-repomanager.css @@ -1,4 +1,3 @@ - .thin { margin:0px; padding:0px; @@ -38,7 +37,7 @@ background:transparent; border-left-width:inherit; border-right-width:inherit; } - + .menuitemtop{ margin-bottom:0px; border-color:inherit; @@ -46,25 +45,19 @@ background:transparent; border-left-width:inherit; border-right-width:inherit; } - .menuitemtop *{ - margin:2px 2px 0 2px; - padding-top:2px; - padding-bottom:2px; - /* padding: 5px 0px 3px 5px; */ + .menuitemtop >*{ + margin:4px 2px 0 2px; + padding: 3px 10px 3px 5px; border:transparent; } - .menuitemmiddle *{ + .menuitemmiddle >*{ margin:0 2px 0 2px; - padding-top:2px; - padding-bottom:2px; - /* padding: 3px 0px 3px 5px; */ + padding: 3px 10px 3px 5px; border:transparent; } - .menuitembottom *{ + .menuitembottom >*{ margin:0 2px 2px 2px; - padding-top:2px; - padding-bottom:2px; - /* padding: 3px 0px 5px 5px; */ + padding: 3px 10px 3px 5px; } .menuitemtop:hover { background:@theme_bg_color; @@ -87,27 +80,21 @@ background:transparent; border-right-width:inherit; } - .menuitemtop:hover* { - margin:2px 2px 0 2px; - padding-top:2px; - padding-bottom:2px; - /* padding: 5px 0 3px 5px; */ + .menuitemtop:hover>* { + margin:4px 2px 0 2px; + padding: 3px 10px 3px 5px; background:@theme_selected_bg_color; border-radius:2px; } - .menuitemmiddle:hover* { - margin:0 2px 0px 2px; - padding-top:2px; - padding-bottom:2px; - /* padding: 3px 0px 3px 5px; */ + .menuitemmiddle:hover>* { + margin:0 2px 0 2px; + padding: 3px 10px 3px 5px; background:@theme_selected_bg_color; border-radius:2px; } - .menuitembottom:hover* { + .menuitembottom:hover>* { margin:0 2px 2px 2px; - padding-top:2px; - padding-bottom:2px; - /* padding: 3px 0px 5px 5px; */ + padding: 3px 10px 3px 5px; background:@theme_selected_bg_color; border-radius:2px; } @@ -118,24 +105,35 @@ background:transparent; .boxInfoMessOK{ background-color: #f3f0ac; } -.invisprogress { - background-color:transparent; - color:transparent; - +.errorBox { + border-width: 2px; + border-color: #ea9999; + border-style:solid; } -.invisprogress.osd { - background:transparent; - color:transparent; + +.chosenOutline{ + transition: 0ms; + border-width: 1px; + border-color: #f3f0ac; + border-style:solid; } -.invisprogress.trough * { - background:transparent; - color:transparent; + +.separatorTop{ + border-color: darker (@theme_bg_color); + border-top-width:1px; + border-style:solid; } -.invisprogress.trough.empty { - background:transparent; - color:transparent; + +.separatorBottom{ + border-color: darker (@theme_bg_color); + border-bottom-width:1px; + border-style:solid; } .marginright image{ margin-right: 2px; -} \ No newline at end of file +} + +treeview row:nth-child(odd) { background-color: #000000; } + +treeview row:nth-child(even) { background-color: #ffffff; } \ No newline at end of file diff --git a/ubl-settings-repomanager.glade b/ubl-settings-repomanager.glade index 39b7c4e..42a9d95 100644 --- a/ubl-settings-repomanager.glade +++ b/ubl-settings-repomanager.glade @@ -1,319 +1,59 @@ - + - - - - - False - False - True - center - com.ublinux.ubl-settings-repomanager - dialog - True - ubl-settings-repomanager - 1.1 - Copyright © 2022 - 2023, UBSoft LLC - Repository manager - https://wiki.ublinux.ru/ru/Программное_обеспечение/Программы_и_утилиты/Все/ubl-settings-repomanager - Project Home Page - Это приложение распространяется без каких-либо гарантий. -Подробнее в <a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.html">GNU General Public License, версии 2 или позднее</a>. - UBGroup - UBGroup - com.ublinux.ubl-settings-repomanager - True - gpl-2-0 - - - True - False - vertical - 2 - - - False - end - - - False - False - 1 - - - - - - - True - False - True - - - True - False - 5 - 5 - 5 - 5 - 2 - Repository manager - - - - - - - - - + True False - - - 90 - True - False - 5 - 5 - 5 - 5 - 6 - 6 - 69 - com.ublinux.ubl-settings-repomanager - - - False - True - 0 - - - - - True - False - - - True - False - - - True - False - vertical - - - 255 - True - False - end - Repository manager - 0 - - - - - - - - True - True - 0 - - - - - 255 - True - False - start - Repository management and configuring - 0 - - - - - - - - True - True - 1 - - - - - False - True - 0 - - - - - True - True - 0 - - - - - True - True - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 65536 - 1 - 10 + True + + + True False - document-new-symbolic - - - True - False - value-increase-symbolic - - - True - False - value-decrease-symbolic - - - True - False - edit-copy-symbolic + com.ublinux.libublsettingsui-gtk3.sync-symbolic True False - document-open-symbolic + com.ublinux.libublsettingsui-gtk3.database-symbolic True False - system-run-symbolic + com.ublinux.libublsettingsui-gtk3.increase-symbolic True False - user-trash-symbolic + com.ublinux.libublsettingsui-gtk3.arrows-left-right-symbolic True False - com.ublinux.ubl-settings-repomanager.document-sign-symbolic + com.ublinux.libublsettingsui-gtk3.trash-symbolic - + True False - com.ublinux.libublsettingsui-gtk3.cancel-symbolic + com.ublinux.libublsettingsui-gtk3.cloud-arrow-up-symbolic - + True False - com.ublinux.libublsettingsui-gtk3.accept-symbolic - - - False - False - 450 - com.ublinux.ubl-settings-repomanager + vertical - + True False - 5 - 5 - 5 - 5 - vertical - 10 True False - - - True - False - start - 20 - 20 - dialog-question-symbolic - 6 - - - False - True - 0 - - + 5 True @@ -322,18 +62,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. vertical 5 - + True - False - start - Would you like to read documentation in the Web? - True - 0 - - - + True + True + image1 @@ -343,16 +78,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - + True - False - start - start - You will be redirected to documentation website where documentation is -translated and supported by community. - 0 + True + True + image2 @@ -362,1095 +94,119 @@ translated and supported by community. - - Always redirect to online documentation + True True - False - end - True + True + image3 False True - end 2 - - - - True - True - 1 - - - - - - True - True - 0 - - - - - - - True - False - - - True - False - Repository manager - - - - - - - - Cancel - True - True - True - image8 - - - - - - Open documentation - True - True - True - image9 - - - - end - 1 - - - - - - - True - False - False - - - True - False - Load from global configuration - - - - - - True - False - Load from local configuration - - - - - - True - False - False - False - - - True - False - False - - - True - False - Save to global and local documentation - - - - - - True - False - Save to global configuration - - - - - - True - False - Save to local configuration - - - - - - 800 - 600 - False - 800 - 600 - com.ublinux.ubl-settings-repomanager - - - True - False - vertical - - - True - False - vertical - - - True - False - + True - False - 5 - 5 - 5 - 5 - 5 - 5 - 25 + True + True + image4 + False True - 0 + 3 - + True - False - start - 5 - 5 - 5 - 5 - 6 - 6 - - - - + True + True + image5 + False True - 1 + 4 - - - False - True - 0 - - - - - True - False - vertical - - 81 + True - False - - - True - False - start - - - -1 - - + True + True + image6 + False True - 0 + 5 False True - 1 + 0 True False - 5 - 5 - 5 - 5 - 5 - 5 - True - True - vertical + 5 True False + 10 5 - + True - False - vertical - 5 + True + in - - True - False - vertical - - - True - True - 40 - edit-find-symbolic - False - False - name - - - False - True - 0 - - - - - False - True - 0 - - - - + True True - 395 - True + RepoList + False + treeviewcolumn1 - - True - False - 5 - 5 - 5 + + column - - True - False - vertical - 5 - - - True - False - - - False - True - 0 - - - - - True - True - True - Open or create repository - image1 - - - - False - True - 1 - - - - - True - True - Open existing repository - image2 - - - - False - True - 2 - - - - - True - True - Configure repository - image3 - - - - False - True - 3 - - - - - True - False - True - True - Delete repository - image4 - - - - False - True - 4 - - - - - True - False - - - False - True - 5 - - - - - True - False - True - True - Sign - image5 - - - - False - True - 6 - - - - - True - False - - - False - True - 7 - - - - - True - False - True - True - Add package - image11 - - - - False - True - 11 - - - - - True - False - True - True - Remove package - image12 - - - - False - True - 12 - - - - - False - True - 0 - - - - - True - False - 0 - in - - - True - False - 5 - 5 - 5 - 5 - - - True - True - - - True - False - none - - - True - True - RepoStore - False - treeviewcolumn2 - 0 - - - - - - column - - - - - column - - - - 0 - - - - - [D] - - - 5 - - - - - - 1 - - - - - - - - - - - - - - - - - - - True - True - 1 - - - - - False - True - - - - - True - True - 5 - 5 - False - - - True - False - 5 - 5 - 5 - 5 - 5 - 5 - vertical - 5 - - - False - 5 - - - True - False - start - Code name: - 0 - - - - - - False - True - 0 - - - - - True - False - True - 0 - - - False - True - 1 - - - - - False - True - 0 - - - - - False - 5 - - - True - False - start - Branch: - 0 - - - - - - False - True - 0 - - - - - True - False - True - 0 - - - False - True - 1 - - - - - False - True - 1 - - - - - False - 5 - - - True - False - start - Version: - 0 - - - - - - False - True - 0 - - - - - True - False - True - 0 - - - False - True - 1 - - - - - False - True - 2 - - - - - False - 5 - - - True - False - start - Architecture: - 0 - - - - - - False - True - 0 - - - - - True - False - True - 0 - - - False - True - 1 - - - - - False - True - 3 - - - - - False - 5 - - - True - False - start - Dependences: - 0 - - - - - - False - True - 0 - - - - - True - False - True - 0 - - - False - True - 1 - - - - - False - True - 4 - - - - - False - 5 - - - True - False - start - Signature: - 0 - - - - - - False - True - 0 - - - - - True - False - True - 0 - - - False - True - 1 - - - - - False - True - 5 - - - - - - - True - False - General + + 4 - - False - + + 1 + - - True - False - 5 - 5 - 5 - 5 - 5 - 5 - vertical - 5 - - - Trusted repository - True - True - False - start - True - - - False - True - 0 - - - - - True - False - 5 - - - True - False - Server type: - 0 - - - False - True - 0 - - - - - True - False - 0 - - HTML - local - - - - False - True - 1 - - - - - False - True - 1 - - - - - True - False - 5 - - - True - False - IP adress: - 0 - - - False - True - 0 - - - - - True - False - 0 - True - - 192.168.1.110 - - - - False - - - - - False - True - 1 - - - - - False - True - 2 - - - - - True - False - 5 - - - True - False - Port: - 0 - - - False - True - 0 - - - - - True - True - 0 - adjustment1 - - - False - True - 1 - - - - - False - True - 3 - - - - - True - False - 5 - - - True - False - True - - - True - True - 0 - - - - - True - True - True - image13 - - - - False - True - 1 - - - - - False - True - 4 - - - - - Publish - True - True - True - start - - - False - True - 5 - - - - - 1 - - - - - True - False - Publication - - - 1 - False - + + + 0 + - - True - True - - - True - True - 1 - @@ -1466,75 +222,20 @@ translated and supported by community. 0 - - - False - True - 2 - - - - - True - True - 0 - - - - - - - True - False - True - - - True - False - 5 - 5 - 5 - 5 - 2 - Repository manager - - - - - - - - True - False - 5 - 5 - 5 - 5 - 6 - 6 - 32 - com.ublinux.ubl-settings-repomanager - - - - - True - False - - - True - False - True - menu3 True False + 10 + vertical + 5 - + True - False - Save + True + edit-find-symbolic + False + False False @@ -1543,135 +244,154 @@ translated and supported by community. - + True - False - pan-down-symbolic + True + in + + + True + True + RepoFileList + False + 0 + + + column + + + + 1 + + + + + + 0 + + + + + + - False + True True 1 + + + 125 + True + True + in + + + True + True + RepoPackagesTre + False + + + column + + + + 1 + + + + + + 0 + + + + + + + + + False + True + 2 + + + + True + True + 1 + - - - False - True - 0 - - - - - True - True - True - False - True - True - menu2 - none - - - - - - False - True - end - 1 - - - - - Save - True - True - True - - - False - True - 2 - - - - - end - 1 - - - - - False - - - True - True - False - True - menu1 - - + True False + 0.019999999552965164 + in - + True False - Load + 5 + 5 + 5 + + + True + False + vertical + + + True + False + 0 + + + False + True + 0 + + + + - - False - True - 0 - - - + + True False - pan-down-symbolic + Information - - False - True - 1 - + + True + True + 2 + - False + True True - 0 + 1 - 2 + -1 - + + True + True + 0 + - - - - - - - - - -