summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPatrick McDermott <pj@pehjota.net>2017-11-04 15:37:00 (EDT)
committer Patrick McDermott <pj@pehjota.net>2017-11-04 15:37:00 (EDT)
commitdb3adb8098bc5fda5eb8719c6a6c6722174b642e (patch)
tree34f8933da2122ebfdf50c6158e326b8364b2f297 /src
parentc1694f37f26ab46f4bad394424f0394be11936cd (diff)
downloadmarquee-db3adb8098bc5fda5eb8719c6a6c6722174b642e.zip
marquee-db3adb8098bc5fda5eb8719c6a6c6722174b642e.tar.gz
marquee-db3adb8098bc5fda5eb8719c6a6c6722174b642e.tar.bz2
about:profiles: New page
Diffstat (limited to 'src')
-rw-r--r--src/schemes/about.c2
-rw-r--r--src/schemes/about/local.mk1
-rw-r--r--src/schemes/about/paths.h4
-rw-r--r--src/schemes/about/profiles.c97
4 files changed, 104 insertions, 0 deletions
diff --git a/src/schemes/about.c b/src/schemes/about.c
index 49104a7..87183f5 100644
--- a/src/schemes/about.c
+++ b/src/schemes/about.c
@@ -49,6 +49,8 @@ mq_about_request(WebKitURISchemeRequest *request, MqApplication *application)
if (g_strcmp0(path, "") == 0 || g_strcmp0(path, "version") == 0) {
mq_about_version_response(application, query, request);
+ } else if (g_strcmp0(path, "profiles") == 0) {
+ mq_about_profiles_response(application, query, request);
} else if (g_strcmp0(path, "preferences") == 0) {
mq_about_preferences_response(application, query, request);
} else if (g_strcmp0(path, "marquee") == 0) {
diff --git a/src/schemes/about/local.mk b/src/schemes/about/local.mk
index f2825f4..fe3eecf 100644
--- a/src/schemes/about/local.mk
+++ b/src/schemes/about/local.mk
@@ -1,4 +1,5 @@
marquee_SOURCES += \
%reldir%/version.c \
%reldir%/preferences.c \
+ %reldir%/profiles.c \
%reldir%/marquee.c
diff --git a/src/schemes/about/paths.h b/src/schemes/about/paths.h
index d7ca9b8..b0d413b 100644
--- a/src/schemes/about/paths.h
+++ b/src/schemes/about/paths.h
@@ -33,6 +33,10 @@ mq_about_version_response(MqApplication *application, GHashTable *query,
WebKitURISchemeRequest *request);
void
+mq_about_profiles_response(MqApplication *application, GHashTable *query,
+ WebKitURISchemeRequest *request);
+
+void
mq_about_preferences_response(MqApplication *application, GHashTable *query,
WebKitURISchemeRequest *request);
diff --git a/src/schemes/about/profiles.c b/src/schemes/about/profiles.c
new file mode 100644
index 0000000..e2522aa
--- /dev/null
+++ b/src/schemes/about/profiles.c
@@ -0,0 +1,97 @@
+/*
+ * about:profiles
+ *
+ * Copyright (C) 2017 Patrick McDermott
+ *
+ * This file is part of Marquee.
+ *
+ * Marquee is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Marquee is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Marquee. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glib.h>
+#include <webkit2/webkit2.h>
+
+#include "../../application.h"
+#include "../../config/profiles.h"
+#include "../../utils/html.h"
+#include "../../utils/profile-icon.h"
+#include "../about.h"
+#include "paths.h"
+
+static gchar *
+generate_div(MqProfiles *profiles, gchar *id)
+{
+ gchar *name;
+ gchar *editing_str;
+ gchar *name_str;
+ gchar *default_str;
+ gchar *delete_str;
+ gchar *save_str;
+ gchar *div;
+
+ /* Freed by mq_html_container(). */
+ name = mq_profiles_get_name(profiles, id);
+
+ editing_str = g_strdup_printf("editing_%s", id);
+ name_str = g_strdup_printf("name_%s", id);
+ default_str = g_strdup_printf("default_%s", id);
+ delete_str = g_strdup_printf("delete_%s", id);
+ save_str = g_strdup_printf("save_%s", id);
+
+ 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_container("span", NULL, name, NULL),
+ mq_html_input_text(name_str, NULL, name),
+ mq_html_submit(default_str, "Make Default", FALSE/*TODO*/),
+ mq_html_submit(delete_str, "Delete", FALSE),
+ mq_html_label(editing_str, "Edit", FALSE),
+ mq_html_submit(save_str, "Save", FALSE),
+ NULL);
+
+ g_free(editing_str);
+ g_free(name_str);
+ g_free(default_str);
+ g_free(delete_str);
+ g_free(save_str);
+
+ return div;
+}
+
+void
+mq_about_profiles_response(MqApplication *application,
+ GHashTable G_GNUC_UNUSED *query,
+ WebKitURISchemeRequest *request)
+{
+ MqProfiles *profiles;
+ gchar *document;
+ gchar **ids;
+ gsize length;
+ gchar **divs;
+ gsize i;
+
+ profiles = mq_application_get_profiles(application);
+
+ ids = mq_profiles_get_profiles(profiles, &length);
+ divs = g_new(gchar *, length);
+ for (i = 0; i < length; ++i) {
+ divs[i] = generate_div(profiles, ids[i]);
+ }
+ divs[i] = NULL;
+
+ document = mq_html_document("Profiles",
+ mq_html_form_v("Add Profile", NULL, divs),
+ NULL);
+ mq_about_response(request, document);
+}