diff --git a/source/ubl-settings-kernel.c b/source/ubl-settings-kernel.c index 0d71e08..18865c5 100644 --- a/source/ubl-settings-kernel.c +++ b/source/ubl-settings-kernel.c @@ -118,9 +118,7 @@ void on_config_custom_load(GtkWidget *,main_window *widgets){ yon_interface_update(widgets); } - -void *yon_interface_update(main_window *widgets){ - g_mutex_lock(&main_config.mutex); +gboolean yon_clear_interface(main_window *widgets){ if (!main_config.kernel_tabs){ GList *list = gtk_container_get_children(GTK_CONTAINER(widgets->KernelsPackageBox)); for (guint i=0;iinstall_tags_box)); + for (guint i=0;imodule_installed){ + yon_tag_add(GTK_BOX(tab->install_tags_box),MODULE_INSTALLED_LABEL,"tag_green",NULL); + + gtk_image_set_from_icon_name(GTK_IMAGE(tab->module_icon),module_icon_path,GTK_ICON_SIZE_BUTTON); + gtk_widget_show(tab->remove_module_button); + gtk_widget_show(tab->remove_package_button); + gtk_widget_show(tab->update_module_button); + gtk_widget_show(tab->update_package_button); + gtk_widget_hide(tab->install_module_button); + gtk_widget_hide(tab->install_package_button); + } + { + if (tab->package_installed){ + yon_tag_add(GTK_BOX(tab->install_tags_box),PACKAGE_INSTALLED_LABEL,"tag_green",NULL); + gtk_image_set_from_icon_name(GTK_IMAGE(tab->package_icon),package_icon_path,GTK_ICON_SIZE_BUTTON); + gtk_widget_hide(tab->install_package_button); + gtk_widget_show(tab->remove_package_button); + gtk_widget_show(tab->update_package_button); + } + } + gtk_widget_set_sensitive(tab->update_module_button,!tab->module_updated); + gtk_widget_set_sensitive(tab->update_package_button,!tab->package_updated); + } else { + yon_tag_add(GTK_BOX(tab->install_tags_box),UNKNOWN_LABEL,"tag_grey",NULL); + } + gtk_widget_show(tab->main_box); + return G_SOURCE_REMOVE; +} +void *yon_tab_set_installed(kernels_tab *tab){ + char *check_install_command = get_package_is_installed_command(tab->module); + if (!system(check_install_command)){ + tab->module_installed=1; + } else tab->module_installed=0; + free(check_install_command); + check_install_command = get_package_is_installed_command(tab->package); + if (!system(check_install_command)){ + tab->package_installed=1; + } else tab->package_installed=0; + free(check_install_command); + + check_install_command = get_package_is_updated_command(tab->module); + if (!system(check_install_command)){ + tab->module_updated = 0; + } else tab->module_updated = 1; + free(check_install_command); + check_install_command = get_package_is_updated_command(tab->package); + if (!system(check_install_command)){ + tab->package_updated = 0; + } else tab->package_updated = 1; + free(check_install_command); + + gdk_threads_add_idle((GSourceFunc)yon_tab_create_tags,tab); + return NULL; +} + +void *yon_interface_update(main_window *widgets){ + gdk_threads_add_idle((GSourceFunc)yon_clear_interface,widgets); int kernels_size; config_str kernels = yon_resource_open_file(kernels_path, &kernels_size); @@ -151,6 +216,7 @@ void *yon_interface_update(main_window *widgets){ for (int i=1;iKernelsPackageBox),kernels[i],widgets); + g_thread_new("tags_install_tread",(GThreadFunc)yon_tab_set_installed,tab); { GList *list = gtk_container_get_children(GTK_CONTAINER(tab->run_tags_box)); for (guint i=0;iAdditionsPackageBox),kernels[i],widgets); + g_thread_new("tags_install_tread",(GThreadFunc)yon_tab_set_installed,tab); gtk_widget_set_can_focus(gtk_widget_get_parent(tab->main_box),0); } - g_mutex_unlock(&main_config.mutex); return NULL; } @@ -234,9 +300,6 @@ int yon_tag_add(GtkBox *target,char *tag_label, char *tag_style, char *icon_name } gboolean on_command_execute_success(GtkWidget *,gint status,main_window *widgets){ - g_mutex_lock(&main_config.pulse_mutex); - main_config.pulse_active=0; - g_mutex_unlock(&main_config.pulse_mutex); g_mutex_lock(&main_config.progress_mutex); main_config.progress_active=0; g_mutex_unlock(&main_config.progress_mutex); @@ -252,20 +315,25 @@ gboolean on_command_execute_success(GtkWidget *,gint status,main_window *widgets gboolean yon_terminal_get_progress(main_window *widgets){ char *text = vte_terminal_get_text_format(VTE_TERMINAL(widgets->InstallTerminal),VTE_FORMAT_TEXT); - GRegex *regex = g_regex_new("\\d?\\d\\d%",0,0,NULL); + GRegex *regex = g_regex_new("\\d?\\d?\\d%",0,0,NULL); GMatchInfo *match = NULL; g_regex_match(regex,text,0,&match); g_regex_unref(regex); - char *target = g_match_info_fetch(match,0); - g_match_info_unref(match); + config_str target = g_match_info_fetch_all(match); + double percentage = 0.0; - if (!yon_char_is_empty(target)) { - target[strlen(target)-1]='\0'; - double percentage = atof(target); - gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(widgets->InstallationProgress),percentage/100); + if (target){ + int i; + for (i=0;target[i];i++){ + target[i][strlen(target[i])-1]='\0'; + percentage = atof(target[i]); + } + gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(widgets->InstallationProgress),percentage/i/100); } + g_match_info_unref(match); + g_mutex_lock(&main_config.progress_mutex); if (!main_config.progress_active){ gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(widgets->InstallationProgress),0); @@ -493,11 +561,6 @@ kernels_tab *yon_tab_row_new(GtkListBox *target, char *target_string, main_windo kernels_tab *tab = NULL; if (cur){ tab = (kernels_tab*)cur->data; - GList *list = gtk_container_get_children(GTK_CONTAINER(tab->install_tags_box)); - for (guint i=0;ichangelog_button); gtk_widget_show(tab->launch_button); gtk_image_set_from_icon_name(GTK_IMAGE(tab->module_icon),"",GTK_ICON_SIZE_BUTTON); @@ -547,6 +610,8 @@ kernels_tab *yon_tab_row_new(GtkListBox *target, char *target_string, main_windo tab->description_label = yon_gtk_builder_get_widget(builder,"DescriptionLabel"); tab->remove_module_button = yon_gtk_builder_get_widget(builder,"RemoveModuleButton"); tab->remove_package_button = yon_gtk_builder_get_widget(builder,"RemovePackageButton"); + tab->update_module_button = yon_gtk_builder_get_widget(builder,"ModuleUpdateButton"); + tab->update_package_button = yon_gtk_builder_get_widget(builder,"PackageUpdateButton"); tab->install_module_button = yon_gtk_builder_get_widget(builder,"InstallModuleButton"); tab->install_package_button = yon_gtk_builder_get_widget(builder,"InstallPackageButton"); tab->changelog_button = yon_gtk_builder_get_widget(builder,"ChangelogButton"); @@ -604,35 +669,7 @@ kernels_tab *yon_tab_row_new(GtkListBox *target, char *target_string, main_windo } tab->module_requirements = yon_char_parse(parsed[3],&tab->module_requirements_size,","); tab->package_requirements = yon_char_parse(parsed[4],&tab->package_requirements_size,","); - char *check_install_command = get_package_is_installed_command(tab->module); - if (!getuid()){ - if (!system(check_install_command)){ - yon_tag_add(GTK_BOX(tab->install_tags_box),MODULE_INSTALLED_LABEL,"tag_green",NULL); - tab->module_installed=1; - - gtk_image_set_from_icon_name(GTK_IMAGE(tab->module_icon),module_icon_path,GTK_ICON_SIZE_BUTTON); - gtk_widget_show(tab->remove_module_button); - gtk_widget_hide(tab->install_module_button); - gtk_widget_show(tab->changelog_button); - gtk_widget_show(tab->launch_button); - - } else tab->module_installed=0; - { - free(check_install_command); - check_install_command = get_package_is_installed_command(tab->package); - if (!system(check_install_command)){ - tab->package_installed=1; - yon_tag_add(GTK_BOX(tab->install_tags_box),PACKAGE_INSTALLED_LABEL,"tag_green",NULL); - gtk_image_set_from_icon_name(GTK_IMAGE(tab->package_icon),package_icon_path,GTK_ICON_SIZE_BUTTON); - gtk_widget_hide(tab->install_package_button); - gtk_widget_show(tab->remove_package_button); - gtk_widget_show(tab->changelog_button); - gtk_widget_show(tab->launch_button); - } else tab->package_installed=0; - } - } else { - yon_tag_add(GTK_BOX(tab->install_tags_box),UNKNOWN_LABEL,"tag_grey",NULL); - } + yon_char_parsed_free(types_parsed,types_size); gtk_label_set_markup(GTK_LABEL(tab->name_label),name); gtk_label_set_markup(GTK_LABEL(tab->module_label),module); @@ -661,31 +698,30 @@ additions_kernels_tab *yon_additions_tab_row_new(GtkListBox *target, char *targe additions_kernels_tab *tab = NULL; if (cur){ tab = (additions_kernels_tab*)cur->data; - GList *list = gtk_container_get_children(GTK_CONTAINER(tab->install_tags_box)); - for (guint i=0;imodule_icon),"",GTK_ICON_SIZE_BUTTON); gtk_image_set_from_icon_name(GTK_IMAGE(tab->package_icon),"",GTK_ICON_SIZE_BUTTON); - g_list_free(list); if (tab->module_installed){ gtk_widget_show(tab->remove_module_button); gtk_widget_hide(tab->install_module_button); + gtk_widget_show(tab->update_module_button); gtk_widget_show(tab->remove_module_button); yon_tag_add(GTK_BOX(tab->install_tags_box),MODULE_INSTALLED_LABEL,"tag_green",NULL); gtk_image_set_from_icon_name(GTK_IMAGE(tab->module_icon),module_icon_path,GTK_ICON_SIZE_BUTTON); } else { + gtk_widget_hide(tab->update_module_button); gtk_widget_hide(tab->remove_module_button); gtk_widget_show(tab->install_module_button); } if (tab->package_installed){ + gtk_widget_show(tab->update_package_button); gtk_widget_show(tab->remove_package_button); gtk_widget_hide(tab->install_package_button); yon_tag_add(GTK_BOX(tab->install_tags_box),PACKAGE_INSTALLED_LABEL,"tag_green",NULL); gtk_image_set_from_icon_name(GTK_IMAGE(tab->package_icon),package_icon_path,GTK_ICON_SIZE_BUTTON); } else { + gtk_widget_hide(tab->update_package_button); gtk_widget_hide(tab->remove_package_button); gtk_widget_show(tab->install_package_button); @@ -708,10 +744,14 @@ additions_kernels_tab *yon_additions_tab_row_new(GtkListBox *target, char *targe tab->remove_package_button = yon_gtk_builder_get_widget(builder,"RemovePackageButton"); tab->install_module_button = yon_gtk_builder_get_widget(builder,"InstallModuleButton"); tab->install_package_button = yon_gtk_builder_get_widget(builder,"InstallPackageButton"); + tab->update_module_button = yon_gtk_builder_get_widget(builder,"ModuleUpdateButton"); + tab->update_package_button = yon_gtk_builder_get_widget(builder,"PackageUpdateButton"); 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,"tab",tab); + g_signal_connect(G_OBJECT(tab->update_module_button),"clicked",G_CALLBACK(on_module_install_clicked),dict); + g_signal_connect(G_OBJECT(tab->update_package_button),"clicked",G_CALLBACK(on_package_install_clicked),dict); g_signal_connect(G_OBJECT(tab->install_module_button),"clicked",G_CALLBACK(on_module_install_clicked),dict); g_signal_connect(G_OBJECT(tab->install_package_button),"clicked",G_CALLBACK(on_package_install_clicked),dict); g_signal_connect(G_OBJECT(tab->remove_module_button),"clicked",G_CALLBACK(on_module_remove_clicked),dict); @@ -727,31 +767,9 @@ additions_kernels_tab *yon_additions_tab_row_new(GtkListBox *target, char *targe char *name = yon_char_unite("",tab->name,"",NULL); char *module = yon_char_unite("",MODULE_LABEL," ",tab->module,"",NULL); char *package = yon_char_unite("",PACKAGE_LABEL," ",tab->package,"",NULL); - char *check_install_command = get_package_is_installed_command(tab->module); yon_dictionary_add_or_create_if_exists_with_data(main_config.addition_tabs,tab->package,tab); - if (!system(check_install_command)){ - tab->module_installed=1; - yon_tag_add(GTK_BOX(tab->install_tags_box),MODULE_INSTALLED_LABEL,"tag_green",NULL); - - gtk_image_set_from_icon_name(GTK_IMAGE(tab->module_icon),module_icon_path,GTK_ICON_SIZE_BUTTON); - gtk_widget_show(tab->remove_module_button); - gtk_widget_show(tab->remove_package_button); - gtk_widget_hide(tab->install_module_button); - gtk_widget_hide(tab->install_package_button); - } else tab->module_installed=0; - { - free(check_install_command); - check_install_command = get_package_is_installed_command(tab->package); - if (!system(check_install_command)){ - tab->package_installed=1; - yon_tag_add(GTK_BOX(tab->install_tags_box),PACKAGE_INSTALLED_LABEL,"tag_green",NULL); - gtk_image_set_from_icon_name(GTK_IMAGE(tab->package_icon),package_icon_path,GTK_ICON_SIZE_BUTTON); - gtk_widget_hide(tab->install_package_button); - gtk_widget_show(tab->remove_package_button); - } else tab->package_installed=0; - } gtk_label_set_markup(GTK_LABEL(tab->name_label),name); gtk_label_set_markup(GTK_LABEL(tab->module_label),module); gtk_label_set_markup(GTK_LABEL(tab->package_label),package); @@ -788,7 +806,6 @@ void config_init(){ main_config.load_mode=1; main_config.save_config=1; main_config.kernel_tabs=NULL; - main_config.pulse_active=0; main_config.progress_active=0; } @@ -858,17 +875,6 @@ void on_changelog_clicked(GtkWidget *, kernels_tab *tab){ gtk_widget_show(window->window); } -gboolean yon_pulse_run(main_window *widgets){ - gtk_progress_bar_pulse(GTK_PROGRESS_BAR(widgets->InstallationProgress)); - g_mutex_lock(&main_config.pulse_mutex); - gboolean ret; - if (main_config.pulse_active) ret = 0; - else ret = 1; - - g_mutex_unlock(&main_config.pulse_mutex); - return ret; -} - void on_build_execute(GtkWidget *, dictionary *dict){ main_window *widgets = yon_dictionary_get_data(dict->first,main_window*); install_window *window = yon_dictionary_get_data(dict->first->next,install_window*); @@ -877,12 +883,8 @@ void on_build_execute(GtkWidget *, dictionary *dict){ char *target = (char*)gtk_combo_box_get_active_id(GTK_COMBO_BOX(window->KernelVersionCombo)); char *filename = (char*)gtk_entry_get_text(GTK_ENTRY(window->FilenameEntry)); char *command = build_command(target,filename,debug,drivers); - yon_command_execute_async(command,widgets); + yon_terminal_window_launch(GTK_WINDOW(widgets->Window),command); gtk_widget_destroy(window->window); - g_mutex_lock(&main_config.pulse_mutex); - main_config.pulse_active=1; - g_mutex_unlock(&main_config.pulse_mutex); - g_timeout_add(1000,(GSourceFunc)yon_pulse_run,widgets); } void on_building_clicked(GtkWidget *, main_window *widgets){ diff --git a/source/ubl-settings-kernel.h b/source/ubl-settings-kernel.h index 648d064..0f383d2 100644 --- a/source/ubl-settings-kernel.h +++ b/source/ubl-settings-kernel.h @@ -46,6 +46,7 @@ #define get_kernel_changelog_command(target) yon_char_unite("find /usr/lib/modules/ -maxdepth 2 -type f -iname \"pkgbase\" -exec grep -il \"",target,"\" {} + | xargs dirname | xargs -I {} cat \"{}/changelog\"", NULL) #define get_package_info_command(target) yon_char_append("pacman -Si ",target) #define get_package_is_installed_command(target) yon_char_append("pacman -Qq ",target) +#define get_package_is_updated_command(target) yon_char_append("pacman -Qu ",target) #define install_command(target) yon_char_append("pacman -S --noconfirm ",target) #define remove_command(target) yon_char_append("pacman -R --noconfirm ",target) @@ -77,8 +78,6 @@ typedef struct { int save_config; dictionary *kernel_tabs; dictionary *addition_tabs; - GMutex pulse_mutex; - int pulse_active; GMutex progress_mutex; int progress_active; config_str launch_arguments; @@ -146,6 +145,8 @@ typedef struct { char *name; int module_installed; int package_installed; + int module_updated; + int package_updated; GtkWidget *main_box; GtkWidget *name_label; GtkWidget *module_label; @@ -153,15 +154,17 @@ typedef struct { GtkWidget *module_icon; GtkWidget *package_icon; GtkWidget *install_tags_box; - GtkWidget *run_tags_box; - GtkWidget *tags_box; GtkWidget *description_label; GtkWidget *remove_module_button; GtkWidget *remove_package_button; + GtkWidget *update_module_button; + GtkWidget *update_package_button; GtkWidget *install_module_button; GtkWidget *install_package_button; GtkWidget *changelog_button; GtkWidget *launch_button; + GtkWidget *run_tags_box; + GtkWidget *tags_box; config_str module_requirements; int module_requirements_size; config_str package_requirements; @@ -175,6 +178,8 @@ typedef struct { char *name; int module_installed; int package_installed; + int module_updated; + int package_updated; GtkWidget *main_box; GtkWidget *name_label; GtkWidget *module_label; @@ -185,6 +190,8 @@ typedef struct { GtkWidget *description_label; GtkWidget *remove_module_button; GtkWidget *remove_package_button; + GtkWidget *update_module_button; + GtkWidget *update_package_button; GtkWidget *install_module_button; GtkWidget *install_package_button; @@ -204,6 +211,9 @@ typedef struct { void on_save_done(main_window *widgets, config_str output, int size); +gboolean yon_clear_interface(main_window *widgets); +gboolean yon_tab_create_tags(kernels_tab *tab); +void *yon_tab_set_installed(kernels_tab *tab); void *yon_interface_update(main_window *widgets); @@ -249,7 +259,6 @@ void on_info_clicked(GtkWidget *, main_window *widgets); void on_changelog_clicked(GtkWidget *, kernels_tab *tab); -gboolean yon_pulse_run(main_window *widgets); void on_build_execute(GtkWidget *, dictionary *dict); void on_building_clicked(GtkWidget *, main_window *widgets); diff --git a/ubl-settings-kernel-additions-table-row.glade b/ubl-settings-kernel-additions-table-row.glade index 74f0113..66e758e 100644 --- a/ubl-settings-kernel-additions-table-row.glade +++ b/ubl-settings-kernel-additions-table-row.glade @@ -3,6 +3,16 @@ + + True + False + com.ublinux.libublsettingsui-gtk.update-cloud-symbolic + + + True + False + com.ublinux.libublsettingsui-gtk.update-cloud-symbolic + True False @@ -176,13 +186,42 @@ - - Remove module - True - True - + + True + False + 5 + + + True + True + image1 + + + + False + True + 0 + + + + + Remove module + True + True + + + + True + True + 2 + + False @@ -207,13 +246,42 @@ - - Remove package - True - True - + + True + False + 5 + + + True + True + image2 + + + + False + True + 0 + + + + + Remove package + True + True + + + + True + True + 2 + + False diff --git a/ubl-settings-kernel-table-row.glade b/ubl-settings-kernel-table-row.glade index c745b22..29369e1 100644 --- a/ubl-settings-kernel-table-row.glade +++ b/ubl-settings-kernel-table-row.glade @@ -3,6 +3,16 @@ + + True + False + com.ublinux.libublsettingsui-gtk.update-cloud-symbolic + + + True + False + com.ublinux.libublsettingsui-gtk.update-cloud-symbolic + True False @@ -212,13 +222,42 @@ - - Remove module - True - True - + + True + False + 5 + + + True + True + image1 + + + + False + True + 0 + + + + + Remove module + True + True + + + + True + True + 2 + + False @@ -243,13 +282,42 @@ - - Remove package - True - True - + + True + False + 5 + + + True + True + image2 + + + + False + True + 0 + + + + + Remove package + True + True + + + + True + True + 2 + + False diff --git a/ubl-settings-kernel.css b/ubl-settings-kernel.css index 225534a..5e3a34f 100644 --- a/ubl-settings-kernel.css +++ b/ubl-settings-kernel.css @@ -139,7 +139,14 @@ background:transparent; } .listfix row:selected * .buttonlistfx:active * { + background-color: @theme_selected_fg_color; color: @theme_fg_color; + transition:100ms; +} +.listfix row:selected * .buttonlistfx:active { + background-color: @theme_selected_fg_color; + color: @theme_fg_color; + transition:100ms; } @@ -205,4 +212,31 @@ background:transparent; color:#2f2f2f; background-color:#999999 +} +.updatebutton { + background-color: #ef7a7a; + color: @theme_bg_color; + border-color: #aa5555; +} +.updatebutton *{ + background-color: #ef7a7a; + color: @theme_bg_color; +} +.updatebutton:active { + background-color: @theme_selected_bg_color; + color: @theme_bg_color; + border-color: @theme_selected_bg_color; +} +.updatebutton:active *{ + background-color: @theme_selected_bg_color; + color: @theme_bg_color; +} +.updatebutton:disabled { + background-color: #ffcfcf; + border-color: @insensitive_fg_color; + border-width:0.5px; +} +.updatebutton *:disabled { + background-color: #ffcfcf; + color: @insensitive_fg_color; } \ No newline at end of file diff --git a/ubl-settings-kernel.glade b/ubl-settings-kernel.glade index 3d4b658..1df447e 100644 --- a/ubl-settings-kernel.glade +++ b/ubl-settings-kernel.glade @@ -347,6 +347,9 @@ True False +