RecipeAddingLPI

Ubuntu Development > Internationalization Guide > Recipe

Launchpad integration library

Ubuntu applications use the Launchpad integration library to provide shortcuts to Launchpad to obtain help, report bugs and submit translations. You can see it in action in any Ubuntu application's Help menu:

../LPI.png

(i) Note that this only works for Ubuntu packages available in the repositories. The Launchpad integration library does not work with PPAs or other projects hosted in Launchpad.

It has bindings for several languages. Some examples

Python with GtkBuilder

   1 import LaunchpadIntegration
   2 LaunchpadIntegration.set_sourcepackagename('my_app')
   3 LaunchpadIntegration.add_items(self.builder.get_object('menu_help'), 0, False, True)

Assuming self.builder is a gtk.Builder object where the UI is loaded, the first argument in the add_items method is the widget where to add the menu items (a menu we've called 'menu_help'), the second one is their position in the menu shell, and the last two ones specify whether to show spearators on the top and bottom, respectively.

Here is also another example on how Launchpad integration was added to Pitivi.

C# with Glade

   1 using LaunchpadIntegration;
   2 public class GladeApp
   3 {
   4         [Glade.Widget] Gtk.Menu help_menu;
   5 
   6         public static void Main (string[] args)
   7         {
   8                 Glade.XML gxml = new Glade.XML (null, "gui.glade", "window1", null);
   9                 LaunchpadIntegration.LaunchpadIntegration.SetSourcePackageName ("my_app")
  10                 LaunchpadIntegration.AddItems (self.builder.get_object("help_menu"), 0, false, true)
  11         }
  12 }

C

Here's an example in C of how support for this library was added to Empathy:

   1 === modified file 'configure.ac'
   2 --- configure.ac        2009-10-13 03:20:58 +0000
   3 +++ configure.ac        2009-10-13 03:26:58 +0000
   4 @@ -131,6 +131,7 @@
   5     gstreamer-0.10
   6     unique-1.0
   7     gnome-keyring-1 >= $KEYRING_REQUIRED
   8 +   launchpad-integration
   9  ])
  10  
  11  PKG_CHECK_MODULES(LIBNOTIFY, libnotify >= $LIBNOTIFY_REQUIRED)
  12 
  13 === modified file 'src/empathy-main-window.c'
  14 --- src/empathy-main-window.c   2009-10-13 03:20:58 +0000
  15 +++ src/empathy-main-window.c   2009-10-13 18:15:41 +0000
  16 @@ -27,6 +27,9 @@
  17  #include <gtk/gtk.h>
  18  #include <glib/gi18n.h>
  19  
  20 +/* Add launchpad hooks */
  21 +#include <launchpad-integration.h>
  22 +
  23  #include <libempathy/empathy-contact.h>
  24  #include <libempathy/empathy-utils.h>
  25  #include <libempathy/empathy-account-manager.h>
  26 @@ -1424,6 +1427,9 @@
  27  
  28         main_window_update_status (window, window->account_manager);
  29  
  30 +       /* Add launchpad hooks */
  31 +       launchpad_integration_add_ui (window->ui_manager, "/menubar/help/LaunchpadItems");
  32 +
  33         return window->window;
  34  }
  35  
  36 
  37 === modified file 'src/empathy-main-window.ui'
  38 --- src/empathy-main-window.ui  2009-10-13 03:19:42 +0000
  39 +++ src/empathy-main-window.ui  2009-10-13 18:17:20 +0000
  40 @@ -243,6 +243,7 @@
  41          <menu action="help">
  42            <menuitem action="help_contents"/>
  43            <menuitem action="help_debug"/>
  44 +          <placeholder name="LaunchpadItems"/>
  45            <menuitem action="help_about"/>
  46          </menu>
  47        </menubar>


CategoryUbuntuDevelopment CategoryTranslations

UbuntuDevelopment/Internationalisation/RecipeAddingLPI (last edited 2010-01-29 16:25:20 by 168)