static void _lib_history_change_callback(gpointer instance, gpointer user_data) { dt_lib_module_t *self = (dt_lib_module_t *)user_data; dt_lib_history_t *d = (dt_lib_history_t *)self->data; /* first destroy all buttons in list */ gtk_container_foreach(GTK_CONTAINER(d->history_box), (GtkCallback)gtk_widget_destroy, 0); /* add default which always should be */ int num = -1; gtk_box_pack_start(GTK_BOX(d->history_box), _lib_history_create_button(self, num, _("original"), FALSE, darktable.develop->history_end == 0), TRUE, TRUE, 0); num++; /* lock history mutex */ dt_pthread_mutex_lock(&darktable.develop->history_mutex); /* iterate over history items and add them to list*/ GList *history = g_list_first(darktable.develop->history); while(history) { dt_dev_history_item_t *hitem = (dt_dev_history_item_t *)(history->data); gchar *label; if(!hitem->multi_name[0] || strcmp(hitem->multi_name, "0") == 0) label = g_strdup_printf("%s", hitem->module->name()); else label = g_strdup_printf("%s %s", hitem->module->name(), hitem->multi_name); gboolean selected = (num == darktable.develop->history_end - 1); GtkWidget *widget = _lib_history_create_button(self, num, label, hitem->enabled, selected); g_free(label); gtk_box_pack_start(GTK_BOX(d->history_box), widget, TRUE, TRUE, 0); gtk_box_reorder_child(GTK_BOX(d->history_box), widget, 0); num++; history = g_list_next(history); } /* show all widgets */ gtk_widget_show_all(d->history_box); dt_pthread_mutex_unlock(&darktable.develop->history_mutex); }
static void _lib_history_change_callback(gpointer instance, gpointer user_data) { dt_lib_module_t *self = (dt_lib_module_t *)user_data; dt_lib_history_t *d = (dt_lib_history_t *)self->data; /* first destroy all buttons in list */ gtk_container_foreach(GTK_CONTAINER(d->history_box),(GtkCallback)gtk_widget_destroy,0); /* add default which always should be */ long int num = -1; gtk_box_pack_start(GTK_BOX(d->history_box),_lib_history_create_button(self,num, _("original"),FALSE),TRUE,TRUE,0); num++; /* lock history mutex */ dt_pthread_mutex_lock(&darktable.develop->history_mutex); /* iterate over history items and add them to list*/ GList *history = g_list_first(darktable.develop->history); while (history) { dt_dev_history_item_t *hitem = (dt_dev_history_item_t *)(history->data); /* create a history button and add to box */ GtkWidget *widget =_lib_history_create_button(self,num,hitem->module->name(),hitem->enabled); gtk_box_pack_start(GTK_BOX(d->history_box),widget,TRUE,TRUE,0); gtk_box_reorder_child(GTK_BOX(d->history_box),widget,0); num++; history = g_list_next(history); } /* show all widgets */ gtk_widget_show_all(d->history_box); dt_pthread_mutex_unlock(&darktable.develop->history_mutex); }