[gnome-terminal] client: Add "complete profiles" command
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-terminal] client: Add "complete profiles" command
- Date: Tue, 22 Jan 2013 23:23:30 +0000 (UTC)
commit 9fd7d15ce348cb42aca3fbef2532d582f00e8ab1
Author: Christian Persch <chpe gnome org>
Date: Wed Jan 23 00:20:01 2013 +0100
client: Add "complete profiles" command
This will be used by completion to get the list of profiles.
src/client.c | 35 +++++++++++++++++++++++++++++++----
src/terminal-profile-utils.c | 13 +++++++++----
src/terminal-profile-utils.h | 2 ++
3 files changed, 42 insertions(+), 8 deletions(-)
---
diff --git a/src/client.c b/src/client.c
index 2a709f6..3509c3e 100644
--- a/src/client.c
+++ b/src/client.c
@@ -729,10 +729,36 @@ handle_open (int *argc,
return TRUE;
}
-static void
-complete (int *argc,
- char ***argv)
+static gboolean
+complete (int *argcp,
+ char ***argvp)
{
+ char *thing;
+
+ modify_argv0_for_command (argcp, argvp, "complete");
+
+ if (*argcp != 2)
+ {
+ _printerr ("Usage: %s THING\n", (*argvp)[0]);
+ return FALSE;
+ }
+
+ thing = (*argvp)[1];
+ if (g_str_equal (thing, "profiles"))
+ {
+ char **profiles, **p;
+
+ profiles = terminal_profile_util_list_profiles ();
+ if (profiles == NULL)
+ return FALSE;
+
+ for (p = profiles; *p; p++)
+ g_print ("%s\n", *p);
+ g_strfreev (profiles);
+ return TRUE;
+ }
+
+ return FALSE;
}
static int
@@ -790,7 +816,8 @@ main (gint argc, gchar *argv[])
}
else if (g_strcmp0 (command, "complete") == 0)
{
- complete (&argc, &argv);
+ if (complete (&argc, &argv))
+ ret = EXIT_SUCCESS;
}
else
{
diff --git a/src/terminal-profile-utils.c b/src/terminal-profile-utils.c
index 24fdff1..eba5554 100644
--- a/src/terminal-profile-utils.c
+++ b/src/terminal-profile-utils.c
@@ -85,8 +85,13 @@ terminal_profile_util_get_profiles (GSettings *settings)
map_profiles_list, NULL);
}
-static char **
-get_profiles (void)
+/**
+ * terminal_profile_util_list_profiles:
+ *
+ * Returns: (transfer full): the list of profile UUIDs, or %NULL
+ */
+char **
+terminal_profile_util_list_profiles (void)
{
GSettings *settings;
char **profiles;
@@ -152,7 +157,7 @@ terminal_profile_util_get_profile_by_uuid (const char *uuid,
char **profiles;
guint n;
- profiles = get_profiles ();
+ profiles = terminal_profile_util_list_profiles ();
n = strv_contains (profiles, uuid);
g_strfreev (profiles);
@@ -178,7 +183,7 @@ terminal_profile_util_get_profile_by_uuid_or_name (const char *uuid_or_name,
char **profiles, **profile_names;
guint n;
- profiles = get_profiles ();
+ profiles = terminal_profile_util_list_profiles ();
n = strv_contains (profiles, uuid_or_name);
if (n != 0) {
diff --git a/src/terminal-profile-utils.h b/src/terminal-profile-utils.h
index c71e059..13a0f8d 100644
--- a/src/terminal-profile-utils.h
+++ b/src/terminal-profile-utils.h
@@ -23,6 +23,8 @@
G_BEGIN_DECLS
+char **terminal_profile_util_list_profiles (void);
+
char **terminal_profile_util_get_profiles (GSettings *settings);
char *terminal_profile_util_get_profile_by_uuid (const char *uuid,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]