How to attach Gtk::Menu to Gtk::Widget - gtkmm

Gtk::Menu has
void Gtk::Menu::attach_to_widget(Widget& attach_widget,
GtkMenuDetachFunc detacher)
void Gtk::Menu::attach_to_widget (Widget& attach_widget)
wrapper methods for
void gtk_menu_attach_to_widget(GtkMenu *menu,
GtkWidget *attach_widget,
GtkMenuDetachFunc detacher)
But why are they protected?
If I want to make a pop-up menu on a widget, how, then, can I get access to it from the menu's activate call-back if not via these methods?

I guess it was protected because we misunderstood how it should be used. In the very latest gtkmm versions it is now public:
https://git.gnome.org/browse/gtkmm/commit/?id=329d7c59bb3f75f79142600872221ae946c7c3a1
In the meantime, you can call the C function, using yourmenu->gobj() and yourwidget->gobj().

Related

intelij idea shortcut to implement interface as a new class

suppose i have a interface like this:
public interface Dumb{
String getDumbName();
}
Is there any shortcut or menu in intellij-idea to create new classes implementing the interface with dummy implement methods like this:
public class Dumber{
public String getDumbName(){
return null;
}
}
There are multiple ways to go about this.
On the interface name itself, you can hit Alt+Enter (Option+Enter on Mac), then pick 'Implement interface'. IDEA will prompt for a class name and a package to put the new class in, then generate an implementation class.
Alternatively, create the class, then add implements Dumb after the name (im<tab> Dumb). IDEA will complain that your class doesn't implement the correct methods, and offer (Alt+Enter Enter Enter) to generate them for you. Hitting Ctrl+I or clicking 'Implement methods' in the Code menu also works.

How to get hold of AutomatedInstallData within IzPack 5 InstallerListener methods?

I've tried to find any info on that but failed, maybe someone here can help.
I'm using IzPack 5 since couple of weeks and that's what I started with, so I have no prior IzPack 4 experience.
What I want to do is the following:
Give the user an opportunity to select data directory via
UserInputPanel (works fine)
Validate the entry by checking if the
database already resides there (works fine)
Depending on whether
the DB already exists and if "force" flag specified on the
UserInputPanel create the database after the packs have been
installed
This last step, that's what I can't see how to do.
I hava a java class that implements InstallerListener interface:
public class IzPackInstaller implements com.izforge.izpack.api.data.DynamicInstallerRequirementValidator,
com.izforge.izpack.api.event.InstallerListener {
It's the same class I use for both data validation / db existance check on step 2 and creation on step 3, just for convinience reasons, but it shouldn't matter
I override
#Override
public void afterInstallerInitialization(AutomatedInstallData data)
throws Exception {
System.out.println("Called afterInstallerInitialization");
System.out.println("db.location=" + data.getVariable("db.location"));
System.out.println("db.force.creation=" + data.getVariable("db.force.creation"));
}
but it seems to be deprecated alltogether and is never called in runtime - checked with System.out's.
The same is valid for:
#Override
public void afterPacks(AutomatedInstallData data,
AbstractUIProgressHandler handler) throws Exception {
System.out.println("Never called!");
}
I also override
#Override
public void afterPacks(List<Pack> packs, ProgressListener listener) { }
which is called allright, but how to get hold of AutomatedInstallData within this method? Or how else can I read installer variables at this stage?
I thought of creating a singleton, which I would initialize with the variables during DynamicInstallerRequirementValidator.validateData() call and get the variables at a later point in time, but it's ugly and sounds like a nasty workaround - there should be a way to implement InstallerListener interface and be able to use the variables, shouldn't it?
I'd be really grateful for any hints...
Anton
This is not a very clean solution but there is a way to get a hold of AutomatedInstallData really anywhere in running izpack java without actually overriding some method etc. I would just not suggest it in the first place because it is a little tricky :)
public class Test {
InstallerContainer container = new ConsoleInstallerContainer();
AutomatedInstaller automatedInstaller = container.getComponent(AutomatedInstaller.class);
AutomatedInstallData installData;
public Test() throws IllegalAccessException, NoSuchFieldException {
Field f = AutomatedInstaller.class.getDeclaredField("installData");
f.setAccessible(true);
installData = (AutomatedInstallData)f.get(automatedInstaller);
}
etc...
Now you will have access to the object AutomatedInstallData and its methods.

Unity3D embedded Mono with Unity

I've seen plenty of examples of calling static methods in my Unity C# code using C++. I haven't however seen any examples of how to call a single instance's method using C++. i.e rather than
public static void SomeMethod(
{
}
I really want to do:
public void SomeMethod()
{
}
I've managed to make the static implementation work by following some tutorials from but would love to know if the bottom method is possible. I've tried to add a definition for searching a method in a class.
MonoMethod* mono_method_desc_search_in_class (MonoMethodDesc *desc, MonoClass *klass);
But an implementation can't be found with the mono runtime that I was told to use from here: http://www.reigndesign.com/blog/unity-native-plugins-os-x/
Any guidance or knowledge of whether it's possible or how to do it would be appreciated.
Edit:
One other question. If I search for a gameObject, could I then use that to access the instance?
You don't say what platform you're developing for, but for iOS there's the UnitySendMessage function. I believe there are similar implementations for other platforms.
http://docs.unity3d.com/Documentation/Manual/PluginsForIOS.html
Calling C# / JavaScript back from native code
Unity iOS supports limited native-to-managed callback functionality via UnitySendMessage:
UnitySendMessage("GameObjectName1", "MethodName1", "Message to send");
The parameter must be a string, so I've used JSON to send more complex data.
Alternatively, everything that inherits from UnityEngine.Object has a GetInstanceID() method, which is guaranteed to be unique. Using this you could have a static method in C# that keeps a dictionary of recipient instances, and native code would always pass an integer ID to refer to the intended recipient.
static Dictionary<int, SomeClass> instanceDict = new Dictionary<...>();
void Awake() {
instanceDict.Add(GetInstanceID(), this);
}
void OnDestroy() {
instanceDict.Remove(GetInstanceID());
}
public static void SomeMethod(int recipientID, float someValue) {
instanceDict[recipientID].SomeMethod(someValue);
}

How is App.OnSearchActivated different from App.OnActivated w/ActivationKind.Search?

If you are implementing the Search Contract on a Windows Store App, then in your App.xaml.cs you override the OnSearchActivated method like this:
protected override void OnSearchActivated(SearchActivatedEventArgs args)
{
(Window.Current.Content as Frame).Navigate(typeof(Contracts.Search), args.QueryText);
}
But if you are paying attention, then you can see that there is another override in the App class called OnActivated that has event arguments indicating a search activation, like this:
protected override void OnActivated(IActivatedEventArgs args)
{
if (args.Kind == ActivationKind.Search)
{
(Window.Current.Content as Frame).Navigate(typeof(Contracts.Search), args.QueryText);
}
}
When I implement one or the other the result seems to be the same. That begs the question: what is the difference between the two? Are they really the same?
Yes, they are the same.
The XAML team made a design decision to implement a generic OnActivated override as well as strongly typed overrides for the most common types of app activation. It is a best practice that, if there is a specific override, you use the specific override (like OnSearchActivated). But some advanced scenarios, like file or protocol activation, require OnActivated.
Note: in the Page pipeline, OnActivated fires first, the typed overrides follow. Since an app can only be activated by a single kind at a time, the order of execution doesn't matter.
Best of luck!

Which eclipse plugin implements Ctrl+PageDown or M1+PageDown

I am learning eclipse plugin development and a great deal of learning can be done by looking at the implementation of an existing builtin plugin itself.
While I was looking for a shortcut to switch between tabs I found this --> Eclipse HotKey: how to switch between tabs?
However I am not able to search the command /key binding/ Handler class that actually implements the Ctrl+PageDown key binding.
Similarly, I was able to find the key binding and the command of of M3+PAGE_DOWN (ALT+PAGE_DOWN) in plugins/org.eclipse.ui_some_version.jar (org.eclipse.ui_3.103.0.v20120705-114351.jar in my case) but not the Handler.
How can I find these out? Which plugin should I refer to?
Those commands get handled programatically inside
org.eclipse.ui.part.MultiPageEditorPart.
Good tools for analysing the origin of elements are the "Plug-In Registry" View, the "Plug-In Spy" and Google.
You can find the handler in org.eclipse.ui.workbench (see class org.eclipse.ui.part.MultiPageEditorPart)
The handler is defined programmatically and not declaratively:
public abstract class MultiPageEditorPart extends EditorPart implements IPageChangeProvider {
private static final String COMMAND_NEXT_SUB_TAB = "org.eclipse.ui.navigate.nextSubTab"; //$NON-NLS-1$
private void initializeSubTabSwitching() {
IHandlerService service = (IHandlerService) getSite().getService(IHandlerService.class);
service.activateHandler(COMMAND_NEXT_SUB_TAB, new AbstractHandler() {
// ...
}
});
}