diff --git a/source/libublsettings-gtk3.c b/source/libublsettings-gtk3.c index 30b1934..525a907 100644 --- a/source/libublsettings-gtk3.c +++ b/source/libublsettings-gtk3.c @@ -569,6 +569,18 @@ void yon_gtk_widget_set_sensitive_from_combo_box_inversed(GtkComboBox *toggle, G gtk_widget_set_sensitive(target,!gtk_combo_box_get_active(toggle)>0 ? 0 : 1); } +void yon_gtk_toggle_button_set_inactive_from_toggle_button_inversed(GtkToggleButton *self, GtkToggleButton *target){ + if (gtk_toggle_button_get_active(self)){ + gtk_toggle_button_set_active(target,0); + } +} + +void yon_gtk_toggle_button_set_inactive_from_toggle_button(GtkToggleButton *self, GtkToggleButton *target){ + if (!gtk_toggle_button_get_active(self)){ + gtk_toggle_button_set_active(target,0); + } +} + void _yon_ubl_header_setup(GtkWidget *Overlay, GtkWidget *Head, GtkWidget *Image, char *image_path) { gtk_overlay_add_overlay(GTK_OVERLAY(Overlay), Head); @@ -591,28 +603,38 @@ int yon_ubl_status_box_setup(GtkWidget *icon, GtkWidget *box, GtkWidget *label) } else return 0; } +void yon_ubl_status_box_set(BACKGROUND_IMAGE_TYPE type, GtkWidget *box, GtkImage *icon){ + + GtkIconTheme *ictheme = gtk_icon_theme_get_default(); + switch (type){ + case BACKGROUND_IMAGE_SUCCESS_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.libublsettingsui-gtk3.checked", 25, 1, GTK_ICON_LOOKUP_FORCE_SIZE, NULL)); + } + break; + case 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.libublsettingsui-gtk3.warning", 25, 1, GTK_ICON_LOOKUP_FORCE_SIZE, NULL)); + } + break; + case BACKGROUND_IMAGE_INFO_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.libublsettingsui-gtk3.important", 25, 1, GTK_ICON_LOOKUP_FORCE_SIZE, NULL)); + } + break; + } +} + void _yon_ubl_status_box_render(char *text, BACKGROUND_IMAGE_TYPE type) { render_data data = render; - GtkIconTheme *ictheme = gtk_icon_theme_get_default(); - GError *err = NULL; - if (err) - { - printf("%s\n", err->message); - g_error_free(err); - } - if (type == BACKGROUND_IMAGE_SUCCESS_TYPE||! type) - { - gtk_style_context_remove_class(gtk_widget_get_style_context(data.box), "boxInfoMessError"); - gtk_style_context_add_class(gtk_widget_get_style_context(data.box), "boxInfoMessOK"); - gtk_image_set_from_pixbuf(GTK_IMAGE(data.icon), gtk_icon_theme_load_icon_for_scale(ictheme, "com.ublinux.ubl-settings-video.checked", 25, 1, GTK_ICON_LOOKUP_FORCE_SIZE, &err)); - } - else if (type == BACKGROUND_IMAGE_FAIL_TYPE) - { - gtk_style_context_remove_class(gtk_widget_get_style_context(data.box), "boxInfoMessOK"); - gtk_style_context_add_class(gtk_widget_get_style_context(data.box), "boxInfoMessError"); - gtk_image_set_from_pixbuf(GTK_IMAGE(data.icon), gtk_icon_theme_load_icon_for_scale(ictheme, "com.ublinux.ubl-settings-video.warning", 25, 1, GTK_ICON_LOOKUP_FORCE_SIZE, &err)); - } + yon_ubl_status_box_set(type,data.box,GTK_IMAGE(data.icon)); if (text) gtk_label_set_text(GTK_LABEL(data.label), text); } @@ -660,6 +682,8 @@ struct temp_statusbox { GtkWidget *revealer; }; +static char *yon_status_thread_id=NULL; + void _yon_ubl_status_box_timed_remove(struct temp_statusbox *statusstruct){ sleep(statusstruct->times); if (status_thread_busy){ @@ -675,15 +699,39 @@ void __yon_ubl_status_box_destroyed(){ status_thread_busy=0; } -int yon_ubl_status_box_spawn_infinite(GtkContainer *container, char *display_text, BACKGROUND_IMAGE_TYPE type){ +void yon_status_box_destroyed(){ + if (yon_status_thread_id){ + free(yon_status_thread_id); + yon_status_thread_id=NULL; + } +} + +int yon_ubl_status_box_spawn_infinite(GtkContainer *container, char *status_id, char *display_text, BACKGROUND_IMAGE_TYPE type){ if (!status_thread_busy){ + if (yon_status_thread_id){ + if (!strcmp(yon_status_thread_id,status_id)){ + return 0; + } + free(yon_status_thread_id); + yon_status_thread_id=NULL; + GList *list = gtk_container_get_children(container); + for (int i=0;irevealer = revealer; - status_thread_busy=2; } } int _yon_ubl_status_box_despawn_infinite(GtkContainer *container){ + if (yon_status_thread_id){ + free(yon_status_thread_id); + yon_status_thread_id=NULL; + } GList *list = gtk_container_get_children(container); for (int i=0; i