Example #1
0
void
terminal_app_new_profile (TerminalApp *app,
                          GSettings   *base_profile,
                          GtkWindow   *transient_parent)
{
  gs_unref_object GSettings *profile = NULL;
  gs_free char *uuid;

  if (base_profile) {
    gs_free char *base_uuid;

    base_uuid = terminal_settings_list_dup_uuid_from_child (app->profiles_list, base_profile);
    uuid = terminal_settings_list_clone_child (app->profiles_list, base_uuid);
  } else {
    uuid = terminal_settings_list_add_child (app->profiles_list);
  }

  if (uuid == NULL)
    return;

  profile = terminal_settings_list_ref_child (app->profiles_list, uuid);
  if (profile == NULL)
    return;

  terminal_profile_edit (profile, NULL, "profile-name-entry");
}
/**
 * terminal_profiles_list_ref_profile_by_uuid_or_name:
 * @list:
 * @uuid:
 * @error:
 *
 * Returns: (transfer full): the profile #GSettings specified by @uuid, or %NULL
 */
GSettings *
terminal_profiles_list_ref_profile_by_uuid_or_name (TerminalSettingsList *list,
        const char *uuid_or_name,
        GError **error)
{
    gs_free char *uuid;
    GSettings *profile;

    uuid = terminal_profiles_list_dup_uuid_or_name (list, uuid_or_name, error);
    if (uuid == NULL)
        return NULL;

    profile = terminal_settings_list_ref_child (list, uuid);
    g_assert (profile != NULL);
    return profile;
}
static void
get_profile_names (TerminalSettingsList *list,
                   char ***profilesp,
                   char ***namesp)
{
    char **profiles, **names;
    guint i, n;

    *profilesp = profiles = terminal_settings_list_dupv_children (list);

    n = g_strv_length (profiles);
    *namesp = names = g_new0 (char *, n + 1);
    for (i = 0; i < n; i++) {
        gs_unref_object GSettings *profile;

        profile = terminal_settings_list_ref_child (list, profiles[i]);
        names[i] = g_settings_get_string (profile, TERMINAL_PROFILE_VISIBLE_NAME_KEY);
    }

    names[n] = NULL;
}