summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/schemes/about/profiles.c44
1 files changed, 41 insertions, 3 deletions
diff --git a/src/schemes/about/profiles.c b/src/schemes/about/profiles.c
index 8587a12..e38396a 100644
--- a/src/schemes/about/profiles.c
+++ b/src/schemes/about/profiles.c
@@ -19,6 +19,8 @@
* along with Marquee. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <string.h>
+
#include <glib.h>
#include <webkit2/webkit2.h>
@@ -91,13 +93,49 @@ generate_document(MqProfiles *profiles)
NULL);
}
+static void
+edit_profiles(MqProfiles *profiles, GHashTable *query)
+{
+ GList *keys;
+ GList *key;
+ gchar *id;
+ gchar *input_key;
+
+ keys = g_hash_table_get_keys(query);
+
+ for (key = keys; key; key = key->next) {
+ if (g_str_has_prefix(key->data, "save_")) {
+ id = (gchar *) key->data + strlen("save_");
+ input_key = g_strconcat("name_", id, NULL);
+ mq_profiles_set_name(profiles, id,
+ g_hash_table_lookup(query, input_key));
+ g_free(input_key);
+ } else if (g_str_has_prefix(key->data, "delete_")) {
+ id = (gchar *) key->data + strlen("delete_");
+ // mq_profiles_delete(profiles, id);
+ } else if (g_str_has_prefix(key->data, "default_")) {
+ id = (gchar *) key->data + strlen("default_");
+ mq_profiles_set_default(profiles, id);
+ }
+ }
+
+ g_list_free(keys);
+
+ mq_profiles_save(profiles);
+}
+
void
mq_about_profiles_response(MqApplication *application,
- GHashTable G_GNUC_UNUSED *query, WebKitURISchemeRequest *request)
+ GHashTable *query, WebKitURISchemeRequest *request)
{
- MqProfiles *profiles;
+ MqProfiles *profiles;
profiles = mq_application_get_profiles(application);
- mq_about_response(request, generate_document(profiles));
+ if (!query) {
+ mq_about_response(request, generate_document(profiles));
+ } else {
+ edit_profiles(profiles, query);
+ mq_about_redirect(request, "mq-about:profiles");
+ }
}