static void
gis_language_page_constructed (GObject *object)
{
  GisLanguagePage *page = GIS_LANGUAGE_PAGE (object);
  GisLanguagePagePrivate *priv = gis_language_page_get_instance_private (page);
  GDBusConnection *bus;

  g_type_ensure (CC_TYPE_LANGUAGE_CHOOSER);

  G_OBJECT_CLASS (gis_language_page_parent_class)->constructed (object);

  g_signal_connect (priv->language_chooser, "notify::language",
                    G_CALLBACK (language_changed), page);

  /* If we're in new user mode then we're manipulating system settings */
  if (gis_driver_get_mode (GIS_PAGE (page)->driver) == GIS_DRIVER_MODE_NEW_USER)
    {
      priv->permission = polkit_permission_new_sync ("org.freedesktop.locale1.set-locale", NULL, NULL, NULL);

      bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL);
      g_dbus_proxy_new (bus,
                        G_DBUS_PROXY_FLAGS_GET_INVALIDATED_PROPERTIES,
                        NULL,
                        "org.freedesktop.locale1",
                        "/org/freedesktop/locale1",
                        "org.freedesktop.locale1",
                        priv->cancellable,
                        (GAsyncReadyCallback) localed_proxy_ready,
                        object);
      g_object_unref (bus);
  }

  gis_page_set_complete (GIS_PAGE (page), TRUE);
  gtk_widget_show (GTK_WIDGET (page));
}
static void
language_changed (CcLanguageChooser  *chooser,
                  GParamSpec         *pspec,
                  GisLanguagePage    *page)
{
  GisLanguagePagePrivate *priv = gis_language_page_get_instance_private (page);
  ActUser *user;
  GisDriver *driver;

  if (priv->selection_done_source > 0)
    {
      g_source_remove (priv->selection_done_source);
      priv->selection_done_source = 0;
    }

  priv->new_locale_id = cc_language_chooser_get_language (chooser);
  driver = GIS_PAGE (page)->driver;

  setlocale (LC_MESSAGES, priv->new_locale_id);
  gis_driver_locale_changed (driver);

  if (gis_driver_get_mode (driver) == GIS_DRIVER_MODE_NEW_USER) {
      if (g_permission_get_allowed (priv->permission)) {
          set_localed_locale (page);
      }
      else if (g_permission_get_can_acquire (priv->permission)) {
          g_permission_acquire_async (priv->permission,
                                      NULL,
                                      change_locale_permission_acquired,
                                      page);
      }
  }
  user = act_user_manager_get_user (act_user_manager_get_default (),
                                    g_get_user_name ());
  if (act_user_is_loaded (user))
    act_user_set_language (user, priv->new_locale_id);
  else
    g_signal_connect (user,
                      "notify::is-loaded",
                      G_CALLBACK (user_loaded),
                      g_strdup (priv->new_locale_id));

  gis_driver_set_user_language (driver, priv->new_locale_id);

  priv->selection_done_source = g_timeout_add (500, _selection_done,
                                               (gpointer)driver);
}
static void
rebuild_pages_cb (GisDriver *driver)
{
  PageData *page_data;
  GisAssistant *assistant;
  GisPage *current_page;
  gchar **skip_pages;
  gboolean is_new_user;

  assistant = gis_driver_get_assistant (driver);
  current_page = gis_assistant_get_current_page (assistant);

  skip_pages = pages_to_skip_from_file ();

  page_data = page_table;

  if (current_page != NULL) {
    destroy_pages_after (assistant, current_page);

    for (page_data = page_table; page_data->page_id != NULL; ++page_data)
      if (g_str_equal (page_data->page_id, GIS_PAGE_GET_CLASS (current_page)->page_id))
        break;

    ++page_data;
  }

  is_new_user = (gis_driver_get_mode (driver) == GIS_DRIVER_MODE_NEW_USER);
  for (; page_data->page_id != NULL; ++page_data) {
    if (page_data->new_user_only && !is_new_user)
      continue;

    if (should_skip_page (driver, page_data->page_id, skip_pages))
      continue;

    page_data->prepare_page_func (driver);
  }

  g_strfreev (skip_pages);
}
static void
done_cb (GtkButton *button, GisSummaryPage *page)
{
  gchar *file;

  /* the tour is triggered by $XDG_CONFIG_HOME/run-welcome-tour */
  file = g_build_filename (g_get_user_config_dir (), "run-welcome-tour", NULL);
  g_file_set_contents (file, "yes", -1, NULL);
  g_free (file);

  switch (gis_driver_get_mode (GIS_PAGE (page)->driver))
    {
    case GIS_DRIVER_MODE_NEW_USER:
      gis_driver_hide_window (GIS_PAGE (page)->driver);
      log_user_in (page);
      break;
    case GIS_DRIVER_MODE_EXISTING_USER:
      add_setup_done_file ();
      g_application_quit (G_APPLICATION (GIS_PAGE (page)->driver));
    default:
      break;
    }
}
Пример #5
0
static void
gis_finished_page_shown (GisPage *page)
{
  GisFinishedPage *self = GIS_FINISHED_PAGE (page);
  GisFinishedPagePrivate *priv = gis_finished_page_get_instance_private (self);
  GError *error = gis_store_get_error();

  gis_driver_save_data (GIS_PAGE (page)->driver);

  if (error != NULL)
    {
      GisAssistant *assistant = gis_driver_get_assistant (page->driver);
      const gchar *heading = NULL;
      const gchar *detail = error->message;

      g_warning ("%s: %s %d %s", G_STRFUNC,
                 g_quark_to_string (error->domain), error->code, error->message);

      if (error->domain == GIS_UNATTENDED_ERROR)
        {
          heading = _("Oops, something is wrong with your unattended installation configuration.");
        }
      else if (error->domain == GIS_IMAGE_ERROR)
        {
          heading = _("Oops, something is wrong with your Endless OS file.");
        }
      else if (error->domain == GIS_DISK_ERROR)
        {
          heading = _("Oops, something went wrong while finding suitable disks to reformat.");
        }
      else if (error->domain == GIS_INSTALL_ERROR)
        {
          heading = _("Oops, something went wrong while reformatting.");
        }
      else if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
        {
          heading = error->message;
          detail = NULL;
          gtk_widget_hide (GTK_WIDGET (priv->error_label));
          gtk_widget_hide (GTK_WIDGET (priv->diagnostics_label));
          gtk_widget_hide (GTK_WIDGET (priv->support_label));
        }
      else
        {
          heading = _("Oops, something went wrong.");
        }

      if (heading != NULL)
        gtk_label_set_text (priv->error_heading_label, heading);

      if (detail != NULL)
        gtk_label_set_text (priv->error_label, detail);

      gtk_widget_show (priv->error_box);
      gtk_widget_hide (priv->success_box);
      gis_assistant_locale_changed (assistant);

      if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
        {
          /* Running eos-diagnostics can be slow enough that we can't do it
           * synchronously on the UI thread.
           */
          GFile *image_dir = G_FILE (gis_store_get_object (GIS_STORE_IMAGE_DIR));
          /* See implementation of gis_write_diagnostics_async for rationale. */
          const gchar *home_dir = priv->gedit != NULL ? g_get_home_dir () : NULL;

          g_application_hold (G_APPLICATION (page->driver));
          gis_write_diagnostics_async (NULL, image_dir, home_dir,
                                       NULL, write_diagnostics_cb,
                                       g_object_ref (self));
        }

      if (gis_store_is_unattended())
        {
          g_timeout_add_seconds (1, (GSourceFunc)toggle_leds, page);
        }

      /* If running within a live session, hide the "Turn off" button on error,
       * since we have a perfectly good [X] button on the titlebar and we want
       * to encourage the user to notice the link to the diagnostics file.
       */
      GisDriverMode mode = gis_driver_get_mode (GIS_PAGE (self)->driver);
      gtk_widget_set_visible (GTK_WIDGET (priv->restart_button),
                              mode == GIS_DRIVER_MODE_NEW_USER);
    }
  else
    {
      gboolean optical = is_eosdvd ();

      gtk_widget_set_visible (priv->removelabel_usb, !optical);
      gtk_widget_set_visible (priv->removelabel_dvd,  optical);
    }
}