summaryrefslogtreecommitdiffstats
path: root/src/schemes
diff options
context:
space:
mode:
authorPatrick McDermott <pj@pehjota.net>2017-11-04 21:47:14 (EDT)
committer Patrick McDermott <pj@pehjota.net>2017-11-04 21:47:14 (EDT)
commit97cd9aef4004cc4f20f9f018566a148d40f35a2d (patch)
treee0d4233d616745fca81723292c30cce5220db5dd /src/schemes
parent7f7c1b872f1181ec0deba520aedd435edaa6e2a8 (diff)
downloadmarquee-97cd9aef4004cc4f20f9f018566a148d40f35a2d.zip
marquee-97cd9aef4004cc4f20f9f018566a148d40f35a2d.tar.gz
marquee-97cd9aef4004cc4f20f9f018566a148d40f35a2d.tar.bz2
about:profiles: Show new profile on add button click
Diffstat (limited to 'src/schemes')
-rw-r--r--src/schemes/about/profiles.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/src/schemes/about/profiles.c b/src/schemes/about/profiles.c
index c1e3d09..c2b7a96 100644
--- a/src/schemes/about/profiles.c
+++ b/src/schemes/about/profiles.c
@@ -35,6 +35,7 @@ static gchar *
generate_div(MqProfiles *profiles, gchar *id)
{
gchar *name;
+ gchar *color;
gchar *editing_str;
gchar *name_str;
gchar *default_str;
@@ -43,7 +44,13 @@ generate_div(MqProfiles *profiles, gchar *id)
gchar *div;
/* Freed by mq_html_container(). */
- name = mq_profiles_get_name(profiles, id);
+ if (id) {
+ name = mq_profiles_get_name(profiles, id);
+ color = mq_profiles_get_color(profiles, id);
+ } else {
+ name = g_strdup("New Profile");
+ color = g_strdup("#00ff00");
+ }
editing_str = g_strconcat("editing_", id, NULL);
name_str = g_strconcat("name_", id, NULL);
@@ -52,12 +59,13 @@ generate_div(MqProfiles *profiles, gchar *id)
save_str = g_strconcat("save_", id, NULL);
div = mq_html_container("div", "profile",
- mq_html_input_radio("editing", editing_str, id, NULL, FALSE),
- mq_profile_icon_new(mq_profiles_get_color(profiles, id)),
+ mq_html_input_radio("editing", editing_str, id, NULL,
+ id == NULL),
+ mq_profile_icon_new(color),
mq_html_container("span", NULL, name, NULL),
mq_html_input_text(name_str, NULL, name),
mq_html_submit(default_str, "Make Default",
- mq_profiles_is_default(profiles, id)),
+ id && mq_profiles_is_default(profiles, id)),
mq_html_submit(delete_str, "Delete", FALSE),
mq_html_label(editing_str, "Edit", FALSE),
mq_html_submit(save_str, "Save", FALSE),
@@ -73,7 +81,7 @@ generate_div(MqProfiles *profiles, gchar *id)
}
static gchar *
-generate_document(MqProfiles *profiles)
+generate_document(MqProfiles *profiles, gboolean adding)
{
gchar **ids;
gsize length;
@@ -81,10 +89,13 @@ generate_document(MqProfiles *profiles)
gsize i;
ids = mq_profiles_get_profiles(profiles, &length);
- divs = g_new(gchar *, length);
+ divs = g_new(gchar *, length + (adding ? 1 : 0));
for (i = 0; i < length; ++i) {
divs[i] = generate_div(profiles, ids[i]);
}
+ if (adding) {
+ divs[i++] = generate_div(profiles, NULL);
+ }
divs[i] = NULL;
g_strfreev(ids);
@@ -133,7 +144,9 @@ mq_about_profiles_response(MqApplication *application,
profiles = mq_application_get_profiles(application);
if (!query) {
- mq_about_response(request, generate_document(profiles));
+ mq_about_response(request, generate_document(profiles, FALSE));
+ } else if (g_hash_table_lookup(query, "add")) {
+ mq_about_response(request, generate_document(profiles, TRUE));
} else {
edit_profiles(profiles, query);
mq_about_redirect(request, "mq-about:profiles");