Hiroyuki Ikezoe
ikezo****@users*****
Fri Jan 5 19:51:46 JST 2007
Index: kazehakase/src/kz-app.c diff -u kazehakase/src/kz-app.c:1.18 kazehakase/src/kz-app.c:1.19 --- kazehakase/src/kz-app.c:1.18 Fri Jan 5 09:18:54 2007 +++ kazehakase/src/kz-app.c Fri Jan 5 19:51:46 2007 @@ -309,6 +309,8 @@ clean_history_cache(); kz_root_bookmark_save_all(priv->bookmarks); + /* freeze session for storing last saving session */ + kz_session_freeze(KZ_SESSION(priv->bookmarks->current_session)); g_object_unref(G_OBJECT(priv->bookmarks)); kz_profile_close(priv->profile); @@ -373,46 +375,32 @@ { GList *list; const GList *node, *window_node; - gchar *session_file; + const gchar *location; KzAppPrivate *priv; - KzBookmarkFile *tmp_bookmark; + KzBookmark *session; g_return_val_if_fail(KZ_IS_APP(app), NULL); priv = KZ_APP_GET_PRIVATE(app); - /* reload from current session file */ - session_file = g_build_filename(g_get_home_dir(), - "."PACKAGE, - "current_session.xml", - NULL); - if (!g_file_test(session_file, G_FILE_TEST_EXISTS)) - { - g_free(session_file); - return NULL; - } - /* close all tabs before loading session file */ for (node = priv->window_list; node; node = g_list_next(node)) kz_window_close_all_tab(KZ_WINDOW(node->data)); - kz_session_freeze(KZ_SESSION(priv->bookmarks->current_session)); - tmp_bookmark = kz_bookmark_file_new(session_file, "Temporary session bookmark", - "XBEL"); - kz_bookmark_file_load(tmp_bookmark); - g_free(session_file); + session = priv->bookmarks->current_session; + location = kz_bookmark_file_get_location(KZ_BOOKMARK_FILE(session)); + if (g_file_test(location, G_FILE_TEST_EXISTS)) + kz_bookmark_file_load(KZ_BOOKMARK_FILE(session)); - list = kz_bookmark_get_children(KZ_BOOKMARK(tmp_bookmark)); + list = kz_bookmark_get_children(session); window_node = priv->window_list; /* windows */ for (node = list; node; node = g_list_next(node)) { - GList *tabs, *tabnode; KzWindow *window; gint pos; KzBookmark *window_bookmark = KZ_BOOKMARK(node->data); - tabs = kz_bookmark_get_children(window_bookmark); if (!window_node) { @@ -425,18 +413,7 @@ window_node = g_list_next(window_node); } - /* tabs */ - for (tabnode = tabs; tabnode; tabnode = g_list_next(tabnode)) - { - GtkWidget *widget; - KzTabLabel *kztab; - KzBookmark *child = KZ_BOOKMARK(tabnode->data); - widget = kz_window_open_new_tab_at_tail(window, NULL); - kztab = KZ_TAB_LABEL(gtk_notebook_get_tab_label(GTK_NOTEBOOK(window->notebook), - widget)); - kz_tab_label_set_history(kztab, child); - } - g_list_free(tabs); + kz_window_restore_tabs(window, window_bookmark); pos = kz_bookmark_get_current(window_bookmark); gtk_notebook_set_current_page(GTK_NOTEBOOK(window->notebook), pos); } @@ -449,9 +426,12 @@ gtk_widget_destroy(GTK_WIDGET(window)); } - g_object_unref(tmp_bookmark); - kz_session_thaw(KZ_SESSION(priv->bookmarks->current_session)); - kz_bookmark_file_save(KZ_BOOKMARK_FILE(priv->bookmarks->current_session)); + /* if there is no window, create a window */ + if (!priv->window_list) + { + GtkWidget *window = kz_app_create_new_window(app, NULL); + gtk_widget_show(window); + } return GTK_WIDGET(priv->window_list->data); } Index: kazehakase/src/kz-tab-label.c diff -u kazehakase/src/kz-tab-label.c:1.90 kazehakase/src/kz-tab-label.c:1.91 --- kazehakase/src/kz-tab-label.c:1.90 Fri Jan 5 09:18:54 2007 +++ kazehakase/src/kz-tab-label.c Fri Jan 5 19:51:46 2007 @@ -1271,27 +1271,10 @@ void kz_tab_label_set_history (KzTabLabel *kztab, KzBookmark *history) { - GList *children, *node; - g_return_if_fail(KZ_IS_TAB_LABEL(kztab)); - - kz_bookmark_remove_all(kztab->history); - - children = kz_bookmark_get_children(history); - for (node =children; node; node = g_list_next(node)) - { - KzBookmark *new; - KzBookmark *child = KZ_BOOKMARK(node->data); - new = kz_bookmark_new_with_attrs(kz_bookmark_get_title(child), - kz_bookmark_get_link(child), - NULL); - kz_bookmark_set_last_visited(new, - kz_bookmark_get_last_visited(child)); - kz_bookmark_append(kztab->history, new); - g_object_unref(new); - } - g_list_free(children); + g_object_unref(kztab->history); + kztab->history = g_object_ref(history); if (kz_bookmark_get_lock(history)) { @@ -1311,8 +1294,6 @@ kz_embed_set_allow_javascript(KZ_EMBED(kztab->kzembed), FALSE); kz_tab_label_set_javascript(kztab, FALSE); } - kz_bookmark_set_current(kztab->history, - kz_bookmark_get_current(history)); kz_embed_set_history(kztab->kzembed, kztab->history); Index: kazehakase/src/kz-window.c diff -u kazehakase/src/kz-window.c:1.304 kazehakase/src/kz-window.c:1.305 --- kazehakase/src/kz-window.c:1.304 Thu Jan 4 23:05:05 2007 +++ kazehakase/src/kz-window.c Fri Jan 5 19:51:46 2007 @@ -829,41 +829,6 @@ GtkWidget * -kz_window_open_new_tab_at_tail (KzWindow *kz, const gchar *url) -{ - KzEmbed *kzembed; - KzTabLabel *kztab; - GNode *node; - KzWindowPrivate *priv; - g_return_val_if_fail(KZ_IS_WINDOW(kz), NULL); - - priv = KZ_WINDOW_GET_PRIVATE (kz); - kzembed = kz_window_create_embed(kz, url); - kztab = KZ_TAB_LABEL(kz_tab_label_new(kz, kzembed)); - - gtk_widget_show(GTK_WIDGET(kzembed)); - gtk_widget_show(GTK_WIDGET(kztab)); - kz_notebook_open_new_tab_at_pos(KZ_NOTEBOOK(kz->notebook), kzembed, kztab, -1); - kz_window_set_embed_callbacks(kz, kzembed); - - /* root node */ - if (!priv->tab_tree) - priv->tab_tree = g_node_new(NULL); - - /* insret node */ - node = g_node_new(kzembed); - g_node_append(priv->tab_tree, node); - - kz_bookmark_insert_before(kz->tabs, kztab->history, NULL); - - g_signal_emit(kz, kz_window_signals[APPEND_TAB_SIGNAL], - 0, kzembed, NULL); - - return GTK_WIDGET(kzembed); -} - - -GtkWidget * kz_window_open_new_tab_with_parent (KzWindow *kz, const gchar *url, GtkWidget *parent) { @@ -911,6 +876,50 @@ void +kz_window_restore_tabs (KzWindow *kz, KzBookmark *tabs) +{ + GList *childtabs, *tabnode; + KzWindowPrivate *priv; + g_return_if_fail(KZ_IS_WINDOW(kz)); + + priv = KZ_WINDOW_GET_PRIVATE (kz); + + /* remove old tab bookmark */ + kz_bookmark_remove(KZ_GET_CURRENT_SESSION, kz->tabs); + g_object_unref(kz->tabs); + kz->tabs = g_object_ref(tabs); + + childtabs = kz_bookmark_get_children(tabs); + /* tabs */ + for (tabnode = childtabs; tabnode; tabnode = g_list_next(tabnode)) + { + KzEmbed *kzembed; + KzTabLabel *kztab; + GNode *node; + kzembed = kz_window_create_embed(kz, NULL); + kztab = KZ_TAB_LABEL(kz_tab_label_new(kz, kzembed)); + KzBookmark *child = KZ_BOOKMARK(tabnode->data); + + gtk_widget_show(GTK_WIDGET(kzembed)); + gtk_widget_show(GTK_WIDGET(kztab)); + kz_notebook_open_new_tab_at_pos(KZ_NOTEBOOK(kz->notebook), kzembed, kztab, -1); + kz_window_set_embed_callbacks(kz, kzembed); + kz_tab_label_set_history(kztab, child); + + /* root node */ + if (!priv->tab_tree) + priv->tab_tree = g_node_new(NULL); + + /* insret node */ + node = g_node_new(kzembed); + g_node_append(priv->tab_tree, node); + + } + g_list_free(childtabs); +} + + +void kz_window_close_tab (KzWindow *kz, GtkWidget *widget) { g_return_if_fail(KZ_IS_WINDOW(kz)); @@ -1184,8 +1193,10 @@ if (kz->tabs) { + kz_session_freeze(KZ_SESSION(KZ_GET_CURRENT_SESSION)); kz_bookmark_remove(KZ_GET_CURRENT_SESSION, kz->tabs); g_object_unref(kz->tabs); + kz_session_thaw(KZ_SESSION(KZ_GET_CURRENT_SESSION)); kz->tabs = NULL; } if (kz->closed_tabs) Index: kazehakase/src/kz-window.h diff -u kazehakase/src/kz-window.h:1.79 kazehakase/src/kz-window.h:1.80 --- kazehakase/src/kz-window.h:1.79 Thu Jan 4 22:45:54 2007 +++ kazehakase/src/kz-window.h Fri Jan 5 19:51:46 2007 @@ -99,8 +99,6 @@ GtkWidget *kz_window_new (const gchar *url); GtkWidget *kz_window_open_new_tab (KzWindow *kz, const gchar *url); -GtkWidget *kz_window_open_new_tab_at_tail (KzWindow *kz, - const gchar *url); GtkWidget *kz_window_open_new_tab_with_parent (KzWindow *kz, const gchar *url, GtkWidget *parent); @@ -112,6 +110,8 @@ gint position); void kz_window_move_tab (KzWindow *kz, GtkWidget *widget); +void kz_window_restore_tabs (KzWindow *kz, + KzBookmark *tabs); void kz_window_load_url (KzWindow *kz, const gchar *url); void kz_window_store_state (KzWindow *kz);