class WXDLLIMPEXP_FWD_BASE wxMutex;
 #endif
 
+#if wxUSE_LIBHILDON
+typedef struct _HildonProgram HildonProgram;
+#endif // wxUSE_LIBHILDON
+
 //-----------------------------------------------------------------------------
 // wxApp
 //-----------------------------------------------------------------------------
     // must return XVisualInfo pointer (it is not freed by caller)
     virtual void *GetXVisualInfo() { return NULL; }
 
+#if wxUSE_LIBHILDON
+    // Maemo-specific method: get the main program object
+    HildonProgram *GetHildonProgram() const { return m_hildonProgram; }
+#endif // wxUSE_LIBHILDON
 
     // implementation only from now on
     // -------------------------------
 #endif
     guint m_idleSourceId;
 
+#if wxUSE_LIBHILDON
+    HildonProgram *m_hildonProgram;
+#endif // wxUSE_LIBHILDON
+
     DECLARE_DYNAMIC_CLASS(wxApp)
 };
 
 
 }
 #endif
 
-
 #endif // wxUSE_MENUS
 
 #include "wx/gtk/private.h"
 #include "wx/apptrait.h"
 
+#if wxUSE_LIBHILDON
+    #include <hildon-widgets/hildon-program.h>
+#endif // wxUSE_LIBHILDON
+
 #include <gdk/gdkx.h>
 
 //-----------------------------------------------------------------------------
         }
     }
 
+#if wxUSE_LIBHILDON
+    m_hildonProgram = hildon_program_get_instance();
+    if ( !m_hildonProgram )
+    {
+        wxLogError(_("Unable to initialize Hildon program"));
+        return false;
+    }
+#endif // wxUSE_LIBHILDON
+
     return true;
 }
 
 
 
 #include <gtk/gtk.h>
 
+#if wxUSE_LIBHILDON
+    #include <hildon-widgets/hildon-window.h>
+#endif // wxUSE_LIBHILDON
+
 // ----------------------------------------------------------------------------
 // event tables
 // ----------------------------------------------------------------------------
 
     if ( m_frameMenuBar )
     {
+#if wxUSE_LIBHILDON
+        hildon_window_set_menu(HILDON_WINDOW(m_widget), NULL);
+#else // !wxUSE_LIBHILDON
         m_frameMenuBar->UnsetInvokingWindow( this );
 
         gtk_widget_ref( m_frameMenuBar->m_widget );
 
         gtk_container_remove( GTK_CONTAINER(m_mainWidget), m_frameMenuBar->m_widget );
+#endif // wxUSE_LIBHILDON/!wxUSE_LIBHILDON
     }
 
     wxFrameBase::DetachMenuBar();
 
     if (m_frameMenuBar)
     {
+#if wxUSE_LIBHILDON
+        hildon_window_set_menu(HILDON_WINDOW(m_widget),
+                               GTK_MENU(m_frameMenuBar->m_menubar));
+#else // !wxUSE_LIBHILDON
         m_frameMenuBar->SetInvokingWindow( this );
 
         m_frameMenuBar->SetParent(this);
         gtk_widget_set_size_request(menuBar->m_widget, -1, -1);
 
         gtk_widget_show( m_frameMenuBar->m_widget );
+#endif // wxUSE_LIBHILDON/!wxUSE_LIBHILDON
     }
     // make sure next size_allocate causes a wxSizeEvent
     m_oldClientWidth = 0;
 
     m_style = style;
     m_invokingWindow = NULL;
 
+#if wxUSE_LIBHILDON
+    // Hildon window uses a single menu instead of a menu bar, so wxMenuBar is
+    // the same as menu in this case
+    m_widget =
+    m_menubar = gtk_menu_new();
+#else // !wxUSE_LIBHILDON
     if (!PreCreation( NULL, wxDefaultPosition, wxDefaultSize ) ||
         !CreateBase( NULL, -1, wxDefaultPosition, wxDefaultSize, style, wxDefaultValidator, wxT("menubar") ))
     {
     PostCreation();
 
     ApplyWidgetStyle();
+#endif // wxUSE_LIBHILDON/!wxUSE_LIBHILDON
 
     for (size_t i = 0; i < n; ++i )
         Append(menus[i], titles[i]);
     //     can't pass the menu which was closed in wxMenuEvent object
     g_signal_connect (m_menubar, "deactivate",
                       G_CALLBACK (gtk_menu_close_callback), this);
-
 }
 
 wxMenuBar::wxMenuBar(size_t n, wxMenu *menus[], const wxString titles[], long style)
 
 // XA_CARDINAL
 #include <X11/Xatom.h>
 
+#if wxUSE_LIBHILDON
+    #include <hildon-widgets/hildon-program.h>
+    #include <hildon-widgets/hildon-window.h>
+#endif // wxUSE_LIBHILDON
+
 // ----------------------------------------------------------------------------
 // data
 // ----------------------------------------------------------------------------
     //     e.g. in wxTaskBarIconAreaGTK
     if (m_widget == NULL)
     {
+#if wxUSE_LIBHILDON
+        // we must create HildonWindow and not a normal GtkWindow as the latter
+        // doesn't look correctly in Maemo environment and it must also be
+        // registered with the main program object
+        m_widget = hildon_window_new();
+        hildon_program_add_window(wxTheApp->GetHildonProgram(),
+                                  HILDON_WINDOW(m_widget));
+#else // !wxUSE_LIBHILDON
         m_widget = gtk_window_new(GTK_WINDOW_TOPLEVEL);
         if (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG)
         {
                 style |= wxFRAME_NO_TASKBAR;
             }
         }
+#endif // wxUSE_LIBHILDON/!wxUSE_LIBHILDON
     }
 
     wxWindow *topParent = wxGetTopLevelParent(m_parent);
 
 wxTopLevelWindowGTK::~wxTopLevelWindowGTK()
 {
+#if wxUSE_LIBHILDON
+    hildon_program_remove_window(wxTheApp->GetHildonProgram(),
+                                 HILDON_WINDOW(m_widget));
+#endif // wxUSE_LIBHILDON
+
     if (m_grabbed)
     {
         wxFAIL_MSG(_T("Window still grabbed"));