summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPatrick McDermott <pj@pehjota.net>2017-11-04 18:11:25 (EDT)
committer Patrick McDermott <pj@pehjota.net>2017-11-04 18:11:25 (EDT)
commit6155ac75f17c067215bfff61ef2020d06e2060cd (patch)
tree3933a1e008c9597b4e5da27d24952f31317327bb /src
parent80bded4f242373bb9b3ee39a84aaa3763d7b75f5 (diff)
downloadmarquee-6155ac75f17c067215bfff61ef2020d06e2060cd.zip
marquee-6155ac75f17c067215bfff61ef2020d06e2060cd.tar.gz
marquee-6155ac75f17c067215bfff61ef2020d06e2060cd.tar.bz2
about:profiles: Implement editing
Diffstat (limited to 'src')
-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");
+ }
}