I have a few questions regarding this small app.
One, Gtk::Window is a class and it can but loaded in the heap, just like I did in the main() method. The same rule applies to Gtk::MessageDialog, since it is a class that derives from Gtk::Window; I have loaded a Gtk::MessageDialog's object in the heap. Please correct me if I am wrong.
Equally important, the program compiles, but it displays a black window wih a message saying something like:
(myApp.exe:1040): Glib-GObject-CRITICAL ** gtype.c:2710: You forgot to call g_type_init()
This message is repeated many times in the same black window.
I am not using precompile header in my VSE10 and I am using gtkmm-win32-devel-2.22.0-2 package in a Win7 machine.
OK, now that I have stated the above. I would like to know:
In the example in http://git.gnome.org/browse/gtkmm-documentation/tree/examples/book/dialogs/messagedialog/examplewindow.cc.
The Gtk::MessageDialog object declaration only has two parameters, that exaple is not an options for me since I'm not deriving from any Gtk class, I am deriving from std::exception. Is it possible to declare a Gtk::MessageDialog object in a class that is not derived from a Gtk class? and can this Gtk::MessageDialog be decalered and instantiated as a pointer?
Â
TIA
Â
#define WIN32_LEAN_AND_MEAN
#include <stdio.h>
#include <cstddef>
#include <xstddef>
#include <iostream>
#include <stdlib.h>
#include <cstdlib>
#include <regex>
#include <memory>
#include <gtkmm.h>
#include <windows.h>
#include <exception>
#include "uiexception.hpp"
using namespace std;
int main( int argc, char **argv );
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine,int nCmdShow){
return main (__argc, __argv);
}
int main (int argc, char *argv[]) {
ns::uiexception uiex;
Gtk::Main app(argc, argv);
shared_ptr< Gtk::Window > aWindow(new Gtk::Window);
Gtk::Main::run( *aWindow );
return 0;
}
file.hpp
~~~~~~~~
#ifndef ns_UIEXCEPTION_HPP
#define ns_UIEXCEPTION_HPP
#include <gtkmm.h>
#include <glibmm/ustring.h>
namespace ns {
class uiexception : public std::exception{
public:
uiexception();
virtual ~uiexception()throw(){}
private:
Glib::ustring version;
Gtk::MessageDialog* dialog;
void Init();
};
}
#endif
file.cpp
~~~~~~~~
#ifndef ns_UIEXCEPTION_HPP
#include "uiexception.hpp"
#endif
void ns::uiexception::Init(){
version = "0.0.5";
std::shared_ptr<Gtk::MessageDialog>
dialog( new Gtk::MessageDialog(
" message", Message
false, Markup
Gtk::MESSAGE_WARNING, MessageType
Gtk::BUTTONS_OK, Buttons
false)); modal
}
ns::uiexception::uiexception(){
Init();
}
#ifndef JME_UIEXCEPTION_HPP
#include "uiexception.hpp"
#endif
void jme::uiexception::Init(){
version = "0.0.5";
std::shared_ptr<Gtk::MessageDialog>
dialog( new Gtk::MessageDialog(
" message", //Message
false, // Markup
Gtk::MESSAGE_WARNING, //MessageType
Gtk::BUTTONS_OK, //Buttons
false)); // modal
}
jme::uiexception::uiexception(){
Init(); //coment or uncoment this function call to test both MessageDialogs
Gtk::MessageDialog Dialog(
" message", // Message
false, // Markup
Gtk::MESSAGE_WARNING, // MessageType
Gtk::BUTTONS_OK, // Buttons
false); // modal
}