I don't think it's gintro specific. I have never used inheritance in Nim before 
so I just need to get started with the basics.
    
    
    import gintro/[gtk, gobject, gio]
    
    type
      Header = ref object of RootObj
        base: HeaderBar
        text: string
      # Header = ref object of HeaderBar
      #   text: string
      MainWindow = ref object of RootObj
        base: ApplicationWindow
        header: Header
        pb: ProgressBar
    
    proc newHeader(): Header =
      new(result)
      result.base = newHeaderBar()
      result.text = "Initial Title"
      result.base.setTitle(result.text)
      result.base.setShowCloseButton(true)
    
    # proc newHeader(): Header =
    #   new(result)
    #   result.text = "Initial Title"
    #   result.setTitle(result.text)
    #   result.setShowCloseButton(true)
    
    
    proc newMainWindow(gtkApplication: Application): MainWindow =
      new(result)
      result.base = newApplicationWindow(gtkApplication)
      result.header = newHeader()
      result.pb = newProgressBar()
      result.base.add(result.pb)
      result.pb.setFraction(0.25)
      result.base.setSizeRequest(400, 400)
      result.base.setTitlebar(result.header.base)
      # result.base.setTitlebar(result.header)
      result.base.showAll()
    
    
    proc appActivate(app: Application) =
      let window = newMainWindow(app)
    
    proc main =
      let app = newApplication("org.gtk.example")
      connect(app, "activate", appActivate)
      discard run(app)
    
    main()
    
    
    Run

If I use composition as I above it works but if I toggle the comments, I get 
the following warning:

(helloprogress:19510): Gtk-CRITICAL : 01:02:02.771: gtk_header_bar_set_title: 
assertion 'GTK_IS_HEADER_BAR (bar)' failed

(helloprogress:19510): Gtk-CRITICAL : 01:02:02.771: 
gtk_header_bar_set_show_close_button: assertion 'GTK_IS_HEADER_BAR (bar)' failed

So Gtk resorts back to regular titlebars.

Reply via email to