summaryrefslogtreecommitdiff
path: root/src/session.c
diff options
context:
space:
mode:
authorportix <portix@gmx.net>2012-01-08 19:03:21 +0100
committerportix <portix@gmx.net>2012-01-08 19:03:21 +0100
commit8c1e2754d4296726161b1dc19b17c127de976770 (patch)
tree683bf08d75900c296b31886bfd224942aa8c7247 /src/session.c
parentd7509713b43de28d3df9eeb29a97c22d28f50c49 (diff)
downloaddwb-8c1e2754d4296726161b1dc19b17c127de976770.zip
Setting lock/protect state when load has finished for the first time
Diffstat (limited to 'src/session.c')
-rw-r--r--src/session.c35
1 files changed, 29 insertions, 6 deletions
diff --git a/src/session.c b/src/session.c
index ae58aa9b..648cf85d 100644
--- a/src/session.c
+++ b/src/session.c
@@ -22,6 +22,11 @@
#include "view.h"
#include "session.h"
+typedef struct _SessionTab {
+ GList *gl;
+ unsigned int lock;
+} SessionTab;
+
/* session_get_groups() return char ** (alloc){{{*/
static char **
session_get_groups() {
@@ -55,9 +60,23 @@ session_get_group(const char *name) {
return content;
}/*}}}*/
+void
+session_load_status_callback(WebKitWebView *wv, GParamSpec *p, SessionTab *tab) {
+ WebKitLoadStatus status = webkit_web_view_get_load_status(wv);
+ switch (status) {
+ case WEBKIT_LOAD_FINISHED: VIEW(tab->gl)->status->lockprotect = tab->lock;
+ dwb_tab_label_set_text(tab->gl, NULL);
+ case WEBKIT_LOAD_FAILED: g_signal_handlers_disconnect_by_func(wv, (GFunc)session_load_status_callback, tab);
+ g_free(tab);
+ break;
+ default: return;
+ }
+}
+
+
/* session_load_webview(WebKitWebView *, char *, int *){{{*/
static void
-session_load_webview(GList *gl, char *uri, int last) {
+session_load_webview(GList *gl, char *uri, int last, int lock_status) {
if (last > 0) {
for (int j=0; j<last; j++) {
webkit_web_view_go_back(WEBVIEW(gl));
@@ -66,6 +85,12 @@ session_load_webview(GList *gl, char *uri, int last) {
else {
dwb_load_uri(gl, uri);
}
+ if (lock_status > 0) {
+ SessionTab *tab = dwb_malloc(sizeof(SessionTab));
+ tab->gl = gl;
+ tab->lock = lock_status;
+ g_signal_connect(WEBVIEW(gl), "notify::load-status", G_CALLBACK(session_load_status_callback), tab);
+ }
}/*}}}*/
/* session_list {{{*/
@@ -113,16 +138,14 @@ session_restore(const char *name) {
int current = strtol(line[0], &end, 10);
if (current == 0 && *end == '|') {
locked_state = strtol(end+1, NULL, 10);
- if (lastview != NULL)
- VIEW(currentview)->status->lockprotect = locked_state;
}
if (current <= last) {
currentview = view_add(NULL, false);
- locked_state = 0;
bf_list = webkit_web_view_get_back_forward_list(WEBVIEW(currentview));
if (lastview) {
- session_load_webview(lastview, uri, last);
+ session_load_webview(lastview, uri, last, locked_state);
+ locked_state = 0;
}
lastview = currentview;
}
@@ -135,7 +158,7 @@ session_restore(const char *name) {
uri = g_strdup(line[1]);
}
if (i == length && lastview)
- session_load_webview(lastview, uri, last);
+ session_load_webview(lastview, uri, last, locked_state);
g_strfreev(line);
}
g_strfreev(lines);