]> git.saurik.com Git - wxWidgets.git/commitdiff
some Hildon integration work: use HildonProgram (for integration with the OS), Hildon...
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 12 Nov 2007 00:25:09 +0000 (00:25 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 12 Nov 2007 00:25:09 +0000 (00:25 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@49841 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/gtk/app.h
src/common/menucmn.cpp
src/gtk/app.cpp
src/gtk/frame.cpp
src/gtk/menu.cpp
src/gtk/toplevel.cpp

index d9a34eee80aa9c1b5d8aca18584e18316b205436..b258ea5a9969000994fc50ed33a4d33180ca778b 100644 (file)
 class WXDLLIMPEXP_FWD_BASE wxMutex;
 #endif
 
+#if wxUSE_LIBHILDON
+typedef struct _HildonProgram HildonProgram;
+#endif // wxUSE_LIBHILDON
+
 //-----------------------------------------------------------------------------
 // wxApp
 //-----------------------------------------------------------------------------
@@ -58,6 +62,10 @@ public:
     // 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
     // -------------------------------
@@ -80,6 +88,10 @@ private:
 #endif
     guint m_idleSourceId;
 
+#if wxUSE_LIBHILDON
+    HildonProgram *m_hildonProgram;
+#endif // wxUSE_LIBHILDON
+
     DECLARE_DYNAMIC_CLASS(wxApp)
 };
 
index 884fa75167268fcabb89e77f699ba185eeb37541..d7ae6c33d2c320d9cf01528ff9feb028bfe84bc4 100644 (file)
@@ -852,5 +852,4 @@ wxString wxMenuBarBase::GetLabelTop(size_t pos) const
 }
 #endif
 
-
 #endif // wxUSE_MENUS
index 62cf72b0bed670e3d106b35b24af0c2461f80fa2..12b3f4dfdde251d48ddfc98236d6594df53f91f8 100644 (file)
 #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>
 
 //-----------------------------------------------------------------------------
@@ -317,6 +321,15 @@ bool wxApp::OnInitGui()
         }
     }
 
+#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;
 }
 
index 3c1c9f91c3c2eec1f618c51d47f9db56c486c2d1..118148b185df88eded61f1ddc1d8fd20714da2b4 100644 (file)
 
 #include <gtk/gtk.h>
 
+#if wxUSE_LIBHILDON
+    #include <hildon-widgets/hildon-window.h>
+#endif // wxUSE_LIBHILDON
+
 // ----------------------------------------------------------------------------
 // event tables
 // ----------------------------------------------------------------------------
@@ -267,11 +271,15 @@ void wxFrame::DetachMenuBar()
 
     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();
@@ -286,6 +294,10 @@ void wxFrame::AttachMenuBar( wxMenuBar *menuBar )
 
     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);
@@ -309,6 +321,7 @@ void wxFrame::AttachMenuBar( wxMenuBar *menuBar )
         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;
index bfea8d89999b04a2b7521d4e4b313e9095f0423d..6e1d23f4c3a1524bd3cbbbb3890686ccb7232a76 100644 (file)
@@ -174,6 +174,12 @@ void wxMenuBar::Init(size_t n, wxMenu *menus[], const wxString titles[], long st
     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") ))
     {
@@ -197,6 +203,7 @@ void wxMenuBar::Init(size_t n, wxMenu *menus[], const wxString titles[], long st
     PostCreation();
 
     ApplyWidgetStyle();
+#endif // wxUSE_LIBHILDON/!wxUSE_LIBHILDON
 
     for (size_t i = 0; i < n; ++i )
         Append(menus[i], titles[i]);
@@ -207,7 +214,6 @@ void wxMenuBar::Init(size_t n, wxMenu *menus[], const wxString titles[], long st
     //     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)
index 2aa4cc4e5a8806560c0af91b90b25d6f5c614cc8..caca06176dced148fc4132634456fc1e23408b20 100644 (file)
 // 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
 // ----------------------------------------------------------------------------
@@ -503,6 +508,14 @@ bool wxTopLevelWindowGTK::Create( wxWindow *parent,
     //     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)
         {
@@ -529,6 +542,7 @@ bool wxTopLevelWindowGTK::Create( wxWindow *parent,
                 style |= wxFRAME_NO_TASKBAR;
             }
         }
+#endif // wxUSE_LIBHILDON/!wxUSE_LIBHILDON
     }
 
     wxWindow *topParent = wxGetTopLevelParent(m_parent);
@@ -665,6 +679,11 @@ bool wxTopLevelWindowGTK::Create( wxWindow *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"));