---
main.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
utilities.c | 7 ++---
2 files changed, 62 insertions(+), 5 deletions(-)
diff --git a/main.c b/main.c
index aecd7a8..63b9245 100644
--- a/main.c
+++ b/main.c
@@ -101,6 +101,7 @@ gboolean process_keypress(GdkEventKey *event);
void fill_suggline(char * suggline, const char * command, const char *fill_with);
GtkWidget * fill_eventbox(const char * completion_line);
static void mop_up(void);
+void apply_settings(char *uri);
#include "main.h"
@@ -143,7 +144,8 @@ char *error_msg = NULL;
char *config_base = NULL;
static gboolean manual_focus = FALSE;
-GList *activeDownloads;
+GList *activeDownloads, *siteSettings = NULL;
+char backupsettings[MAX_SETTING_SIZE] = "";
#include "config.h"
#include "keymap.h"
@@ -1240,6 +1242,7 @@ open_arg(const Arg *arg) {
memcpy(&new[sizeof("http://") - 1], s, len + 1);
}
}
+ apply_settings(new);
webkit_web_view_load_uri(webview, new);
g_free(new);
} else
@@ -2557,6 +2560,61 @@ load_all_cookies(void)
#endif
void
+apply_settings(char *uri) {
+ SSettings *s;
+ GList *l;
+ char temp[MAX_SETTING_SIZE], *temp2, temp3[MAX_SETTING_SIZE];
+ guint i, j, len, len2, len3;
+
+ /* check for site-specific settings */
+ if (siteSettings != NULL) {
+ len = g_list_length(siteSettings);
+ for (i = 0; i < len; i++) {
+ l = g_list_nth(siteSettings, i);
+ s = (SSettings *)l->data;
+ if (strlen(uri) >= strlen(s->url) && strncmp(s->url, uri, strlen(s->url)) == 0) {
+ /* match found */
+ memset(temp, 0, MAX_SETTING_SIZE);
+ strncpy(temp, s->settings, MAX_SETTING_SIZE);
+ temp2 = strtok(temp, "|");
+ while (temp2 != NULL) {
+ /* remember current standard settings */
+ memset(temp3, 0, MAX_SETTING_SIZE);
+ len2 = strcspn(temp2, "=");
+ len3 = LENGTH(browsersettings);
+ for (j = 0; j < len3; j++) {
+ if (strlen(browsersettings[j].name) == len2 && strncmp(browsersettings[j].name, temp2, len2) == 0) {
+ strncat(backupsettings, "|", 1);
+ strncat(backupsettings, temp2, len2 + 1);
+ strncat(backupsettings, browsersettings[j].var, strlen(browsersettings[j].var));
+ }
+ }
+ /* apply the setting */
+ process_set_line(temp2);
+ temp2 = strtok(NULL, "|");
+ }
+ return;
+ }
+ }
+ if (strlen(backupsettings) > 0) {
+ /* revert to standard settings
+ * the string has to be applied from right to left
+ * this ensures that if various values have been set for the same key in the meantime,
+ * we will still get back to the most basic state
+ */
+ temp2 = strrchr(backupsettings, '|');
+ while (temp2 != NULL) {
+ process_set_line(temp2 + 1);
+ memset(temp2, 0, strlen(temp2));
+ temp2 = strrchr(backupsettings, '|');
+ }
+ /* erase remembered settings */
+ memset(backupsettings, 0, MAX_SETTING_SIZE);
+ }
+ }
+}
+
+void
mop_up(void) {
/* Free up any nasty globals before exiting. */
#ifdef ENABLE_COOKIE_SUPPORT
diff --git a/utilities.c b/utilities.c
index 856eb36..4a7e1df 100644
--- a/utilities.c
+++ b/utilities.c
@@ -12,7 +12,7 @@
#include "main.h"
#include "utilities.h"
-extern GList *commandhistory;
+extern GList *commandhistory, *siteSettings;
extern int commandpointer;
extern Command commands[COMMANDSIZE];
extern KeyList *keylistroot;
@@ -20,7 +20,7 @@ extern Key keys[];
extern char *error_msg;
extern char *config_base;
extern VSettings cursettings;
-static GList *dynamic_searchengines = NULL, *dynamic_uri_handlers = NULL, *site_settings = NULL;
+static GList *dynamic_searchengines = NULL, *dynamic_uri_handlers = NULL;
void add_modkeys(char key);
@@ -757,7 +757,7 @@ read_rcfile(const char *config)
}
newsettings->url = g_strdup(buffer);
newsettings->settings = g_strdup(buffer+index);
- site_settings = g_list_prepend(site_settings, newsettings);
+ siteSettings = g_list_prepend(siteSettings, newsettings);
} else if (strncmp(s, "searchengine", 12) == 0) {
buffer = (s + 12);
while (buffer[0] == ' ')
@@ -862,4 +862,3 @@ open_handler(char *uri) {
}
return FALSE;
}
-
--
1.7.2.5
|