tweaksp
tweaksp

Reputation: 621

GTK+ ToggleAction

I'm developing a UI with gtkmm/C++ for a project I'm working on. I'm entirely new to GTK. For this program, I need multithreading, for which I'm using Glib::Threads objects. The second thread will be toggled on and off so that the user may control execution of the program; naturally, the name Gtk::ToggleAction made me curious, but I haven't been able to find out what this really does. Would it be possible to derive a class from ToggleAction that handles my thread?

Thanks! Chris

Upvotes: 1

Views: 233

Answers (3)

h3lix
h3lix

Reputation: 31

Alternatively you could use my thread implementation in gobject of Advanced Gtk+ Sequencer:

This implementation provides suspending and resuming threads. For sure you can extend GtkToggleButton object.

This is probably the most important function

g_type_class_peek_parent(klass);

Upvotes: 0

Chris
Chris

Reputation: 65

GTK uses an event driven architecture for its non-blocking UI like all other UI systems. The standard way to do this is to have a main thread for event handling and a second thread for painting. Most windows like the "save as" dialog are handled in a different way so you will not need to work with threads for that. If you are developing a new application then consider using the GTK3 interfaces. GtkAction is being deprecated. Use GAction and the GMenu interface instead.

https://developer.gnome.org/gio/stable/GAction.html#GAction-struct

Upvotes: 0

Pete
Pete

Reputation: 11495

Gtk::ToggleAction is part of the set of classes used for "action based menus and toolbars": http://developer.gnome.org/gtk3/stable/Actions.html

In particular, GtkToggleAction represents an action that has an on/off toggle-able state. This is more about abstracting the concept of an "action" that can be visualized by any number of UI elements (menu check item, toggle button, etc) at the same time. You certainly could use the events triggered by changes to the Gtk::ToggleAction to decide to do your pause/unpause of your thread, either by subclassing Gtk::ToggleAction or composition with a new class that references a Gtk::ToggleAction instance.

Upvotes: 1

Related Questions