pub mod step_adjustments;
pub mod step_compress;
pub mod step_convert;
pub mod step_images;
pub mod step_metadata;
pub mod step_output;
pub mod step_rename;
pub mod step_resize;
pub mod step_watermark;
pub mod step_workflow;

use gtk::prelude::*;

/// Creates a list factory for ComboRow dropdowns where labels never truncate.
/// The default GTK factory ellipsizes text, which cuts off long option names.
pub fn full_text_list_factory() -> gtk::SignalListItemFactory {
    let factory = gtk::SignalListItemFactory::new();
    factory.connect_setup(|_, item| {
        let Some(item) = item.downcast_ref::<gtk::ListItem>() else { return };
        let label = gtk::Label::builder()
            .xalign(0.0)
            .margin_start(8)
            .margin_end(8)
            .margin_top(8)
            .margin_bottom(8)
            .build();
        item.set_child(Some(&label));
    });
    factory.connect_bind(|_, item| {
        let Some(item) = item.downcast_ref::<gtk::ListItem>() else { return };
        if let Some(obj) = item.item() {
            if let Some(string_obj) = obj.downcast_ref::<gtk::StringObject>() {
                if let Some(label) = item.child().and_downcast_ref::<gtk::Label>() {
                    label.set_label(&string_obj.string());
                }
            }
        }
    });
    factory
}
