From 7c72a0186df98422648dd99531409989b3195318 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Thu, 10 Oct 2024 10:45:00 +0600 Subject: [PATCH 1/8] Update 1.0 WIP --- source/CMakeLists.txt | 41 +- source/ubl-cmake.in | 1 - source/ubl-settings-update.c | 713 ++++++++++++----------- source/ubl-settings-update.h | 263 ++++++--- source/ubl-strings.h | 56 +- source/ubl-utils.c | 1060 ---------------------------------- source/ubl-utils.h | 297 ---------- 7 files changed, 568 insertions(+), 1863 deletions(-) delete mode 100644 source/ubl-cmake.in delete mode 100644 source/ubl-utils.c delete mode 100644 source/ubl-utils.h diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index b72b52e..537cbbf 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) @@ -19,18 +24,18 @@ if(WEBKIT_LIBRARIES_FOUND) add_definitions(${WEBKIT_CFLAGS_OTHER}) endif() -configure_file(ubl-cmake.in ubl-cmake.h) - -file(COPY ${CMAKE_CURRENT_BINARY_DIR}/ubl-cmake.h DESTINATION ./) - set(GRESOURCE_C resources.c) set(GRESOURCE_XML gresource.xml) find_program(GLIB_COMPILE_RESOURCES NAMES glib-compile-resources REQUIRED) -add_custom_target(GLADE ubl-settings-update.glade) +add_custom_target(GLADE ubinstall-gtk.glade) set(DEPENDFILES ../ubl-settings-update.glade + ../ubl-settings-update-repo-add.glade + ../ubl-settings-update-web-publication-add.glade + ../ubl-settings-update-mirror-add.glade + ../ubl-settings-update-mirror-configure.glade ../gresource.xml ../ubl-settings-update-banner.png ../ubl-settings-update.css @@ -56,27 +61,35 @@ add_custom_target( DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${GRESOURCE_C} ) -#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always -std=c++2a") -#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always -lm") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always \ +add_definitions(-DVTE_INCLUDE) + +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always \ -O2 -pipe -fno-plt -fexceptions \ - -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security \ + -Wformat -Werror=format-security \ -fstack-clash-protection -fcf-protection") - + +string(FIND "${CMAKE_CXX_FLAGS}" "-D_FORTIFY_SOURCE" FORTIFY_FOUND) + +if(FORTIFY_FOUND EQUAL -1) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wp,-D_FORTIFY_SOURCE=2") +endif() set(SOURCE_FILES ubl-settings-update.c ubl-settings-update.h ubl-strings.h - ubl-utils.h - ubl-utils.c - ${CMAKE_CURRENT_BINARY_DIR}/ubl-cmake.h ) set(LIBRARIES ${GTK_LIBRARIES} ${WEBKIT_LIBRARIES} - pthread) + ${UTILS_LIBRARIES} + ${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-cmake.in b/source/ubl-cmake.in deleted file mode 100644 index d4623a7..0000000 --- a/source/ubl-cmake.in +++ /dev/null @@ -1 +0,0 @@ -#cmakedefine WEBKIT_FOUND diff --git a/source/ubl-settings-update.c b/source/ubl-settings-update.c index f1edb13..d6b8801 100644 --- a/source/ubl-settings-update.c +++ b/source/ubl-settings-update.c @@ -1,406 +1,417 @@ #include "ubl-settings-update.h" config main_config; -render_data render; -void on_close_subwindow(GtkWidget *self){ - gtk_widget_destroy(gtk_widget_get_toplevel(self)); +//functions + +void yon_load_proceed(YON_CONFIG_TYPE type){ + yon_config_clean(); + if (!yon_char_is_empty(config_get_default_command)) + yon_config_load_config(YON_CONFIG_DEFAULT,config_get_default_command,NULL); + if (type==YON_CONFIG_GLOBAL){ + yon_config_load_config(type,config_get_global_command,NULL); + } else if (type==YON_CONFIG_LOCAL){ + yon_config_load_config(type,config_get_local_command,NULL); + } else if (type==YON_CONFIG_CUSTOM){ + char *path=""; + textdomain(template_ui_LocaleName); + GtkWidget *dialog = gtk_file_chooser_dialog_new(template_app_information.app_title,NULL,GTK_FILE_CHOOSER_ACTION_SAVE,CANCEL_LABEL,GTK_RESPONSE_CANCEL,OPEN_LABEL,GTK_RESPONSE_ACCEPT,NULL); + textdomain(LocaleName); + gtk_window_set_icon_name(GTK_WINDOW(dialog),"com.ublinux.ubl-settings-services"); + gtk_window_set_title(GTK_WINDOW(dialog),TITLE_LABEL); + GtkFileFilter *filter = gtk_file_filter_new(); + gtk_file_filter_add_pattern(filter,"*.ini"); + gtk_file_filter_set_name(filter, "*.ini"); + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog),filter); + gtk_widget_show(dialog); + int response = gtk_dialog_run(GTK_DIALOG(dialog)); + if (response == GTK_RESPONSE_ACCEPT){ + char *file = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); + if (!yon_char_is_empty(file)){ + path=file; + } + gtk_widget_destroy(dialog); + } else { + gtk_widget_destroy(dialog); + } + char *command = yon_config_get_custom_command(path); + yon_config_load_config(type,command,NULL); + } } -void yon_open_browser(GtkWidget *self, char *link){ - yon_ubl_browser_window_open(link,TITLE_LABEL); +// standard functions + +/**config_init() + * [EN] + * + * [RU] + * Функция инициализации всех параметров конфигурации +*/ +void config_init(){ + main_config.always_open_documentation=0; + main_config.socket_id=-1; + main_config.save_socket_id=-1; + main_config.load_socket_id=-1; + main_config.lock_help=0; + main_config.lock_help=0; + main_config.lock_load_global=0; + main_config.lock_save_global=0; + main_config.lock_save_local=0; + main_config.load_mode=1; } -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); +void on_selection_changed(GtkWidget *self, main_window *widgets){ + GtkTreeModel *model; + GtkTreeIter iter; + if (self == widgets->RepositoriesTree){ + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->RepositoriesTree)),&model,&iter)){ + gtk_widget_set_sensitive(widgets->RepositoriesMoveUpButton,1); + gtk_widget_set_sensitive(widgets->RepositoriesMoveDownButton,1); + gtk_widget_set_sensitive(widgets->RepositoriesEditButton,1); + gtk_widget_set_sensitive(widgets->RepositoriesDeleteButton,1); + } else { + gtk_widget_set_sensitive(widgets->RepositoriesMoveUpButton,0); + gtk_widget_set_sensitive(widgets->RepositoriesMoveDownButton,0); + gtk_widget_set_sensitive(widgets->RepositoriesEditButton,0); + gtk_widget_set_sensitive(widgets->RepositoriesDeleteButton,0); + } + } else if (self == widgets->WebPublicationTree){ + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->WebPublicationTree)),&model,&iter)){ + gtk_widget_set_sensitive(widgets->WebPublicationEditButton,1); + gtk_widget_set_sensitive(widgets->WebPublicationRemoveButton,1); + } else { + gtk_widget_set_sensitive(widgets->WebPublicationEditButton,0); + gtk_widget_set_sensitive(widgets->WebPublicationRemoveButton,0); + } + } else if (self == widgets->MirrorTree){ + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->MirrorTree)),&model,&iter)){ + gtk_widget_set_sensitive(widgets->MirrorConfigureButton,1); + gtk_widget_set_sensitive(widgets->MirrorEditButton,1); + gtk_widget_set_sensitive(widgets->MirrorRemoveButton,1); + } else { + gtk_widget_set_sensitive(widgets->MirrorConfigureButton,0); + gtk_widget_set_sensitive(widgets->MirrorEditButton,0); + gtk_widget_set_sensitive(widgets->MirrorRemoveButton,0); + } } } -void on_link(GtkWidget *self, char* uri, gpointer user_data){ - gtk_widget_destroy(self); - on_open_documentation_confirmation(self,uri); -} +void on_repo_add(GtkWidget *, main_window *widgets){ + repo_add_window *window = yon_repo_add_window_new(); + yon_gtk_window_setup(GTK_WINDOW(window->Window),GTK_WINDOW(widgets->Window),ADD_REPO_LABEL,icon_path,"add_repo_window"); -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); -} + dictionary *dict = NULL; + yon_dictionary_add_or_create_if_exists_with_data(dict,"widgets",widgets); + yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window); + g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_repo_accept_clicked),dict); -void on_repos_add(GtkWidget *self, repo_window *repo){ - char *distr = yon_char_new((char*)gtk_entry_get_text(GTK_ENTRY(repo->repoDistributionEntry))); - char *address = yon_char_new((char*)gtk_entry_get_text(GTK_ENTRY(repo->repoTypeEntry))); - if ((distr&&address)||(strcmp(distr,"")!=0&&strcmp(address,"")!=0)){ - GtkTreeIter iter; - gtk_list_store_append(main_config.list,&iter); - gtk_list_store_set(main_config.list,&iter,1,address,2,distr,-1); - } } -void on_repos_delete(GtkWidget *self, GtkWidget *tree){ - GtkTreeIter iter; - GtkTreeModel *model = GTK_TREE_MODEL(main_config.list); - if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(tree)),&model,&iter)){ - gtk_list_store_remove(main_config.list,&iter); - } else { - yon_ubl_status_box_render(render,NOTHING_CHOSEN_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); - } -} +void on_web_publish_add(GtkWidget *,main_window *widgets){ + web_publication_add_window *window = yon_web_publication_add_window_new(); + yon_gtk_window_setup(GTK_WINDOW(window->Window),GTK_WINDOW(widgets->Window),ADD_REPO_LABEL,icon_path,"web_publish_window"); -void on_repos_edit(GtkWidget *self, repo_window *widgets){ - GtkTreeIter iter; - GtkTreeModel *model=GTK_TREE_MODEL(main_config.list); - if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->tree)),&model,&iter)){ - char *adress=yon_char_new((char*)gtk_entry_get_text(GTK_ENTRY(widgets->repoTypeEntry))); - char *distro=yon_char_new((char*)gtk_entry_get_text(GTK_ENTRY(widgets->repoDistributionEntry))); - if ((distro&&adress)||(strcmp(distro,"")!=0&&strcmp(adress,"")!=0)) - gtk_list_store_set(main_config.list,&iter,1,adress,2,distro,-1); - } + dictionary *dict = NULL; + yon_dictionary_add_or_create_if_exists_with_data(dict,"widgets",widgets); + yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window); + g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_web_publish_accept),dict); } -void on_repo_window_open_edit(GtkWidget *self, GtkWidget *tree){ - GtkTreeIter iter; - GtkTreeModel *model=GTK_TREE_MODEL(main_config.list); - if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(tree)),&model,&iter)){ - repo_window *widgets=NULL; - widgets=malloc(sizeof(repo_window)); - widgets->builder= gtk_builder_new_from_resource(glade_path); - widgets->window=yon_gtk_builder_get_widget(widgets->builder, "RepoWindow"); - - widgets->repoTypeLabel=yon_gtk_builder_get_widget(widgets->builder, "repoAdressLabel"); - widgets->repoTypeEntry=yon_gtk_builder_get_widget(widgets->builder, "repoAdressEntry"); - widgets->repoDistributionLabel=yon_gtk_builder_get_widget(widgets->builder, "repoDistributionLabel"); - widgets->repoDistributionEntry=yon_gtk_builder_get_widget(widgets->builder, "repoDistributionEntry"); - - widgets->repoCancelButton=yon_gtk_builder_get_widget(widgets->builder, "repoCancelButton"); - widgets->repoAcceptButton=yon_gtk_builder_get_widget(widgets->builder, "repoAcceptButton"); - widgets->tree=tree; - - g_signal_connect(G_OBJECT(widgets->repoCancelButton), "clicked", G_CALLBACK(on_close_subwindow), NULL); - g_signal_connect(G_OBJECT(widgets->repoAcceptButton), "clicked", G_CALLBACK(on_repos_edit), widgets); - g_signal_connect(G_OBJECT(widgets->repoAcceptButton), "clicked", G_CALLBACK(on_close_subwindow), NULL); - char *adress = NULL; - char *distro = NULL; - gtk_tree_model_get(GTK_TREE_MODEL(main_config.list),&iter,1,&adress,2,&distro,-1); - gtk_entry_set_text(GTK_ENTRY(widgets->repoTypeEntry),adress); - gtk_entry_set_text(GTK_ENTRY(widgets->repoDistributionEntry),distro); - - gtk_window_set_title(GTK_WINDOW(widgets->window),TITLE_LABEL); - - gtk_label_set_text(GTK_LABEL(widgets->repoTypeLabel),ADRESS_LABEL); - gtk_label_set_text(GTK_LABEL(widgets->repoDistributionLabel),DISTRIBUTION_LABEL); - - gtk_button_set_label(GTK_BUTTON(widgets->repoCancelButton),CANCEL_LABEL); - gtk_button_set_label(GTK_BUTTON(widgets->repoAcceptButton),SAVE_LABEL); - gtk_widget_show_all(widgets->window); - } else { - yon_ubl_status_box_render(render,NOTHING_CHOSEN_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); - } - +void on_mirror_add(GtkWidget *,main_window *widgets){ + mirror_add_window *window = yon_mirror_add_window_new(); + yon_gtk_window_setup(GTK_WINDOW(window->Window),GTK_WINDOW(widgets->Window),ADD_REPO_LABEL,icon_path,"mirror_window"); + dictionary *dict = NULL; + yon_dictionary_add_or_create_if_exists_with_data(dict,"widgets",widgets); + yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window); + g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_mirror_accept),dict); + } -repo_window *on_repo_window_open_create(GtkWidget *self){ - repo_window *widgets=NULL; - widgets=malloc(sizeof(repo_window)); - widgets->builder= gtk_builder_new_from_resource(glade_path); - widgets->window=yon_gtk_builder_get_widget(widgets->builder, "RepoWindow"); - - widgets->repoTypeLabel=yon_gtk_builder_get_widget(widgets->builder, "repoAdressLabel"); - widgets->repoTypeEntry=yon_gtk_builder_get_widget(widgets->builder, "repoAdressEntry"); - widgets->repoDistributionLabel=yon_gtk_builder_get_widget(widgets->builder, "repoDistributionLabel"); - widgets->repoDistributionEntry=yon_gtk_builder_get_widget(widgets->builder, "repoDistributionEntry"); - - widgets->repoCancelButton=yon_gtk_builder_get_widget(widgets->builder, "repoCancelButton"); - widgets->repoAcceptButton=yon_gtk_builder_get_widget(widgets->builder, "repoAcceptButton"); +void on_web_publish_remove(GtkWidget *self,main_window *widgets){ + dialog_confirmation_data *data = malloc(sizeof(dialog_confirmation_data)); + data->action_text=REMOVE_REPO_WARNING_LABEL; + data->function=(void(*)(void*,void*))on_remove_accept; + data->data = widgets->WebPublicationTree; + yon_confirmation_dialog_call(self,data); +} - g_signal_connect(G_OBJECT(widgets->repoCancelButton), "clicked", G_CALLBACK(on_close_subwindow), NULL); - g_signal_connect(G_OBJECT(widgets->repoAcceptButton), "clicked", G_CALLBACK(on_repos_add), widgets); - g_signal_connect(G_OBJECT(widgets->repoAcceptButton), "clicked", G_CALLBACK(on_close_subwindow), NULL); +void on_mirror_remove(GtkWidget *self,main_window *widgets){ + dialog_confirmation_data *data = malloc(sizeof(dialog_confirmation_data)); + data->action_text=REMOVE_REPO_WARNING_LABEL; + data->function=(void(*)(void*,void*))on_remove_accept; + data->data = widgets->MirrorTree; + yon_confirmation_dialog_call(self,data); + +} +void on_web_publish_edit(GtkWidget *,main_window *widgets){ + web_publication_add_window *window = yon_web_publication_add_window_new(); + yon_gtk_window_setup(GTK_WINDOW(window->Window),GTK_WINDOW(widgets->Window),ADD_REPO_LABEL,icon_path,"mirror_window"); - gtk_window_set_title(GTK_WINDOW(widgets->window),TITLE_LABEL); + dictionary *dict = NULL; + yon_dictionary_add_or_create_if_exists_with_data(dict,"widgets",widgets); + yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window); + g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_mirror_accept),dict); +} - gtk_label_set_text(GTK_LABEL(widgets->repoTypeLabel),ADRESS_LABEL); - gtk_label_set_text(GTK_LABEL(widgets->repoDistributionLabel),DISTRIBUTION_LABEL); +void on_mirror_edit(GtkWidget *,main_window *widgets){ + mirror_add_window *window = yon_mirror_add_window_new(); + yon_gtk_window_setup(GTK_WINDOW(window->Window),GTK_WINDOW(widgets->Window),ADD_REPO_LABEL,icon_path,"mirror_window"); - gtk_button_set_label(GTK_BUTTON(widgets->repoCancelButton),CANCEL_LABEL); - gtk_button_set_label(GTK_BUTTON(widgets->repoAcceptButton),SAVE_LABEL); - gtk_widget_show_all(widgets->window); + dictionary *dict = NULL; + yon_dictionary_add_or_create_if_exists_with_data(dict,"widgets",widgets); + yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window); + g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_mirror_accept),dict); } -void init(GtkListStore *list){ - main_config.always_open_documentation=0; - main_config.win_height=600; - main_config.win_width=800; - 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; - main_config.lock_help=0; - main_config.lock_help=0; - main_config.lock_load_global=0; - main_config.lock_save_global=0; - main_config.lock_save_local=0; - main_config.list=list; +void on_mirror_configure(GtkWidget *,main_window *widgets){ + mirror_configure_window *window = yon_mirror_configure_window_new(); + yon_gtk_window_setup(GTK_WINDOW(window->Window),GTK_WINDOW(widgets->Window),ADD_REPO_LABEL,icon_path,"mirror_window"); + + dictionary *dict = NULL; + yon_dictionary_add_or_create_if_exists_with_data(dict,"widgets",widgets); + yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window); + g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_mirror_accept),dict); + } -main_window *setup_window(){ - main_window *widgets=NULL; - widgets=malloc(sizeof(main_window)); - widgets->builder=gtk_builder_new_from_resource(glade_path); - widgets->window=yon_gtk_builder_get_widget(widgets->builder,"MainWindow"); - - widgets->HeaderTopic=yon_gtk_builder_get_widget(widgets->builder,"headerTopic"); - - widgets->PlugBox=yon_gtk_builder_get_widget(widgets->builder,"plugBox"); - widgets->RightBox=yon_gtk_builder_get_widget(widgets->builder,"LeftBox"); - widgets->LeftBox=yon_gtk_builder_get_widget(widgets->builder,"RightBox"); - - widgets->generalSettingsTabLabel=yon_gtk_builder_get_widget(widgets->builder,"generalTabLabel"); - widgets->repositoriesSettingsTabLabel=yon_gtk_builder_get_widget(widgets->builder,"repositoriesTabLabel"); - widgets->extraSettingsTabLabel=yon_gtk_builder_get_widget(widgets->builder,"extraTabLabel"); - - widgets->generalSettingsHideNoUpdatesCheck=yon_gtk_builder_get_widget(widgets->builder,"hideIfNoUpdatesCheck"); - widgets->generalSettingsUpdatesCheckFreqLabel=yon_gtk_builder_get_widget(widgets->builder,"UpdateCheckFreqLabel"); - widgets->generalSettingsUpdatesCheckFreqCombo=yon_gtk_builder_get_widget(widgets->builder,"UpdateCheckFreqCombo"); - widgets->generalSettingsDownloadAutoCheck=yon_gtk_builder_get_widget(widgets->builder,"DownloadAutoCheck"); - - widgets->repositoriesSettingsActivateAURCheck=yon_gtk_builder_get_widget(widgets->builder,"AcivateAURCheck"); - widgets->repositoriesSettingsActivateUBURCheck=yon_gtk_builder_get_widget(widgets->builder,"AcivateUBURCheck"); - widgets->repositoriesSettingsMoveUpButton=yon_gtk_builder_get_widget(widgets->builder,"MoveUpButton"); - widgets->repositoriesSettingsMoveDownButton=yon_gtk_builder_get_widget(widgets->builder,"MoveDownButton"); - widgets->repositoriesSettingsCreateButton=yon_gtk_builder_get_widget(widgets->builder,"CreateButton"); - widgets->repositoriesSettingsEditButton=yon_gtk_builder_get_widget(widgets->builder,"EditButton"); - widgets->repositoriesSettingsDeleteButton=yon_gtk_builder_get_widget(widgets->builder,"DeleteButton"); - widgets->repositoriesSettingsRepositoriesTreeView=yon_gtk_builder_get_widget(widgets->builder,"RepositoriesTreeView"); - widgets->repositoriesSettingsEnabledColumn=GTK_TREE_VIEW_COLUMN(gtk_builder_get_object(widgets->builder,"EnabledColumn")); - widgets->repositoriesSettingsURIColumn=GTK_TREE_VIEW_COLUMN(gtk_builder_get_object(widgets->builder,"URIColumn")); - widgets->repositoriesSettingsDistributionColumn=GTK_TREE_VIEW_COLUMN(gtk_builder_get_object(widgets->builder,"DistributionColumn")); - - widgets->extraSettingsPackageManagerLabel=yon_gtk_builder_get_widget(widgets->builder,"PackageManagerLabel"); - widgets->extraSettingsPackageManagerEntry=yon_gtk_builder_get_widget(widgets->builder,"PackageManagerEntry"); - widgets->extraSettingsUpdateCommandLabel=yon_gtk_builder_get_widget(widgets->builder,"UpdateCommandLabel"); - widgets->extraSettingsUpdateCommandEntry=yon_gtk_builder_get_widget(widgets->builder,"UpdateCommandEntry"); - widgets->extraSettingsCacheCleanlabel=yon_gtk_builder_get_widget(widgets->builder,"CleanCommandLabel"); - widgets->extraSettingsCacheCleanEntry=yon_gtk_builder_get_widget(widgets->builder,"CleanCommandEntry"); - widgets->extraSettingsLaunchPackageManagerButton=yon_gtk_builder_get_widget(widgets->builder,"LaunchPackageManagerButton"); - - widgets->headerLoadConfigLabel=yon_gtk_builder_get_widget(widgets->builder,"headerLoadConfigLabel"); - widgets->headerLoadGlobalConfigButton=yon_gtk_builder_get_widget(widgets->builder,"LoadGlobalConfigurationMenuItem"); - widgets->headerLoadLocalConfigButton=yon_gtk_builder_get_widget(widgets->builder,"LoadLocalConfigurationMenuItem"); - - widgets->headerSaveConfigLabel=yon_gtk_builder_get_widget(widgets->builder,"headerSaveConfigLabel"); - widgets->headerSaveGlobalLocalConfigButton=yon_gtk_builder_get_widget(widgets->builder,"SaveGlobalLocalConfigurationMenuItem"); - widgets->headerSaveGlobalConfigButton=yon_gtk_builder_get_widget(widgets->builder,"SaveGlobalConfigurationMenuItem"); - widgets->headerSaveLocalConfigButton=yon_gtk_builder_get_widget(widgets->builder,"SaveLocalConfigurationMenuItem"); - - widgets->headerDocumentationButton=yon_gtk_builder_get_widget(widgets->builder,"DocumentationMenuItem"); - widgets->headerAboutButton=yon_gtk_builder_get_widget(widgets->builder,"AboutMenuItem"); - - widgets->mainCheckForUpdatesButton=yon_gtk_builder_get_widget(widgets->builder,"checkForUpdatesButton"); - - widgets->mainCheckForUpdatesButton = yon_gtk_builder_get_widget(widgets->builder,"checkForUpdatesButton"); - widgets->statusBox = yon_gtk_builder_get_widget(widgets->builder,"mainStatusBox"); - widgets->statusIcon = yon_gtk_builder_get_widget(widgets->builder,"mainStatusIcon"); - widgets->statusLabel = yon_gtk_builder_get_widget(widgets->builder,"mainStatusLabel"); - - main_config.list=GTK_LIST_STORE(gtk_builder_get_object(widgets->builder,"liststore1")); - - if (main_config.lock_load_global == 1){ - gtk_widget_set_sensitive(widgets->headerLoadGlobalConfigButton,0); - } - if (main_config.lock_save_global == 1){ - gtk_widget_set_sensitive(widgets->headerSaveGlobalConfigButton,0); - gtk_widget_set_sensitive(widgets->headerSaveGlobalLocalConfigButton,0); +void on_repo_accept_clicked(GtkWidget *, dictionary *dict){ + // main_window *widgets = yon_dictionary_get_data(dict->first,main_window*); + repo_add_window *window = yon_dictionary_get_data(dict->first->next,repo_add_window*); + // int enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->EnabledCheck)); + const char *repo_name = gtk_entry_get_text(GTK_ENTRY(window->RepoNameEntry)); + if (yon_char_is_empty(repo_name)){ + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect(window->RepoNameEntry); + return; } - if (main_config.lock_save_local == 1){ - gtk_widget_set_sensitive(widgets->headerSaveLocalConfigButton,0); - gtk_widget_set_sensitive(widgets->headerSaveGlobalLocalConfigButton,0); + // int source_mode = gtk_combo_box_get_active(GTK_COMBO_BOX(window->RepoSourceCombo)); + const char *source_path = gtk_entry_get_text(GTK_ENTRY(window->RepoSourceEntry)); + if (yon_char_is_empty(source_path)){ + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect(window->RepoSourceEntry); + return; } - gtk_window_set_title(GTK_WINDOW(widgets->window),TITLE_LABEL); - - gtk_label_set_text(GTK_LABEL(widgets->HeaderTopic),TITLE_LABEL); + // int sign_level_package = gtk_combo_box_get_active(GTK_COMBO_BOX(window->RepoSignCheckCombo)); + // int sign_level_condiition = gtk_combo_box_get_active(GTK_COMBO_BOX(window->RepoSignConditionCombo)); - gtk_label_set_text(GTK_LABEL(widgets->generalSettingsTabLabel),GENERAL_LABEL); - gtk_label_set_text(GTK_LABEL(widgets->repositoriesSettingsTabLabel),REPOSITORIES_LABEL); - gtk_label_set_text(GTK_LABEL(widgets->extraSettingsTabLabel),EXTRA_LABEL); + // int usage_level_default = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->UsageDefaultCheck)); + // int usage_level_enable_update = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->UsageEnableUpdateCheck)); + // int usage_level_enable_search = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->UsageEnableSearchCheck)); + // int usage_level_enable_install = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->UsageEnableInsallCheck)); + // int usage_level_sysupgrade = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->UsageSysupgradeCheck)); + gtk_widget_destroy(window->Window); + free(window); - gtk_label_set_text(GTK_LABEL(widgets->generalSettingsUpdatesCheckFreqLabel),CHECK_FREQUENCY_LABEL); - gtk_button_set_label(GTK_BUTTON(widgets->generalSettingsHideNoUpdatesCheck),HIDE_NO_UPDATES_LABEL); - gtk_button_set_label(GTK_BUTTON(widgets->generalSettingsDownloadAutoCheck),AUTO_UPDATE_LABEL); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widgets->generalSettingsUpdatesCheckFreqCombo),EVERY_1_HOUR_LABEL); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widgets->generalSettingsUpdatesCheckFreqCombo),EVERY_2_HOURS_LABEL); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widgets->generalSettingsUpdatesCheckFreqCombo),EVERY_3_HOURS_LABEL); +} - gtk_button_set_label(GTK_BUTTON(widgets->repositoriesSettingsActivateAURCheck),AUR_LABEL); - gtk_button_set_label(GTK_BUTTON(widgets->repositoriesSettingsActivateUBURCheck),UBUR_LABEL); - // gtk_button_set_label(GTK_BUTTON(widgets->repositoriesSettingsCreateButton),_("Create")); - // gtk_button_set_label(GTK_BUTTON(widgets->repositoriesSettingsEditButton),_("Edit")); - // gtk_button_set_label(GTK_BUTTON(widgets->repositoriesSettingsDeleteButton),_("Delete")); - gtk_tree_view_column_set_title(GTK_TREE_VIEW_COLUMN(widgets->repositoriesSettingsEnabledColumn),ENABLED_LABEL); - gtk_tree_view_column_set_title(GTK_TREE_VIEW_COLUMN(widgets->repositoriesSettingsURIColumn),URI_LABEL); - gtk_tree_view_column_set_title(GTK_TREE_VIEW_COLUMN(widgets->repositoriesSettingsDistributionColumn),DISTIBUTION_LABEL); +void on_web_publish_accept(GtkWidget *, dictionary *){ + // main_window *widgets = yon_dictionary_get_data(dict->first,main_window*); + // repo_add_window *window = yon_dictionary_get_data(dict->first->next,repo_add_window*); - gtk_label_set_text(GTK_LABEL(widgets->extraSettingsPackageManagerLabel),PACKAGE_MANAGER_LABEL); - gtk_label_set_text(GTK_LABEL(widgets->extraSettingsUpdateCommandLabel),UPDATE_COMMAND_LABEL); - gtk_label_set_text(GTK_LABEL(widgets->extraSettingsCacheCleanlabel),CACHE_CLEAN_LABEL); - gtk_button_set_label(GTK_BUTTON(widgets->extraSettingsLaunchPackageManagerButton),LAUNCH_PACKAGE_MANAGER_LABEL); +} - gtk_label_set_text(GTK_LABEL(widgets->headerLoadConfigLabel),LOAD_LABEL); - gtk_menu_item_set_label(GTK_MENU_ITEM(widgets->headerLoadGlobalConfigButton),LOAD_GLOBAL_LABEL); - gtk_menu_item_set_label(GTK_MENU_ITEM(widgets->headerLoadLocalConfigButton),LOAD_LOCAL_LABEL); +void on_mirror_accept(GtkWidget *,dictionary *){ + // main_window *widgets = yon_dictionary_get_data(dict->first,main_window*); + // repo_add_window *window = yon_dictionary_get_data(dict->first->next,repo_add_window*); - gtk_label_set_text(GTK_LABEL(widgets->headerSaveConfigLabel),SAVE_LABEL); - gtk_menu_item_set_label(GTK_MENU_ITEM(widgets->headerSaveGlobalLocalConfigButton),SAVE_LABEL); - gtk_menu_item_set_label(GTK_MENU_ITEM(widgets->headerSaveGlobalConfigButton),SAVE_GLOBAL_LABEL); - gtk_menu_item_set_label(GTK_MENU_ITEM(widgets->headerSaveLocalConfigButton),SAVE_LOCAL_LABEL); +} - gtk_menu_item_set_label(GTK_MENU_ITEM(widgets->headerDocumentationButton),DOCUMENTATION_LABEL); - gtk_menu_item_set_label(GTK_MENU_ITEM(widgets->headerAboutButton),ABOUT_LABEL); +void on_remove_accept(GtkWidget *, GtkWidget *){ - gtk_button_set_label(GTK_BUTTON(widgets->mainCheckForUpdatesButton),CHECK_FOR_UPDATES_LABEL); +} +repo_add_window *yon_repo_add_window_new(){ + GtkBuilder *builder = gtk_builder_new_from_resource(glade_repo_add_path); + repo_add_window *window = malloc(sizeof(repo_add_window)); + window->Window = yon_gtk_builder_get_widget(builder,"MainWindow"); + window->StatusBox = yon_gtk_builder_get_widget(builder,"StatusBox"); + window->EnabledCheck = yon_gtk_builder_get_widget(builder,"EnabledCheck"); + window->RepoNameEntry = yon_gtk_builder_get_widget(builder,"RepoNameEntry"); + window->RepoSourceCombo = yon_gtk_builder_get_widget(builder,"RepoSourceCombo"); + window->RepoSourceEntry = yon_gtk_builder_get_widget(builder,"RepoSourceEntry"); + window->RepoSourceButton = yon_gtk_builder_get_widget(builder,"RepoSourceButton"); + window->RepoSignCheckCombo = yon_gtk_builder_get_widget(builder,"RepoSignCheckCombo"); + window->RepoSignConditionCombo = yon_gtk_builder_get_widget(builder,"RepoSignConditionCombo"); + window->UsageDefaultCheck = yon_gtk_builder_get_widget(builder,"UsageDefaultCheck"); + window->UsageEnableUpdateCheck = yon_gtk_builder_get_widget(builder,"UsageEnableUpdateCheck"); + window->UsageEnableSearchCheck = yon_gtk_builder_get_widget(builder,"UsageEnableSearchCheck"); + window->UsageEnableInsallCheck = yon_gtk_builder_get_widget(builder,"UsageEnableInsallCheck"); + window->UsageSysupgradeCheck = yon_gtk_builder_get_widget(builder,"UsageSysupgradeCheck"); + window->AcceptButton = yon_gtk_builder_get_widget(builder,"AcceptButton"); + window->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton"); + window->HeadLabel = yon_gtk_builder_get_widget(builder,"HeadLabel"); + + g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); + gtk_widget_show(window->Window); + return window; +} +web_publication_add_window *yon_web_publication_add_window_new(){ + GtkBuilder *builder = gtk_builder_new_from_resource(glade_web_publish_add_path); + web_publication_add_window *window = malloc(sizeof(web_publication_add_window)); + window->Window = yon_gtk_builder_get_widget(builder,"MainWindow"); + window->StatusBox = yon_gtk_builder_get_widget(builder,"StatusBox"); + window->EnablePublishCheck = yon_gtk_builder_get_widget(builder,"EnablePublishCheck"); + window->PathEntry = yon_gtk_builder_get_widget(builder,"PathEntry"); + window->PathButton = yon_gtk_builder_get_widget(builder,"PathButton"); + window->RepositoriesTree = yon_gtk_builder_get_widget(builder,"RepositoriesTree"); + window->PortCheck = yon_gtk_builder_get_widget(builder,"PortCheck"); + window->PortEntry = yon_gtk_builder_get_widget(builder,"PortEntry"); + window->EnableWebFileBrowserCheck = yon_gtk_builder_get_widget(builder,"EnableWebFileBrowserCheck"); + window->UsernameCheck = yon_gtk_builder_get_widget(builder,"UsernameCheck"); + window->UsernameEntry = yon_gtk_builder_get_widget(builder,"UsernameEntry"); + window->UserPasswordCheck = yon_gtk_builder_get_widget(builder,"UserPasswordCheck"); + window->UserPasswordCombo = yon_gtk_builder_get_widget(builder,"UserPasswordCombo"); + window->UserPasswordEntry = yon_gtk_builder_get_widget(builder,"UserPasswordEntry"); + window->AcceptButton = yon_gtk_builder_get_widget(builder,"AcceptButton"); + window->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton"); + window->HeadLabel = yon_gtk_builder_get_widget(builder,"HeadLabel"); + + g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); + gtk_widget_show(window->Window); + + return window; +} - GtkWidget *Header = yon_gtk_builder_get_widget(widgets->builder,"boxColor"); - GtkWidget *Image = yon_gtk_builder_get_widget(widgets->builder,"HeadBackgroundImage"); - GtkWidget *Overlay = yon_gtk_builder_get_widget(widgets->builder,"HeadOverlay"); - - GtkWidget *UnderNoteOverlay = yon_gtk_builder_get_widget(widgets->builder,"UnderNoteOverlay"); - GtkWidget *headLabel = yon_gtk_builder_get_widget(widgets->builder,"headLabel"); - GtkWidget *headInfoLabel = yon_gtk_builder_get_widget(widgets->builder,"headInfoLabel"); - yon_ubl_header_setup(Overlay,Header,Image,image_path); - gtk_overlay_add_overlay(GTK_OVERLAY(UnderNoteOverlay),widgets->mainCheckForUpdatesButton); - - gtk_label_set_text(GTK_LABEL(headLabel),TITLE_LABEL); - gtk_label_set_text(GTK_LABEL(headInfoLabel),TITLE_INFO_LABEL); - gtk_widget_show_all(widgets->window); - - render.box=widgets->statusBox; - render.icon=widgets->statusIcon; - render.label=widgets->statusLabel; - yon_ubl_setup_sockets(widgets->PlugBox,widgets->LeftBox,widgets->RightBox,main_config.socket_id,main_config.load_socket_id,main_config.save_socket_id); +mirror_configure_window *yon_mirror_configure_window_new(){ + GtkBuilder *builder = gtk_builder_new_from_resource(glade_mirror_configure_path); + mirror_configure_window *window = malloc(sizeof(mirror_configure_window)); + window->Window = yon_gtk_builder_get_widget(builder,"MainWindow"); + window->StatusBox = yon_gtk_builder_get_widget(builder,"StatusBox"); + window->AcceptButton = yon_gtk_builder_get_widget(builder,"AcceptButton"); + window->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton"); + window->HeadLabel = yon_gtk_builder_get_widget(builder,"HeadLabel"); + window->PortDefaultCheck = yon_gtk_builder_get_widget(builder,"PortDefaultCheck"); + window->PortEntry = yon_gtk_builder_get_widget(builder,"PortEntry"); + window->CacheDefaultCheck = yon_gtk_builder_get_widget(builder,"CacheDefaultCheck"); + window->CacheEntry = yon_gtk_builder_get_widget(builder,"CacheEntry"); + window->CacheButton = yon_gtk_builder_get_widget(builder,"CacheButton"); + window->InactivityDurationDefaultCheck = yon_gtk_builder_get_widget(builder,"InactivityDurationDefaultCheck"); + window->InactivityDurationEntry = yon_gtk_builder_get_widget(builder,"InactivityDurationEntry"); + window->CacheTimeoutDefaultCheck = yon_gtk_builder_get_widget(builder,"CacheTimeoutDefaultCheck"); + window->CacheTimeoutEntry = yon_gtk_builder_get_widget(builder,"CacheTimeoutEntry"); + window->ProxyCheck = yon_gtk_builder_get_widget(builder,"ProxyCheck"); + window->ProxyEntry = yon_gtk_builder_get_widget(builder,"ProxyEntry"); + window->AgentDefaultCheck = yon_gtk_builder_get_widget(builder,"AgentDefaultCheck"); + window->AgentEntry = yon_gtk_builder_get_widget(builder,"AgentEntry"); + window->CronEntry = yon_gtk_builder_get_widget(builder,"CronEntry"); + window->UpdatesDelayDefaultCheck = yon_gtk_builder_get_widget(builder,"UpdatesDelayDefaultCheck"); + window->UpdatesDelayEntry = yon_gtk_builder_get_widget(builder,"UpdatesDelayEntry"); + window->UpdatesRequestDelayDefaultCheck = yon_gtk_builder_get_widget(builder,"UpdatesRequestDelayDefaultCheck"); + window->UpdatesRequestDelayEntry = yon_gtk_builder_get_widget(builder,"UpdatesRequestDelayEntry"); + + g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); + gtk_widget_show(window->Window); + + return window; +} - g_signal_connect(G_OBJECT(widgets->repositoriesSettingsCreateButton), "clicked", G_CALLBACK(on_repo_window_open_create), NULL); - g_signal_connect(G_OBJECT(widgets->repositoriesSettingsEditButton), "clicked", G_CALLBACK(on_repo_window_open_edit), widgets->repositoriesSettingsRepositoriesTreeView); - g_signal_connect(G_OBJECT(widgets->repositoriesSettingsDeleteButton), "clicked", G_CALLBACK(on_repos_delete), widgets->repositoriesSettingsRepositoriesTreeView); +mirror_add_window *yon_mirror_add_window_new(){ + GtkBuilder *builder = gtk_builder_new_from_resource(glade_mirror_add_path); + mirror_add_window *window = malloc(sizeof(mirror_add_window)); + window->Window = yon_gtk_builder_get_widget(builder,"MainWindow"); + window->StatusBox = yon_gtk_builder_get_widget(builder,"StatusBox"); + window->NameEntry = yon_gtk_builder_get_widget(builder,"NameEntry"); + window->TypeCombo = yon_gtk_builder_get_widget(builder,"TypeCombo"); + window->TypeEntry = yon_gtk_builder_get_widget(builder,"TypeEntry"); + window->TypeButton = yon_gtk_builder_get_widget(builder,"TypeButton"); + window->AcceptButton = yon_gtk_builder_get_widget(builder,"AcceptButton"); + window->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton"); + window->HeadLabel = yon_gtk_builder_get_widget(builder,"HeadLabel"); + + g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); + gtk_widget_show(window->Window); + + return window; +} - g_signal_connect(G_OBJECT(widgets->headerAboutButton), "activate", G_CALLBACK(on_about), NULL); +/**yon_main_window_complete(main_window *widgets) + * [EN] + * + * [RU] + * Функция настройки основного окна приложения. [widgets] - структура со стандартным интерфейсом. +*/ +void 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); - g_signal_connect(G_OBJECT(widgets->window), "destroy", G_CALLBACK(gtk_main_quit), NULL); - g_signal_connect(G_OBJECT(widgets->headerDocumentationButton), "activate", G_CALLBACK(on_open_documentation_confirmation), WIKI_LINK); + { + gtk_builder_add_callback_symbol(builder,"yon_gtk_widget_set_sensitive_from_toggle_button_inversed",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button_inversed)); + } + // Custom widgets configuration + { + widgets->AutoUpdateCheck = yon_gtk_builder_get_widget(builder,"AutoUpdateCheck"); + widgets->UpdateCheckFreqCombo = yon_gtk_builder_get_widget(builder,"UpdateCheckFreqCombo"); + widgets->UpdateCheckIntervalCombo = yon_gtk_builder_get_widget(builder,"UpdateCheckIntervalCombo"); + widgets->UpdateRepoListCombo = yon_gtk_builder_get_widget(builder,"UpdateRepoListCombo"); + widgets->UpdateRepoTree = yon_gtk_builder_get_widget(builder,"UpdateRepoTree"); + widgets->RepositoriesRepoListConfigurationCheck = yon_gtk_builder_get_widget(builder,"RepositoriesRepoListConfigurationCheck"); + widgets->RepositoriesDisableSystemReposCheck = yon_gtk_builder_get_widget(builder,"RepositoriesDisableSystemReposCheck"); + widgets->RepositoriesTree = yon_gtk_builder_get_widget(builder,"RepositoriesTree"); + widgets->RepositoriesUpdateButton = yon_gtk_builder_get_widget(builder,"RepositoriesUpdateButton"); + widgets->RepositoriesMoveUpButton = yon_gtk_builder_get_widget(builder,"RepositoriesMoveUpButton"); + widgets->RepositoriesMoveDownButton = yon_gtk_builder_get_widget(builder,"RepositoriesMoveDownButton"); + widgets->RepositoriesCreateButton = yon_gtk_builder_get_widget(builder,"RepositoriesCreateButton"); + widgets->RepositoriesEditButton = yon_gtk_builder_get_widget(builder,"RepositoriesEditButton"); + widgets->RepositoriesDeleteButton = yon_gtk_builder_get_widget(builder,"RepositoriesDeleteButton"); + widgets->PublicationConnectPublicCheck = yon_gtk_builder_get_widget(builder,"PublicationConnectPublicCheck"); + widgets->RecieveDBFromNetCheck = yon_gtk_builder_get_widget(builder,"RecieveDBFromNetCheck"); + widgets->PublicationTree = yon_gtk_builder_get_widget(builder,"PublicationTree"); + widgets->PublicationUpdateButton = yon_gtk_builder_get_widget(builder,"PublicationUpdateButton"); + widgets->WebPublicationUpdateButton = yon_gtk_builder_get_widget(builder,"WebPublicationUpdateButton"); + widgets->WebPublicationAddButton = yon_gtk_builder_get_widget(builder,"WebPublicationAddButton"); + widgets->WebPublicationEditButton = yon_gtk_builder_get_widget(builder,"WebPublicationEditButton"); + widgets->WebPublicationRemoveButton = yon_gtk_builder_get_widget(builder,"WebPublicationRemoveButton"); + widgets->WebPublicationTree = yon_gtk_builder_get_widget(builder,"WebPublicationTree"); + widgets->MirrorPublicCheck = yon_gtk_builder_get_widget(builder,"MirrorPublicCheck"); + widgets->MirrorTree = yon_gtk_builder_get_widget(builder,"MirrorTree"); + widgets->MirrorUpdateButton = yon_gtk_builder_get_widget(builder,"MirrorUpdateButton"); + widgets->MirrorAddButton = yon_gtk_builder_get_widget(builder,"MirrorAddButton"); + widgets->MirrorEditButton = yon_gtk_builder_get_widget(builder,"MirrorEditButton"); + widgets->MirrorRemoveButton = yon_gtk_builder_get_widget(builder,"MirrorRemoveButton"); + widgets->MirrorConfigureButton = yon_gtk_builder_get_widget(builder,"MirrorConfigureButton"); + widgets->UpdateRepoList = GTK_LIST_STORE(gtk_builder_get_object(builder,"UpdateRepoList")); + widgets->ReposList = GTK_LIST_STORE(gtk_builder_get_object(builder,"ReposList")); + widgets->PublicationList = GTK_LIST_STORE(gtk_builder_get_object(builder,"PublicationList")); + widgets->WebPublicationList = GTK_LIST_STORE(gtk_builder_get_object(builder,"WebPublicationList")); + widgets->MirrorList = GTK_LIST_STORE(gtk_builder_get_object(builder,"MirrorList")); + } + { + g_signal_connect(G_OBJECT(widgets->RepositoriesCreateButton),"clicked",G_CALLBACK(on_repo_add),widgets); + g_signal_connect(G_OBJECT(widgets->WebPublicationAddButton),"clicked",G_CALLBACK(on_web_publish_add),widgets); + g_signal_connect(G_OBJECT(widgets->MirrorAddButton),"clicked",G_CALLBACK(on_mirror_add),widgets); + g_signal_connect(G_OBJECT(widgets->RepositoriesTree),"cursor-changed",G_CALLBACK(on_selection_changed),widgets); + g_signal_connect(G_OBJECT(widgets->PublicationTree),"cursor-changed",G_CALLBACK(on_selection_changed),widgets); + g_signal_connect(G_OBJECT(widgets->WebPublicationTree),"cursor-changed",G_CALLBACK(on_selection_changed),widgets); + g_signal_connect(G_OBJECT(widgets->MirrorTree),"cursor-changed",G_CALLBACK(on_selection_changed),widgets); + } } - -int main(int argc, char *argv[]){ +int main(int argc, char *argv[]){ local=setlocale(LC_ALL, ""); textdomain (LocaleName); - init(NULL); - int option_index=0; - int show_help=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'}, - { NULL, 0, NULL, 0 } - }; - for (int i=0;i #include -#include "ubl-utils.h" #include #include #include @@ -8,7 +9,9 @@ #include #include #include -#include "../compile/ubl-cmake.h" +#include +#include +#include #ifdef WEBKIT_FOUND #include #endif @@ -19,123 +22,197 @@ #define _(String) gettext(String) #define glade_path "/com/ublinux/ui/ubl-settings-update.glade" -#define image_path "/com/ublinux/images/ubl-settings-update-banner.png" +#define glade_repo_add_path "/com/ublinux/ui/ubl-settings-update-repo-add.glade" +#define glade_web_publish_add_path "/com/ublinux/ui/ubl-settings-update-web-publication-add.glade" +#define glade_mirror_configure_path "/com/ublinux/ui/ubl-settings-update-mirror-configure.glade" +#define glade_mirror_add_path "/com/ublinux/ui/ubl-settings-update-mirror-add.glade" +#define banner_path "/com/ublinux/images/ubl-settings-update-banner.png" #define CssPath "/com/ublinux/css/ubl-settings-update.css" +#define config_path yon_char_unite(yon_ubl_user_get_home_directory(),"/.config/",LocaleName,"/",LocaleName,".conf",NULL) #define LocalePath "/usr/share/locale" #define LocaleName "ubl-settings-update" +#define icon_path "com.ublinux.ubl-settings-update" + +#define yon_config_get_custom_command(target) yon_char_unite("ubconfig --source ",target," get system PARAMETERS",NULL) +#define config_get_local_command "ubconfig --source system get system PARAMETERS" +#define config_get_global_command "ubconfig --source global get system PARAMETERS" +#define config_get_default_command "" + +#define config_get_global_only_parameters "" +#define config_get_local_only_parameters "" + typedef char* string; string version_application; char *local; typedef struct { - 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; - - GtkListStore *list; + template_config_fields + } config; typedef struct { - GtkWidget *window; - GtkBuilder *builder; - - GtkWidget *HeaderTopic; - - GtkWidget *PlugBox; - GtkWidget *LeftBox; - GtkWidget *RightBox; - - GtkWidget *generalSettingsTabLabel; - GtkWidget *repositoriesSettingsTabLabel; - GtkWidget *extraSettingsTabLabel; - - GtkWidget *generalSettingsHideNoUpdatesCheck; - GtkWidget *generalSettingsUpdatesCheckFreqLabel; - GtkWidget *generalSettingsUpdatesCheckFreqCombo; - GtkWidget *generalSettingsDownloadAutoCheck; - - GtkWidget *repositoriesSettingsActivateAURCheck; - GtkWidget *repositoriesSettingsActivateUBURCheck; - GtkWidget *repositoriesSettingsMoveUpButton; - GtkWidget *repositoriesSettingsMoveDownButton; - GtkWidget *repositoriesSettingsCreateButton; - GtkWidget *repositoriesSettingsEditButton; - GtkWidget *repositoriesSettingsDeleteButton; - GtkWidget *repositoriesSettingsRepositoriesTreeView; - GtkTreeViewColumn *repositoriesSettingsEnabledColumn; - GtkTreeViewColumn *repositoriesSettingsURIColumn; - GtkTreeViewColumn *repositoriesSettingsDistributionColumn; - - GtkWidget *extraSettingsPackageManagerLabel; - GtkWidget *extraSettingsPackageManagerEntry; - GtkWidget *extraSettingsUpdateCommandLabel; - GtkWidget *extraSettingsUpdateCommandEntry; - GtkWidget *extraSettingsCacheCleanlabel; - GtkWidget *extraSettingsCacheCleanEntry; - GtkWidget *extraSettingsLaunchPackageManagerButton; - - GtkWidget *headerLoadConfigLabel; - GtkWidget *headerLoadGlobalConfigButton; - GtkWidget *headerLoadLocalConfigButton; - - GtkWidget *headerSaveConfigLabel; - GtkWidget *headerSaveGlobalLocalConfigButton; - GtkWidget *headerSaveGlobalConfigButton; - GtkWidget *headerSaveLocalConfigButton; - - GtkWidget *headerDocumentationButton; - GtkWidget *headerAboutButton; - - GtkWidget *mainCheckForUpdatesButton; - - GtkWidget *statusBox; - GtkWidget *statusIcon; - GtkWidget *statusLabel; - + template_window_fields + GtkWidget *AutoUpdateCheck; + GtkWidget *UpdateCheckFreqCombo; + GtkWidget *UpdateCheckIntervalCombo; + GtkWidget *UpdateRepoListCombo; + GtkWidget *UpdateRepoTree; + GtkListStore *UpdateRepoList; + + GtkWidget *RepositoriesRepoListConfigurationCheck; + GtkWidget *RepositoriesDisableSystemReposCheck; + GtkWidget *RepositoriesTree; + GtkWidget *RepositoriesUpdateButton; + GtkWidget *RepositoriesMoveUpButton; + GtkWidget *RepositoriesMoveDownButton; + GtkWidget *RepositoriesCreateButton; + GtkWidget *RepositoriesEditButton; + GtkWidget *RepositoriesDeleteButton; + GtkListStore *ReposList; + + GtkWidget *PublicationConnectPublicCheck; + GtkWidget *RecieveDBFromNetCheck; + GtkWidget *PublicationTree; + GtkWidget *PublicationUpdateButton; + GtkListStore *PublicationList; + + GtkWidget *WebPublicationUpdateButton; + GtkWidget *WebPublicationAddButton; + GtkWidget *WebPublicationEditButton; + GtkWidget *WebPublicationRemoveButton; + GtkWidget *WebPublicationTree; + GtkListStore *WebPublicationList; + + GtkWidget *MirrorPublicCheck; + GtkWidget *MirrorTree; + GtkWidget *MirrorUpdateButton; + GtkWidget *MirrorAddButton; + GtkWidget *MirrorEditButton; + GtkWidget *MirrorRemoveButton; + GtkWidget *MirrorConfigureButton; + GtkListStore *MirrorList; } main_window; typedef struct { - GtkWidget *window; - GtkBuilder *builder; - GtkListStore *list; + GtkWidget *Window; + GtkWidget *HeadLabel; + GtkWidget *StatusBox; + GtkWidget *UsageSysupgradeCheck; + GtkWidget *UsageEnableInsallCheck; + GtkWidget *UsageEnableSearchCheck; + GtkWidget *UsageEnableUpdateCheck; + GtkWidget *UsageDefaultCheck; + GtkWidget *RepoSignConditionCombo; + GtkWidget *RepoSignCheckCombo; + GtkWidget *RepoSourceButton; + GtkWidget *RepoSourceEntry; + GtkWidget *RepoSourceCombo; + GtkWidget *RepoNameEntry; + GtkWidget *EnabledCheck; + GtkWidget *AcceptButton; + GtkWidget *CancelButton; +} repo_add_window; - GtkWidget *repoTypeLabel; - GtkWidget *repoTypeEntry; - GtkWidget *repoDistributionLabel; - GtkWidget *repoDistributionEntry; +typedef struct { + GtkWidget *Window; + GtkWidget *HeadLabel; + GtkWidget *StatusBox; + GtkWidget *EnablePublishCheck; + GtkWidget *PathEntry; + GtkWidget *PathButton; + GtkWidget *RepositoriesTree; + GtkWidget *PortCheck; + GtkWidget *PortEntry; + GtkWidget *EnableWebFileBrowserCheck; + GtkWidget *UsernameCheck; + GtkWidget *UsernameEntry; + GtkWidget *UserPasswordCheck; + GtkWidget *UserPasswordCombo; + GtkWidget *UserPasswordEntry; + GtkWidget *AcceptButton; + GtkWidget *CancelButton; +} web_publication_add_window; - GtkWidget *repoCancelButton; - GtkWidget *repoAcceptButton; - GtkWidget *tree; -} repo_window; +typedef struct { + GtkWidget *Window; + GtkWidget *HeadLabel; + GtkWidget *StatusBox; + GtkWidget *AcceptButton; + GtkWidget *CancelButton; + GtkWidget *NameEntry; + GtkWidget *TypeCombo; + GtkWidget *TypeEntry; + GtkWidget *TypeButton; +} mirror_add_window; typedef struct { GtkWidget *Window; + GtkWidget *HeadLabel; + GtkWidget *StatusBox; + GtkWidget *AcceptButton; + GtkWidget *CancelButton; + + GtkWidget *PortDefaultCheck; + GtkWidget *PortEntry; + GtkWidget *CacheDefaultCheck; + GtkWidget *CacheEntry; + GtkWidget *CacheButton; + GtkWidget *InactivityDurationDefaultCheck; + GtkWidget *InactivityDurationEntry; + GtkWidget *CacheTimeoutDefaultCheck; + GtkWidget *CacheTimeoutEntry; + GtkWidget *ProxyCheck; + GtkWidget *ProxyEntry; + GtkWidget *AgentDefaultCheck; + GtkWidget *AgentEntry; + GtkWidget *CronEntry; + GtkWidget *UpdatesDelayDefaultCheck; + GtkWidget *UpdatesDelayEntry; + GtkWidget *UpdatesRequestDelayDefaultCheck; + GtkWidget *UpdatesRequestDelayEntry; +} mirror_configure_window; + + +typedef struct { + GtkWidget *Window; + GtkWidget *HeaderLabel; - GtkWidget *HatText; - GtkWidget *HeaderText; - GtkWidget *InfoText; GtkWidget *AlwaysOpenCheck; GtkWidget *CloseButton; GtkWidget *AcceptButton; } documentation_confirmation_window; -void on_repo_window_open(GtkWidget *self); +void yon_load_proceed(YON_CONFIG_TYPE type); + +void config_init(); + +void yon_main_window_complete(main_window *widgets); + +void on_repo_accept_clicked(GtkWidget *, dictionary *dict); +void on_web_publish_accept(GtkWidget *, dictionary *dict); +void on_mirror_accept(GtkWidget *,dictionary *dict); +void on_remove_accept(GtkWidget *, GtkWidget *target); + +repo_add_window *yon_repo_add_window_new(); +web_publication_add_window *yon_web_publication_add_window_new(); +mirror_add_window *yon_mirror_add_window_new(); +mirror_configure_window *yon_mirror_configure_window_new(); + +void on_repo_add(GtkWidget *, main_window *widgets); +void on_mirror_add(GtkWidget *,main_window *widgets); +void on_web_publish_add(GtkWidget *,main_window *widgets); + +void on_web_publish_remove(GtkWidget *self,main_window *widgets); +void on_mirror_remove(GtkWidget *,main_window *widgets); + +void on_web_publish_edit(GtkWidget *,main_window *widgets); +void on_mirror_edit(GtkWidget *,main_window *widgets); + +void on_mirror_configure(GtkWidget *,main_window *widgets); + +void on_selection_changed(GtkWidget *self, main_window *widgets); -void on_repo_window_open_edit(GtkWidget *self, GtkWidget *tree); -repo_window *on_repo_window_open_create(GtkWidget *self); -main_window *setup_window(); \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/ubl-strings.h b/source/ubl-strings.h index eebe1a6..e3c2683 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -1,49 +1,11 @@ -#define VERSION_LABEL yon_char_unite(_("Version:")," ",version_application,"\n",NULL) -#define HELP_LABEL yon_char_unite(_("ubl-settings-update version:")," ", version_application,"\n",_("update settings"),"\n",_("Usage:"), " ubl-settings-update ",_("[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 TITLE_LABEL _("System update") -#define TITLE_INFO_LABEL _("System update settings management") -#define CHECK_FOR_UPDATES_LABEL _("Check for updates") -#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 LAUNCH_PACKAGE_MANAGER_LABEL _("Launch package manager") -#define CACHE_CLEAN_LABEL _("Cache clean command: ") -#define UPDATE_COMMAND_LABEL _("Update command: ") -#define PACKAGE_MANAGER_LABEL _("Package manager: ") -#define URI_LABEL _("URI") -#define ENABLED_LABEL _("Enabled") -#define DISTIBUTION_LABEL _("Distribution") -#define UBUR_LABEL _("Activate UBUR") -#define AUR_LABEL _("Activate AUR") -#define EVERY_3_HOURS_LABEL _("Every 3 hours") -#define EVERY_2_HOURS_LABEL _("Every 2 hours") -#define EVERY_1_HOUR_LABEL _("Every 1 hour") -#define AUTO_UPDATE_LABEL _("Download updates automatically") -#define HIDE_NO_UPDATES_LABEL _("Hide icon of no updates found") -#define CHECK_FREQUENCY_LABEL _("Update checking frequency") -#define EXTRA_LABEL _("Extra") -#define REPOSITORIES_LABEL _("Repositories") -#define GENERAL_LABEL _("General") -#define ADRESS_LABEL _("Adress: ") -#define DISTRIBUTION_LABEL _("Distribution: ") -#define CANCEL_LABEL _("Cancel") -#define SAVE_LABEL _("Save") -#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.") -#define HELP_ALWAYS_OPEN_LABEL _("Always redirect to online documentation") -#define OPEN_HELP_LABEL _("Open documentation") -#define PROJECT_HOME_LABEL _("Project Home Page") -#define NOTHING_CHOSEN_LABEL _("Nothing were chosen") +#ifndef UBL_SETTINGS_UPDATE_STRINGS +#define UBL_SETTINGS_UPDATE_STRINGS -#define GLOBAL_LOAD_SUCCESS _("Global configuration loading succseeded.") -#define LOCAL_LOAD_SUCCESS _("Local configuration loading succseeded.") + #define TITLE_LABEL _("System update") + #define TITLE_INFO_LABEL _("System update settings management") + #define NOTHING_CHOSEN_LABEL _("Nothing were chosen") + #define EMPTY_IMPORTANT_LABEL _("Empty important field!") + #define ADD_REPO_LABEL _("Add repository") + #define REMOVE_REPO_WARNING_LABEL _("Are you sure want to remove repository?") -#define GLOBAL_LOCAL_SAVE_SUCCESS _("Local and global configuration saving succseeded.") -#define GLOBAL_SAVE_SUCCESS _("Global configuration saving succseeded.") -#define LOCAL_SAVE_SUCCESS _("Local configuration saving succseeded.") \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/ubl-utils.c b/source/ubl-utils.c deleted file mode 100644 index ba72538..0000000 --- a/source/ubl-utils.c +++ /dev/null @@ -1,1060 +0,0 @@ -#include "ubl-utils.h" - -#include "../compile/ubl-cmake.h" -#ifdef WEBKIT_FOUND - #include -#endif -// dictionary functions - -/**[EN] - * yon_dictionary_create_empty(): - * Creates and returns empty dictionary - */ -dictionary *yon_dictionary_create_empty() -{ - 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; -} - -void yon_dictionary_switch_to_last(dictionary **dict) -{ - if ((*dict)->next != NULL) - for ((*dict) = (*dict)->first; (*dict)->next != NULL; (*dict) = (*dict)->next) - { - } -} - -dictionary *yon_dictionary_create_conneced(dictionary *targetdict) -{ - targetdict = yon_dictionary_get_last(targetdict); - targetdict->next = yon_dictionary_create_empty(); - targetdict->next->prev = targetdict; - targetdict->next->first = targetdict->first; - targetdict->next->data_type = DICTIONARY_OTHER_TYPE; - return targetdict->next; -} - -dictionary *yon_dictionary_get_last(dictionary *dict) -{ - dictionary *dct = NULL; - for (dct = dict->first; dct->next != NULL; dct = dct->next) - { - } - return dct; -} - -dictionary *yon_dictionary_switch_places(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; - } - } - } - } -} - -void yon_dictionary_make_first(dictionary *dict) -{ - for (dictionary *dct = dict->first; dct != NULL; dct = dct->next) - { - dct->first = dict; - } -} - -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; -} - -dictionary *yon_dictionary_create_with_data(char *key, void *data) -{ - dictionary *dct = yon_dictionary_create_empty(); - 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; -} - -dictionary *yon_dictionary_create_with_data_connected(dictionary *dict, char *key, void *data) -{ - dictionary *dct = yon_dictionary_create_conneced(dict); - dct->key = yon_char_new(key); - dct->data = data; - dct->data_type = DICTIONARY_OTHER_TYPE; - return dct; -} - -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; -} - -dictionary *yon_dictionary_find(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; -} - -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; - } -} - -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 - -/**[EN] - * - * creates new char string by combining two char strings. - */ -char *yon_char_get_augumented(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; -} - -// char *yon_char_unite(char *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_get_augumented(new_char,unite_char); - unite_char = va_arg(arglist,char*); - } - va_end(arglist); - return new_char; -} - -/**[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; -} -/**[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; -} - -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 = malloc(i * sizeof(char) + 1); - sprintf(ch, "%d", int_to_convert); - return ch; -} - -char *yon_char_replace(char *source, char *find, char*replace){ - 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_get_augumented(temp,replace); - source=yon_char_get_augumented(temp,final+1); - } - return source; - } -} - -/**[EN] - * char **yon_char_parse(char *parameters, int *size, char *divider) - * 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; - while ((param=yon_char_divide_search(paramline,divider,1))){ - string=realloc(string,sizeof(char*)*i); - string[i-1]=yon_char_new(param); - i++; - if (strcmp(param,paramline)==0) break; - } - string=realloc(string,sizeof(char*)*i); - string[i-1]=yon_char_new(paramline); - i++; - // printf("%d\n",i); - *size=i-1; - return string; - -} - -char **yon_char_parsed_shrink(char **char_string, int *size, int item_to_delete){ - char **new_char_parsed=NULL; - new_char_parsed=malloc(sizeof(char*)*(*size)-2); - int sz=0; - for (int i=0;i<*size-2;i++){ - if (i!=item_to_delete){ - new_char_parsed[i]=yon_char_new(char_string[i]); - sz++; - } - - } - *size=sz; - return new_char_parsed; -} - -/**[EN] - * - * Checks if [parameters] string array of length [size] - * has [param] element; -*/ -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_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[1000]; - memset(str, 0, 1000); - while (fgets(str, 1000, 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, 1000); - i++; - } - } - if (i>0){ - *str_len = i; - return output_strings; - } else{ - *str_len=-1; - return NULL; - } -} - -/**[EN] - * int yon_config_save(char *command) - * Saves config with [command] - * [RU] -*/ -int yon_config_save(char *command) -{ - FILE *output = popen(command, "r"); - return 1; -} - -/**[EN] - * char *yon_config_get_parameter(config parameters, int size, char *param) - * Gets parameter from parameter list; - * - * [RU] -*/ -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; -} - -/**[EN] - * Parses, modifies and connects string to use it as one of arguments, - * sended to ubconfig. - * - * [RU] - */ -char *yon_config_make_save_parameter_with_multiple_arguments(char *parameter_string, char *config_parameter, char *divider){ - char *final=""; - int done=0; - char *cur=yon_char_new(parameter_string); - yon_char_divide_search(cur,"=",1); - char *cur_param=NULL; - while (cur_param=yon_char_divide_search(cur,",",1)){ - if (done==0){ - final=yon_char_get_augumented(final,yon_char_get_augumented(yon_char_get_augumented(config_parameter,"="), yon_char_get_augumented(cur_param,", "))); - done=1; - } else { - final=yon_char_get_augumented(final,yon_char_get_augumented(yon_char_get_augumented(config_parameter,"+="), yon_char_get_augumented(cur_param,", "))); - } - } - if (cur&&strcmp(cur,"")!=0) - if (done==0) - final=yon_char_get_augumented(final,yon_char_get_augumented(yon_char_get_augumented(config_parameter,"="), yon_char_get_augumented(cur,", "))); - else - final=yon_char_get_augumented(final,yon_char_get_augumented(yon_char_get_augumented(config_parameter,"+="), yon_char_get_augumented(cur,", "))); - return final; -} - -// terminal-using functions - -int yon_launch_app(char *name) -{ - char *path = name; - thread_output *thread = malloc(sizeof(thread_output)); - thread->command = path; - thread->exitcode = malloc(sizeof(int)); - pthread_t thread_id; - pthread_create(&thread_id, NULL, (void *)yon_launch, thread); - return *thread->exitcode; -}; - -int yon_launch_app_with_arguments(char *name, char *args) -{ - char *path = yon_char_get_augumented("/usr/bin/", name); - path = yon_char_get_augumented(path, " "); - path = yon_char_get_augumented(path, args); - pthread_t thread_id; - thread_output *thread = malloc(sizeof(thread_output)); - thread->command = path; - thread->exitcode = malloc(sizeof(int)); - pthread_create(&thread_id, NULL, (void *)yon_launch, thread); - return *thread->exitcode; -}; - -int yon_launch(thread_output *thread) -{ - int a = 0; - a = system(thread->command); - *thread->exitcode = a; - return *thread->exitcode; -} - -// Gtk functions - - -#ifdef __GTK_H__ - -#ifdef VTE_TERMINAL - -/** - * 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){ - 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); - char *install_command=yon_char_unite("tput cup 0 0 && tput ed; ",command," ; sleep 5;exit 0","\n",NULL); - g_signal_connect(G_OBJECT(terminal), "child-exited", G_CALLBACK(on_terminal_done), widgets); - vte_terminal_spawn_async(VTE_TERMINAL(terminal), - VTE_PTY_DEFAULT, - NULL, - install_command, - NULL, - 0, - NULL, NULL, - NULL, - -1, - NULL, - NULL, - NULL); - vte_pty_spawn_async(pty, - NULL, - install_command, - 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(widgets->TerminalRevealer); - } - -#endif - -int yon_gtk_combo_box_fill(GtkWidget *combo, config_str parameters,int size){ - if (combo&¶meters){ - for (int i=0;ifirst; dct != NULL; dct = dct->next) - { - gtk_box_pack_start(GTK_BOX(destination), (GtkWidget *)dct->data, expand, fill, padding); - } - return 1; - }else return 0; -} - -int yon_dictionary_gtk_pack_end_multiple_widgets(dictionary *dict, GtkWidget *destination, gboolean expand, gboolean fill, int padding) -{ - for (dictionary *dct = dict->first; dct != NULL; dct = dct->next) - { - gtk_box_pack_end(GTK_BOX(destination), (GtkWidget *)dct->data, expand, fill, padding); - } - return 1; -} - -void _yon_ubl_header_setup(GtkWidget *Overlay, GtkWidget *Head, GtkWidget *Image, char *image_path) -{ - gtk_overlay_add_overlay(GTK_OVERLAY(Overlay), Head); - gtk_image_set_from_file(GTK_IMAGE(Image), image_path); -} - -/** - * -*/ -void _yon_ubl_status_box_render(render_data *datav) -{ - render_data data = *(render_data*)datav; - GtkIconTheme *ictheme = gtk_icon_theme_get_default(); - GError *err = NULL; - if (err) - { - printf("%s\n", err->message); - g_error_free(err); - } - if (data.type == BACKGROUND_IMAGE_SUCCESS_TYPE||! data.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 (data.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 (data.text_to_render) - gtk_label_set_text(GTK_LABEL(data.label), data.text_to_render); -} - -/**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 7004cca..0000000 --- a/source/ubl-utils.h +++ /dev/null @@ -1,297 +0,0 @@ -#ifndef UBL_UTILS -#define UBL_UTILS -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#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 yon_ubl_set_config_save_data_pointer(command) config_commands.config_save_data = command - -#define yon_ubl_load_global_config(command, size_pointer) yon_config_load(command, size_pointer) -#define yon_ubl_load_local_config(command, size_pointer) yon_config_load(command, size_pointer) -#define yon_ubl_save_global_config(command) yon_config_save(command) -#define yon_ubl_save_local_config(command) yon_config_save(command) - -typedef enum -{ - #ifdef __GTK_H__ - DICTIONARY_GTK_WIDGETS_TYPE, - #endif - DICTIONARY_OTHER_TYPE - -} DICT_TYPE; - -typedef struct -{ - char *command; - int *exitcode; -} thread_output; - - -typedef struct dictionary -{ - char *key; - void *data; - struct dictionary *next; - struct dictionary *prev; - struct dictionary *first; - DICT_TYPE data_type; -} dictionary; - -typedef struct apps -{ - char *Name; - int Type; - char *Categories; - char *Exec; - char *Icon; - int Pluggable; - int DualPluggable; -} apps; - -typedef char** config_str; -// 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) -#define yon_dictionary_add_or_create_if_exists_with_data(dict,key,data) {if (!dict) dict=yon_dictionary_create_with_data(key,data); \ - else dict=yon_dictionary_create_with_data_connected(dict,key,data);} - -dictionary *yon_dictionary_create_empty(); - -dictionary *yon_dictionary_create_conneced(dictionary *targetdict); - -dictionary *yon_dictionary_get_last(dictionary *dict); - -dictionary *yon_dictionary_switch_places(dictionary *dict, int aim); - -void yon_dictionary_make_first(dictionary *dict); - -void yon_dictionary_make_nth(dictionary *dict, int nth); - -dictionary *yon_dictionary_create_with_data(char *key, void *data); - -dictionary *yon_dictionary_create_with_data_connected(dictionary *dict, char *key, void *data); - -dictionary *yon_dictionary_connect(dictionary *old, dictionary *toconnect); - -dictionary *yon_dictionary_find(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 - -char *yon_char_get_augumented(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_shrink(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 (config_str old, int *old_size, ...); - -// parsing functions - -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(char *command); - -char *yon_config_get_parameter(config_str parameters, int size, char *param); - -char *yon_config_make_save_parameter_with_multiple_arguments(char *parameter_string, char *config_parameter, char *divider); - -// terminal-using functions - -int yon_launch_app(char *name); - -int yon_launch_app_with_arguments(char *name, char *args); - -int yon_launch(thread_output *thread); - -// 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); -#endif - -/**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; - -// GtkWidget *yon_gtk_app_chooser_apps_create(); - -// dictionary *yon_gtk_app_chooser_create(); - -// expander_icon_view yon_gtk_icon_view_expander_create(GtkWidget *pack, ...); - -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(dictionary *dict, GtkWidget *destination, gboolean expand, gboolean fill, int padding); -int yon_dictionary_gtk_pack_end_multiple_widgets(dictionary *dict, GtkWidget *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 в котором будет отображаться текст статусного сообщения; -*/ -#define yon_ubl_status_box_setup(render,icon,box,label) {render.icon=GTK_WIDGET(icon); render.box=GTK_WIDGET(box); render.label=GTK_WIDGET(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 (Жёлтный фон, иконка - галка) -*/ -#define yon_ubl_status_box_render(render,text,m_type) {render.text_to_render=text; render.type=m_type; pthread_attr_t attr; pthread_attr_init(&attr); pthread_t tid; pthread_create(&tid,&attr,(void*)_yon_ubl_status_box_render,((void*)&render)); } - -#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) -#endif - -void _yon_ubl_header_setup(GtkWidget *Overlay, GtkWidget *Head, GtkWidget *Image, char *image_path); -void _yon_ubl_status_box_render(render_data *datav); -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 From a67c45899fca167baafa85b69dd432faf331b295 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Thu, 10 Oct 2024 10:45:34 +0600 Subject: [PATCH 2/8] Update 1.0 WIP --- .gitignore | 6 + gresource.xml | 4 + source/ubl-settings-update.c | 52 +- source/ubl-settings-update.h | 28 +- ubl-settings-update-mirror-add.glade | 218 ++ ubl-settings-update-mirror-configure.glade | 575 +++++ ubl-settings-update-repo-add.glade | 400 ++++ ubl-settings-update-web-publication-add.glade | 458 ++++ ubl-settings-update.glade | 2118 ++++++++--------- 9 files changed, 2700 insertions(+), 1159 deletions(-) create mode 100644 ubl-settings-update-mirror-add.glade create mode 100644 ubl-settings-update-mirror-configure.glade create mode 100644 ubl-settings-update-repo-add.glade create mode 100644 ubl-settings-update-web-publication-add.glade diff --git a/.gitignore b/.gitignore index 1e99be8..af2ee60 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,13 @@ ubl-settings-update.glade~ ubl-settings-update ubl-settings-update_ru.po~ +*~ build/ compile/ +*# terminal-commands/ +source/ubl-cmake.h +vgcore* +.BUILD.md +.updatebuild.sh .install.sh \ No newline at end of file diff --git a/gresource.xml b/gresource.xml index abb260e..ad5e3f1 100644 --- a/gresource.xml +++ b/gresource.xml @@ -2,6 +2,10 @@ ubl-settings-update.glade + ubl-settings-update-repo-add.glade + ubl-settings-update-web-publication-add.glade + ubl-settings-update-mirror-add.glade + ubl-settings-update-mirror-configure.glade ubl-settings-update.css diff --git a/source/ubl-settings-update.c b/source/ubl-settings-update.c index d6b8801..a1c7e9a 100644 --- a/source/ubl-settings-update.c +++ b/source/ubl-settings-update.c @@ -39,6 +39,33 @@ void yon_load_proceed(YON_CONFIG_TYPE type){ } } +void yon_interface_update(main_window *widgets){ + int size; + config_str repos = yon_config_get_all_by_key(REPOSITORY_search,&size); + GtkTreeIter iter; + for (int i=0;iReposList,&iter); + gtk_list_store_set(widgets->ReposList,&iter,0,cur_size>3?0:1,1,key,2,parsed[0],3,cur_size>1?parsed[1]:"",4,cur_size>2?parsed[2]:"",-1); + + } + free(key); + free(current); + yon_char_parsed_free(parsed,cur_size); + } + yon_char_parsed_free(repos,size); + char *publish = config(REPOPUBLIC_NET); + if (publish) { + + } +} + // standard functions /**config_init() @@ -145,6 +172,22 @@ void on_mirror_remove(GtkWidget *self,main_window *widgets){ } +void on_repo_remove(GtkWidget *self, main_window *widgets){ + dialog_confirmation_data *data = malloc(sizeof(dialog_confirmation_data)); + data->action_text=REMOVE_REPO_WARNING_LABEL; + data->function=(void(*)(void*,void*))on_remove_accept; + data->data = widgets->RepositoriesTree; + yon_confirmation_dialog_call(self,data); +} + +void on_remove_accept(GtkWidget *, GtkWidget *target){ + GtkTreeModel *model=NULL; + GtkTreeIter iter; + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(target)),&model,&iter)) { + gtk_list_store_remove(GTK_LIST_STORE(model),&iter); + } +} + void on_web_publish_edit(GtkWidget *,main_window *widgets){ web_publication_add_window *window = yon_web_publication_add_window_new(); yon_gtk_window_setup(GTK_WINDOW(window->Window),GTK_WINDOW(widgets->Window),ADD_REPO_LABEL,icon_path,"mirror_window"); @@ -219,10 +262,6 @@ void on_mirror_accept(GtkWidget *,dictionary *){ } -void on_remove_accept(GtkWidget *, GtkWidget *){ - -} - repo_add_window *yon_repo_add_window_new(){ GtkBuilder *builder = gtk_builder_new_from_resource(glade_repo_add_path); repo_add_window *window = malloc(sizeof(repo_add_window)); @@ -385,11 +424,16 @@ void yon_main_window_complete(main_window *widgets){ g_signal_connect(G_OBJECT(widgets->RepositoriesCreateButton),"clicked",G_CALLBACK(on_repo_add),widgets); g_signal_connect(G_OBJECT(widgets->WebPublicationAddButton),"clicked",G_CALLBACK(on_web_publish_add),widgets); g_signal_connect(G_OBJECT(widgets->MirrorAddButton),"clicked",G_CALLBACK(on_mirror_add),widgets); + g_signal_connect(G_OBJECT(widgets->RepositoriesDeleteButton),"clicked",G_CALLBACK(on_repo_remove),widgets); + g_signal_connect(G_OBJECT(widgets->WebPublicationRemoveButton),"clicked",G_CALLBACK(on_web_publish_remove),widgets); + g_signal_connect(G_OBJECT(widgets->MirrorRemoveButton),"clicked",G_CALLBACK(on_mirror_remove),widgets); g_signal_connect(G_OBJECT(widgets->RepositoriesTree),"cursor-changed",G_CALLBACK(on_selection_changed),widgets); g_signal_connect(G_OBJECT(widgets->PublicationTree),"cursor-changed",G_CALLBACK(on_selection_changed),widgets); g_signal_connect(G_OBJECT(widgets->WebPublicationTree),"cursor-changed",G_CALLBACK(on_selection_changed),widgets); g_signal_connect(G_OBJECT(widgets->MirrorTree),"cursor-changed",G_CALLBACK(on_selection_changed),widgets); } + yon_load_proceed(YON_CONFIG_LOCAL); + yon_interface_update(widgets); } int main(int argc, char *argv[]){ diff --git a/source/ubl-settings-update.h b/source/ubl-settings-update.h index 75bfae4..1f006dd 100644 --- a/source/ubl-settings-update.h +++ b/source/ubl-settings-update.h @@ -34,14 +34,31 @@ #define LocaleName "ubl-settings-update" #define icon_path "com.ublinux.ubl-settings-update" -#define yon_config_get_custom_command(target) yon_char_unite("ubconfig --source ",target," get system PARAMETERS",NULL) -#define config_get_local_command "ubconfig --source system get system PARAMETERS" -#define config_get_global_command "ubconfig --source global get system PARAMETERS" -#define config_get_default_command "" +#define yon_config_get_custom_command(target) yon_char_unite("ubconfig --source ",target," get update REPOPUBLIC_NET REPOPUBLIC_WEB REPOSITORY[*] REPOPUBLIC_WEB REPOPUBLIC_WEB[*] REPOPUBLIC_CACHE REPOPUBLIC_CACHE[*] AUTOUPDATE AUTOUPDATE[mode] AUTOUPDATE[interval] AUTOUPDATE[repos] AUTOUPDATE[timestamp]",NULL) +#define config_get_local_command "ubconfig --source system get update REPOPUBLIC_NET REPOPUBLIC_WEB REPOSITORY[*] REPOPUBLIC_WEB REPOPUBLIC_WEB[*] REPOPUBLIC_CACHE REPOPUBLIC_CACHE[*] AUTOUPDATE AUTOUPDATE[mode] AUTOUPDATE[interval] AUTOUPDATE[repos] AUTOUPDATE[timestamp]" +#define config_get_global_command "ubconfig --source global get update REPOPUBLIC_NET REPOPUBLIC_WEB REPOSITORY[*] REPOPUBLIC_WEB REPOPUBLIC_WEB[*] REPOPUBLIC_CACHE REPOPUBLIC_CACHE[*] AUTOUPDATE AUTOUPDATE[mode] AUTOUPDATE[interval] AUTOUPDATE[repos] AUTOUPDATE[timestamp]" +#define config_get_default_command "REPOSITORY[*]" #define config_get_global_only_parameters "" #define config_get_local_only_parameters "" +#define REPOSITORY(target) yon_char_unite("REPOSITORY[",target,"]",NULL) +#define REPOSITORY_parameter "REPOSITORY" +#define REPOSITORY_search "REPOSITORY[" + +#define REPOPUBLIC_NET "REPOPUBLIC_NET" +#define REPOPUBLIC_WEB "REPOPUBLIC_WEB" +#define REPOPUBLIC_WEB_search "REPOPUBLIC_WEB[" +#define REPOPUBLIC_WEB_full(target) yon_char_unite("REPOPUBLIC_WEB[",target,"]",NULL) +#define REPOPUBLIC_CACHE "REPOPUBLIC_CACHE" +#define REPOPUBLIC_CACHE_search "REPOPUBLIC_CACHE[" +#define REPOPUBLIC_CACHE_full(target) yon_char_unite("REPOPUBLIC_CACHE[",target,"]",NULL) +#define AUTOUPDATE "AUTOUPDATE" +#define AUTOUPDATE_mode "AUTOUPDATE[mode]" +#define AUTOUPDATE_interval "AUTOUPDATE[interval]" +#define AUTOUPDATE_repos "AUTOUPDATE[repos]" +#define AUTOUPDATE_timestamp "AUTOUPDATE[timestamp]" + typedef char* string; string version_application; @@ -194,6 +211,7 @@ void yon_main_window_complete(main_window *widgets); void on_repo_accept_clicked(GtkWidget *, dictionary *dict); void on_web_publish_accept(GtkWidget *, dictionary *dict); void on_mirror_accept(GtkWidget *,dictionary *dict); +void on_repo_remove(GtkWidget *self, main_window *widgets); void on_remove_accept(GtkWidget *, GtkWidget *target); repo_add_window *yon_repo_add_window_new(); @@ -215,4 +233,6 @@ void on_mirror_configure(GtkWidget *,main_window *widgets); void on_selection_changed(GtkWidget *self, main_window *widgets); +void yon_interface_update(main_window *widgets); + #endif \ No newline at end of file diff --git a/ubl-settings-update-mirror-add.glade b/ubl-settings-update-mirror-add.glade new file mode 100644 index 0000000..6345b00 --- /dev/null +++ b/ubl-settings-update-mirror-add.glade @@ -0,0 +1,218 @@ + + + + + + + True + False + com.ublinux.libublsettingsui-gtk3.zoom-symbolic + + + 500 + 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 + Repository name: + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + + + + False + True + 0 + + + + + True + False + 5 + + + True + False + Repository type: + + + False + True + 0 + + + + + True + False + 5 + + + True + False + + WEB link + Proxy server + Mirrors file + + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + + + + True + True + True + image1 + + + + False + True + 2 + + + + + True + True + 1 + + + + + False + True + 1 + + + + + False + True + 1 + + + + + + + True + False + + + True + False + Add repository + + + + + + + + True + False + 32 + com.ublinux.ubl-settings-repomanager + + + + + Cancel + True + True + True + + + 1 + + + + + Accept + True + True + True + + + end + 2 + + + + + + + diff --git a/ubl-settings-update-mirror-configure.glade b/ubl-settings-update-mirror-configure.glade new file mode 100644 index 0000000..7a710aa --- /dev/null +++ b/ubl-settings-update-mirror-configure.glade @@ -0,0 +1,575 @@ + + + + + + + 1 + 65535 + 1 + 10 + + + 999999999 + 1 + 10 + + + 999999999 + 1 + 10 + + + 999999 + 1 + 10 + + + 999999 + 1 + 10 + + + True + False + com.ublinux.libublsettingsui-gtk3.zoom-symbolic + + + 500 + 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 + Service port: + + + False + True + 0 + + + + + Default + True + True + False + True + + + + False + True + 1 + + + + + True + True + adjustment1 + + + False + True + 2 + + + + + False + True + 0 + + + + + True + False + 5 + + + True + False + Cache directory: + + + False + True + 0 + + + + + Default + True + True + False + True + + + + + False + True + 1 + + + + + True + True + + + True + True + 2 + + + + + True + True + True + image1 + + + + False + True + 3 + + + + + False + True + 1 + + + + + True + False + 5 + + + True + False + Duration of inactivity (in seconds): + + + False + True + 0 + + + + + Default + True + True + False + True + + + + False + True + 1 + + + + + True + True + adjustment2 + + + False + True + 2 + + + + + False + True + 2 + + + + + True + False + 5 + + + True + False + Timeout (in seconds) for loading internel cache: + + + False + True + 0 + + + + + Default + True + True + False + True + + + + False + True + 1 + + + + + True + True + adjustment3 + + + False + True + 2 + + + + + False + True + 3 + + + + + True + False + 5 + + + Work through proxy: + True + True + False + True + + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + + + + False + True + 4 + + + + + True + False + 5 + + + True + False + User agent: + + + False + True + 0 + + + + + Default + True + True + False + True + + + + False + True + 1 + + + + + True + True + + + True + True + 2 + + + + + False + True + 5 + + + + + True + False + 5 + + + True + False + Standard expression for cron: + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + + + + False + True + 6 + + + + + True + False + 5 + + + True + False + The number of consecutie days that systems on the network have not been updated: + + + False + True + 0 + + + + + Default + True + True + False + True + + + + False + True + 1 + + + + + True + True + adjustment4 + + + False + True + 2 + + + + + False + True + 7 + + + + + True + False + 5 + + + True + False + The number of consecutive days wthout an update requested: + + + False + True + 0 + + + + + Default + True + True + False + True + + + + False + True + 1 + + + + + True + True + adjustment5 + + + False + True + 2 + + + + + False + True + 8 + + + + + False + True + 1 + + + + + + + True + False + + + True + False + Add repository + + + + + + + + True + False + 32 + com.ublinux.ubl-settings-repomanager + + + + + Cancel + True + True + True + + + 1 + + + + + Accept + True + True + True + + + end + 2 + + + + + + + diff --git a/ubl-settings-update-repo-add.glade b/ubl-settings-update-repo-add.glade new file mode 100644 index 0000000..e5f558e --- /dev/null +++ b/ubl-settings-update-repo-add.glade @@ -0,0 +1,400 @@ + + + + + + + True + False + com.ublinux.libublsettingsui-gtk3.zoom-symbolic + + + 500 + False + True + com.ublinux.ubl-settings-repomanager + + + True + False + vertical + + + True + False + vertical + + + + + + False + True + 0 + + + + + True + False + 5 + 5 + 5 + 5 + vertical + 5 + + + Enabled + True + True + False + True + + + False + True + 0 + + + + + True + False + 3 + 5 + + + True + False + Repository name: + + + False + True + 0 + + + + + True + True + 100 + + + True + True + 1 + + + + + False + True + 1 + + + + + True + False + 3 + 5 + + + True + False + Source: + + + False + True + 0 + + + + + True + False + 0 + + file:// + ftp:// + http:// + https:// + Configuration + + + + False + True + 1 + + + + + True + True + + + True + True + 2 + + + + + True + True + True + image1 + + + + False + True + 3 + + + + + False + True + 2 + + + + + True + False + 3 + 5 + + + True + False + Sign level: + + + False + True + 0 + + + + + True + False + 0 + + Never (Signature verification will not be performed) + Optional + Required + TrustedOnly + TrustAll + + + + True + True + 1 + + + + + True + False + 0 + + PackageNever + DatabaseNever + PackageOptional + DatabaseOptional + PackageRequired + DatabaseRequired + Package TrustedOnly + Database TrustedOnly + Package TrustAll + Database TrustAll + + + + True + True + 2 + + + + + False + True + 3 + + + + + True + False + 0.019999999552965164 + in + + + True + False + 5 + 5 + 5 + + + True + False + vertical + 5 + + + Default + True + True + False + True + + + False + True + 0 + + + + + Enable repository update + True + True + False + True + + + False + True + 1 + + + + + Enable repository search + True + True + False + True + + + False + True + 2 + + + + + Enable installation of packages from this repository during --sync operation + True + True + False + True + + + False + True + 3 + + + + + Allow this repository to be a valid source of packages when running --sysupgrade + True + True + False + True + + + False + True + 4 + + + + + + + + + True + False + Usage level + + + + + True + True + 4 + + + + + True + True + 1 + + + + + + + True + False + + + True + False + Add repository + + + + + + + + True + False + 32 + com.ublinux.ubl-settings-repomanager + + + + + Cancel + True + True + True + + + 1 + + + + + Accept + True + True + True + + + end + 2 + + + + + + diff --git a/ubl-settings-update-web-publication-add.glade b/ubl-settings-update-web-publication-add.glade new file mode 100644 index 0000000..1a4130e --- /dev/null +++ b/ubl-settings-update-web-publication-add.glade @@ -0,0 +1,458 @@ + + + + + + + True + False + com.ublinux.libublsettingsui-gtk3.zoom-symbolic + + + + 500 + False + True + com.ublinux.ubl-settings-repomanager + + + True + False + vertical + + + True + False + vertical + + + + + + False + True + 0 + + + + + True + False + 5 + 5 + 5 + 5 + vertical + 5 + + + Enable publishing of local repository as WEB resource + True + True + False + True + + + False + True + 0 + + + + + True + False + 3 + 5 + + + True + False + Path to publication directory: + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + + + + True + True + True + image1 + + + + False + True + 2 + + + + + False + True + 1 + + + + + True + True + 3 + in + + + True + True + liststore1 + + + + + + Chosen + + + + + + + + Repository name + + + + + + + + + + False + True + 2 + + + + + True + False + 3 + 5 + + + True + False + Port: + + + False + True + 0 + + + + + True + True + False + True + + + + + + False + True + 1 + + + + + True + True + + + True + True + 2 + + + + + False + True + 3 + + + + + True + False + 0.019999999552965164 + in + + + True + False + 5 + 5 + 5 + + + Enable WEB file browser + True + True + False + True + + + + + + + True + False + Publishing parameters + + + + + False + True + 4 + + + + + True + False + 0.019999999552965164 + in + + + True + False + 5 + 5 + 5 + + + True + False + vertical + 5 + + + True + False + 5 + + + True + False + Username: + + + False + True + 0 + + + + + True + True + False + True + + + + + + False + True + 1 + + + + + True + True + + + True + True + 2 + + + + + False + True + 0 + + + + + True + False + 5 + + + True + False + User password: + + + False + True + 0 + + + + + True + True + False + True + + + + + + + False + True + 1 + + + + + True + False + 0 + + Not encrypted + Encrypted with SHA256 + Encrypted with SHA512 + + + + False + True + 2 + + + + + True + True + + + True + True + 3 + + + + + False + True + 1 + + + + + + + + + True + False + Authorization parameters + + + + + False + True + 5 + + + + + False + True + 1 + + + + + + + True + False + + + True + False + Add repository + + + + + + + + True + False + 32 + com.ublinux.ubl-settings-repomanager + + + + + Cancel + True + True + True + + + 1 + + + + + Accept + True + True + True + + + end + 2 + + + + + + diff --git a/ubl-settings-update.glade b/ubl-settings-update.glade index 5ebde48..c98ea53 100644 --- a/ubl-settings-update.glade +++ b/ubl-settings-update.glade @@ -25,458 +25,135 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - False - False - True - center - com.ublinux.ubl-settings-update - dialog - True - ubl-settings-update - 1.1 - Copyright © 2022 - 2023, UBSoft LLC - Update confugurator - https://wiki.ublinux.ru/ru/Программное_обеспечение/Программы_и_утилиты/Все/ubl-settings-update - 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-update - True - gpl-2-0 - - - True - False - vertical - 2 - - - False - end - - - False - False - 1 - - - - - - - True - False - True - - - True - False - 5 - 5 - 5 - 5 - 2 - System update - - - - - - - + + + + + + + + + + + + + + + + + + - + True False - - - 90 - True - False - 5 - 5 - 5 - 5 - 6 - 6 - 69 - com.ublinux.ubl-settings-update - - - False - True - 0 - - - - - True - False - - - True - False - - - True - False - vertical - - - 255 - True - False - end - System update parameter configuration - 0 - - - - - - - - True - True - 0 - - - - - 255 - True - False - start - hsrdtfhbfn - 0 - - - - - - - - True - True - 1 - - - - - False - True - 0 - - - - - True - True - 0 - - - - - True - True - 1 - - + com.ublinux.libublsettingsui-gtk3.sync-symbolic - + True False - process-stop-symbolic + com.ublinux.libublsettingsui-gtk3.trash-symbolic - + True False - emblem-ok-symbolic + com.ublinux.libublsettingsui-gtk3.sync-symbolic - + + True False - System update - False - True - com.ublinux.ubl-settings-update - - - True - False - 5 - 5 - 5 - 5 - vertical - 5 - - - True - False - 5 - - - True - False - Adress: - 0 - - - False - True - 0 - - - - - True - True - - - True - True - 1 - - - - - False - True - 0 - - - - - True - False - vertical - 5 - - - True - False - 5 - - - True - False - Distribution: - 0 - - - False - True - 0 - - - - - True - True - - - True - True - 1 - - - - - False - True - 1 - - - - - False - True - 1 - - - - - True - False - - - True - False - - - True - True - 0 - - - - - True - False - 5 - True - - - Cancel - True - True - True - image1 - - - False - True - 0 - - - - - Save - True - True - True - image2 - - - False - True - 1 - - - - - False - True - end - 1 - - - - - False - True - end - 2 - - - - + com.ublinux.libublsettingsui-gtk3.increase-symbolic - - - - - + + True + False + document-edit-symbolic - + + True + False + com.ublinux.libublsettingsui-gtk3.trash-symbolic + + True False - dropboxstatus-logo + com.ublinux.libublsettingsui-gtk3.settings-symbolic - + True False - 17 - view-refresh-symbolic + com.ublinux.libublsettingsui-gtk3.sync-symbolic - - Check for updates + True - True - True - end - start - image4 + False + com.ublinux.libublsettingsui-gtk3.sync-symbolic True False - value-increase-symbolic + com.ublinux.libublsettingsui-gtk3.increase-symbolic True False - error-correct-symbolic + document-edit-symbolic True False - user-trash-symbolic + com.ublinux.libublsettingsui-gtk3.trash-symbolic True False - process-stop-symbolic + com.ublinux.libublsettingsui-gtk3.increase-symbolic True False - emblem-ok-symbolic + document-edit-symbolic - + + True False - False - 450 - dialog-question-symbolic + 5 + 5 + 5 + 5 + 5 + 5 + True + True + vertical - + True False - 5 - 5 - 5 - 5 - vertical - 10 - + True - False - - - True - False - start - 20 - 20 - dialog-question-symbolic - 6 - - - False - True - 0 - - + True + 3 True False + 5 + 5 + 5 + 5 vertical + 5 - + + Automatic update True - False - start - 10 - 5 - Would you like to read documentation in the Web? - True + True + False 0 - - - - + True False @@ -485,20 +162,41 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - + True False - start - start - 10 - 10 - You will be redirected to documentation website where documentation is -translated and supported by community. - True - 0 - + 5 + + + True + False + Update mode: + 0 + + + False + True + 0 + + + + + True + False + 0 + + Default + First update all modules and then the system + Update only modules + Update everything in the order of the specified repositories + + + + True + True + 1 + + False @@ -507,281 +205,78 @@ translated and supported by community. - - Always redirect to online documentation - True - True - False - end - True - - - - False - True - end - 2 - - - - - - True - True - 1 - - - - - - True - True - 0 - - - - - True - False - 30 - True - - - Cancel - True - True - True - image8 - - - - True - True - 0 - - - - - Read Online - True - True - True - image9 - - - - True - True - 1 - - - - - False - True - 1 - - - - - - - True - False - True - - - True - False - UBLinux Settings - - - - - - - - - - - - - - - - - - - - 800 - 600 - False - 800 - 600 - com.ublinux.ubl-settings-update - - - True - False - vertical - - - True - False - vertical - - - True - False - - - True - False - 5 - 5 - 5 - 5 - 5 - 5 - 25 - - - False - True - 0 - - - - - True - False - start - 5 - 5 - 5 - 5 - 6 - 6 - - - - - - - False - True - 1 - - - - - False - True - 0 - - - - - True - False - vertical - - - 81 + True False + 5 + + + True + False + Update interval: + 0 + + + False + True + 0 + + - + True False - start + 0 + + Default + First update all modules and then the system + Update only modules + Update everything in the order of the specified repositories + - -1 + True + True + 1 False True - 0 + 2 - - - False - True - 1 - - - - - True - False - 5 - 5 - 5 - 5 - 5 - 5 - True - True - vertical - + True False + 0 + none - + True - True - 3 + False + 5 + 5 + 5 + 5 True False - 5 - 5 - 5 - 5 vertical 5 - - - Hide icon if no updates found - True - True - False - 0 - True - - - False - True - 0 - - True False 5 - + True False - Update checking frequency - 0 + Repository list: False @@ -790,90 +285,17 @@ translated and supported by community. - + True False 0 + + Default + Choose + - False - True - 1 - - - - - False - True - 1 - - - - - Download updates automatically - True - True - False - 0 - True - - - False - True - 2 - - - - - - - True - False - General settings - - - False - - - - - True - False - 5 - 5 - 5 - 5 - vertical - 5 - - - True - False - 5 - - - Activate AUR - True - True - False - True - - - False - True - 0 - - - - - Activate UBUR - True - True - False - True - - - False + True True 1 @@ -886,181 +308,35 @@ translated and supported by community. - + True - False - 5 - 5 - 5 + True + in - + True True - liststore1 + UpdateRepoList - - Enabled + + Chosen - - URI - - - - 1 - - - - - - - Distribution + + Repository - - 2 - - - - - - - True - True - 0 - - - - - True - False - start - vertical - 15 - - - True - True - True - - - True - False - True - False - True - up - - - - - - - - False - True - 0 - - - - - True - True - True - - - True - False - True - False - True - - - - - - - - - - False - True - 1 - - - - - True - True - True - image5 - - - - False - True - 2 - - - - - True - True - True - image6 - - - - False - True - 3 - - - - - True - True - True - image7 - - - - False - True - 4 - - - False - True - 1 - @@ -1070,267 +346,612 @@ translated and supported by community. - - 1 - - - - - True - False - Repositories - - - 1 - False - - - - True - False - 5 - 5 - 5 - 5 - vertical - 5 - - - True - False - 5 - - - True - False - Package manager: - 0 - - - False - True - 0 - - + + + + + True + False + Repositories from which the update will occur + + + + + True + True + 3 + + + + + + + True + False + Update + + + False + + + + + True + False + 5 + 5 + 5 + 5 + vertical + 5 + + + True + False + Repository connection configuration + 0 + + + + + + + + False + True + 0 + + + + + True + False + vertical + 5 + + + Manage repository list + True + True + False + True + + + False + True + 0 + + + + + Disable system repositories + True + True + False + True + + + False + True + 1 + + + + + False + True + 1 + + + + + True + False + 3 + 5 + + + True + False + start + vertical + 5 + + + True + True + True + image1 + + + + False + True + 0 + + + + + True + False + True + True + + + True + False + True + False + True + up - - True - True - - - True - True - 1 - + + - - False - True - 0 - + + + + False + True + 1 + + + + + True + False + True + True - + True - False - 5 + False + True + False + True - - True - False - Update command: - 0 - - - False - True - 0 - + + + + + + + + + False + True + 2 + + + + + True + True + True + image5 + + + + False + True + 3 + + + + + True + False + True + True + image6 + + + + False + True + 4 + + + + + True + False + True + True + image7 + + + + False + True + 5 + + + + + False + True + 0 + + + + + True + True + in + + + True + True + ReposList + 0 + + + + + + Enabled + + + + 0 + + + + + + Reposiory - - True - True - - - True - True - 1 - + + + 1 + - - False - True - 1 - - - True - False - 5 + + Source - - True - False - Cache clean command: - 0 - - - False - True - 0 - + + + 2 + + + + + + Signature level - - True - True - - - True - True - 1 - + + + 3 + - - False - True - 2 - - - True - False - 5 + + Usage level - + + + 4 + + + + + + + + + True + True + 1 + + + + + True + True + 2 + + + + + 1 + + + + + True + False + Repositories + + + 1 + False + + + + + True + False + 5 + 5 + 5 + 5 + vertical + 5 + + + True + False + Repository connection configuration + 0 + + + + + + + + False + True + 0 + + + + + Connect and publish + True + True + False + True + + + False + True + 1 + + + + + Recieve DB packages from shared network + True + True + False + True + + + False + True + 2 + + + + + True + False + 3 + 5 + + + True + False + vertical + + + True + True + True + image2 + + + + False + True + 0 + + + + + False + True + 0 + + + + + True + True + in + + + True + True + PublicationList + + + + + + Chosen + + + + + + + Repository name - - Launch package manager - True - True - True - image3 - - - False - True - end - 1 - + - - False - True - 3 - - - 2 - - - - - True - False - Extra - - - 2 - False - - -1 + True + True + 1 True True - 0 + 3 - False - True 2 - - - True - True - 0 - - - - - - - True - False - True - - - True - False - 5 - 5 - 5 - 5 - 2 - System update - - - - - - - - True - False - 5 - 5 - 5 - 5 - 6 - 6 - 32 - com.ublinux.ubl-settings-update - - - - - True - False + + + True + False + Publication + + + 2 + False + + - + True - True - False - True - menu1 + False + 5 + 5 + 5 + 5 + vertical + 5 + + + True + False + Repository connection configuration + 0 + + + + + + + + False + True + 0 + + True False + 5 - + True False - Load + vertical + 5 + + + True + True + True + image3 + + + + False + True + 0 + + + + + True + True + True + image8 + + + + False + True + 1 + + + + + True + False + True + True + image9 + + + + False + True + 2 + + + + + True + False + True + True + image10 + + + + False + True + 3 + + False @@ -1339,51 +960,227 @@ translated and supported by community. - + True - False - pan-down-symbolic + True + in + + + True + True + WebPublicationList + + + + + + Enabled + + + + + Source + + + + + Repository + + + + + Reviewer + + + + + Port + + + + + Name + + + + + Password/Hash type + + + + + Password/Password hash + + + + - False + True True 1 + + True + True + 1 + - False - True - 0 + 3 + + + + + True + False + WEB-publication + + + 3 + False - - - 2 - - - - - True - False - + True - True - False - True - menu3 + False + 5 + 5 + 5 + 5 + vertical + 5 + + + True + False + Repository connection configuration + 0 + + + + + + + + False + True + 0 + + + + + Publish lazy mirror + True + True + False + True + + + False + True + 1 + + True False + 5 - + True False - Save + 3 + vertical + 5 + + + True + True + True + image11 + + + + False + True + 0 + + + + + True + True + True + image12 + + + + False + True + 1 + + + + + True + False + True + True + image13 + + + + False + True + 2 + + + + + True + False + True + True + image14 + + + + False + True + 3 + + + + + True + False + True + True + image15 + + + + False + True + 4 + + False @@ -1392,68 +1189,87 @@ translated and supported by community. - + True - False - pan-down-symbolic + True + in + + + True + True + MirrorList + + + + + + Repository + + + + + + + + Type + + + + + + + + Resource URL + + + + + + + - False + True True 1 + + True + True + 2 + - False - True - 0 + 4 - - + + True - True - True - False - True - True - menu2 - none - - - - + False + Mirror publication - False - True - 1 + 4 + False - end - 3 + -1 - + + True + True + 0 + - - - - - - - True False From 15aee5ac1bd77f940a50100165667c881f8a8ae3 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Thu, 10 Oct 2024 18:05:57 +0600 Subject: [PATCH 3/8] Loading interface update WIP --- source/ubl-settings-update.c | 104 ++++++++++++++++- source/ubl-settings-update.h | 6 +- ubl-settings-update.css | 33 +++--- ubl-settings-update.glade | 211 ++++++++++++++++++++++++++--------- 4 files changed, 284 insertions(+), 70 deletions(-) diff --git a/source/ubl-settings-update.c b/source/ubl-settings-update.c index a1c7e9a..8542fed 100644 --- a/source/ubl-settings-update.c +++ b/source/ubl-settings-update.c @@ -41,6 +41,17 @@ void yon_load_proceed(YON_CONFIG_TYPE type){ void yon_interface_update(main_window *widgets){ int size; + char *repo_config = config(REPOSITORY_parameter); + if (!yon_char_is_empty(repo_config)){ + if (!strcmp(repo_config,"disable")){ + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->RepositoriesRepoListConfigurationCheck),0); + } else if (!strcmp(repo_config,"enable")){ + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->RepositoriesRepoListConfigurationCheck),1); + }else if (!strcmp(repo_config,"only")){ + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->RepositoriesDisableSystemReposCheck),1); + } + } + config_str repos = yon_config_get_all_by_key(REPOSITORY_search,&size); GtkTreeIter iter; for (int i=0;iPublicationConnectPublicCheck),1); + } + if (cur_size>1&&!strcmp(parsed[1],"db")){ + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->RecieveDBFromNetCheck),1); + } + if (cur_size>2){ + for (int i=2;iPublicationList,&iter); + gtk_list_store_set(widgets->PublicationList,&iter,1,parsed[i],-1); + } + } + yon_char_parsed_free(parsed,cur_size); + } + } + + char *mirror = config(REPOPUBLIC_CACHE); + if (!yon_char_is_empty(mirror)){ + if (!strcmp(mirror,"enable")||!strcmp(mirror,"yes")){ + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->MirrorPublicCheck),1); + } else if (!strcmp(mirror,"disable")||!strcmp(mirror,"no")||!strcmp(mirror,"none")){ + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->MirrorPublicCheck),0); + } } + + // config_str mirror_list = yon_config_get_all_by_key(REPOPUBLIC_CACHE_search,&size); + // if (size){ + // for (int i=0;iMirrorList,&iter); + // gtk_list_store_set(widgets->MirrorList,&iter,,-1); + // } + // } + // } + + char *autoupdate_config = config(AUTOUPDATE); + if (!yon_char_is_empty(autoupdate_config)&&!strcmp(autoupdate_config,"enable")){ + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->AutoUpdateCheck),1); + } + + autoupdate_config = config(AUTOUPDATE_mode); + if (!yon_char_is_empty(autoupdate_config)){ + if (!strcmp(autoupdate_config,"modsys")){ + gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->UpdateModeCombo),1); + } else if (!strcmp(autoupdate_config,"modules")){ + gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->UpdateModeCombo),2); + } else if (!strcmp(autoupdate_config,"system")){ + gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->UpdateModeCombo),3); + } + } + + autoupdate_config = config(AUTOUPDATE_interval); + if (!yon_char_is_empty(autoupdate_config)){ + if (!strcmp(autoupdate_config,"boot")){ + gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->UpdateIntervalCombo),0); + } else { + if (strstr(autoupdate_config,"min")){ + gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->UpdateIntervalCombo),1); + } else if (autoupdate_config[strlen(autoupdate_config)-1]=='h'){ + gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->UpdateIntervalCombo),2); + } else if (autoupdate_config[strlen(autoupdate_config)-1]=='d'){ + gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->UpdateIntervalCombo),3); + } else if (autoupdate_config[strlen(autoupdate_config)-1]=='M'){ + gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->UpdateIntervalCombo),4); + } + gtk_spin_button_set_value(GTK_SPIN_BUTTON(widgets->UpdateIntervalSpin),atol(autoupdate_config)); + } + } + } // standard functions @@ -385,8 +481,10 @@ void yon_main_window_complete(main_window *widgets){ // Custom widgets configuration { widgets->AutoUpdateCheck = yon_gtk_builder_get_widget(builder,"AutoUpdateCheck"); - widgets->UpdateCheckFreqCombo = yon_gtk_builder_get_widget(builder,"UpdateCheckFreqCombo"); - widgets->UpdateCheckIntervalCombo = yon_gtk_builder_get_widget(builder,"UpdateCheckIntervalCombo"); + widgets->UpdateModeCombo = yon_gtk_builder_get_widget(builder,"UpdateModeCombo"); + widgets->UpdateIntervalDefaultCheck = yon_gtk_builder_get_widget(builder,"UpdateIntervalDefaultCheck"); + widgets->UpdateIntervalSpin = yon_gtk_builder_get_widget(builder,"UpdateIntervalSpin"); + widgets->UpdateIntervalCombo = yon_gtk_builder_get_widget(builder,"UpdateIntervalCombo"); widgets->UpdateRepoListCombo = yon_gtk_builder_get_widget(builder,"UpdateRepoListCombo"); widgets->UpdateRepoTree = yon_gtk_builder_get_widget(builder,"UpdateRepoTree"); widgets->RepositoriesRepoListConfigurationCheck = yon_gtk_builder_get_widget(builder,"RepositoriesRepoListConfigurationCheck"); diff --git a/source/ubl-settings-update.h b/source/ubl-settings-update.h index 1f006dd..a7000c6 100644 --- a/source/ubl-settings-update.h +++ b/source/ubl-settings-update.h @@ -72,8 +72,10 @@ typedef struct { typedef struct { template_window_fields GtkWidget *AutoUpdateCheck; - GtkWidget *UpdateCheckFreqCombo; - GtkWidget *UpdateCheckIntervalCombo; + GtkWidget *UpdateModeCombo; + GtkWidget *UpdateIntervalDefaultCheck; + GtkWidget *UpdateIntervalSpin; + GtkWidget *UpdateIntervalCombo; GtkWidget *UpdateRepoListCombo; GtkWidget *UpdateRepoTree; GtkListStore *UpdateRepoList; diff --git a/ubl-settings-update.css b/ubl-settings-update.css index 8687d4a..3873397 100644 --- a/ubl-settings-update.css +++ b/ubl-settings-update.css @@ -26,7 +26,7 @@ background:transparent; } .menuitembottom{ margin-top:0px; - margin-bottom:3px; + margin-bottom:4px; border-color:inherit; border-left-width:inherit; border-right-width:inherit; @@ -46,56 +46,59 @@ background:transparent; border-left-width:inherit; border-right-width:inherit; } - .menuitemtop *{ + .menuitemtop>*{ margin:2px 2px 0 2px; - padding: 5px 10px 3px 5px; + padding: 3px 10px 3px 5px; border:transparent; } - .menuitemmiddle *{ + .menuitemmiddle>*{ margin:0 2px 0 2px; padding: 3px 10px 3px 5px; border:transparent; } - .menuitembottom *{ + .menuitembottom>*{ margin:0 2px 2px 2px; - padding: 3px 10px 5px 5px; + padding: 3px 10px 3px 5px; } .menuitemtop:hover { - background:@theme_bg_color; + background:@theme_base_color; border-color:inherit; border-top-width:inherit; border-left-width:inherit; border-right-width:inherit; } .menuitemmiddle:hover { - background:@theme_bg_color; + background:@theme_base_color; border-color:inherit; border-left-width:inherit; border-right-width:inherit; } .menuitembottom:hover { - background:@theme_bg_color; + background:@theme_base_color; border-color:inherit; border-bottom-width:0px; border-left-width:inherit; border-right-width:inherit; } - .menuitemtop:hover* { + .menuitemtop:hover>* { margin:2px 2px 0 2px; - padding: 5px 10px 3px 5px; + padding: 3px 10px 3px 5px; + /* padding: 5px 0 3px 5px; */ background:@theme_selected_bg_color; border-radius:2px; } - .menuitemmiddle:hover* { - margin:0 2px 0 2px; + .menuitemmiddle:hover>* { + margin:0 2px 0px 2px; padding: 3px 10px 3px 5px; + /* padding: 3px 0px 3px 5px; */ background:@theme_selected_bg_color; border-radius:2px; } - .menuitembottom:hover* { + .menuitembottom:hover>* { margin:0 2px 2px 2px; - padding: 3px 10px 5px 5px; + padding: 3px 10px 3px 5px; + /* padding: 3px 0px 5px 5px; */ background:@theme_selected_bg_color; border-radius:2px; } diff --git a/ubl-settings-update.glade b/ubl-settings-update.glade index c98ea53..9e8e317 100644 --- a/ubl-settings-update.glade +++ b/ubl-settings-update.glade @@ -25,8 +25,24 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - + + + + + + + + + + + + + + + + + + @@ -44,6 +60,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + 100 + 1 + 10 + True @@ -115,6 +136,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. False document-edit-symbolic + True False @@ -180,7 +202,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - + True False 0 @@ -223,19 +245,58 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - + True False - 0 - - Default - First update all modules and then the system - Update only modules - Update everything in the order of the specified repositories - + 5 + + + Default + True + True + False + True + + + False + True + 0 + + + + + True + True + adjustment1 + + + False + True + 1 + + + + + True + False + 0 + + Boot + Minutes + Hours + Days + Months + + + + False + True + 2 + + - True + False True 1 @@ -251,8 +312,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. True False - 0 - none + 0.019999999552965164 + in True @@ -804,6 +865,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Chosen + + 0 + @@ -812,6 +876,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Repository name + + 1 + @@ -960,59 +1027,94 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - + True - True - in + False + vertical - + True True - WebPublicationList + liststore1 - - Enabled - + - Source - - - - - Repository - - - - - Reviewer - - - - - Port - - - - - Name - - - - - Password/Hash type + Authtorization parameters + + + False + True + 0 + + + + + True + True + in - - Password/Password hash + + True + True + WebPublicationList + + + + + + Enabled + + + + + Storage + + + + + Chosen repositories + + + + + Reviewer + + + + + Port + + + + + Name + + + + + Password/Hash type + + + + + Password/Password hash + + + + True + True + 1 + @@ -1206,6 +1308,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Repository + + 0 + @@ -1214,6 +1319,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Type + + 1 + @@ -1222,6 +1330,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Resource URL + + 2 + From 7c6244f5ba47f4f8436eb6deeef6a1146f465a58 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Mon, 14 Oct 2024 18:05:01 +0600 Subject: [PATCH 4/8] Saving windows WIP --- gresource.xml | 1 + source/CMakeLists.txt | 1 + source/ubl-settings-update.c | 100 +++++++- source/ubl-settings-update.h | 10 + ubl-settings-update-mirror-add.glade | 225 +++++++++++++----- ubl-settings-update-mirror-path-add.glade | 72 ++++++ ubl-settings-update-repo-add.glade | 30 +-- ubl-settings-update-web-publication-add.glade | 53 ++--- ubl-settings-update.css | 6 + ubl-settings-update.glade | 70 +++++- 10 files changed, 444 insertions(+), 124 deletions(-) create mode 100644 ubl-settings-update-mirror-path-add.glade diff --git a/gresource.xml b/gresource.xml index ad5e3f1..f736816 100644 --- a/gresource.xml +++ b/gresource.xml @@ -5,6 +5,7 @@ ubl-settings-update-repo-add.glade ubl-settings-update-web-publication-add.glade ubl-settings-update-mirror-add.glade + ubl-settings-update-mirror-path-add.glade ubl-settings-update-mirror-configure.glade diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 537cbbf..4fa7a4d 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -35,6 +35,7 @@ set(DEPENDFILES ../ubl-settings-update-repo-add.glade ../ubl-settings-update-web-publication-add.glade ../ubl-settings-update-mirror-add.glade + ../ubl-settings-update-mirror-path-add.glade ../ubl-settings-update-mirror-configure.glade ../gresource.xml ../ubl-settings-update-banner.png diff --git a/source/ubl-settings-update.c b/source/ubl-settings-update.c index 8542fed..f957b59 100644 --- a/source/ubl-settings-update.c +++ b/source/ubl-settings-update.c @@ -160,6 +160,43 @@ void yon_interface_update(main_window *widgets){ } } + config_str web_publish = yon_config_get_all_by_key(REPOPUBLIC_WEB_search,&size); + for (int i=0;iWebPublicationList,&iter); + char *cur = yon_char_new(web_publish[i]); + char *key = yon_char_divide_search(cur,"=",-1); + free(yon_char_divide_search(key,"[",-1)); + key[strlen(key)-1]='\0'; + char *path = yon_char_divide_search(key,":",-1); + int repos_size; + config_str repos = yon_char_parse(key,&repos_size,","); + + gtk_list_store_set(widgets->WebPublicationList,&iter,1,path,2,yon_char_parsed_to_string(repos,repos_size,"\n"),-1); + int cur_size; + config_str parsed = yon_char_parse(cur,&cur_size,":"); + if (cur_size){ + if (!strcmp(parsed[0],"enable")||!strcmp(parsed[0],"yes")){ + gtk_list_store_set(widgets->WebPublicationList,&iter,0,1,-1); + } else if (!strcmp(parsed[0],"disable")||!strcmp(parsed[0],"no")||!strcmp(parsed[0],"none")) { + gtk_list_store_set(widgets->WebPublicationList,&iter,0,0,-1); + } + if (cur_size>1&&!strcmp(parsed[1],"listing")){ + + } + if (cur_size>2&&!yon_char_is_empty(parsed[2])){ + gtk_list_store_set(widgets->WebPublicationList,&iter,4,parsed[2],-1); + } + if (cur_size>3&&!yon_char_is_empty(parsed[3])){ + gtk_list_store_set(widgets->WebPublicationList,&iter,5,parsed[3],-1); + } + if (cur_size>4&&!yon_char_is_empty(parsed[4])){ + gtk_list_store_set(widgets->WebPublicationList,&iter,6,parsed[4],-1); + } + if (cur_size>5&&!yon_char_is_empty(parsed[5])){ + gtk_list_store_set(widgets->WebPublicationList,&iter,7,parsed[5],-1); + } + } + } } // standard functions @@ -318,14 +355,15 @@ void on_mirror_configure(GtkWidget *,main_window *widgets){ void on_repo_accept_clicked(GtkWidget *, dictionary *dict){ // main_window *widgets = yon_dictionary_get_data(dict->first,main_window*); repo_add_window *window = yon_dictionary_get_data(dict->first->next,repo_add_window*); - // int enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->EnabledCheck)); + + int enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->EnabledCheck)); const char *repo_name = gtk_entry_get_text(GTK_ENTRY(window->RepoNameEntry)); if (yon_char_is_empty(repo_name)){ yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); yon_ubl_status_highlight_incorrect(window->RepoNameEntry); return; } - // int source_mode = gtk_combo_box_get_active(GTK_COMBO_BOX(window->RepoSourceCombo)); + char *source_mode = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(window->RepoSourceCombo)); const char *source_path = gtk_entry_get_text(GTK_ENTRY(window->RepoSourceEntry)); if (yon_char_is_empty(source_path)){ yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); @@ -333,28 +371,70 @@ void on_repo_accept_clicked(GtkWidget *, dictionary *dict){ return; } - // int sign_level_package = gtk_combo_box_get_active(GTK_COMBO_BOX(window->RepoSignCheckCombo)); - // int sign_level_condiition = gtk_combo_box_get_active(GTK_COMBO_BOX(window->RepoSignConditionCombo)); + char *sign_level_package = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(window->RepoSignCheckCombo)); + char *sign_level_condiition = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(window->RepoSignConditionCombo)); // int usage_level_default = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->UsageDefaultCheck)); // int usage_level_enable_update = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->UsageEnableUpdateCheck)); // int usage_level_enable_search = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->UsageEnableSearchCheck)); // int usage_level_enable_install = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->UsageEnableInsallCheck)); // int usage_level_sysupgrade = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->UsageSysupgradeCheck)); + + char *final = yon_char_unite(source_mode,source_path,";",sign_level_package,",",sign_level_condiition,";",enabled?"":"disable",NULL); + + yon_config_register(REPOSITORY(repo_name),REOSITORY_command(repo_name),final); + gtk_widget_destroy(window->Window); free(window); } -void on_web_publish_accept(GtkWidget *, dictionary *){ +void on_web_publish_accept(GtkWidget *, dictionary *dict){ // main_window *widgets = yon_dictionary_get_data(dict->first,main_window*); - // repo_add_window *window = yon_dictionary_get_data(dict->first->next,repo_add_window*); + web_publication_add_window *window = yon_dictionary_get_data(dict->first->next,web_publication_add_window*); + int enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->EnablePublishCheck)); + // char *path = (char*)gtk_entry_get_text(GTK_ENTRY(window->PathEntry)); + int port_enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->PortCheck)); + char *port = (char*)gtk_entry_get_text(GTK_ENTRY(window->PortEntry)); + int enable_browser = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->EnableWebFileBrowserCheck)); + + int username_check = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->UsernameCheck)); + char *username = (char*)gtk_entry_get_text(GTK_ENTRY(window->UsernameEntry)); + char *user_password = (char*)gtk_entry_get_text(GTK_ENTRY(window->UserPasswordEntry)); + + char *name = ""; + char *final = yon_char_unite(enabled?"enable":"disable",":",enable_browser?"listing":"",":",port_enabled?port:"",":",username_check?username:"",username_check?user_password:"",NULL); + yon_config_register(REPOPUBLIC_WEB_full(name),REPOPUBLIC_WEB_command(name),final); } void on_mirror_accept(GtkWidget *,dictionary *){ // main_window *widgets = yon_dictionary_get_data(dict->first,main_window*); - // repo_add_window *window = yon_dictionary_get_data(dict->first->next,repo_add_window*); + // mirror_add_window *window = yon_dictionary_get_data(dict->first->next,mirror_add_window*); + // char *name = (char*)gtk_entry_get_text(GTK_ENTRY(window->NameEntry)); + // char *path = (char*)gtk_entry_get_text(GTK_ENTRY(window->TypeEntry)); +} + +void on_mirror_path_removed(GtkWidget *, GtkWidget *target){ + if (GTK_IS_WIDGET(target)){ + gtk_widget_destroy(target); + } +} + +void on_mirror_path_add(GtkWidget *, mirror_add_window *window){ + const char *target = gtk_entry_get_text(GTK_ENTRY(window->TypeEntry)); + if (yon_char_is_empty(target)){ + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect(window->TypeEntry); + return; + } + char *type = (char*)gtk_combo_box_get_active_id(GTK_COMBO_BOX(window->TypeCombo)); + char *full_name = yon_char_unite(type,"@",target,NULL); + gtk_entry_set_text(GTK_ENTRY(window->TypeEntry),""); + GtkBuilder *builder = gtk_builder_new_from_resource(glade_mirror_path_add_path); + gtk_box_pack_start(GTK_BOX(window->PathBox),yon_gtk_builder_get_widget(builder,"PathRemovalBox"),0,0,5); + gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(builder,"PathLabel")),full_name); + g_signal_connect(gtk_builder_get_object(builder,"PathRemoveButton"),"clicked",G_CALLBACK(on_mirror_path_removed),gtk_builder_get_object(builder,"PathRemovalBox")); } @@ -454,10 +534,16 @@ mirror_add_window *yon_mirror_add_window_new(){ window->TypeCombo = yon_gtk_builder_get_widget(builder,"TypeCombo"); window->TypeEntry = yon_gtk_builder_get_widget(builder,"TypeEntry"); window->TypeButton = yon_gtk_builder_get_widget(builder,"TypeButton"); + window->AddButton = yon_gtk_builder_get_widget(builder,"AddButton"); window->AcceptButton = yon_gtk_builder_get_widget(builder,"AcceptButton"); window->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton"); window->HeadLabel = yon_gtk_builder_get_widget(builder,"HeadLabel"); + window->PathBox = yon_gtk_builder_get_widget(builder,"PathBox"); + window->PathRemovalBox = yon_gtk_builder_get_widget(builder,"PathRemovalBox"); + window->PathRemoveButton = yon_gtk_builder_get_widget(builder,"PathRemoveButton"); + window->PathLabel = yon_gtk_builder_get_widget(builder,"PathLabel"); + g_signal_connect(G_OBJECT(window->AddButton),"clicked",G_CALLBACK(on_mirror_path_add),window); g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); gtk_widget_show(window->Window); diff --git a/source/ubl-settings-update.h b/source/ubl-settings-update.h index a7000c6..2332c52 100644 --- a/source/ubl-settings-update.h +++ b/source/ubl-settings-update.h @@ -26,6 +26,7 @@ #define glade_web_publish_add_path "/com/ublinux/ui/ubl-settings-update-web-publication-add.glade" #define glade_mirror_configure_path "/com/ublinux/ui/ubl-settings-update-mirror-configure.glade" #define glade_mirror_add_path "/com/ublinux/ui/ubl-settings-update-mirror-add.glade" +#define glade_mirror_path_add_path "/com/ublinux/ui/ubl-settings-update-mirror-path-add.glade" #define banner_path "/com/ublinux/images/ubl-settings-update-banner.png" #define CssPath "/com/ublinux/css/ubl-settings-update.css" #define config_path yon_char_unite(yon_ubl_user_get_home_directory(),"/.config/",LocaleName,"/",LocaleName,".conf",NULL) @@ -44,12 +45,14 @@ #define REPOSITORY(target) yon_char_unite("REPOSITORY[",target,"]",NULL) #define REPOSITORY_parameter "REPOSITORY" +#define REOSITORY_command(target) yon_char_unite("ubconfig --source global get [update] REPOSITORY[",target,"]",NULL) #define REPOSITORY_search "REPOSITORY[" #define REPOPUBLIC_NET "REPOPUBLIC_NET" #define REPOPUBLIC_WEB "REPOPUBLIC_WEB" #define REPOPUBLIC_WEB_search "REPOPUBLIC_WEB[" #define REPOPUBLIC_WEB_full(target) yon_char_unite("REPOPUBLIC_WEB[",target,"]",NULL) +#define REPOPUBLIC_WEB_command(target) yon_char_unite("ubconfig --source global get [update] REPOPUBLIC_WEB[",target,"]",NULL) #define REPOPUBLIC_CACHE "REPOPUBLIC_CACHE" #define REPOPUBLIC_CACHE_search "REPOPUBLIC_CACHE[" #define REPOPUBLIC_CACHE_full(target) yon_char_unite("REPOPUBLIC_CACHE[",target,"]",NULL) @@ -158,12 +161,17 @@ typedef struct { GtkWidget *Window; GtkWidget *HeadLabel; GtkWidget *StatusBox; + GtkWidget *AddButton; GtkWidget *AcceptButton; GtkWidget *CancelButton; GtkWidget *NameEntry; GtkWidget *TypeCombo; GtkWidget *TypeEntry; GtkWidget *TypeButton; + GtkWidget *PathBox; + GtkWidget *PathRemovalBox; + GtkWidget *PathRemoveButton; + GtkWidget *PathLabel; } mirror_add_window; typedef struct { @@ -237,4 +245,6 @@ void on_selection_changed(GtkWidget *self, main_window *widgets); void yon_interface_update(main_window *widgets); +void on_mirror_path_add(GtkWidget *, mirror_add_window *window); +void on_mirror_path_removed(GtkWidget *, GtkWidget *target); #endif \ No newline at end of file diff --git a/ubl-settings-update-mirror-add.glade b/ubl-settings-update-mirror-add.glade index 6345b00..b26541a 100644 --- a/ubl-settings-update-mirror-add.glade +++ b/ubl-settings-update-mirror-add.glade @@ -47,47 +47,36 @@ True False + vertical 5 - - True - False - Repository name: - - - False - True - 0 - - - - - True - True - - - True - True - 1 - - - - - False - True - 0 - - - - - True - False - 5 - - + True False - Repository type: + 5 + + + True + False + Repository name: + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + False @@ -101,14 +90,10 @@ False 5 - + True False - - WEB link - Proxy server - Mirrors file - + Repository type: False @@ -117,9 +102,70 @@ - + True - True + False + 5 + + + True + False + 0 + + WEB link + Proxy server + Mirrors file + + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + + + + True + True + True + image1 + + + + False + True + 2 + + + + + True + True + True + image3 + + + + False + True + 3 + + True @@ -127,25 +173,9 @@ 1 - - - True - True - True - image1 - - - - False - True - 2 - - - True + False True 1 @@ -154,14 +184,69 @@ False True + 0 + + + + + True + True + + + True + False + + + True + False + 5 + + + True + False + vertical + + + + + + False + True + 0 + + + + + True + False + vertical + 2 + + + + + + True + True + 1 + + + + + + + + + True + True 1 - False + True True - 1 + 3 @@ -214,5 +299,17 @@ + + + + + + + + + True + False + com.ublinux.ubinstall.increase-symbolic + diff --git a/ubl-settings-update-mirror-path-add.glade b/ubl-settings-update-mirror-path-add.glade new file mode 100644 index 0000000..e0bed96 --- /dev/null +++ b/ubl-settings-update-mirror-path-add.glade @@ -0,0 +1,72 @@ + + + + + + + True + False + 5 + + + True + False + 5 + + + + + + False + True + 0 + + + + + True + False + 5 + + + True + False + True + image2 + + + + False + True + 1 + + + + + True + False + label + + + False + True + 2 + + + + + False + True + 2 + + + + + True + False + com.ublinux.libublsettingsui-gtk3.decrease-symbolic + + diff --git a/ubl-settings-update-repo-add.glade b/ubl-settings-update-repo-add.glade index e5f558e..89576d9 100644 --- a/ubl-settings-update-repo-add.glade +++ b/ubl-settings-update-repo-add.glade @@ -189,11 +189,11 @@ False 0 - Never (Signature verification will not be performed) - Optional - Required - TrustedOnly - TrustAll + Never (Signature verification will not be performed) + Optional + Required + TrustedOnly + TrustAll @@ -208,16 +208,16 @@ False 0 - PackageNever - DatabaseNever - PackageOptional - DatabaseOptional - PackageRequired - DatabaseRequired - Package TrustedOnly - Database TrustedOnly - Package TrustAll - Database TrustAll + PackageNever + DatabaseNever + PackageOptional + DatabaseOptional + PackageRequired + DatabaseRequired + Package TrustedOnly + Database TrustedOnly + Package TrustAll + Database TrustAll diff --git a/ubl-settings-update-web-publication-add.glade b/ubl-settings-update-web-publication-add.glade index 1a4130e..742d47b 100644 --- a/ubl-settings-update-web-publication-add.glade +++ b/ubl-settings-update-web-publication-add.glade @@ -258,6 +258,20 @@ False vertical 5 + + + Set + True + True + False + True + + + False + True + 0 + + True @@ -275,22 +289,6 @@ 0 - - - True - True - False - True - - - - - - False - True - 1 - - True @@ -306,7 +304,7 @@ False True - 0 + 1 @@ -326,25 +324,6 @@ 0 - - - True - True - False - True - - - - - - - False - True - 1 - - True @@ -377,7 +356,7 @@ False True - 1 + 2 diff --git a/ubl-settings-update.css b/ubl-settings-update.css index 3873397..5526ff1 100644 --- a/ubl-settings-update.css +++ b/ubl-settings-update.css @@ -9,6 +9,12 @@ .nobackground { background:transparent; } +.nobg_active:active { +background:@theme_selected_bg_color; +} +.nobg_active { +background:transparent; +} .nobackground:active { background:transparent; } diff --git a/ubl-settings-update.glade b/ubl-settings-update.glade index 9e8e317..42b38fe 100644 --- a/ubl-settings-update.glade +++ b/ubl-settings-update.glade @@ -58,7 +58,26 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - + + + + + + + + + + + + + + + + + + + + 100 @@ -1064,47 +1083,96 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. True True WebPublicationList + both Enabled + + + + 0 + + Storage + + + + 1 + + Chosen repositories + + + + 2 + + Reviewer + + + + 3 + + Port + + + + 4 + + Name + + + + 5 + + Password/Hash type + + + + 6 + + Password/Password hash + + + + 7 + + From fd5935ef9d8f52445f80f7797ff215ffff20f306 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Tue, 15 Oct 2024 18:27:08 +0600 Subject: [PATCH 5/8] repo adding window applying WIP --- source/ubl-settings-update.c | 95 +++++-- source/ubl-settings-update.h | 11 +- ubl-settings-update-mirror-add.glade | 308 ++++++++++++---------- ubl-settings-update-mirror-path-add.glade | 84 +++--- ubl-settings-update-repo-add.glade | 231 ++++++++++++---- ubl-settings-update.glade | 4 +- 6 files changed, 479 insertions(+), 254 deletions(-) diff --git a/source/ubl-settings-update.c b/source/ubl-settings-update.c index f957b59..e54952a 100644 --- a/source/ubl-settings-update.c +++ b/source/ubl-settings-update.c @@ -40,6 +40,11 @@ void yon_load_proceed(YON_CONFIG_TYPE type){ } void yon_interface_update(main_window *widgets){ + gtk_list_store_clear(widgets->ReposList); + gtk_list_store_clear(widgets->MirrorList); + gtk_list_store_clear(widgets->UpdateRepoList); + gtk_list_store_clear(widgets->PublicationList); + gtk_list_store_clear(widgets->WebPublicationList); int size; char *repo_config = config(REPOSITORY_parameter); if (!yon_char_is_empty(repo_config)){ @@ -353,7 +358,7 @@ void on_mirror_configure(GtkWidget *,main_window *widgets){ } void on_repo_accept_clicked(GtkWidget *, dictionary *dict){ - // main_window *widgets = yon_dictionary_get_data(dict->first,main_window*); + main_window *widgets = yon_dictionary_get_data(dict->first,main_window*); repo_add_window *window = yon_dictionary_get_data(dict->first->next,repo_add_window*); int enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->EnabledCheck)); @@ -363,9 +368,19 @@ void on_repo_accept_clicked(GtkWidget *, dictionary *dict){ yon_ubl_status_highlight_incorrect(window->RepoNameEntry); return; } - char *source_mode = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(window->RepoSourceCombo)); - const char *source_path = gtk_entry_get_text(GTK_ENTRY(window->RepoSourceEntry)); - if (yon_char_is_empty(source_path)){ + char *sources = ""; + GList *list = gtk_container_get_children(GTK_CONTAINER(window->SourceBox)); + for (guint i=0;iStatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); yon_ubl_status_highlight_incorrect(window->RepoSourceEntry); return; @@ -380,17 +395,17 @@ void on_repo_accept_clicked(GtkWidget *, dictionary *dict){ // int usage_level_enable_install = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->UsageEnableInsallCheck)); // int usage_level_sysupgrade = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->UsageSysupgradeCheck)); - char *final = yon_char_unite(source_mode,source_path,";",sign_level_package,",",sign_level_condiition,";",enabled?"":"disable",NULL); + char *final = yon_char_unite(sources,";",sign_level_package,",",sign_level_condiition,";",enabled?"":"disable",NULL); yon_config_register(REPOSITORY(repo_name),REOSITORY_command(repo_name),final); - + yon_interface_update(widgets); gtk_widget_destroy(window->Window); free(window); } void on_web_publish_accept(GtkWidget *, dictionary *dict){ - // main_window *widgets = yon_dictionary_get_data(dict->first,main_window*); + main_window *widgets = yon_dictionary_get_data(dict->first,main_window*); web_publication_add_window *window = yon_dictionary_get_data(dict->first->next,web_publication_add_window*); int enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->EnablePublishCheck)); @@ -406,13 +421,26 @@ void on_web_publish_accept(GtkWidget *, dictionary *dict){ char *name = ""; char *final = yon_char_unite(enabled?"enable":"disable",":",enable_browser?"listing":"",":",port_enabled?port:"",":",username_check?username:"",username_check?user_password:"",NULL); yon_config_register(REPOPUBLIC_WEB_full(name),REPOPUBLIC_WEB_command(name),final); + yon_interface_update(widgets); } -void on_mirror_accept(GtkWidget *,dictionary *){ - // main_window *widgets = yon_dictionary_get_data(dict->first,main_window*); - // mirror_add_window *window = yon_dictionary_get_data(dict->first->next,mirror_add_window*); - // char *name = (char*)gtk_entry_get_text(GTK_ENTRY(window->NameEntry)); - // char *path = (char*)gtk_entry_get_text(GTK_ENTRY(window->TypeEntry)); +void on_mirror_accept(GtkWidget *,dictionary *dict){ + main_window *widgets = yon_dictionary_get_data(dict->first,main_window*); + mirror_add_window *window = yon_dictionary_get_data(dict->first->next,mirror_add_window*); + char *name = (char*)gtk_entry_get_text(GTK_ENTRY(window->NameEntry)); + char *paths = ""; + GList *list = gtk_container_get_children(GTK_CONTAINER(window->PathBox)); + for (guint i=0;iTypeEntry)); if (yon_char_is_empty(target)){ @@ -432,12 +475,30 @@ void on_mirror_path_add(GtkWidget *, mirror_add_window *window){ char *full_name = yon_char_unite(type,"@",target,NULL); gtk_entry_set_text(GTK_ENTRY(window->TypeEntry),""); GtkBuilder *builder = gtk_builder_new_from_resource(glade_mirror_path_add_path); - gtk_box_pack_start(GTK_BOX(window->PathBox),yon_gtk_builder_get_widget(builder,"PathRemovalBox"),0,0,5); - gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(builder,"PathLabel")),full_name); + gtk_box_pack_start(GTK_BOX(window->PathBox),yon_gtk_builder_get_widget(builder,"PathRemovalBox"),0,0,2); + gtk_entry_set_text(GTK_ENTRY(gtk_builder_get_object(builder,"PathEntry")),full_name); + g_signal_connect(gtk_builder_get_object(builder,"PathEditButton"),"clicked",G_CALLBACK(on_mirror_path_edit),gtk_builder_get_object(builder,"PathRemovalBox")); g_signal_connect(gtk_builder_get_object(builder,"PathRemoveButton"),"clicked",G_CALLBACK(on_mirror_path_removed),gtk_builder_get_object(builder,"PathRemovalBox")); } +void on_repo_source_add(GtkWidget *, repo_add_window *window){ + const char *target = gtk_entry_get_text(GTK_ENTRY(window->RepoSourceEntry)); + if (yon_char_is_empty(target)){ + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect(window->RepoSourceEntry); + return; + } + char *type = (char*)gtk_combo_box_get_active_id(GTK_COMBO_BOX(window->RepoSourceCombo)); + char *full_name = yon_char_append(type,target); + gtk_entry_set_text(GTK_ENTRY(window->RepoSourceEntry),""); + GtkBuilder *builder = gtk_builder_new_from_resource(glade_mirror_path_add_path); + gtk_box_pack_start(GTK_BOX(window->SourceBox),yon_gtk_builder_get_widget(builder,"PathRemovalBox"),0,0,2); + gtk_entry_set_text(GTK_ENTRY(gtk_builder_get_object(builder,"PathEntry")),full_name); + g_signal_connect(gtk_builder_get_object(builder,"PathEditButton"),"clicked",G_CALLBACK(on_mirror_path_edit),gtk_builder_get_object(builder,"PathRemovalBox")); + g_signal_connect(gtk_builder_get_object(builder,"PathRemoveButton"),"clicked",G_CALLBACK(on_mirror_path_removed),gtk_builder_get_object(builder,"PathRemovalBox")); +} + repo_add_window *yon_repo_add_window_new(){ GtkBuilder *builder = gtk_builder_new_from_resource(glade_repo_add_path); repo_add_window *window = malloc(sizeof(repo_add_window)); @@ -458,7 +519,10 @@ repo_add_window *yon_repo_add_window_new(){ window->AcceptButton = yon_gtk_builder_get_widget(builder,"AcceptButton"); window->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton"); window->HeadLabel = yon_gtk_builder_get_widget(builder,"HeadLabel"); + window->SourceBox = yon_gtk_builder_get_widget(builder,"SourceBox"); + window->RepoSourceAddButton = yon_gtk_builder_get_widget(builder,"RepoSourceAddButton"); + g_signal_connect(G_OBJECT(window->RepoSourceAddButton),"clicked",G_CALLBACK(on_repo_source_add),window); g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); gtk_widget_show(window->Window); @@ -539,9 +603,6 @@ mirror_add_window *yon_mirror_add_window_new(){ window->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton"); window->HeadLabel = yon_gtk_builder_get_widget(builder,"HeadLabel"); window->PathBox = yon_gtk_builder_get_widget(builder,"PathBox"); - window->PathRemovalBox = yon_gtk_builder_get_widget(builder,"PathRemovalBox"); - window->PathRemoveButton = yon_gtk_builder_get_widget(builder,"PathRemoveButton"); - window->PathLabel = yon_gtk_builder_get_widget(builder,"PathLabel"); g_signal_connect(G_OBJECT(window->AddButton),"clicked",G_CALLBACK(on_mirror_path_add),window); g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); diff --git a/source/ubl-settings-update.h b/source/ubl-settings-update.h index 2332c52..3425ebb 100644 --- a/source/ubl-settings-update.h +++ b/source/ubl-settings-update.h @@ -31,6 +31,9 @@ #define CssPath "/com/ublinux/css/ubl-settings-update.css" #define config_path yon_char_unite(yon_ubl_user_get_home_directory(),"/.config/",LocaleName,"/",LocaleName,".conf",NULL) +#define accept_icon_name "com.ublinux.libublsettingsui-gtk3.accept-symbolic" +#define edit_icon_name "document-edit-symbolic" + #define LocalePath "/usr/share/locale" #define LocaleName "ubl-settings-update" #define icon_path "com.ublinux.ubl-settings-update" @@ -56,6 +59,7 @@ #define REPOPUBLIC_CACHE "REPOPUBLIC_CACHE" #define REPOPUBLIC_CACHE_search "REPOPUBLIC_CACHE[" #define REPOPUBLIC_CACHE_full(target) yon_char_unite("REPOPUBLIC_CACHE[",target,"]",NULL) +#define REPOPUBLIC_CACHE_full_command(target) yon_char_unite("ubconfig --source global get [update] REPOPUBLIC_CACHE[",target,"]",NULL) #define AUTOUPDATE "AUTOUPDATE" #define AUTOUPDATE_mode "AUTOUPDATE[mode]" #define AUTOUPDATE_interval "AUTOUPDATE[interval]" @@ -131,6 +135,8 @@ typedef struct { GtkWidget *RepoSourceButton; GtkWidget *RepoSourceEntry; GtkWidget *RepoSourceCombo; + GtkWidget *SourceBox; + GtkWidget *RepoSourceAddButton; GtkWidget *RepoNameEntry; GtkWidget *EnabledCheck; GtkWidget *AcceptButton; @@ -169,9 +175,6 @@ typedef struct { GtkWidget *TypeEntry; GtkWidget *TypeButton; GtkWidget *PathBox; - GtkWidget *PathRemovalBox; - GtkWidget *PathRemoveButton; - GtkWidget *PathLabel; } mirror_add_window; typedef struct { @@ -247,4 +250,6 @@ void yon_interface_update(main_window *widgets); void on_mirror_path_add(GtkWidget *, mirror_add_window *window); void on_mirror_path_removed(GtkWidget *, GtkWidget *target); +void on_mirror_path_edit(GtkWidget*,GtkWidget *target); +void on_repo_source_add(GtkWidget *, repo_add_window *window); #endif \ No newline at end of file diff --git a/ubl-settings-update-mirror-add.glade b/ubl-settings-update-mirror-add.glade index b26541a..bdc2cf4 100644 --- a/ubl-settings-update-mirror-add.glade +++ b/ubl-settings-update-mirror-add.glade @@ -8,6 +8,11 @@ False com.ublinux.libublsettingsui-gtk3.zoom-symbolic + + True + False + com.ublinux.ubinstall.increase-symbolic + 500 False @@ -85,161 +90,199 @@ - - True - False - 5 - - - True - False - Repository type: - - - False - True - 0 - - - - - True - False - 5 - - - True - False - 0 - - WEB link - Proxy server - Mirrors file - - - - False - True - 0 - - - - - True - True - - - True - True - 1 - - - - - True - True - True - image1 - - - - False - True - 2 - - - - - True - True - True - image3 - - - - False - True - 3 - - - - - True - True - 1 - - - - - False - True - 1 - + - - - False - True - 0 - - - - - True - True - + True False + 0 + in - + True False - 5 + 5 + 5 + 5 - + True False vertical + 5 - + + True + False + 5 + + + True + False + Repository type: + + + False + True + 0 + + + + + True + False + 5 + + + True + False + 0 + + WEB link + Proxy server + Mirrors file + + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + + + + True + True + True + image1 + + + + False + True + 2 + + + + + True + True + True + image3 + + + + False + True + 3 + + + + + True + True + 1 + + + + + False + True + 0 + - - - False - True - 0 - - - - - True - False - vertical - 2 - + + True + True + + + True + False + + + True + False + 5 + + + True + False + vertical + + + + + + False + True + 0 + + + + + True + False + vertical + + + + + + True + True + 1 + + + + + + + + + True + True + 1 + - - True - True - 1 - + + + True + False + + + + True + True + 2 + True True - 1 + 0 @@ -306,10 +349,5 @@ - - True - False - com.ublinux.ubinstall.increase-symbolic - diff --git a/ubl-settings-update-mirror-path-add.glade b/ubl-settings-update-mirror-path-add.glade index e0bed96..13c785d 100644 --- a/ubl-settings-update-mirror-path-add.glade +++ b/ubl-settings-update-mirror-path-add.glade @@ -3,70 +3,72 @@ + + True + False + document-edit-symbolic + + + True + False + com.ublinux.libublsettingsui-gtk3.decrease-symbolic + True False 5 - + True False - 5 - - - + True + image2 + False True + end 0 - + + True + True + False + False + False + + + + False + True + 1 + + + + True False - 5 - - - True - False - True - image2 - - - - False - True - 1 - - - - - True - False - label - - - False - True - 2 - - + True + image1 + False True + end 2 - - True - False - com.ublinux.libublsettingsui-gtk3.decrease-symbolic - diff --git a/ubl-settings-update-repo-add.glade b/ubl-settings-update-repo-add.glade index 89576d9..87b576f 100644 --- a/ubl-settings-update-repo-add.glade +++ b/ubl-settings-update-repo-add.glade @@ -95,68 +95,174 @@ - + True False - 3 - 5 - - - True - False - Source: - - - False - True - 0 - - + 0 + in - + True False - 0 - - file:// - ftp:// - http:// - https:// - Configuration - - - - False - True - 1 - - - - - True - True + 5 + 5 + 5 + 5 + + + True + False + vertical + 5 + + + True + False + 3 + 5 + + + True + False + Source: + + + False + True + 0 + + + + + True + False + 0 + + file:// + ftp:// + http:// + https:// + Configuration + + + + False + True + 1 + + + + + True + True + + + True + True + 2 + + + + + True + True + True + image1 + + + + False + True + 3 + + + + + True + True + True + image2 + + + + False + True + 4 + + + + + False + True + 0 + + + + + True + True + 100 + + + True + False + + + True + False + 5 + + + True + False + vertical + + + + + + False + True + 0 + + + + + True + False + vertical + 5 + + + + + + True + True + 1 + + + + + + + + + False + True + 1 + + + + - - True - True - 2 - - - - True - True - True - image1 - - - - False - True - 3 - + + @@ -230,7 +336,7 @@ False True - 3 + 4 @@ -337,7 +443,7 @@ True True - 4 + 5 @@ -397,4 +503,15 @@ + + + + + + + + True + False + com.ublinux.libublsettingsui-gtk3.increase-symbolic + diff --git a/ubl-settings-update.glade b/ubl-settings-update.glade index 42b38fe..c6f70a6 100644 --- a/ubl-settings-update.glade +++ b/ubl-settings-update.glade @@ -726,7 +726,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Signature level - + + 125 + 3 From 12e9e78a15caa9caa804b8d77aa53df74d6e630d Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Wed, 16 Oct 2024 18:09:01 +0600 Subject: [PATCH 6/8] Add windows fixes --- source/ubl-settings-update.c | 87 +++++++++++++++++++++++------------- source/ubl-settings-update.h | 3 +- ubl-settings-update.glade | 6 --- 3 files changed, 59 insertions(+), 37 deletions(-) diff --git a/source/ubl-settings-update.c b/source/ubl-settings-update.c index e54952a..01a493f 100644 --- a/source/ubl-settings-update.c +++ b/source/ubl-settings-update.c @@ -68,7 +68,10 @@ void yon_interface_update(main_window *widgets){ config_str parsed = yon_char_parse(current,&cur_size,";"); if (cur_size){ gtk_list_store_append(widgets->ReposList,&iter); - gtk_list_store_set(widgets->ReposList,&iter,0,cur_size>3?0:1,1,key,2,parsed[0],3,cur_size>1?parsed[1]:"",4,cur_size>2?parsed[2]:"",-1); + char *temp = yon_char_replace(parsed[0],",","\n"); + free(parsed[0]); + parsed[0] = temp; + gtk_list_store_set(widgets->ReposList,&iter,0,cur_size>3&&!strcmp(parsed[3],"")?1:0,1,key,2,parsed[0],3,cur_size>1?parsed[1]:"",4,cur_size>2?parsed[2]:"",-1); } free(key); @@ -109,27 +112,23 @@ void yon_interface_update(main_window *widgets){ } } - // config_str mirror_list = yon_config_get_all_by_key(REPOPUBLIC_CACHE_search,&size); - // if (size){ - // for (int i=0;iMirrorList,&iter); - // gtk_list_store_set(widgets->MirrorList,&iter,,-1); - // } - // } - // } + config_str mirror_list = yon_config_get_all_by_key(REPOPUBLIC_CACHE_search,&size); + if (size){ + for (int i=0;iMirrorList,&iter); + int cur_size; + config_str parsed = yon_char_parse(cur,&cur_size,","); + if (cur_size){ + gtk_list_store_set(widgets->MirrorList,&iter,0,key,2,yon_char_parsed_to_string(parsed,cur_size,"\n"),-1); + } + } + } char *autoupdate_config = config(AUTOUPDATE); if (!yon_char_is_empty(autoupdate_config)&&!strcmp(autoupdate_config,"enable")){ @@ -147,6 +146,18 @@ void yon_interface_update(main_window *widgets){ } } + char *autoupdate_repos = config(AUTOUPDATE_repos); + if (!yon_char_is_empty(autoupdate_repos)){ + int parsed_size; + GtkTreeIter iter; + config_str parsed = yon_char_parse(autoupdate_repos,&parsed_size,","); + for (int i=0;iUpdateRepoList),&iter); + gtk_list_store_set(widgets->UpdateRepoList,&iter,1,parsed[i],-1); + } + yon_char_parsed_free(parsed,parsed_size); + } + autoupdate_config = config(AUTOUPDATE_interval); if (!yon_char_is_empty(autoupdate_config)){ if (!strcmp(autoupdate_config,"boot")){ @@ -172,11 +183,11 @@ void yon_interface_update(main_window *widgets){ char *key = yon_char_divide_search(cur,"=",-1); free(yon_char_divide_search(key,"[",-1)); key[strlen(key)-1]='\0'; - char *path = yon_char_divide_search(key,":",-1); + char *path = !strstr(key,"=") ? NULL : yon_char_divide_search(key,":",-1); int repos_size; - config_str repos = yon_char_parse(key,&repos_size,","); + config_str repos = yon_char_parse(path,&repos_size,","); - gtk_list_store_set(widgets->WebPublicationList,&iter,1,path,2,yon_char_parsed_to_string(repos,repos_size,"\n"),-1); + gtk_list_store_set(widgets->WebPublicationList,&iter,1,key,2,yon_char_parsed_to_string(repos,repos_size,"\n"),-1); int cur_size; config_str parsed = yon_char_parse(cur,&cur_size,":"); if (cur_size){ @@ -395,7 +406,7 @@ void on_repo_accept_clicked(GtkWidget *, dictionary *dict){ // int usage_level_enable_install = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->UsageEnableInsallCheck)); // int usage_level_sysupgrade = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->UsageSysupgradeCheck)); - char *final = yon_char_unite(sources,";",sign_level_package,",",sign_level_condiition,";",enabled?"":"disable",NULL); + char *final = yon_char_unite(sources,";",sign_level_package,",",sign_level_condiition,";",";",enabled?"":"disable",NULL); yon_config_register(REPOSITORY(repo_name),REOSITORY_command(repo_name),final); yon_interface_update(widgets); @@ -418,10 +429,24 @@ void on_web_publish_accept(GtkWidget *, dictionary *dict){ char *username = (char*)gtk_entry_get_text(GTK_ENTRY(window->UsernameEntry)); char *user_password = (char*)gtk_entry_get_text(GTK_ENTRY(window->UserPasswordEntry)); - char *name = ""; + char *name = (char*)gtk_entry_get_text(GTK_ENTRY(window->PathEntry)); + char *full_name = ""; + GtkTreeIter iter; + for_iter (GTK_TREE_MODEL(window->list),&iter){ + int chosen; + char *repos; + gtk_tree_model_get(GTK_TREE_MODEL(window->list),0,&chosen,1,&repos,-1); + if (chosen){ + char *temp = yon_char_unite(full_name,yon_char_is_empty(full_name)?"":",",repos,NULL); + if (!yon_char_is_empty(full_name)) free(full_name); + full_name = temp; + } + } + char *final_name = yon_char_is_empty(full_name) ? name : yon_char_unite(name,":",full_name,NULL); char *final = yon_char_unite(enabled?"enable":"disable",":",enable_browser?"listing":"",":",port_enabled?port:"",":",username_check?username:"",username_check?user_password:"",NULL); - yon_config_register(REPOPUBLIC_WEB_full(name),REPOPUBLIC_WEB_command(name),final); + yon_config_register(REPOPUBLIC_WEB_full(final_name),REPOPUBLIC_WEB_command(final_name),final); yon_interface_update(widgets); + gtk_widget_destroy(window->Window); } void on_mirror_accept(GtkWidget *,dictionary *dict){ @@ -432,7 +457,7 @@ void on_mirror_accept(GtkWidget *,dictionary *dict){ GList *list = gtk_container_get_children(GTK_CONTAINER(window->PathBox)); for (guint i=0;iWindow); } void on_mirror_path_removed(GtkWidget *, GtkWidget *target){ @@ -483,7 +509,7 @@ void on_mirror_path_add(GtkWidget *, mirror_add_window *window){ } void on_repo_source_add(GtkWidget *, repo_add_window *window){ - const char *target = gtk_entry_get_text(GTK_ENTRY(window->RepoSourceEntry)); + char *target = (char*)gtk_entry_get_text(GTK_ENTRY(window->RepoSourceEntry)); if (yon_char_is_empty(target)){ yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); yon_ubl_status_highlight_incorrect(window->RepoSourceEntry); @@ -549,6 +575,7 @@ web_publication_add_window *yon_web_publication_add_window_new(){ window->AcceptButton = yon_gtk_builder_get_widget(builder,"AcceptButton"); window->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton"); window->HeadLabel = yon_gtk_builder_get_widget(builder,"HeadLabel"); + window->list = GTK_LIST_STORE(gtk_builder_get_object(builder,"liststore1")); g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); gtk_widget_show(window->Window); diff --git a/source/ubl-settings-update.h b/source/ubl-settings-update.h index 3425ebb..faafbbc 100644 --- a/source/ubl-settings-update.h +++ b/source/ubl-settings-update.h @@ -41,7 +41,7 @@ #define yon_config_get_custom_command(target) yon_char_unite("ubconfig --source ",target," get update REPOPUBLIC_NET REPOPUBLIC_WEB REPOSITORY[*] REPOPUBLIC_WEB REPOPUBLIC_WEB[*] REPOPUBLIC_CACHE REPOPUBLIC_CACHE[*] AUTOUPDATE AUTOUPDATE[mode] AUTOUPDATE[interval] AUTOUPDATE[repos] AUTOUPDATE[timestamp]",NULL) #define config_get_local_command "ubconfig --source system get update REPOPUBLIC_NET REPOPUBLIC_WEB REPOSITORY[*] REPOPUBLIC_WEB REPOPUBLIC_WEB[*] REPOPUBLIC_CACHE REPOPUBLIC_CACHE[*] AUTOUPDATE AUTOUPDATE[mode] AUTOUPDATE[interval] AUTOUPDATE[repos] AUTOUPDATE[timestamp]" #define config_get_global_command "ubconfig --source global get update REPOPUBLIC_NET REPOPUBLIC_WEB REPOSITORY[*] REPOPUBLIC_WEB REPOPUBLIC_WEB[*] REPOPUBLIC_CACHE REPOPUBLIC_CACHE[*] AUTOUPDATE AUTOUPDATE[mode] AUTOUPDATE[interval] AUTOUPDATE[repos] AUTOUPDATE[timestamp]" -#define config_get_default_command "REPOSITORY[*]" +#define config_get_default_command "ubconfig --source global get update AUTOUPDATE[repos]" #define config_get_global_only_parameters "" #define config_get_local_only_parameters "" @@ -161,6 +161,7 @@ typedef struct { GtkWidget *UserPasswordEntry; GtkWidget *AcceptButton; GtkWidget *CancelButton; + GtkListStore *list; } web_publication_add_window; typedef struct { diff --git a/ubl-settings-update.glade b/ubl-settings-update.glade index c6f70a6..36b38ed 100644 --- a/ubl-settings-update.glade +++ b/ubl-settings-update.glade @@ -159,12 +159,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. True False - 5 - 5 - 5 - 5 - 5 - 5 True True vertical From 2ac710f0f20a16372c9cb40d85bcc7dea4b3a8de Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Thu, 17 Oct 2024 18:01:27 +0600 Subject: [PATCH 7/8] Editing windows WIP --- source/ubl-settings-update.c | 183 +++++++++++++++--- source/ubl-settings-update.h | 12 +- source/ubl-strings.h | 1 + ubl-settings-update-mirror-path-add.glade | 2 +- ubl-settings-update-web-publication-add.glade | 25 ++- ubl-settings-update.glade | 87 +++++++-- 6 files changed, 265 insertions(+), 45 deletions(-) diff --git a/source/ubl-settings-update.c b/source/ubl-settings-update.c index 01a493f..dfb38f6 100644 --- a/source/ubl-settings-update.c +++ b/source/ubl-settings-update.c @@ -183,11 +183,17 @@ void yon_interface_update(main_window *widgets){ char *key = yon_char_divide_search(cur,"=",-1); free(yon_char_divide_search(key,"[",-1)); key[strlen(key)-1]='\0'; - char *path = !strstr(key,"=") ? NULL : yon_char_divide_search(key,":",-1); + char *path = NULL; + if (!strstr(key,":")){ + path=key; + key=NULL; + } else { + path = yon_char_divide_search(key,":",-1); + } int repos_size; - config_str repos = yon_char_parse(path,&repos_size,","); + config_str repos = yon_char_parse(key,&repos_size,","); - gtk_list_store_set(widgets->WebPublicationList,&iter,1,key,2,yon_char_parsed_to_string(repos,repos_size,"\n"),-1); + gtk_list_store_set(widgets->WebPublicationList,&iter,1,path,2,yon_char_parsed_to_string(repos,repos_size,"\n"),-1); int cur_size; config_str parsed = yon_char_parse(cur,&cur_size,":"); if (cur_size){ @@ -272,18 +278,29 @@ void on_selection_changed(GtkWidget *self, main_window *widgets){ } } -void on_repo_add(GtkWidget *, main_window *widgets){ - repo_add_window *window = yon_repo_add_window_new(); - yon_gtk_window_setup(GTK_WINDOW(window->Window),GTK_WINDOW(widgets->Window),ADD_REPO_LABEL,icon_path,"add_repo_window"); - - dictionary *dict = NULL; - yon_dictionary_add_or_create_if_exists_with_data(dict,"widgets",widgets); - yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window); - g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_repo_accept_clicked),dict); +void on_web_publish_path_changed(GtkWidget *, web_publication_add_window *window){ + gtk_list_store_clear(window->list); + char *path = (char*)gtk_entry_get_text(GTK_ENTRY(window->PathEntry)); + if (yon_char_is_empty(path) || access(path,F_OK)) return; + int size; + config_str parsed = yon_dir_get_contents(path,&size); + GtkTreeIter iter; + for (int i=0;ilist,&iter); + gtk_list_store_set(window->list,&iter,0,1,1,parsed[i],-1); + } + free(cur_path); + } + yon_char_parsed_free(parsed,size); } void on_web_publish_add(GtkWidget *,main_window *widgets){ + gtk_tree_selection_unselect_all(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->MirrorTree))); web_publication_add_window *window = yon_web_publication_add_window_new(); yon_gtk_window_setup(GTK_WINDOW(window->Window),GTK_WINDOW(widgets->Window),ADD_REPO_LABEL,icon_path,"web_publish_window"); @@ -293,7 +310,20 @@ void on_web_publish_add(GtkWidget *,main_window *widgets){ g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_web_publish_accept),dict); } +void on_repo_add(GtkWidget *, main_window *widgets){ + gtk_tree_selection_unselect_all(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->MirrorTree))); + repo_add_window *window = yon_repo_add_window_new(); + yon_gtk_window_setup(GTK_WINDOW(window->Window),GTK_WINDOW(widgets->Window),ADD_REPO_LABEL,icon_path,"add_repo_window"); + + dictionary *dict = NULL; + yon_dictionary_add_or_create_if_exists_with_data(dict,"widgets",widgets); + yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window); + g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_repo_accept_clicked),dict); + +} + void on_mirror_add(GtkWidget *,main_window *widgets){ + gtk_tree_selection_unselect_all(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->MirrorTree))); mirror_add_window *window = yon_mirror_add_window_new(); yon_gtk_window_setup(GTK_WINDOW(window->Window),GTK_WINDOW(widgets->Window),ADD_REPO_LABEL,icon_path,"mirror_window"); @@ -307,16 +337,16 @@ void on_mirror_add(GtkWidget *,main_window *widgets){ void on_web_publish_remove(GtkWidget *self,main_window *widgets){ dialog_confirmation_data *data = malloc(sizeof(dialog_confirmation_data)); data->action_text=REMOVE_REPO_WARNING_LABEL; - data->function=(void(*)(void*,void*))on_remove_accept; - data->data = widgets->WebPublicationTree; + data->function=(void(*)(void*,void*))on_web_publish_remove_accept; + data->data = widgets; yon_confirmation_dialog_call(self,data); } void on_mirror_remove(GtkWidget *self,main_window *widgets){ dialog_confirmation_data *data = malloc(sizeof(dialog_confirmation_data)); data->action_text=REMOVE_REPO_WARNING_LABEL; - data->function=(void(*)(void*,void*))on_remove_accept; - data->data = widgets->MirrorTree; + data->function=(void(*)(void*,void*))on_mirror_remove_accept; + data->data = widgets; yon_confirmation_dialog_call(self,data); } @@ -324,27 +354,75 @@ void on_mirror_remove(GtkWidget *self,main_window *widgets){ void on_repo_remove(GtkWidget *self, main_window *widgets){ dialog_confirmation_data *data = malloc(sizeof(dialog_confirmation_data)); data->action_text=REMOVE_REPO_WARNING_LABEL; - data->function=(void(*)(void*,void*))on_remove_accept; - data->data = widgets->RepositoriesTree; + data->function=(void(*)(void*,void*))on_repositories_remove_accept; + data->data = widgets; yon_confirmation_dialog_call(self,data); } -void on_remove_accept(GtkWidget *, GtkWidget *target){ +void on_web_publish_remove_accept(GtkWidget *, main_window *widgets){ + GtkTreeModel *model=NULL; + GtkTreeIter iter; + if (!gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->WebPublicationTree)),&model,&iter)) { + return; + } + char *storage; + char *repositories; + gtk_tree_model_get(model,&iter,1,&storage,2,&repositories,-1); + char *full_name = NULL; + if (!yon_char_is_empty(repositories)){ + int size; + config_str parsed = yon_char_parse(repositories,&size,"\n"); + char *temp = yon_char_parsed_to_string(parsed,size,","); + full_name=yon_char_unite(storage,":",temp); + free(temp); + yon_char_parsed_free(parsed,size); + } else full_name = storage; + yon_config_remove_by_key(full_name); + yon_interface_update(widgets); +} + +void on_mirror_remove_accept(GtkWidget *, main_window *widgets){ + GtkTreeModel *model=NULL; + GtkTreeIter iter; + if (!gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->MirrorTree)),&model,&iter)) { + return; + } + char *repo; + gtk_tree_model_get(model,&iter,0,&repo,-1); + yon_config_remove_by_key(repo); + yon_interface_update(widgets); +} + +void on_repositories_remove_accept(GtkWidget *, main_window *widgets){ GtkTreeModel *model=NULL; GtkTreeIter iter; - if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(target)),&model,&iter)) { - gtk_list_store_remove(GTK_LIST_STORE(model),&iter); + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->RepositoriesTree)),&model,&iter)) { + return; } + char *repo; + gtk_tree_model_get(model,&iter,1,&repo,-1); + yon_config_remove_by_key(repo); + yon_interface_update(widgets); +} + +void on_repo_edit(GtkWidget *,main_window *widgets){ + repo_add_window *window = yon_repo_add_window_new(); + yon_gtk_window_setup(GTK_WINDOW(window->Window),GTK_WINDOW(widgets->Window),ADD_REPO_LABEL,icon_path,"add_repo_window"); + + dictionary *dict = NULL; + yon_dictionary_add_or_create_if_exists_with_data(dict,"widgets",widgets); + yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window); + g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_repo_accept_clicked),dict); } void on_web_publish_edit(GtkWidget *,main_window *widgets){ web_publication_add_window *window = yon_web_publication_add_window_new(); - yon_gtk_window_setup(GTK_WINDOW(window->Window),GTK_WINDOW(widgets->Window),ADD_REPO_LABEL,icon_path,"mirror_window"); + yon_gtk_window_setup(GTK_WINDOW(window->Window),GTK_WINDOW(widgets->Window),ADD_REPO_LABEL,icon_path,"web_publish_window"); dictionary *dict = NULL; yon_dictionary_add_or_create_if_exists_with_data(dict,"widgets",widgets); yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window); - g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_mirror_accept),dict); + g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_web_publish_accept),dict); } void on_mirror_edit(GtkWidget *,main_window *widgets){ @@ -355,6 +433,18 @@ void on_mirror_edit(GtkWidget *,main_window *widgets){ yon_dictionary_add_or_create_if_exists_with_data(dict,"widgets",widgets); yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window); g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_mirror_accept),dict); + + char *target; + GtkTreeIter iter; + gtk_tree_model_get(GTK_TREE_MODEL(widgets->MirrorList),&iter,0,&target,-1); + char *parameter = config(REPOPUBLIC_CACHE_full(target)); + int size; + config_str parsed = yon_char_parse(parameter,&size,","); + for (int i=0;iPathEntry)); char *full_name = ""; GtkTreeIter iter; + int disabled=0; + int overall=0; for_iter (GTK_TREE_MODEL(window->list),&iter){ + overall++; int chosen; char *repos; - gtk_tree_model_get(GTK_TREE_MODEL(window->list),0,&chosen,1,&repos,-1); + gtk_tree_model_get(GTK_TREE_MODEL(window->list),&iter,0,&chosen,1,&repos,-1); if (chosen){ char *temp = yon_char_unite(full_name,yon_char_is_empty(full_name)?"":",",repos,NULL); if (!yon_char_is_empty(full_name)) free(full_name); full_name = temp; + } else { + disabled++; } } - char *final_name = yon_char_is_empty(full_name) ? name : yon_char_unite(name,":",full_name,NULL); + if (overall==disabled) { + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),NO_SHARED_REPOS_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + return; + } + char *final_name = yon_char_is_empty(full_name)||!disabled ? name : yon_char_unite(name,":",full_name,NULL); char *final = yon_char_unite(enabled?"enable":"disable",":",enable_browser?"listing":"",":",port_enabled?port:"",":",username_check?username:"",username_check?user_password:"",NULL); yon_config_register(REPOPUBLIC_WEB_full(final_name),REPOPUBLIC_WEB_command(final_name),final); yon_interface_update(widgets); @@ -525,6 +624,18 @@ void on_repo_source_add(GtkWidget *, repo_add_window *window){ g_signal_connect(gtk_builder_get_object(builder,"PathRemoveButton"),"clicked",G_CALLBACK(on_mirror_path_removed),gtk_builder_get_object(builder,"PathRemovalBox")); } +void on_file_chooser_open(GtkWidget *, GtkEntry *target){ + GtkWidget *dialog = gtk_file_chooser_dialog_new(TITLE_LABEL,GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(target))),GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,CANCEL_LABEL,GTK_RESPONSE_CANCEL,ACCEPT_LABEL,GTK_RESPONSE_ACCEPT,NULL); + int resp = gtk_dialog_run(GTK_DIALOG(dialog)); + if (resp == GTK_RESPONSE_ACCEPT){ + char *file = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); + if (!yon_char_is_empty(file)){ + gtk_entry_set_text(target,file); + } + } + gtk_widget_destroy(dialog); +} + repo_add_window *yon_repo_add_window_new(){ GtkBuilder *builder = gtk_builder_new_from_resource(glade_repo_add_path); repo_add_window *window = malloc(sizeof(repo_add_window)); @@ -548,6 +659,7 @@ repo_add_window *yon_repo_add_window_new(){ window->SourceBox = yon_gtk_builder_get_widget(builder,"SourceBox"); window->RepoSourceAddButton = yon_gtk_builder_get_widget(builder,"RepoSourceAddButton"); + g_signal_connect(G_OBJECT(window->RepoSourceButton),"clicked",G_CALLBACK(on_file_chooser_open),window->RepoSourceEntry); g_signal_connect(G_OBJECT(window->RepoSourceAddButton),"clicked",G_CALLBACK(on_repo_source_add),window); g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); gtk_widget_show(window->Window); @@ -576,7 +688,11 @@ web_publication_add_window *yon_web_publication_add_window_new(){ window->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton"); window->HeadLabel = yon_gtk_builder_get_widget(builder,"HeadLabel"); window->list = GTK_LIST_STORE(gtk_builder_get_object(builder,"liststore1")); + window->SelectionCellRenderer = GTK_CELL_RENDERER(gtk_builder_get_object(builder,"SelectionCellRenderer")); + g_signal_connect(G_OBJECT(window->SelectionCellRenderer),"toggled",G_CALLBACK(on_cell_renderer_toggle_toggled),window->RepositoriesTree); + g_signal_connect(G_OBJECT(window->PathButton),"clicked",G_CALLBACK(on_file_chooser_open),window->PathEntry); + g_signal_connect(G_OBJECT(window->PathEntry),"changed",G_CALLBACK(on_web_publish_path_changed),window); g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); gtk_widget_show(window->Window); @@ -631,6 +747,7 @@ mirror_add_window *yon_mirror_add_window_new(){ window->HeadLabel = yon_gtk_builder_get_widget(builder,"HeadLabel"); window->PathBox = yon_gtk_builder_get_widget(builder,"PathBox"); + g_signal_connect(G_OBJECT(window->TypeButton),"clicked",G_CALLBACK(on_file_chooser_open),window->TypeEntry); g_signal_connect(G_OBJECT(window->AddButton),"clicked",G_CALLBACK(on_mirror_path_add),window); g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); gtk_widget_show(window->Window); @@ -638,6 +755,16 @@ mirror_add_window *yon_mirror_add_window_new(){ return window; } +void on_cell_renderer_toggle_toggled(GtkWidget *, gchar* path, GtkWidget *table){ + GtkTreeIter iter; + GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(table)); + if (gtk_tree_model_get_iter_from_string(model,&iter,path)){ + int status; + gtk_tree_model_get(model,&iter,0,&status,-1); + gtk_list_store_set(GTK_LIST_STORE(model),&iter,0,!status,-1); + } +} + /**yon_main_window_complete(main_window *widgets) * [EN] * @@ -651,6 +778,7 @@ void yon_main_window_complete(main_window *widgets){ { gtk_builder_add_callback_symbol(builder,"yon_gtk_widget_set_sensitive_from_toggle_button_inversed",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button_inversed)); + } // Custom widgets configuration { @@ -704,6 +832,13 @@ void yon_main_window_complete(main_window *widgets){ g_signal_connect(G_OBJECT(widgets->WebPublicationTree),"cursor-changed",G_CALLBACK(on_selection_changed),widgets); g_signal_connect(G_OBJECT(widgets->MirrorTree),"cursor-changed",G_CALLBACK(on_selection_changed),widgets); } + { + yon_gtk_tree_view_minimal_fixed_size_set_full(GTK_TREE_VIEW(widgets->MirrorTree)); + yon_gtk_tree_view_minimal_fixed_size_set_full(GTK_TREE_VIEW(widgets->UpdateRepoTree)); + yon_gtk_tree_view_minimal_fixed_size_set_full(GTK_TREE_VIEW(widgets->PublicationTree)); + yon_gtk_tree_view_minimal_fixed_size_set_full(GTK_TREE_VIEW(widgets->RepositoriesTree)); + yon_gtk_tree_view_minimal_fixed_size_set_full(GTK_TREE_VIEW(widgets->WebPublicationTree)); + } yon_load_proceed(YON_CONFIG_LOCAL); yon_interface_update(widgets); } diff --git a/source/ubl-settings-update.h b/source/ubl-settings-update.h index faafbbc..f21640b 100644 --- a/source/ubl-settings-update.h +++ b/source/ubl-settings-update.h @@ -162,6 +162,7 @@ typedef struct { GtkWidget *AcceptButton; GtkWidget *CancelButton; GtkListStore *list; + GtkCellRenderer *SelectionCellRenderer; } web_publication_add_window; typedef struct { @@ -226,13 +227,19 @@ void on_repo_accept_clicked(GtkWidget *, dictionary *dict); void on_web_publish_accept(GtkWidget *, dictionary *dict); void on_mirror_accept(GtkWidget *,dictionary *dict); void on_repo_remove(GtkWidget *self, main_window *widgets); -void on_remove_accept(GtkWidget *, GtkWidget *target); +void on_web_publish_remove_accept(GtkWidget *, main_window *widgets); +void on_mirror_remove_accept(GtkWidget *, main_window *widgets); +void on_repositories_remove_accept(GtkWidget *, main_window *widgets); repo_add_window *yon_repo_add_window_new(); web_publication_add_window *yon_web_publication_add_window_new(); mirror_add_window *yon_mirror_add_window_new(); mirror_configure_window *yon_mirror_configure_window_new(); +void on_file_chooser_open(GtkWidget *self, GtkEntry *target); + +void on_web_publish_path_changed(GtkWidget *, web_publication_add_window *window); + void on_repo_add(GtkWidget *, main_window *widgets); void on_mirror_add(GtkWidget *,main_window *widgets); void on_web_publish_add(GtkWidget *,main_window *widgets); @@ -240,6 +247,7 @@ void on_web_publish_add(GtkWidget *,main_window *widgets); void on_web_publish_remove(GtkWidget *self,main_window *widgets); void on_mirror_remove(GtkWidget *,main_window *widgets); +void on_repo_edit(GtkWidget *,main_window *widgets); void on_web_publish_edit(GtkWidget *,main_window *widgets); void on_mirror_edit(GtkWidget *,main_window *widgets); @@ -253,4 +261,6 @@ void on_mirror_path_add(GtkWidget *, mirror_add_window *window); void on_mirror_path_removed(GtkWidget *, GtkWidget *target); void on_mirror_path_edit(GtkWidget*,GtkWidget *target); void on_repo_source_add(GtkWidget *, repo_add_window *window); + +void on_cell_renderer_toggle_toggled(GtkWidget *self, gchar* path, GtkWidget *table); #endif \ No newline at end of file diff --git a/source/ubl-strings.h b/source/ubl-strings.h index e3c2683..e4890d0 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -7,5 +7,6 @@ #define EMPTY_IMPORTANT_LABEL _("Empty important field!") #define ADD_REPO_LABEL _("Add repository") #define REMOVE_REPO_WARNING_LABEL _("Are you sure want to remove repository?") + #define NO_SHARED_REPOS_LABEL _("No repositories were chosen to share") #endif \ No newline at end of file diff --git a/ubl-settings-update-mirror-path-add.glade b/ubl-settings-update-mirror-path-add.glade index 13c785d..93d25ea 100644 --- a/ubl-settings-update-mirror-path-add.glade +++ b/ubl-settings-update-mirror-path-add.glade @@ -47,7 +47,7 @@ - False + True True 1 diff --git a/ubl-settings-update-web-publication-add.glade b/ubl-settings-update-web-publication-add.glade index 742d47b..a223689 100644 --- a/ubl-settings-update-web-publication-add.glade +++ b/ubl-settings-update-web-publication-add.glade @@ -8,7 +8,14 @@ False com.ublinux.libublsettingsui-gtk3.zoom-symbolic - + + + + + + + + 500 False @@ -122,13 +129,18 @@ True liststore1 - + + none + Chosen - + + + 0 + @@ -137,6 +149,9 @@ Repository name + + 1 + @@ -144,7 +159,7 @@ - False + True True 2 @@ -379,7 +394,7 @@ - False + True True 1 diff --git a/ubl-settings-update.glade b/ubl-settings-update.glade index 36b38ed..0b262c0 100644 --- a/ubl-settings-update.glade +++ b/ubl-settings-update.glade @@ -396,6 +396,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + True + fixed Chosen @@ -406,7 +408,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Repository - + + end + @@ -685,6 +689,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + True + fixed Enabled @@ -696,9 +702,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + True + fixed Reposiory - + + end + 1 @@ -707,9 +717,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + True + fixed Source - + + end + 2 @@ -718,9 +732,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + True + fixed Signature level + end 125 @@ -733,7 +750,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Usage level - + + end + 4 @@ -877,6 +896,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + True + fixed Chosen @@ -890,7 +911,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Repository name - + + end + 1 @@ -1085,6 +1108,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + True + fixed Enabled @@ -1096,9 +1121,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + True + fixed Storage - + + end + 1 @@ -1107,9 +1136,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + True + fixed Chosen repositories - + + end + 2 @@ -1118,6 +1151,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + True + fixed Reviewer @@ -1129,9 +1164,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + True + fixed Port - + + end + 4 @@ -1140,9 +1179,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + True + fixed Name - + + end + 5 @@ -1151,9 +1194,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + True + fixed Password/Hash type - + + end + 6 @@ -1164,7 +1211,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Password/Password hash - + + end + 7 @@ -1369,9 +1418,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + True + fixed Repository - + + end + 0 @@ -1380,9 +1433,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + True + fixed Type - + + end + 1 @@ -1393,7 +1450,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Resource URL - + + end + 2 From 648e82c7711af0966933451da1fba5e91254e5dd Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 18 Oct 2024 18:12:17 +0600 Subject: [PATCH 8/8] Repository edit window WIP --- source/ubl-settings-update.c | 136 +++++++++++++++++- ubl-settings-update-web-publication-add.glade | 4 +- 2 files changed, 132 insertions(+), 8 deletions(-) diff --git a/source/ubl-settings-update.c b/source/ubl-settings-update.c index dfb38f6..9333d1a 100644 --- a/source/ubl-settings-update.c +++ b/source/ubl-settings-update.c @@ -212,10 +212,15 @@ void yon_interface_update(main_window *widgets){ gtk_list_store_set(widgets->WebPublicationList,&iter,5,parsed[3],-1); } if (cur_size>4&&!yon_char_is_empty(parsed[4])){ - gtk_list_store_set(widgets->WebPublicationList,&iter,6,parsed[4],-1); - } - if (cur_size>5&&!yon_char_is_empty(parsed[5])){ - gtk_list_store_set(widgets->WebPublicationList,&iter,7,parsed[5],-1); + if (!strcmp(parsed[4],"sha256")||!strcmp(parsed[4],"sha512")){ + gtk_list_store_set(widgets->WebPublicationList,&iter,7,parsed[5],-1); + gtk_list_store_set(widgets->WebPublicationList,&iter,6,parsed[4],-1); + } else { + gtk_list_store_set(widgets->WebPublicationList,&iter,6,parsed[4],-1); + if (cur_size>5&&!yon_char_is_empty(parsed[5])){ + gtk_list_store_set(widgets->WebPublicationList,&iter,7,parsed[5],-1); + } + } } } } @@ -409,10 +414,52 @@ void on_repo_edit(GtkWidget *,main_window *widgets){ repo_add_window *window = yon_repo_add_window_new(); yon_gtk_window_setup(GTK_WINDOW(window->Window),GTK_WINDOW(widgets->Window),ADD_REPO_LABEL,icon_path,"add_repo_window"); + GtkTreeIter iter; + char *target; + gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->RepositoriesTree)),NULL,&iter); + gtk_tree_model_get(GTK_TREE_MODEL(widgets->ReposList),&iter,1,&target,-1); dictionary *dict = NULL; yon_dictionary_add_or_create_if_exists_with_data(dict,"widgets",widgets); yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window); g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_repo_accept_clicked),dict); + + int size; + config_str parsed = yon_char_parse(config(REPOSITORY(target)),&size,";"); + if (size){ + { + int cur_size; + config_str repos = yon_char_parse(parsed[0],&cur_size,","); + for (int i=0;iStatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect(window->RepoSourceEntry); + return; + } + char *type = (char*)gtk_combo_box_get_active_id(GTK_COMBO_BOX(window->RepoSourceCombo)); + char *full_name = yon_char_append(type,target); + gtk_entry_set_text(GTK_ENTRY(window->RepoSourceEntry),""); + GtkBuilder *builder = gtk_builder_new_from_resource(glade_mirror_path_add_path); + gtk_box_pack_start(GTK_BOX(window->SourceBox),yon_gtk_builder_get_widget(builder,"PathRemovalBox"),0,0,2); + gtk_entry_set_text(GTK_ENTRY(gtk_builder_get_object(builder,"PathEntry")),full_name); + g_signal_connect(gtk_builder_get_object(builder,"PathEditButton"),"clicked",G_CALLBACK(on_mirror_path_edit),gtk_builder_get_object(builder,"PathRemovalBox")); + g_signal_connect(gtk_builder_get_object(builder,"PathRemoveButton"),"clicked",G_CALLBACK(on_mirror_path_removed),gtk_builder_get_object(builder,"PathRemovalBox")); + } + } + if (size>1&&!yon_char_is_empty(parsed[1])){ //siglevel + int cur_size; + config_str siglevel = yon_char_parse(parsed[1],&cur_size,","); + gtk_combo_box_set_active_id(GTK_COMBO_BOX(window->RepoSignCheckCombo),siglevel[0]); + gtk_combo_box_set_active_id(GTK_COMBO_BOX(window->RepoSignConditionCombo),siglevel[1]); + } + if (size>2&&!yon_char_is_empty(parsed[2])){} //usage + if (size>3&&!yon_char_is_empty(parsed[3])){ //disable + if (strcmp(parsed[3],"disable")){ + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->EnabledCheck),1); + } + } + } + gtk_widget_show(window->Window); } void on_web_publish_edit(GtkWidget *,main_window *widgets){ @@ -423,6 +470,62 @@ void on_web_publish_edit(GtkWidget *,main_window *widgets){ yon_dictionary_add_or_create_if_exists_with_data(dict,"widgets",widgets); yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window); g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_web_publish_accept),dict); + GtkTreeIter iter; + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->WebPublicationTree)),NULL,&iter)){ + char *storage; + char *repos; + gtk_tree_model_get(GTK_TREE_MODEL(widgets->WebPublicationList),&iter,1,&storage,2,&repos,-1); + gtk_entry_set_text(GTK_ENTRY(window->PathEntry),storage); + while(gtk_events_pending()) gtk_main_iteration(); + char *full_name = storage; + if(!yon_char_is_empty(repos)){ + int size; + config_str parsed = yon_char_parse(repos,&size,"\n"); + full_name = yon_char_unite(storage,":",yon_char_replace(repos,"\n",","),NULL); + if (size){ + GtkTreeIter itar; + for_iter(GTK_TREE_MODEL(window->list),&itar){ + char *target; + gtk_tree_model_get(GTK_TREE_MODEL(window->list),&itar,1,&target,-1); + if (yon_char_parsed_check_exist(parsed,size,target)==-1){ + gtk_list_store_set(window->list,&itar,0,0,-1); + } + } + } + } + char *parameter = config(REPOPUBLIC_WEB_full(full_name)); + int size; + config_str parsed = yon_char_parse(parameter,&size,":"); + if (size){ + if (!strcmp(parsed[0],"enable")||!strcmp(parsed[0],"yes")){ + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->EnablePublishCheck),1); + } + if (size>1&&!strcmp(parsed[1],"listing")){ + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->EnableWebFileBrowserCheck),1); + } + if (size>2&&!yon_char_is_empty(parsed[2])){ + gtk_entry_set_text(GTK_ENTRY(window->PortEntry),parsed[2]); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->PortCheck),1); + } + if (size>3&&!yon_char_is_empty(parsed[3])){ + gtk_entry_set_text(GTK_ENTRY(window->UsernameEntry),parsed[3]); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->UsernameCheck),1); + } + if (size>4&&!yon_char_is_empty(parsed[4])){ + if (!strcmp(parsed[4],"sha256")||!strcmp(parsed[4],"sha512")){ + gtk_combo_box_set_active_id(GTK_COMBO_BOX(window->UserPasswordCombo),parsed[4]); + gtk_entry_set_text(GTK_ENTRY(window->UserPasswordEntry),parsed[5]); + + } else { + gtk_entry_set_text(GTK_ENTRY(window->UserPasswordEntry),parsed[4]); + if (size>5) + gtk_combo_box_set_active_id(GTK_COMBO_BOX(window->UserPasswordCombo),""); + } + } + } + } + + gtk_widget_show(window->Window); } void on_mirror_edit(GtkWidget *,main_window *widgets){ @@ -436,15 +539,31 @@ void on_mirror_edit(GtkWidget *,main_window *widgets){ char *target; GtkTreeIter iter; + gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->MirrorTree)),NULL,&iter); gtk_tree_model_get(GTK_TREE_MODEL(widgets->MirrorList),&iter,0,&target,-1); + gtk_entry_set_text(GTK_ENTRY(window->NameEntry),target); char *parameter = config(REPOPUBLIC_CACHE_full(target)); int size; config_str parsed = yon_char_parse(parameter,&size,","); for (int i=0;iStatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect(window->TypeEntry); + return; + } + char *type = (char*)gtk_combo_box_get_active_id(GTK_COMBO_BOX(window->TypeCombo)); + char *full_name = yon_char_unite(type,"@",target,NULL); + gtk_entry_set_text(GTK_ENTRY(window->TypeEntry),""); GtkBuilder *builder = gtk_builder_new_from_resource(glade_mirror_path_add_path); + gtk_box_pack_start(GTK_BOX(window->PathBox),yon_gtk_builder_get_widget(builder,"PathRemovalBox"),0,0,2); + gtk_entry_set_text(GTK_ENTRY(gtk_builder_get_object(builder,"PathEntry")),full_name); + g_signal_connect(gtk_builder_get_object(builder,"PathEditButton"),"clicked",G_CALLBACK(on_mirror_path_edit),gtk_builder_get_object(builder,"PathRemovalBox")); + g_signal_connect(gtk_builder_get_object(builder,"PathRemoveButton"),"clicked",G_CALLBACK(on_mirror_path_removed),gtk_builder_get_object(builder,"PathRemovalBox")); + g_object_unref(G_OBJECT(builder)); } - + gtk_widget_show(window->Window); } void on_mirror_configure(GtkWidget *,main_window *widgets){ @@ -518,6 +637,7 @@ void on_web_publish_accept(GtkWidget *, dictionary *dict){ int username_check = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->UsernameCheck)); char *username = (char*)gtk_entry_get_text(GTK_ENTRY(window->UsernameEntry)); char *user_password = (char*)gtk_entry_get_text(GTK_ENTRY(window->UserPasswordEntry)); + char *encryption = (char*)gtk_combo_box_get_active_id(GTK_COMBO_BOX(window->UserPasswordCombo)); char *name = (char*)gtk_entry_get_text(GTK_ENTRY(window->PathEntry)); char *full_name = ""; @@ -542,7 +662,7 @@ void on_web_publish_accept(GtkWidget *, dictionary *dict){ return; } char *final_name = yon_char_is_empty(full_name)||!disabled ? name : yon_char_unite(name,":",full_name,NULL); - char *final = yon_char_unite(enabled?"enable":"disable",":",enable_browser?"listing":"",":",port_enabled?port:"",":",username_check?username:"",username_check?user_password:"",NULL); + char *final = yon_char_unite(enabled?"enable":"disable",":",enable_browser?"listing":"",":",port_enabled?port:"",":",username_check?username:"",":",username_check?yon_char_is_empty(encryption)? user_password:encryption:"",":",username_check?!yon_char_is_empty(encryption)?user_password:"":"",NULL); yon_config_register(REPOPUBLIC_WEB_full(final_name),REPOPUBLIC_WEB_command(final_name),final); yon_interface_update(widgets); gtk_widget_destroy(window->Window); @@ -831,6 +951,10 @@ void yon_main_window_complete(main_window *widgets){ g_signal_connect(G_OBJECT(widgets->PublicationTree),"cursor-changed",G_CALLBACK(on_selection_changed),widgets); g_signal_connect(G_OBJECT(widgets->WebPublicationTree),"cursor-changed",G_CALLBACK(on_selection_changed),widgets); g_signal_connect(G_OBJECT(widgets->MirrorTree),"cursor-changed",G_CALLBACK(on_selection_changed),widgets); + + g_signal_connect(G_OBJECT(widgets->MirrorEditButton),"clicked",G_CALLBACK(on_mirror_edit),widgets); + g_signal_connect(G_OBJECT(widgets->WebPublicationEditButton),"clicked",G_CALLBACK(on_web_publish_edit),widgets); + g_signal_connect(G_OBJECT(widgets->RepositoriesEditButton),"clicked",G_CALLBACK(on_repo_edit),widgets); } { yon_gtk_tree_view_minimal_fixed_size_set_full(GTK_TREE_VIEW(widgets->MirrorTree)); diff --git a/ubl-settings-update-web-publication-add.glade b/ubl-settings-update-web-publication-add.glade index a223689..3c13554 100644 --- a/ubl-settings-update-web-publication-add.glade +++ b/ubl-settings-update-web-publication-add.glade @@ -346,8 +346,8 @@ 0 Not encrypted - Encrypted with SHA256 - Encrypted with SHA512 + Encrypted with SHA256 + Encrypted with SHA512