Working on a Gtk3 demo application

See GitHub - gummybears/shadertoy for details, WIP.

At the moment I am working on loading text files into a Gtk::TextView and to compile shader code to display either into a separate window (OpenGL) or a Gtk::Window.

3 Likes

When you get far enough, please include a screenshot in the README.md.

Sure,

Now I am trying to enable/disable a menu item (Gio::SimpleAction) by setting enabled is false
when the text view is empty but must be doing something wrong. I think I have to “deactivate” the signal for the specific action.

Perhaps you know the answer?

 def setup_menu_actions(builder : Gtk::Builder, window)

    # .... code truncated ....

    action = Gio::SimpleAction.new("new_file", nil)
    @app.add_action(action)
    action.activate_signal.connect do

      clear_textbuffer(builder,window)
      compile_action = Gio::SimpleAction.new("compile", nil)

      # next line of code does not disable the menu action
      compile_action.enabled = false
    end

  end

Crystal 1.6.2 [879691b2e] (2022-11-03)

LLVM: 13.0.1
Default target: x86_64-unknown-linux-gnu

Found the answer, needed to remove the action via @app.remove_action(“compile”)

1 Like