Sunday, December 23, 2007

Changes to wxWidgets 2.9 SVN repo

To get everything to compile correctly under Maemo 4.0 with the new Hildon-1 library and ScratchBox, I needed to do the following:

- Change pkg-config files to use new library, without needing to edit configure script
> ln -s /usr/lib/pkgconfig/hildon-1.pc /usr/lib/pkgconfig/hildon-lgpl.pc

- Edit source files for compatibility.
Replace any hildon #include statements with #include <hildon/hildon.h>

I needed to edit the following files:
M src/gtk/checklst.cpp
M src/gtk/frame.cpp
M src/gtk/toplevel.cpp
M src/gtk/msgdlg.cpp
M src/gtk/hildon/notifmsg.cpp
M src/gtk/colordlg.cpp
M src/gtk/app.cpp

I'll provide a full listing of the changes after the directions are complete.

- Configure
> ./configure --with-hildon

- Make
> make && make install
(this will put the includes and utils and libs in /usr/local/)

That should pretty much do it. To transfer it to the tablet, I just tar/gzip it up and dump the whole ScratchBox /usr/local into the tablet's /usr/local, then add /usr/local/lib to /etc/ld.so.conf, and run ldconfig as root.

If you don't want to compile this all yourself, I've posted the tar.gz:

http://caflor.net/iosix/wxMaemo4-2.9.tar.gz
(6347243 bytes, md5: c2fcc4c646b67f1cfa3506a479deffdc)

This also includes nano (the useful command-line text editor, very much like pico).

To extract on either ScratchBox or the N800/N810 (need xterm or ssh on the tablet):
> cd /usr/local
> wget http://caflor.net/iosix/wxMaemo4-2.9.tar.gz
> tar -zxf wxMaemo4-2.9.tar.gz

Any applications you run under ScratchBox may crash unless you run them like this:
> run-standalone.sh wxWidgets/samples/dialogs/dialogs

Thanks.



Now for the changes (I'm hoping someone with a. write access to wxWidgets SVN and b. a good idea of how to integrate this portably will merge these into the main SVN) :

-- This is to allow the checkboxes in a list with a select capability to work correctly. They are not wide enough for the Hildon checkboxes by default.

[sbox-CHINOOK_ARMEL: ~/wxWidgets/src/gtk] > svn diff checklst.cpp
Index: checklst.cpp
===================================================================
--- checklst.cpp (revision 50770)
+++ checklst.cpp (working copy)
@@ -87,7 +87,7 @@
gtk_tree_view_column_new_with_attributes( "", renderer,
"active", 0,
NULL );
- gtk_tree_view_column_set_fixed_width(column, 20);
+ gtk_tree_view_column_set_fixed_width(column, 40); // hildon
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
gtk_tree_view_column_set_clickable(column, TRUE);


-- Compatibility with Hildon-1 library

[sbox-CHINOOK_ARMEL: ~/wxWidgets/src/gtk] > svn diff frame.cpp
Index: frame.cpp
===================================================================
--- frame.cpp (revision 50770)
+++ frame.cpp (working copy)
@@ -21,7 +21,7 @@
#include <gtk/gtk.h>

#if wxUSE_LIBHILDON
- #include <hildon-widgets/hildon-window.h>
+ #include <hildon/hildon.h>
#endif // wxUSE_LIBHILDON

// ----------------------------------------------------------------------------


-- To make wxWidgets see the window sizes correctly, as it seems to be off by 24 pixels in the non-fullscreen view. This would cause widgets to be drawn off-screen unintentionally.

[sbox-CHINOOK_ARMEL: ~/wxWidgets/src/gtk] > svn diff toplevel.cpp
Index: toplevel.cpp
===================================================================
--- toplevel.cpp (revision 50770)
+++ toplevel.cpp (working copy)
@@ -46,8 +46,7 @@
#include <X11/Xatom.h>

#if wxUSE_LIBHILDON
- #include <hildon-widgets/hildon-program.h>
- #include <hildon-widgets/hildon-window.h>
+ #include <hildon/hildon.h>
#endif // wxUSE_LIBHILDON

// ----------------------------------------------------------------------------
@@ -905,8 +904,22 @@
size -= m_decorSize;
if (size.x < 0) size.x = 0;
if (size.y < 0) size.y = 0;
- if (width) *width = size.x;
- if (height) *height = size.y;
+ if (width) {
+ if (size.x == 720)
+ *width = 696;
+ else
+ *width = size.x;
+ }
+ if (height) {
+ if (size.y == 420)
+ *height = 396;
+ else if (size.y == 270)
+ *height = 246;
+ else
+ *height = size.y;
+ }
}

void wxTopLevelWindowGTK::DoSetSize( int x, int y, int width, int height, int sizeFlags )


-- Compatibility with Hildon-1 library

[sbox-CHINOOK_ARMEL: ~/wxWidgets/src/gtk] > svn diff msgdlg.cpp
Index: msgdlg.cpp
===================================================================
--- msgdlg.cpp (revision 50770)
+++ msgdlg.cpp (working copy)
@@ -28,7 +28,7 @@
#include <gtk/gtk.h>

#if wxUSE_LIBHILDON
- #include <hildon-widgets/hildon-note.h>
+ #include <hildon/hildon.h>
#endif // wxUSE_LIBHILDON

IMPLEMENT_CLASS(wxMessageDialog, wxDialog)
@@ -67,7 +67,7 @@
m_widget = (GtkWidget *)g_object_new
(
HILDON_TYPE_NOTE,
- "note_type", HILDON_NOTE_CONFIRMATION_BUTTON_TYPE,
+ "note_type", HILDON_NOTE_TYPE_CONFIRMATION_BUTTON,
"description", (const char *)GetFullMessage().utf8_str(),
"icon", stockIcon,
NULL


-- Compatibility with Hildon-1 library

[sbox-CHINOOK_ARMEL: ~/wxWidgets/src/gtk] > svn diff hildon/notifmsg.cpp
Index: hildon/notifmsg.cpp
===================================================================
--- hildon/notifmsg.cpp (revision 50770)
+++ hildon/notifmsg.cpp (working copy)
@@ -31,7 +31,7 @@
#include "wx/notifmsg.h"
#include "wx/toplevel.h"

-#include <hildon-widgets/hildon-banner.h>
+#include <hildon/hildon.h>

// ============================================================================
// wxNotificationMessage implementation


-- Compatibility with Hildon-1 library

[sbox-CHINOOK_ARMEL: ~/wxWidgets/src/gtk] > svn diff app.cpp
Index: app.cpp
===================================================================
--- app.cpp (revision 50770)
+++ app.cpp (working copy)
@@ -30,7 +30,7 @@
#include "wx/apptrait.h"

#if wxUSE_LIBHILDON
- #include <hildon-widgets/hildon-program.h>
+ #include <hildon/hildon.h>
#endif // wxUSE_LIBHILDON

#include <gdk/gdkx.h>


-- This was the big one; much of the color API was changed from hildon-lgpl to hildon-1... Also, the new include files do not seem to work equally well with C and C++...

[sbox-CHINOOK_ARMEL: ~/wxWidgets/src/gtk] > svn diff colordlg.cpp
Index: colordlg.cpp
===================================================================
--- colordlg.cpp (revision 50770)
+++ colordlg.cpp (working copy)
@@ -27,7 +27,9 @@
#include "wx/gtk/private.h"

#if wxUSE_LIBHILDON
- #include <hildon-widgets/hildon-color-selector.h>
+extern "C" {
+ #include <hildon/hildon.h>
+}
#endif // wxUSE_LIBHILDON

IMPLEMENT_DYNAMIC_CLASS(wxColourDialog, wxDialog)
@@ -47,7 +49,7 @@
: NULL;

#if wxUSE_LIBHILDON
- m_widget = hildon_color_selector_new(parentGTK);
+ m_widget = hildon_color_chooser_dialog_new();
#else // !wxUSE_LIBHILDON
wxString title(_("Choose colour"));
m_widget = gtk_color_selection_dialog_new(wxGTK_CONV(title));
@@ -96,8 +98,17 @@
: NULL;

#if wxUSE_LIBHILDON
- HildonColorSelector * const sel = HILDON_COLOR_SELECTOR(m_widget);
- hildon_color_selector_set_color(sel, wx_const_cast(GdkColor *, col));
+ GdkColor clr;
+ if (col)
+ clr = *col;
+ else {
+ clr.pixel = 0;
+ clr.red = 32768;
+ clr.green = 32768;
+ clr.blue = 32768;
+ }
+
+ hildon_color_chooser_dialog_set_color((HildonColorChooserDialog *)m_widget, &clr);
#else // !wxUSE_LIBHILDON
GtkColorSelection *sel =
GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(m_widget)->colorsel);
@@ -129,10 +140,23 @@
void wxColourDialog::DialogToColourData()
{
#if wxUSE_LIBHILDON
- HildonColorSelector * const sel = HILDON_COLOR_SELECTOR(m_widget);
- const GdkColor * const clr = hildon_color_selector_get_color(sel);
- if ( clr )
- m_data.SetColour(*clr);
+ const GdkColor * const
+ col = m_data.GetColour().Ok() ? m_data.GetColour().GetColor()
+ : NULL;
+
+ GdkColor clr;
+ if (col)
+ clr = *col;
+ else {
+ clr.pixel = 0;
+ clr.red = 32768;
+ clr.green = 32768;
+ clr.blue = 32768;
+ }
+ GdkColor new_color = clr;
+ hildon_color_chooser_dialog_get_color((HildonColorChooserDialog *)m_widget, &new_color);
+
+ m_data.SetColour(new_color);
#else // !wxUSE_LIBHILDON
GtkColorSelection *sel =
GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(m_widget)->colorsel);

1 comment:

VZ said...

Hello,

I didn't have time to continue playing with Maemo since December myself and so I'm very glad to see that you have made so much progress since then.

However it would be really great if you could contribute your changes to us (post to wx-dev@lists.wxwidgets.org to discuss and/or follow instructions and submit patches). The only thing that I'd like to change is that I'd prefer to use #ifdef to test for Hildon libraries versions instead of just replacing 770 code with 800-only versions as I only have a 770 myself and I'd like to be able to continue to test wx apps on it.

Anyhow, please do get in touch with us and let's try to integrate your changes into svn so that they don't get lost.

TIA!