Progress bar fix

pull/24/head
parent dcab08ee04
commit b576bc5e5d

@ -342,23 +342,31 @@ 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%",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);
config_str target = g_match_info_fetch_all(match);
double percentage = 0.0;
if (target){
int i;
for (i=0;target[i+1];i++){};
target[i][strlen(target[i])-1]='\0';
percentage = atof(target[i]);
yon_debug_output("%s\n",target[i]);
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(widgets->InstallationProgress),percentage/100);
char *last_match = NULL;
while (g_match_info_matches(match)) {
char *current_match = g_match_info_fetch(match, 0);
if (last_match) {
g_free(last_match);
}
last_match = current_match;
g_match_info_next(match, NULL);
}
if (last_match) {
yon_char_remove_last_symbol(last_match,'%');
percentage = atof(last_match);
yon_debug_output("%s\n", text);
yon_debug_output("%s\n", last_match);
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(widgets->InstallationProgress), percentage / 100);
g_free(last_match);
}
g_match_info_unref(match);
g_mutex_lock(&main_config.progress_mutex);
@ -407,8 +415,6 @@ void on_module_install_accept(GtkWidget *, dictionary *dict){
}
}
char *command = install_command(modules_to_install);
char *command_unload = unload_command(modules_to_install);
system(command_unload);
yon_command_execute_async(command,widgets);
tab->module_installed=1;
on_subwindow_close(window->Window);
@ -558,6 +564,8 @@ void on_module_remove_clicked(GtkWidget *self,dictionary *dict){
if (yon_confirmation_dialog_call(self,data) == GTK_RESPONSE_ACCEPT){
char *target = yon_package_string_set(tab->module);
char *command = remove_command(target);
char *command_unload = unload_command(target);
system(yon_debug_output("%s\n",command_unload));
g_signal_connect(G_OBJECT(widgets->InstallTerminal),"child-exited",G_CALLBACK(on_module_remove_done),tab);
yon_command_execute_async(command,widgets);
tab->module_installed=0;

Loading…
Cancel
Save