Changed spawned infinite status box open/close logic

pull/7/head
parent 6ca41f6760
commit 5c71bed891

@ -682,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){
@ -697,12 +699,33 @@ 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);
GList *list = gtk_container_get_children(container);
for (int i=0;i<g_list_length(list);i++){
gtk_widget_destroy((GtkWidget*)g_list_nth_data(list,i));
}
status_thread_busy=0;
}
yon_status_thread_id = yon_char_new(status_id);
GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5);
GtkWidget *revealer = gtk_revealer_new();
GtkWidget *label = gtk_label_new("");
GtkWidget *icon = gtk_image_new();
g_signal_connect(G_OBJECT(box),"destroy",G_CALLBACK(yon_status_box_destroyed),NULL);
gtk_label_set_line_wrap(GTK_LABEL(label),1);
gtk_label_set_line_wrap_mode(GTK_LABEL(label),PANGO_WRAP_WORD);
gtk_container_add(GTK_CONTAINER(revealer),box);
@ -735,11 +758,14 @@ int yon_ubl_status_box_spawn_infinite(GtkContainer *container, char *display_tex
gtk_label_set_text(GTK_LABEL(label),display_text);
struct temp_statusbox *statusstruct = malloc(sizeof(struct temp_statusbox));
statusstruct->revealer = 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<g_list_length(list);i++){
GtkWidget *revealer = g_list_nth_data(list,i);

@ -330,7 +330,7 @@ void yon_ubl_status_list_store_highlight_incorrect(GtkListStore *list, GtkTreeIt
static int status_thread_busy;
int yon_ubl_status_box_spawn_infinite(GtkContainer *container, char *display_text, BACKGROUND_IMAGE_TYPE type);
int yon_ubl_status_box_spawn_infinite(GtkContainer *container, char *status_id, char *display_text, BACKGROUND_IMAGE_TYPE type);
int yon_ubl_status_box_despawn_infinite(GtkContainer *container);
/**yon_ubl_status_box_spawn(GtkContainer *container,char *display_text, int timeout,BACKGROUND_IMAGE_TYPE type);

Loading…
Cancel
Save