What's swap and after checkbox in Signals editor? - gtk3

There is a checkbox called "swap" and other called "after" in signals editor. What is their purpose?

https://developer.gnome.org/gobject/stable/gobject-Signals.html#g-signal-connect-swapped
https://developer.gnome.org/gobject/stable/gobject-Signals.html#g-signal-connect-after
I think the docs speak for themselves but an example for after is say you had a dialog that runs something important on the 'response' signal, you would connect after so that has already ran.
Swapped is just for very specific cases where you want to reuse a function.

Related

Specify an intent on the ask function

I would like to know, how to specify the function of redirection in the ask function.
Like :
Launch main function to choice the actions.
Start the function chosen by the user.
Loop in this function as long as the user does not say "stop" for example.
Maybe with a specific intent in the ask function, I don't know ...
Does anyone have the solution ?
Your request is what contexts are used for in Dialogflow. You can set it up so that certain intents are only available to be triggered if a certain input context exists. These contexts originate from an output context of an intent.
Using the dialog state is not recommended. If you want to store generic data, you should use app.data in v1 or conv.data in v2 of the AoG client library. This data object persists throughout a session, which is more powerful than dialog state.
You can't. The ask() method is "completed" in the text intent. It is a shame that you can't - the code would be so much less cluttered if you could.
IAC, you can pass "dialog state" to ask() and then getDialogState() in the text intent and use that to restore your application's context and continue from there.

GTK3 - Monitoring all signals emitted from a widget

Is there any way to monitor all signals emitted from a widget with GTK3? I know that the event signal is emitted before an event, but I'm not sure of the distinction between "event" and "signal" in GTK terminology - as this does not seem to capture all signals.
I know GDK has a function gdk_set_show_events but this mostly shows events which are sent to the window from the operating system. Is there a GTK3 equivalent?
There is not built in function AFAIK, but I'm sure you can hack something together yourself:
Use g_signal_lookup to get all signal ids for a gtype. Then use g_signal_add_emission_hook on each signal of your instance to register a hook to be called whenever that particular signal is emitted. Inside the hook function, you're provided with the signal id via *ihint, from which g_signal_query should provide you with all the information you need to print debug messages. (I didn't test it, but it should work)
Note that this will unfortunately not work for signals defined with G_SIGNAL_NO_HOOKS.
Use g_signal_lookup to get all signal ids
It's a little more complicated than described. In order to use g_signal_lookup, you first need a signal-name. If you want to monitor every signal independent of the object-type, you first need to list all signals of the specific instance-type. This can be arranged by g_signal_list_ids for exactly one single GType. To get really ALL signals emitted on the instance, you need to iterate over all parent-types of this instance. You can do this by using g_type_parent.
I have build some utility-functions by myself, that provide this functionality for the same debugging purpose the question was intended. You can connect an Emission-Hook for all signals of a GObject-instance with gemu_glib_util_connect_to_all_signals or connect an emission-Hook to a GtkWidget-instance and all its children with gemu_gtk_util_signal_connect_to_widget_children.

Can two panels share a uicontrol in a MATLAB GUI?

I've got a MATLAB GUI that has different aspects of functionality, each with their own panel of uicontrols. When one panel is selected, the other one is set to invisible, and vice-versa. However, they share some of the same inputs in the form of a popup menu. Can I include a 'clone' instance of the menu on the second panel somehow? I'd like to avoid as many redundant callbacks and uicontrols as possible.
I guess if the uicontrol was a direct child of the figure, you may be able to put it in front of everything.
A much simpler solution is to use the same callback for multiple uicontrols. In the property editor, you can modify the callback name and set it to a common callback function. Additionally, you can create a field (e.g. myPopupH) in the OpeningFcn of the GUI, in which you store the handles of the popups that should behave the same way. Then, in the callback, you'd use hObject, i.e. the first input argument, for all the get calls (to access the modified state of the popup-menu), but you'd use handles.myPopupH in all the set calls, so that you can ensure that both popups always have the same state. Thus, the ui-object may be redundant, but all the code (which is much more critical) only exists in a single copy.
One place where I routinely use a single callback for multiple ui elements is the close request function which is accessed from the "Cancel"-button as well as from the "X" that closes the figure, and possibly from one of the "File"-menu items.

gtk signal for moving a scale(slider)?

Simple question:
I've added some scales (sliders) to my window, and I want to call a method when you move the scale.
What is the signal name that I use for gtk_signal_connect?
ie I should be able to write something like:
gtk_signal_connect(GTK_OBJECT(my_scale), "scale_moved", (GtkSignalFunc)my_event, data);
or am I missing something here?
And more importantly - how do I find out in the future what the signal names are? for example - I googled 'gtk_signal_connect' but I didn't find a big list of different signals.
Similarly, I didn't find details about related signals in the GtkScale documentation. (Well, in this page, there is a single signal detail, but it relates to changing the displayed value format).
GtkScale inherits from GtkRange, and signals are inherited in GTK+. Therefore, you can connect to the value-changed signal exposed by GtkRange.
You're on the right track to find the signals exposed by a given GTK+ widget: besides the source code itself, the documentation is indeed the canonical resource, but you should also take the base classes into account in your search.

MATLAB: Perform callback on variable change?

I am trying to build a GUI with several tabs, using uitabpanel() found at http://www.mathworks.com/matlabcentral/fileexchange/11546 . I would like to resize the GUI based on the currently opened tab; this is available with uitabpanel.SelectedItem.
Basically I would like to build a callback in order to monitor uitabpanel.SelectedItem - when this variable changes, the GUI window should resize appropriately. Generally speaking, I am looking for a way to monitor a variable and execute a callback when the variable changes value.
Is this possible? How would I go about doing this?
Thanks!
I don't have a MATLAB in front of me right now, but if it is implemented as a property -- and as far as I can tell from a quick look at the code, it is -- you can use addlistener function and provide a callback function for it.
addlistener(hTab,'SelectedItem','PostSet',#(s,e)disp('SelectedItem changed'))
I'm not familiar with uitab from the file exchange. However, if it's build upon the built-in uitab, then there should be a selectionChangeCallback or selectionChangeFcn property (depending on your Matlab version). Specify a function for this callback property, and you have a way to execute a function whenever the selection changes.
If that's not possible, the only other way to monitor a variable change (if you can't somehow use objects and set methods) is to use a TIMER OBJECT that periodically polls the value of the variable.
EDIT Since the FEX uitab is based on uipanel, the callback you're looking for is most likely ButtonDownFcn. Before you change it, make sure that it's not used by the uitab function, otherwise, you will want to edit that function.