~ubuntu-branches/debian/jessie/aisleriot/jessie

« back to all changes in this revision

Viewing changes to src/lib/ar-card-themes.c

  • Committer: Package Import Robot
  • Author(s): Jordi Mallach, Jeremy Bicha, Jordi Mallach
  • Date: 2012-04-22 12:49:26 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20120422124926-gmr0thwstl91jt1n
Tags: 1:3.4.1-1
[ Jeremy Bicha ]
* New upstream release
* debian/control.in: (Build)-depend on guile-2.0
* debian/*.install: Cards files are now stored as zipped .svg's
* debian/patches/99_format-security.patch: Dropped, applied upstream

[ Jordi Mallach ]
* New upstream release.
* Update copyright to final version of the machine-readable 1.0 spec.
* Bump Standards Version to 3.9.3.

Show diffs side-by-side

added added

removed removed

Lines of Context:
374
374
  variant = g_dbus_connection_call_finish (connection, result, &error);
375
375
  if (variant == NULL) {
376
376
    ar_debug_print (AR_DEBUG_CARD_THEME,
377
 
                        "Failed to call InstallPackages: %s\n",
378
 
                        error->message);
 
377
                    "Failed to call InstallCatalogs: %s\n",
 
378
                    error->message);
379
379
    g_error_free (error);
380
380
    g_object_unref (theme_manager);
381
381
    return;
641
641
 */
642
642
void
643
643
ar_card_themes_install_themes (ArCardThemes *theme_manager,
644
 
                                  GtkWindow *parent_window,
645
 
                                  guint user_time)
 
644
                               GtkWidget *parent_window,
 
645
                               guint user_time)
646
646
{
647
 
  static const char *formats[] = {
648
 
#ifdef ENABLE_CARD_THEME_FORMAT_SVG
649
 
    "ThemesSVG",
650
 
#endif
651
 
#ifdef ENABLE_CARD_THEME_FORMAT_KDE
652
 
    "ThemesKDE",
653
 
#endif
654
 
#ifdef ENABLE_CARD_THEME_FORMAT_PYSOL
655
 
    "ThemesPySol",
656
 
#endif
657
 
    NULL
658
 
  };
659
647
  char *path;
660
 
  GKeyFile *key_file;
661
648
  GDBusConnection *connection;
662
649
  GVariantBuilder builder;
663
 
  gsize i;
664
650
  GError *error = NULL;
665
651
 
 
652
  path = ar_runtime_get_file (AR_RUNTIME_PKG_DATA_DIRECTORY, "aisleriot.catalog");
 
653
 
 
654
  /* The gnome-packagekit DBUS API is broken */
 
655
  if (!g_utf8_validate (path, -1, NULL)) {
 
656
    g_free (path);
 
657
    g_warning ("Borked! Cannot call InstallCatalogs with non-UTF-8 path!\n");
 
658
    return;
 
659
  }
 
660
 
666
661
  connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
667
662
  if (connection == NULL) {
668
663
    ar_debug_print (AR_DEBUG_CARD_THEME,
669
 
                        "Failed to get the session bus: %s\n",
670
 
                        error->message);
 
664
                    "Failed to get the session bus: %s\n",
 
665
                    error->message);
671
666
    g_error_free (error);
672
 
    return;
673
 
  }
674
 
 
675
 
  key_file = g_key_file_new ();
676
 
  path = ar_runtime_get_file (AR_RUNTIME_PKG_DATA_DIRECTORY, "theme-install.ini");
677
 
  if (!g_key_file_load_from_file (key_file, path, 0, NULL)) {
678
667
    g_free (path);
679
 
    g_key_file_free (key_file);
680
 
    g_object_unref (connection);
681
668
    return;
682
669
  }
683
 
  g_free (path);
684
670
 
685
671
  g_variant_builder_init (&builder, G_VARIANT_TYPE ("(uass)"));
686
672
 
687
673
#ifdef GDK_WINDOWING_X11
688
 
  if (parent_window) {
 
674
  if (parent_window &&
 
675
      GDK_IS_X11_DISPLAY (gtk_widget_get_display (parent_window))) {
689
676
    g_variant_builder_add (&builder, "u",
690
 
                           (guint) GDK_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET (parent_window))));
 
677
                           (guint) GDK_WINDOW_XID (gtk_widget_get_window (parent_window)));
691
678
  } else
692
679
#endif
693
680
    g_variant_builder_add (&builder, "u", (guint) 0);
694
681
 
695
682
  g_variant_builder_open (&builder, G_VARIANT_TYPE ("as"));
696
 
 
697
 
  /* If there's a group for the specific distribution, use that one, or
698
 
   * otherwise the generic one. E.g.:
699
 
   * If "Ubuntu 8.10" group exists, use it, else fallback to "Ubuntu" group.
700
 
   */
701
 
  for (i = 0; formats[i] != NULL; ++i) {
702
 
    char **packages;
703
 
    gsize n_packages, j;
704
 
 
705
 
    packages = g_key_file_get_string_list (key_file, LSB_DISTRIBUTION, formats[i], &n_packages, NULL);
706
 
    if (packages == NULL)
707
 
      packages = g_key_file_get_string_list (key_file, LSB_DISTRIBUTOR, formats[i], &n_packages, NULL);
708
 
    if (packages == NULL)
709
 
      continue;
710
 
    
711
 
    for (j = 0; j < n_packages; ++j) {
712
 
      g_variant_builder_add (&builder, "s", packages[j]);
713
 
      ar_debug_print (AR_DEBUG_CARD_THEME, "Requesting pkg '%s'\n",
714
 
                          packages[j]);
715
 
    }
716
 
 
717
 
    g_strfreev (packages);
718
 
  }
719
 
 
720
 
  g_key_file_free (key_file);
721
 
 
 
683
  g_variant_builder_add (&builder, "s", path);
722
684
  g_variant_builder_close (&builder);
 
685
  g_free (path);
 
686
 
723
687
  g_variant_builder_add (&builder, "s", "hide-confirm-search" ","
724
688
                                        "show-confirm-install" ","
725
689
                                        "hide-warning");
728
692
                          "org.freedesktop.PackageKit",
729
693
                          "/org/freedesktop/PackageKit",
730
694
                          "org.freedesktop.PackageKit.Modify",
731
 
                          "InstallPackageNames",
 
695
                          "InstallCatalogs",
732
696
                          g_variant_builder_end (&builder),
733
697
                          G_VARIANT_TYPE ("()"),
734
698
                          G_DBUS_CALL_FLAGS_NONE,
735
699
                          G_MAXINT /* no timeout */,
736
 
                          NULL,
 
700
                          NULL /* cancellable */,
737
701
                          (GAsyncReadyCallback) theme_install_reply_cb,
738
702
                          g_object_ref (theme_manager));
739
703
}