static void
sync_accounts (GisGoaPage *page)
{
  GisGoaPagePrivate *priv = gis_goa_page_get_instance_private (page);
  GList *accounts, *l;

  accounts = goa_client_get_accounts (priv->goa_client);

  for (l = accounts; l != NULL; l = l->next) {
    GoaObject *object = GOA_OBJECT (l->data);
    GoaAccount *account = goa_object_get_account (object);
    const char *account_type = goa_account_get_provider_type (account);
    ProviderWidget *provider_widget;

    provider_widget = g_hash_table_lookup (priv->providers, account_type);
    if (!provider_widget)
      continue;

    priv->accounts_exist = TRUE;

    if (provider_widget->displayed_account)
      continue;

    provider_widget->displayed_account = account;
    sync_provider_widget (provider_widget);
  }

  g_list_free_full (accounts, (GDestroyNotify) g_object_unref);

  sync_visibility (page);
  gis_page_set_skippable (GIS_PAGE (page), !priv->accounts_exist);
  gis_page_set_complete (GIS_PAGE (page), priv->accounts_exist);
}
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));
}
Exemple #3
0
static void
enterprise_apply_complete (GisPage  *dummy,
                           gboolean  valid,
                           gpointer  user_data)
{
  GisAccountPage *page = GIS_ACCOUNT_PAGE (user_data);
  gis_driver_set_username (GIS_PAGE (page)->driver, NULL);
  gis_page_apply_complete (GIS_PAGE (page), valid);
}
Exemple #4
0
static void
gis_password_page_dispose (GObject *object)
{
  if (GIS_PAGE (object)->driver)
  g_signal_handlers_disconnect_by_func (GIS_PAGE (object)->driver,
                                        username_changed, object);

  G_OBJECT_CLASS (gis_password_page_parent_class)->dispose (object);
}
static void
gis_summary_page_shown (GisPage *page)
{
  GisSummaryPage *summary = GIS_SUMMARY_PAGE (page);
  GisSummaryPagePrivate *priv = gis_summary_page_get_instance_private (summary);

  gis_driver_save_data (GIS_PAGE (page)->driver);

  gis_driver_get_user_permissions (GIS_PAGE (page)->driver,
                                   &priv->user_account,
                                   &priv->user_password);

  gtk_widget_grab_focus (priv->start_button);
}
Exemple #6
0
static void
on_local_user_cached (GtkWidget      *page_local,
                      ActUser        *user,
                      char           *password,
                      GisAccountPage *page)
{
  const gchar *language;

  language = gis_driver_get_user_language (GIS_PAGE (page)->driver);
  if (language)
    act_user_set_language (user, language);

  gis_driver_set_user_permissions (GIS_PAGE (page)->driver, user, password);
}
static void
sync_visibility (GisGoaPage *page)
{
  GisGoaPagePrivate *priv = gis_goa_page_get_instance_private (page);
  GisAssistant *assistant = gis_driver_get_assistant (GIS_PAGE (page)->driver);
  GNetworkMonitor *network_monitor = g_network_monitor_get_default ();
  gboolean visible;

  if (gis_assistant_get_current_page (assistant) == GIS_PAGE (page))
    return;

  visible = (priv->accounts_exist || g_network_monitor_get_network_available (network_monitor));
  gtk_widget_set_visible (GTK_WIDGET (page), visible);
}
static void
gis_finished_page_constructed (GObject *object)
{
  GisFinishedPage *page = GIS_FINISHED_PAGE (object);
  GisFinishedPagePrivate *priv = gis_finished_page_get_instance_private (page);
  g_autoptr(GClosure) closure = NULL;

  G_OBJECT_CLASS (gis_finished_page_parent_class)->constructed (object);

  gis_page_set_complete (GIS_PAGE (page), TRUE);

  g_signal_connect (priv->restart_button, "clicked", G_CALLBACK (reboot_cb), page);

  priv->gedit = g_desktop_app_info_new ("org.gnome.gedit.desktop");
  if (priv->gedit != NULL)
    g_signal_connect (priv->diagnostics_label, "activate-link",
                      G_CALLBACK (diagnostics_label_activate_link_cb), page);

  /* Use Ctrl+U to write unattended config */
  priv->accel_group = gtk_accel_group_new ();
  closure = g_cclosure_new_swap (G_CALLBACK (write_unattended_config_cb), page, NULL);
  gtk_accel_group_connect (priv->accel_group, GDK_KEY_u, GDK_CONTROL_MASK, 0, closure);

  gtk_widget_show (GTK_WIDGET (page));
}
Exemple #9
0
static void
set_mode (GisAccountPage *page,
          UmAccountMode   mode)
{
  GisAccountPagePrivate *priv = gis_account_page_get_instance_private (page);

  if (priv->mode == mode)
    return;

  priv->mode = mode;
  gis_driver_set_account_mode (GIS_PAGE (page)->driver, mode);

  switch (mode)
    {
    case UM_LOCAL:
      gtk_stack_set_visible_child (GTK_STACK (priv->stack), priv->page_local);
      gis_account_page_local_shown (GIS_ACCOUNT_PAGE_LOCAL (priv->page_local));
      break;
    case UM_ENTERPRISE:
      gtk_stack_set_visible_child (GTK_STACK (priv->stack), priv->page_enterprise);
      gis_account_page_enterprise_shown (GIS_ACCOUNT_PAGE_ENTERPRISE (priv->page_enterprise));
      break;
    default:
      g_assert_not_reached ();
    }

  update_page_validation (page);
}
Exemple #10
0
static void
gis_password_page_constructed (GObject *object)
{
  GisPasswordPage *page = GIS_PASSWORD_PAGE (object);
  GisPasswordPagePrivate *priv = gis_password_page_get_instance_private (page);

  G_OBJECT_CLASS (gis_password_page_parent_class)->constructed (object);

  g_signal_connect (priv->password_entry, "notify::text",
                    G_CALLBACK (password_changed), page);
  g_signal_connect_swapped (priv->password_entry, "focus-out-event",
                            G_CALLBACK (on_focusout), page);
  g_signal_connect_swapped (priv->password_entry, "activate",
                            G_CALLBACK (confirm), page);

  g_signal_connect (priv->confirm_entry, "notify::text",
                    G_CALLBACK (confirm_changed), page);
  g_signal_connect_swapped (priv->confirm_entry, "focus-out-event",
                            G_CALLBACK (on_focusout), page);
  g_signal_connect_swapped (priv->confirm_entry, "activate",
                            G_CALLBACK (confirm), page);

  g_signal_connect (GIS_PAGE (page)->driver, "notify::username",
                    G_CALLBACK (username_changed), page);

  validate (page);

  gtk_widget_show (GTK_WIDGET (page));
}
static void
on_reformatter_exited (GTask  *task,
                       GError *error)
{
  GisPage *page = GIS_PAGE (g_task_get_source_object (task));

  gis_driver_show_window (page->driver);

  if (error == NULL)
    {
      g_task_return_boolean (task, TRUE);
      return;
    }

  GtkWindow *toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (page)));
  GtkWidget *message_dialog;

  g_critical ("Error running the reformatter: %s", error->message);

  message_dialog = gtk_message_dialog_new (toplevel,
                                           GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
                                           GTK_MESSAGE_ERROR,
                                           GTK_BUTTONS_CLOSE,
                                           /* Translators: this is shown when launching the
                                            * reformatter (an external program) fails. The
                                            * placeholder is an error message describing what went
                                            * wrong.
                                            */
                                           _("Error running the reformatter: %s"), error->message);
  g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, run_dialog_cb,
                   message_dialog, (GDestroyNotify) gtk_widget_destroy);

  g_task_return_error (task, g_steal_pointer (&error));
}
Exemple #12
0
static void
gis_page_get_property (GObject    *object,
                       guint       prop_id,
                       GValue     *value,
                       GParamSpec *pspec)
{
  GisPage *page = GIS_PAGE (object);
  GisPagePrivate *priv = gis_page_get_instance_private (page);
  switch (prop_id)
    {
    case PROP_DRIVER:
      g_value_set_object (value, page->driver);
      break;
    case PROP_TITLE:
      g_value_set_string (value, priv->title);
      break;
    case PROP_FORWARD_TEXT:
      g_value_set_string (value, priv->forward_text);
      break;
    case PROP_COMPLETE:
      g_value_set_boolean (value, priv->complete);
      break;
    case PROP_APPLYING:
      g_value_set_boolean (value, gis_page_get_applying (page));
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    }
}
static void
gis_page_set_property (GObject      *object,
                       guint         prop_id,
                       const GValue *value,
                       GParamSpec   *pspec)
{
  GisPage *page = GIS_PAGE (object);
  GisPagePrivate *priv = gis_page_get_instance_private (page);
  switch (prop_id)
    {
    case PROP_DRIVER:
      page->driver = g_value_dup_object (value);
      break;
    case PROP_TITLE:
      gis_page_set_title (page, (char *) g_value_get_string (value));
      break;
    case PROP_SKIPPABLE:
      priv->skippable = g_value_get_boolean (value);
      break;
    case PROP_NEEDS_ACCEPT:
      priv->needs_accept = g_value_get_boolean (value);
      break;
    case PROP_COMPLETE:
      priv->complete = g_value_get_boolean (value);
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    }
}
static void
gis_privacy_page_constructed (GObject *object)
{
  GisPrivacyPage *page = GIS_PRIVACY_PAGE (object);
  GisPrivacyPagePrivate *priv = gis_privacy_page_get_instance_private (page);

  G_OBJECT_CLASS (gis_privacy_page_parent_class)->constructed (object);

  gis_page_set_complete (GIS_PAGE (page), TRUE);

  priv->location_settings = g_settings_new ("org.gnome.system.location");
  priv->privacy_settings = g_settings_new ("org.gnome.desktop.privacy");

  gtk_switch_set_active (GTK_SWITCH (priv->location_switch), TRUE);
  gtk_switch_set_active (GTK_SWITCH (priv->reporting_switch), TRUE);

  update_os_data (page);

  priv->abrt_watch_id = g_bus_watch_name (G_BUS_TYPE_SYSTEM,
                                          "org.freedesktop.problems.daemon",
                                          G_BUS_NAME_WATCHER_FLAGS_NONE,
                                          abrt_appeared_cb,
                                          abrt_vanished_cb,
                                          page,
                                          NULL);
}
void
gis_page_util_show_demo_dialog (GisPage *page)
{
  GisDriver *driver = GIS_PAGE (page)->driver;
  g_autoptr(GtkBuilder) builder = NULL;
  GtkDialog *demo_dialog;

  if (!gis_driver_get_supports_demo_mode (driver))
    return;

  builder = get_modals_builder ();
  if (builder == NULL) {
    g_warning ("Can't get private builder object for demo mode!");
    return;
  }

  demo_dialog = (GtkDialog *)gtk_builder_get_object (builder, "demo-dialog");

  g_signal_connect_object (demo_dialog,
                           "response",
                           G_CALLBACK (response_cb),
                           driver,
                           G_CONNECT_AFTER);

  gtk_window_set_transient_for (GTK_WINDOW (demo_dialog),
                                GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (page))));
  gtk_window_set_modal (GTK_WINDOW (demo_dialog), TRUE);
  gtk_window_present (GTK_WINDOW (demo_dialog));
}
Exemple #16
0
static void
sync_complete (GisNetworkPage *page)
{
  GisNetworkPagePrivate *priv = gis_network_page_get_instance_private (page);
  gboolean activated;

  activated = (nm_device_get_state (priv->nm_device) == NM_DEVICE_STATE_ACTIVATED);
  gis_page_set_complete (GIS_PAGE (page), activated);
}
static GisPage *
find_prev_page (GisPage *page)
{
  GList *l = page->assistant_priv->link->prev;
  while (!should_show_page (l)) {
    l = l->prev;
  }
  return GIS_PAGE (l->data);
}
static void
gis_page_constructed (GObject *object)
{
  GisPage *page = GIS_PAGE (object);

  gis_page_locale_changed (page);

  G_OBJECT_CLASS (gis_page_parent_class)->constructed (object);

}
static void
gis_page_dispose (GObject *object)
{
  GisPage *page = GIS_PAGE (object);
  GisPagePrivate *priv = gis_page_get_instance_private (page);

  if (priv->apply_cancel)
    g_cancellable_cancel (priv->apply_cancel);

  g_clear_object (&page->driver);

  G_OBJECT_CLASS (gis_page_parent_class)->dispose (object);
}
static void
gis_page_finalize (GObject *object)
{
  GisPage *page = GIS_PAGE (object);
  GisPagePrivate *priv = gis_page_get_instance_private (page);

  g_free (priv->title);
  g_assert (!priv->applying);
  g_assert (priv->apply_cb == NULL);
  g_assert (priv->apply_cancel == NULL);

  G_OBJECT_CLASS (gis_page_parent_class)->finalize (object);
}
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;
    }
}
static void
widget_destroyed (GtkWidget    *widget,
                  GisAssistant *assistant)
{
  GisPage *page = GIS_PAGE (widget);
  GisAssistantPrivate *priv = assistant->priv;

  priv->pages = g_list_delete_link (priv->pages, page->assistant_priv->link);
  if (page == priv->current_page)
    priv->current_page = NULL;

  g_slice_free (GisAssistantPagePrivate, page->assistant_priv);
  page->assistant_priv = NULL;
}
static void
gis_summary_page_constructed (GObject *object)
{
  GisSummaryPage *page = GIS_SUMMARY_PAGE (object);
  GisSummaryPagePrivate *priv = gis_summary_page_get_instance_private (page);

  G_OBJECT_CLASS (gis_summary_page_parent_class)->constructed (object);

  update_distro_name (page);
  g_signal_connect (priv->start_button, "clicked", G_CALLBACK (done_cb), page);

  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
write_diagnostics_cb (GObject      *source,
                      GAsyncResult *result,
                      gpointer      user_data)
{
  g_autoptr(GisFinishedPage) self = GIS_FINISHED_PAGE (user_data);
  GisFinishedPagePrivate *priv = gis_finished_page_get_instance_private (self);
  g_autoptr(GError) error = NULL;
  g_autoptr(GFile) output = gis_write_diagnostics_finish (result, &error);

  g_application_release (G_APPLICATION (GIS_PAGE (self)->driver));

  if (output != NULL)
    {
      g_autofree gchar *basename_ = g_file_get_basename (output);
      g_autofree gchar *link = NULL;
      g_autofree gchar *markup = NULL;

      if (priv->gedit != NULL)
        {
          g_assert (error == NULL);
          g_autofree gchar *url = g_file_get_uri (output);

          link = g_markup_printf_escaped ("<a href=\"%s\">%s</a>",
                                          url, basename_);
        }
      else
        {
          link = g_strdup (basename_);
        }

      markup = g_strdup_printf (_("A debug log has been saved as %s."), link);
      gtk_label_set_markup (priv->diagnostics_label, markup);
    }
  else if (error != NULL)
    {
      g_prefix_error (&error, _("Failed to save debug log: "));
      gtk_label_set_text (priv->diagnostics_label, error->message);
      g_warning ("%s: %s", G_STRFUNC, error->message);
    }
  /* else, both possible target directories were NULL */
}
static void
gis_goa_page_constructed (GObject *object)
{
  GisGoaPage *page = GIS_GOA_PAGE (object);
  GisGoaPagePrivate *priv = gis_goa_page_get_instance_private (page);
  GError *error = NULL;
  GNetworkMonitor *network_monitor = g_network_monitor_get_default ();

  G_OBJECT_CLASS (gis_goa_page_parent_class)->constructed (object);

  gis_page_set_skippable (GIS_PAGE (page), TRUE);

  priv->providers = g_hash_table_new (g_str_hash, g_str_equal);

  priv->goa_client = goa_client_new_sync (NULL, &error);

  if (priv->goa_client == NULL) {
    g_warning ("Failed to get a GoaClient: %s", error->message);
    g_error_free (error);
    return;
  }

  g_signal_connect (priv->goa_client, "account-added",
                    G_CALLBACK (accounts_changed), page);
  g_signal_connect (priv->goa_client, "account-removed",
                    G_CALLBACK (accounts_changed), page);
  g_signal_connect (network_monitor, "network-changed",
                    G_CALLBACK (network_status_changed), page);

  gtk_list_box_set_header_func (GTK_LIST_BOX (priv->accounts_list),
                                update_header_func,
                                NULL, NULL);
  g_signal_connect (priv->accounts_list, "row-activated",
                    G_CALLBACK (row_activated), page);

  populate_provider_list (page);
  sync_accounts (page);
}
static void
gis_page_get_property (GObject    *object,
                       guint       prop_id,
                       GValue     *value,
                       GParamSpec *pspec)
{
  GisPage *page = GIS_PAGE (object);
  GisPagePrivate *priv = gis_page_get_instance_private (page);
  switch (prop_id)
    {
    case PROP_DRIVER:
      g_value_set_object (value, page->driver);
      break;
    case PROP_TITLE:
      g_value_set_string (value, priv->title);
      break;
    case PROP_COMPLETE:
      g_value_set_boolean (value, priv->complete);
      break;
    case PROP_SKIPPABLE:
      g_value_set_boolean (value, priv->skippable);
      break;
    case PROP_NEEDS_ACCEPT:
      g_value_set_boolean (value, priv->needs_accept);
      break;
    case PROP_APPLYING:
      g_value_set_boolean (value, gis_page_get_applying (page));
      break;
    case PROP_SMALL_SCREEN:
      g_value_set_boolean (value, gis_driver_is_small_screen (page->driver));
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    }
}
Exemple #28
0
static void
update_page_validation (GisAccountPage *page)
{
  gis_page_set_complete (GIS_PAGE (page), page_validate (page));
}
Exemple #29
0
static void
gis_account_page_locale_changed (GisPage *page)
{
  gis_page_set_title (GIS_PAGE (page), _("About You"));
}
Exemple #30
0
static void
on_local_page_confirmed (GisAccountPageLocal *local,
                         GisAccountPage      *page)
{
  gis_assistant_next_page (gis_driver_get_assistant (GIS_PAGE (page)->driver));
}