Setting a window menu with set_menubar(), is there an 'activated' signal I can connect to run custom code when a menu is opened from the bar? - c++

Gtk 3.0 application (with C++ and GtkMM). I use set_menubar() to set the menu bar for the main window (loaded from a resource file, i.e. a "*.ui" XML file).
At run time, I want to be able to enable/disable (gray out) menu items in accordance with availability. I know that I can use "add_action()" and "remove_action()" to associate/dissociate the actions, which will have the desired effect. However it is complicated and expensive to add/remove the actions dynamically considering that the only time it matters which actions are available is when the user has opened the menu and is looking at it.
So I was thinking that I should be able to connect to an "activate" signal of the menu bar items to adjust the appearance of their menu each time the user clicks on an item, just before the corresponding menu is displayed to the user. Any idea how I can get to the signal from the Gio::Menu resource? Is this possible in theory but an unfortunate omission in the Glib API? Or is there something I don't understand?

Related

Display and use the same MFC CList control in multiple dialogs

I am coding a test application for a windows CE device. This is the first time I am programming for a handheld device. I use MFC VC++ on Visual Studio 2008. I have found that there are many restrictions in the controls and what I could do with them when running the program on a handy versus when I run a similar program on a desktop computer.
Now, the device I am currently deploying my test program to, does not have a touchscreen and has few extra keys other that the numberpad 0-9 keys. So, I have to do with a simple GUI that uses keydowns to call specific functions like add, edit, delete etc... It also forces me to use separate dialogs for each of these functions so as to avoid unnecessary mouse cursor usage.
This leads me to my current problem: The 'ADD' dialog of my test app adds some user data to a CListCtrl that is on the 'MAIN' dialog. The 'EDIT/DELETE' dialog is to allow the user to select the desired data from its own CListCtrl and press the "ENTER" key, which thereby deletes the selected data from the 'MAIN' dialog's CListCtrl. Thus, both the main dialog and the 'EDIT/DELETE' dialog have CListCtrl with the exact same data. So, instead of having to use 2 separate list controls and using loops to copy the data to and fro among them, is there a way in which i could use the exact same CListCtrl (one and only one instance of the CListCtrl exists), but display it on 2 separate dialogs? This would remove all the copying code, as well as halve the amount of data in memory.
I tried passing a pointer to the MAIN dialog's CListCtrl to the 'EDIT/DELETE' dialog in hopes that I could redraw the control there, but in vain. I could call the RedrawWindow, RedrawItems commands, but they seem to have no effect in the 'EDIT/DELETE' dialog (I think it is because the control itself is not present on the edit/delete dialog). Any other suggestions?
You could temporarily change the parent of the ListCtrl using CWnd::SetParent to the EDIT/DELETE dialog, and set the position with CWnd::SetWindowPos to where you want to have it. When the dialog gets closed, set the parent back to the MAIN dialog.

Sitecore Speak UI what layout and renderings for dialog opened from launchpad, desktop or content editor

What layout and renderings should be used to create a dialog/app which can be started from
Launchpad
Content Editor button
Desktop start menu shortcut
As an example; here are images of the User Manager dialog. Note the differences in the appearance of the header bar in each case. I tried to examine this control in Sitecore to see how it was developed, but it is implemented in Sheer UI, not SPEAK UI. Can this be done automatically with a particular layout and combination of renderings, or would I need to detect the context of the application to control whether the launchpad icon is displayed in the top left corner of the dialog?
User Manager - launched from Launchpad
User Manager - launched from Content Editor
User Manager - launched from Desktop Start Menu
I can tell you that the user manager example here is actually Sheer UI rather than SPEAK.
For the dialog header use the "DialogPageStucture", "DashboardPageStrucuture" will give you the "GlobalHeader" placeholder as used below. I'm not sure how you mix and match them as the User Manager is Sheer UI rather than SPEAK.
For the launch pad button and header use "GlobalHeader" and "GlobalLogo" (this is the launch pad button). Add GlobalHeader into the GlobalHeader placeholder. Add GlobalLogo into GlobalHeader.StartButton.

Dynamic Menu in Qt Application

I have a bunch of Dock Widgets that the User is free to close and want to provide a menu in my QMenuBar that reopens each of them individually. So possibly every time the menu is opened, the list of options will be different.
Is there any event or hook that I can use to recreate the menu whenever it is opened? The only thing I could find was the triggered event, but that is only generated after I already selected something.
Otherwise I would have to monitor all dock widget actions or I could use a timer that periodically recreates the menu - both solutions don't sound very appealing.

How to gray out a menu item in Qt

I'm building a small program in Qt with menu bars (menuBar) using C++ and I would like to know how to gray out (eg. disable) an item of the menu when a certain variable is activated. Is it possible?
If you know an index of the corresponding QAction :
QMenu::actions.at(i).setEnabled(false);
P.S. As kindly prompted below, setEnabled(bool) and setDisabled(bool) are slots (so is toggle()), so they can be connected to a signal indicating a need to change the availability of the action.
Looking for the index of the action is not necessarily convenient. If you have built the interface with QtCreator's form editor then you will have an action for each menu item. Their names are based on the text that you first give to the actions. For example if you interactively enter a menu item with title Foo Bar then an action named actionFoo_Bar is created for you. Just type ui->action in the code editor and watch what "name completion" QtCreator will propose.
In such a case I would consider a call like this:
ui->actionFoo_Bar.setEnabled(false);
You can even make the menu item disappear with
ui->actionFoo_Bar.setVisible(false);

Cocoa-track the menu of/inject options into itunes

Is there a way I can inject menu items into itunes or detect when menu items are pressed. I have an itunes plugin that executes code when iTunes launches, but how can I use that to detect menu item clicks or possibly inject new menu item options? For example adding a new contextual menu item when you right click on a library item, or detecting when the users clicks "Like" from the Ping menu.
Whatever functionality is not provided by an app's scripting bridge would only be accessible by hackery.
iTunes a Carbon app, not Cocoa, so that's more for you to learn about. iTunes even uses a call to ptrace(), passing PT_DENY_ATTACH to prevent you attaching a debugger to snoop around at runtime as well.
In other words, this is by no means an easy thing to do.