diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index 9bc3756..dee4abb 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -1202,12 +1202,17 @@ void on_logrotate_apps_configure(GtkWidget *self, logrotate_window *window){ if (!strcmp(cur[i],parsed_check[j])) found ++; } } - if (cur_size==found) return; + if (cur_size==found) { + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),REPEATED_PATHS_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + return; + } + } settings = yon_char_replace(settings,",\t",","); if (settings[0]==',') yon_char_divide_search(settings,",",-1); yon_config_register(LOGROTATE(yon_char_replace(paths,"\n",",")),"logging",settings); gtk_list_store_set(main_config.logrotate_list,&itar,0,name,1,paths,-1); + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),SUCCESS_LABEL,5,BACKGROUND_IMAGE_SUCCESS_TYPE); } } @@ -1278,6 +1283,7 @@ void on_logrotate_tab_open(GtkWidget *self, main_window *widgets){ window->ConfigureButton = yon_gtk_builder_get_widget(builder,"ConfigureButton"); window->AddButton = yon_gtk_builder_get_widget(builder,"AddButton"); window->RemoveButton = yon_gtk_builder_get_widget(builder,"RemoveButton"); + window->StatusBox = yon_gtk_builder_get_widget(builder,"StatusBox"); gtk_window_set_title(GTK_WINDOW(window->Window),TITLE_LABEL); gtk_tree_view_set_model(GTK_TREE_VIEW(window->MainTree),GTK_TREE_MODEL(main_config.logrotate_list)); diff --git a/source/ubl-settings-logging.h b/source/ubl-settings-logging.h index bd964a2..b2da285 100644 --- a/source/ubl-settings-logging.h +++ b/source/ubl-settings-logging.h @@ -228,6 +228,7 @@ typedef struct { GtkWidget *ConfigureButton; GtkWidget *CancelButton; GtkWidget *SaveButton; + GtkWidget *StatusBox; } logrotate_window; typedef struct { diff --git a/source/ubl-utils.c b/source/ubl-utils.c index 93b95bb..e264544 100644 --- a/source/ubl-utils.c +++ b/source/ubl-utils.c @@ -1363,11 +1363,13 @@ int yon_config_save_registered(char *path){ if (sections_add) for_dictionaries(dct,sections_add){ char *command = yon_dictionary_get_data(dct,char*); + printf(command); yon_launch(command); } if (sections_remove) for_dictionaries(dct,sections_remove){ char *command = yon_dictionary_get_data(dct,char*); + printf(command); yon_launch(command); } return 1; @@ -2103,58 +2105,63 @@ void _yon_ubl_status_box_timed_remove(struct temp_statusbox *statusstruct){ gtk_revealer_set_reveal_child(GTK_REVEALER(statusstruct->revealer),0); sleep(1); gtk_widget_destroy(statusstruct->revealer); + } + status_thread_busy=0; } void yon_ubl_status_box_spawn(GtkContainer *container,char *display_text, int timeout,BACKGROUND_IMAGE_TYPE type){ - GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5); - GtkWidget *revealer = gtk_revealer_new(); - GtkWidget *label = gtk_label_new(""); - GtkWidget *icon = gtk_image_new(); - gtk_container_add(GTK_CONTAINER(revealer),box); - gtk_box_pack_start(GTK_BOX(box),icon,0,0,5); - gtk_box_pack_start(GTK_BOX(box),label,0,0,5); - gtk_container_add(container,revealer); - - gtk_widget_show_all(revealer); - gtk_revealer_set_reveal_child(GTK_REVEALER(revealer),1); - - gtk_widget_set_margin_bottom(label,9); - gtk_widget_set_margin_top(label,9); - gtk_label_set_xalign(GTK_LABEL(label),0.0); - PangoAttrList *attributes = pango_attr_list_new(); - PangoAttribute *boldAttr = pango_attr_weight_new(PANGO_WEIGHT_BOLD); - pango_attr_list_insert(attributes, boldAttr); - gtk_label_set_attributes(GTK_LABEL(label),attributes); - - GdkRGBA textColor; - gdk_rgba_parse(&textColor, "#4d4d4d4d4d4d"); - PangoAttribute *colorAttr = pango_attr_foreground_new( - (int)(textColor.red * 65535), - (int)(textColor.green * 65535), - (int)(textColor.blue * 65535) - ); - pango_attr_list_insert(attributes, colorAttr); - - GtkIconTheme *ictheme = gtk_icon_theme_get_default(); - if (type == BACKGROUND_IMAGE_SUCCESS_TYPE||! type) - { - gtk_style_context_remove_class(gtk_widget_get_style_context(box), "boxInfoMessError"); - gtk_style_context_add_class(gtk_widget_get_style_context(box), "boxInfoMessOK"); - gtk_image_set_from_pixbuf(GTK_IMAGE(icon), gtk_icon_theme_load_icon_for_scale(ictheme, "com.ublinux.ubl-settings-logging.checked", 25, 1, GTK_ICON_LOOKUP_FORCE_SIZE, NULL)); - } - else if (type == BACKGROUND_IMAGE_FAIL_TYPE) - { - gtk_style_context_remove_class(gtk_widget_get_style_context(box), "boxInfoMessOK"); - gtk_style_context_add_class(gtk_widget_get_style_context(box), "boxInfoMessError"); - gtk_image_set_from_pixbuf(GTK_IMAGE(icon), gtk_icon_theme_load_icon_for_scale(ictheme, "com.ublinux.ubl-settings-logging.warning", 25, 1, GTK_ICON_LOOKUP_FORCE_SIZE, NULL)); - } - if (display_text) - gtk_label_set_text(GTK_LABEL(label),display_text); + if (!status_thread_busy){ + GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5); + GtkWidget *revealer = gtk_revealer_new(); + GtkWidget *label = gtk_label_new(""); + GtkWidget *icon = gtk_image_new(); + gtk_container_add(GTK_CONTAINER(revealer),box); + gtk_box_pack_start(GTK_BOX(box),icon,0,0,5); + gtk_box_pack_start(GTK_BOX(box),label,0,0,5); + gtk_container_add(container,revealer); + + gtk_widget_show_all(revealer); + gtk_revealer_set_reveal_child(GTK_REVEALER(revealer),1); + + gtk_widget_set_margin_bottom(label,9); + gtk_widget_set_margin_top(label,9); + gtk_label_set_xalign(GTK_LABEL(label),0.0); + PangoAttrList *attributes = pango_attr_list_new(); + PangoAttribute *boldAttr = pango_attr_weight_new(PANGO_WEIGHT_BOLD); + pango_attr_list_insert(attributes, boldAttr); + gtk_label_set_attributes(GTK_LABEL(label),attributes); + + GdkRGBA textColor; + gdk_rgba_parse(&textColor, "#4d4d4d4d4d4d"); + PangoAttribute *colorAttr = pango_attr_foreground_new( + (int)(textColor.red * 65535), + (int)(textColor.green * 65535), + (int)(textColor.blue * 65535) + ); + pango_attr_list_insert(attributes, colorAttr); + + GtkIconTheme *ictheme = gtk_icon_theme_get_default(); + if (type == BACKGROUND_IMAGE_SUCCESS_TYPE||! type) + { + gtk_style_context_remove_class(gtk_widget_get_style_context(box), "boxInfoMessError"); + gtk_style_context_add_class(gtk_widget_get_style_context(box), "boxInfoMessOK"); + gtk_image_set_from_pixbuf(GTK_IMAGE(icon), gtk_icon_theme_load_icon_for_scale(ictheme, "com.ublinux.ubl-settings-logging.checked", 25, 1, GTK_ICON_LOOKUP_FORCE_SIZE, NULL)); + } + else if (type == BACKGROUND_IMAGE_FAIL_TYPE) + { + gtk_style_context_remove_class(gtk_widget_get_style_context(box), "boxInfoMessOK"); + gtk_style_context_add_class(gtk_widget_get_style_context(box), "boxInfoMessError"); + gtk_image_set_from_pixbuf(GTK_IMAGE(icon), gtk_icon_theme_load_icon_for_scale(ictheme, "com.ublinux.ubl-settings-logging.warning", 25, 1, GTK_ICON_LOOKUP_FORCE_SIZE, NULL)); + } + if (display_text) + gtk_label_set_text(GTK_LABEL(label),display_text); struct temp_statusbox *statusstruct = malloc(sizeof(struct temp_statusbox)); statusstruct->revealer = revealer; statusstruct->times = timeout; - GThread *thread = g_thread_new(NULL,(GThreadFunc)_yon_ubl_status_box_timed_remove,statusstruct); + GThread *thread = g_thread_new("StatusThread",(GThreadFunc)_yon_ubl_status_box_timed_remove,statusstruct); + status_thread_busy=1; + } } /**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) diff --git a/source/ubl-utils.h b/source/ubl-utils.h index 7ddc5c0..d488149 100644 --- a/source/ubl-utils.h +++ b/source/ubl-utils.h @@ -354,6 +354,7 @@ void yon_ubl_status_box_render(char *text, BACKGROUND_IMAGE_TYPE type); void yon_ubl_status_highlight_incorrect(GtkWidget *widget); +static int status_thread_busy; void yon_ubl_status_box_spawn(GtkContainer *container,char *display_text, int timeout,BACKGROUND_IMAGE_TYPE type); #ifdef __cplusplus diff --git a/ubl-settings-logging-logrotate-table.glade b/ubl-settings-logging-logrotate-table.glade index f6c0dfa..fc75f46 100644 --- a/ubl-settings-logging-logrotate-table.glade +++ b/ubl-settings-logging-logrotate-table.glade @@ -60,40 +60,101 @@ True False - 5 - 5 - 5 - 5 vertical - 5 - + True - True + False + vertical - + + + + + False + True + 0 + + + + + True + False + 5 + 5 + 5 + 5 + vertical + 5 + + True - False - 5 - 5 - 5 - 5 - 5 + True True False - vertical + 5 + 5 + 5 + 5 5 - + True - True - True - image5 - + False + vertical + 5 + + + True + True + True + image5 + + + + False + True + 0 + + + + + True + False + True + True + image4 + + + + False + True + 1 + + + + + True + False + True + True + image3 + + + + False + True + 2 + + False @@ -102,146 +163,186 @@ - + True - False True - True - image4 - + in + + + True + True + + + Log/Journal + + + + 0 + + + + + + + Path + + + + 1 + + + + + + + Description + + + + 2 + + + + + + - False + True True 1 - - - True - False - True - True - image3 - - - - False - True - 2 - - + + + + + True + False + System configuration - False - True - 0 + False - + True - True - in + False + 5 + 5 + 5 + 5 + 5 + 5 + 5 - + True - True - - - + False + vertical + 5 - - Log/Journal - - - - 0 - - + + True + False + True + True + image8 + + + False + True + 2 + + + + False + True + 0 + + + + + True + True + in - - Path + + True + True - - - 1 - + + Log/Journal + + + + 0 + + + - - - - - Description - - - 2 - + + Path + + + + 1 + + + + + True + True + 1 + - True - True 1 - - - - - True - False - System configuration + + + True + False + Applications configuration + + + 1 + False + + - False + True + True + 0 True False - 5 - 5 - 5 - 5 - 5 - 5 + end 5 + True - + + Cancel True - False - vertical - 5 - - - True - False - True - True - image8 - - - - False - True - 2 - - + True + True + image1 False @@ -250,100 +351,20 @@ - + + Save True True - in - - - True - True - - - - - - Log/Journal - - - - 0 - - - - - - - Path - - - - 1 - - - - - - + True + image2 - True + False True 1 - - 1 - - - - - True - False - Applications configuration - - - 1 - False - - - - - True - True - 0 - - - - - True - False - end - 5 - True - - - Cancel - True - True - True - image1 - - - False - True - 0 - - - - - Save - True - True - True - image2 - False True @@ -352,7 +373,7 @@ - False + True True 1