Editing Documentation/Maemo 5 Developer Guide/Porting Software/Porting MaemoPad

Warning: You are not logged in. Your IP address will be recorded in this page's edit history.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 1: Line 1:
This is a practical example of porting a [[Open development/Maemo roadmap/Diablo|Diablo]] (Maemo 4.1) application to [[Open development/Maemo roadmap/Fremantle|Fremantle]] (Maemo 5). The example application, MaemoPad, is a simple Notepad-like editor.
This is a practical example of porting a [[Open development/Maemo roadmap/Diablo|Diablo]] (Maemo 4.1) application to [[Open development/Maemo roadmap/Fremantle|Fremantle]] (Maemo 5). The example application, MaemoPad, is a simple Notepad-like editor.
-
[[Image:maemopad.png|frame|center|alt=Screenshot of MaemoPad|MaemoPad main window]]
+
<div align="CENTER">
-
 
+
{| summary="MaemoPad"
 +
|+ align="BOTTOM" |'''Figure:''' MaemoPad
 +
|-
 +
|
 +
[[Image:maemopad.png|MaemoPad]]
 +
|}
 +
</div>
== Porting MaemoPad from Diablo to Fremantle  ==
== Porting MaemoPad from Diablo to Fremantle  ==
Line 10: Line 16:
=== Installing MaemoPad ===
=== Installing MaemoPad ===
-
MaemoPad can be installed and tested in the Scratchbox environment.
+
MaemoPad can be installed and tested in the scratchbox environment.
* If not already activated, activate the X86 target, go to the testing directory, and download the source package of maemopad application.
* If not already activated, activate the X86 target, go to the testing directory, and download the source package of maemopad application.
Line 146: Line 152:
Diablo: debian/control:
Diablo: debian/control:
-
<pre>
+
Build-Depends: debhelper (&gt;= 4.0.0), intltool,
-
Build-Depends: debhelper (&gt;= 4.0.0), intltool,
+
  libhildon1-dev, libgtk2.0-dev, libosso-gnomevfs2-dev,
-
libhildon1-dev, libgtk2.0-dev, libosso-gnomevfs2-dev,
+
  libglib2.0-dev, libdbus-glib-1-dev, libosso-dev, libmodest-dbus-client-dev,
-
libglib2.0-dev, libdbus-glib-1-dev, libosso-dev, libmodest-dbus-client-dev,
+
  conbtdialogs-dev,libhildonhelp-dev, libhildonfm2-dev, osso-af-settings
-
conbtdialogs-dev,libhildonhelp-dev, libhildonfm2-dev, osso-af-settings
+
-
</pre>
+
Fremantle: debian/control:
Fremantle: debian/control:
-
<pre>
+
Build-Depends: debhelper (&gt;= 4.0.0), intltool,
-
Build-Depends: debhelper (&gt;= 4.0.0), intltool,
+
  libhildon1-dev, libgtk2.0-dev, libosso-gnomevfs2-dev,
-
libhildon1-dev, libgtk2.0-dev, libosso-gnomevfs2-dev,
+
  libglib2.0-dev, libdbus-glib-1-dev, libosso-dev, libmodest-dbus-client-dev,
-
libglib2.0-dev, libdbus-glib-1-dev, libosso-dev, libmodest-dbus-client-dev,
+
  conbtdialogs-dev,  libhildonfm2-dev, osso-af-settings
-
conbtdialogs-dev,  libhildonfm2-dev, osso-af-settings
+
-
</pre>
+
Callback and all other help stuff removed:
Callback and all other help stuff removed:
Line 208: Line 210:
<source lang="c">  
<source lang="c">  
-
PKG_CHECK_MODULES(HILDON, hildon-1 hildon-fm-2 conbtdialogs)
+
PKG_CHECK_MODULES(HILDON, hildon-1 hildon-fm-2 conbtdialogs)
</source>
</source>
Line 249: Line 251:
Also the menu system was changed. In Diablo, a <code>GtkMenu</code> was used, but it was replaced with a <code>HildonAppMenu</code> in Fremantle, as shown in Figure:
Also the menu system was changed. In Diablo, a <code>GtkMenu</code> was used, but it was replaced with a <code>HildonAppMenu</code> in Fremantle, as shown in Figure:
-
[[Image:maemopad_menu.png|frame|center|alt=Screenshot of MaemoPad menu|MaemoPad menu]]
+
<div align="CENTER">
 +
 
 +
{| summary="MaemoPad Menu"
 +
|+ align="BOTTOM" |'''Figure:''' MaemoPad Menu
 +
|-
 +
|
 +
<div align="CENTER">[[Image:maemopad_menu.png|MaemoPad menu]]</div>
 +
|}
 +
 
 +
</div>
Function <code>create_menu()</code> is responsible for creating the menus in both versions:
Function <code>create_menu()</code> is responsible for creating the menus in both versions:
Line 345: Line 356:
</source>
</source>
-
Menu callbacks were also changed. There were some changes in the callbacks themselves as a result of code reorganizations, but the main change from the menu viewpoint was that the 1st arguments of the callbacks were changed from <code>GtkAction</code> to <code>GtkButton</code>, like in the following example:
+
Menu callbacks were also changed. There were some changes in the callbacks themselves as a result of code reorganizations, but the main change from the menu viewpoint was that the 1st arguments of the callbacks were changed from GtkAction to GtkButton, like in the following example:
Diablo callbacks.c  
Diablo callbacks.c  
Line 364: Line 375:
<li>
<li>
Rich text support was changed with the new GTK+, as described in [http://live.gnome.org/Maemo/Gtk210Migration Maemo-GTK+ 2.6 to 2.10 Migration].This required editing two lines:
Rich text support was changed with the new GTK+, as described in [http://live.gnome.org/Maemo/Gtk210Migration Maemo-GTK+ 2.6 to 2.10 Migration].This required editing two lines:
-
 
+
<br /><br />
Part of function <code>create_textarea()</code> in Diablo interface.c  
Part of function <code>create_textarea()</code> in Diablo interface.c  
Line 373: Line 384:
</source>
</source>
-
Part of function <code>create_textarea()</code> in Fremantle maemopad-window.c  
+
Part of function create_textarea() in Fremantle maemopad-window.c  
<source lang="c">
<source lang="c">
Line 381: Line 392:
</source>
</source>
</li>
</li>
 +
<li>
<li>
<code>HildonFontSelectionDialog</code> was deprecated and replaced with a <code>GtkFontButton</code>. In Diablo, the font callback was a callback to a regular <code>GtkAction</code>:
<code>HildonFontSelectionDialog</code> was deprecated and replaced with a <code>GtkFontButton</code>. In Diablo, the font callback was a callback to a regular <code>GtkAction</code>:
-
 
+
<br /><br />
callback.c  
callback.c  
Line 401: Line 413:
Function <code>callback_font</code> got the font from an auxiliary function <code>interface_font_chooser()</code> and then modified the font in the text view. The auxiliary function <code>interface_font_chooser()</code> in turn opened a <code>HildonFontSelectionDialog</code> that returned the font parameters:
Function <code>callback_font</code> got the font from an auxiliary function <code>interface_font_chooser()</code> and then modified the font in the text view. The auxiliary function <code>interface_font_chooser()</code> in turn opened a <code>HildonFontSelectionDialog</code> that returned the font parameters:
-
 
+
<br /><br />
callback.c  
callback.c  
Line 440: Line 452:
Instead of the deprecated <code>HildonFontSelectionDialog</code>, Fremantle uses a <code>GtkFontButton</code> directly in the font button callback:
Instead of the deprecated <code>HildonFontSelectionDialog</code>, Fremantle uses a <code>GtkFontButton</code> directly in the font button callback:
-
 
+
<br /><br />
maemopad-window.c  
maemopad-window.c  
Line 462: Line 474:
</source>
</source>
-
This <code>GtkFontButton</code> was initialized in function <code>create_menu()</code> (see above) in <code>maemopad-window.c</code> so that it would respond to the <code>"font-set"</code> signal and call the callback above:
+
This <code>GtkFontButton</code> was initialized in function <code>create_menu()</code> (see above) in maemopad-window.c so that it would respond to the <code>"font-set"</code> signal and call the callback above:
<source lang="c">
<source lang="c">
Line 475: Line 487:
<li>
<li>
Instead of <code>GtkTextView</code>, a [http://maemo.org/api_refs/5.0/5.0-final/hildon/HildonTextView.html HildonTextView] is now used:
Instead of <code>GtkTextView</code>, a [http://maemo.org/api_refs/5.0/5.0-final/hildon/HildonTextView.html HildonTextView] is now used:
-
 
+
<br /><br />
Diablo callback.c
Diablo callback.c
Line 507: Line 519:
<li>
<li>
All Hildon applications should now initialize hildon before using it. In maemopad this is done by calling <code>hildon_gtk_init()</code> which also calls <code>gtk_init()</code> so the original call can be removed:
All Hildon applications should now initialize hildon before using it. In maemopad this is done by calling <code>hildon_gtk_init()</code> which also calls <code>gtk_init()</code> so the original call can be removed:
-
 
+
<br /><br />
Diablo main.c  
Diablo main.c  

Learn more about Contributing to the wiki.


Please note that all contributions to maemo.org wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see maemo.org wiki:Copyrights for details). Do not submit copyrighted work without permission!


Cancel | Editing help (opens in new window)