From 80bded4f242373bb9b3ee39a84aaa3763d7b75f5 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Sat, 04 Nov 2017 17:40:14 -0400 Subject: about:profiles: Factor out document generation into new function --- (limited to 'src/schemes/about/profiles.c') diff --git a/src/schemes/about/profiles.c b/src/schemes/about/profiles.c index a4b6eb2..8587a12 100644 --- a/src/schemes/about/profiles.c +++ b/src/schemes/about/profiles.c @@ -70,19 +70,13 @@ generate_div(MqProfiles *profiles, gchar *id) return div; } -void -mq_about_profiles_response(MqApplication *application, - GHashTable G_GNUC_UNUSED *query, - WebKitURISchemeRequest *request) +static gchar * +generate_document(MqProfiles *profiles) { - MqProfiles *profiles; - gchar *document; - gchar **ids; - gsize length; - gchar **divs; - gsize i; - - profiles = mq_application_get_profiles(application); + gchar **ids; + gsize length; + gchar **divs; + gsize i; ids = mq_profiles_get_profiles(profiles, &length); divs = g_new(gchar *, length); @@ -92,8 +86,18 @@ mq_about_profiles_response(MqApplication *application, divs[i] = NULL; g_strfreev(ids); - document = mq_html_document("Profiles", + return mq_html_document("Profiles", mq_html_form_v("Add Profile", NULL, divs), NULL); - mq_about_response(request, document); +} + +void +mq_about_profiles_response(MqApplication *application, + GHashTable G_GNUC_UNUSED *query, WebKitURISchemeRequest *request) +{ + MqProfiles *profiles; + + profiles = mq_application_get_profiles(application); + + mq_about_response(request, generate_document(profiles)); } -- cgit v0.9.1