[gnome-initial-setup] summary-page: Install language packs



commit 0d36baf38edba7d625bafea7078215d40c58f812
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Tue Mar 26 15:27:32 2013 -0400

    summary-page: Install language packs

 .gitignore                                         |    1 +
 gnome-initial-setup/pages/summary/Makefile.am      |    7 +
 .../pages/summary/gis-summary-page.c               |   56 ++
 .../pages/summary/org.freedesktop.PackageKit.xml   |  546 ++++++++++++++++++++
 4 files changed, 610 insertions(+), 0 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 2f0fbbd..80575a1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -58,6 +58,7 @@ gnome-initial-setup/pages/location/cc-datetime-resources.[ch]
 gnome-initial-setup/pages/location/location-resources.[ch]
 gnome-initial-setup/pages/goa/goa-resources.[ch]
 gnome-initial-setup/pages/summary/summary-resources.[ch]
+gnome-initial-setup/pages/summary/pk.[ch]
 
 gnome-initial-setup-first-login.desktop
 gnome-initial-setup.desktop
diff --git a/gnome-initial-setup/pages/summary/Makefile.am b/gnome-initial-setup/pages/summary/Makefile.am
index d716355..c93ee77 100644
--- a/gnome-initial-setup/pages/summary/Makefile.am
+++ b/gnome-initial-setup/pages/summary/Makefile.am
@@ -8,6 +8,13 @@ AM_CPPFLAGS = \
 
 BUILT_SOURCES =
 
+pk.c: pk.h
+pk.h: $(srcdir)/org.freedesktop.PackageKit.xml
+       $(AM_V_GEN) gdbus-codegen \
+               --interface-prefix org.freedesktop. \
+               --generate-c-code pk $<
+BUILT_SOURCES += pk.c pk.h
+
 resource_files = $(shell glib-compile-resources --sourcedir=$(srcdir) --generate-dependencies 
$(srcdir)/summary.gresource.xml)
 summary-resources.c: summary.gresource.xml $(resource_files)
        $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate-source $<
diff --git a/gnome-initial-setup/pages/summary/gis-summary-page.c 
b/gnome-initial-setup/pages/summary/gis-summary-page.c
index cdf1e1b..a9965d0 100644
--- a/gnome-initial-setup/pages/summary/gis-summary-page.c
+++ b/gnome-initial-setup/pages/summary/gis-summary-page.c
@@ -32,6 +32,7 @@
 #include <glib/gstdio.h>
 #include <glib/gi18n.h>
 #include <gio/gio.h>
+#include <locale.h>
 #include <stdlib.h>
 #include <errno.h>
 
@@ -39,6 +40,11 @@
 
 #include <gdm/gdm-client.h>
 
+#define GNOME_DESKTOP_USE_UNSTABLE_API
+#include <libgnome-desktop/gnome-languages.h>
+
+#include "pk.h"
+
 #define SERVICE_NAME "gdm-password"
 
 G_DEFINE_TYPE (GisSummaryPage, gis_summary_page, GIS_TYPE_PAGE);
@@ -212,6 +218,54 @@ add_setup_done_file (void)
   g_free (gis_done_path);
 }
 
+static gchar *
+getting_started_package_name (void)
+{
+  gchar *lc = setlocale (LC_MESSAGES, NULL);
+  gchar *locale = gnome_normalize_locale (lc);
+  gchar *package_name;
+
+  if (strcmp (locale, "en"))
+    package_name = g_strdup ("gnome-getting-started-docs");
+  else
+    package_name = g_strdup_printf ("gnome-getting-started-docs-%s", locale);
+
+  g_free (locale);
+  return package_name;
+}
+
+static void
+download_language_pack (GisSummaryPage *page)
+{
+  gchar *package_name = getting_started_package_name ();
+  gchar *package_names[2] = { package_name, NULL };
+  PackageKitModify *proxy;
+  GError *error = NULL;
+
+  proxy = package_kit_modify_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                     G_DBUS_PROXY_FLAGS_NONE,
+                                                     "org.freedesktop.PackageKit",
+                                                     "/org/freedesktop/PackageKit",
+                                                     NULL, NULL);
+
+  if (!package_kit_modify_call_install_package_names_sync (proxy,
+                                                           0,
+                                                           (const gchar *const *) package_names,
+                                                           
"hide-confirm-search,hide-confirm-deps,hide-confirm-install,hide-progress,hide-finished,hide-warning",
+                                                           NULL, &error)) {
+
+    /* we need to get a better api than this broken pile of trash */
+    if (!(g_dbus_error_is_remote_error (error) &&
+          g_strcmp0 (g_dbus_error_get_remote_error (error), "org.freedesktop.PackageKit.Modify.Failed") == 0 
&&
+          g_dbus_error_strip_remote_error (error) &&
+          g_strcmp0 (error->message, "package already found") == 0))
+      g_warning ("Error installing packages: %s", error->message);
+  }
+
+  g_clear_error (&error);
+  g_free (package_name);
+}
+
 static void
 done_cb (GtkButton *button, GisSummaryPage *page)
 {
@@ -246,6 +300,8 @@ prepare_cb (GisAssistant   *assistant,
       gis_driver_get_user_permissions (GIS_PAGE (this_page)->driver,
                                        &priv->user_account,
                                        &priv->user_password);
+
+      download_language_pack (this_page);
     }
 }
 
diff --git a/gnome-initial-setup/pages/summary/org.freedesktop.PackageKit.xml 
b/gnome-initial-setup/pages/summary/org.freedesktop.PackageKit.xml
new file mode 100644
index 0000000..72ad53c
--- /dev/null
+++ b/gnome-initial-setup/pages/summary/org.freedesktop.PackageKit.xml
@@ -0,0 +1,546 @@
+<!DOCTYPE node PUBLIC
+"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
+"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"; [
+  <!ENTITY ERROR_GENERAL "org.freedesktop.PackageKit.Denied">
+]>
+<node name="/" xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd";>
+
+  <interface name="org.freedesktop.PackageKit.Query">
+    <doc:doc>
+      <doc:description>
+        <doc:para>
+          The interface used for quering the package database.
+        </doc:para>
+      </doc:description>
+    </doc:doc>
+
+    <!--*****************************************************************************************-->
+    <method name="IsInstalled">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <doc:doc>
+        <doc:description>
+          <doc:para>
+            Finds out if the package is installed.
+          </doc:para>
+        </doc:description>
+      </doc:doc>
+      <arg type="s" name="package_name" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              A package name, e.g. <doc:tt>hal-info</doc:tt>
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="s" name="interaction" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              An optional interaction mode, e.g.
+              <doc:tt>timeout=10</doc:tt>
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="b" name="installed" direction="out">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              If the package is installed.
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+    </method>
+
+    <!--*****************************************************************************************-->
+    <method name="SearchFile">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <doc:doc>
+        <doc:description>
+          <doc:para>
+            Finds the package name for an installed or available file
+          </doc:para>
+        </doc:description>
+      </doc:doc>
+      <arg type="s" name="file_name" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              A package name, e.g. <doc:tt>/usr/share/help/gimp/index.html</doc:tt>
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="s" name="interaction" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              An optional interaction mode, e.g.
+              <doc:tt>timeout=10</doc:tt>
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="b" name="installed" direction="out">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              If the package is installed.
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="s" name="package_name" direction="out">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              The package name of the file, e.g. <doc:tt>hal-info</doc:tt>
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+    </method>
+  </interface>
+
+  <!-- ######################################################################################### -->
+  <interface name="org.freedesktop.PackageKit.Modify">
+    <doc:doc>
+      <doc:description>
+        <doc:para>
+          The interface used for modifying the package database.
+        </doc:para>
+      </doc:description>
+    </doc:doc>
+
+    <!--*****************************************************************************************-->
+    <method name="InstallPackageFiles">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <doc:doc>
+        <doc:description>
+          <doc:para>
+            Installs local package files or service packs.
+          </doc:para>
+        </doc:description>
+      </doc:doc>
+      <arg type="u" name="xid" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              The X window handle ID, used for focus stealing prevention and setting modality.
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="as" name="files" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              An array of file names.
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="s" name="interaction" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              An interaction mode that specifies which UI elements should be shown
+              or hidden different from the user default, e.g.
+              <doc:tt>hide-confirm-search,hide-confirm-deps,hide-confirm-install,show-progress</doc:tt>.
+              The show options are:
+              
<doc:tt>show-confirm-search,show-confirm-deps,show-confirm-install,show-progress,show-finished,show-warning</doc:tt>.
+              The hide options are:
+              
<doc:tt>hide-confirm-search,hide-confirm-deps,hide-confirm-install,hide-progress,hide-finished,hide-warning</doc:tt>.
+              Convenience options such as:
+              <doc:tt>never</doc:tt>, <doc:tt>defaults</doc:tt> or <doc:tt>always</doc:tt>.
+              are also available.
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+    </method>
+
+    <!--*****************************************************************************************-->
+    <method name="InstallProvideFiles">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <doc:doc>
+        <doc:description>
+          <doc:para>
+            Installs packages to provide files.
+          </doc:para>
+        </doc:description>
+      </doc:doc>
+      <arg type="u" name="xid" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              The X window handle ID, used for focus stealing prevention and setting modality.
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="as" name="files" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              An array of file names.
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="s" name="interaction" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              An optional interaction mode, e.g.
+              
<doc:tt>show-confirm-search,show-confirm-deps,show-confirm-install,show-progress,show-finished,show-warning</doc:tt>
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+    </method>
+
+    <!--*****************************************************************************************-->
+    <method name="InstallCatalogs">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <doc:doc>
+        <doc:description>
+          <doc:para>
+            Installs specified package catalogs.
+          </doc:para>
+        </doc:description>
+      </doc:doc>
+      <arg type="u" name="xid" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              The X window handle ID, used for focus stealing prevention and setting modality.
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="as" name="files" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              An array of catalog file names.
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="s" name="interaction" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              An optional interaction mode, e.g.
+              
<doc:tt>show-confirm-search,show-confirm-deps,show-confirm-install,show-progress,show-finished,show-warning</doc:tt>
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+    </method>
+
+    <!--*****************************************************************************************-->
+    <method name="InstallPackageNames">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <doc:doc>
+        <doc:description>
+          <doc:para>
+            Installs packages from a configured software source.
+          </doc:para>
+        </doc:description>
+      </doc:doc>
+      <arg type="u" name="xid" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              The X window handle ID, used for focus stealing prevention and setting modality.
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="as" name="packages" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              An array of package names.
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="s" name="interaction" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              An optional interaction mode, e.g.
+              
<doc:tt>show-confirm-search,show-confirm-deps,show-confirm-install,show-progress,show-finished,show-warning</doc:tt>
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+    </method>
+
+    <!--*****************************************************************************************-->
+    <method name="InstallMimeTypes">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <doc:doc>
+        <doc:description>
+          <doc:para>
+            Installs mimetype handlers from a configured software source.
+          </doc:para>
+        </doc:description>
+      </doc:doc>
+      <arg type="u" name="xid" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              The X window handle ID, used for focus stealing prevention and setting modality.
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="as" name="mime_types" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              An array of mime types, e.g. <doc:tt>text/plain</doc:tt>
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="s" name="interaction" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              An optional interaction mode, e.g.
+              
<doc:tt>show-confirm-search,show-confirm-deps,show-confirm-install,show-progress,show-finished,show-warning</doc:tt>
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+    </method>
+
+    <!--*****************************************************************************************-->
+    <method name="InstallFontconfigResources">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <doc:doc>
+        <doc:description>
+          <doc:para>
+            Installs fontconfig resources (usually fonts) from a configured software source.
+          </doc:para>
+        </doc:description>
+      </doc:doc>
+      <arg type="u" name="xid" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              The X window handle ID, used for focus stealing prevention and setting modality.
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="as" name="resources" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              An array of font descriptors from fontconfig, e.g. <doc:tt>:lang=mn</doc:tt>
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="s" name="interaction" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              An optional interaction mode, e.g.
+              
<doc:tt>show-confirm-search,show-confirm-deps,show-confirm-install,show-progress,show-finished,show-warning</doc:tt>
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+    </method>
+
+    <!--*****************************************************************************************-->
+    <method name="InstallGStreamerResources">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <doc:doc>
+        <doc:description>
+          <doc:para>
+            Installs GStreamer fontconfig resources (usually codecs) from a configured software source.
+          </doc:para>
+        </doc:description>
+      </doc:doc>
+      <arg type="u" name="xid" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              The X window handle ID, used for focus stealing prevention and setting modality.
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="as" name="resources" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              An array of codecs descriptors from <doc:tt>pk-gstreamer-install</doc:tt>, e.g.
+              <doc:tt>Advanced Streaming Format (ASF) demuxer|decoder-video/x-ms-asf</doc:tt>
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="s" name="interaction" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              An optional interaction mode, e.g.
+              
<doc:tt>show-confirm-search,show-confirm-deps,show-confirm-install,show-progress,show-finished,show-warning</doc:tt>
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+    </method>
+
+    <!--*****************************************************************************************-->
+    <method name="InstallResources">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <doc:doc>
+        <doc:description>
+          <doc:para>
+            Installs resources of a given type from a configured software source.
+          </doc:para>
+        </doc:description>
+      </doc:doc>
+      <arg type="u" name="xid" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              The X window handle ID, used for focus stealing prevention and setting modality.
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="s" name="type" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              The type of resource to request, e.g. <doc:tt>plasma-service</doc:tt>
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="as" name="resources" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              An array of resource descriptors
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="s" name="interaction" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              An optional interaction mode, e.g.
+              
<doc:tt>show-confirm-search,show-confirm-deps,show-confirm-install,show-progress,show-finished,show-warning</doc:tt>
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+    </method>
+
+    <!--*****************************************************************************************-->
+    <method name="RemovePackageByFiles">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <doc:doc>
+        <doc:description>
+          <doc:para>
+            Removes packages that provide the given local files.
+          </doc:para>
+        </doc:description>
+      </doc:doc>
+      <arg type="u" name="xid" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              The X window handle ID, used for focus stealing prevention and setting modality.
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="as" name="files" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              An array of file names.
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="s" name="interaction" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              An interaction mode that specifies which UI elements should be shown
+              or hidden different from the user default, e.g.
+              <doc:tt>hide-confirm-search,hide-confirm-deps,hide-confirm-install,show-progress</doc:tt>.
+              The show options are:
+              
<doc:tt>show-confirm-search,show-confirm-deps,show-confirm-install,show-progress,show-finished,show-warning</doc:tt>.
+              The hide options are:
+              
<doc:tt>hide-confirm-search,hide-confirm-deps,hide-confirm-install,hide-progress,hide-finished,hide-warning</doc:tt>.
+              Convenience options such as:
+              <doc:tt>never</doc:tt>, <doc:tt>defaults</doc:tt> or <doc:tt>always</doc:tt>.
+              are also available.
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+    </method>
+
+    <method name="InstallPrinterDrivers">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <doc:doc>
+        <doc:description>
+          <doc:para>
+            Installs printer drivers from a configured software source.
+          </doc:para>
+        </doc:description>
+      </doc:doc>
+      <arg type="u" name="xid" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              The X window handle ID, used for focus stealing prevention and setting modality.
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="as" name="resources" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              An array of printer model descriptors in IEEE 1284
+              Device ID format,
+              e.g. <doc:tt>MFG:Hewlett-Packard;MDL:HP LaserJet
+              6MP;</doc:tt>.
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+      <arg type="s" name="interaction" direction="in">
+        <doc:doc>
+          <doc:summary>
+            <doc:para>
+              An optional interaction mode, e.g.
+              
<doc:tt>show-confirm-search,show-confirm-deps,show-confirm-install,show-progress,show-finished,show-warning</doc:tt>
+            </doc:para>
+          </doc:summary>
+        </doc:doc>
+      </arg>
+    </method>
+  </interface>
+</node>
+


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]